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 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 325 | struct attr *newattr, *existattr; |
| 326 | struct attr_extra *newattre, *existattre; |
| 327 | bgp_peer_sort_t new_sort; |
| 328 | bgp_peer_sort_t exist_sort; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 329 | u_int32_t new_pref; |
| 330 | u_int32_t exist_pref; |
| 331 | u_int32_t new_med; |
| 332 | u_int32_t exist_med; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 333 | u_int32_t new_weight; |
| 334 | u_int32_t exist_weight; |
| 335 | uint32_t newm, existm; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 336 | struct in_addr new_id; |
| 337 | struct in_addr exist_id; |
| 338 | int new_cluster; |
| 339 | int exist_cluster; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 340 | int internal_as_route; |
| 341 | int confed_as_route; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 342 | int ret; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 343 | |
| 344 | *paths_eq = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 345 | |
| 346 | /* 0. Null check. */ |
| 347 | if (new == NULL) |
| 348 | return 0; |
| 349 | if (exist == NULL) |
| 350 | return 1; |
| 351 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 352 | newattr = new->attr; |
| 353 | existattr = exist->attr; |
| 354 | newattre = newattr->extra; |
| 355 | existattre = existattr->extra; |
| 356 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 357 | /* 1. Weight check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 358 | new_weight = exist_weight = 0; |
| 359 | |
| 360 | if (newattre) |
| 361 | new_weight = newattre->weight; |
| 362 | if (existattre) |
| 363 | exist_weight = existattre->weight; |
| 364 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 365 | if (new_weight > exist_weight) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 366 | return 1; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 367 | if (new_weight < exist_weight) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 368 | return 0; |
| 369 | |
| 370 | /* 2. Local preference check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 371 | new_pref = exist_pref = bgp->default_local_pref; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 372 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 373 | if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 374 | new_pref = newattr->local_pref; |
| 375 | if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 376 | exist_pref = existattr->local_pref; |
| 377 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 378 | if (new_pref > exist_pref) |
| 379 | return 1; |
| 380 | if (new_pref < exist_pref) |
| 381 | return 0; |
| 382 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 383 | /* 3. Local route check. We prefer: |
| 384 | * - BGP_ROUTE_STATIC |
| 385 | * - BGP_ROUTE_AGGREGATE |
| 386 | * - BGP_ROUTE_REDISTRIBUTE |
| 387 | */ |
| 388 | if (! (new->sub_type == BGP_ROUTE_NORMAL)) |
| 389 | return 1; |
| 390 | if (! (exist->sub_type == BGP_ROUTE_NORMAL)) |
| 391 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 392 | |
| 393 | /* 4. AS path length check. */ |
| 394 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 395 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 396 | int exist_hops = aspath_count_hops (existattr->aspath); |
| 397 | int exist_confeds = aspath_count_confeds (existattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 398 | |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 399 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
| 400 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 401 | int aspath_hops; |
| 402 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 403 | aspath_hops = aspath_count_hops (newattr->aspath); |
| 404 | aspath_hops += aspath_count_confeds (newattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 405 | |
| 406 | if ( aspath_hops < (exist_hops + exist_confeds)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 407 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 408 | if ( aspath_hops > (exist_hops + exist_confeds)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 409 | return 0; |
| 410 | } |
| 411 | else |
| 412 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 413 | int newhops = aspath_count_hops (newattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 414 | |
| 415 | if (newhops < exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 416 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 417 | if (newhops > exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 418 | return 0; |
| 419 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | /* 5. Origin check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 423 | if (newattr->origin < existattr->origin) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 424 | return 1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 425 | if (newattr->origin > existattr->origin) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 426 | return 0; |
| 427 | |
| 428 | /* 6. MED check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 429 | internal_as_route = (aspath_count_hops (newattr->aspath) == 0 |
| 430 | && aspath_count_hops (existattr->aspath) == 0); |
| 431 | confed_as_route = (aspath_count_confeds (newattr->aspath) > 0 |
| 432 | && aspath_count_confeds (existattr->aspath) > 0 |
| 433 | && aspath_count_hops (newattr->aspath) == 0 |
| 434 | && aspath_count_hops (existattr->aspath) == 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 435 | |
| 436 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 437 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 438 | && confed_as_route) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 439 | || aspath_cmp_left (newattr->aspath, existattr->aspath) |
| 440 | || aspath_cmp_left_confed (newattr->aspath, existattr->aspath) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 441 | || internal_as_route) |
| 442 | { |
| 443 | new_med = bgp_med_value (new->attr, bgp); |
| 444 | exist_med = bgp_med_value (exist->attr, bgp); |
| 445 | |
| 446 | if (new_med < exist_med) |
| 447 | return 1; |
| 448 | if (new_med > exist_med) |
| 449 | return 0; |
| 450 | } |
| 451 | |
| 452 | /* 7. Peer type check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 453 | new_sort = new->peer->sort; |
| 454 | exist_sort = exist->peer->sort; |
| 455 | |
| 456 | if (new_sort == BGP_PEER_EBGP |
| 457 | && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 458 | return 1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 459 | if (exist_sort == BGP_PEER_EBGP |
| 460 | && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 461 | return 0; |
| 462 | |
| 463 | /* 8. IGP metric check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 464 | newm = existm = 0; |
| 465 | |
| 466 | if (new->extra) |
| 467 | newm = new->extra->igpmetric; |
| 468 | if (exist->extra) |
| 469 | existm = exist->extra->igpmetric; |
| 470 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 471 | if (newm < existm) |
| 472 | ret = 1; |
| 473 | if (newm > existm) |
| 474 | ret = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 475 | |
| 476 | /* 9. Maximum path check. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 477 | if (newm == existm) |
| 478 | { |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 479 | if (new->peer->sort == BGP_PEER_IBGP) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 480 | { |
| 481 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) |
| 482 | *paths_eq = 1; |
| 483 | } |
| 484 | else if (new->peer->as == exist->peer->as) |
| 485 | *paths_eq = 1; |
| 486 | } |
| 487 | else |
| 488 | { |
| 489 | /* |
| 490 | * TODO: If unequal cost ibgp multipath is enabled we can |
| 491 | * mark the paths as equal here instead of returning |
| 492 | */ |
| 493 | return ret; |
| 494 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 495 | |
| 496 | /* 10. If both paths are external, prefer the path that was received |
| 497 | first (the oldest one). This step minimizes route-flap, since a |
| 498 | newer path won't displace an older one, even if it was the |
| 499 | preferred route based on the additional decision criteria below. */ |
| 500 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 501 | && new_sort == BGP_PEER_EBGP |
| 502 | && exist_sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 503 | { |
| 504 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
| 505 | return 1; |
| 506 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
| 507 | return 0; |
| 508 | } |
| 509 | |
| 510 | /* 11. Rourter-ID comparision. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 511 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 512 | new_id.s_addr = newattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 513 | else |
| 514 | new_id.s_addr = new->peer->remote_id.s_addr; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 515 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 516 | exist_id.s_addr = existattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 517 | else |
| 518 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 519 | |
| 520 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 521 | return 1; |
| 522 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 523 | return 0; |
| 524 | |
| 525 | /* 12. Cluster length comparision. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 526 | new_cluster = exist_cluster = 0; |
| 527 | |
| 528 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 529 | new_cluster = newattre->cluster->length; |
| 530 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 531 | exist_cluster = existattre->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 532 | |
| 533 | if (new_cluster < exist_cluster) |
| 534 | return 1; |
| 535 | if (new_cluster > exist_cluster) |
| 536 | return 0; |
| 537 | |
| 538 | /* 13. Neighbor address comparision. */ |
| 539 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 540 | |
| 541 | if (ret == 1) |
| 542 | return 0; |
| 543 | if (ret == -1) |
| 544 | return 1; |
| 545 | |
| 546 | return 1; |
| 547 | } |
| 548 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 549 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 550 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 551 | afi_t afi, safi_t safi) |
| 552 | { |
| 553 | struct bgp_filter *filter; |
| 554 | |
| 555 | filter = &peer->filter[afi][safi]; |
| 556 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 557 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 558 | if (BGP_DEBUG (update, UPDATE_IN) \ |
| 559 | && !(F ## _IN (filter))) \ |
| 560 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ |
| 561 | peer->host, #f, F ## _IN_NAME(filter)); |
| 562 | |
| 563 | if (DISTRIBUTE_IN_NAME (filter)) { |
| 564 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 565 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 566 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 567 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 568 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 569 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 570 | if (PREFIX_LIST_IN_NAME (filter)) { |
| 571 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 572 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 573 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 574 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 575 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 576 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 577 | if (FILTER_LIST_IN_NAME (filter)) { |
| 578 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 579 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 580 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 581 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 582 | } |
| 583 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 584 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 585 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 586 | } |
| 587 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 588 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 589 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 590 | afi_t afi, safi_t safi) |
| 591 | { |
| 592 | struct bgp_filter *filter; |
| 593 | |
| 594 | filter = &peer->filter[afi][safi]; |
| 595 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 596 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 597 | if (BGP_DEBUG (update, UPDATE_OUT) \ |
| 598 | && !(F ## _OUT (filter))) \ |
| 599 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ |
| 600 | peer->host, #f, F ## _OUT_NAME(filter)); |
| 601 | |
| 602 | if (DISTRIBUTE_OUT_NAME (filter)) { |
| 603 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 604 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 605 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 606 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 607 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 608 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 609 | if (PREFIX_LIST_OUT_NAME (filter)) { |
| 610 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 611 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 612 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 613 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 614 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 615 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 616 | if (FILTER_LIST_OUT_NAME (filter)) { |
| 617 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 618 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 619 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 620 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 621 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 622 | |
| 623 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 624 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 625 | } |
| 626 | |
| 627 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 628 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 629 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 630 | { |
| 631 | if (attr->community) |
| 632 | { |
| 633 | /* NO_ADVERTISE check. */ |
| 634 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 635 | return 1; |
| 636 | |
| 637 | /* NO_EXPORT check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 638 | if (peer->sort == BGP_PEER_EBGP && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 639 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 640 | return 1; |
| 641 | |
| 642 | /* NO_EXPORT_SUBCONFED check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 643 | if (peer->sort == BGP_PEER_EBGP |
| 644 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 645 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 646 | return 1; |
| 647 | } |
| 648 | return 0; |
| 649 | } |
| 650 | |
| 651 | /* Route reflection loop check. */ |
| 652 | static int |
| 653 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 654 | { |
| 655 | struct in_addr cluster_id; |
| 656 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 657 | if (attr->extra && attr->extra->cluster) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 658 | { |
| 659 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 660 | cluster_id = peer->bgp->cluster_id; |
| 661 | else |
| 662 | cluster_id = peer->bgp->router_id; |
| 663 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 664 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 665 | return 1; |
| 666 | } |
| 667 | return 0; |
| 668 | } |
| 669 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 670 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 671 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 672 | afi_t afi, safi_t safi) |
| 673 | { |
| 674 | struct bgp_filter *filter; |
| 675 | struct bgp_info info; |
| 676 | route_map_result_t ret; |
| 677 | |
| 678 | filter = &peer->filter[afi][safi]; |
| 679 | |
| 680 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 681 | if (peer->weight) |
| 682 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 683 | |
| 684 | /* Route map apply. */ |
| 685 | if (ROUTE_MAP_IN_NAME (filter)) |
| 686 | { |
| 687 | /* Duplicate current value to new strucutre for modification. */ |
| 688 | info.peer = peer; |
| 689 | info.attr = attr; |
| 690 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 691 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 692 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 693 | /* Apply BGP route map to the attribute. */ |
| 694 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 695 | |
| 696 | peer->rmap_type = 0; |
| 697 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 698 | if (ret == RMAP_DENYMATCH) |
| 699 | { |
| 700 | /* Free newly generated AS path and community by route-map. */ |
| 701 | bgp_attr_flush (attr); |
| 702 | return RMAP_DENY; |
| 703 | } |
| 704 | } |
| 705 | return RMAP_PERMIT; |
| 706 | } |
| 707 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 708 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 709 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 710 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 711 | { |
| 712 | struct bgp_filter *filter; |
| 713 | struct bgp_info info; |
| 714 | route_map_result_t ret; |
| 715 | |
| 716 | filter = &peer->filter[afi][safi]; |
| 717 | |
| 718 | /* Route map apply. */ |
| 719 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 720 | { |
| 721 | /* Duplicate current value to new strucutre for modification. */ |
| 722 | info.peer = rsclient; |
| 723 | info.attr = attr; |
| 724 | |
| 725 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 726 | |
| 727 | /* Apply BGP route map to the attribute. */ |
| 728 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 729 | |
| 730 | rsclient->rmap_type = 0; |
| 731 | |
| 732 | if (ret == RMAP_DENYMATCH) |
| 733 | { |
| 734 | /* Free newly generated AS path and community by route-map. */ |
| 735 | bgp_attr_flush (attr); |
| 736 | return RMAP_DENY; |
| 737 | } |
| 738 | } |
| 739 | return RMAP_PERMIT; |
| 740 | } |
| 741 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 742 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 743 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 744 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 745 | { |
| 746 | struct bgp_filter *filter; |
| 747 | struct bgp_info info; |
| 748 | route_map_result_t ret; |
| 749 | |
| 750 | filter = &rsclient->filter[afi][safi]; |
| 751 | |
| 752 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 753 | if (peer->weight) |
| 754 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 755 | |
| 756 | /* Route map apply. */ |
| 757 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 758 | { |
| 759 | /* Duplicate current value to new strucutre for modification. */ |
| 760 | info.peer = peer; |
| 761 | info.attr = attr; |
| 762 | |
| 763 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 764 | |
| 765 | /* Apply BGP route map to the attribute. */ |
| 766 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 767 | |
| 768 | peer->rmap_type = 0; |
| 769 | |
| 770 | if (ret == RMAP_DENYMATCH) |
| 771 | { |
| 772 | /* Free newly generated AS path and community by route-map. */ |
| 773 | bgp_attr_flush (attr); |
| 774 | return RMAP_DENY; |
| 775 | } |
| 776 | } |
| 777 | return RMAP_PERMIT; |
| 778 | } |
| 779 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 780 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 781 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 782 | struct attr *attr, afi_t afi, safi_t safi) |
| 783 | { |
| 784 | int ret; |
| 785 | char buf[SU_ADDRSTRLEN]; |
| 786 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 787 | struct peer *from; |
| 788 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 789 | int transparent; |
| 790 | int reflect; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 791 | struct attr *riattr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 792 | |
| 793 | from = ri->peer; |
| 794 | filter = &peer->filter[afi][safi]; |
| 795 | bgp = peer->bgp; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 796 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 797 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 798 | if (DISABLE_BGP_ANNOUNCE) |
| 799 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 800 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 801 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 802 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 803 | return 0; |
| 804 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 805 | /* Do not send back route to sender. */ |
| 806 | if (from == peer) |
| 807 | return 0; |
| 808 | |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 809 | /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */ |
| 810 | if (p->family == AF_INET |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 811 | && IPV4_ADDR_SAME(&peer->remote_id, &riattr->nexthop)) |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 812 | return 0; |
| 813 | #ifdef HAVE_IPV6 |
| 814 | if (p->family == AF_INET6 |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 815 | && IPV6_ADDR_SAME(&peer->remote_id, &riattr->nexthop)) |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 816 | return 0; |
| 817 | #endif |
| 818 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 819 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 820 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 821 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 822 | return 0; |
| 823 | |
| 824 | /* Default route check. */ |
| 825 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 826 | { |
| 827 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 828 | return 0; |
| 829 | #ifdef HAVE_IPV6 |
| 830 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 831 | return 0; |
| 832 | #endif /* HAVE_IPV6 */ |
| 833 | } |
| 834 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 835 | /* Transparency check. */ |
| 836 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 837 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 838 | transparent = 1; |
| 839 | else |
| 840 | transparent = 0; |
| 841 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 842 | /* If community is not disabled check the no-export and local. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 843 | if (! transparent && bgp_community_filter (peer, riattr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 844 | return 0; |
| 845 | |
| 846 | /* If the attribute has originator-id and it is same as remote |
| 847 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 848 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 849 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 850 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 851 | { |
| 852 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 853 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 854 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 855 | peer->host, |
| 856 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 857 | p->prefixlen); |
| 858 | return 0; |
| 859 | } |
| 860 | } |
| 861 | |
| 862 | /* ORF prefix-list filter check */ |
| 863 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 864 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 865 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 866 | if (peer->orf_plist[afi][safi]) |
| 867 | { |
| 868 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 869 | return 0; |
| 870 | } |
| 871 | |
| 872 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 873 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 874 | { |
| 875 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 876 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 877 | "%s [Update:SEND] %s/%d is filtered", |
| 878 | peer->host, |
| 879 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 880 | p->prefixlen); |
| 881 | return 0; |
| 882 | } |
| 883 | |
| 884 | #ifdef BGP_SEND_ASPATH_CHECK |
| 885 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 886 | if (aspath_loop_check (riattr->aspath, peer->as)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 887 | { |
| 888 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 889 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 890 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 891 | peer->host, peer->as); |
| 892 | return 0; |
| 893 | } |
| 894 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 895 | |
| 896 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 897 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 898 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 899 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 900 | { |
| 901 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 902 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 903 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 904 | peer->host, |
| 905 | bgp->confed_id); |
| 906 | return 0; |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | /* Route-Reflect check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 911 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 912 | reflect = 1; |
| 913 | else |
| 914 | reflect = 0; |
| 915 | |
| 916 | /* IBGP reflection check. */ |
| 917 | if (reflect) |
| 918 | { |
| 919 | /* A route from a Client peer. */ |
| 920 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 921 | { |
| 922 | /* Reflect to all the Non-Client peers and also to the |
| 923 | Client peers other than the originator. Originator check |
| 924 | is already done. So there is noting to do. */ |
| 925 | /* no bgp client-to-client reflection check. */ |
| 926 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 927 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 928 | return 0; |
| 929 | } |
| 930 | else |
| 931 | { |
| 932 | /* A route from a Non-client peer. Reflect to all other |
| 933 | clients. */ |
| 934 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 935 | return 0; |
| 936 | } |
| 937 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 938 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 939 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 940 | bgp_attr_dup (attr, riattr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 941 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 942 | /* If local-preference is not set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 943 | if ((peer->sort == BGP_PEER_IBGP |
| 944 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 945 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 946 | { |
| 947 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 948 | attr->local_pref = bgp->default_local_pref; |
| 949 | } |
| 950 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 951 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 952 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 953 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 954 | { |
| 955 | if (ri->peer != bgp->peer_self && ! transparent |
| 956 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 957 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 958 | } |
| 959 | |
| 960 | /* next-hop-set */ |
| 961 | if (transparent || reflect |
| 962 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 963 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 964 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 965 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 966 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 967 | #endif /* HAVE_IPV6 */ |
| 968 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 969 | { |
| 970 | /* NEXT-HOP Unchanged. */ |
| 971 | } |
| 972 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 973 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 974 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 975 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 976 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 977 | #endif /* HAVE_IPV6 */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 978 | || (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 979 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 980 | { |
| 981 | /* Set IPv4 nexthop. */ |
| 982 | if (p->family == AF_INET) |
| 983 | { |
| 984 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 985 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 986 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 987 | else |
| 988 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 989 | } |
| 990 | #ifdef HAVE_IPV6 |
| 991 | /* Set IPv6 nexthop. */ |
| 992 | if (p->family == AF_INET6) |
| 993 | { |
| 994 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 995 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 996 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 997 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 998 | } |
| 999 | #endif /* HAVE_IPV6 */ |
| 1000 | } |
| 1001 | |
| 1002 | #ifdef HAVE_IPV6 |
| 1003 | if (p->family == AF_INET6) |
| 1004 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1005 | /* Left nexthop_local unchanged if so configured. */ |
| 1006 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 1007 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1008 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1009 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 1010 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1011 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1012 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1013 | } |
| 1014 | |
| 1015 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 1016 | else |
| 1017 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1018 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1019 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1020 | |
| 1021 | /* Set link-local address for shared network peer. */ |
| 1022 | if (peer->shared_network |
| 1023 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 1024 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1025 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1026 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1027 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1028 | } |
| 1029 | |
| 1030 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 1031 | address.*/ |
| 1032 | if (reflect) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1033 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1034 | |
| 1035 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 1036 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1037 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1038 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1039 | |
| 1040 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1041 | #endif /* HAVE_IPV6 */ |
| 1042 | |
| 1043 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1044 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1045 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1046 | && aspath_private_as_check (attr->aspath)) |
| 1047 | attr->aspath = aspath_empty_get (); |
| 1048 | |
| 1049 | /* Route map & unsuppress-map apply. */ |
| 1050 | if (ROUTE_MAP_OUT_NAME (filter) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1051 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1052 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1053 | struct bgp_info info; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 1054 | struct attr dummy_attr; |
| 1055 | struct attr_extra dummy_extra; |
| 1056 | |
| 1057 | dummy_attr.extra = &dummy_extra; |
| 1058 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1059 | info.peer = peer; |
| 1060 | info.attr = attr; |
| 1061 | |
| 1062 | /* The route reflector is not allowed to modify the attributes |
| 1063 | of the reflected IBGP routes. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1064 | if (from->sort == BGP_PEER_IBGP |
| 1065 | && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1066 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1067 | bgp_attr_dup (&dummy_attr, attr); |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1068 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1069 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1070 | |
| 1071 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1072 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1073 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1074 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1075 | else |
| 1076 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1077 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1078 | peer->rmap_type = 0; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 1079 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1080 | if (ret == RMAP_DENYMATCH) |
| 1081 | { |
| 1082 | bgp_attr_flush (attr); |
| 1083 | return 0; |
| 1084 | } |
| 1085 | } |
| 1086 | return 1; |
| 1087 | } |
| 1088 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1089 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1090 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1091 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1092 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1093 | int ret; |
| 1094 | char buf[SU_ADDRSTRLEN]; |
| 1095 | struct bgp_filter *filter; |
| 1096 | struct bgp_info info; |
| 1097 | struct peer *from; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1098 | struct attr *riattr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1099 | |
| 1100 | from = ri->peer; |
| 1101 | filter = &rsclient->filter[afi][safi]; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1102 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1103 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 1104 | if (DISABLE_BGP_ANNOUNCE) |
| 1105 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1106 | |
| 1107 | /* Do not send back route to sender. */ |
| 1108 | if (from == rsclient) |
| 1109 | return 0; |
| 1110 | |
| 1111 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1112 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1113 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 1114 | return 0; |
| 1115 | |
| 1116 | /* Default route check. */ |
| 1117 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1118 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1119 | { |
| 1120 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1121 | return 0; |
| 1122 | #ifdef HAVE_IPV6 |
| 1123 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1124 | return 0; |
| 1125 | #endif /* HAVE_IPV6 */ |
| 1126 | } |
| 1127 | |
| 1128 | /* If the attribute has originator-id and it is same as remote |
| 1129 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1130 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1131 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1132 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1133 | &riattr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1134 | { |
| 1135 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1136 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1137 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1138 | rsclient->host, |
| 1139 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1140 | p->prefixlen); |
| 1141 | return 0; |
| 1142 | } |
| 1143 | } |
| 1144 | |
| 1145 | /* ORF prefix-list filter check */ |
| 1146 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1147 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1148 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1149 | if (rsclient->orf_plist[afi][safi]) |
| 1150 | { |
| 1151 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1152 | return 0; |
| 1153 | } |
| 1154 | |
| 1155 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1156 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1157 | { |
| 1158 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1159 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1160 | "%s [Update:SEND] %s/%d is filtered", |
| 1161 | rsclient->host, |
| 1162 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1163 | p->prefixlen); |
| 1164 | return 0; |
| 1165 | } |
| 1166 | |
| 1167 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1168 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1169 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1170 | { |
| 1171 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1172 | zlog (rsclient->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 1173 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1174 | rsclient->host, rsclient->as); |
| 1175 | return 0; |
| 1176 | } |
| 1177 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1178 | |
| 1179 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1180 | bgp_attr_dup (attr, riattr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1181 | |
| 1182 | /* next-hop-set */ |
| 1183 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1184 | #ifdef HAVE_IPV6 |
| 1185 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1186 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1187 | #endif /* HAVE_IPV6 */ |
| 1188 | ) |
| 1189 | { |
| 1190 | /* Set IPv4 nexthop. */ |
| 1191 | if (p->family == AF_INET) |
| 1192 | { |
| 1193 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1194 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1195 | IPV4_MAX_BYTELEN); |
| 1196 | else |
| 1197 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1198 | } |
| 1199 | #ifdef HAVE_IPV6 |
| 1200 | /* Set IPv6 nexthop. */ |
| 1201 | if (p->family == AF_INET6) |
| 1202 | { |
| 1203 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1204 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1205 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1206 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1207 | } |
| 1208 | #endif /* HAVE_IPV6 */ |
| 1209 | } |
| 1210 | |
| 1211 | #ifdef HAVE_IPV6 |
| 1212 | if (p->family == AF_INET6) |
| 1213 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1214 | struct attr_extra *attre = attr->extra; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 1215 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1216 | /* Left nexthop_local unchanged if so configured. */ |
| 1217 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1218 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1219 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1220 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1221 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1222 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1223 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1224 | } |
| 1225 | |
| 1226 | /* Default nexthop_local treatment for RS-Clients */ |
| 1227 | else |
| 1228 | { |
| 1229 | /* Announcer and RS-Client are both in the same network */ |
| 1230 | if (rsclient->shared_network && from->shared_network && |
| 1231 | (rsclient->ifindex == from->ifindex)) |
| 1232 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1233 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1234 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1235 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1236 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1237 | } |
| 1238 | |
| 1239 | /* Set link-local address for shared network peer. */ |
| 1240 | else if (rsclient->shared_network |
| 1241 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1242 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1243 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1244 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1245 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1246 | } |
| 1247 | |
| 1248 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1249 | attre->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1250 | } |
| 1251 | |
| 1252 | } |
| 1253 | #endif /* HAVE_IPV6 */ |
| 1254 | |
| 1255 | |
| 1256 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1257 | if (rsclient->sort == BGP_PEER_EBGP |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1258 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1259 | && aspath_private_as_check (attr->aspath)) |
| 1260 | attr->aspath = aspath_empty_get (); |
| 1261 | |
| 1262 | /* Route map & unsuppress-map apply. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1263 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1264 | { |
| 1265 | info.peer = rsclient; |
| 1266 | info.attr = attr; |
| 1267 | |
| 1268 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1269 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1270 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1271 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1272 | else |
| 1273 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1274 | |
| 1275 | rsclient->rmap_type = 0; |
| 1276 | |
| 1277 | if (ret == RMAP_DENYMATCH) |
| 1278 | { |
| 1279 | bgp_attr_flush (attr); |
| 1280 | return 0; |
| 1281 | } |
| 1282 | } |
| 1283 | |
| 1284 | return 1; |
| 1285 | } |
| 1286 | |
| 1287 | struct bgp_info_pair |
| 1288 | { |
| 1289 | struct bgp_info *old; |
| 1290 | struct bgp_info *new; |
| 1291 | }; |
| 1292 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1293 | static void |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1294 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
| 1295 | struct bgp_maxpaths_cfg *mpath_cfg, |
| 1296 | struct bgp_info_pair *result) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1297 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1298 | struct bgp_info *new_select; |
| 1299 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1300 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1301 | struct bgp_info *ri1; |
| 1302 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1303 | struct bgp_info *nextri = NULL; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1304 | int paths_eq, do_mpath; |
| 1305 | struct list mp_list; |
| 1306 | |
| 1307 | bgp_mp_list_init (&mp_list); |
| 1308 | do_mpath = (mpath_cfg->maxpaths_ebgp != BGP_DEFAULT_MAXPATHS || |
| 1309 | mpath_cfg->maxpaths_ibgp != BGP_DEFAULT_MAXPATHS); |
| 1310 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1311 | /* bgp deterministic-med */ |
| 1312 | new_select = NULL; |
| 1313 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1314 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1315 | { |
| 1316 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1317 | continue; |
| 1318 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1319 | continue; |
| 1320 | |
| 1321 | new_select = ri1; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1322 | if (do_mpath) |
| 1323 | bgp_mp_list_add (&mp_list, ri1); |
| 1324 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1325 | if (ri1->next) |
| 1326 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1327 | { |
| 1328 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1329 | continue; |
| 1330 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1331 | continue; |
| 1332 | |
| 1333 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1334 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1335 | ri2->attr->aspath)) |
| 1336 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1337 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
| 1338 | old_select = ri2; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1339 | if (bgp_info_cmp (bgp, ri2, new_select, &paths_eq)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1340 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1341 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1342 | new_select = ri2; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1343 | if (do_mpath && !paths_eq) |
| 1344 | { |
| 1345 | bgp_mp_list_clear (&mp_list); |
| 1346 | bgp_mp_list_add (&mp_list, ri2); |
| 1347 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1348 | } |
| 1349 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1350 | if (do_mpath && paths_eq) |
| 1351 | bgp_mp_list_add (&mp_list, ri2); |
| 1352 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1353 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1354 | } |
| 1355 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1356 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1357 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1358 | |
| 1359 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); |
| 1360 | bgp_mp_list_clear (&mp_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1361 | } |
| 1362 | |
| 1363 | /* Check old selected route and new selected route. */ |
| 1364 | old_select = NULL; |
| 1365 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1366 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1367 | { |
| 1368 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1369 | old_select = ri; |
| 1370 | |
| 1371 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1372 | { |
| 1373 | /* reap REMOVED routes, if needs be |
| 1374 | * selected route must stay for a while longer though |
| 1375 | */ |
| 1376 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1377 | && (ri != old_select)) |
| 1378 | bgp_info_reap (rn, ri); |
| 1379 | |
| 1380 | continue; |
| 1381 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1382 | |
| 1383 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1384 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1385 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1386 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1387 | continue; |
| 1388 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1389 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1390 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1391 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1392 | if (bgp_info_cmp (bgp, ri, new_select, &paths_eq)) |
| 1393 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1394 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1395 | bgp_mp_dmed_deselect (new_select); |
| 1396 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1397 | new_select = ri; |
| 1398 | |
| 1399 | if (do_mpath && !paths_eq) |
| 1400 | { |
| 1401 | bgp_mp_list_clear (&mp_list); |
| 1402 | bgp_mp_list_add (&mp_list, ri); |
| 1403 | } |
| 1404 | } |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1405 | else if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1406 | bgp_mp_dmed_deselect (ri); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1407 | |
| 1408 | if (do_mpath && paths_eq) |
| 1409 | bgp_mp_list_add (&mp_list, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1410 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1411 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1412 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1413 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1414 | 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] | 1415 | |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1416 | bgp_info_mpath_aggregate_update (new_select, old_select); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1417 | bgp_mp_list_clear (&mp_list); |
| 1418 | |
| 1419 | result->old = old_select; |
| 1420 | result->new = new_select; |
| 1421 | |
| 1422 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1423 | } |
| 1424 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1425 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1426 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1427 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1428 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1429 | struct prefix *p; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 1430 | struct attr attr; |
| 1431 | struct attr_extra extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1432 | |
| 1433 | p = &rn->p; |
| 1434 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1435 | /* Announce route to Established peer. */ |
| 1436 | if (peer->status != Established) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1437 | return 0; |
| 1438 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1439 | /* Address family configuration check. */ |
| 1440 | if (! peer->afc_nego[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1441 | return 0; |
| 1442 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1443 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1444 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1445 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1446 | return 0; |
| 1447 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 1448 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 1449 | attr.extra = &extra; |
| 1450 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1451 | switch (rn->table->type) |
| 1452 | { |
| 1453 | case BGP_TABLE_MAIN: |
| 1454 | /* Announcement to peer->conf. If the route is filtered, |
| 1455 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1456 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
| 1457 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1458 | else |
| 1459 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1460 | break; |
| 1461 | case BGP_TABLE_RSCLIENT: |
| 1462 | /* Announcement to peer->conf. If the route is filtered, |
| 1463 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1464 | if (selected && |
| 1465 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) |
| 1466 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
| 1467 | else |
| 1468 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1469 | break; |
| 1470 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 1471 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1472 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1473 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1474 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1475 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1476 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1477 | struct bgp *bgp; |
| 1478 | struct bgp_node *rn; |
| 1479 | afi_t afi; |
| 1480 | safi_t safi; |
| 1481 | }; |
| 1482 | |
| 1483 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1484 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1485 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1486 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1487 | struct bgp *bgp = pq->bgp; |
| 1488 | struct bgp_node *rn = pq->rn; |
| 1489 | afi_t afi = pq->afi; |
| 1490 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1491 | struct bgp_info *new_select; |
| 1492 | struct bgp_info *old_select; |
| 1493 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1494 | struct listnode *node, *nnode; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1495 | struct peer *rsclient = rn->table->owner; |
| 1496 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1497 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1498 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1499 | new_select = old_and_new.new; |
| 1500 | old_select = old_and_new.old; |
| 1501 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1502 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1503 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1504 | if (rsclient->group) |
| 1505 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1506 | { |
| 1507 | /* Nothing to do. */ |
| 1508 | if (old_select && old_select == new_select) |
| 1509 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1510 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1511 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1512 | if (old_select) |
| 1513 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
| 1514 | if (new_select) |
| 1515 | { |
| 1516 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1517 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1518 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
| 1519 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1520 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1521 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1522 | afi, safi); |
| 1523 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1524 | } |
| 1525 | else |
| 1526 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1527 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1528 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1529 | if (new_select) |
| 1530 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1531 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1532 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1533 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1534 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1535 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1536 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1537 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1538 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1539 | bgp_info_reap (rn, old_select); |
| 1540 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1541 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1542 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1543 | } |
| 1544 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1545 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1546 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1547 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1548 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1549 | struct bgp *bgp = pq->bgp; |
| 1550 | struct bgp_node *rn = pq->rn; |
| 1551 | afi_t afi = pq->afi; |
| 1552 | safi_t safi = pq->safi; |
| 1553 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1554 | struct bgp_info *new_select; |
| 1555 | struct bgp_info *old_select; |
| 1556 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1557 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1558 | struct peer *peer; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1559 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1560 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1561 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1562 | old_select = old_and_new.old; |
| 1563 | new_select = old_and_new.new; |
| 1564 | |
| 1565 | /* Nothing to do. */ |
| 1566 | if (old_select && old_select == new_select) |
| 1567 | { |
| 1568 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1569 | { |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1570 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
| 1571 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1572 | bgp_zebra_announce (p, old_select, bgp, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1573 | |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1574 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1575 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1576 | return WQ_SUCCESS; |
| 1577 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1578 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1579 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1580 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1581 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1582 | if (new_select) |
| 1583 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1584 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1585 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1586 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1587 | } |
| 1588 | |
| 1589 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1590 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1591 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1592 | { |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1593 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1594 | } |
| 1595 | |
| 1596 | /* FIB update. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1597 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
| 1598 | ! bgp_option_check (BGP_OPT_NO_FIB))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1599 | { |
| 1600 | if (new_select |
| 1601 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1602 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1603 | bgp_zebra_announce (p, new_select, bgp, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1604 | else |
| 1605 | { |
| 1606 | /* Withdraw the route from the kernel. */ |
| 1607 | if (old_select |
| 1608 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1609 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1610 | bgp_zebra_withdraw (p, old_select, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1611 | } |
| 1612 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1613 | |
| 1614 | /* Reap old select bgp_info, it it has been removed */ |
| 1615 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1616 | bgp_info_reap (rn, old_select); |
| 1617 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1618 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1619 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1620 | } |
| 1621 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1622 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1623 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1624 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1625 | struct bgp_process_queue *pq = data; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1626 | struct bgp_table *table = pq->rn->table; |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1627 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1628 | bgp_unlock (pq->bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1629 | bgp_unlock_node (pq->rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1630 | bgp_table_unlock (table); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1631 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1632 | } |
| 1633 | |
| 1634 | static void |
| 1635 | bgp_process_queue_init (void) |
| 1636 | { |
| 1637 | bm->process_main_queue |
| 1638 | = work_queue_new (bm->master, "process_main_queue"); |
| 1639 | bm->process_rsclient_queue |
| 1640 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1641 | |
| 1642 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1643 | { |
| 1644 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1645 | exit (1); |
| 1646 | } |
| 1647 | |
| 1648 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1649 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1650 | bm->process_main_queue->spec.max_retries = 0; |
| 1651 | bm->process_main_queue->spec.hold = 50; |
| 1652 | |
| 1653 | memcpy (bm->process_rsclient_queue, bm->process_main_queue, |
| 1654 | sizeof (struct work_queue *)); |
| 1655 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1656 | } |
| 1657 | |
| 1658 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1659 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1660 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1661 | struct bgp_process_queue *pqnode; |
| 1662 | |
| 1663 | /* already scheduled for processing? */ |
| 1664 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1665 | return; |
| 1666 | |
| 1667 | if ( (bm->process_main_queue == NULL) || |
| 1668 | (bm->process_rsclient_queue == NULL) ) |
| 1669 | bgp_process_queue_init (); |
| 1670 | |
| 1671 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1672 | sizeof (struct bgp_process_queue)); |
| 1673 | if (!pqnode) |
| 1674 | return; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1675 | |
| 1676 | /* all unlocked in bgp_processq_del */ |
| 1677 | bgp_table_lock (rn->table); |
| 1678 | pqnode->rn = bgp_lock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1679 | pqnode->bgp = bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1680 | bgp_lock (bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1681 | pqnode->afi = afi; |
| 1682 | pqnode->safi = safi; |
| 1683 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1684 | switch (rn->table->type) |
| 1685 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1686 | case BGP_TABLE_MAIN: |
| 1687 | work_queue_add (bm->process_main_queue, pqnode); |
| 1688 | break; |
| 1689 | case BGP_TABLE_RSCLIENT: |
| 1690 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1691 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1692 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1693 | |
| 1694 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1695 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1696 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1697 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1698 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1699 | { |
| 1700 | struct peer *peer; |
| 1701 | |
| 1702 | peer = THREAD_ARG (thread); |
| 1703 | peer->t_pmax_restart = NULL; |
| 1704 | |
| 1705 | if (BGP_DEBUG (events, EVENTS)) |
| 1706 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1707 | peer->host); |
| 1708 | |
| 1709 | peer_clear (peer); |
| 1710 | |
| 1711 | return 0; |
| 1712 | } |
| 1713 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1714 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1715 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1716 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1717 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1718 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1719 | return 0; |
| 1720 | |
| 1721 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1722 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1723 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1724 | && ! always) |
| 1725 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1726 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1727 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1728 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1729 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1730 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1731 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1732 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1733 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1734 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1735 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1736 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1737 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1738 | |
| 1739 | if (safi == SAFI_MPLS_VPN) |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 1740 | safi = SAFI_MPLS_LABELED_VPN; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1741 | |
| 1742 | ndata[0] = (afi >> 8); |
| 1743 | ndata[1] = afi; |
| 1744 | ndata[2] = safi; |
| 1745 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1746 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1747 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1748 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1749 | |
| 1750 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1751 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1752 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1753 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1754 | |
| 1755 | /* restart timer start */ |
| 1756 | if (peer->pmax_restart[afi][safi]) |
| 1757 | { |
| 1758 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1759 | |
| 1760 | if (BGP_DEBUG (events, EVENTS)) |
| 1761 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1762 | peer->host, peer->v_pmax_restart); |
| 1763 | |
| 1764 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1765 | peer->v_pmax_restart); |
| 1766 | } |
| 1767 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1768 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1769 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1770 | else |
| 1771 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1772 | |
| 1773 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1774 | { |
| 1775 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1776 | && ! always) |
| 1777 | return 0; |
| 1778 | |
| 1779 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1780 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1781 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1782 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1783 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1784 | } |
| 1785 | else |
| 1786 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1787 | return 0; |
| 1788 | } |
| 1789 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1790 | /* Unconditionally remove the route from the RIB, without taking |
| 1791 | * damping into consideration (eg, because the session went down) |
| 1792 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1793 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1794 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1795 | afi_t afi, safi_t safi) |
| 1796 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1797 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1798 | |
| 1799 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1800 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1801 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1802 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1803 | } |
| 1804 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1805 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1806 | 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] | 1807 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1808 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1809 | int status = BGP_DAMP_NONE; |
| 1810 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1811 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1812 | * the bgp_info in the RIB for historical reference. |
| 1813 | */ |
| 1814 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1815 | && peer->sort == BGP_PEER_EBGP) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1816 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1817 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1818 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1819 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1820 | return; |
| 1821 | } |
| 1822 | |
| 1823 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1824 | } |
| 1825 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1826 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1827 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1828 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1829 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1830 | { |
| 1831 | struct bgp_node *rn; |
| 1832 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 1833 | struct attr new_attr; |
| 1834 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1835 | struct attr *attr_new; |
| 1836 | struct attr *attr_new2; |
| 1837 | struct bgp_info *ri; |
| 1838 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1839 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1840 | char buf[SU_ADDRSTRLEN]; |
| 1841 | |
| 1842 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1843 | if (peer == rsclient) |
| 1844 | return; |
| 1845 | |
| 1846 | bgp = peer->bgp; |
| 1847 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1848 | |
| 1849 | /* Check previously received route. */ |
| 1850 | for (ri = rn->info; ri; ri = ri->next) |
| 1851 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1852 | break; |
| 1853 | |
| 1854 | /* AS path loop check. */ |
| 1855 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) |
| 1856 | { |
| 1857 | reason = "as-path contains our own AS;"; |
| 1858 | goto filtered; |
| 1859 | } |
| 1860 | |
| 1861 | /* Route reflector originator ID check. */ |
| 1862 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1863 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1864 | { |
| 1865 | reason = "originator is us;"; |
| 1866 | goto filtered; |
| 1867 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1868 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 1869 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1870 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1871 | |
| 1872 | /* Apply export policy. */ |
| 1873 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1874 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1875 | { |
| 1876 | reason = "export-policy;"; |
| 1877 | goto filtered; |
| 1878 | } |
| 1879 | |
| 1880 | attr_new2 = bgp_attr_intern (&new_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1881 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1882 | /* Apply import policy. */ |
| 1883 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1884 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1885 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1886 | |
| 1887 | reason = "import-policy;"; |
| 1888 | goto filtered; |
| 1889 | } |
| 1890 | |
| 1891 | attr_new = bgp_attr_intern (&new_attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1892 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1893 | |
| 1894 | /* IPv4 unicast next hop check. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1895 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1896 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1897 | /* 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] | 1898 | if (new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1899 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1900 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1901 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1902 | |
| 1903 | reason = "martian next-hop;"; |
| 1904 | goto filtered; |
| 1905 | } |
| 1906 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 1907 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1908 | /* If the update is implicit withdraw. */ |
| 1909 | if (ri) |
| 1910 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1911 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1912 | |
| 1913 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1914 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1915 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1916 | { |
| 1917 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1918 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1919 | |
| 1920 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1921 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1922 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1923 | peer->host, |
| 1924 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1925 | p->prefixlen, rsclient->host); |
| 1926 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1927 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1928 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1929 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1930 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1931 | } |
| 1932 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1933 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 1934 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 1935 | bgp_info_restore (rn, ri); |
| 1936 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1937 | /* Received Logging. */ |
| 1938 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1939 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1940 | peer->host, |
| 1941 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1942 | p->prefixlen, rsclient->host); |
| 1943 | |
| 1944 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1945 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1946 | |
| 1947 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1948 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1949 | ri->attr = attr_new; |
| 1950 | |
| 1951 | /* Update MPLS tag. */ |
| 1952 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1953 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1954 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1955 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1956 | |
| 1957 | /* Process change. */ |
| 1958 | bgp_process (bgp, rn, afi, safi); |
| 1959 | bgp_unlock_node (rn); |
| 1960 | |
| 1961 | return; |
| 1962 | } |
| 1963 | |
| 1964 | /* Received Logging. */ |
| 1965 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1966 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1967 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1968 | peer->host, |
| 1969 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1970 | p->prefixlen, rsclient->host); |
| 1971 | } |
| 1972 | |
| 1973 | /* Make new BGP info. */ |
| 1974 | new = bgp_info_new (); |
| 1975 | new->type = type; |
| 1976 | new->sub_type = sub_type; |
| 1977 | new->peer = peer; |
| 1978 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1979 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1980 | |
| 1981 | /* Update MPLS tag. */ |
| 1982 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1983 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1984 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1985 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1986 | |
| 1987 | /* Register new BGP information. */ |
| 1988 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1989 | |
| 1990 | /* route_node_get lock */ |
| 1991 | bgp_unlock_node (rn); |
| 1992 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1993 | /* Process change. */ |
| 1994 | bgp_process (bgp, rn, afi, safi); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 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); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 2012 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2013 | return; |
| 2014 | } |
| 2015 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2016 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2017 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 2018 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 2019 | struct prefix_rd *prd, u_char *tag) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2020 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2021 | struct bgp_node *rn; |
| 2022 | struct bgp_info *ri; |
| 2023 | char buf[SU_ADDRSTRLEN]; |
| 2024 | |
| 2025 | if (rsclient == peer) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2026 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2027 | |
| 2028 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 2029 | |
| 2030 | /* Lookup withdrawn route. */ |
| 2031 | for (ri = rn->info; ri; ri = ri->next) |
| 2032 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2033 | break; |
| 2034 | |
| 2035 | /* Withdraw specified route from routing table. */ |
| 2036 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2037 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2038 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2039 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2040 | "%s Can't find the route %s/%d", peer->host, |
| 2041 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2042 | p->prefixlen); |
| 2043 | |
| 2044 | /* Unlock bgp_node_get() lock. */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2045 | bgp_unlock_node (rn); |
| 2046 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2047 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2048 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2049 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2050 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2051 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2052 | { |
| 2053 | int ret; |
| 2054 | int aspath_loop_count = 0; |
| 2055 | struct bgp_node *rn; |
| 2056 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 2057 | struct attr new_attr; |
| 2058 | struct attr_extra new_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2059 | struct attr *attr_new; |
| 2060 | struct bgp_info *ri; |
| 2061 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2062 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2063 | char buf[SU_ADDRSTRLEN]; |
| 2064 | |
| 2065 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2066 | 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] | 2067 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2068 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2069 | Adj-RIBs-In. */ |
| 2070 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2071 | && peer != bgp->peer_self && ! soft_reconfig) |
| 2072 | bgp_adj_in_set (rn, peer, attr); |
| 2073 | |
| 2074 | /* Check previously received route. */ |
| 2075 | for (ri = rn->info; ri; ri = ri->next) |
| 2076 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2077 | break; |
| 2078 | |
| 2079 | /* AS path local-as loop check. */ |
| 2080 | if (peer->change_local_as) |
| 2081 | { |
| 2082 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 2083 | aspath_loop_count = 1; |
| 2084 | |
| 2085 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 2086 | { |
| 2087 | reason = "as-path contains our own AS;"; |
| 2088 | goto filtered; |
| 2089 | } |
| 2090 | } |
| 2091 | |
| 2092 | /* AS path loop check. */ |
| 2093 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 2094 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2095 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2096 | > peer->allowas_in[afi][safi])) |
| 2097 | { |
| 2098 | reason = "as-path contains our own AS;"; |
| 2099 | goto filtered; |
| 2100 | } |
| 2101 | |
| 2102 | /* Route reflector originator ID check. */ |
| 2103 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2104 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2105 | { |
| 2106 | reason = "originator is us;"; |
| 2107 | goto filtered; |
| 2108 | } |
| 2109 | |
| 2110 | /* Route reflector cluster ID check. */ |
| 2111 | if (bgp_cluster_filter (peer, attr)) |
| 2112 | { |
| 2113 | reason = "reflected from the same cluster;"; |
| 2114 | goto filtered; |
| 2115 | } |
| 2116 | |
| 2117 | /* Apply incoming filter. */ |
| 2118 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2119 | { |
| 2120 | reason = "filter;"; |
| 2121 | goto filtered; |
| 2122 | } |
| 2123 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 2124 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2125 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2126 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 2127 | /* Apply incoming route-map. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2128 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2129 | { |
| 2130 | reason = "route-map;"; |
| 2131 | goto filtered; |
| 2132 | } |
| 2133 | |
| 2134 | /* IPv4 unicast next hop check. */ |
| 2135 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2136 | { |
| 2137 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2138 | discard it. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2139 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 |
Denis Ovsienko | 8e80bdf | 2011-08-05 18:52:52 +0400 | [diff] [blame] | 2140 | && ! bgp_nexthop_onlink (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2141 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2142 | { |
| 2143 | reason = "non-connected next-hop;"; |
| 2144 | goto filtered; |
| 2145 | } |
| 2146 | |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2147 | /* 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] | 2148 | must not be my own address. */ |
Jorge Boncompte [DTI2] | 10f9bf3 | 2012-05-07 16:52:52 +0000 | [diff] [blame] | 2149 | if (new_attr.nexthop.s_addr == 0 |
| 2150 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) |
| 2151 | || bgp_nexthop_self (&new_attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2152 | { |
| 2153 | reason = "martian next-hop;"; |
| 2154 | goto filtered; |
| 2155 | } |
| 2156 | } |
| 2157 | |
| 2158 | attr_new = bgp_attr_intern (&new_attr); |
| 2159 | |
| 2160 | /* If the update is implicit withdraw. */ |
| 2161 | if (ri) |
| 2162 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2163 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2164 | |
| 2165 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2166 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2167 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2168 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2169 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2170 | |
| 2171 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2172 | && peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2173 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2174 | { |
| 2175 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2176 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2177 | peer->host, |
| 2178 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2179 | p->prefixlen); |
| 2180 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2181 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2182 | { |
| 2183 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2184 | bgp_process (bgp, rn, afi, safi); |
| 2185 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2186 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2187 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2188 | { |
| 2189 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2190 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2191 | "%s rcvd %s/%d...duplicate ignored", |
| 2192 | peer->host, |
| 2193 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2194 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2195 | |
| 2196 | /* graceful restart STALE flag unset. */ |
| 2197 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2198 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2199 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2200 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2201 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2202 | } |
| 2203 | |
| 2204 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2205 | bgp_attr_unintern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 2206 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2207 | return 0; |
| 2208 | } |
| 2209 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2210 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2211 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2212 | { |
| 2213 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2214 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2215 | peer->host, |
| 2216 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2217 | p->prefixlen); |
| 2218 | bgp_info_restore (rn, ri); |
| 2219 | } |
| 2220 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2221 | /* Received Logging. */ |
| 2222 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2223 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2224 | peer->host, |
| 2225 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2226 | p->prefixlen); |
| 2227 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2228 | /* graceful restart STALE flag unset. */ |
| 2229 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2230 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2231 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2232 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2233 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2234 | |
| 2235 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2236 | * only if update is accepted, they'll increment below. |
| 2237 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2238 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2239 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2240 | /* Update bgp route dampening information. */ |
| 2241 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2242 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2243 | { |
| 2244 | /* This is implicit withdraw so we should update dampening |
| 2245 | information. */ |
| 2246 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2247 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2248 | } |
| 2249 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2250 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2251 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2252 | ri->attr = attr_new; |
| 2253 | |
| 2254 | /* Update MPLS tag. */ |
| 2255 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2256 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2257 | |
| 2258 | /* Update bgp route dampening information. */ |
| 2259 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2260 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2261 | { |
| 2262 | /* Now we do normal update dampening. */ |
| 2263 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2264 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2265 | { |
| 2266 | bgp_unlock_node (rn); |
| 2267 | return 0; |
| 2268 | } |
| 2269 | } |
| 2270 | |
| 2271 | /* Nexthop reachability check. */ |
| 2272 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2273 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2274 | && (peer->sort == BGP_PEER_IBGP |
| 2275 | || peer->sort == BGP_PEER_CONFED |
| 2276 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2277 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2278 | { |
| 2279 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2280 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2281 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2282 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2283 | } |
| 2284 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2285 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2286 | |
| 2287 | /* Process change. */ |
| 2288 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2289 | |
| 2290 | bgp_process (bgp, rn, afi, safi); |
| 2291 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 2292 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2293 | return 0; |
| 2294 | } |
| 2295 | |
| 2296 | /* Received Logging. */ |
| 2297 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2298 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2299 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2300 | peer->host, |
| 2301 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2302 | p->prefixlen); |
| 2303 | } |
| 2304 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2305 | /* Make new BGP info. */ |
| 2306 | new = bgp_info_new (); |
| 2307 | new->type = type; |
| 2308 | new->sub_type = sub_type; |
| 2309 | new->peer = peer; |
| 2310 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2311 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2312 | |
| 2313 | /* Update MPLS tag. */ |
| 2314 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2315 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2316 | |
| 2317 | /* Nexthop reachability check. */ |
| 2318 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2319 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2320 | && (peer->sort == BGP_PEER_IBGP |
| 2321 | || peer->sort == BGP_PEER_CONFED |
| 2322 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2323 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2324 | { |
| 2325 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2326 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2327 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2328 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2329 | } |
| 2330 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2331 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2332 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2333 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2334 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2335 | |
| 2336 | /* Register new BGP information. */ |
| 2337 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2338 | |
| 2339 | /* route_node_get lock */ |
| 2340 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 2341 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2342 | /* If maximum prefix count is configured and current prefix |
| 2343 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2344 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2345 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2346 | |
| 2347 | /* Process change. */ |
| 2348 | bgp_process (bgp, rn, afi, safi); |
| 2349 | |
| 2350 | return 0; |
| 2351 | |
| 2352 | /* This BGP update is filtered. Log the reason then update BGP |
| 2353 | entry. */ |
| 2354 | filtered: |
| 2355 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2356 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2357 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2358 | peer->host, |
| 2359 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2360 | p->prefixlen, reason); |
| 2361 | |
| 2362 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2363 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2364 | |
| 2365 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 2366 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2367 | return 0; |
| 2368 | } |
| 2369 | |
| 2370 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2371 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2372 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2373 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2374 | { |
| 2375 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2376 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2377 | struct bgp *bgp; |
| 2378 | int ret; |
| 2379 | |
| 2380 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2381 | soft_reconfig); |
| 2382 | |
| 2383 | bgp = peer->bgp; |
| 2384 | |
| 2385 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2386 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2387 | { |
| 2388 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2389 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2390 | sub_type, prd, tag); |
| 2391 | } |
| 2392 | |
| 2393 | return ret; |
| 2394 | } |
| 2395 | |
| 2396 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2397 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2398 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2399 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2400 | { |
| 2401 | struct bgp *bgp; |
| 2402 | char buf[SU_ADDRSTRLEN]; |
| 2403 | struct bgp_node *rn; |
| 2404 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2405 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2406 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2407 | |
| 2408 | bgp = peer->bgp; |
| 2409 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2410 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2411 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2412 | { |
| 2413 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2414 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2415 | } |
| 2416 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2417 | /* Logging. */ |
| 2418 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2419 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2420 | peer->host, |
| 2421 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2422 | p->prefixlen); |
| 2423 | |
| 2424 | /* Lookup node. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2425 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2426 | |
| 2427 | /* If peer is soft reconfiguration enabled. Record input packet for |
| 2428 | further calculation. */ |
| 2429 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2430 | && peer != bgp->peer_self) |
| 2431 | bgp_adj_in_unset (rn, peer); |
| 2432 | |
| 2433 | /* Lookup withdrawn route. */ |
| 2434 | for (ri = rn->info; ri; ri = ri->next) |
| 2435 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2436 | break; |
| 2437 | |
| 2438 | /* Withdraw specified route from routing table. */ |
| 2439 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2440 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2441 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2442 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2443 | "%s Can't find the route %s/%d", peer->host, |
| 2444 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2445 | p->prefixlen); |
| 2446 | |
| 2447 | /* Unlock bgp_node_get() lock. */ |
| 2448 | bgp_unlock_node (rn); |
| 2449 | |
| 2450 | return 0; |
| 2451 | } |
| 2452 | |
| 2453 | void |
| 2454 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2455 | { |
| 2456 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 2457 | struct attr attr; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2458 | struct aspath *aspath = { 0 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2459 | struct prefix p; |
| 2460 | struct bgp_info binfo; |
| 2461 | struct peer *from; |
| 2462 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2463 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2464 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2465 | return; |
| 2466 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2467 | bgp = peer->bgp; |
| 2468 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2469 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2470 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2471 | aspath = attr.aspath; |
| 2472 | attr.local_pref = bgp->default_local_pref; |
| 2473 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2474 | |
| 2475 | if (afi == AFI_IP) |
| 2476 | str2prefix ("0.0.0.0/0", &p); |
| 2477 | #ifdef HAVE_IPV6 |
| 2478 | else if (afi == AFI_IP6) |
| 2479 | { |
Jorge Boncompte [DTI2] | 6182d65 | 2012-05-07 16:53:02 +0000 | [diff] [blame] | 2480 | struct attr_extra *ae = attr.extra; |
| 2481 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2482 | str2prefix ("::/0", &p); |
| 2483 | |
| 2484 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2485 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2486 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2487 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2488 | |
| 2489 | /* If the peer is on shared nextwork and we have link-local |
| 2490 | nexthop set it. */ |
| 2491 | if (peer->shared_network |
| 2492 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2493 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2494 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2495 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2496 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2497 | } |
| 2498 | } |
| 2499 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2500 | |
| 2501 | if (peer->default_rmap[afi][safi].name) |
| 2502 | { |
| 2503 | binfo.peer = bgp->peer_self; |
| 2504 | binfo.attr = &attr; |
| 2505 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2506 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
| 2507 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2508 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
| 2509 | RMAP_BGP, &binfo); |
| 2510 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2511 | bgp->peer_self->rmap_type = 0; |
| 2512 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2513 | if (ret == RMAP_DENYMATCH) |
| 2514 | { |
| 2515 | bgp_attr_flush (&attr); |
| 2516 | withdraw = 1; |
| 2517 | } |
| 2518 | } |
| 2519 | |
| 2520 | if (withdraw) |
| 2521 | { |
| 2522 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2523 | bgp_default_withdraw_send (peer, afi, safi); |
| 2524 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2525 | } |
| 2526 | else |
| 2527 | { |
| 2528 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2529 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2530 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2531 | |
| 2532 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2533 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2534 | } |
| 2535 | |
| 2536 | static void |
| 2537 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2538 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2539 | { |
| 2540 | struct bgp_node *rn; |
| 2541 | struct bgp_info *ri; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 2542 | struct attr attr; |
| 2543 | struct attr_extra extra; |
| 2544 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2545 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2546 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2547 | |
| 2548 | if (safi != SAFI_MPLS_VPN |
| 2549 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2550 | bgp_default_originate (peer, afi, safi, 0); |
| 2551 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 2552 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 2553 | attr.extra = &extra; |
| 2554 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2555 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2556 | for (ri = rn->info; ri; ri = ri->next) |
| 2557 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2558 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2559 | if ( (rsclient) ? |
| 2560 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2561 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2562 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2563 | else |
| 2564 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2565 | } |
| 2566 | } |
| 2567 | |
| 2568 | void |
| 2569 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2570 | { |
| 2571 | struct bgp_node *rn; |
| 2572 | struct bgp_table *table; |
| 2573 | |
| 2574 | if (peer->status != Established) |
| 2575 | return; |
| 2576 | |
| 2577 | if (! peer->afc_nego[afi][safi]) |
| 2578 | return; |
| 2579 | |
| 2580 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2581 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2582 | return; |
| 2583 | |
| 2584 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2585 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2586 | else |
| 2587 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2588 | rn = bgp_route_next(rn)) |
| 2589 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2590 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2591 | |
| 2592 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2593 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2594 | } |
| 2595 | |
| 2596 | void |
| 2597 | bgp_announce_route_all (struct peer *peer) |
| 2598 | { |
| 2599 | afi_t afi; |
| 2600 | safi_t safi; |
| 2601 | |
| 2602 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2603 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2604 | bgp_announce_route (peer, afi, safi); |
| 2605 | } |
| 2606 | |
| 2607 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2608 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2609 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2610 | { |
| 2611 | struct bgp_node *rn; |
| 2612 | struct bgp_adj_in *ain; |
| 2613 | |
| 2614 | if (! table) |
| 2615 | table = rsclient->bgp->rib[afi][safi]; |
| 2616 | |
| 2617 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2618 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2619 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2620 | struct bgp_info *ri = rn->info; |
| 2621 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2622 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2623 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, |
| 2624 | (bgp_info_extra_get (ri))->tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2625 | } |
| 2626 | } |
| 2627 | |
| 2628 | void |
| 2629 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2630 | { |
| 2631 | struct bgp_table *table; |
| 2632 | struct bgp_node *rn; |
| 2633 | |
| 2634 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2635 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2636 | |
| 2637 | else |
| 2638 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2639 | rn = bgp_route_next (rn)) |
| 2640 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2641 | { |
| 2642 | struct prefix_rd prd; |
| 2643 | prd.family = AF_UNSPEC; |
| 2644 | prd.prefixlen = 64; |
| 2645 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2646 | |
| 2647 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); |
| 2648 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 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, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2653 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2667 | struct bgp_info *ri = rn->info; |
| 2668 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2669 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2670 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2671 | prd, (bgp_info_extra_get (ri))->tag, 1); |
| 2672 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2673 | if (ret < 0) |
| 2674 | { |
| 2675 | bgp_unlock_node (rn); |
| 2676 | return; |
| 2677 | } |
| 2678 | continue; |
| 2679 | } |
| 2680 | } |
| 2681 | } |
| 2682 | |
| 2683 | void |
| 2684 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2685 | { |
| 2686 | struct bgp_node *rn; |
| 2687 | struct bgp_table *table; |
| 2688 | |
| 2689 | if (peer->status != Established) |
| 2690 | return; |
| 2691 | |
| 2692 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2693 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2694 | else |
| 2695 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2696 | rn = bgp_route_next (rn)) |
| 2697 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2698 | { |
| 2699 | struct prefix_rd prd; |
| 2700 | prd.family = AF_UNSPEC; |
| 2701 | prd.prefixlen = 64; |
| 2702 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2703 | |
| 2704 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); |
| 2705 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2706 | } |
| 2707 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2708 | |
| 2709 | struct bgp_clear_node_queue |
| 2710 | { |
| 2711 | struct bgp_node *rn; |
| 2712 | enum bgp_clear_route_type purpose; |
| 2713 | }; |
| 2714 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2715 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2716 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2717 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2718 | struct bgp_clear_node_queue *cnq = data; |
| 2719 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2720 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2721 | struct bgp_info *ri; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2722 | afi_t afi = rn->table->afi; |
| 2723 | safi_t safi = rn->table->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2724 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2725 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2726 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2727 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2728 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2729 | { |
| 2730 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2731 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2732 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2733 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2734 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2735 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2736 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2737 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2738 | break; |
| 2739 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2740 | return WQ_SUCCESS; |
| 2741 | } |
| 2742 | |
| 2743 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2744 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2745 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2746 | struct bgp_clear_node_queue *cnq = data; |
| 2747 | struct bgp_node *rn = cnq->rn; |
| 2748 | struct bgp_table *table = rn->table; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2749 | |
| 2750 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2751 | bgp_table_unlock (table); |
| 2752 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2753 | } |
| 2754 | |
| 2755 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2756 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2757 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2758 | struct peer *peer = wq->spec.data; |
| 2759 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2760 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2761 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2762 | |
| 2763 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2764 | } |
| 2765 | |
| 2766 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2767 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2768 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2769 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2770 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2771 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2772 | #undef CLEAR_QUEUE_NAME_LEN |
| 2773 | |
| 2774 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2775 | { |
| 2776 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2777 | exit (1); |
| 2778 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2779 | peer->clear_node_queue->spec.hold = 10; |
| 2780 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2781 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2782 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2783 | peer->clear_node_queue->spec.max_retries = 0; |
| 2784 | |
| 2785 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2786 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2787 | } |
| 2788 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2789 | static void |
| 2790 | 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] | 2791 | struct bgp_table *table, struct peer *rsclient, |
| 2792 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2793 | { |
| 2794 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2795 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2796 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2797 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2798 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2799 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2800 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2801 | if (! table) |
| 2802 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2803 | |
| 2804 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2805 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2806 | struct bgp_info *ri; |
| 2807 | struct bgp_adj_in *ain; |
| 2808 | struct bgp_adj_out *aout; |
| 2809 | |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2810 | if (rn->info == NULL) |
| 2811 | continue; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2812 | |
| 2813 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2814 | * queued for every clearing peer, regardless of whether it is |
| 2815 | * relevant to the peer at hand. |
| 2816 | * |
| 2817 | * Overview: There are 3 different indices which need to be |
| 2818 | * scrubbed, potentially, when a peer is removed: |
| 2819 | * |
| 2820 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2821 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2822 | * 3 other routes visible by the peer's adj-out index |
| 2823 | * |
| 2824 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2825 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2826 | * adj-outs at our leisure. |
| 2827 | * |
| 2828 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2829 | * invisible via RIB index before peer session is allowed to be |
| 2830 | * brought back up. So one needs to know when such a 'search' is |
| 2831 | * complete. |
| 2832 | * |
| 2833 | * Ideally: |
| 2834 | * |
| 2835 | * - there'd be a single global queue or a single RIB walker |
| 2836 | * - rather than tracking which route_nodes still need to be |
| 2837 | * examined on a peer basis, we'd track which peers still |
| 2838 | * aren't cleared |
| 2839 | * |
| 2840 | * Given that our per-peer prefix-counts now should be reliable, |
| 2841 | * this may actually be achievable. It doesn't seem to be a huge |
| 2842 | * problem at this time, |
| 2843 | */ |
| 2844 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2845 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2846 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2847 | struct bgp_clear_node_queue *cnq; |
| 2848 | |
| 2849 | /* both unlocked in bgp_clear_node_queue_del */ |
| 2850 | bgp_table_lock (rn->table); |
| 2851 | bgp_lock_node (rn); |
| 2852 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2853 | sizeof (struct bgp_clear_node_queue)); |
| 2854 | cnq->rn = rn; |
| 2855 | cnq->purpose = purpose; |
| 2856 | work_queue_add (peer->clear_node_queue, cnq); |
| 2857 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2858 | } |
| 2859 | |
| 2860 | for (ain = rn->adj_in; ain; ain = ain->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2861 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2862 | { |
| 2863 | bgp_adj_in_remove (rn, ain); |
| 2864 | bgp_unlock_node (rn); |
| 2865 | break; |
| 2866 | } |
| 2867 | for (aout = rn->adj_out; aout; aout = aout->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2868 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2869 | { |
| 2870 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2871 | bgp_unlock_node (rn); |
| 2872 | break; |
| 2873 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2874 | } |
| 2875 | return; |
| 2876 | } |
| 2877 | |
| 2878 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2879 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2880 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2881 | { |
| 2882 | struct bgp_node *rn; |
| 2883 | struct bgp_table *table; |
| 2884 | struct peer *rsclient; |
| 2885 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2886 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2887 | if (peer->clear_node_queue == NULL) |
| 2888 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2889 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2890 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 2891 | * Idle until it receives a Clearing_Completed event. This protects |
| 2892 | * against peers which flap faster than we can we clear, which could |
| 2893 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2894 | * |
| 2895 | * a) race with routes from the new session being installed before |
| 2896 | * clear_route_node visits the node (to delete the route of that |
| 2897 | * peer) |
| 2898 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 2899 | * on the process_main queue. Fast-flapping could cause that queue |
| 2900 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2901 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2902 | if (!peer->clear_node_queue->thread) |
| 2903 | peer_lock (peer); /* bgp_clear_node_complete */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2904 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2905 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2906 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2907 | case BGP_CLEAR_ROUTE_NORMAL: |
| 2908 | if (safi != SAFI_MPLS_VPN) |
| 2909 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 2910 | else |
| 2911 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2912 | rn = bgp_route_next (rn)) |
| 2913 | if ((table = rn->info) != NULL) |
| 2914 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 2915 | |
| 2916 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 2917 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 2918 | PEER_FLAG_RSERVER_CLIENT)) |
| 2919 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 2920 | break; |
| 2921 | |
| 2922 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
| 2923 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 2924 | break; |
| 2925 | |
| 2926 | default: |
| 2927 | assert (0); |
| 2928 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2929 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2930 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2931 | /* If no routes were cleared, nothing was added to workqueue, the |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2932 | * completion function won't be run by workqueue code - call it here. |
| 2933 | * XXX: Actually, this assumption doesn't hold, see |
| 2934 | * bgp_clear_route_table(), we queue all non-empty nodes. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2935 | * |
| 2936 | * Additionally, there is a presumption in FSM that clearing is only |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2937 | * really needed if peer state is Established - peers in |
| 2938 | * pre-Established states shouldn't have any route-update state |
| 2939 | * associated with them (in or out). |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2940 | * |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2941 | * We still can get here in pre-Established though, through |
| 2942 | * peer_delete -> bgp_fsm_change_status, so this is a useful sanity |
| 2943 | * check to ensure the assumption above holds. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2944 | * |
| 2945 | * At some future point, this check could be move to the top of the |
| 2946 | * function, and do a quick early-return when state is |
| 2947 | * pre-Established, avoiding above list and table scans. Once we're |
| 2948 | * sure it is safe.. |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2949 | */ |
| 2950 | if (!peer->clear_node_queue->thread) |
| 2951 | bgp_clear_node_complete (peer->clear_node_queue); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2952 | } |
| 2953 | |
| 2954 | void |
| 2955 | bgp_clear_route_all (struct peer *peer) |
| 2956 | { |
| 2957 | afi_t afi; |
| 2958 | safi_t safi; |
| 2959 | |
| 2960 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2961 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2962 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2963 | } |
| 2964 | |
| 2965 | void |
| 2966 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2967 | { |
| 2968 | struct bgp_table *table; |
| 2969 | struct bgp_node *rn; |
| 2970 | struct bgp_adj_in *ain; |
| 2971 | |
| 2972 | table = peer->bgp->rib[afi][safi]; |
| 2973 | |
| 2974 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2975 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 2976 | if (ain->peer == peer) |
| 2977 | { |
| 2978 | bgp_adj_in_remove (rn, ain); |
| 2979 | bgp_unlock_node (rn); |
| 2980 | break; |
| 2981 | } |
| 2982 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2983 | |
| 2984 | void |
| 2985 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2986 | { |
| 2987 | struct bgp_node *rn; |
| 2988 | struct bgp_info *ri; |
| 2989 | struct bgp_table *table; |
| 2990 | |
| 2991 | table = peer->bgp->rib[afi][safi]; |
| 2992 | |
| 2993 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2994 | { |
| 2995 | for (ri = rn->info; ri; ri = ri->next) |
| 2996 | if (ri->peer == peer) |
| 2997 | { |
| 2998 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2999 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3000 | break; |
| 3001 | } |
| 3002 | } |
| 3003 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3004 | |
| 3005 | /* Delete all kernel routes. */ |
| 3006 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3007 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3008 | { |
| 3009 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3010 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3011 | struct bgp_node *rn; |
| 3012 | struct bgp_table *table; |
| 3013 | struct bgp_info *ri; |
| 3014 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3015 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3016 | { |
| 3017 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 3018 | |
| 3019 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3020 | for (ri = rn->info; ri; ri = ri->next) |
| 3021 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3022 | && ri->type == ZEBRA_ROUTE_BGP |
| 3023 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3024 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3025 | |
| 3026 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 3027 | |
| 3028 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3029 | for (ri = rn->info; ri; ri = ri->next) |
| 3030 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3031 | && ri->type == ZEBRA_ROUTE_BGP |
| 3032 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3033 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3034 | } |
| 3035 | } |
| 3036 | |
| 3037 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3038 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3039 | { |
| 3040 | vty_reset (); |
| 3041 | bgp_zclient_reset (); |
| 3042 | access_list_reset (); |
| 3043 | prefix_list_reset (); |
| 3044 | } |
| 3045 | |
| 3046 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3047 | value. */ |
| 3048 | int |
| 3049 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 3050 | { |
| 3051 | u_char *pnt; |
| 3052 | u_char *lim; |
| 3053 | struct prefix p; |
| 3054 | int psize; |
| 3055 | int ret; |
| 3056 | |
| 3057 | /* Check peer status. */ |
| 3058 | if (peer->status != Established) |
| 3059 | return 0; |
| 3060 | |
| 3061 | pnt = packet->nlri; |
| 3062 | lim = pnt + packet->length; |
| 3063 | |
| 3064 | for (; pnt < lim; pnt += psize) |
| 3065 | { |
| 3066 | /* Clear prefix structure. */ |
| 3067 | memset (&p, 0, sizeof (struct prefix)); |
| 3068 | |
| 3069 | /* Fetch prefix length. */ |
| 3070 | p.prefixlen = *pnt++; |
| 3071 | p.family = afi2family (packet->afi); |
| 3072 | |
| 3073 | /* Already checked in nlri_sanity_check(). We do double check |
| 3074 | here. */ |
| 3075 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 3076 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 3077 | return -1; |
| 3078 | |
| 3079 | /* Packet size overflow check. */ |
| 3080 | psize = PSIZE (p.prefixlen); |
| 3081 | |
| 3082 | /* When packet overflow occur return immediately. */ |
| 3083 | if (pnt + psize > lim) |
| 3084 | return -1; |
| 3085 | |
| 3086 | /* Fetch prefix from NLRI packet. */ |
| 3087 | memcpy (&p.u.prefix, pnt, psize); |
| 3088 | |
| 3089 | /* Check address. */ |
| 3090 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3091 | { |
| 3092 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3093 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3094 | /* |
| 3095 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 3096 | * If a BGP router receives an UPDATE message with a |
| 3097 | * semantically incorrect NLRI field, in which a prefix is |
| 3098 | * semantically incorrect (eg. an unexpected multicast IP |
| 3099 | * address), it should ignore the prefix. |
| 3100 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3101 | zlog (peer->log, LOG_ERR, |
| 3102 | "IPv4 unicast NLRI is multicast address %s", |
| 3103 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3104 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3105 | return -1; |
| 3106 | } |
| 3107 | } |
| 3108 | |
| 3109 | #ifdef HAVE_IPV6 |
| 3110 | /* Check address. */ |
| 3111 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3112 | { |
| 3113 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3114 | { |
| 3115 | char buf[BUFSIZ]; |
| 3116 | |
| 3117 | zlog (peer->log, LOG_WARNING, |
| 3118 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 3119 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3120 | |
| 3121 | continue; |
| 3122 | } |
| 3123 | } |
| 3124 | #endif /* HAVE_IPV6 */ |
| 3125 | |
| 3126 | /* Normal process. */ |
| 3127 | if (attr) |
| 3128 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3129 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3130 | else |
| 3131 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3132 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3133 | |
| 3134 | /* Address family configuration mismatch or maximum-prefix count |
| 3135 | overflow. */ |
| 3136 | if (ret < 0) |
| 3137 | return -1; |
| 3138 | } |
| 3139 | |
| 3140 | /* Packet length consistency check. */ |
| 3141 | if (pnt != lim) |
| 3142 | return -1; |
| 3143 | |
| 3144 | return 0; |
| 3145 | } |
| 3146 | |
| 3147 | /* NLRI encode syntax check routine. */ |
| 3148 | int |
| 3149 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 3150 | bgp_size_t length) |
| 3151 | { |
| 3152 | u_char *end; |
| 3153 | u_char prefixlen; |
| 3154 | int psize; |
| 3155 | |
| 3156 | end = pnt + length; |
| 3157 | |
| 3158 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 3159 | syntactic validity. If the field is syntactically incorrect, |
| 3160 | then the Error Subcode is set to Invalid Network Field. */ |
| 3161 | |
| 3162 | while (pnt < end) |
| 3163 | { |
| 3164 | prefixlen = *pnt++; |
| 3165 | |
| 3166 | /* Prefix length check. */ |
| 3167 | if ((afi == AFI_IP && prefixlen > 32) |
| 3168 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 3169 | { |
| 3170 | plog_err (peer->log, |
| 3171 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 3172 | peer->host, prefixlen); |
| 3173 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3174 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3175 | return -1; |
| 3176 | } |
| 3177 | |
| 3178 | /* Packet size overflow check. */ |
| 3179 | psize = PSIZE (prefixlen); |
| 3180 | |
| 3181 | if (pnt + psize > end) |
| 3182 | { |
| 3183 | plog_err (peer->log, |
| 3184 | "%s [Error] Update packet error" |
| 3185 | " (prefix data overflow prefix size is %d)", |
| 3186 | peer->host, psize); |
| 3187 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3188 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3189 | return -1; |
| 3190 | } |
| 3191 | |
| 3192 | pnt += psize; |
| 3193 | } |
| 3194 | |
| 3195 | /* Packet length consistency check. */ |
| 3196 | if (pnt != end) |
| 3197 | { |
| 3198 | plog_err (peer->log, |
| 3199 | "%s [Error] Update packet error" |
| 3200 | " (prefix length mismatch with total length)", |
| 3201 | peer->host); |
| 3202 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3203 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3204 | return -1; |
| 3205 | } |
| 3206 | return 0; |
| 3207 | } |
| 3208 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3209 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3210 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3211 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3212 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3213 | } |
| 3214 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3215 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3216 | bgp_static_free (struct bgp_static *bgp_static) |
| 3217 | { |
| 3218 | if (bgp_static->rmap.name) |
| 3219 | free (bgp_static->rmap.name); |
| 3220 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3221 | } |
| 3222 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3223 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3224 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3225 | struct prefix *p, afi_t afi, safi_t safi) |
| 3226 | { |
| 3227 | struct bgp_node *rn; |
| 3228 | struct bgp_info *ri; |
| 3229 | |
| 3230 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3231 | |
| 3232 | /* Check selected route and self inserted route. */ |
| 3233 | for (ri = rn->info; ri; ri = ri->next) |
| 3234 | if (ri->peer == bgp->peer_self |
| 3235 | && ri->type == ZEBRA_ROUTE_BGP |
| 3236 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3237 | break; |
| 3238 | |
| 3239 | /* Withdraw static BGP route from routing table. */ |
| 3240 | if (ri) |
| 3241 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3242 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3243 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3244 | } |
| 3245 | |
| 3246 | /* Unlock bgp_node_lookup. */ |
| 3247 | bgp_unlock_node (rn); |
| 3248 | } |
| 3249 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3250 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3251 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3252 | struct bgp_static *bgp_static, |
| 3253 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3254 | { |
| 3255 | struct bgp_node *rn; |
| 3256 | struct bgp_info *ri; |
| 3257 | struct bgp_info *new; |
| 3258 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3259 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3260 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 3261 | struct attr new_attr; |
| 3262 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3263 | struct bgp *bgp; |
| 3264 | int ret; |
| 3265 | char buf[SU_ADDRSTRLEN]; |
| 3266 | |
| 3267 | bgp = rsclient->bgp; |
| 3268 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3269 | assert (bgp_static); |
| 3270 | if (!bgp_static) |
| 3271 | return; |
| 3272 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3273 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3274 | |
| 3275 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3276 | |
| 3277 | attr.nexthop = bgp_static->igpnexthop; |
| 3278 | attr.med = bgp_static->igpmetric; |
| 3279 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3280 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3281 | if (bgp_static->atomic) |
| 3282 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3283 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3284 | /* Apply network route-map for export to this rsclient. */ |
| 3285 | if (bgp_static->rmap.name) |
| 3286 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3287 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3288 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3289 | info.attr = &attr_tmp; |
| 3290 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3291 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3292 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3293 | |
| 3294 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3295 | |
| 3296 | rsclient->rmap_type = 0; |
| 3297 | |
| 3298 | if (ret == RMAP_DENYMATCH) |
| 3299 | { |
| 3300 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3301 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3302 | |
| 3303 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3304 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3305 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3306 | bgp_attr_extra_free (&attr); |
| 3307 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3308 | return; |
| 3309 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3310 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3311 | } |
| 3312 | else |
| 3313 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 3314 | |
| 3315 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3316 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3317 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3318 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3319 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3320 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3321 | == RMAP_DENY) |
| 3322 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3323 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3324 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3325 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3326 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3327 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3328 | p->prefixlen, rsclient->host); |
| 3329 | |
| 3330 | bgp->peer_self->rmap_type = 0; |
| 3331 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3332 | bgp_attr_unintern (&attr_new); |
| 3333 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3334 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3335 | |
| 3336 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3337 | |
| 3338 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3339 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3340 | |
| 3341 | bgp->peer_self->rmap_type = 0; |
| 3342 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3343 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3344 | attr_new = bgp_attr_intern (&new_attr); |
| 3345 | |
| 3346 | for (ri = rn->info; ri; ri = ri->next) |
| 3347 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3348 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3349 | break; |
| 3350 | |
| 3351 | if (ri) |
| 3352 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3353 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3354 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3355 | { |
| 3356 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3357 | bgp_attr_unintern (&attr_new); |
| 3358 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3359 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3360 | return; |
| 3361 | } |
| 3362 | else |
| 3363 | { |
| 3364 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3365 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3366 | |
| 3367 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3368 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3369 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3370 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3371 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3372 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3373 | |
| 3374 | /* Process change. */ |
| 3375 | bgp_process (bgp, rn, afi, safi); |
| 3376 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3377 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3378 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3379 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3380 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3381 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3382 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3383 | /* Make new BGP info. */ |
| 3384 | new = bgp_info_new (); |
| 3385 | new->type = ZEBRA_ROUTE_BGP; |
| 3386 | new->sub_type = BGP_ROUTE_STATIC; |
| 3387 | new->peer = bgp->peer_self; |
| 3388 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3389 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3390 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3391 | |
| 3392 | /* Register new BGP information. */ |
| 3393 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3394 | |
| 3395 | /* route_node_get lock */ |
| 3396 | bgp_unlock_node (rn); |
| 3397 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3398 | /* Process change. */ |
| 3399 | bgp_process (bgp, rn, afi, safi); |
| 3400 | |
| 3401 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3402 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3403 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3404 | } |
| 3405 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3406 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3407 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3408 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3409 | { |
| 3410 | struct bgp_node *rn; |
| 3411 | struct bgp_info *ri; |
| 3412 | struct bgp_info *new; |
| 3413 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3414 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3415 | struct attr *attr_new; |
| 3416 | int ret; |
| 3417 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3418 | assert (bgp_static); |
| 3419 | if (!bgp_static) |
| 3420 | return; |
| 3421 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3422 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3423 | |
| 3424 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3425 | |
| 3426 | attr.nexthop = bgp_static->igpnexthop; |
| 3427 | attr.med = bgp_static->igpmetric; |
| 3428 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3429 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3430 | if (bgp_static->atomic) |
| 3431 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3432 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3433 | /* Apply route-map. */ |
| 3434 | if (bgp_static->rmap.name) |
| 3435 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3436 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3437 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3438 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3439 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3440 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3441 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3442 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3443 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3444 | bgp->peer_self->rmap_type = 0; |
| 3445 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3446 | if (ret == RMAP_DENYMATCH) |
| 3447 | { |
| 3448 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3449 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3450 | |
| 3451 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3452 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3453 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3454 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3455 | return; |
| 3456 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3457 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3458 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3459 | else |
| 3460 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3461 | |
| 3462 | for (ri = rn->info; ri; ri = ri->next) |
| 3463 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3464 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3465 | break; |
| 3466 | |
| 3467 | if (ri) |
| 3468 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3469 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3470 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3471 | { |
| 3472 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3473 | bgp_attr_unintern (&attr_new); |
| 3474 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3475 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3476 | return; |
| 3477 | } |
| 3478 | else |
| 3479 | { |
| 3480 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3481 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3482 | |
| 3483 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3484 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3485 | bgp_info_restore(rn, ri); |
| 3486 | else |
| 3487 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3488 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3489 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3490 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3491 | |
| 3492 | /* Process change. */ |
| 3493 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3494 | bgp_process (bgp, rn, afi, safi); |
| 3495 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3496 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3497 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3498 | return; |
| 3499 | } |
| 3500 | } |
| 3501 | |
| 3502 | /* Make new BGP info. */ |
| 3503 | new = bgp_info_new (); |
| 3504 | new->type = ZEBRA_ROUTE_BGP; |
| 3505 | new->sub_type = BGP_ROUTE_STATIC; |
| 3506 | new->peer = bgp->peer_self; |
| 3507 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3508 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3509 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3510 | |
| 3511 | /* Aggregate address increment. */ |
| 3512 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3513 | |
| 3514 | /* Register new BGP information. */ |
| 3515 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3516 | |
| 3517 | /* route_node_get lock */ |
| 3518 | bgp_unlock_node (rn); |
| 3519 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3520 | /* Process change. */ |
| 3521 | bgp_process (bgp, rn, afi, safi); |
| 3522 | |
| 3523 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3524 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3525 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3526 | } |
| 3527 | |
| 3528 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3529 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3530 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3531 | { |
| 3532 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3533 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3534 | |
| 3535 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3536 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3537 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3538 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3539 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3540 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3541 | } |
| 3542 | } |
| 3543 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3544 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3545 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3546 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3547 | { |
| 3548 | struct bgp_node *rn; |
| 3549 | struct bgp_info *new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3550 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3551 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3552 | |
| 3553 | /* Make new BGP info. */ |
| 3554 | new = bgp_info_new (); |
| 3555 | new->type = ZEBRA_ROUTE_BGP; |
| 3556 | new->sub_type = BGP_ROUTE_STATIC; |
| 3557 | new->peer = bgp->peer_self; |
| 3558 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 3559 | SET_FLAG (new->flags, BGP_INFO_VALID); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3560 | new->uptime = bgp_clock (); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3561 | new->extra = bgp_info_extra_new(); |
| 3562 | memcpy (new->extra->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3563 | |
| 3564 | /* Aggregate address increment. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3565 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3566 | |
| 3567 | /* Register new BGP information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3568 | bgp_info_add (rn, new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3569 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3570 | /* route_node_get lock */ |
| 3571 | bgp_unlock_node (rn); |
| 3572 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3573 | /* Process change. */ |
| 3574 | bgp_process (bgp, rn, afi, safi); |
| 3575 | } |
| 3576 | |
| 3577 | void |
| 3578 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3579 | safi_t safi) |
| 3580 | { |
| 3581 | struct bgp_node *rn; |
| 3582 | struct bgp_info *ri; |
| 3583 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3584 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3585 | |
| 3586 | /* Check selected route and self inserted route. */ |
| 3587 | for (ri = rn->info; ri; ri = ri->next) |
| 3588 | if (ri->peer == bgp->peer_self |
| 3589 | && ri->type == ZEBRA_ROUTE_BGP |
| 3590 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3591 | break; |
| 3592 | |
| 3593 | /* Withdraw static BGP route from routing table. */ |
| 3594 | if (ri) |
| 3595 | { |
| 3596 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3597 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3598 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3599 | } |
| 3600 | |
| 3601 | /* Unlock bgp_node_lookup. */ |
| 3602 | bgp_unlock_node (rn); |
| 3603 | } |
| 3604 | |
| 3605 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3606 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3607 | { |
| 3608 | struct bgp_static *bgp_static; |
| 3609 | struct bgp *bgp; |
| 3610 | struct bgp_node *rn; |
| 3611 | struct prefix *p; |
| 3612 | |
| 3613 | bgp = rsclient->bgp; |
| 3614 | |
| 3615 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3616 | if ((bgp_static = rn->info) != NULL) |
| 3617 | { |
| 3618 | p = &rn->p; |
| 3619 | |
| 3620 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3621 | afi, safi); |
| 3622 | } |
| 3623 | } |
| 3624 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3625 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3626 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3627 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3628 | { |
| 3629 | struct bgp_node *rn; |
| 3630 | struct bgp_info *ri; |
| 3631 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3632 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3633 | |
| 3634 | /* Check selected route and self inserted route. */ |
| 3635 | for (ri = rn->info; ri; ri = ri->next) |
| 3636 | if (ri->peer == bgp->peer_self |
| 3637 | && ri->type == ZEBRA_ROUTE_BGP |
| 3638 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3639 | break; |
| 3640 | |
| 3641 | /* Withdraw static BGP route from routing table. */ |
| 3642 | if (ri) |
| 3643 | { |
| 3644 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3645 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3646 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3647 | } |
| 3648 | |
| 3649 | /* Unlock bgp_node_lookup. */ |
| 3650 | bgp_unlock_node (rn); |
| 3651 | } |
| 3652 | |
| 3653 | /* Configure static BGP network. When user don't run zebra, static |
| 3654 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3655 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3656 | 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] | 3657 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3658 | { |
| 3659 | int ret; |
| 3660 | struct prefix p; |
| 3661 | struct bgp_static *bgp_static; |
| 3662 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3663 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3664 | |
| 3665 | /* Convert IP prefix string to struct prefix. */ |
| 3666 | ret = str2prefix (ip_str, &p); |
| 3667 | if (! ret) |
| 3668 | { |
| 3669 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3670 | return CMD_WARNING; |
| 3671 | } |
| 3672 | #ifdef HAVE_IPV6 |
| 3673 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3674 | { |
| 3675 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3676 | VTY_NEWLINE); |
| 3677 | return CMD_WARNING; |
| 3678 | } |
| 3679 | #endif /* HAVE_IPV6 */ |
| 3680 | |
| 3681 | apply_mask (&p); |
| 3682 | |
| 3683 | /* Set BGP static route configuration. */ |
| 3684 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3685 | |
| 3686 | if (rn->info) |
| 3687 | { |
| 3688 | /* Configuration change. */ |
| 3689 | bgp_static = rn->info; |
| 3690 | |
| 3691 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3692 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 3693 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3694 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3695 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3696 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3697 | if (rmap) |
| 3698 | { |
| 3699 | if (bgp_static->rmap.name) |
| 3700 | free (bgp_static->rmap.name); |
| 3701 | bgp_static->rmap.name = strdup (rmap); |
| 3702 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3703 | } |
| 3704 | else |
| 3705 | { |
| 3706 | if (bgp_static->rmap.name) |
| 3707 | free (bgp_static->rmap.name); |
| 3708 | bgp_static->rmap.name = NULL; |
| 3709 | bgp_static->rmap.map = NULL; |
| 3710 | bgp_static->valid = 0; |
| 3711 | } |
| 3712 | bgp_unlock_node (rn); |
| 3713 | } |
| 3714 | else |
| 3715 | { |
| 3716 | /* New configuration. */ |
| 3717 | bgp_static = bgp_static_new (); |
| 3718 | bgp_static->backdoor = backdoor; |
| 3719 | bgp_static->valid = 0; |
| 3720 | bgp_static->igpmetric = 0; |
| 3721 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3722 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3723 | if (rmap) |
| 3724 | { |
| 3725 | if (bgp_static->rmap.name) |
| 3726 | free (bgp_static->rmap.name); |
| 3727 | bgp_static->rmap.name = strdup (rmap); |
| 3728 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3729 | } |
| 3730 | rn->info = bgp_static; |
| 3731 | } |
| 3732 | |
| 3733 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3734 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3735 | { |
| 3736 | bgp_static->valid = 1; |
| 3737 | |
| 3738 | if (need_update) |
| 3739 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3740 | |
| 3741 | if (! bgp_static->backdoor) |
| 3742 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3743 | } |
| 3744 | |
| 3745 | return CMD_SUCCESS; |
| 3746 | } |
| 3747 | |
| 3748 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3749 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3750 | 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] | 3751 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3752 | { |
| 3753 | int ret; |
| 3754 | struct prefix p; |
| 3755 | struct bgp_static *bgp_static; |
| 3756 | struct bgp_node *rn; |
| 3757 | |
| 3758 | /* Convert IP prefix string to struct prefix. */ |
| 3759 | ret = str2prefix (ip_str, &p); |
| 3760 | if (! ret) |
| 3761 | { |
| 3762 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3763 | return CMD_WARNING; |
| 3764 | } |
| 3765 | #ifdef HAVE_IPV6 |
| 3766 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3767 | { |
| 3768 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3769 | VTY_NEWLINE); |
| 3770 | return CMD_WARNING; |
| 3771 | } |
| 3772 | #endif /* HAVE_IPV6 */ |
| 3773 | |
| 3774 | apply_mask (&p); |
| 3775 | |
| 3776 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3777 | if (! rn) |
| 3778 | { |
| 3779 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3780 | VTY_NEWLINE); |
| 3781 | return CMD_WARNING; |
| 3782 | } |
| 3783 | |
| 3784 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3785 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3786 | /* Update BGP RIB. */ |
| 3787 | if (! bgp_static->backdoor) |
| 3788 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3789 | |
| 3790 | /* Clear configuration. */ |
| 3791 | bgp_static_free (bgp_static); |
| 3792 | rn->info = NULL; |
| 3793 | bgp_unlock_node (rn); |
| 3794 | bgp_unlock_node (rn); |
| 3795 | |
| 3796 | return CMD_SUCCESS; |
| 3797 | } |
| 3798 | |
| 3799 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3800 | instance. */ |
| 3801 | void |
| 3802 | bgp_static_delete (struct bgp *bgp) |
| 3803 | { |
| 3804 | afi_t afi; |
| 3805 | safi_t safi; |
| 3806 | struct bgp_node *rn; |
| 3807 | struct bgp_node *rm; |
| 3808 | struct bgp_table *table; |
| 3809 | struct bgp_static *bgp_static; |
| 3810 | |
| 3811 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3812 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3813 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3814 | if (rn->info != NULL) |
| 3815 | { |
| 3816 | if (safi == SAFI_MPLS_VPN) |
| 3817 | { |
| 3818 | table = rn->info; |
| 3819 | |
| 3820 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3821 | { |
| 3822 | bgp_static = rn->info; |
| 3823 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3824 | AFI_IP, SAFI_MPLS_VPN, |
| 3825 | (struct prefix_rd *)&rn->p, |
| 3826 | bgp_static->tag); |
| 3827 | bgp_static_free (bgp_static); |
| 3828 | rn->info = NULL; |
| 3829 | bgp_unlock_node (rn); |
| 3830 | } |
| 3831 | } |
| 3832 | else |
| 3833 | { |
| 3834 | bgp_static = rn->info; |
| 3835 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3836 | bgp_static_free (bgp_static); |
| 3837 | rn->info = NULL; |
| 3838 | bgp_unlock_node (rn); |
| 3839 | } |
| 3840 | } |
| 3841 | } |
| 3842 | |
| 3843 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3844 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3845 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3846 | { |
| 3847 | int ret; |
| 3848 | struct prefix p; |
| 3849 | struct prefix_rd prd; |
| 3850 | struct bgp *bgp; |
| 3851 | struct bgp_node *prn; |
| 3852 | struct bgp_node *rn; |
| 3853 | struct bgp_table *table; |
| 3854 | struct bgp_static *bgp_static; |
| 3855 | u_char tag[3]; |
| 3856 | |
| 3857 | bgp = vty->index; |
| 3858 | |
| 3859 | ret = str2prefix (ip_str, &p); |
| 3860 | if (! ret) |
| 3861 | { |
| 3862 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3863 | return CMD_WARNING; |
| 3864 | } |
| 3865 | apply_mask (&p); |
| 3866 | |
| 3867 | ret = str2prefix_rd (rd_str, &prd); |
| 3868 | if (! ret) |
| 3869 | { |
| 3870 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3871 | return CMD_WARNING; |
| 3872 | } |
| 3873 | |
| 3874 | ret = str2tag (tag_str, tag); |
| 3875 | if (! ret) |
| 3876 | { |
| 3877 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3878 | return CMD_WARNING; |
| 3879 | } |
| 3880 | |
| 3881 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3882 | (struct prefix *)&prd); |
| 3883 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3884 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3885 | else |
| 3886 | bgp_unlock_node (prn); |
| 3887 | table = prn->info; |
| 3888 | |
| 3889 | rn = bgp_node_get (table, &p); |
| 3890 | |
| 3891 | if (rn->info) |
| 3892 | { |
| 3893 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3894 | bgp_unlock_node (rn); |
| 3895 | } |
| 3896 | else |
| 3897 | { |
| 3898 | /* New configuration. */ |
| 3899 | bgp_static = bgp_static_new (); |
| 3900 | bgp_static->valid = 1; |
| 3901 | memcpy (bgp_static->tag, tag, 3); |
| 3902 | rn->info = bgp_static; |
| 3903 | |
| 3904 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3905 | } |
| 3906 | |
| 3907 | return CMD_SUCCESS; |
| 3908 | } |
| 3909 | |
| 3910 | /* Configure static BGP network. */ |
| 3911 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3912 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3913 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3914 | { |
| 3915 | int ret; |
| 3916 | struct bgp *bgp; |
| 3917 | struct prefix p; |
| 3918 | struct prefix_rd prd; |
| 3919 | struct bgp_node *prn; |
| 3920 | struct bgp_node *rn; |
| 3921 | struct bgp_table *table; |
| 3922 | struct bgp_static *bgp_static; |
| 3923 | u_char tag[3]; |
| 3924 | |
| 3925 | bgp = vty->index; |
| 3926 | |
| 3927 | /* Convert IP prefix string to struct prefix. */ |
| 3928 | ret = str2prefix (ip_str, &p); |
| 3929 | if (! ret) |
| 3930 | { |
| 3931 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3932 | return CMD_WARNING; |
| 3933 | } |
| 3934 | apply_mask (&p); |
| 3935 | |
| 3936 | ret = str2prefix_rd (rd_str, &prd); |
| 3937 | if (! ret) |
| 3938 | { |
| 3939 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3940 | return CMD_WARNING; |
| 3941 | } |
| 3942 | |
| 3943 | ret = str2tag (tag_str, tag); |
| 3944 | if (! ret) |
| 3945 | { |
| 3946 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3947 | return CMD_WARNING; |
| 3948 | } |
| 3949 | |
| 3950 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3951 | (struct prefix *)&prd); |
| 3952 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3953 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3954 | else |
| 3955 | bgp_unlock_node (prn); |
| 3956 | table = prn->info; |
| 3957 | |
| 3958 | rn = bgp_node_lookup (table, &p); |
| 3959 | |
| 3960 | if (rn) |
| 3961 | { |
| 3962 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3963 | |
| 3964 | bgp_static = rn->info; |
| 3965 | bgp_static_free (bgp_static); |
| 3966 | rn->info = NULL; |
| 3967 | bgp_unlock_node (rn); |
| 3968 | bgp_unlock_node (rn); |
| 3969 | } |
| 3970 | else |
| 3971 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 3972 | |
| 3973 | return CMD_SUCCESS; |
| 3974 | } |
| 3975 | |
| 3976 | DEFUN (bgp_network, |
| 3977 | bgp_network_cmd, |
| 3978 | "network A.B.C.D/M", |
| 3979 | "Specify a network to announce via BGP\n" |
| 3980 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3981 | { |
| 3982 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3983 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3984 | } |
| 3985 | |
| 3986 | DEFUN (bgp_network_route_map, |
| 3987 | bgp_network_route_map_cmd, |
| 3988 | "network A.B.C.D/M route-map WORD", |
| 3989 | "Specify a network to announce via BGP\n" |
| 3990 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3991 | "Route-map to modify the attributes\n" |
| 3992 | "Name of the route map\n") |
| 3993 | { |
| 3994 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3995 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3996 | } |
| 3997 | |
| 3998 | DEFUN (bgp_network_backdoor, |
| 3999 | bgp_network_backdoor_cmd, |
| 4000 | "network A.B.C.D/M backdoor", |
| 4001 | "Specify a network to announce via BGP\n" |
| 4002 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4003 | "Specify a BGP backdoor route\n") |
| 4004 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4005 | 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] | 4006 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4007 | } |
| 4008 | |
| 4009 | DEFUN (bgp_network_mask, |
| 4010 | bgp_network_mask_cmd, |
| 4011 | "network A.B.C.D mask A.B.C.D", |
| 4012 | "Specify a network to announce via BGP\n" |
| 4013 | "Network number\n" |
| 4014 | "Network mask\n" |
| 4015 | "Network mask\n") |
| 4016 | { |
| 4017 | int ret; |
| 4018 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4019 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4020 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4021 | if (! ret) |
| 4022 | { |
| 4023 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4024 | return CMD_WARNING; |
| 4025 | } |
| 4026 | |
| 4027 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4028 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4029 | } |
| 4030 | |
| 4031 | DEFUN (bgp_network_mask_route_map, |
| 4032 | bgp_network_mask_route_map_cmd, |
| 4033 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4034 | "Specify a network to announce via BGP\n" |
| 4035 | "Network number\n" |
| 4036 | "Network mask\n" |
| 4037 | "Network mask\n" |
| 4038 | "Route-map to modify the attributes\n" |
| 4039 | "Name of the route map\n") |
| 4040 | { |
| 4041 | int ret; |
| 4042 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4043 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4044 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4045 | if (! ret) |
| 4046 | { |
| 4047 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4048 | return CMD_WARNING; |
| 4049 | } |
| 4050 | |
| 4051 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4052 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4053 | } |
| 4054 | |
| 4055 | DEFUN (bgp_network_mask_backdoor, |
| 4056 | bgp_network_mask_backdoor_cmd, |
| 4057 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4058 | "Specify a network to announce via BGP\n" |
| 4059 | "Network number\n" |
| 4060 | "Network mask\n" |
| 4061 | "Network mask\n" |
| 4062 | "Specify a BGP backdoor route\n") |
| 4063 | { |
| 4064 | int ret; |
| 4065 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4066 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4067 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4068 | if (! ret) |
| 4069 | { |
| 4070 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4071 | return CMD_WARNING; |
| 4072 | } |
| 4073 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4074 | 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] | 4075 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4076 | } |
| 4077 | |
| 4078 | DEFUN (bgp_network_mask_natural, |
| 4079 | bgp_network_mask_natural_cmd, |
| 4080 | "network A.B.C.D", |
| 4081 | "Specify a network to announce via BGP\n" |
| 4082 | "Network number\n") |
| 4083 | { |
| 4084 | int ret; |
| 4085 | char prefix_str[BUFSIZ]; |
| 4086 | |
| 4087 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4088 | if (! ret) |
| 4089 | { |
| 4090 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4091 | return CMD_WARNING; |
| 4092 | } |
| 4093 | |
| 4094 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4095 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4096 | } |
| 4097 | |
| 4098 | DEFUN (bgp_network_mask_natural_route_map, |
| 4099 | bgp_network_mask_natural_route_map_cmd, |
| 4100 | "network A.B.C.D route-map WORD", |
| 4101 | "Specify a network to announce via BGP\n" |
| 4102 | "Network number\n" |
| 4103 | "Route-map to modify the attributes\n" |
| 4104 | "Name of the route map\n") |
| 4105 | { |
| 4106 | int ret; |
| 4107 | char prefix_str[BUFSIZ]; |
| 4108 | |
| 4109 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4110 | if (! ret) |
| 4111 | { |
| 4112 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4113 | return CMD_WARNING; |
| 4114 | } |
| 4115 | |
| 4116 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4117 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4118 | } |
| 4119 | |
| 4120 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4121 | bgp_network_mask_natural_backdoor_cmd, |
| 4122 | "network A.B.C.D backdoor", |
| 4123 | "Specify a network to announce via BGP\n" |
| 4124 | "Network number\n" |
| 4125 | "Specify a BGP backdoor route\n") |
| 4126 | { |
| 4127 | int ret; |
| 4128 | char prefix_str[BUFSIZ]; |
| 4129 | |
| 4130 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4131 | if (! ret) |
| 4132 | { |
| 4133 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4134 | return CMD_WARNING; |
| 4135 | } |
| 4136 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4137 | 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] | 4138 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4139 | } |
| 4140 | |
| 4141 | DEFUN (no_bgp_network, |
| 4142 | no_bgp_network_cmd, |
| 4143 | "no network A.B.C.D/M", |
| 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 | { |
| 4148 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4149 | bgp_node_safi (vty)); |
| 4150 | } |
| 4151 | |
| 4152 | ALIAS (no_bgp_network, |
| 4153 | no_bgp_network_route_map_cmd, |
| 4154 | "no network A.B.C.D/M route-map WORD", |
| 4155 | NO_STR |
| 4156 | "Specify a network to announce via BGP\n" |
| 4157 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4158 | "Route-map to modify the attributes\n" |
| 4159 | "Name of the route map\n") |
| 4160 | |
| 4161 | ALIAS (no_bgp_network, |
| 4162 | no_bgp_network_backdoor_cmd, |
| 4163 | "no network A.B.C.D/M backdoor", |
| 4164 | NO_STR |
| 4165 | "Specify a network to announce via BGP\n" |
| 4166 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4167 | "Specify a BGP backdoor route\n") |
| 4168 | |
| 4169 | DEFUN (no_bgp_network_mask, |
| 4170 | no_bgp_network_mask_cmd, |
| 4171 | "no network A.B.C.D mask A.B.C.D", |
| 4172 | NO_STR |
| 4173 | "Specify a network to announce via BGP\n" |
| 4174 | "Network number\n" |
| 4175 | "Network mask\n" |
| 4176 | "Network mask\n") |
| 4177 | { |
| 4178 | int ret; |
| 4179 | char prefix_str[BUFSIZ]; |
| 4180 | |
| 4181 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4182 | if (! ret) |
| 4183 | { |
| 4184 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4185 | return CMD_WARNING; |
| 4186 | } |
| 4187 | |
| 4188 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4189 | bgp_node_safi (vty)); |
| 4190 | } |
| 4191 | |
| 4192 | ALIAS (no_bgp_network_mask, |
| 4193 | no_bgp_network_mask_route_map_cmd, |
| 4194 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 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 | "Route-map to modify the attributes\n" |
| 4201 | "Name of the route map\n") |
| 4202 | |
| 4203 | ALIAS (no_bgp_network_mask, |
| 4204 | no_bgp_network_mask_backdoor_cmd, |
| 4205 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4206 | NO_STR |
| 4207 | "Specify a network to announce via BGP\n" |
| 4208 | "Network number\n" |
| 4209 | "Network mask\n" |
| 4210 | "Network mask\n" |
| 4211 | "Specify a BGP backdoor route\n") |
| 4212 | |
| 4213 | DEFUN (no_bgp_network_mask_natural, |
| 4214 | no_bgp_network_mask_natural_cmd, |
| 4215 | "no network A.B.C.D", |
| 4216 | NO_STR |
| 4217 | "Specify a network to announce via BGP\n" |
| 4218 | "Network number\n") |
| 4219 | { |
| 4220 | int ret; |
| 4221 | char prefix_str[BUFSIZ]; |
| 4222 | |
| 4223 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4224 | if (! ret) |
| 4225 | { |
| 4226 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4227 | return CMD_WARNING; |
| 4228 | } |
| 4229 | |
| 4230 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4231 | bgp_node_safi (vty)); |
| 4232 | } |
| 4233 | |
| 4234 | ALIAS (no_bgp_network_mask_natural, |
| 4235 | no_bgp_network_mask_natural_route_map_cmd, |
| 4236 | "no network A.B.C.D route-map WORD", |
| 4237 | NO_STR |
| 4238 | "Specify a network to announce via BGP\n" |
| 4239 | "Network number\n" |
| 4240 | "Route-map to modify the attributes\n" |
| 4241 | "Name of the route map\n") |
| 4242 | |
| 4243 | ALIAS (no_bgp_network_mask_natural, |
| 4244 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4245 | "no network A.B.C.D backdoor", |
| 4246 | NO_STR |
| 4247 | "Specify a network to announce via BGP\n" |
| 4248 | "Network number\n" |
| 4249 | "Specify a BGP backdoor route\n") |
| 4250 | |
| 4251 | #ifdef HAVE_IPV6 |
| 4252 | DEFUN (ipv6_bgp_network, |
| 4253 | ipv6_bgp_network_cmd, |
| 4254 | "network X:X::X:X/M", |
| 4255 | "Specify a network to announce via BGP\n" |
| 4256 | "IPv6 prefix <network>/<length>\n") |
| 4257 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4258 | 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] | 4259 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4260 | } |
| 4261 | |
| 4262 | DEFUN (ipv6_bgp_network_route_map, |
| 4263 | ipv6_bgp_network_route_map_cmd, |
| 4264 | "network X:X::X:X/M route-map WORD", |
| 4265 | "Specify a network to announce via BGP\n" |
| 4266 | "IPv6 prefix <network>/<length>\n" |
| 4267 | "Route-map to modify the attributes\n" |
| 4268 | "Name of the route map\n") |
| 4269 | { |
| 4270 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4271 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4272 | } |
| 4273 | |
| 4274 | DEFUN (no_ipv6_bgp_network, |
| 4275 | no_ipv6_bgp_network_cmd, |
| 4276 | "no network X:X::X:X/M", |
| 4277 | NO_STR |
| 4278 | "Specify a network to announce via BGP\n" |
| 4279 | "IPv6 prefix <network>/<length>\n") |
| 4280 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4281 | 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] | 4282 | } |
| 4283 | |
| 4284 | ALIAS (no_ipv6_bgp_network, |
| 4285 | no_ipv6_bgp_network_route_map_cmd, |
| 4286 | "no network X:X::X:X/M route-map WORD", |
| 4287 | NO_STR |
| 4288 | "Specify a network to announce via BGP\n" |
| 4289 | "IPv6 prefix <network>/<length>\n" |
| 4290 | "Route-map to modify the attributes\n" |
| 4291 | "Name of the route map\n") |
| 4292 | |
| 4293 | ALIAS (ipv6_bgp_network, |
| 4294 | old_ipv6_bgp_network_cmd, |
| 4295 | "ipv6 bgp network X:X::X:X/M", |
| 4296 | IPV6_STR |
| 4297 | BGP_STR |
| 4298 | "Specify a network to announce via BGP\n" |
| 4299 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4300 | |
| 4301 | ALIAS (no_ipv6_bgp_network, |
| 4302 | old_no_ipv6_bgp_network_cmd, |
| 4303 | "no ipv6 bgp network X:X::X:X/M", |
| 4304 | NO_STR |
| 4305 | IPV6_STR |
| 4306 | BGP_STR |
| 4307 | "Specify a network to announce via BGP\n" |
| 4308 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4309 | #endif /* HAVE_IPV6 */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4310 | |
| 4311 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4312 | ALIAS_DEPRECATED (bgp_network, |
| 4313 | bgp_network_ttl_cmd, |
| 4314 | "network A.B.C.D/M pathlimit <0-255>", |
| 4315 | "Specify a network to announce via BGP\n" |
| 4316 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4317 | "AS-Path hopcount limit attribute\n" |
| 4318 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4319 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4320 | bgp_network_backdoor_ttl_cmd, |
| 4321 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4322 | "Specify a network to announce via BGP\n" |
| 4323 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4324 | "Specify a BGP backdoor route\n" |
| 4325 | "AS-Path hopcount limit attribute\n" |
| 4326 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4327 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4328 | bgp_network_mask_ttl_cmd, |
| 4329 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4330 | "Specify a network to announce via BGP\n" |
| 4331 | "Network number\n" |
| 4332 | "Network mask\n" |
| 4333 | "Network mask\n" |
| 4334 | "AS-Path hopcount limit attribute\n" |
| 4335 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4336 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4337 | bgp_network_mask_backdoor_ttl_cmd, |
| 4338 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4339 | "Specify a network to announce via BGP\n" |
| 4340 | "Network number\n" |
| 4341 | "Network mask\n" |
| 4342 | "Network mask\n" |
| 4343 | "Specify a BGP backdoor route\n" |
| 4344 | "AS-Path hopcount limit attribute\n" |
| 4345 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4346 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4347 | bgp_network_mask_natural_ttl_cmd, |
| 4348 | "network A.B.C.D pathlimit <0-255>", |
| 4349 | "Specify a network to announce via BGP\n" |
| 4350 | "Network number\n" |
| 4351 | "AS-Path hopcount limit attribute\n" |
| 4352 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4353 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4354 | bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4355 | "network A.B.C.D backdoor pathlimit (1-255>", |
| 4356 | "Specify a network to announce via BGP\n" |
| 4357 | "Network number\n" |
| 4358 | "Specify a BGP backdoor route\n" |
| 4359 | "AS-Path hopcount limit attribute\n" |
| 4360 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4361 | ALIAS_DEPRECATED (no_bgp_network, |
| 4362 | no_bgp_network_ttl_cmd, |
| 4363 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4364 | NO_STR |
| 4365 | "Specify a network to announce via BGP\n" |
| 4366 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4367 | "AS-Path hopcount limit attribute\n" |
| 4368 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4369 | ALIAS_DEPRECATED (no_bgp_network, |
| 4370 | no_bgp_network_backdoor_ttl_cmd, |
| 4371 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4372 | NO_STR |
| 4373 | "Specify a network to announce via BGP\n" |
| 4374 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4375 | "Specify a BGP backdoor route\n" |
| 4376 | "AS-Path hopcount limit attribute\n" |
| 4377 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4378 | ALIAS_DEPRECATED (no_bgp_network, |
| 4379 | no_bgp_network_mask_ttl_cmd, |
| 4380 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4381 | NO_STR |
| 4382 | "Specify a network to announce via BGP\n" |
| 4383 | "Network number\n" |
| 4384 | "Network mask\n" |
| 4385 | "Network mask\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, |
| 4389 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4390 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4391 | NO_STR |
| 4392 | "Specify a network to announce via BGP\n" |
| 4393 | "Network number\n" |
| 4394 | "Network mask\n" |
| 4395 | "Network mask\n" |
| 4396 | "Specify a BGP backdoor route\n" |
| 4397 | "AS-Path hopcount limit attribute\n" |
| 4398 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4399 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4400 | no_bgp_network_mask_natural_ttl_cmd, |
| 4401 | "no network A.B.C.D pathlimit <0-255>", |
| 4402 | NO_STR |
| 4403 | "Specify a network to announce via BGP\n" |
| 4404 | "Network number\n" |
| 4405 | "AS-Path hopcount limit attribute\n" |
| 4406 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4407 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4408 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4409 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4410 | NO_STR |
| 4411 | "Specify a network to announce via BGP\n" |
| 4412 | "Network number\n" |
| 4413 | "Specify a BGP backdoor route\n" |
| 4414 | "AS-Path hopcount limit attribute\n" |
| 4415 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4416 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4417 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4418 | ipv6_bgp_network_ttl_cmd, |
| 4419 | "network X:X::X:X/M pathlimit <0-255>", |
| 4420 | "Specify a network to announce via BGP\n" |
| 4421 | "IPv6 prefix <network>/<length>\n" |
| 4422 | "AS-Path hopcount limit attribute\n" |
| 4423 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4424 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4425 | no_ipv6_bgp_network_ttl_cmd, |
| 4426 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4427 | NO_STR |
| 4428 | "Specify a network to announce via BGP\n" |
| 4429 | "IPv6 prefix <network>/<length>\n" |
| 4430 | "AS-Path hopcount limit attribute\n" |
| 4431 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4432 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4433 | |
| 4434 | /* Aggreagete address: |
| 4435 | |
| 4436 | advertise-map Set condition to advertise attribute |
| 4437 | as-set Generate AS set path information |
| 4438 | attribute-map Set attributes of aggregate |
| 4439 | route-map Set parameters of aggregate |
| 4440 | summary-only Filter more specific routes from updates |
| 4441 | suppress-map Conditionally filter more specific routes from updates |
| 4442 | <cr> |
| 4443 | */ |
| 4444 | struct bgp_aggregate |
| 4445 | { |
| 4446 | /* Summary-only flag. */ |
| 4447 | u_char summary_only; |
| 4448 | |
| 4449 | /* AS set generation. */ |
| 4450 | u_char as_set; |
| 4451 | |
| 4452 | /* Route-map for aggregated route. */ |
| 4453 | struct route_map *map; |
| 4454 | |
| 4455 | /* Suppress-count. */ |
| 4456 | unsigned long count; |
| 4457 | |
| 4458 | /* SAFI configuration. */ |
| 4459 | safi_t safi; |
| 4460 | }; |
| 4461 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4462 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4463 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4464 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4465 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4466 | } |
| 4467 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4468 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4469 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4470 | { |
| 4471 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4472 | } |
| 4473 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4474 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4475 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4476 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4477 | struct bgp_aggregate *aggregate) |
| 4478 | { |
| 4479 | struct bgp_table *table; |
| 4480 | struct bgp_node *top; |
| 4481 | struct bgp_node *rn; |
| 4482 | u_char origin; |
| 4483 | struct aspath *aspath = NULL; |
| 4484 | struct aspath *asmerge = NULL; |
| 4485 | struct community *community = NULL; |
| 4486 | struct community *commerge = NULL; |
| 4487 | struct in_addr nexthop; |
| 4488 | u_int32_t med = 0; |
| 4489 | struct bgp_info *ri; |
| 4490 | struct bgp_info *new; |
| 4491 | int first = 1; |
| 4492 | unsigned long match = 0; |
| 4493 | |
| 4494 | /* Record adding route's nexthop and med. */ |
| 4495 | if (rinew) |
| 4496 | { |
| 4497 | nexthop = rinew->attr->nexthop; |
| 4498 | med = rinew->attr->med; |
| 4499 | } |
| 4500 | |
| 4501 | /* ORIGIN attribute: If at least one route among routes that are |
| 4502 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4503 | aggregated route must have the ORIGIN attribute with the value |
| 4504 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4505 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4506 | route must have the origin attribute with the value EGP. In all |
| 4507 | other case the value of the ORIGIN attribute of the aggregated |
| 4508 | route is INTERNAL. */ |
| 4509 | origin = BGP_ORIGIN_IGP; |
| 4510 | |
| 4511 | table = bgp->rib[afi][safi]; |
| 4512 | |
| 4513 | top = bgp_node_get (table, p); |
| 4514 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4515 | if (rn->p.prefixlen > p->prefixlen) |
| 4516 | { |
| 4517 | match = 0; |
| 4518 | |
| 4519 | for (ri = rn->info; ri; ri = ri->next) |
| 4520 | { |
| 4521 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4522 | continue; |
| 4523 | |
| 4524 | if (del && ri == del) |
| 4525 | continue; |
| 4526 | |
| 4527 | if (! rinew && first) |
| 4528 | { |
| 4529 | nexthop = ri->attr->nexthop; |
| 4530 | med = ri->attr->med; |
| 4531 | first = 0; |
| 4532 | } |
| 4533 | |
| 4534 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4535 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4536 | || ri->attr->med != med) |
| 4537 | { |
| 4538 | if (aspath) |
| 4539 | aspath_free (aspath); |
| 4540 | if (community) |
| 4541 | community_free (community); |
| 4542 | bgp_unlock_node (rn); |
| 4543 | bgp_unlock_node (top); |
| 4544 | return; |
| 4545 | } |
| 4546 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4547 | |
| 4548 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4549 | { |
| 4550 | if (aggregate->summary_only) |
| 4551 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4552 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4553 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4554 | match++; |
| 4555 | } |
| 4556 | |
| 4557 | aggregate->count++; |
| 4558 | |
| 4559 | if (aggregate->as_set) |
| 4560 | { |
| 4561 | if (origin < ri->attr->origin) |
| 4562 | origin = ri->attr->origin; |
| 4563 | |
| 4564 | if (aspath) |
| 4565 | { |
| 4566 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4567 | aspath_free (aspath); |
| 4568 | aspath = asmerge; |
| 4569 | } |
| 4570 | else |
| 4571 | aspath = aspath_dup (ri->attr->aspath); |
| 4572 | |
| 4573 | if (ri->attr->community) |
| 4574 | { |
| 4575 | if (community) |
| 4576 | { |
| 4577 | commerge = community_merge (community, |
| 4578 | ri->attr->community); |
| 4579 | community = community_uniq_sort (commerge); |
| 4580 | community_free (commerge); |
| 4581 | } |
| 4582 | else |
| 4583 | community = community_dup (ri->attr->community); |
| 4584 | } |
| 4585 | } |
| 4586 | } |
| 4587 | } |
| 4588 | if (match) |
| 4589 | bgp_process (bgp, rn, afi, safi); |
| 4590 | } |
| 4591 | bgp_unlock_node (top); |
| 4592 | |
| 4593 | if (rinew) |
| 4594 | { |
| 4595 | aggregate->count++; |
| 4596 | |
| 4597 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4598 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4599 | |
| 4600 | if (aggregate->as_set) |
| 4601 | { |
| 4602 | if (origin < rinew->attr->origin) |
| 4603 | origin = rinew->attr->origin; |
| 4604 | |
| 4605 | if (aspath) |
| 4606 | { |
| 4607 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4608 | aspath_free (aspath); |
| 4609 | aspath = asmerge; |
| 4610 | } |
| 4611 | else |
| 4612 | aspath = aspath_dup (rinew->attr->aspath); |
| 4613 | |
| 4614 | if (rinew->attr->community) |
| 4615 | { |
| 4616 | if (community) |
| 4617 | { |
| 4618 | commerge = community_merge (community, |
| 4619 | rinew->attr->community); |
| 4620 | community = community_uniq_sort (commerge); |
| 4621 | community_free (commerge); |
| 4622 | } |
| 4623 | else |
| 4624 | community = community_dup (rinew->attr->community); |
| 4625 | } |
| 4626 | } |
| 4627 | } |
| 4628 | |
| 4629 | if (aggregate->count > 0) |
| 4630 | { |
| 4631 | rn = bgp_node_get (table, p); |
| 4632 | new = bgp_info_new (); |
| 4633 | new->type = ZEBRA_ROUTE_BGP; |
| 4634 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4635 | new->peer = bgp->peer_self; |
| 4636 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4637 | 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] | 4638 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4639 | |
| 4640 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4641 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4642 | bgp_process (bgp, rn, afi, safi); |
| 4643 | } |
| 4644 | else |
| 4645 | { |
| 4646 | if (aspath) |
| 4647 | aspath_free (aspath); |
| 4648 | if (community) |
| 4649 | community_free (community); |
| 4650 | } |
| 4651 | } |
| 4652 | |
| 4653 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4654 | struct bgp_aggregate *); |
| 4655 | |
| 4656 | void |
| 4657 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4658 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4659 | { |
| 4660 | struct bgp_node *child; |
| 4661 | struct bgp_node *rn; |
| 4662 | struct bgp_aggregate *aggregate; |
| 4663 | |
| 4664 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4665 | if (safi == SAFI_MPLS_VPN) |
| 4666 | return; |
| 4667 | |
| 4668 | if (p->prefixlen == 0) |
| 4669 | return; |
| 4670 | |
| 4671 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4672 | return; |
| 4673 | |
| 4674 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 4675 | |
| 4676 | /* Aggregate address configuration check. */ |
| 4677 | for (rn = child; rn; rn = rn->parent) |
| 4678 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4679 | { |
| 4680 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4681 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4682 | } |
| 4683 | bgp_unlock_node (child); |
| 4684 | } |
| 4685 | |
| 4686 | void |
| 4687 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4688 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4689 | { |
| 4690 | struct bgp_node *child; |
| 4691 | struct bgp_node *rn; |
| 4692 | struct bgp_aggregate *aggregate; |
| 4693 | |
| 4694 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4695 | if (safi == SAFI_MPLS_VPN) |
| 4696 | return; |
| 4697 | |
| 4698 | if (p->prefixlen == 0) |
| 4699 | return; |
| 4700 | |
| 4701 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 4702 | |
| 4703 | /* Aggregate address configuration check. */ |
| 4704 | for (rn = child; rn; rn = rn->parent) |
| 4705 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4706 | { |
| 4707 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4708 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4709 | } |
| 4710 | bgp_unlock_node (child); |
| 4711 | } |
| 4712 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4713 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4714 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4715 | struct bgp_aggregate *aggregate) |
| 4716 | { |
| 4717 | struct bgp_table *table; |
| 4718 | struct bgp_node *top; |
| 4719 | struct bgp_node *rn; |
| 4720 | struct bgp_info *new; |
| 4721 | struct bgp_info *ri; |
| 4722 | unsigned long match; |
| 4723 | u_char origin = BGP_ORIGIN_IGP; |
| 4724 | struct aspath *aspath = NULL; |
| 4725 | struct aspath *asmerge = NULL; |
| 4726 | struct community *community = NULL; |
| 4727 | struct community *commerge = NULL; |
| 4728 | |
| 4729 | table = bgp->rib[afi][safi]; |
| 4730 | |
| 4731 | /* Sanity check. */ |
| 4732 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4733 | return; |
| 4734 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4735 | return; |
| 4736 | |
| 4737 | /* If routes exists below this node, generate aggregate routes. */ |
| 4738 | top = bgp_node_get (table, p); |
| 4739 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4740 | if (rn->p.prefixlen > p->prefixlen) |
| 4741 | { |
| 4742 | match = 0; |
| 4743 | |
| 4744 | for (ri = rn->info; ri; ri = ri->next) |
| 4745 | { |
| 4746 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4747 | continue; |
| 4748 | |
| 4749 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4750 | { |
| 4751 | /* summary-only aggregate route suppress aggregated |
| 4752 | route announcement. */ |
| 4753 | if (aggregate->summary_only) |
| 4754 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4755 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4756 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4757 | match++; |
| 4758 | } |
| 4759 | /* as-set aggregate route generate origin, as path, |
| 4760 | community aggregation. */ |
| 4761 | if (aggregate->as_set) |
| 4762 | { |
| 4763 | if (origin < ri->attr->origin) |
| 4764 | origin = ri->attr->origin; |
| 4765 | |
| 4766 | if (aspath) |
| 4767 | { |
| 4768 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4769 | aspath_free (aspath); |
| 4770 | aspath = asmerge; |
| 4771 | } |
| 4772 | else |
| 4773 | aspath = aspath_dup (ri->attr->aspath); |
| 4774 | |
| 4775 | if (ri->attr->community) |
| 4776 | { |
| 4777 | if (community) |
| 4778 | { |
| 4779 | commerge = community_merge (community, |
| 4780 | ri->attr->community); |
| 4781 | community = community_uniq_sort (commerge); |
| 4782 | community_free (commerge); |
| 4783 | } |
| 4784 | else |
| 4785 | community = community_dup (ri->attr->community); |
| 4786 | } |
| 4787 | } |
| 4788 | aggregate->count++; |
| 4789 | } |
| 4790 | } |
| 4791 | |
| 4792 | /* If this node is suppressed, process the change. */ |
| 4793 | if (match) |
| 4794 | bgp_process (bgp, rn, afi, safi); |
| 4795 | } |
| 4796 | bgp_unlock_node (top); |
| 4797 | |
| 4798 | /* Add aggregate route to BGP table. */ |
| 4799 | if (aggregate->count) |
| 4800 | { |
| 4801 | rn = bgp_node_get (table, p); |
| 4802 | |
| 4803 | new = bgp_info_new (); |
| 4804 | new->type = ZEBRA_ROUTE_BGP; |
| 4805 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4806 | new->peer = bgp->peer_self; |
| 4807 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4808 | 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] | 4809 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4810 | |
| 4811 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4812 | bgp_unlock_node (rn); |
| 4813 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4814 | /* Process change. */ |
| 4815 | bgp_process (bgp, rn, afi, safi); |
| 4816 | } |
| 4817 | } |
| 4818 | |
| 4819 | void |
| 4820 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4821 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4822 | { |
| 4823 | struct bgp_table *table; |
| 4824 | struct bgp_node *top; |
| 4825 | struct bgp_node *rn; |
| 4826 | struct bgp_info *ri; |
| 4827 | unsigned long match; |
| 4828 | |
| 4829 | table = bgp->rib[afi][safi]; |
| 4830 | |
| 4831 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4832 | return; |
| 4833 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4834 | return; |
| 4835 | |
| 4836 | /* If routes exists below this node, generate aggregate routes. */ |
| 4837 | top = bgp_node_get (table, p); |
| 4838 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4839 | if (rn->p.prefixlen > p->prefixlen) |
| 4840 | { |
| 4841 | match = 0; |
| 4842 | |
| 4843 | for (ri = rn->info; ri; ri = ri->next) |
| 4844 | { |
| 4845 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4846 | continue; |
| 4847 | |
| 4848 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4849 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4850 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4851 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4852 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4853 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4854 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4855 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4856 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4857 | match++; |
| 4858 | } |
| 4859 | } |
| 4860 | aggregate->count--; |
| 4861 | } |
| 4862 | } |
| 4863 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4864 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4865 | if (match) |
| 4866 | bgp_process (bgp, rn, afi, safi); |
| 4867 | } |
| 4868 | bgp_unlock_node (top); |
| 4869 | |
| 4870 | /* Delete aggregate route from BGP table. */ |
| 4871 | rn = bgp_node_get (table, p); |
| 4872 | |
| 4873 | for (ri = rn->info; ri; ri = ri->next) |
| 4874 | if (ri->peer == bgp->peer_self |
| 4875 | && ri->type == ZEBRA_ROUTE_BGP |
| 4876 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4877 | break; |
| 4878 | |
| 4879 | /* Withdraw static BGP route from routing table. */ |
| 4880 | if (ri) |
| 4881 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4882 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4883 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4884 | } |
| 4885 | |
| 4886 | /* Unlock bgp_node_lookup. */ |
| 4887 | bgp_unlock_node (rn); |
| 4888 | } |
| 4889 | |
| 4890 | /* Aggregate route attribute. */ |
| 4891 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4892 | #define AGGREGATE_AS_SET 1 |
| 4893 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4894 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4895 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4896 | afi_t afi, safi_t safi) |
| 4897 | { |
| 4898 | int ret; |
| 4899 | struct prefix p; |
| 4900 | struct bgp_node *rn; |
| 4901 | struct bgp *bgp; |
| 4902 | struct bgp_aggregate *aggregate; |
| 4903 | |
| 4904 | /* Convert string to prefix structure. */ |
| 4905 | ret = str2prefix (prefix_str, &p); |
| 4906 | if (!ret) |
| 4907 | { |
| 4908 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4909 | return CMD_WARNING; |
| 4910 | } |
| 4911 | apply_mask (&p); |
| 4912 | |
| 4913 | /* Get BGP structure. */ |
| 4914 | bgp = vty->index; |
| 4915 | |
| 4916 | /* Old configuration check. */ |
| 4917 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4918 | if (! rn) |
| 4919 | { |
| 4920 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4921 | VTY_NEWLINE); |
| 4922 | return CMD_WARNING; |
| 4923 | } |
| 4924 | |
| 4925 | aggregate = rn->info; |
| 4926 | if (aggregate->safi & SAFI_UNICAST) |
| 4927 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4928 | if (aggregate->safi & SAFI_MULTICAST) |
| 4929 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4930 | |
| 4931 | /* Unlock aggregate address configuration. */ |
| 4932 | rn->info = NULL; |
| 4933 | bgp_aggregate_free (aggregate); |
| 4934 | bgp_unlock_node (rn); |
| 4935 | bgp_unlock_node (rn); |
| 4936 | |
| 4937 | return CMD_SUCCESS; |
| 4938 | } |
| 4939 | |
| 4940 | static int |
| 4941 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4942 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4943 | u_char summary_only, u_char as_set) |
| 4944 | { |
| 4945 | int ret; |
| 4946 | struct prefix p; |
| 4947 | struct bgp_node *rn; |
| 4948 | struct bgp *bgp; |
| 4949 | struct bgp_aggregate *aggregate; |
| 4950 | |
| 4951 | /* Convert string to prefix structure. */ |
| 4952 | ret = str2prefix (prefix_str, &p); |
| 4953 | if (!ret) |
| 4954 | { |
| 4955 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4956 | return CMD_WARNING; |
| 4957 | } |
| 4958 | apply_mask (&p); |
| 4959 | |
| 4960 | /* Get BGP structure. */ |
| 4961 | bgp = vty->index; |
| 4962 | |
| 4963 | /* Old configuration check. */ |
| 4964 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 4965 | |
| 4966 | if (rn->info) |
| 4967 | { |
| 4968 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 4969 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4970 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 4971 | if (ret) |
| 4972 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 4973 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 4974 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4975 | return CMD_WARNING; |
| 4976 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4977 | } |
| 4978 | |
| 4979 | /* Make aggregate address structure. */ |
| 4980 | aggregate = bgp_aggregate_new (); |
| 4981 | aggregate->summary_only = summary_only; |
| 4982 | aggregate->as_set = as_set; |
| 4983 | aggregate->safi = safi; |
| 4984 | rn->info = aggregate; |
| 4985 | |
| 4986 | /* Aggregate address insert into BGP routing table. */ |
| 4987 | if (safi & SAFI_UNICAST) |
| 4988 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4989 | if (safi & SAFI_MULTICAST) |
| 4990 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4991 | |
| 4992 | return CMD_SUCCESS; |
| 4993 | } |
| 4994 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4995 | DEFUN (aggregate_address, |
| 4996 | aggregate_address_cmd, |
| 4997 | "aggregate-address A.B.C.D/M", |
| 4998 | "Configure BGP aggregate entries\n" |
| 4999 | "Aggregate prefix\n") |
| 5000 | { |
| 5001 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5002 | } |
| 5003 | |
| 5004 | DEFUN (aggregate_address_mask, |
| 5005 | aggregate_address_mask_cmd, |
| 5006 | "aggregate-address A.B.C.D A.B.C.D", |
| 5007 | "Configure BGP aggregate entries\n" |
| 5008 | "Aggregate address\n" |
| 5009 | "Aggregate mask\n") |
| 5010 | { |
| 5011 | int ret; |
| 5012 | char prefix_str[BUFSIZ]; |
| 5013 | |
| 5014 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5015 | |
| 5016 | if (! ret) |
| 5017 | { |
| 5018 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5019 | return CMD_WARNING; |
| 5020 | } |
| 5021 | |
| 5022 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5023 | 0, 0); |
| 5024 | } |
| 5025 | |
| 5026 | DEFUN (aggregate_address_summary_only, |
| 5027 | aggregate_address_summary_only_cmd, |
| 5028 | "aggregate-address A.B.C.D/M summary-only", |
| 5029 | "Configure BGP aggregate entries\n" |
| 5030 | "Aggregate prefix\n" |
| 5031 | "Filter more specific routes from updates\n") |
| 5032 | { |
| 5033 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5034 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5035 | } |
| 5036 | |
| 5037 | DEFUN (aggregate_address_mask_summary_only, |
| 5038 | aggregate_address_mask_summary_only_cmd, |
| 5039 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5040 | "Configure BGP aggregate entries\n" |
| 5041 | "Aggregate address\n" |
| 5042 | "Aggregate mask\n" |
| 5043 | "Filter more specific routes from updates\n") |
| 5044 | { |
| 5045 | int ret; |
| 5046 | char prefix_str[BUFSIZ]; |
| 5047 | |
| 5048 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5049 | |
| 5050 | if (! ret) |
| 5051 | { |
| 5052 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5053 | return CMD_WARNING; |
| 5054 | } |
| 5055 | |
| 5056 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5057 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5058 | } |
| 5059 | |
| 5060 | DEFUN (aggregate_address_as_set, |
| 5061 | aggregate_address_as_set_cmd, |
| 5062 | "aggregate-address A.B.C.D/M as-set", |
| 5063 | "Configure BGP aggregate entries\n" |
| 5064 | "Aggregate prefix\n" |
| 5065 | "Generate AS set path information\n") |
| 5066 | { |
| 5067 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5068 | 0, AGGREGATE_AS_SET); |
| 5069 | } |
| 5070 | |
| 5071 | DEFUN (aggregate_address_mask_as_set, |
| 5072 | aggregate_address_mask_as_set_cmd, |
| 5073 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5074 | "Configure BGP aggregate entries\n" |
| 5075 | "Aggregate address\n" |
| 5076 | "Aggregate mask\n" |
| 5077 | "Generate AS set path information\n") |
| 5078 | { |
| 5079 | int ret; |
| 5080 | char prefix_str[BUFSIZ]; |
| 5081 | |
| 5082 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5083 | |
| 5084 | if (! ret) |
| 5085 | { |
| 5086 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5087 | return CMD_WARNING; |
| 5088 | } |
| 5089 | |
| 5090 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5091 | 0, AGGREGATE_AS_SET); |
| 5092 | } |
| 5093 | |
| 5094 | |
| 5095 | DEFUN (aggregate_address_as_set_summary, |
| 5096 | aggregate_address_as_set_summary_cmd, |
| 5097 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5098 | "Configure BGP aggregate entries\n" |
| 5099 | "Aggregate prefix\n" |
| 5100 | "Generate AS set path information\n" |
| 5101 | "Filter more specific routes from updates\n") |
| 5102 | { |
| 5103 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5104 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5105 | } |
| 5106 | |
| 5107 | ALIAS (aggregate_address_as_set_summary, |
| 5108 | aggregate_address_summary_as_set_cmd, |
| 5109 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5110 | "Configure BGP aggregate entries\n" |
| 5111 | "Aggregate prefix\n" |
| 5112 | "Filter more specific routes from updates\n" |
| 5113 | "Generate AS set path information\n") |
| 5114 | |
| 5115 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5116 | aggregate_address_mask_as_set_summary_cmd, |
| 5117 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5118 | "Configure BGP aggregate entries\n" |
| 5119 | "Aggregate address\n" |
| 5120 | "Aggregate mask\n" |
| 5121 | "Generate AS set path information\n" |
| 5122 | "Filter more specific routes from updates\n") |
| 5123 | { |
| 5124 | int ret; |
| 5125 | char prefix_str[BUFSIZ]; |
| 5126 | |
| 5127 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5128 | |
| 5129 | if (! ret) |
| 5130 | { |
| 5131 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5132 | return CMD_WARNING; |
| 5133 | } |
| 5134 | |
| 5135 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5136 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5137 | } |
| 5138 | |
| 5139 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5140 | aggregate_address_mask_summary_as_set_cmd, |
| 5141 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5142 | "Configure BGP aggregate entries\n" |
| 5143 | "Aggregate address\n" |
| 5144 | "Aggregate mask\n" |
| 5145 | "Filter more specific routes from updates\n" |
| 5146 | "Generate AS set path information\n") |
| 5147 | |
| 5148 | DEFUN (no_aggregate_address, |
| 5149 | no_aggregate_address_cmd, |
| 5150 | "no aggregate-address A.B.C.D/M", |
| 5151 | NO_STR |
| 5152 | "Configure BGP aggregate entries\n" |
| 5153 | "Aggregate prefix\n") |
| 5154 | { |
| 5155 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5156 | } |
| 5157 | |
| 5158 | ALIAS (no_aggregate_address, |
| 5159 | no_aggregate_address_summary_only_cmd, |
| 5160 | "no aggregate-address A.B.C.D/M summary-only", |
| 5161 | NO_STR |
| 5162 | "Configure BGP aggregate entries\n" |
| 5163 | "Aggregate prefix\n" |
| 5164 | "Filter more specific routes from updates\n") |
| 5165 | |
| 5166 | ALIAS (no_aggregate_address, |
| 5167 | no_aggregate_address_as_set_cmd, |
| 5168 | "no aggregate-address A.B.C.D/M as-set", |
| 5169 | NO_STR |
| 5170 | "Configure BGP aggregate entries\n" |
| 5171 | "Aggregate prefix\n" |
| 5172 | "Generate AS set path information\n") |
| 5173 | |
| 5174 | ALIAS (no_aggregate_address, |
| 5175 | no_aggregate_address_as_set_summary_cmd, |
| 5176 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5177 | NO_STR |
| 5178 | "Configure BGP aggregate entries\n" |
| 5179 | "Aggregate prefix\n" |
| 5180 | "Generate AS set path information\n" |
| 5181 | "Filter more specific routes from updates\n") |
| 5182 | |
| 5183 | ALIAS (no_aggregate_address, |
| 5184 | no_aggregate_address_summary_as_set_cmd, |
| 5185 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5186 | NO_STR |
| 5187 | "Configure BGP aggregate entries\n" |
| 5188 | "Aggregate prefix\n" |
| 5189 | "Filter more specific routes from updates\n" |
| 5190 | "Generate AS set path information\n") |
| 5191 | |
| 5192 | DEFUN (no_aggregate_address_mask, |
| 5193 | no_aggregate_address_mask_cmd, |
| 5194 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5195 | NO_STR |
| 5196 | "Configure BGP aggregate entries\n" |
| 5197 | "Aggregate address\n" |
| 5198 | "Aggregate mask\n") |
| 5199 | { |
| 5200 | int ret; |
| 5201 | char prefix_str[BUFSIZ]; |
| 5202 | |
| 5203 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5204 | |
| 5205 | if (! ret) |
| 5206 | { |
| 5207 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5208 | return CMD_WARNING; |
| 5209 | } |
| 5210 | |
| 5211 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5212 | } |
| 5213 | |
| 5214 | ALIAS (no_aggregate_address_mask, |
| 5215 | no_aggregate_address_mask_summary_only_cmd, |
| 5216 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5217 | NO_STR |
| 5218 | "Configure BGP aggregate entries\n" |
| 5219 | "Aggregate address\n" |
| 5220 | "Aggregate mask\n" |
| 5221 | "Filter more specific routes from updates\n") |
| 5222 | |
| 5223 | ALIAS (no_aggregate_address_mask, |
| 5224 | no_aggregate_address_mask_as_set_cmd, |
| 5225 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5226 | NO_STR |
| 5227 | "Configure BGP aggregate entries\n" |
| 5228 | "Aggregate address\n" |
| 5229 | "Aggregate mask\n" |
| 5230 | "Generate AS set path information\n") |
| 5231 | |
| 5232 | ALIAS (no_aggregate_address_mask, |
| 5233 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5234 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5235 | NO_STR |
| 5236 | "Configure BGP aggregate entries\n" |
| 5237 | "Aggregate address\n" |
| 5238 | "Aggregate mask\n" |
| 5239 | "Generate AS set path information\n" |
| 5240 | "Filter more specific routes from updates\n") |
| 5241 | |
| 5242 | ALIAS (no_aggregate_address_mask, |
| 5243 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5244 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5245 | NO_STR |
| 5246 | "Configure BGP aggregate entries\n" |
| 5247 | "Aggregate address\n" |
| 5248 | "Aggregate mask\n" |
| 5249 | "Filter more specific routes from updates\n" |
| 5250 | "Generate AS set path information\n") |
| 5251 | |
| 5252 | #ifdef HAVE_IPV6 |
| 5253 | DEFUN (ipv6_aggregate_address, |
| 5254 | ipv6_aggregate_address_cmd, |
| 5255 | "aggregate-address X:X::X:X/M", |
| 5256 | "Configure BGP aggregate entries\n" |
| 5257 | "Aggregate prefix\n") |
| 5258 | { |
| 5259 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5260 | } |
| 5261 | |
| 5262 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5263 | ipv6_aggregate_address_summary_only_cmd, |
| 5264 | "aggregate-address X:X::X:X/M summary-only", |
| 5265 | "Configure BGP aggregate entries\n" |
| 5266 | "Aggregate prefix\n" |
| 5267 | "Filter more specific routes from updates\n") |
| 5268 | { |
| 5269 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5270 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5271 | } |
| 5272 | |
| 5273 | DEFUN (no_ipv6_aggregate_address, |
| 5274 | no_ipv6_aggregate_address_cmd, |
| 5275 | "no aggregate-address X:X::X:X/M", |
| 5276 | NO_STR |
| 5277 | "Configure BGP aggregate entries\n" |
| 5278 | "Aggregate prefix\n") |
| 5279 | { |
| 5280 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5281 | } |
| 5282 | |
| 5283 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5284 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5285 | "no aggregate-address X:X::X:X/M summary-only", |
| 5286 | NO_STR |
| 5287 | "Configure BGP aggregate entries\n" |
| 5288 | "Aggregate prefix\n" |
| 5289 | "Filter more specific routes from updates\n") |
| 5290 | { |
| 5291 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5292 | } |
| 5293 | |
| 5294 | ALIAS (ipv6_aggregate_address, |
| 5295 | old_ipv6_aggregate_address_cmd, |
| 5296 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5297 | IPV6_STR |
| 5298 | BGP_STR |
| 5299 | "Configure BGP aggregate entries\n" |
| 5300 | "Aggregate prefix\n") |
| 5301 | |
| 5302 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5303 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5304 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5305 | IPV6_STR |
| 5306 | BGP_STR |
| 5307 | "Configure BGP aggregate entries\n" |
| 5308 | "Aggregate prefix\n" |
| 5309 | "Filter more specific routes from updates\n") |
| 5310 | |
| 5311 | ALIAS (no_ipv6_aggregate_address, |
| 5312 | old_no_ipv6_aggregate_address_cmd, |
| 5313 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5314 | NO_STR |
| 5315 | IPV6_STR |
| 5316 | BGP_STR |
| 5317 | "Configure BGP aggregate entries\n" |
| 5318 | "Aggregate prefix\n") |
| 5319 | |
| 5320 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5321 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5322 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5323 | NO_STR |
| 5324 | IPV6_STR |
| 5325 | BGP_STR |
| 5326 | "Configure BGP aggregate entries\n" |
| 5327 | "Aggregate prefix\n" |
| 5328 | "Filter more specific routes from updates\n") |
| 5329 | #endif /* HAVE_IPV6 */ |
| 5330 | |
| 5331 | /* Redistribute route treatment. */ |
| 5332 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5333 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5334 | const struct in6_addr *nexthop6, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5335 | u_int32_t metric, u_char type) |
| 5336 | { |
| 5337 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5338 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5339 | struct bgp_info *new; |
| 5340 | struct bgp_info *bi; |
| 5341 | struct bgp_info info; |
| 5342 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5343 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5344 | struct attr *new_attr; |
| 5345 | afi_t afi; |
| 5346 | int ret; |
| 5347 | |
| 5348 | /* Make default attribute. */ |
| 5349 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5350 | if (nexthop) |
| 5351 | attr.nexthop = *nexthop; |
| 5352 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5353 | #ifdef HAVE_IPV6 |
| 5354 | if (nexthop6) |
| 5355 | { |
| 5356 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5357 | extra->mp_nexthop_global = *nexthop6; |
| 5358 | extra->mp_nexthop_len = 16; |
| 5359 | } |
| 5360 | #endif |
| 5361 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5362 | attr.med = metric; |
| 5363 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5364 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5365 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5366 | { |
| 5367 | afi = family2afi (p->family); |
| 5368 | |
| 5369 | if (bgp->redist[afi][type]) |
| 5370 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 5371 | struct attr attr_new; |
| 5372 | struct attr_extra extra_new; |
| 5373 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5374 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 5375 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5376 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5377 | |
| 5378 | if (bgp->redist_metric_flag[afi][type]) |
| 5379 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5380 | |
| 5381 | /* Apply route-map. */ |
| 5382 | if (bgp->rmap[afi][type].map) |
| 5383 | { |
| 5384 | info.peer = bgp->peer_self; |
| 5385 | info.attr = &attr_new; |
| 5386 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5387 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5388 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5389 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5390 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5391 | |
| 5392 | bgp->peer_self->rmap_type = 0; |
| 5393 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5394 | if (ret == RMAP_DENYMATCH) |
| 5395 | { |
| 5396 | /* Free uninterned attribute. */ |
| 5397 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 5398 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5399 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5400 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5401 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5402 | bgp_redistribute_delete (p, type); |
| 5403 | return; |
| 5404 | } |
| 5405 | } |
| 5406 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5407 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5408 | afi, SAFI_UNICAST, p, NULL); |
| 5409 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5410 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 5411 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5412 | for (bi = bn->info; bi; bi = bi->next) |
| 5413 | if (bi->peer == bgp->peer_self |
| 5414 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5415 | break; |
| 5416 | |
| 5417 | if (bi) |
| 5418 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5419 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5420 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5421 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5422 | bgp_attr_unintern (&new_attr); |
| 5423 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5424 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5425 | bgp_unlock_node (bn); |
| 5426 | return; |
| 5427 | } |
| 5428 | else |
| 5429 | { |
| 5430 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5431 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5432 | |
| 5433 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5434 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5435 | bgp_info_restore(bn, bi); |
| 5436 | else |
| 5437 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5438 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5439 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5440 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5441 | |
| 5442 | /* Process change. */ |
| 5443 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5444 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5445 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5446 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5447 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5448 | return; |
| 5449 | } |
| 5450 | } |
| 5451 | |
| 5452 | new = bgp_info_new (); |
| 5453 | new->type = type; |
| 5454 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 5455 | new->peer = bgp->peer_self; |
| 5456 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5457 | new->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5458 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5459 | |
| 5460 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5461 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5462 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5463 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5464 | } |
| 5465 | } |
| 5466 | |
| 5467 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5468 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5469 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5470 | } |
| 5471 | |
| 5472 | void |
| 5473 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5474 | { |
| 5475 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5476 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5477 | afi_t afi; |
| 5478 | struct bgp_node *rn; |
| 5479 | struct bgp_info *ri; |
| 5480 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5481 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5482 | { |
| 5483 | afi = family2afi (p->family); |
| 5484 | |
| 5485 | if (bgp->redist[afi][type]) |
| 5486 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5487 | 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] | 5488 | |
| 5489 | for (ri = rn->info; ri; ri = ri->next) |
| 5490 | if (ri->peer == bgp->peer_self |
| 5491 | && ri->type == type) |
| 5492 | break; |
| 5493 | |
| 5494 | if (ri) |
| 5495 | { |
| 5496 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5497 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5498 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5499 | } |
| 5500 | bgp_unlock_node (rn); |
| 5501 | } |
| 5502 | } |
| 5503 | } |
| 5504 | |
| 5505 | /* Withdraw specified route type's route. */ |
| 5506 | void |
| 5507 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5508 | { |
| 5509 | struct bgp_node *rn; |
| 5510 | struct bgp_info *ri; |
| 5511 | struct bgp_table *table; |
| 5512 | |
| 5513 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5514 | |
| 5515 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5516 | { |
| 5517 | for (ri = rn->info; ri; ri = ri->next) |
| 5518 | if (ri->peer == bgp->peer_self |
| 5519 | && ri->type == type) |
| 5520 | break; |
| 5521 | |
| 5522 | if (ri) |
| 5523 | { |
| 5524 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5525 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5526 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5527 | } |
| 5528 | } |
| 5529 | } |
| 5530 | |
| 5531 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5532 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5533 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5534 | { |
| 5535 | int len; |
| 5536 | u_int32_t destination; |
| 5537 | char buf[BUFSIZ]; |
| 5538 | |
| 5539 | if (p->family == AF_INET) |
| 5540 | { |
| 5541 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5542 | destination = ntohl (p->u.prefix4.s_addr); |
| 5543 | |
| 5544 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5545 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5546 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5547 | || p->u.prefix4.s_addr == 0) |
| 5548 | { |
| 5549 | /* When mask is natural, mask is not displayed. */ |
| 5550 | } |
| 5551 | else |
| 5552 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5553 | } |
| 5554 | else |
| 5555 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5556 | p->prefixlen); |
| 5557 | |
| 5558 | len = 17 - len; |
| 5559 | if (len < 1) |
| 5560 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5561 | else |
| 5562 | vty_out (vty, "%*s", len, " "); |
| 5563 | } |
| 5564 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5565 | enum bgp_display_type |
| 5566 | { |
| 5567 | normal_list, |
| 5568 | }; |
| 5569 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5570 | /* Print the short form route status for a bgp_info */ |
| 5571 | static void |
| 5572 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5573 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5574 | /* Route status display. */ |
| 5575 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5576 | vty_out (vty, "R"); |
| 5577 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5578 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5579 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5580 | vty_out (vty, "s"); |
| 5581 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5582 | vty_out (vty, "*"); |
| 5583 | else |
| 5584 | vty_out (vty, " "); |
| 5585 | |
| 5586 | /* Selected */ |
| 5587 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5588 | vty_out (vty, "h"); |
| 5589 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5590 | vty_out (vty, "d"); |
| 5591 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5592 | vty_out (vty, ">"); |
| 5593 | else |
| 5594 | vty_out (vty, " "); |
| 5595 | |
| 5596 | /* Internal route. */ |
| 5597 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5598 | vty_out (vty, "i"); |
| 5599 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5600 | vty_out (vty, " "); |
| 5601 | } |
| 5602 | |
| 5603 | /* called from terminal list command */ |
| 5604 | void |
| 5605 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5606 | struct bgp_info *binfo, int display, safi_t safi) |
| 5607 | { |
| 5608 | struct attr *attr; |
| 5609 | |
| 5610 | /* short status lead text */ |
| 5611 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5612 | |
| 5613 | /* print prefix and mask */ |
| 5614 | if (! display) |
| 5615 | route_vty_out_route (p, vty); |
| 5616 | else |
| 5617 | vty_out (vty, "%*s", 17, " "); |
| 5618 | |
| 5619 | /* Print attribute */ |
| 5620 | attr = binfo->attr; |
| 5621 | if (attr) |
| 5622 | { |
| 5623 | if (p->family == AF_INET) |
| 5624 | { |
| 5625 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5626 | vty_out (vty, "%-16s", |
| 5627 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5628 | else |
| 5629 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5630 | } |
| 5631 | #ifdef HAVE_IPV6 |
| 5632 | else if (p->family == AF_INET6) |
| 5633 | { |
| 5634 | int len; |
| 5635 | char buf[BUFSIZ]; |
| 5636 | |
| 5637 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5638 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5639 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5640 | len = 16 - len; |
| 5641 | if (len < 1) |
| 5642 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5643 | else |
| 5644 | vty_out (vty, "%*s", len, " "); |
| 5645 | } |
| 5646 | #endif /* HAVE_IPV6 */ |
| 5647 | |
| 5648 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5649 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5650 | else |
| 5651 | vty_out (vty, " "); |
| 5652 | |
| 5653 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5654 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5655 | else |
| 5656 | vty_out (vty, " "); |
| 5657 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5658 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5659 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5660 | /* Print aspath */ |
| 5661 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5662 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5663 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5664 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5665 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5666 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5667 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5668 | } |
| 5669 | |
| 5670 | /* called from terminal list command */ |
| 5671 | void |
| 5672 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5673 | struct attr *attr, safi_t safi) |
| 5674 | { |
| 5675 | /* Route status display. */ |
| 5676 | vty_out (vty, "*"); |
| 5677 | vty_out (vty, ">"); |
| 5678 | vty_out (vty, " "); |
| 5679 | |
| 5680 | /* print prefix and mask */ |
| 5681 | route_vty_out_route (p, vty); |
| 5682 | |
| 5683 | /* Print attribute */ |
| 5684 | if (attr) |
| 5685 | { |
| 5686 | if (p->family == AF_INET) |
| 5687 | { |
| 5688 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5689 | vty_out (vty, "%-16s", |
| 5690 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5691 | else |
| 5692 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5693 | } |
| 5694 | #ifdef HAVE_IPV6 |
| 5695 | else if (p->family == AF_INET6) |
| 5696 | { |
| 5697 | int len; |
| 5698 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5699 | |
| 5700 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5701 | |
| 5702 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5703 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5704 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5705 | len = 16 - len; |
| 5706 | if (len < 1) |
| 5707 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5708 | else |
| 5709 | vty_out (vty, "%*s", len, " "); |
| 5710 | } |
| 5711 | #endif /* HAVE_IPV6 */ |
| 5712 | |
| 5713 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5714 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5715 | else |
| 5716 | vty_out (vty, " "); |
| 5717 | |
| 5718 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5719 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5720 | else |
| 5721 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5722 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5723 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5724 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5725 | /* Print aspath */ |
| 5726 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5727 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5728 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5729 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5730 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5731 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5732 | |
| 5733 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5734 | } |
| 5735 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5736 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5737 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 5738 | struct bgp_info *binfo, int display, safi_t safi) |
| 5739 | { |
| 5740 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5741 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5742 | |
| 5743 | if (!binfo->extra) |
| 5744 | return; |
| 5745 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5746 | /* short status lead text */ |
| 5747 | route_vty_short_status_out (vty, binfo); |
| 5748 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5749 | /* print prefix and mask */ |
| 5750 | if (! display) |
| 5751 | route_vty_out_route (p, vty); |
| 5752 | else |
| 5753 | vty_out (vty, "%*s", 17, " "); |
| 5754 | |
| 5755 | /* Print attribute */ |
| 5756 | attr = binfo->attr; |
| 5757 | if (attr) |
| 5758 | { |
| 5759 | if (p->family == AF_INET) |
| 5760 | { |
| 5761 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5762 | vty_out (vty, "%-16s", |
| 5763 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5764 | else |
| 5765 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5766 | } |
| 5767 | #ifdef HAVE_IPV6 |
| 5768 | else if (p->family == AF_INET6) |
| 5769 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5770 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5771 | char buf[BUFSIZ]; |
| 5772 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5773 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5774 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5775 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5776 | buf, BUFSIZ)); |
| 5777 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5778 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5779 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5780 | buf, BUFSIZ), |
| 5781 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 5782 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5783 | |
| 5784 | } |
| 5785 | #endif /* HAVE_IPV6 */ |
| 5786 | } |
| 5787 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5788 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5789 | |
| 5790 | vty_out (vty, "notag/%d", label); |
| 5791 | |
| 5792 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5793 | } |
| 5794 | |
| 5795 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5796 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5797 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5798 | struct bgp_info *binfo, int display, safi_t safi) |
| 5799 | { |
| 5800 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5801 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5802 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5803 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5804 | /* short status lead text */ |
| 5805 | route_vty_short_status_out (vty, binfo); |
| 5806 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5807 | /* print prefix and mask */ |
| 5808 | if (! display) |
| 5809 | route_vty_out_route (p, vty); |
| 5810 | else |
| 5811 | vty_out (vty, "%*s", 17, " "); |
| 5812 | |
| 5813 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5814 | len = 17 - len; |
| 5815 | if (len < 1) |
| 5816 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5817 | else |
| 5818 | vty_out (vty, "%*s", len, " "); |
| 5819 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5820 | 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] | 5821 | |
| 5822 | /* Print attribute */ |
| 5823 | attr = binfo->attr; |
| 5824 | if (attr) |
| 5825 | { |
| 5826 | /* Print aspath */ |
| 5827 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5828 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5829 | |
| 5830 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5831 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5832 | } |
| 5833 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5834 | } |
| 5835 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5836 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5837 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5838 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5839 | struct bgp_info *binfo, int display, safi_t safi) |
| 5840 | { |
| 5841 | struct attr *attr; |
| 5842 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5843 | char timebuf[BGP_UPTIME_LEN]; |
| 5844 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5845 | |
| 5846 | if (!binfo->extra) |
| 5847 | return; |
| 5848 | |
| 5849 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5850 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5851 | /* short status lead text */ |
| 5852 | route_vty_short_status_out (vty, binfo); |
| 5853 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5854 | /* print prefix and mask */ |
| 5855 | if (! display) |
| 5856 | route_vty_out_route (p, vty); |
| 5857 | else |
| 5858 | vty_out (vty, "%*s", 17, " "); |
| 5859 | |
| 5860 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5861 | len = 16 - len; |
| 5862 | if (len < 1) |
| 5863 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5864 | else |
| 5865 | vty_out (vty, "%*s", len, " "); |
| 5866 | |
| 5867 | len = vty_out (vty, "%d", bdi->flap); |
| 5868 | len = 5 - len; |
| 5869 | if (len < 1) |
| 5870 | vty_out (vty, " "); |
| 5871 | else |
| 5872 | vty_out (vty, "%*s ", len, " "); |
| 5873 | |
| 5874 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5875 | timebuf, BGP_UPTIME_LEN)); |
| 5876 | |
| 5877 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5878 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5879 | 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] | 5880 | else |
| 5881 | vty_out (vty, "%*s ", 8, " "); |
| 5882 | |
| 5883 | /* Print attribute */ |
| 5884 | attr = binfo->attr; |
| 5885 | if (attr) |
| 5886 | { |
| 5887 | /* Print aspath */ |
| 5888 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5889 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5890 | |
| 5891 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5892 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5893 | } |
| 5894 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5895 | } |
| 5896 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5897 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5898 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5899 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5900 | { |
| 5901 | char buf[INET6_ADDRSTRLEN]; |
| 5902 | char buf1[BUFSIZ]; |
| 5903 | struct attr *attr; |
| 5904 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 5905 | #ifdef HAVE_CLOCK_MONOTONIC |
| 5906 | time_t tbuf; |
| 5907 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5908 | |
| 5909 | attr = binfo->attr; |
| 5910 | |
| 5911 | if (attr) |
| 5912 | { |
| 5913 | /* Line1 display AS-path, Aggregator */ |
| 5914 | if (attr->aspath) |
| 5915 | { |
| 5916 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 5917 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5918 | vty_out (vty, "Local"); |
| 5919 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5920 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5921 | } |
| 5922 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5923 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5924 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5925 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 5926 | vty_out (vty, ", (stale)"); |
| 5927 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 5928 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5929 | attr->extra->aggregator_as, |
| 5930 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5931 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 5932 | vty_out (vty, ", (Received from a RR-client)"); |
| 5933 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 5934 | vty_out (vty, ", (Received from a RS-client)"); |
| 5935 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5936 | vty_out (vty, ", (history entry)"); |
| 5937 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5938 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5939 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5940 | |
| 5941 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 5942 | if (p->family == AF_INET) |
| 5943 | { |
| 5944 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5945 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5946 | inet_ntoa (attr->nexthop)); |
| 5947 | } |
| 5948 | #ifdef HAVE_IPV6 |
| 5949 | else |
| 5950 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5951 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5952 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5953 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5954 | buf, INET6_ADDRSTRLEN)); |
| 5955 | } |
| 5956 | #endif /* HAVE_IPV6 */ |
| 5957 | |
| 5958 | if (binfo->peer == bgp->peer_self) |
| 5959 | { |
| 5960 | vty_out (vty, " from %s ", |
| 5961 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 5962 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 5963 | } |
| 5964 | else |
| 5965 | { |
| 5966 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 5967 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5968 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 5969 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 5970 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5971 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5972 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5973 | else |
| 5974 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 5975 | } |
| 5976 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5977 | |
| 5978 | #ifdef HAVE_IPV6 |
| 5979 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5980 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5981 | { |
| 5982 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5983 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5984 | buf, INET6_ADDRSTRLEN), |
| 5985 | VTY_NEWLINE); |
| 5986 | } |
| 5987 | #endif /* HAVE_IPV6 */ |
| 5988 | |
| 5989 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 5990 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 5991 | |
| 5992 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5993 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5994 | |
| 5995 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5996 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5997 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5998 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5999 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6000 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6001 | vty_out (vty, ", weight %u", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6002 | |
| 6003 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6004 | vty_out (vty, ", valid"); |
| 6005 | |
| 6006 | if (binfo->peer != bgp->peer_self) |
| 6007 | { |
| 6008 | if (binfo->peer->as == binfo->peer->local_as) |
| 6009 | vty_out (vty, ", internal"); |
| 6010 | else |
| 6011 | vty_out (vty, ", %s", |
| 6012 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6013 | } |
| 6014 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6015 | vty_out (vty, ", aggregated, local"); |
| 6016 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6017 | vty_out (vty, ", sourced"); |
| 6018 | else |
| 6019 | vty_out (vty, ", sourced, local"); |
| 6020 | |
| 6021 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6022 | vty_out (vty, ", atomic-aggregate"); |
| 6023 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6024 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6025 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6026 | bgp_info_mpath_count (binfo))) |
| 6027 | vty_out (vty, ", multipath"); |
| 6028 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6029 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6030 | vty_out (vty, ", best"); |
| 6031 | |
| 6032 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6033 | |
| 6034 | /* Line 4 display Community */ |
| 6035 | if (attr->community) |
| 6036 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6037 | VTY_NEWLINE); |
| 6038 | |
| 6039 | /* Line 5 display Extended-community */ |
| 6040 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6041 | vty_out (vty, " Extended Community: %s%s", |
| 6042 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6043 | |
| 6044 | /* Line 6 display Originator, Cluster-id */ |
| 6045 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6046 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6047 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6048 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6049 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6050 | vty_out (vty, " Originator: %s", |
| 6051 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6052 | |
| 6053 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6054 | { |
| 6055 | int i; |
| 6056 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6057 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6058 | vty_out (vty, "%s ", |
| 6059 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6060 | } |
| 6061 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6062 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6063 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6064 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6065 | bgp_damp_info_vty (vty, binfo); |
| 6066 | |
| 6067 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6068 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6069 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6070 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6071 | #else |
| 6072 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6073 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6074 | } |
| 6075 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6076 | } |
| 6077 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6078 | #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] | 6079 | #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] | 6080 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6081 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6082 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6083 | |
| 6084 | enum bgp_show_type |
| 6085 | { |
| 6086 | bgp_show_type_normal, |
| 6087 | bgp_show_type_regexp, |
| 6088 | bgp_show_type_prefix_list, |
| 6089 | bgp_show_type_filter_list, |
| 6090 | bgp_show_type_route_map, |
| 6091 | bgp_show_type_neighbor, |
| 6092 | bgp_show_type_cidr_only, |
| 6093 | bgp_show_type_prefix_longer, |
| 6094 | bgp_show_type_community_all, |
| 6095 | bgp_show_type_community, |
| 6096 | bgp_show_type_community_exact, |
| 6097 | bgp_show_type_community_list, |
| 6098 | bgp_show_type_community_list_exact, |
| 6099 | bgp_show_type_flap_statistics, |
| 6100 | bgp_show_type_flap_address, |
| 6101 | bgp_show_type_flap_prefix, |
| 6102 | bgp_show_type_flap_cidr_only, |
| 6103 | bgp_show_type_flap_regexp, |
| 6104 | bgp_show_type_flap_filter_list, |
| 6105 | bgp_show_type_flap_prefix_list, |
| 6106 | bgp_show_type_flap_prefix_longer, |
| 6107 | bgp_show_type_flap_route_map, |
| 6108 | bgp_show_type_flap_neighbor, |
| 6109 | bgp_show_type_dampend_paths, |
| 6110 | bgp_show_type_damp_neighbor |
| 6111 | }; |
| 6112 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6113 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6114 | 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] | 6115 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6116 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6117 | struct bgp_info *ri; |
| 6118 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6119 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6120 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6121 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6122 | |
| 6123 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6124 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6125 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6126 | /* Start processing of routes. */ |
| 6127 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6128 | if (rn->info != NULL) |
| 6129 | { |
| 6130 | display = 0; |
| 6131 | |
| 6132 | for (ri = rn->info; ri; ri = ri->next) |
| 6133 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6134 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6135 | || type == bgp_show_type_flap_address |
| 6136 | || type == bgp_show_type_flap_prefix |
| 6137 | || type == bgp_show_type_flap_cidr_only |
| 6138 | || type == bgp_show_type_flap_regexp |
| 6139 | || type == bgp_show_type_flap_filter_list |
| 6140 | || type == bgp_show_type_flap_prefix_list |
| 6141 | || type == bgp_show_type_flap_prefix_longer |
| 6142 | || type == bgp_show_type_flap_route_map |
| 6143 | || type == bgp_show_type_flap_neighbor |
| 6144 | || type == bgp_show_type_dampend_paths |
| 6145 | || type == bgp_show_type_damp_neighbor) |
| 6146 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6147 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6148 | continue; |
| 6149 | } |
| 6150 | if (type == bgp_show_type_regexp |
| 6151 | || type == bgp_show_type_flap_regexp) |
| 6152 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6153 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6154 | |
| 6155 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6156 | continue; |
| 6157 | } |
| 6158 | if (type == bgp_show_type_prefix_list |
| 6159 | || type == bgp_show_type_flap_prefix_list) |
| 6160 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6161 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6162 | |
| 6163 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6164 | continue; |
| 6165 | } |
| 6166 | if (type == bgp_show_type_filter_list |
| 6167 | || type == bgp_show_type_flap_filter_list) |
| 6168 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6169 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6170 | |
| 6171 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6172 | continue; |
| 6173 | } |
| 6174 | if (type == bgp_show_type_route_map |
| 6175 | || type == bgp_show_type_flap_route_map) |
| 6176 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6177 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6178 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 6179 | struct attr dummy_attr; |
| 6180 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6181 | int ret; |
| 6182 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 6183 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6184 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame^] | 6185 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6186 | binfo.peer = ri->peer; |
| 6187 | binfo.attr = &dummy_attr; |
| 6188 | |
| 6189 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6190 | if (ret == RMAP_DENYMATCH) |
| 6191 | continue; |
| 6192 | } |
| 6193 | if (type == bgp_show_type_neighbor |
| 6194 | || type == bgp_show_type_flap_neighbor |
| 6195 | || type == bgp_show_type_damp_neighbor) |
| 6196 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6197 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6198 | |
| 6199 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6200 | continue; |
| 6201 | } |
| 6202 | if (type == bgp_show_type_cidr_only |
| 6203 | || type == bgp_show_type_flap_cidr_only) |
| 6204 | { |
| 6205 | u_int32_t destination; |
| 6206 | |
| 6207 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6208 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6209 | continue; |
| 6210 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6211 | continue; |
| 6212 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6213 | continue; |
| 6214 | } |
| 6215 | if (type == bgp_show_type_prefix_longer |
| 6216 | || type == bgp_show_type_flap_prefix_longer) |
| 6217 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6218 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6219 | |
| 6220 | if (! prefix_match (p, &rn->p)) |
| 6221 | continue; |
| 6222 | } |
| 6223 | if (type == bgp_show_type_community_all) |
| 6224 | { |
| 6225 | if (! ri->attr->community) |
| 6226 | continue; |
| 6227 | } |
| 6228 | if (type == bgp_show_type_community) |
| 6229 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6230 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6231 | |
| 6232 | if (! ri->attr->community || |
| 6233 | ! community_match (ri->attr->community, com)) |
| 6234 | continue; |
| 6235 | } |
| 6236 | if (type == bgp_show_type_community_exact) |
| 6237 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6238 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6239 | |
| 6240 | if (! ri->attr->community || |
| 6241 | ! community_cmp (ri->attr->community, com)) |
| 6242 | continue; |
| 6243 | } |
| 6244 | if (type == bgp_show_type_community_list) |
| 6245 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6246 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6247 | |
| 6248 | if (! community_list_match (ri->attr->community, list)) |
| 6249 | continue; |
| 6250 | } |
| 6251 | if (type == bgp_show_type_community_list_exact) |
| 6252 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6253 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6254 | |
| 6255 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6256 | continue; |
| 6257 | } |
| 6258 | if (type == bgp_show_type_flap_address |
| 6259 | || type == bgp_show_type_flap_prefix) |
| 6260 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6261 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6262 | |
| 6263 | if (! prefix_match (&rn->p, p)) |
| 6264 | continue; |
| 6265 | |
| 6266 | if (type == bgp_show_type_flap_prefix) |
| 6267 | if (p->prefixlen != rn->p.prefixlen) |
| 6268 | continue; |
| 6269 | } |
| 6270 | if (type == bgp_show_type_dampend_paths |
| 6271 | || type == bgp_show_type_damp_neighbor) |
| 6272 | { |
| 6273 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6274 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6275 | continue; |
| 6276 | } |
| 6277 | |
| 6278 | if (header) |
| 6279 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6280 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6281 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6282 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6283 | if (type == bgp_show_type_dampend_paths |
| 6284 | || type == bgp_show_type_damp_neighbor) |
| 6285 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6286 | else if (type == bgp_show_type_flap_statistics |
| 6287 | || type == bgp_show_type_flap_address |
| 6288 | || type == bgp_show_type_flap_prefix |
| 6289 | || type == bgp_show_type_flap_cidr_only |
| 6290 | || type == bgp_show_type_flap_regexp |
| 6291 | || type == bgp_show_type_flap_filter_list |
| 6292 | || type == bgp_show_type_flap_prefix_list |
| 6293 | || type == bgp_show_type_flap_prefix_longer |
| 6294 | || type == bgp_show_type_flap_route_map |
| 6295 | || type == bgp_show_type_flap_neighbor) |
| 6296 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6297 | else |
| 6298 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6299 | header = 0; |
| 6300 | } |
| 6301 | |
| 6302 | if (type == bgp_show_type_dampend_paths |
| 6303 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6304 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6305 | else if (type == bgp_show_type_flap_statistics |
| 6306 | || type == bgp_show_type_flap_address |
| 6307 | || type == bgp_show_type_flap_prefix |
| 6308 | || type == bgp_show_type_flap_cidr_only |
| 6309 | || type == bgp_show_type_flap_regexp |
| 6310 | || type == bgp_show_type_flap_filter_list |
| 6311 | || type == bgp_show_type_flap_prefix_list |
| 6312 | || type == bgp_show_type_flap_prefix_longer |
| 6313 | || type == bgp_show_type_flap_route_map |
| 6314 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6315 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6316 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6317 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6318 | display++; |
| 6319 | } |
| 6320 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6321 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6322 | } |
| 6323 | |
| 6324 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6325 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6326 | { |
| 6327 | if (type == bgp_show_type_normal) |
| 6328 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 6329 | } |
| 6330 | else |
| 6331 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6332 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6333 | |
| 6334 | return CMD_SUCCESS; |
| 6335 | } |
| 6336 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6337 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6338 | 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] | 6339 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6340 | { |
| 6341 | struct bgp_table *table; |
| 6342 | |
| 6343 | if (bgp == NULL) { |
| 6344 | bgp = bgp_get_default (); |
| 6345 | } |
| 6346 | |
| 6347 | if (bgp == NULL) |
| 6348 | { |
| 6349 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6350 | return CMD_WARNING; |
| 6351 | } |
| 6352 | |
| 6353 | |
| 6354 | table = bgp->rib[afi][safi]; |
| 6355 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6356 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6357 | } |
| 6358 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6359 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6360 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6361 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6362 | struct bgp_node *rn, |
| 6363 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6364 | { |
| 6365 | struct bgp_info *ri; |
| 6366 | struct prefix *p; |
| 6367 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6368 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6369 | char buf1[INET6_ADDRSTRLEN]; |
| 6370 | char buf2[INET6_ADDRSTRLEN]; |
| 6371 | int count = 0; |
| 6372 | int best = 0; |
| 6373 | int suppress = 0; |
| 6374 | int no_export = 0; |
| 6375 | int no_advertise = 0; |
| 6376 | int local_as = 0; |
| 6377 | int first = 0; |
| 6378 | |
| 6379 | p = &rn->p; |
| 6380 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 6381 | (safi == SAFI_MPLS_VPN ? |
| 6382 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6383 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 6384 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6385 | p->prefixlen, VTY_NEWLINE); |
| 6386 | |
| 6387 | for (ri = rn->info; ri; ri = ri->next) |
| 6388 | { |
| 6389 | count++; |
| 6390 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6391 | { |
| 6392 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6393 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6394 | suppress = 1; |
| 6395 | if (ri->attr->community != NULL) |
| 6396 | { |
| 6397 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6398 | no_advertise = 1; |
| 6399 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6400 | no_export = 1; |
| 6401 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6402 | local_as = 1; |
| 6403 | } |
| 6404 | } |
| 6405 | } |
| 6406 | |
| 6407 | vty_out (vty, "Paths: (%d available", count); |
| 6408 | if (best) |
| 6409 | { |
| 6410 | vty_out (vty, ", best #%d", best); |
| 6411 | if (safi == SAFI_UNICAST) |
| 6412 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6413 | } |
| 6414 | else |
| 6415 | vty_out (vty, ", no best path"); |
| 6416 | if (no_advertise) |
| 6417 | vty_out (vty, ", not advertised to any peer"); |
| 6418 | else if (no_export) |
| 6419 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6420 | else if (local_as) |
| 6421 | vty_out (vty, ", not advertised outside local AS"); |
| 6422 | if (suppress) |
| 6423 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6424 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6425 | |
| 6426 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6427 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6428 | { |
| 6429 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6430 | { |
| 6431 | if (! first) |
| 6432 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6433 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6434 | first = 1; |
| 6435 | } |
| 6436 | } |
| 6437 | if (! first) |
| 6438 | vty_out (vty, " Not advertised to any peer"); |
| 6439 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6440 | } |
| 6441 | |
| 6442 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6443 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6444 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6445 | struct bgp_table *rib, const char *ip_str, |
| 6446 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6447 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6448 | { |
| 6449 | int ret; |
| 6450 | int header; |
| 6451 | int display = 0; |
| 6452 | struct prefix match; |
| 6453 | struct bgp_node *rn; |
| 6454 | struct bgp_node *rm; |
| 6455 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6456 | struct bgp_table *table; |
| 6457 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6458 | /* Check IP address argument. */ |
| 6459 | ret = str2prefix (ip_str, &match); |
| 6460 | if (! ret) |
| 6461 | { |
| 6462 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6463 | return CMD_WARNING; |
| 6464 | } |
| 6465 | |
| 6466 | match.family = afi2family (afi); |
| 6467 | |
| 6468 | if (safi == SAFI_MPLS_VPN) |
| 6469 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6470 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6471 | { |
| 6472 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6473 | continue; |
| 6474 | |
| 6475 | if ((table = rn->info) != NULL) |
| 6476 | { |
| 6477 | header = 1; |
| 6478 | |
| 6479 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6480 | { |
| 6481 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6482 | { |
| 6483 | bgp_unlock_node (rm); |
| 6484 | continue; |
| 6485 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6486 | |
| 6487 | for (ri = rm->info; ri; ri = ri->next) |
| 6488 | { |
| 6489 | if (header) |
| 6490 | { |
| 6491 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 6492 | AFI_IP, SAFI_MPLS_VPN); |
| 6493 | |
| 6494 | header = 0; |
| 6495 | } |
| 6496 | display++; |
| 6497 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 6498 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6499 | |
| 6500 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6501 | } |
| 6502 | } |
| 6503 | } |
| 6504 | } |
| 6505 | else |
| 6506 | { |
| 6507 | header = 1; |
| 6508 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6509 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6510 | { |
| 6511 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6512 | { |
| 6513 | for (ri = rn->info; ri; ri = ri->next) |
| 6514 | { |
| 6515 | if (header) |
| 6516 | { |
| 6517 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6518 | header = 0; |
| 6519 | } |
| 6520 | display++; |
| 6521 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6522 | } |
| 6523 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6524 | |
| 6525 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6526 | } |
| 6527 | } |
| 6528 | |
| 6529 | if (! display) |
| 6530 | { |
| 6531 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6532 | return CMD_WARNING; |
| 6533 | } |
| 6534 | |
| 6535 | return CMD_SUCCESS; |
| 6536 | } |
| 6537 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6538 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6539 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6540 | 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] | 6541 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6542 | int prefix_check) |
| 6543 | { |
| 6544 | struct bgp *bgp; |
| 6545 | |
| 6546 | /* BGP structure lookup. */ |
| 6547 | if (view_name) |
| 6548 | { |
| 6549 | bgp = bgp_lookup_by_name (view_name); |
| 6550 | if (bgp == NULL) |
| 6551 | { |
| 6552 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6553 | return CMD_WARNING; |
| 6554 | } |
| 6555 | } |
| 6556 | else |
| 6557 | { |
| 6558 | bgp = bgp_get_default (); |
| 6559 | if (bgp == NULL) |
| 6560 | { |
| 6561 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6562 | return CMD_WARNING; |
| 6563 | } |
| 6564 | } |
| 6565 | |
| 6566 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6567 | afi, safi, prd, prefix_check); |
| 6568 | } |
| 6569 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6570 | /* BGP route print out function. */ |
| 6571 | DEFUN (show_ip_bgp, |
| 6572 | show_ip_bgp_cmd, |
| 6573 | "show ip bgp", |
| 6574 | SHOW_STR |
| 6575 | IP_STR |
| 6576 | BGP_STR) |
| 6577 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6578 | 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] | 6579 | } |
| 6580 | |
| 6581 | DEFUN (show_ip_bgp_ipv4, |
| 6582 | show_ip_bgp_ipv4_cmd, |
| 6583 | "show ip bgp ipv4 (unicast|multicast)", |
| 6584 | SHOW_STR |
| 6585 | IP_STR |
| 6586 | BGP_STR |
| 6587 | "Address family\n" |
| 6588 | "Address Family modifier\n" |
| 6589 | "Address Family modifier\n") |
| 6590 | { |
| 6591 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6592 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6593 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6594 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6595 | 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] | 6596 | } |
| 6597 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6598 | ALIAS (show_ip_bgp_ipv4, |
| 6599 | show_bgp_ipv4_safi_cmd, |
| 6600 | "show bgp ipv4 (unicast|multicast)", |
| 6601 | SHOW_STR |
| 6602 | BGP_STR |
| 6603 | "Address family\n" |
| 6604 | "Address Family modifier\n" |
| 6605 | "Address Family modifier\n") |
| 6606 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6607 | DEFUN (show_ip_bgp_route, |
| 6608 | show_ip_bgp_route_cmd, |
| 6609 | "show ip bgp A.B.C.D", |
| 6610 | SHOW_STR |
| 6611 | IP_STR |
| 6612 | BGP_STR |
| 6613 | "Network in the BGP routing table to display\n") |
| 6614 | { |
| 6615 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6616 | } |
| 6617 | |
| 6618 | DEFUN (show_ip_bgp_ipv4_route, |
| 6619 | show_ip_bgp_ipv4_route_cmd, |
| 6620 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6621 | SHOW_STR |
| 6622 | IP_STR |
| 6623 | BGP_STR |
| 6624 | "Address family\n" |
| 6625 | "Address Family modifier\n" |
| 6626 | "Address Family modifier\n" |
| 6627 | "Network in the BGP routing table to display\n") |
| 6628 | { |
| 6629 | if (strncmp (argv[0], "m", 1) == 0) |
| 6630 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6631 | |
| 6632 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6633 | } |
| 6634 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6635 | ALIAS (show_ip_bgp_ipv4_route, |
| 6636 | show_bgp_ipv4_safi_route_cmd, |
| 6637 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6638 | SHOW_STR |
| 6639 | BGP_STR |
| 6640 | "Address family\n" |
| 6641 | "Address Family modifier\n" |
| 6642 | "Address Family modifier\n" |
| 6643 | "Network in the BGP routing table to display\n") |
| 6644 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6645 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6646 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6647 | "show ip bgp vpnv4 all A.B.C.D", |
| 6648 | SHOW_STR |
| 6649 | IP_STR |
| 6650 | BGP_STR |
| 6651 | "Display VPNv4 NLRI specific information\n" |
| 6652 | "Display information about all VPNv4 NLRIs\n" |
| 6653 | "Network in the BGP routing table to display\n") |
| 6654 | { |
| 6655 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6656 | } |
| 6657 | |
| 6658 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6659 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6660 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6661 | SHOW_STR |
| 6662 | IP_STR |
| 6663 | BGP_STR |
| 6664 | "Display VPNv4 NLRI specific information\n" |
| 6665 | "Display information for a route distinguisher\n" |
| 6666 | "VPN Route Distinguisher\n" |
| 6667 | "Network in the BGP routing table to display\n") |
| 6668 | { |
| 6669 | int ret; |
| 6670 | struct prefix_rd prd; |
| 6671 | |
| 6672 | ret = str2prefix_rd (argv[0], &prd); |
| 6673 | if (! ret) |
| 6674 | { |
| 6675 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6676 | return CMD_WARNING; |
| 6677 | } |
| 6678 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6679 | } |
| 6680 | |
| 6681 | DEFUN (show_ip_bgp_prefix, |
| 6682 | show_ip_bgp_prefix_cmd, |
| 6683 | "show ip bgp A.B.C.D/M", |
| 6684 | SHOW_STR |
| 6685 | IP_STR |
| 6686 | BGP_STR |
| 6687 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6688 | { |
| 6689 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6690 | } |
| 6691 | |
| 6692 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6693 | show_ip_bgp_ipv4_prefix_cmd, |
| 6694 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6695 | SHOW_STR |
| 6696 | IP_STR |
| 6697 | BGP_STR |
| 6698 | "Address family\n" |
| 6699 | "Address Family modifier\n" |
| 6700 | "Address Family modifier\n" |
| 6701 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6702 | { |
| 6703 | if (strncmp (argv[0], "m", 1) == 0) |
| 6704 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6705 | |
| 6706 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6707 | } |
| 6708 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6709 | ALIAS (show_ip_bgp_ipv4_prefix, |
| 6710 | show_bgp_ipv4_safi_prefix_cmd, |
| 6711 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6712 | SHOW_STR |
| 6713 | BGP_STR |
| 6714 | "Address family\n" |
| 6715 | "Address Family modifier\n" |
| 6716 | "Address Family modifier\n" |
| 6717 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6718 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6719 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 6720 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 6721 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 6722 | SHOW_STR |
| 6723 | IP_STR |
| 6724 | BGP_STR |
| 6725 | "Display VPNv4 NLRI specific information\n" |
| 6726 | "Display information about all VPNv4 NLRIs\n" |
| 6727 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6728 | { |
| 6729 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 6730 | } |
| 6731 | |
| 6732 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 6733 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 6734 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 6735 | SHOW_STR |
| 6736 | IP_STR |
| 6737 | BGP_STR |
| 6738 | "Display VPNv4 NLRI specific information\n" |
| 6739 | "Display information for a route distinguisher\n" |
| 6740 | "VPN Route Distinguisher\n" |
| 6741 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6742 | { |
| 6743 | int ret; |
| 6744 | struct prefix_rd prd; |
| 6745 | |
| 6746 | ret = str2prefix_rd (argv[0], &prd); |
| 6747 | if (! ret) |
| 6748 | { |
| 6749 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6750 | return CMD_WARNING; |
| 6751 | } |
| 6752 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 6753 | } |
| 6754 | |
| 6755 | DEFUN (show_ip_bgp_view, |
| 6756 | show_ip_bgp_view_cmd, |
| 6757 | "show ip bgp view WORD", |
| 6758 | SHOW_STR |
| 6759 | IP_STR |
| 6760 | BGP_STR |
| 6761 | "BGP view\n" |
| 6762 | "BGP view name\n") |
| 6763 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6764 | struct bgp *bgp; |
| 6765 | |
| 6766 | /* BGP structure lookup. */ |
| 6767 | bgp = bgp_lookup_by_name (argv[0]); |
| 6768 | if (bgp == NULL) |
| 6769 | { |
| 6770 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6771 | return CMD_WARNING; |
| 6772 | } |
| 6773 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6774 | 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] | 6775 | } |
| 6776 | |
| 6777 | DEFUN (show_ip_bgp_view_route, |
| 6778 | show_ip_bgp_view_route_cmd, |
| 6779 | "show ip bgp view WORD A.B.C.D", |
| 6780 | SHOW_STR |
| 6781 | IP_STR |
| 6782 | BGP_STR |
| 6783 | "BGP view\n" |
| 6784 | "BGP view name\n" |
| 6785 | "Network in the BGP routing table to display\n") |
| 6786 | { |
| 6787 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6788 | } |
| 6789 | |
| 6790 | DEFUN (show_ip_bgp_view_prefix, |
| 6791 | show_ip_bgp_view_prefix_cmd, |
| 6792 | "show ip bgp view WORD A.B.C.D/M", |
| 6793 | SHOW_STR |
| 6794 | IP_STR |
| 6795 | BGP_STR |
| 6796 | "BGP view\n" |
| 6797 | "BGP view name\n" |
| 6798 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6799 | { |
| 6800 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6801 | } |
| 6802 | |
| 6803 | #ifdef HAVE_IPV6 |
| 6804 | DEFUN (show_bgp, |
| 6805 | show_bgp_cmd, |
| 6806 | "show bgp", |
| 6807 | SHOW_STR |
| 6808 | BGP_STR) |
| 6809 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6810 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6811 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6812 | } |
| 6813 | |
| 6814 | ALIAS (show_bgp, |
| 6815 | show_bgp_ipv6_cmd, |
| 6816 | "show bgp ipv6", |
| 6817 | SHOW_STR |
| 6818 | BGP_STR |
| 6819 | "Address family\n") |
| 6820 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6821 | DEFUN (show_bgp_ipv6_safi, |
| 6822 | show_bgp_ipv6_safi_cmd, |
| 6823 | "show bgp ipv6 (unicast|multicast)", |
| 6824 | SHOW_STR |
| 6825 | BGP_STR |
| 6826 | "Address family\n" |
| 6827 | "Address Family modifier\n" |
| 6828 | "Address Family modifier\n") |
| 6829 | { |
| 6830 | if (strncmp (argv[0], "m", 1) == 0) |
| 6831 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6832 | NULL); |
| 6833 | |
| 6834 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6835 | } |
| 6836 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6837 | /* old command */ |
| 6838 | DEFUN (show_ipv6_bgp, |
| 6839 | show_ipv6_bgp_cmd, |
| 6840 | "show ipv6 bgp", |
| 6841 | SHOW_STR |
| 6842 | IP_STR |
| 6843 | BGP_STR) |
| 6844 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6845 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6846 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6847 | } |
| 6848 | |
| 6849 | DEFUN (show_bgp_route, |
| 6850 | show_bgp_route_cmd, |
| 6851 | "show bgp X:X::X:X", |
| 6852 | SHOW_STR |
| 6853 | BGP_STR |
| 6854 | "Network in the BGP routing table to display\n") |
| 6855 | { |
| 6856 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6857 | } |
| 6858 | |
| 6859 | ALIAS (show_bgp_route, |
| 6860 | show_bgp_ipv6_route_cmd, |
| 6861 | "show bgp ipv6 X:X::X:X", |
| 6862 | SHOW_STR |
| 6863 | BGP_STR |
| 6864 | "Address family\n" |
| 6865 | "Network in the BGP routing table to display\n") |
| 6866 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6867 | DEFUN (show_bgp_ipv6_safi_route, |
| 6868 | show_bgp_ipv6_safi_route_cmd, |
| 6869 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
| 6870 | SHOW_STR |
| 6871 | BGP_STR |
| 6872 | "Address family\n" |
| 6873 | "Address Family modifier\n" |
| 6874 | "Address Family modifier\n" |
| 6875 | "Network in the BGP routing table to display\n") |
| 6876 | { |
| 6877 | if (strncmp (argv[0], "m", 1) == 0) |
| 6878 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6879 | |
| 6880 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6881 | } |
| 6882 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6883 | /* old command */ |
| 6884 | DEFUN (show_ipv6_bgp_route, |
| 6885 | show_ipv6_bgp_route_cmd, |
| 6886 | "show ipv6 bgp X:X::X:X", |
| 6887 | SHOW_STR |
| 6888 | IP_STR |
| 6889 | BGP_STR |
| 6890 | "Network in the BGP routing table to display\n") |
| 6891 | { |
| 6892 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6893 | } |
| 6894 | |
| 6895 | DEFUN (show_bgp_prefix, |
| 6896 | show_bgp_prefix_cmd, |
| 6897 | "show bgp X:X::X:X/M", |
| 6898 | SHOW_STR |
| 6899 | BGP_STR |
| 6900 | "IPv6 prefix <network>/<length>\n") |
| 6901 | { |
| 6902 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6903 | } |
| 6904 | |
| 6905 | ALIAS (show_bgp_prefix, |
| 6906 | show_bgp_ipv6_prefix_cmd, |
| 6907 | "show bgp ipv6 X:X::X:X/M", |
| 6908 | SHOW_STR |
| 6909 | BGP_STR |
| 6910 | "Address family\n" |
| 6911 | "IPv6 prefix <network>/<length>\n") |
| 6912 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6913 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 6914 | show_bgp_ipv6_safi_prefix_cmd, |
| 6915 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 6916 | SHOW_STR |
| 6917 | BGP_STR |
| 6918 | "Address family\n" |
| 6919 | "Address Family modifier\n" |
| 6920 | "Address Family modifier\n" |
| 6921 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6922 | { |
| 6923 | if (strncmp (argv[0], "m", 1) == 0) |
| 6924 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 6925 | |
| 6926 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6927 | } |
| 6928 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6929 | /* old command */ |
| 6930 | DEFUN (show_ipv6_bgp_prefix, |
| 6931 | show_ipv6_bgp_prefix_cmd, |
| 6932 | "show ipv6 bgp X:X::X:X/M", |
| 6933 | SHOW_STR |
| 6934 | IP_STR |
| 6935 | BGP_STR |
| 6936 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6937 | { |
| 6938 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6939 | } |
| 6940 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6941 | DEFUN (show_bgp_view, |
| 6942 | show_bgp_view_cmd, |
| 6943 | "show bgp view WORD", |
| 6944 | SHOW_STR |
| 6945 | BGP_STR |
| 6946 | "BGP view\n" |
| 6947 | "View name\n") |
| 6948 | { |
| 6949 | struct bgp *bgp; |
| 6950 | |
| 6951 | /* BGP structure lookup. */ |
| 6952 | bgp = bgp_lookup_by_name (argv[0]); |
| 6953 | if (bgp == NULL) |
| 6954 | { |
| 6955 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6956 | return CMD_WARNING; |
| 6957 | } |
| 6958 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6959 | 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] | 6960 | } |
| 6961 | |
| 6962 | ALIAS (show_bgp_view, |
| 6963 | show_bgp_view_ipv6_cmd, |
| 6964 | "show bgp view WORD ipv6", |
| 6965 | SHOW_STR |
| 6966 | BGP_STR |
| 6967 | "BGP view\n" |
| 6968 | "View name\n" |
| 6969 | "Address family\n") |
| 6970 | |
| 6971 | DEFUN (show_bgp_view_route, |
| 6972 | show_bgp_view_route_cmd, |
| 6973 | "show bgp view WORD X:X::X:X", |
| 6974 | SHOW_STR |
| 6975 | BGP_STR |
| 6976 | "BGP view\n" |
| 6977 | "View name\n" |
| 6978 | "Network in the BGP routing table to display\n") |
| 6979 | { |
| 6980 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6981 | } |
| 6982 | |
| 6983 | ALIAS (show_bgp_view_route, |
| 6984 | show_bgp_view_ipv6_route_cmd, |
| 6985 | "show bgp view WORD ipv6 X:X::X:X", |
| 6986 | SHOW_STR |
| 6987 | BGP_STR |
| 6988 | "BGP view\n" |
| 6989 | "View name\n" |
| 6990 | "Address family\n" |
| 6991 | "Network in the BGP routing table to display\n") |
| 6992 | |
| 6993 | DEFUN (show_bgp_view_prefix, |
| 6994 | show_bgp_view_prefix_cmd, |
| 6995 | "show bgp view WORD X:X::X:X/M", |
| 6996 | SHOW_STR |
| 6997 | BGP_STR |
| 6998 | "BGP view\n" |
| 6999 | "View name\n" |
| 7000 | "IPv6 prefix <network>/<length>\n") |
| 7001 | { |
| 7002 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7003 | } |
| 7004 | |
| 7005 | ALIAS (show_bgp_view_prefix, |
| 7006 | show_bgp_view_ipv6_prefix_cmd, |
| 7007 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 7008 | SHOW_STR |
| 7009 | BGP_STR |
| 7010 | "BGP view\n" |
| 7011 | "View name\n" |
| 7012 | "Address family\n" |
| 7013 | "IPv6 prefix <network>/<length>\n") |
| 7014 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7015 | /* old command */ |
| 7016 | DEFUN (show_ipv6_mbgp, |
| 7017 | show_ipv6_mbgp_cmd, |
| 7018 | "show ipv6 mbgp", |
| 7019 | SHOW_STR |
| 7020 | IP_STR |
| 7021 | MBGP_STR) |
| 7022 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7023 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7024 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7025 | } |
| 7026 | |
| 7027 | /* old command */ |
| 7028 | DEFUN (show_ipv6_mbgp_route, |
| 7029 | show_ipv6_mbgp_route_cmd, |
| 7030 | "show ipv6 mbgp X:X::X:X", |
| 7031 | SHOW_STR |
| 7032 | IP_STR |
| 7033 | MBGP_STR |
| 7034 | "Network in the MBGP routing table to display\n") |
| 7035 | { |
| 7036 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7037 | } |
| 7038 | |
| 7039 | /* old command */ |
| 7040 | DEFUN (show_ipv6_mbgp_prefix, |
| 7041 | show_ipv6_mbgp_prefix_cmd, |
| 7042 | "show ipv6 mbgp X:X::X:X/M", |
| 7043 | SHOW_STR |
| 7044 | IP_STR |
| 7045 | MBGP_STR |
| 7046 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7047 | { |
| 7048 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7049 | } |
| 7050 | #endif |
| 7051 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7052 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7053 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7054 | 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] | 7055 | safi_t safi, enum bgp_show_type type) |
| 7056 | { |
| 7057 | int i; |
| 7058 | struct buffer *b; |
| 7059 | char *regstr; |
| 7060 | int first; |
| 7061 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7062 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7063 | |
| 7064 | first = 0; |
| 7065 | b = buffer_new (1024); |
| 7066 | for (i = 0; i < argc; i++) |
| 7067 | { |
| 7068 | if (first) |
| 7069 | buffer_putc (b, ' '); |
| 7070 | else |
| 7071 | { |
| 7072 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7073 | continue; |
| 7074 | first = 1; |
| 7075 | } |
| 7076 | |
| 7077 | buffer_putstr (b, argv[i]); |
| 7078 | } |
| 7079 | buffer_putc (b, '\0'); |
| 7080 | |
| 7081 | regstr = buffer_getstr (b); |
| 7082 | buffer_free (b); |
| 7083 | |
| 7084 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7085 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7086 | if (! regex) |
| 7087 | { |
| 7088 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 7089 | VTY_NEWLINE); |
| 7090 | return CMD_WARNING; |
| 7091 | } |
| 7092 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7093 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 7094 | bgp_regex_free (regex); |
| 7095 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7096 | } |
| 7097 | |
| 7098 | DEFUN (show_ip_bgp_regexp, |
| 7099 | show_ip_bgp_regexp_cmd, |
| 7100 | "show ip bgp regexp .LINE", |
| 7101 | SHOW_STR |
| 7102 | IP_STR |
| 7103 | BGP_STR |
| 7104 | "Display routes matching the AS path regular expression\n" |
| 7105 | "A regular-expression to match the BGP AS paths\n") |
| 7106 | { |
| 7107 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7108 | bgp_show_type_regexp); |
| 7109 | } |
| 7110 | |
| 7111 | DEFUN (show_ip_bgp_flap_regexp, |
| 7112 | show_ip_bgp_flap_regexp_cmd, |
| 7113 | "show ip bgp flap-statistics regexp .LINE", |
| 7114 | SHOW_STR |
| 7115 | IP_STR |
| 7116 | BGP_STR |
| 7117 | "Display flap statistics of routes\n" |
| 7118 | "Display routes matching the AS path regular expression\n" |
| 7119 | "A regular-expression to match the BGP AS paths\n") |
| 7120 | { |
| 7121 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7122 | bgp_show_type_flap_regexp); |
| 7123 | } |
| 7124 | |
| 7125 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 7126 | show_ip_bgp_ipv4_regexp_cmd, |
| 7127 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 7128 | SHOW_STR |
| 7129 | IP_STR |
| 7130 | BGP_STR |
| 7131 | "Address family\n" |
| 7132 | "Address Family modifier\n" |
| 7133 | "Address Family modifier\n" |
| 7134 | "Display routes matching the AS path regular expression\n" |
| 7135 | "A regular-expression to match the BGP AS paths\n") |
| 7136 | { |
| 7137 | if (strncmp (argv[0], "m", 1) == 0) |
| 7138 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 7139 | bgp_show_type_regexp); |
| 7140 | |
| 7141 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7142 | bgp_show_type_regexp); |
| 7143 | } |
| 7144 | |
| 7145 | #ifdef HAVE_IPV6 |
| 7146 | DEFUN (show_bgp_regexp, |
| 7147 | show_bgp_regexp_cmd, |
| 7148 | "show bgp regexp .LINE", |
| 7149 | SHOW_STR |
| 7150 | BGP_STR |
| 7151 | "Display routes matching the AS path regular expression\n" |
| 7152 | "A regular-expression to match the BGP AS paths\n") |
| 7153 | { |
| 7154 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7155 | bgp_show_type_regexp); |
| 7156 | } |
| 7157 | |
| 7158 | ALIAS (show_bgp_regexp, |
| 7159 | show_bgp_ipv6_regexp_cmd, |
| 7160 | "show bgp ipv6 regexp .LINE", |
| 7161 | SHOW_STR |
| 7162 | BGP_STR |
| 7163 | "Address family\n" |
| 7164 | "Display routes matching the AS path regular expression\n" |
| 7165 | "A regular-expression to match the BGP AS paths\n") |
| 7166 | |
| 7167 | /* old command */ |
| 7168 | DEFUN (show_ipv6_bgp_regexp, |
| 7169 | show_ipv6_bgp_regexp_cmd, |
| 7170 | "show ipv6 bgp regexp .LINE", |
| 7171 | SHOW_STR |
| 7172 | IP_STR |
| 7173 | BGP_STR |
| 7174 | "Display routes matching the AS path regular expression\n" |
| 7175 | "A regular-expression to match the BGP AS paths\n") |
| 7176 | { |
| 7177 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7178 | bgp_show_type_regexp); |
| 7179 | } |
| 7180 | |
| 7181 | /* old command */ |
| 7182 | DEFUN (show_ipv6_mbgp_regexp, |
| 7183 | show_ipv6_mbgp_regexp_cmd, |
| 7184 | "show ipv6 mbgp regexp .LINE", |
| 7185 | SHOW_STR |
| 7186 | IP_STR |
| 7187 | BGP_STR |
| 7188 | "Display routes matching the AS path regular expression\n" |
| 7189 | "A regular-expression to match the MBGP AS paths\n") |
| 7190 | { |
| 7191 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 7192 | bgp_show_type_regexp); |
| 7193 | } |
| 7194 | #endif /* HAVE_IPV6 */ |
| 7195 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7196 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7197 | 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] | 7198 | safi_t safi, enum bgp_show_type type) |
| 7199 | { |
| 7200 | struct prefix_list *plist; |
| 7201 | |
| 7202 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 7203 | if (plist == NULL) |
| 7204 | { |
| 7205 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 7206 | prefix_list_str, VTY_NEWLINE); |
| 7207 | return CMD_WARNING; |
| 7208 | } |
| 7209 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7210 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7211 | } |
| 7212 | |
| 7213 | DEFUN (show_ip_bgp_prefix_list, |
| 7214 | show_ip_bgp_prefix_list_cmd, |
| 7215 | "show ip bgp prefix-list WORD", |
| 7216 | SHOW_STR |
| 7217 | IP_STR |
| 7218 | BGP_STR |
| 7219 | "Display routes conforming to the prefix-list\n" |
| 7220 | "IP prefix-list name\n") |
| 7221 | { |
| 7222 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7223 | bgp_show_type_prefix_list); |
| 7224 | } |
| 7225 | |
| 7226 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 7227 | show_ip_bgp_flap_prefix_list_cmd, |
| 7228 | "show ip bgp flap-statistics prefix-list WORD", |
| 7229 | SHOW_STR |
| 7230 | IP_STR |
| 7231 | BGP_STR |
| 7232 | "Display flap statistics of routes\n" |
| 7233 | "Display routes conforming to the prefix-list\n" |
| 7234 | "IP prefix-list name\n") |
| 7235 | { |
| 7236 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7237 | bgp_show_type_flap_prefix_list); |
| 7238 | } |
| 7239 | |
| 7240 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 7241 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 7242 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 7243 | SHOW_STR |
| 7244 | IP_STR |
| 7245 | BGP_STR |
| 7246 | "Address family\n" |
| 7247 | "Address Family modifier\n" |
| 7248 | "Address Family modifier\n" |
| 7249 | "Display routes conforming to the prefix-list\n" |
| 7250 | "IP prefix-list name\n") |
| 7251 | { |
| 7252 | if (strncmp (argv[0], "m", 1) == 0) |
| 7253 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7254 | bgp_show_type_prefix_list); |
| 7255 | |
| 7256 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7257 | bgp_show_type_prefix_list); |
| 7258 | } |
| 7259 | |
| 7260 | #ifdef HAVE_IPV6 |
| 7261 | DEFUN (show_bgp_prefix_list, |
| 7262 | show_bgp_prefix_list_cmd, |
| 7263 | "show bgp prefix-list WORD", |
| 7264 | SHOW_STR |
| 7265 | BGP_STR |
| 7266 | "Display routes conforming to the prefix-list\n" |
| 7267 | "IPv6 prefix-list name\n") |
| 7268 | { |
| 7269 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7270 | bgp_show_type_prefix_list); |
| 7271 | } |
| 7272 | |
| 7273 | ALIAS (show_bgp_prefix_list, |
| 7274 | show_bgp_ipv6_prefix_list_cmd, |
| 7275 | "show bgp ipv6 prefix-list WORD", |
| 7276 | SHOW_STR |
| 7277 | BGP_STR |
| 7278 | "Address family\n" |
| 7279 | "Display routes conforming to the prefix-list\n" |
| 7280 | "IPv6 prefix-list name\n") |
| 7281 | |
| 7282 | /* old command */ |
| 7283 | DEFUN (show_ipv6_bgp_prefix_list, |
| 7284 | show_ipv6_bgp_prefix_list_cmd, |
| 7285 | "show ipv6 bgp prefix-list WORD", |
| 7286 | SHOW_STR |
| 7287 | IPV6_STR |
| 7288 | BGP_STR |
| 7289 | "Display routes matching the prefix-list\n" |
| 7290 | "IPv6 prefix-list name\n") |
| 7291 | { |
| 7292 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7293 | bgp_show_type_prefix_list); |
| 7294 | } |
| 7295 | |
| 7296 | /* old command */ |
| 7297 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 7298 | show_ipv6_mbgp_prefix_list_cmd, |
| 7299 | "show ipv6 mbgp prefix-list WORD", |
| 7300 | SHOW_STR |
| 7301 | IPV6_STR |
| 7302 | MBGP_STR |
| 7303 | "Display routes matching the prefix-list\n" |
| 7304 | "IPv6 prefix-list name\n") |
| 7305 | { |
| 7306 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7307 | bgp_show_type_prefix_list); |
| 7308 | } |
| 7309 | #endif /* HAVE_IPV6 */ |
| 7310 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7311 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7312 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7313 | safi_t safi, enum bgp_show_type type) |
| 7314 | { |
| 7315 | struct as_list *as_list; |
| 7316 | |
| 7317 | as_list = as_list_lookup (filter); |
| 7318 | if (as_list == NULL) |
| 7319 | { |
| 7320 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 7321 | return CMD_WARNING; |
| 7322 | } |
| 7323 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7324 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7325 | } |
| 7326 | |
| 7327 | DEFUN (show_ip_bgp_filter_list, |
| 7328 | show_ip_bgp_filter_list_cmd, |
| 7329 | "show ip bgp filter-list WORD", |
| 7330 | SHOW_STR |
| 7331 | IP_STR |
| 7332 | BGP_STR |
| 7333 | "Display routes conforming to the filter-list\n" |
| 7334 | "Regular expression access list name\n") |
| 7335 | { |
| 7336 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7337 | bgp_show_type_filter_list); |
| 7338 | } |
| 7339 | |
| 7340 | DEFUN (show_ip_bgp_flap_filter_list, |
| 7341 | show_ip_bgp_flap_filter_list_cmd, |
| 7342 | "show ip bgp flap-statistics filter-list WORD", |
| 7343 | SHOW_STR |
| 7344 | IP_STR |
| 7345 | BGP_STR |
| 7346 | "Display flap statistics of routes\n" |
| 7347 | "Display routes conforming to the filter-list\n" |
| 7348 | "Regular expression access list name\n") |
| 7349 | { |
| 7350 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7351 | bgp_show_type_flap_filter_list); |
| 7352 | } |
| 7353 | |
| 7354 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 7355 | show_ip_bgp_ipv4_filter_list_cmd, |
| 7356 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 7357 | SHOW_STR |
| 7358 | IP_STR |
| 7359 | BGP_STR |
| 7360 | "Address family\n" |
| 7361 | "Address Family modifier\n" |
| 7362 | "Address Family modifier\n" |
| 7363 | "Display routes conforming to the filter-list\n" |
| 7364 | "Regular expression access list name\n") |
| 7365 | { |
| 7366 | if (strncmp (argv[0], "m", 1) == 0) |
| 7367 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7368 | bgp_show_type_filter_list); |
| 7369 | |
| 7370 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7371 | bgp_show_type_filter_list); |
| 7372 | } |
| 7373 | |
| 7374 | #ifdef HAVE_IPV6 |
| 7375 | DEFUN (show_bgp_filter_list, |
| 7376 | show_bgp_filter_list_cmd, |
| 7377 | "show bgp filter-list WORD", |
| 7378 | SHOW_STR |
| 7379 | BGP_STR |
| 7380 | "Display routes conforming to the filter-list\n" |
| 7381 | "Regular expression access list name\n") |
| 7382 | { |
| 7383 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7384 | bgp_show_type_filter_list); |
| 7385 | } |
| 7386 | |
| 7387 | ALIAS (show_bgp_filter_list, |
| 7388 | show_bgp_ipv6_filter_list_cmd, |
| 7389 | "show bgp ipv6 filter-list WORD", |
| 7390 | SHOW_STR |
| 7391 | BGP_STR |
| 7392 | "Address family\n" |
| 7393 | "Display routes conforming to the filter-list\n" |
| 7394 | "Regular expression access list name\n") |
| 7395 | |
| 7396 | /* old command */ |
| 7397 | DEFUN (show_ipv6_bgp_filter_list, |
| 7398 | show_ipv6_bgp_filter_list_cmd, |
| 7399 | "show ipv6 bgp filter-list WORD", |
| 7400 | SHOW_STR |
| 7401 | IPV6_STR |
| 7402 | BGP_STR |
| 7403 | "Display routes conforming to the filter-list\n" |
| 7404 | "Regular expression access list name\n") |
| 7405 | { |
| 7406 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7407 | bgp_show_type_filter_list); |
| 7408 | } |
| 7409 | |
| 7410 | /* old command */ |
| 7411 | DEFUN (show_ipv6_mbgp_filter_list, |
| 7412 | show_ipv6_mbgp_filter_list_cmd, |
| 7413 | "show ipv6 mbgp filter-list WORD", |
| 7414 | SHOW_STR |
| 7415 | IPV6_STR |
| 7416 | MBGP_STR |
| 7417 | "Display routes conforming to the filter-list\n" |
| 7418 | "Regular expression access list name\n") |
| 7419 | { |
| 7420 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7421 | bgp_show_type_filter_list); |
| 7422 | } |
| 7423 | #endif /* HAVE_IPV6 */ |
| 7424 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7425 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7426 | 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] | 7427 | safi_t safi, enum bgp_show_type type) |
| 7428 | { |
| 7429 | struct route_map *rmap; |
| 7430 | |
| 7431 | rmap = route_map_lookup_by_name (rmap_str); |
| 7432 | if (! rmap) |
| 7433 | { |
| 7434 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 7435 | rmap_str, VTY_NEWLINE); |
| 7436 | return CMD_WARNING; |
| 7437 | } |
| 7438 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7439 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7440 | } |
| 7441 | |
| 7442 | DEFUN (show_ip_bgp_route_map, |
| 7443 | show_ip_bgp_route_map_cmd, |
| 7444 | "show ip bgp route-map WORD", |
| 7445 | SHOW_STR |
| 7446 | IP_STR |
| 7447 | BGP_STR |
| 7448 | "Display routes matching the route-map\n" |
| 7449 | "A route-map to match on\n") |
| 7450 | { |
| 7451 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7452 | bgp_show_type_route_map); |
| 7453 | } |
| 7454 | |
| 7455 | DEFUN (show_ip_bgp_flap_route_map, |
| 7456 | show_ip_bgp_flap_route_map_cmd, |
| 7457 | "show ip bgp flap-statistics route-map WORD", |
| 7458 | SHOW_STR |
| 7459 | IP_STR |
| 7460 | BGP_STR |
| 7461 | "Display flap statistics of routes\n" |
| 7462 | "Display routes matching the route-map\n" |
| 7463 | "A route-map to match on\n") |
| 7464 | { |
| 7465 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7466 | bgp_show_type_flap_route_map); |
| 7467 | } |
| 7468 | |
| 7469 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 7470 | show_ip_bgp_ipv4_route_map_cmd, |
| 7471 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 7472 | SHOW_STR |
| 7473 | IP_STR |
| 7474 | BGP_STR |
| 7475 | "Address family\n" |
| 7476 | "Address Family modifier\n" |
| 7477 | "Address Family modifier\n" |
| 7478 | "Display routes matching the route-map\n" |
| 7479 | "A route-map to match on\n") |
| 7480 | { |
| 7481 | if (strncmp (argv[0], "m", 1) == 0) |
| 7482 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7483 | bgp_show_type_route_map); |
| 7484 | |
| 7485 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7486 | bgp_show_type_route_map); |
| 7487 | } |
| 7488 | |
| 7489 | DEFUN (show_bgp_route_map, |
| 7490 | show_bgp_route_map_cmd, |
| 7491 | "show bgp route-map WORD", |
| 7492 | SHOW_STR |
| 7493 | BGP_STR |
| 7494 | "Display routes matching the route-map\n" |
| 7495 | "A route-map to match on\n") |
| 7496 | { |
| 7497 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7498 | bgp_show_type_route_map); |
| 7499 | } |
| 7500 | |
| 7501 | ALIAS (show_bgp_route_map, |
| 7502 | show_bgp_ipv6_route_map_cmd, |
| 7503 | "show bgp ipv6 route-map WORD", |
| 7504 | SHOW_STR |
| 7505 | BGP_STR |
| 7506 | "Address family\n" |
| 7507 | "Display routes matching the route-map\n" |
| 7508 | "A route-map to match on\n") |
| 7509 | |
| 7510 | DEFUN (show_ip_bgp_cidr_only, |
| 7511 | show_ip_bgp_cidr_only_cmd, |
| 7512 | "show ip bgp cidr-only", |
| 7513 | SHOW_STR |
| 7514 | IP_STR |
| 7515 | BGP_STR |
| 7516 | "Display only routes with non-natural netmasks\n") |
| 7517 | { |
| 7518 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7519 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7520 | } |
| 7521 | |
| 7522 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 7523 | show_ip_bgp_flap_cidr_only_cmd, |
| 7524 | "show ip bgp flap-statistics cidr-only", |
| 7525 | SHOW_STR |
| 7526 | IP_STR |
| 7527 | BGP_STR |
| 7528 | "Display flap statistics of routes\n" |
| 7529 | "Display only routes with non-natural netmasks\n") |
| 7530 | { |
| 7531 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7532 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7533 | } |
| 7534 | |
| 7535 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 7536 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 7537 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 7538 | SHOW_STR |
| 7539 | IP_STR |
| 7540 | BGP_STR |
| 7541 | "Address family\n" |
| 7542 | "Address Family modifier\n" |
| 7543 | "Address Family modifier\n" |
| 7544 | "Display only routes with non-natural netmasks\n") |
| 7545 | { |
| 7546 | if (strncmp (argv[0], "m", 1) == 0) |
| 7547 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7548 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7552 | } |
| 7553 | |
| 7554 | DEFUN (show_ip_bgp_community_all, |
| 7555 | show_ip_bgp_community_all_cmd, |
| 7556 | "show ip bgp community", |
| 7557 | SHOW_STR |
| 7558 | IP_STR |
| 7559 | BGP_STR |
| 7560 | "Display routes matching the communities\n") |
| 7561 | { |
| 7562 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7563 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7564 | } |
| 7565 | |
| 7566 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 7567 | show_ip_bgp_ipv4_community_all_cmd, |
| 7568 | "show ip bgp ipv4 (unicast|multicast) community", |
| 7569 | SHOW_STR |
| 7570 | IP_STR |
| 7571 | BGP_STR |
| 7572 | "Address family\n" |
| 7573 | "Address Family modifier\n" |
| 7574 | "Address Family modifier\n" |
| 7575 | "Display routes matching the communities\n") |
| 7576 | { |
| 7577 | if (strncmp (argv[0], "m", 1) == 0) |
| 7578 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7579 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7580 | |
| 7581 | return bgp_show (vty, NULL, AFI_IP, 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 | #ifdef HAVE_IPV6 |
| 7586 | DEFUN (show_bgp_community_all, |
| 7587 | show_bgp_community_all_cmd, |
| 7588 | "show bgp community", |
| 7589 | SHOW_STR |
| 7590 | BGP_STR |
| 7591 | "Display routes matching the communities\n") |
| 7592 | { |
| 7593 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7594 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7595 | } |
| 7596 | |
| 7597 | ALIAS (show_bgp_community_all, |
| 7598 | show_bgp_ipv6_community_all_cmd, |
| 7599 | "show bgp ipv6 community", |
| 7600 | SHOW_STR |
| 7601 | BGP_STR |
| 7602 | "Address family\n" |
| 7603 | "Display routes matching the communities\n") |
| 7604 | |
| 7605 | /* old command */ |
| 7606 | DEFUN (show_ipv6_bgp_community_all, |
| 7607 | show_ipv6_bgp_community_all_cmd, |
| 7608 | "show ipv6 bgp community", |
| 7609 | SHOW_STR |
| 7610 | IPV6_STR |
| 7611 | BGP_STR |
| 7612 | "Display routes matching the communities\n") |
| 7613 | { |
| 7614 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7615 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7616 | } |
| 7617 | |
| 7618 | /* old command */ |
| 7619 | DEFUN (show_ipv6_mbgp_community_all, |
| 7620 | show_ipv6_mbgp_community_all_cmd, |
| 7621 | "show ipv6 mbgp community", |
| 7622 | SHOW_STR |
| 7623 | IPV6_STR |
| 7624 | MBGP_STR |
| 7625 | "Display routes matching the communities\n") |
| 7626 | { |
| 7627 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7628 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7629 | } |
| 7630 | #endif /* HAVE_IPV6 */ |
| 7631 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7632 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7633 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 7634 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7635 | { |
| 7636 | struct community *com; |
| 7637 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7638 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7639 | int i; |
| 7640 | char *str; |
| 7641 | int first = 0; |
| 7642 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7643 | /* BGP structure lookup */ |
| 7644 | if (view_name) |
| 7645 | { |
| 7646 | bgp = bgp_lookup_by_name (view_name); |
| 7647 | if (bgp == NULL) |
| 7648 | { |
| 7649 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 7650 | return CMD_WARNING; |
| 7651 | } |
| 7652 | } |
| 7653 | else |
| 7654 | { |
| 7655 | bgp = bgp_get_default (); |
| 7656 | if (bgp == NULL) |
| 7657 | { |
| 7658 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 7659 | return CMD_WARNING; |
| 7660 | } |
| 7661 | } |
| 7662 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7663 | b = buffer_new (1024); |
| 7664 | for (i = 0; i < argc; i++) |
| 7665 | { |
| 7666 | if (first) |
| 7667 | buffer_putc (b, ' '); |
| 7668 | else |
| 7669 | { |
| 7670 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7671 | continue; |
| 7672 | first = 1; |
| 7673 | } |
| 7674 | |
| 7675 | buffer_putstr (b, argv[i]); |
| 7676 | } |
| 7677 | buffer_putc (b, '\0'); |
| 7678 | |
| 7679 | str = buffer_getstr (b); |
| 7680 | buffer_free (b); |
| 7681 | |
| 7682 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7683 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7684 | if (! com) |
| 7685 | { |
| 7686 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 7687 | return CMD_WARNING; |
| 7688 | } |
| 7689 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7690 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7691 | (exact ? bgp_show_type_community_exact : |
| 7692 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7693 | } |
| 7694 | |
| 7695 | DEFUN (show_ip_bgp_community, |
| 7696 | show_ip_bgp_community_cmd, |
| 7697 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7698 | SHOW_STR |
| 7699 | IP_STR |
| 7700 | BGP_STR |
| 7701 | "Display routes matching the communities\n" |
| 7702 | "community number\n" |
| 7703 | "Do not send outside local AS (well-known community)\n" |
| 7704 | "Do not advertise to any peer (well-known community)\n" |
| 7705 | "Do not export to next AS (well-known community)\n") |
| 7706 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7707 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7708 | } |
| 7709 | |
| 7710 | ALIAS (show_ip_bgp_community, |
| 7711 | show_ip_bgp_community2_cmd, |
| 7712 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7713 | SHOW_STR |
| 7714 | IP_STR |
| 7715 | BGP_STR |
| 7716 | "Display routes matching the communities\n" |
| 7717 | "community number\n" |
| 7718 | "Do not send outside local AS (well-known community)\n" |
| 7719 | "Do not advertise to any peer (well-known community)\n" |
| 7720 | "Do not export to next AS (well-known community)\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 | |
| 7726 | ALIAS (show_ip_bgp_community, |
| 7727 | show_ip_bgp_community3_cmd, |
| 7728 | "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)", |
| 7729 | SHOW_STR |
| 7730 | IP_STR |
| 7731 | BGP_STR |
| 7732 | "Display routes matching the communities\n" |
| 7733 | "community number\n" |
| 7734 | "Do not send outside local AS (well-known community)\n" |
| 7735 | "Do not advertise to any peer (well-known community)\n" |
| 7736 | "Do not export to next AS (well-known community)\n" |
| 7737 | "community number\n" |
| 7738 | "Do not send outside local AS (well-known community)\n" |
| 7739 | "Do not advertise to any peer (well-known community)\n" |
| 7740 | "Do not export to next AS (well-known community)\n" |
| 7741 | "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 | |
| 7746 | ALIAS (show_ip_bgp_community, |
| 7747 | show_ip_bgp_community4_cmd, |
| 7748 | "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)", |
| 7749 | SHOW_STR |
| 7750 | IP_STR |
| 7751 | BGP_STR |
| 7752 | "Display routes matching the communities\n" |
| 7753 | "community number\n" |
| 7754 | "Do not send outside local AS (well-known community)\n" |
| 7755 | "Do not advertise to any peer (well-known community)\n" |
| 7756 | "Do not export to next AS (well-known community)\n" |
| 7757 | "community number\n" |
| 7758 | "Do not send outside local AS (well-known community)\n" |
| 7759 | "Do not advertise to any peer (well-known community)\n" |
| 7760 | "Do not export to next AS (well-known community)\n" |
| 7761 | "community number\n" |
| 7762 | "Do not send outside local AS (well-known community)\n" |
| 7763 | "Do not advertise to any peer (well-known community)\n" |
| 7764 | "Do not export to next AS (well-known community)\n" |
| 7765 | "community number\n" |
| 7766 | "Do not send outside local AS (well-known community)\n" |
| 7767 | "Do not advertise to any peer (well-known community)\n" |
| 7768 | "Do not export to next AS (well-known community)\n") |
| 7769 | |
| 7770 | DEFUN (show_ip_bgp_ipv4_community, |
| 7771 | show_ip_bgp_ipv4_community_cmd, |
| 7772 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7773 | SHOW_STR |
| 7774 | IP_STR |
| 7775 | BGP_STR |
| 7776 | "Address family\n" |
| 7777 | "Address Family modifier\n" |
| 7778 | "Address Family modifier\n" |
| 7779 | "Display routes matching the communities\n" |
| 7780 | "community number\n" |
| 7781 | "Do not send outside local AS (well-known community)\n" |
| 7782 | "Do not advertise to any peer (well-known community)\n" |
| 7783 | "Do not export to next AS (well-known community)\n") |
| 7784 | { |
| 7785 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7786 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7787 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7788 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7789 | } |
| 7790 | |
| 7791 | ALIAS (show_ip_bgp_ipv4_community, |
| 7792 | show_ip_bgp_ipv4_community2_cmd, |
| 7793 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7794 | SHOW_STR |
| 7795 | IP_STR |
| 7796 | BGP_STR |
| 7797 | "Address family\n" |
| 7798 | "Address Family modifier\n" |
| 7799 | "Address Family modifier\n" |
| 7800 | "Display routes matching the communities\n" |
| 7801 | "community number\n" |
| 7802 | "Do not send outside local AS (well-known community)\n" |
| 7803 | "Do not advertise to any peer (well-known community)\n" |
| 7804 | "Do not export to next AS (well-known community)\n" |
| 7805 | "community number\n" |
| 7806 | "Do not send outside local AS (well-known community)\n" |
| 7807 | "Do not advertise to any peer (well-known community)\n" |
| 7808 | "Do not export to next AS (well-known community)\n") |
| 7809 | |
| 7810 | ALIAS (show_ip_bgp_ipv4_community, |
| 7811 | show_ip_bgp_ipv4_community3_cmd, |
| 7812 | "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)", |
| 7813 | SHOW_STR |
| 7814 | IP_STR |
| 7815 | BGP_STR |
| 7816 | "Address family\n" |
| 7817 | "Address Family modifier\n" |
| 7818 | "Address Family modifier\n" |
| 7819 | "Display routes matching the communities\n" |
| 7820 | "community number\n" |
| 7821 | "Do not send outside local AS (well-known community)\n" |
| 7822 | "Do not advertise to any peer (well-known community)\n" |
| 7823 | "Do not export to next AS (well-known community)\n" |
| 7824 | "community number\n" |
| 7825 | "Do not send outside local AS (well-known community)\n" |
| 7826 | "Do not advertise to any peer (well-known community)\n" |
| 7827 | "Do not export to next AS (well-known community)\n" |
| 7828 | "community number\n" |
| 7829 | "Do not send outside local AS (well-known community)\n" |
| 7830 | "Do not advertise to any peer (well-known community)\n" |
| 7831 | "Do not export to next AS (well-known community)\n") |
| 7832 | |
| 7833 | ALIAS (show_ip_bgp_ipv4_community, |
| 7834 | show_ip_bgp_ipv4_community4_cmd, |
| 7835 | "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)", |
| 7836 | SHOW_STR |
| 7837 | IP_STR |
| 7838 | BGP_STR |
| 7839 | "Address family\n" |
| 7840 | "Address Family modifier\n" |
| 7841 | "Address Family modifier\n" |
| 7842 | "Display routes matching the communities\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 | "community number\n" |
| 7848 | "Do not send outside local AS (well-known community)\n" |
| 7849 | "Do not advertise to any peer (well-known community)\n" |
| 7850 | "Do not export to next AS (well-known community)\n" |
| 7851 | "community number\n" |
| 7852 | "Do not send outside local AS (well-known community)\n" |
| 7853 | "Do not advertise to any peer (well-known community)\n" |
| 7854 | "Do not export to next AS (well-known community)\n" |
| 7855 | "community number\n" |
| 7856 | "Do not send outside local AS (well-known community)\n" |
| 7857 | "Do not advertise to any peer (well-known community)\n" |
| 7858 | "Do not export to next AS (well-known community)\n") |
| 7859 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7860 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 7861 | show_bgp_view_afi_safi_community_all_cmd, |
| 7862 | #ifdef HAVE_IPV6 |
| 7863 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
| 7864 | #else |
| 7865 | "show bgp view WORD ipv4 (unicast|multicast) community", |
| 7866 | #endif |
| 7867 | SHOW_STR |
| 7868 | BGP_STR |
| 7869 | "BGP view\n" |
| 7870 | "BGP view name\n" |
| 7871 | "Address family\n" |
| 7872 | #ifdef HAVE_IPV6 |
| 7873 | "Address family\n" |
| 7874 | #endif |
| 7875 | "Address Family modifier\n" |
| 7876 | "Address Family modifier\n" |
| 7877 | "Display routes containing communities\n") |
| 7878 | { |
| 7879 | int afi; |
| 7880 | int safi; |
| 7881 | struct bgp *bgp; |
| 7882 | |
| 7883 | /* BGP structure lookup. */ |
| 7884 | bgp = bgp_lookup_by_name (argv[0]); |
| 7885 | if (bgp == NULL) |
| 7886 | { |
| 7887 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7888 | return CMD_WARNING; |
| 7889 | } |
| 7890 | |
| 7891 | #ifdef HAVE_IPV6 |
| 7892 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 7893 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7894 | #else |
| 7895 | afi = AFI_IP; |
| 7896 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7897 | #endif |
| 7898 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 7899 | } |
| 7900 | |
| 7901 | DEFUN (show_bgp_view_afi_safi_community, |
| 7902 | show_bgp_view_afi_safi_community_cmd, |
| 7903 | #ifdef HAVE_IPV6 |
| 7904 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7905 | #else |
| 7906 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7907 | #endif |
| 7908 | SHOW_STR |
| 7909 | BGP_STR |
| 7910 | "BGP view\n" |
| 7911 | "BGP view name\n" |
| 7912 | "Address family\n" |
| 7913 | #ifdef HAVE_IPV6 |
| 7914 | "Address family\n" |
| 7915 | #endif |
| 7916 | "Address family modifier\n" |
| 7917 | "Address family modifier\n" |
| 7918 | "Display routes matching the communities\n" |
| 7919 | "community number\n" |
| 7920 | "Do not send outside local AS (well-known community)\n" |
| 7921 | "Do not advertise to any peer (well-known community)\n" |
| 7922 | "Do not export to next AS (well-known community)\n") |
| 7923 | { |
| 7924 | int afi; |
| 7925 | int safi; |
| 7926 | |
| 7927 | #ifdef HAVE_IPV6 |
| 7928 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 7929 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7930 | return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi); |
| 7931 | #else |
| 7932 | afi = AFI_IP; |
| 7933 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7934 | return bgp_show_community (vty, argv[0], argc-2, &argv[2], 0, afi, safi); |
| 7935 | #endif |
| 7936 | } |
| 7937 | |
| 7938 | ALIAS (show_bgp_view_afi_safi_community, |
| 7939 | show_bgp_view_afi_safi_community2_cmd, |
| 7940 | #ifdef HAVE_IPV6 |
| 7941 | "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)", |
| 7942 | #else |
| 7943 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7944 | #endif |
| 7945 | SHOW_STR |
| 7946 | BGP_STR |
| 7947 | "BGP view\n" |
| 7948 | "BGP view name\n" |
| 7949 | "Address family\n" |
| 7950 | #ifdef HAVE_IPV6 |
| 7951 | "Address family\n" |
| 7952 | #endif |
| 7953 | "Address family modifier\n" |
| 7954 | "Address family modifier\n" |
| 7955 | "Display routes matching the communities\n" |
| 7956 | "community number\n" |
| 7957 | "Do not send outside local AS (well-known community)\n" |
| 7958 | "Do not advertise to any peer (well-known community)\n" |
| 7959 | "Do not export to next AS (well-known community)\n" |
| 7960 | "community number\n" |
| 7961 | "Do not send outside local AS (well-known community)\n" |
| 7962 | "Do not advertise to any peer (well-known community)\n" |
| 7963 | "Do not export to next AS (well-known community)\n") |
| 7964 | |
| 7965 | ALIAS (show_bgp_view_afi_safi_community, |
| 7966 | show_bgp_view_afi_safi_community3_cmd, |
| 7967 | #ifdef HAVE_IPV6 |
| 7968 | "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)", |
| 7969 | #else |
| 7970 | "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)", |
| 7971 | #endif |
| 7972 | SHOW_STR |
| 7973 | BGP_STR |
| 7974 | "BGP view\n" |
| 7975 | "BGP view name\n" |
| 7976 | "Address family\n" |
| 7977 | #ifdef HAVE_IPV6 |
| 7978 | "Address family\n" |
| 7979 | #endif |
| 7980 | "Address family modifier\n" |
| 7981 | "Address family modifier\n" |
| 7982 | "Display routes matching the communities\n" |
| 7983 | "community number\n" |
| 7984 | "Do not send outside local AS (well-known community)\n" |
| 7985 | "Do not advertise to any peer (well-known community)\n" |
| 7986 | "Do not export to next AS (well-known community)\n" |
| 7987 | "community number\n" |
| 7988 | "Do not send outside local AS (well-known community)\n" |
| 7989 | "Do not advertise to any peer (well-known community)\n" |
| 7990 | "Do not export to next AS (well-known community)\n" |
| 7991 | "community number\n" |
| 7992 | "Do not send outside local AS (well-known community)\n" |
| 7993 | "Do not advertise to any peer (well-known community)\n" |
| 7994 | "Do not export to next AS (well-known community)\n") |
| 7995 | |
| 7996 | ALIAS (show_bgp_view_afi_safi_community, |
| 7997 | show_bgp_view_afi_safi_community4_cmd, |
| 7998 | #ifdef HAVE_IPV6 |
| 7999 | "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)", |
| 8000 | #else |
| 8001 | "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)", |
| 8002 | #endif |
| 8003 | SHOW_STR |
| 8004 | BGP_STR |
| 8005 | "BGP view\n" |
| 8006 | "BGP view name\n" |
| 8007 | "Address family\n" |
| 8008 | #ifdef HAVE_IPV6 |
| 8009 | "Address family\n" |
| 8010 | #endif |
| 8011 | "Address family modifier\n" |
| 8012 | "Address family modifier\n" |
| 8013 | "Display routes matching the communities\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 | "community number\n" |
| 8019 | "Do not send outside local AS (well-known community)\n" |
| 8020 | "Do not advertise to any peer (well-known community)\n" |
| 8021 | "Do not export to next AS (well-known community)\n" |
| 8022 | "community number\n" |
| 8023 | "Do not send outside local AS (well-known community)\n" |
| 8024 | "Do not advertise to any peer (well-known community)\n" |
| 8025 | "Do not export to next AS (well-known community)\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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8031 | DEFUN (show_ip_bgp_community_exact, |
| 8032 | show_ip_bgp_community_exact_cmd, |
| 8033 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8034 | SHOW_STR |
| 8035 | IP_STR |
| 8036 | BGP_STR |
| 8037 | "Display routes matching the communities\n" |
| 8038 | "community number\n" |
| 8039 | "Do not send outside local AS (well-known community)\n" |
| 8040 | "Do not advertise to any peer (well-known community)\n" |
| 8041 | "Do not export to next AS (well-known community)\n" |
| 8042 | "Exact match of the communities") |
| 8043 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8044 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8045 | } |
| 8046 | |
| 8047 | ALIAS (show_ip_bgp_community_exact, |
| 8048 | show_ip_bgp_community2_exact_cmd, |
| 8049 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8050 | SHOW_STR |
| 8051 | IP_STR |
| 8052 | BGP_STR |
| 8053 | "Display routes matching the communities\n" |
| 8054 | "community number\n" |
| 8055 | "Do not send outside local AS (well-known community)\n" |
| 8056 | "Do not advertise to any peer (well-known community)\n" |
| 8057 | "Do not export to next AS (well-known community)\n" |
| 8058 | "community number\n" |
| 8059 | "Do not send outside local AS (well-known community)\n" |
| 8060 | "Do not advertise to any peer (well-known community)\n" |
| 8061 | "Do not export to next AS (well-known community)\n" |
| 8062 | "Exact match of the communities") |
| 8063 | |
| 8064 | ALIAS (show_ip_bgp_community_exact, |
| 8065 | show_ip_bgp_community3_exact_cmd, |
| 8066 | "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", |
| 8067 | SHOW_STR |
| 8068 | IP_STR |
| 8069 | BGP_STR |
| 8070 | "Display routes matching the communities\n" |
| 8071 | "community number\n" |
| 8072 | "Do not send outside local AS (well-known community)\n" |
| 8073 | "Do not advertise to any peer (well-known community)\n" |
| 8074 | "Do not export to next AS (well-known community)\n" |
| 8075 | "community number\n" |
| 8076 | "Do not send outside local AS (well-known community)\n" |
| 8077 | "Do not advertise to any peer (well-known community)\n" |
| 8078 | "Do not export to next AS (well-known community)\n" |
| 8079 | "community number\n" |
| 8080 | "Do not send outside local AS (well-known community)\n" |
| 8081 | "Do not advertise to any peer (well-known community)\n" |
| 8082 | "Do not export to next AS (well-known community)\n" |
| 8083 | "Exact match of the communities") |
| 8084 | |
| 8085 | ALIAS (show_ip_bgp_community_exact, |
| 8086 | show_ip_bgp_community4_exact_cmd, |
| 8087 | "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", |
| 8088 | SHOW_STR |
| 8089 | IP_STR |
| 8090 | BGP_STR |
| 8091 | "Display routes matching the communities\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 | "community number\n" |
| 8097 | "Do not send outside local AS (well-known community)\n" |
| 8098 | "Do not advertise to any peer (well-known community)\n" |
| 8099 | "Do not export to next AS (well-known community)\n" |
| 8100 | "community number\n" |
| 8101 | "Do not send outside local AS (well-known community)\n" |
| 8102 | "Do not advertise to any peer (well-known community)\n" |
| 8103 | "Do not export to next AS (well-known community)\n" |
| 8104 | "community number\n" |
| 8105 | "Do not send outside local AS (well-known community)\n" |
| 8106 | "Do not advertise to any peer (well-known community)\n" |
| 8107 | "Do not export to next AS (well-known community)\n" |
| 8108 | "Exact match of the communities") |
| 8109 | |
| 8110 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 8111 | show_ip_bgp_ipv4_community_exact_cmd, |
| 8112 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8113 | SHOW_STR |
| 8114 | IP_STR |
| 8115 | BGP_STR |
| 8116 | "Address family\n" |
| 8117 | "Address Family modifier\n" |
| 8118 | "Address Family modifier\n" |
| 8119 | "Display routes matching the communities\n" |
| 8120 | "community number\n" |
| 8121 | "Do not send outside local AS (well-known community)\n" |
| 8122 | "Do not advertise to any peer (well-known community)\n" |
| 8123 | "Do not export to next AS (well-known community)\n" |
| 8124 | "Exact match of the communities") |
| 8125 | { |
| 8126 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8127 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8128 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8129 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8130 | } |
| 8131 | |
| 8132 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8133 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 8134 | "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", |
| 8135 | SHOW_STR |
| 8136 | IP_STR |
| 8137 | BGP_STR |
| 8138 | "Address family\n" |
| 8139 | "Address Family modifier\n" |
| 8140 | "Address Family modifier\n" |
| 8141 | "Display routes matching the communities\n" |
| 8142 | "community number\n" |
| 8143 | "Do not send outside local AS (well-known community)\n" |
| 8144 | "Do not advertise to any peer (well-known community)\n" |
| 8145 | "Do not export to next AS (well-known community)\n" |
| 8146 | "community number\n" |
| 8147 | "Do not send outside local AS (well-known community)\n" |
| 8148 | "Do not advertise to any peer (well-known community)\n" |
| 8149 | "Do not export to next AS (well-known community)\n" |
| 8150 | "Exact match of the communities") |
| 8151 | |
| 8152 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8153 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 8154 | "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", |
| 8155 | SHOW_STR |
| 8156 | IP_STR |
| 8157 | BGP_STR |
| 8158 | "Address family\n" |
| 8159 | "Address Family modifier\n" |
| 8160 | "Address Family modifier\n" |
| 8161 | "Display routes matching the communities\n" |
| 8162 | "community number\n" |
| 8163 | "Do not send outside local AS (well-known community)\n" |
| 8164 | "Do not advertise to any peer (well-known community)\n" |
| 8165 | "Do not export to next AS (well-known community)\n" |
| 8166 | "community number\n" |
| 8167 | "Do not send outside local AS (well-known community)\n" |
| 8168 | "Do not advertise to any peer (well-known community)\n" |
| 8169 | "Do not export to next AS (well-known community)\n" |
| 8170 | "community number\n" |
| 8171 | "Do not send outside local AS (well-known community)\n" |
| 8172 | "Do not advertise to any peer (well-known community)\n" |
| 8173 | "Do not export to next AS (well-known community)\n" |
| 8174 | "Exact match of the communities") |
| 8175 | |
| 8176 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8177 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 8178 | "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", |
| 8179 | SHOW_STR |
| 8180 | IP_STR |
| 8181 | BGP_STR |
| 8182 | "Address family\n" |
| 8183 | "Address Family modifier\n" |
| 8184 | "Address Family modifier\n" |
| 8185 | "Display routes matching the communities\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 | "community number\n" |
| 8191 | "Do not send outside local AS (well-known community)\n" |
| 8192 | "Do not advertise to any peer (well-known community)\n" |
| 8193 | "Do not export to next AS (well-known community)\n" |
| 8194 | "community number\n" |
| 8195 | "Do not send outside local AS (well-known community)\n" |
| 8196 | "Do not advertise to any peer (well-known community)\n" |
| 8197 | "Do not export to next AS (well-known community)\n" |
| 8198 | "community number\n" |
| 8199 | "Do not send outside local AS (well-known community)\n" |
| 8200 | "Do not advertise to any peer (well-known community)\n" |
| 8201 | "Do not export to next AS (well-known community)\n" |
| 8202 | "Exact match of the communities") |
| 8203 | |
| 8204 | #ifdef HAVE_IPV6 |
| 8205 | DEFUN (show_bgp_community, |
| 8206 | show_bgp_community_cmd, |
| 8207 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8208 | SHOW_STR |
| 8209 | BGP_STR |
| 8210 | "Display routes matching the communities\n" |
| 8211 | "community number\n" |
| 8212 | "Do not send outside local AS (well-known community)\n" |
| 8213 | "Do not advertise to any peer (well-known community)\n" |
| 8214 | "Do not export to next AS (well-known community)\n") |
| 8215 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8216 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8217 | } |
| 8218 | |
| 8219 | ALIAS (show_bgp_community, |
| 8220 | show_bgp_ipv6_community_cmd, |
| 8221 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 8222 | SHOW_STR |
| 8223 | BGP_STR |
| 8224 | "Address family\n" |
| 8225 | "Display routes matching the communities\n" |
| 8226 | "community number\n" |
| 8227 | "Do not send outside local AS (well-known community)\n" |
| 8228 | "Do not advertise to any peer (well-known community)\n" |
| 8229 | "Do not export to next AS (well-known community)\n") |
| 8230 | |
| 8231 | ALIAS (show_bgp_community, |
| 8232 | show_bgp_community2_cmd, |
| 8233 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8234 | SHOW_STR |
| 8235 | BGP_STR |
| 8236 | "Display routes matching the communities\n" |
| 8237 | "community number\n" |
| 8238 | "Do not send outside local AS (well-known community)\n" |
| 8239 | "Do not advertise to any peer (well-known community)\n" |
| 8240 | "Do not export to next AS (well-known community)\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 | |
| 8246 | ALIAS (show_bgp_community, |
| 8247 | show_bgp_ipv6_community2_cmd, |
| 8248 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8249 | SHOW_STR |
| 8250 | BGP_STR |
| 8251 | "Address family\n" |
| 8252 | "Display routes matching the communities\n" |
| 8253 | "community number\n" |
| 8254 | "Do not send outside local AS (well-known community)\n" |
| 8255 | "Do not advertise to any peer (well-known community)\n" |
| 8256 | "Do not export to next AS (well-known community)\n" |
| 8257 | "community number\n" |
| 8258 | "Do not send outside local AS (well-known community)\n" |
| 8259 | "Do not advertise to any peer (well-known community)\n" |
| 8260 | "Do not export to next AS (well-known community)\n") |
| 8261 | |
| 8262 | ALIAS (show_bgp_community, |
| 8263 | show_bgp_community3_cmd, |
| 8264 | "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)", |
| 8265 | SHOW_STR |
| 8266 | BGP_STR |
| 8267 | "Display routes matching the communities\n" |
| 8268 | "community number\n" |
| 8269 | "Do not send outside local AS (well-known community)\n" |
| 8270 | "Do not advertise to any peer (well-known community)\n" |
| 8271 | "Do not export to next AS (well-known community)\n" |
| 8272 | "community number\n" |
| 8273 | "Do not send outside local AS (well-known community)\n" |
| 8274 | "Do not advertise to any peer (well-known community)\n" |
| 8275 | "Do not export to next AS (well-known community)\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 | |
| 8281 | ALIAS (show_bgp_community, |
| 8282 | show_bgp_ipv6_community3_cmd, |
| 8283 | "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)", |
| 8284 | SHOW_STR |
| 8285 | BGP_STR |
| 8286 | "Address family\n" |
| 8287 | "Display routes matching the communities\n" |
| 8288 | "community number\n" |
| 8289 | "Do not send outside local AS (well-known community)\n" |
| 8290 | "Do not advertise to any peer (well-known community)\n" |
| 8291 | "Do not export to next AS (well-known community)\n" |
| 8292 | "community number\n" |
| 8293 | "Do not send outside local AS (well-known community)\n" |
| 8294 | "Do not advertise to any peer (well-known community)\n" |
| 8295 | "Do not export to next AS (well-known community)\n" |
| 8296 | "community number\n" |
| 8297 | "Do not send outside local AS (well-known community)\n" |
| 8298 | "Do not advertise to any peer (well-known community)\n" |
| 8299 | "Do not export to next AS (well-known community)\n") |
| 8300 | |
| 8301 | ALIAS (show_bgp_community, |
| 8302 | show_bgp_community4_cmd, |
| 8303 | "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)", |
| 8304 | SHOW_STR |
| 8305 | BGP_STR |
| 8306 | "Display routes matching the communities\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 | "community number\n" |
| 8312 | "Do not send outside local AS (well-known community)\n" |
| 8313 | "Do not advertise to any peer (well-known community)\n" |
| 8314 | "Do not export to next AS (well-known community)\n" |
| 8315 | "community number\n" |
| 8316 | "Do not send outside local AS (well-known community)\n" |
| 8317 | "Do not advertise to any peer (well-known community)\n" |
| 8318 | "Do not export to next AS (well-known community)\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 | |
| 8324 | ALIAS (show_bgp_community, |
| 8325 | show_bgp_ipv6_community4_cmd, |
| 8326 | "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)", |
| 8327 | SHOW_STR |
| 8328 | BGP_STR |
| 8329 | "Address family\n" |
| 8330 | "Display routes matching the communities\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 | "community number\n" |
| 8336 | "Do not send outside local AS (well-known community)\n" |
| 8337 | "Do not advertise to any peer (well-known community)\n" |
| 8338 | "Do not export to next AS (well-known community)\n" |
| 8339 | "community number\n" |
| 8340 | "Do not send outside local AS (well-known community)\n" |
| 8341 | "Do not advertise to any peer (well-known community)\n" |
| 8342 | "Do not export to next AS (well-known community)\n" |
| 8343 | "community number\n" |
| 8344 | "Do not send outside local AS (well-known community)\n" |
| 8345 | "Do not advertise to any peer (well-known community)\n" |
| 8346 | "Do not export to next AS (well-known community)\n") |
| 8347 | |
| 8348 | /* old command */ |
| 8349 | DEFUN (show_ipv6_bgp_community, |
| 8350 | show_ipv6_bgp_community_cmd, |
| 8351 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8352 | SHOW_STR |
| 8353 | IPV6_STR |
| 8354 | BGP_STR |
| 8355 | "Display routes matching the communities\n" |
| 8356 | "community number\n" |
| 8357 | "Do not send outside local AS (well-known community)\n" |
| 8358 | "Do not advertise to any peer (well-known community)\n" |
| 8359 | "Do not export to next AS (well-known community)\n") |
| 8360 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8361 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8362 | } |
| 8363 | |
| 8364 | /* old command */ |
| 8365 | ALIAS (show_ipv6_bgp_community, |
| 8366 | show_ipv6_bgp_community2_cmd, |
| 8367 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8368 | SHOW_STR |
| 8369 | IPV6_STR |
| 8370 | BGP_STR |
| 8371 | "Display routes matching the communities\n" |
| 8372 | "community number\n" |
| 8373 | "Do not send outside local AS (well-known community)\n" |
| 8374 | "Do not advertise to any peer (well-known community)\n" |
| 8375 | "Do not export to next AS (well-known community)\n" |
| 8376 | "community number\n" |
| 8377 | "Do not send outside local AS (well-known community)\n" |
| 8378 | "Do not advertise to any peer (well-known community)\n" |
| 8379 | "Do not export to next AS (well-known community)\n") |
| 8380 | |
| 8381 | /* old command */ |
| 8382 | ALIAS (show_ipv6_bgp_community, |
| 8383 | show_ipv6_bgp_community3_cmd, |
| 8384 | "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)", |
| 8385 | SHOW_STR |
| 8386 | IPV6_STR |
| 8387 | BGP_STR |
| 8388 | "Display routes matching the communities\n" |
| 8389 | "community number\n" |
| 8390 | "Do not send outside local AS (well-known community)\n" |
| 8391 | "Do not advertise to any peer (well-known community)\n" |
| 8392 | "Do not export to next AS (well-known community)\n" |
| 8393 | "community number\n" |
| 8394 | "Do not send outside local AS (well-known community)\n" |
| 8395 | "Do not advertise to any peer (well-known community)\n" |
| 8396 | "Do not export to next AS (well-known community)\n" |
| 8397 | "community number\n" |
| 8398 | "Do not send outside local AS (well-known community)\n" |
| 8399 | "Do not advertise to any peer (well-known community)\n" |
| 8400 | "Do not export to next AS (well-known community)\n") |
| 8401 | |
| 8402 | /* old command */ |
| 8403 | ALIAS (show_ipv6_bgp_community, |
| 8404 | show_ipv6_bgp_community4_cmd, |
| 8405 | "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)", |
| 8406 | SHOW_STR |
| 8407 | IPV6_STR |
| 8408 | BGP_STR |
| 8409 | "Display routes matching the communities\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 | "community number\n" |
| 8415 | "Do not send outside local AS (well-known community)\n" |
| 8416 | "Do not advertise to any peer (well-known community)\n" |
| 8417 | "Do not export to next AS (well-known community)\n" |
| 8418 | "community number\n" |
| 8419 | "Do not send outside local AS (well-known community)\n" |
| 8420 | "Do not advertise to any peer (well-known community)\n" |
| 8421 | "Do not export to next AS (well-known community)\n" |
| 8422 | "community number\n" |
| 8423 | "Do not send outside local AS (well-known community)\n" |
| 8424 | "Do not advertise to any peer (well-known community)\n" |
| 8425 | "Do not export to next AS (well-known community)\n") |
| 8426 | |
| 8427 | DEFUN (show_bgp_community_exact, |
| 8428 | show_bgp_community_exact_cmd, |
| 8429 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8430 | SHOW_STR |
| 8431 | BGP_STR |
| 8432 | "Display routes matching the communities\n" |
| 8433 | "community number\n" |
| 8434 | "Do not send outside local AS (well-known community)\n" |
| 8435 | "Do not advertise to any peer (well-known community)\n" |
| 8436 | "Do not export to next AS (well-known community)\n" |
| 8437 | "Exact match of the communities") |
| 8438 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8439 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8440 | } |
| 8441 | |
| 8442 | ALIAS (show_bgp_community_exact, |
| 8443 | show_bgp_ipv6_community_exact_cmd, |
| 8444 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8445 | SHOW_STR |
| 8446 | BGP_STR |
| 8447 | "Address family\n" |
| 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 | "Exact match of the communities") |
| 8454 | |
| 8455 | ALIAS (show_bgp_community_exact, |
| 8456 | show_bgp_community2_exact_cmd, |
| 8457 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8458 | SHOW_STR |
| 8459 | BGP_STR |
| 8460 | "Display routes matching the communities\n" |
| 8461 | "community number\n" |
| 8462 | "Do not send outside local AS (well-known community)\n" |
| 8463 | "Do not advertise to any peer (well-known community)\n" |
| 8464 | "Do not export to next AS (well-known community)\n" |
| 8465 | "community number\n" |
| 8466 | "Do not send outside local AS (well-known community)\n" |
| 8467 | "Do not advertise to any peer (well-known community)\n" |
| 8468 | "Do not export to next AS (well-known community)\n" |
| 8469 | "Exact match of the communities") |
| 8470 | |
| 8471 | ALIAS (show_bgp_community_exact, |
| 8472 | show_bgp_ipv6_community2_exact_cmd, |
| 8473 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8474 | SHOW_STR |
| 8475 | BGP_STR |
| 8476 | "Address family\n" |
| 8477 | "Display routes matching the communities\n" |
| 8478 | "community number\n" |
| 8479 | "Do not send outside local AS (well-known community)\n" |
| 8480 | "Do not advertise to any peer (well-known community)\n" |
| 8481 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") |
| 8487 | |
| 8488 | ALIAS (show_bgp_community_exact, |
| 8489 | show_bgp_community3_exact_cmd, |
| 8490 | "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", |
| 8491 | SHOW_STR |
| 8492 | BGP_STR |
| 8493 | "Display routes matching the communities\n" |
| 8494 | "community number\n" |
| 8495 | "Do not send outside local AS (well-known community)\n" |
| 8496 | "Do not advertise to any peer (well-known community)\n" |
| 8497 | "Do not export to next AS (well-known community)\n" |
| 8498 | "community number\n" |
| 8499 | "Do not send outside local AS (well-known community)\n" |
| 8500 | "Do not advertise to any peer (well-known community)\n" |
| 8501 | "Do not export to next AS (well-known community)\n" |
| 8502 | "community number\n" |
| 8503 | "Do not send outside local AS (well-known community)\n" |
| 8504 | "Do not advertise to any peer (well-known community)\n" |
| 8505 | "Do not export to next AS (well-known community)\n" |
| 8506 | "Exact match of the communities") |
| 8507 | |
| 8508 | ALIAS (show_bgp_community_exact, |
| 8509 | show_bgp_ipv6_community3_exact_cmd, |
| 8510 | "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", |
| 8511 | SHOW_STR |
| 8512 | BGP_STR |
| 8513 | "Address family\n" |
| 8514 | "Display routes matching the communities\n" |
| 8515 | "community number\n" |
| 8516 | "Do not send outside local AS (well-known community)\n" |
| 8517 | "Do not advertise to any peer (well-known community)\n" |
| 8518 | "Do not export to next AS (well-known community)\n" |
| 8519 | "community number\n" |
| 8520 | "Do not send outside local AS (well-known community)\n" |
| 8521 | "Do not advertise to any peer (well-known community)\n" |
| 8522 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") |
| 8528 | |
| 8529 | ALIAS (show_bgp_community_exact, |
| 8530 | show_bgp_community4_exact_cmd, |
| 8531 | "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", |
| 8532 | SHOW_STR |
| 8533 | BGP_STR |
| 8534 | "Display routes matching the communities\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 | "community number\n" |
| 8540 | "Do not send outside local AS (well-known community)\n" |
| 8541 | "Do not advertise to any peer (well-known community)\n" |
| 8542 | "Do not export to next AS (well-known community)\n" |
| 8543 | "community number\n" |
| 8544 | "Do not send outside local AS (well-known community)\n" |
| 8545 | "Do not advertise to any peer (well-known community)\n" |
| 8546 | "Do not export to next AS (well-known community)\n" |
| 8547 | "community number\n" |
| 8548 | "Do not send outside local AS (well-known community)\n" |
| 8549 | "Do not advertise to any peer (well-known community)\n" |
| 8550 | "Do not export to next AS (well-known community)\n" |
| 8551 | "Exact match of the communities") |
| 8552 | |
| 8553 | ALIAS (show_bgp_community_exact, |
| 8554 | show_bgp_ipv6_community4_exact_cmd, |
| 8555 | "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", |
| 8556 | SHOW_STR |
| 8557 | BGP_STR |
| 8558 | "Address family\n" |
| 8559 | "Display routes matching the communities\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 | "community number\n" |
| 8565 | "Do not send outside local AS (well-known community)\n" |
| 8566 | "Do not advertise to any peer (well-known community)\n" |
| 8567 | "Do not export to next AS (well-known community)\n" |
| 8568 | "community number\n" |
| 8569 | "Do not send outside local AS (well-known community)\n" |
| 8570 | "Do not advertise to any peer (well-known community)\n" |
| 8571 | "Do not export to next AS (well-known community)\n" |
| 8572 | "community number\n" |
| 8573 | "Do not send outside local AS (well-known community)\n" |
| 8574 | "Do not advertise to any peer (well-known community)\n" |
| 8575 | "Do not export to next AS (well-known community)\n" |
| 8576 | "Exact match of the communities") |
| 8577 | |
| 8578 | /* old command */ |
| 8579 | DEFUN (show_ipv6_bgp_community_exact, |
| 8580 | show_ipv6_bgp_community_exact_cmd, |
| 8581 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8582 | SHOW_STR |
| 8583 | IPV6_STR |
| 8584 | BGP_STR |
| 8585 | "Display routes matching the communities\n" |
| 8586 | "community number\n" |
| 8587 | "Do not send outside local AS (well-known community)\n" |
| 8588 | "Do not advertise to any peer (well-known community)\n" |
| 8589 | "Do not export to next AS (well-known community)\n" |
| 8590 | "Exact match of the communities") |
| 8591 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8592 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8593 | } |
| 8594 | |
| 8595 | /* old command */ |
| 8596 | ALIAS (show_ipv6_bgp_community_exact, |
| 8597 | show_ipv6_bgp_community2_exact_cmd, |
| 8598 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8599 | SHOW_STR |
| 8600 | IPV6_STR |
| 8601 | BGP_STR |
| 8602 | "Display routes matching the communities\n" |
| 8603 | "community number\n" |
| 8604 | "Do not send outside local AS (well-known community)\n" |
| 8605 | "Do not advertise to any peer (well-known community)\n" |
| 8606 | "Do not export to next AS (well-known community)\n" |
| 8607 | "community number\n" |
| 8608 | "Do not send outside local AS (well-known community)\n" |
| 8609 | "Do not advertise to any peer (well-known community)\n" |
| 8610 | "Do not export to next AS (well-known community)\n" |
| 8611 | "Exact match of the communities") |
| 8612 | |
| 8613 | /* old command */ |
| 8614 | ALIAS (show_ipv6_bgp_community_exact, |
| 8615 | show_ipv6_bgp_community3_exact_cmd, |
| 8616 | "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", |
| 8617 | SHOW_STR |
| 8618 | IPV6_STR |
| 8619 | BGP_STR |
| 8620 | "Display routes matching the communities\n" |
| 8621 | "community number\n" |
| 8622 | "Do not send outside local AS (well-known community)\n" |
| 8623 | "Do not advertise to any peer (well-known community)\n" |
| 8624 | "Do not export to next AS (well-known community)\n" |
| 8625 | "community number\n" |
| 8626 | "Do not send outside local AS (well-known community)\n" |
| 8627 | "Do not advertise to any peer (well-known community)\n" |
| 8628 | "Do not export to next AS (well-known community)\n" |
| 8629 | "community number\n" |
| 8630 | "Do not send outside local AS (well-known community)\n" |
| 8631 | "Do not advertise to any peer (well-known community)\n" |
| 8632 | "Do not export to next AS (well-known community)\n" |
| 8633 | "Exact match of the communities") |
| 8634 | |
| 8635 | /* old command */ |
| 8636 | ALIAS (show_ipv6_bgp_community_exact, |
| 8637 | show_ipv6_bgp_community4_exact_cmd, |
| 8638 | "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", |
| 8639 | SHOW_STR |
| 8640 | IPV6_STR |
| 8641 | BGP_STR |
| 8642 | "Display routes matching the communities\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 | "community number\n" |
| 8648 | "Do not send outside local AS (well-known community)\n" |
| 8649 | "Do not advertise to any peer (well-known community)\n" |
| 8650 | "Do not export to next AS (well-known community)\n" |
| 8651 | "community number\n" |
| 8652 | "Do not send outside local AS (well-known community)\n" |
| 8653 | "Do not advertise to any peer (well-known community)\n" |
| 8654 | "Do not export to next AS (well-known community)\n" |
| 8655 | "community number\n" |
| 8656 | "Do not send outside local AS (well-known community)\n" |
| 8657 | "Do not advertise to any peer (well-known community)\n" |
| 8658 | "Do not export to next AS (well-known community)\n" |
| 8659 | "Exact match of the communities") |
| 8660 | |
| 8661 | /* old command */ |
| 8662 | DEFUN (show_ipv6_mbgp_community, |
| 8663 | show_ipv6_mbgp_community_cmd, |
| 8664 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8665 | SHOW_STR |
| 8666 | IPV6_STR |
| 8667 | MBGP_STR |
| 8668 | "Display routes matching the communities\n" |
| 8669 | "community number\n" |
| 8670 | "Do not send outside local AS (well-known community)\n" |
| 8671 | "Do not advertise to any peer (well-known community)\n" |
| 8672 | "Do not export to next AS (well-known community)\n") |
| 8673 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8674 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8675 | } |
| 8676 | |
| 8677 | /* old command */ |
| 8678 | ALIAS (show_ipv6_mbgp_community, |
| 8679 | show_ipv6_mbgp_community2_cmd, |
| 8680 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8681 | SHOW_STR |
| 8682 | IPV6_STR |
| 8683 | MBGP_STR |
| 8684 | "Display routes matching the communities\n" |
| 8685 | "community number\n" |
| 8686 | "Do not send outside local AS (well-known community)\n" |
| 8687 | "Do not advertise to any peer (well-known community)\n" |
| 8688 | "Do not export to next AS (well-known community)\n" |
| 8689 | "community number\n" |
| 8690 | "Do not send outside local AS (well-known community)\n" |
| 8691 | "Do not advertise to any peer (well-known community)\n" |
| 8692 | "Do not export to next AS (well-known community)\n") |
| 8693 | |
| 8694 | /* old command */ |
| 8695 | ALIAS (show_ipv6_mbgp_community, |
| 8696 | show_ipv6_mbgp_community3_cmd, |
| 8697 | "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)", |
| 8698 | SHOW_STR |
| 8699 | IPV6_STR |
| 8700 | MBGP_STR |
| 8701 | "Display routes matching the communities\n" |
| 8702 | "community number\n" |
| 8703 | "Do not send outside local AS (well-known community)\n" |
| 8704 | "Do not advertise to any peer (well-known community)\n" |
| 8705 | "Do not export to next AS (well-known community)\n" |
| 8706 | "community number\n" |
| 8707 | "Do not send outside local AS (well-known community)\n" |
| 8708 | "Do not advertise to any peer (well-known community)\n" |
| 8709 | "Do not export to next AS (well-known community)\n" |
| 8710 | "community number\n" |
| 8711 | "Do not send outside local AS (well-known community)\n" |
| 8712 | "Do not advertise to any peer (well-known community)\n" |
| 8713 | "Do not export to next AS (well-known community)\n") |
| 8714 | |
| 8715 | /* old command */ |
| 8716 | ALIAS (show_ipv6_mbgp_community, |
| 8717 | show_ipv6_mbgp_community4_cmd, |
| 8718 | "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)", |
| 8719 | SHOW_STR |
| 8720 | IPV6_STR |
| 8721 | MBGP_STR |
| 8722 | "Display routes matching the communities\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 | "community number\n" |
| 8728 | "Do not send outside local AS (well-known community)\n" |
| 8729 | "Do not advertise to any peer (well-known community)\n" |
| 8730 | "Do not export to next AS (well-known community)\n" |
| 8731 | "community number\n" |
| 8732 | "Do not send outside local AS (well-known community)\n" |
| 8733 | "Do not advertise to any peer (well-known community)\n" |
| 8734 | "Do not export to next AS (well-known community)\n" |
| 8735 | "community number\n" |
| 8736 | "Do not send outside local AS (well-known community)\n" |
| 8737 | "Do not advertise to any peer (well-known community)\n" |
| 8738 | "Do not export to next AS (well-known community)\n") |
| 8739 | |
| 8740 | /* old command */ |
| 8741 | DEFUN (show_ipv6_mbgp_community_exact, |
| 8742 | show_ipv6_mbgp_community_exact_cmd, |
| 8743 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8744 | SHOW_STR |
| 8745 | IPV6_STR |
| 8746 | MBGP_STR |
| 8747 | "Display routes matching the communities\n" |
| 8748 | "community number\n" |
| 8749 | "Do not send outside local AS (well-known community)\n" |
| 8750 | "Do not advertise to any peer (well-known community)\n" |
| 8751 | "Do not export to next AS (well-known community)\n" |
| 8752 | "Exact match of the communities") |
| 8753 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8754 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8755 | } |
| 8756 | |
| 8757 | /* old command */ |
| 8758 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8759 | show_ipv6_mbgp_community2_exact_cmd, |
| 8760 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8761 | SHOW_STR |
| 8762 | IPV6_STR |
| 8763 | MBGP_STR |
| 8764 | "Display routes matching the communities\n" |
| 8765 | "community number\n" |
| 8766 | "Do not send outside local AS (well-known community)\n" |
| 8767 | "Do not advertise to any peer (well-known community)\n" |
| 8768 | "Do not export to next AS (well-known community)\n" |
| 8769 | "community number\n" |
| 8770 | "Do not send outside local AS (well-known community)\n" |
| 8771 | "Do not advertise to any peer (well-known community)\n" |
| 8772 | "Do not export to next AS (well-known community)\n" |
| 8773 | "Exact match of the communities") |
| 8774 | |
| 8775 | /* old command */ |
| 8776 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8777 | show_ipv6_mbgp_community3_exact_cmd, |
| 8778 | "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", |
| 8779 | SHOW_STR |
| 8780 | IPV6_STR |
| 8781 | MBGP_STR |
| 8782 | "Display routes matching the communities\n" |
| 8783 | "community number\n" |
| 8784 | "Do not send outside local AS (well-known community)\n" |
| 8785 | "Do not advertise to any peer (well-known community)\n" |
| 8786 | "Do not export to next AS (well-known community)\n" |
| 8787 | "community number\n" |
| 8788 | "Do not send outside local AS (well-known community)\n" |
| 8789 | "Do not advertise to any peer (well-known community)\n" |
| 8790 | "Do not export to next AS (well-known community)\n" |
| 8791 | "community number\n" |
| 8792 | "Do not send outside local AS (well-known community)\n" |
| 8793 | "Do not advertise to any peer (well-known community)\n" |
| 8794 | "Do not export to next AS (well-known community)\n" |
| 8795 | "Exact match of the communities") |
| 8796 | |
| 8797 | /* old command */ |
| 8798 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8799 | show_ipv6_mbgp_community4_exact_cmd, |
| 8800 | "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", |
| 8801 | SHOW_STR |
| 8802 | IPV6_STR |
| 8803 | MBGP_STR |
| 8804 | "Display routes matching the communities\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 | "community number\n" |
| 8810 | "Do not send outside local AS (well-known community)\n" |
| 8811 | "Do not advertise to any peer (well-known community)\n" |
| 8812 | "Do not export to next AS (well-known community)\n" |
| 8813 | "community number\n" |
| 8814 | "Do not send outside local AS (well-known community)\n" |
| 8815 | "Do not advertise to any peer (well-known community)\n" |
| 8816 | "Do not export to next AS (well-known community)\n" |
| 8817 | "community number\n" |
| 8818 | "Do not send outside local AS (well-known community)\n" |
| 8819 | "Do not advertise to any peer (well-known community)\n" |
| 8820 | "Do not export to next AS (well-known community)\n" |
| 8821 | "Exact match of the communities") |
| 8822 | #endif /* HAVE_IPV6 */ |
| 8823 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8824 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8825 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 8826 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8827 | { |
| 8828 | struct community_list *list; |
| 8829 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8830 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8831 | if (list == NULL) |
| 8832 | { |
| 8833 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 8834 | VTY_NEWLINE); |
| 8835 | return CMD_WARNING; |
| 8836 | } |
| 8837 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8838 | return bgp_show (vty, NULL, afi, safi, |
| 8839 | (exact ? bgp_show_type_community_list_exact : |
| 8840 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8841 | } |
| 8842 | |
| 8843 | DEFUN (show_ip_bgp_community_list, |
| 8844 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8845 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8846 | SHOW_STR |
| 8847 | IP_STR |
| 8848 | BGP_STR |
| 8849 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8850 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8851 | "community-list name\n") |
| 8852 | { |
| 8853 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 8854 | } |
| 8855 | |
| 8856 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 8857 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8858 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8859 | SHOW_STR |
| 8860 | IP_STR |
| 8861 | BGP_STR |
| 8862 | "Address family\n" |
| 8863 | "Address Family modifier\n" |
| 8864 | "Address Family modifier\n" |
| 8865 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8866 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8867 | "community-list name\n") |
| 8868 | { |
| 8869 | if (strncmp (argv[0], "m", 1) == 0) |
| 8870 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 8871 | |
| 8872 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 8873 | } |
| 8874 | |
| 8875 | DEFUN (show_ip_bgp_community_list_exact, |
| 8876 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8877 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8878 | SHOW_STR |
| 8879 | IP_STR |
| 8880 | BGP_STR |
| 8881 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8882 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8883 | "community-list name\n" |
| 8884 | "Exact match of the communities\n") |
| 8885 | { |
| 8886 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 8887 | } |
| 8888 | |
| 8889 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 8890 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8891 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8892 | SHOW_STR |
| 8893 | IP_STR |
| 8894 | BGP_STR |
| 8895 | "Address family\n" |
| 8896 | "Address Family modifier\n" |
| 8897 | "Address Family modifier\n" |
| 8898 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8899 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8900 | "community-list name\n" |
| 8901 | "Exact match of the communities\n") |
| 8902 | { |
| 8903 | if (strncmp (argv[0], "m", 1) == 0) |
| 8904 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 8905 | |
| 8906 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 8907 | } |
| 8908 | |
| 8909 | #ifdef HAVE_IPV6 |
| 8910 | DEFUN (show_bgp_community_list, |
| 8911 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8912 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8913 | SHOW_STR |
| 8914 | BGP_STR |
| 8915 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8916 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8917 | "community-list name\n") |
| 8918 | { |
| 8919 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8920 | } |
| 8921 | |
| 8922 | ALIAS (show_bgp_community_list, |
| 8923 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8924 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8925 | SHOW_STR |
| 8926 | BGP_STR |
| 8927 | "Address family\n" |
| 8928 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8929 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 8930 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8931 | |
| 8932 | /* old command */ |
| 8933 | DEFUN (show_ipv6_bgp_community_list, |
| 8934 | show_ipv6_bgp_community_list_cmd, |
| 8935 | "show ipv6 bgp community-list WORD", |
| 8936 | SHOW_STR |
| 8937 | IPV6_STR |
| 8938 | BGP_STR |
| 8939 | "Display routes matching the community-list\n" |
| 8940 | "community-list name\n") |
| 8941 | { |
| 8942 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8943 | } |
| 8944 | |
| 8945 | /* old command */ |
| 8946 | DEFUN (show_ipv6_mbgp_community_list, |
| 8947 | show_ipv6_mbgp_community_list_cmd, |
| 8948 | "show ipv6 mbgp community-list WORD", |
| 8949 | SHOW_STR |
| 8950 | IPV6_STR |
| 8951 | MBGP_STR |
| 8952 | "Display routes matching the community-list\n" |
| 8953 | "community-list name\n") |
| 8954 | { |
| 8955 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 8956 | } |
| 8957 | |
| 8958 | DEFUN (show_bgp_community_list_exact, |
| 8959 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8960 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8961 | SHOW_STR |
| 8962 | BGP_STR |
| 8963 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8964 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8965 | "community-list name\n" |
| 8966 | "Exact match of the communities\n") |
| 8967 | { |
| 8968 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8969 | } |
| 8970 | |
| 8971 | ALIAS (show_bgp_community_list_exact, |
| 8972 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8973 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8974 | SHOW_STR |
| 8975 | BGP_STR |
| 8976 | "Address family\n" |
| 8977 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8978 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8979 | "community-list name\n" |
| 8980 | "Exact match of the communities\n") |
| 8981 | |
| 8982 | /* old command */ |
| 8983 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 8984 | show_ipv6_bgp_community_list_exact_cmd, |
| 8985 | "show ipv6 bgp community-list WORD exact-match", |
| 8986 | SHOW_STR |
| 8987 | IPV6_STR |
| 8988 | BGP_STR |
| 8989 | "Display routes matching the community-list\n" |
| 8990 | "community-list name\n" |
| 8991 | "Exact match of the communities\n") |
| 8992 | { |
| 8993 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8994 | } |
| 8995 | |
| 8996 | /* old command */ |
| 8997 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 8998 | show_ipv6_mbgp_community_list_exact_cmd, |
| 8999 | "show ipv6 mbgp community-list WORD exact-match", |
| 9000 | SHOW_STR |
| 9001 | IPV6_STR |
| 9002 | MBGP_STR |
| 9003 | "Display routes matching the community-list\n" |
| 9004 | "community-list name\n" |
| 9005 | "Exact match of the communities\n") |
| 9006 | { |
| 9007 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 9008 | } |
| 9009 | #endif /* HAVE_IPV6 */ |
| 9010 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9011 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9012 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9013 | safi_t safi, enum bgp_show_type type) |
| 9014 | { |
| 9015 | int ret; |
| 9016 | struct prefix *p; |
| 9017 | |
| 9018 | p = prefix_new(); |
| 9019 | |
| 9020 | ret = str2prefix (prefix, p); |
| 9021 | if (! ret) |
| 9022 | { |
| 9023 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 9024 | return CMD_WARNING; |
| 9025 | } |
| 9026 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9027 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 9028 | prefix_free(p); |
| 9029 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9030 | } |
| 9031 | |
| 9032 | DEFUN (show_ip_bgp_prefix_longer, |
| 9033 | show_ip_bgp_prefix_longer_cmd, |
| 9034 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 9035 | SHOW_STR |
| 9036 | IP_STR |
| 9037 | BGP_STR |
| 9038 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9039 | "Display route and more specific routes\n") |
| 9040 | { |
| 9041 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9042 | bgp_show_type_prefix_longer); |
| 9043 | } |
| 9044 | |
| 9045 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 9046 | show_ip_bgp_flap_prefix_longer_cmd, |
| 9047 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 9048 | SHOW_STR |
| 9049 | IP_STR |
| 9050 | BGP_STR |
| 9051 | "Display flap statistics of routes\n" |
| 9052 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9053 | "Display route and more specific routes\n") |
| 9054 | { |
| 9055 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9056 | bgp_show_type_flap_prefix_longer); |
| 9057 | } |
| 9058 | |
| 9059 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 9060 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 9061 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 9062 | SHOW_STR |
| 9063 | IP_STR |
| 9064 | BGP_STR |
| 9065 | "Address family\n" |
| 9066 | "Address Family modifier\n" |
| 9067 | "Address Family modifier\n" |
| 9068 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9069 | "Display route and more specific routes\n") |
| 9070 | { |
| 9071 | if (strncmp (argv[0], "m", 1) == 0) |
| 9072 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 9073 | bgp_show_type_prefix_longer); |
| 9074 | |
| 9075 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 9076 | bgp_show_type_prefix_longer); |
| 9077 | } |
| 9078 | |
| 9079 | DEFUN (show_ip_bgp_flap_address, |
| 9080 | show_ip_bgp_flap_address_cmd, |
| 9081 | "show ip bgp flap-statistics A.B.C.D", |
| 9082 | SHOW_STR |
| 9083 | IP_STR |
| 9084 | BGP_STR |
| 9085 | "Display flap statistics of routes\n" |
| 9086 | "Network in the BGP routing table to display\n") |
| 9087 | { |
| 9088 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9089 | bgp_show_type_flap_address); |
| 9090 | } |
| 9091 | |
| 9092 | DEFUN (show_ip_bgp_flap_prefix, |
| 9093 | show_ip_bgp_flap_prefix_cmd, |
| 9094 | "show ip bgp flap-statistics A.B.C.D/M", |
| 9095 | SHOW_STR |
| 9096 | IP_STR |
| 9097 | BGP_STR |
| 9098 | "Display flap statistics of routes\n" |
| 9099 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9100 | { |
| 9101 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9102 | bgp_show_type_flap_prefix); |
| 9103 | } |
| 9104 | #ifdef HAVE_IPV6 |
| 9105 | DEFUN (show_bgp_prefix_longer, |
| 9106 | show_bgp_prefix_longer_cmd, |
| 9107 | "show bgp X:X::X:X/M longer-prefixes", |
| 9108 | SHOW_STR |
| 9109 | BGP_STR |
| 9110 | "IPv6 prefix <network>/<length>\n" |
| 9111 | "Display route and more specific routes\n") |
| 9112 | { |
| 9113 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9114 | bgp_show_type_prefix_longer); |
| 9115 | } |
| 9116 | |
| 9117 | ALIAS (show_bgp_prefix_longer, |
| 9118 | show_bgp_ipv6_prefix_longer_cmd, |
| 9119 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 9120 | SHOW_STR |
| 9121 | BGP_STR |
| 9122 | "Address family\n" |
| 9123 | "IPv6 prefix <network>/<length>\n" |
| 9124 | "Display route and more specific routes\n") |
| 9125 | |
| 9126 | /* old command */ |
| 9127 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 9128 | show_ipv6_bgp_prefix_longer_cmd, |
| 9129 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 9130 | SHOW_STR |
| 9131 | IPV6_STR |
| 9132 | BGP_STR |
| 9133 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9134 | "Display route and more specific routes\n") |
| 9135 | { |
| 9136 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9137 | bgp_show_type_prefix_longer); |
| 9138 | } |
| 9139 | |
| 9140 | /* old command */ |
| 9141 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 9142 | show_ipv6_mbgp_prefix_longer_cmd, |
| 9143 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 9144 | SHOW_STR |
| 9145 | IPV6_STR |
| 9146 | MBGP_STR |
| 9147 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9148 | "Display route and more specific routes\n") |
| 9149 | { |
| 9150 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 9151 | bgp_show_type_prefix_longer); |
| 9152 | } |
| 9153 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9154 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9155 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9156 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 9157 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9158 | { |
| 9159 | int ret; |
| 9160 | struct bgp *bgp; |
| 9161 | struct peer *peer; |
| 9162 | union sockunion su; |
| 9163 | |
| 9164 | /* BGP structure lookup. */ |
| 9165 | if (view_name) |
| 9166 | { |
| 9167 | bgp = bgp_lookup_by_name (view_name); |
| 9168 | if (! bgp) |
| 9169 | { |
| 9170 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9171 | return NULL; |
| 9172 | } |
| 9173 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 9174 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9175 | { |
| 9176 | bgp = bgp_get_default (); |
| 9177 | if (! bgp) |
| 9178 | { |
| 9179 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9180 | return NULL; |
| 9181 | } |
| 9182 | } |
| 9183 | |
| 9184 | /* Get peer sockunion. */ |
| 9185 | ret = str2sockunion (ip_str, &su); |
| 9186 | if (ret < 0) |
| 9187 | { |
| 9188 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 9189 | return NULL; |
| 9190 | } |
| 9191 | |
| 9192 | /* Peer structure lookup. */ |
| 9193 | peer = peer_lookup (bgp, &su); |
| 9194 | if (! peer) |
| 9195 | { |
| 9196 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 9197 | return NULL; |
| 9198 | } |
| 9199 | |
| 9200 | return peer; |
| 9201 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9202 | |
| 9203 | enum bgp_stats |
| 9204 | { |
| 9205 | BGP_STATS_MAXBITLEN = 0, |
| 9206 | BGP_STATS_RIB, |
| 9207 | BGP_STATS_PREFIXES, |
| 9208 | BGP_STATS_TOTPLEN, |
| 9209 | BGP_STATS_UNAGGREGATEABLE, |
| 9210 | BGP_STATS_MAX_AGGREGATEABLE, |
| 9211 | BGP_STATS_AGGREGATES, |
| 9212 | BGP_STATS_SPACE, |
| 9213 | BGP_STATS_ASPATH_COUNT, |
| 9214 | BGP_STATS_ASPATH_MAXHOPS, |
| 9215 | BGP_STATS_ASPATH_TOTHOPS, |
| 9216 | BGP_STATS_ASPATH_MAXSIZE, |
| 9217 | BGP_STATS_ASPATH_TOTSIZE, |
| 9218 | BGP_STATS_ASN_HIGHEST, |
| 9219 | BGP_STATS_MAX, |
| 9220 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9221 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9222 | static const char *table_stats_strs[] = |
| 9223 | { |
| 9224 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 9225 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 9226 | [BGP_STATS_RIB] = "Total Advertisements", |
| 9227 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 9228 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 9229 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 9230 | [BGP_STATS_SPACE] = "Address space advertised", |
| 9231 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 9232 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 9233 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 9234 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 9235 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 9236 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 9237 | [BGP_STATS_MAX] = NULL, |
| 9238 | }; |
| 9239 | |
| 9240 | struct bgp_table_stats |
| 9241 | { |
| 9242 | struct bgp_table *table; |
| 9243 | unsigned long long counts[BGP_STATS_MAX]; |
| 9244 | }; |
| 9245 | |
| 9246 | #if 0 |
| 9247 | #define TALLY_SIGFIG 100000 |
| 9248 | static unsigned long |
| 9249 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 9250 | { |
| 9251 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 9252 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 9253 | unsigned long ret = newtot / count; |
| 9254 | |
| 9255 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 9256 | return ret + 1; |
| 9257 | else |
| 9258 | return ret; |
| 9259 | } |
| 9260 | #endif |
| 9261 | |
| 9262 | static int |
| 9263 | bgp_table_stats_walker (struct thread *t) |
| 9264 | { |
| 9265 | struct bgp_node *rn; |
| 9266 | struct bgp_node *top; |
| 9267 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 9268 | unsigned int space = 0; |
| 9269 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 9270 | if (!(top = bgp_table_top (ts->table))) |
| 9271 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9272 | |
| 9273 | switch (top->p.family) |
| 9274 | { |
| 9275 | case AF_INET: |
| 9276 | space = IPV4_MAX_BITLEN; |
| 9277 | break; |
| 9278 | case AF_INET6: |
| 9279 | space = IPV6_MAX_BITLEN; |
| 9280 | break; |
| 9281 | } |
| 9282 | |
| 9283 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 9284 | |
| 9285 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 9286 | { |
| 9287 | struct bgp_info *ri; |
| 9288 | struct bgp_node *prn = rn->parent; |
| 9289 | unsigned int rinum = 0; |
| 9290 | |
| 9291 | if (rn == top) |
| 9292 | continue; |
| 9293 | |
| 9294 | if (!rn->info) |
| 9295 | continue; |
| 9296 | |
| 9297 | ts->counts[BGP_STATS_PREFIXES]++; |
| 9298 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 9299 | |
| 9300 | #if 0 |
| 9301 | ts->counts[BGP_STATS_AVGPLEN] |
| 9302 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 9303 | ts->counts[BGP_STATS_AVGPLEN], |
| 9304 | rn->p.prefixlen); |
| 9305 | #endif |
| 9306 | |
| 9307 | /* check if the prefix is included by any other announcements */ |
| 9308 | while (prn && !prn->info) |
| 9309 | prn = prn->parent; |
| 9310 | |
| 9311 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 9312 | { |
| 9313 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 9314 | /* announced address space */ |
| 9315 | if (space) |
| 9316 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 9317 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9318 | else if (prn->info) |
| 9319 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 9320 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9321 | for (ri = rn->info; ri; ri = ri->next) |
| 9322 | { |
| 9323 | rinum++; |
| 9324 | ts->counts[BGP_STATS_RIB]++; |
| 9325 | |
| 9326 | if (ri->attr && |
| 9327 | (CHECK_FLAG (ri->attr->flag, |
| 9328 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 9329 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 9330 | |
| 9331 | /* as-path stats */ |
| 9332 | if (ri->attr && ri->attr->aspath) |
| 9333 | { |
| 9334 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 9335 | unsigned int size = aspath_size (ri->attr->aspath); |
| 9336 | as_t highest = aspath_highest (ri->attr->aspath); |
| 9337 | |
| 9338 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 9339 | |
| 9340 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 9341 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 9342 | |
| 9343 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 9344 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 9345 | |
| 9346 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 9347 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 9348 | #if 0 |
| 9349 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 9350 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9351 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 9352 | hops); |
| 9353 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 9354 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9355 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 9356 | size); |
| 9357 | #endif |
| 9358 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 9359 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 9360 | } |
| 9361 | } |
| 9362 | } |
| 9363 | return 0; |
| 9364 | } |
| 9365 | |
| 9366 | static int |
| 9367 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 9368 | { |
| 9369 | struct bgp_table_stats ts; |
| 9370 | unsigned int i; |
| 9371 | |
| 9372 | if (!bgp->rib[afi][safi]) |
| 9373 | { |
| 9374 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); |
| 9375 | return CMD_WARNING; |
| 9376 | } |
| 9377 | |
| 9378 | memset (&ts, 0, sizeof (ts)); |
| 9379 | ts.table = bgp->rib[afi][safi]; |
| 9380 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 9381 | |
| 9382 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 9383 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 9384 | |
| 9385 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 9386 | { |
| 9387 | if (!table_stats_strs[i]) |
| 9388 | continue; |
| 9389 | |
| 9390 | switch (i) |
| 9391 | { |
| 9392 | #if 0 |
| 9393 | case BGP_STATS_ASPATH_AVGHOPS: |
| 9394 | case BGP_STATS_ASPATH_AVGSIZE: |
| 9395 | case BGP_STATS_AVGPLEN: |
| 9396 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9397 | vty_out (vty, "%12.2f", |
| 9398 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 9399 | break; |
| 9400 | #endif |
| 9401 | case BGP_STATS_ASPATH_TOTHOPS: |
| 9402 | case BGP_STATS_ASPATH_TOTSIZE: |
| 9403 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9404 | vty_out (vty, "%12.2f", |
| 9405 | ts.counts[i] ? |
| 9406 | (float)ts.counts[i] / |
| 9407 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 9408 | : 0); |
| 9409 | break; |
| 9410 | case BGP_STATS_TOTPLEN: |
| 9411 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9412 | vty_out (vty, "%12.2f", |
| 9413 | ts.counts[i] ? |
| 9414 | (float)ts.counts[i] / |
| 9415 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 9416 | : 0); |
| 9417 | break; |
| 9418 | case BGP_STATS_SPACE: |
| 9419 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9420 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 9421 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 9422 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 9423 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9424 | vty_out (vty, "%12.2f%s", |
| 9425 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 9426 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9427 | VTY_NEWLINE); |
| 9428 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 9429 | vty_out (vty, "%12.2f%s", |
| 9430 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9431 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 9432 | VTY_NEWLINE); |
| 9433 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 9434 | break; |
| 9435 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 9436 | vty_out (vty, "%12.2f", |
| 9437 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9438 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 9439 | break; |
| 9440 | default: |
| 9441 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9442 | vty_out (vty, "%12llu", ts.counts[i]); |
| 9443 | } |
| 9444 | |
| 9445 | vty_out (vty, "%s", VTY_NEWLINE); |
| 9446 | } |
| 9447 | return CMD_SUCCESS; |
| 9448 | } |
| 9449 | |
| 9450 | static int |
| 9451 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 9452 | const char *afi_str, const char *safi_str) |
| 9453 | { |
| 9454 | struct bgp *bgp; |
| 9455 | afi_t afi; |
| 9456 | safi_t safi; |
| 9457 | |
| 9458 | if (name) |
| 9459 | bgp = bgp_lookup_by_name (name); |
| 9460 | else |
| 9461 | bgp = bgp_get_default (); |
| 9462 | |
| 9463 | if (!bgp) |
| 9464 | { |
| 9465 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); |
| 9466 | return CMD_WARNING; |
| 9467 | } |
| 9468 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 9469 | { |
| 9470 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 9471 | afi = AFI_IP; |
| 9472 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 9473 | afi = AFI_IP6; |
| 9474 | else |
| 9475 | { |
| 9476 | vty_out (vty, "%% Invalid address family %s%s", |
| 9477 | afi_str, VTY_NEWLINE); |
| 9478 | return CMD_WARNING; |
| 9479 | } |
| 9480 | if (strncmp (safi_str, "m", 1) == 0) |
| 9481 | safi = SAFI_MULTICAST; |
| 9482 | else if (strncmp (safi_str, "u", 1) == 0) |
| 9483 | safi = SAFI_UNICAST; |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 9484 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
| 9485 | safi = SAFI_MPLS_LABELED_VPN; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9486 | else |
| 9487 | { |
| 9488 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
| 9489 | safi_str, VTY_NEWLINE); |
| 9490 | return CMD_WARNING; |
| 9491 | } |
| 9492 | } |
| 9493 | else |
| 9494 | { |
| 9495 | vty_out (vty, "%% Invalid address family %s%s", |
| 9496 | afi_str, VTY_NEWLINE); |
| 9497 | return CMD_WARNING; |
| 9498 | } |
| 9499 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9500 | return bgp_table_stats (vty, bgp, afi, safi); |
| 9501 | } |
| 9502 | |
| 9503 | DEFUN (show_bgp_statistics, |
| 9504 | show_bgp_statistics_cmd, |
| 9505 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", |
| 9506 | SHOW_STR |
| 9507 | BGP_STR |
| 9508 | "Address family\n" |
| 9509 | "Address family\n" |
| 9510 | "Address Family modifier\n" |
| 9511 | "Address Family modifier\n" |
| 9512 | "BGP RIB advertisement statistics\n") |
| 9513 | { |
| 9514 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9515 | } |
| 9516 | |
| 9517 | ALIAS (show_bgp_statistics, |
| 9518 | show_bgp_statistics_vpnv4_cmd, |
| 9519 | "show bgp (ipv4) (vpnv4) statistics", |
| 9520 | SHOW_STR |
| 9521 | BGP_STR |
| 9522 | "Address family\n" |
| 9523 | "Address Family modifier\n" |
| 9524 | "BGP RIB advertisement statistics\n") |
| 9525 | |
| 9526 | DEFUN (show_bgp_statistics_view, |
| 9527 | show_bgp_statistics_view_cmd, |
| 9528 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", |
| 9529 | SHOW_STR |
| 9530 | BGP_STR |
| 9531 | "BGP view\n" |
| 9532 | "Address family\n" |
| 9533 | "Address family\n" |
| 9534 | "Address Family modifier\n" |
| 9535 | "Address Family modifier\n" |
| 9536 | "BGP RIB advertisement statistics\n") |
| 9537 | { |
| 9538 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9539 | } |
| 9540 | |
| 9541 | ALIAS (show_bgp_statistics_view, |
| 9542 | show_bgp_statistics_view_vpnv4_cmd, |
| 9543 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
| 9544 | SHOW_STR |
| 9545 | BGP_STR |
| 9546 | "BGP view\n" |
| 9547 | "Address family\n" |
| 9548 | "Address Family modifier\n" |
| 9549 | "BGP RIB advertisement statistics\n") |
| 9550 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9551 | enum bgp_pcounts |
| 9552 | { |
| 9553 | PCOUNT_ADJ_IN = 0, |
| 9554 | PCOUNT_DAMPED, |
| 9555 | PCOUNT_REMOVED, |
| 9556 | PCOUNT_HISTORY, |
| 9557 | PCOUNT_STALE, |
| 9558 | PCOUNT_VALID, |
| 9559 | PCOUNT_ALL, |
| 9560 | PCOUNT_COUNTED, |
| 9561 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 9562 | PCOUNT_MAX, |
| 9563 | }; |
| 9564 | |
| 9565 | static const char *pcount_strs[] = |
| 9566 | { |
| 9567 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 9568 | [PCOUNT_DAMPED] = "Damped", |
| 9569 | [PCOUNT_REMOVED] = "Removed", |
| 9570 | [PCOUNT_HISTORY] = "History", |
| 9571 | [PCOUNT_STALE] = "Stale", |
| 9572 | [PCOUNT_VALID] = "Valid", |
| 9573 | [PCOUNT_ALL] = "All RIB", |
| 9574 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 9575 | [PCOUNT_PFCNT] = "Useable", |
| 9576 | [PCOUNT_MAX] = NULL, |
| 9577 | }; |
| 9578 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9579 | struct peer_pcounts |
| 9580 | { |
| 9581 | unsigned int count[PCOUNT_MAX]; |
| 9582 | const struct peer *peer; |
| 9583 | const struct bgp_table *table; |
| 9584 | }; |
| 9585 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9586 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9587 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9588 | { |
| 9589 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9590 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 9591 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9592 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9593 | 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] | 9594 | { |
| 9595 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9596 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9597 | |
| 9598 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9599 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9600 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9601 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9602 | for (ri = rn->info; ri; ri = ri->next) |
| 9603 | { |
| 9604 | char buf[SU_ADDRSTRLEN]; |
| 9605 | |
| 9606 | if (ri->peer != peer) |
| 9607 | continue; |
| 9608 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9609 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9610 | |
| 9611 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9612 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9613 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9614 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9615 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9616 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9617 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9618 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9619 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9620 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9621 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9622 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9623 | |
| 9624 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 9625 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9626 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9627 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9628 | plog_warn (peer->log, |
| 9629 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 9630 | peer->host, |
| 9631 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9632 | buf, SU_ADDRSTRLEN), |
| 9633 | rn->p.prefixlen, |
| 9634 | ri->flags); |
| 9635 | } |
| 9636 | else |
| 9637 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9638 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9639 | plog_warn (peer->log, |
| 9640 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 9641 | peer->host, |
| 9642 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9643 | buf, SU_ADDRSTRLEN), |
| 9644 | rn->p.prefixlen, |
| 9645 | ri->flags); |
| 9646 | } |
| 9647 | } |
| 9648 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9649 | return 0; |
| 9650 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9651 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9652 | static int |
| 9653 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 9654 | { |
| 9655 | struct peer_pcounts pcounts = { .peer = peer }; |
| 9656 | unsigned int i; |
| 9657 | |
| 9658 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 9659 | || !peer->bgp->rib[afi][safi]) |
| 9660 | { |
| 9661 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9662 | return CMD_WARNING; |
| 9663 | } |
| 9664 | |
| 9665 | memset (&pcounts, 0, sizeof(pcounts)); |
| 9666 | pcounts.peer = peer; |
| 9667 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 9668 | |
| 9669 | /* in-place call via thread subsystem so as to record execution time |
| 9670 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 9671 | * on just vty_read()). |
| 9672 | */ |
| 9673 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 9674 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9675 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 9676 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 9677 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 9678 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 9679 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 9680 | |
| 9681 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9682 | vty_out (vty, "%20s: %-10d%s", |
| 9683 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9684 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9685 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9686 | { |
| 9687 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 9688 | peer->host, VTY_NEWLINE); |
| 9689 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 9690 | VTY_NEWLINE); |
| 9691 | } |
| 9692 | |
| 9693 | return CMD_SUCCESS; |
| 9694 | } |
| 9695 | |
| 9696 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 9697 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 9698 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9699 | SHOW_STR |
| 9700 | IP_STR |
| 9701 | BGP_STR |
| 9702 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9703 | "Neighbor to display information about\n" |
| 9704 | "Neighbor to display information about\n" |
| 9705 | "Display detailed prefix count information\n") |
| 9706 | { |
| 9707 | struct peer *peer; |
| 9708 | |
| 9709 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9710 | if (! peer) |
| 9711 | return CMD_WARNING; |
| 9712 | |
| 9713 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9714 | } |
| 9715 | |
| 9716 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 9717 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 9718 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9719 | SHOW_STR |
| 9720 | BGP_STR |
| 9721 | "Address family\n" |
| 9722 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9723 | "Neighbor to display information about\n" |
| 9724 | "Neighbor to display information about\n" |
| 9725 | "Display detailed prefix count information\n") |
| 9726 | { |
| 9727 | struct peer *peer; |
| 9728 | |
| 9729 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9730 | if (! peer) |
| 9731 | return CMD_WARNING; |
| 9732 | |
| 9733 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 9734 | } |
| 9735 | |
| 9736 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 9737 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 9738 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9739 | SHOW_STR |
| 9740 | IP_STR |
| 9741 | BGP_STR |
| 9742 | "Address family\n" |
| 9743 | "Address Family modifier\n" |
| 9744 | "Address Family modifier\n" |
| 9745 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9746 | "Neighbor to display information about\n" |
| 9747 | "Neighbor to display information about\n" |
| 9748 | "Display detailed prefix count information\n") |
| 9749 | { |
| 9750 | struct peer *peer; |
| 9751 | |
| 9752 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9753 | if (! peer) |
| 9754 | return CMD_WARNING; |
| 9755 | |
| 9756 | if (strncmp (argv[0], "m", 1) == 0) |
| 9757 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 9758 | |
| 9759 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9760 | } |
| 9761 | |
| 9762 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 9763 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 9764 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9765 | SHOW_STR |
| 9766 | IP_STR |
| 9767 | BGP_STR |
| 9768 | "Address family\n" |
| 9769 | "Address Family modifier\n" |
| 9770 | "Address Family modifier\n" |
| 9771 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9772 | "Neighbor to display information about\n" |
| 9773 | "Neighbor to display information about\n" |
| 9774 | "Display detailed prefix count information\n") |
| 9775 | { |
| 9776 | struct peer *peer; |
| 9777 | |
| 9778 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9779 | if (! peer) |
| 9780 | return CMD_WARNING; |
| 9781 | |
| 9782 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 9783 | } |
| 9784 | |
| 9785 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9786 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9787 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 9788 | int in) |
| 9789 | { |
| 9790 | struct bgp_table *table; |
| 9791 | struct bgp_adj_in *ain; |
| 9792 | struct bgp_adj_out *adj; |
| 9793 | unsigned long output_count; |
| 9794 | struct bgp_node *rn; |
| 9795 | int header1 = 1; |
| 9796 | struct bgp *bgp; |
| 9797 | int header2 = 1; |
| 9798 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9799 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9800 | |
| 9801 | if (! bgp) |
| 9802 | return; |
| 9803 | |
| 9804 | table = bgp->rib[afi][safi]; |
| 9805 | |
| 9806 | output_count = 0; |
| 9807 | |
| 9808 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 9809 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 9810 | { |
| 9811 | 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] | 9812 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9813 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9814 | |
| 9815 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 9816 | VTY_NEWLINE, VTY_NEWLINE); |
| 9817 | header1 = 0; |
| 9818 | } |
| 9819 | |
| 9820 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 9821 | if (in) |
| 9822 | { |
| 9823 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9824 | if (ain->peer == peer) |
| 9825 | { |
| 9826 | if (header1) |
| 9827 | { |
| 9828 | 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] | 9829 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9830 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9831 | header1 = 0; |
| 9832 | } |
| 9833 | if (header2) |
| 9834 | { |
| 9835 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9836 | header2 = 0; |
| 9837 | } |
| 9838 | if (ain->attr) |
| 9839 | { |
| 9840 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 9841 | output_count++; |
| 9842 | } |
| 9843 | } |
| 9844 | } |
| 9845 | else |
| 9846 | { |
| 9847 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 9848 | if (adj->peer == peer) |
| 9849 | { |
| 9850 | if (header1) |
| 9851 | { |
| 9852 | 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] | 9853 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9854 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9855 | header1 = 0; |
| 9856 | } |
| 9857 | if (header2) |
| 9858 | { |
| 9859 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9860 | header2 = 0; |
| 9861 | } |
| 9862 | if (adj->attr) |
| 9863 | { |
| 9864 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 9865 | output_count++; |
| 9866 | } |
| 9867 | } |
| 9868 | } |
| 9869 | |
| 9870 | if (output_count != 0) |
| 9871 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 9872 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 9873 | } |
| 9874 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9875 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9876 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 9877 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9878 | if (! peer || ! peer->afc[afi][safi]) |
| 9879 | { |
| 9880 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9881 | return CMD_WARNING; |
| 9882 | } |
| 9883 | |
| 9884 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 9885 | { |
| 9886 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 9887 | VTY_NEWLINE); |
| 9888 | return CMD_WARNING; |
| 9889 | } |
| 9890 | |
| 9891 | show_adj_route (vty, peer, afi, safi, in); |
| 9892 | |
| 9893 | return CMD_SUCCESS; |
| 9894 | } |
| 9895 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 9896 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 9897 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 9898 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9899 | SHOW_STR |
| 9900 | IP_STR |
| 9901 | BGP_STR |
| 9902 | "BGP view\n" |
| 9903 | "View name\n" |
| 9904 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9905 | "Neighbor to display information about\n" |
| 9906 | "Neighbor to display information about\n" |
| 9907 | "Display the routes advertised to a BGP neighbor\n") |
| 9908 | { |
| 9909 | struct peer *peer; |
| 9910 | |
| 9911 | if (argc == 2) |
| 9912 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9913 | else |
| 9914 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9915 | |
| 9916 | if (! peer) |
| 9917 | return CMD_WARNING; |
| 9918 | |
| 9919 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 9920 | } |
| 9921 | |
| 9922 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9923 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 9924 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9925 | SHOW_STR |
| 9926 | IP_STR |
| 9927 | BGP_STR |
| 9928 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9929 | "Neighbor to display information about\n" |
| 9930 | "Neighbor to display information about\n" |
| 9931 | "Display the routes advertised to a BGP neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9932 | |
| 9933 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 9934 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 9935 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9936 | SHOW_STR |
| 9937 | IP_STR |
| 9938 | BGP_STR |
| 9939 | "Address family\n" |
| 9940 | "Address Family modifier\n" |
| 9941 | "Address Family modifier\n" |
| 9942 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9943 | "Neighbor to display information about\n" |
| 9944 | "Neighbor to display information about\n" |
| 9945 | "Display the routes advertised to a BGP neighbor\n") |
| 9946 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9947 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9948 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9949 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9950 | if (! peer) |
| 9951 | return CMD_WARNING; |
| 9952 | |
| 9953 | if (strncmp (argv[0], "m", 1) == 0) |
| 9954 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 9955 | |
| 9956 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9957 | } |
| 9958 | |
| 9959 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9960 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 9961 | show_bgp_view_neighbor_advertised_route_cmd, |
| 9962 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9963 | SHOW_STR |
| 9964 | BGP_STR |
| 9965 | "BGP view\n" |
| 9966 | "View name\n" |
| 9967 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9968 | "Neighbor to display information about\n" |
| 9969 | "Neighbor to display information about\n" |
| 9970 | "Display the routes advertised to a BGP neighbor\n") |
| 9971 | { |
| 9972 | struct peer *peer; |
| 9973 | |
| 9974 | if (argc == 2) |
| 9975 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9976 | else |
| 9977 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9978 | |
| 9979 | if (! peer) |
| 9980 | return CMD_WARNING; |
| 9981 | |
| 9982 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 9983 | } |
| 9984 | |
| 9985 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 9986 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 9987 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9988 | SHOW_STR |
| 9989 | BGP_STR |
| 9990 | "BGP view\n" |
| 9991 | "View name\n" |
| 9992 | "Address family\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 routes advertised to a BGP neighbor\n") |
| 9997 | |
| 9998 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 9999 | show_bgp_view_neighbor_received_routes_cmd, |
| 10000 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10001 | SHOW_STR |
| 10002 | BGP_STR |
| 10003 | "BGP view\n" |
| 10004 | "View name\n" |
| 10005 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10006 | "Neighbor to display information about\n" |
| 10007 | "Neighbor to display information about\n" |
| 10008 | "Display the received routes from neighbor\n") |
| 10009 | { |
| 10010 | struct peer *peer; |
| 10011 | |
| 10012 | if (argc == 2) |
| 10013 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10014 | else |
| 10015 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10016 | |
| 10017 | if (! peer) |
| 10018 | return CMD_WARNING; |
| 10019 | |
| 10020 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 10021 | } |
| 10022 | |
| 10023 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 10024 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 10025 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10026 | SHOW_STR |
| 10027 | BGP_STR |
| 10028 | "BGP view\n" |
| 10029 | "View name\n" |
| 10030 | "Address family\n" |
| 10031 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10032 | "Neighbor to display information about\n" |
| 10033 | "Neighbor to display information about\n" |
| 10034 | "Display the received routes from neighbor\n") |
| 10035 | |
| 10036 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10037 | show_bgp_neighbor_advertised_route_cmd, |
| 10038 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10039 | SHOW_STR |
| 10040 | BGP_STR |
| 10041 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10042 | "Neighbor to display information about\n" |
| 10043 | "Neighbor to display information about\n" |
| 10044 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10045 | |
| 10046 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10047 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 10048 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10049 | SHOW_STR |
| 10050 | BGP_STR |
| 10051 | "Address family\n" |
| 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") |
| 10056 | |
| 10057 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10058 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10059 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 10060 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10061 | SHOW_STR |
| 10062 | IPV6_STR |
| 10063 | BGP_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") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10068 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10069 | /* old command */ |
| 10070 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 10071 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 10072 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10073 | SHOW_STR |
| 10074 | IPV6_STR |
| 10075 | MBGP_STR |
| 10076 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10077 | "Neighbor to display information about\n" |
| 10078 | "Neighbor to display information about\n" |
| 10079 | "Display the routes advertised to a BGP neighbor\n") |
| 10080 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10081 | struct peer *peer; |
| 10082 | |
| 10083 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10084 | if (! peer) |
| 10085 | return CMD_WARNING; |
| 10086 | |
| 10087 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10088 | } |
| 10089 | #endif /* HAVE_IPV6 */ |
| 10090 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10091 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 10092 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 10093 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10094 | SHOW_STR |
| 10095 | IP_STR |
| 10096 | BGP_STR |
| 10097 | "BGP view\n" |
| 10098 | "View name\n" |
| 10099 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10100 | "Neighbor to display information about\n" |
| 10101 | "Neighbor to display information about\n" |
| 10102 | "Display the received routes from neighbor\n") |
| 10103 | { |
| 10104 | struct peer *peer; |
| 10105 | |
| 10106 | if (argc == 2) |
| 10107 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10108 | else |
| 10109 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10110 | |
| 10111 | if (! peer) |
| 10112 | return CMD_WARNING; |
| 10113 | |
| 10114 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 10115 | } |
| 10116 | |
| 10117 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10118 | show_ip_bgp_neighbor_received_routes_cmd, |
| 10119 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10120 | SHOW_STR |
| 10121 | IP_STR |
| 10122 | BGP_STR |
| 10123 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10124 | "Neighbor to display information about\n" |
| 10125 | "Neighbor to display information about\n" |
| 10126 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10127 | |
| 10128 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 10129 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 10130 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10131 | SHOW_STR |
| 10132 | IP_STR |
| 10133 | BGP_STR |
| 10134 | "Address family\n" |
| 10135 | "Address Family modifier\n" |
| 10136 | "Address Family modifier\n" |
| 10137 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10138 | "Neighbor to display information about\n" |
| 10139 | "Neighbor to display information about\n" |
| 10140 | "Display the received routes from neighbor\n") |
| 10141 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10142 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10143 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10144 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10145 | if (! peer) |
| 10146 | return CMD_WARNING; |
| 10147 | |
| 10148 | if (strncmp (argv[0], "m", 1) == 0) |
| 10149 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 10150 | |
| 10151 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10152 | } |
| 10153 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10154 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 10155 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
| 10156 | #ifdef HAVE_IPV6 |
| 10157 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
| 10158 | #else |
| 10159 | "show bgp view WORD ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
| 10160 | #endif |
| 10161 | SHOW_STR |
| 10162 | BGP_STR |
| 10163 | "BGP view\n" |
| 10164 | "BGP view name\n" |
| 10165 | "Address family\n" |
| 10166 | #ifdef HAVE_IPV6 |
| 10167 | "Address family\n" |
| 10168 | #endif |
| 10169 | "Address family modifier\n" |
| 10170 | "Address family modifier\n" |
| 10171 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10172 | "Neighbor to display information about\n" |
| 10173 | "Neighbor to display information about\n" |
| 10174 | "Display the advertised routes to neighbor\n" |
| 10175 | "Display the received routes from neighbor\n") |
| 10176 | { |
| 10177 | int afi; |
| 10178 | int safi; |
| 10179 | int in; |
| 10180 | struct peer *peer; |
| 10181 | |
| 10182 | #ifdef HAVE_IPV6 |
| 10183 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
| 10184 | #else |
| 10185 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10186 | #endif |
| 10187 | |
| 10188 | if (! peer) |
| 10189 | return CMD_WARNING; |
| 10190 | |
| 10191 | #ifdef HAVE_IPV6 |
| 10192 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10193 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10194 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
| 10195 | #else |
| 10196 | afi = AFI_IP; |
| 10197 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10198 | in = (strncmp (argv[3], "r", 1) == 0) ? 1 : 0; |
| 10199 | #endif |
| 10200 | |
| 10201 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 10202 | } |
| 10203 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10204 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 10205 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 10206 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10207 | SHOW_STR |
| 10208 | IP_STR |
| 10209 | BGP_STR |
| 10210 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10211 | "Neighbor to display information about\n" |
| 10212 | "Neighbor to display information about\n" |
| 10213 | "Display information received from a BGP neighbor\n" |
| 10214 | "Display the prefixlist filter\n") |
| 10215 | { |
| 10216 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10217 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10218 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10219 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10220 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10221 | ret = str2sockunion (argv[0], &su); |
| 10222 | if (ret < 0) |
| 10223 | { |
| 10224 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10225 | return CMD_WARNING; |
| 10226 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10227 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10228 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10229 | if (! peer) |
| 10230 | return CMD_WARNING; |
| 10231 | |
| 10232 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10233 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10234 | if (count) |
| 10235 | { |
| 10236 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10237 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10238 | } |
| 10239 | |
| 10240 | return CMD_SUCCESS; |
| 10241 | } |
| 10242 | |
| 10243 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 10244 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 10245 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10246 | SHOW_STR |
| 10247 | IP_STR |
| 10248 | BGP_STR |
| 10249 | "Address family\n" |
| 10250 | "Address Family modifier\n" |
| 10251 | "Address Family modifier\n" |
| 10252 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10253 | "Neighbor to display information about\n" |
| 10254 | "Neighbor to display information about\n" |
| 10255 | "Display information received from a BGP neighbor\n" |
| 10256 | "Display the prefixlist filter\n") |
| 10257 | { |
| 10258 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10259 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10260 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10261 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10262 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10263 | ret = str2sockunion (argv[1], &su); |
| 10264 | if (ret < 0) |
| 10265 | { |
| 10266 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10267 | return CMD_WARNING; |
| 10268 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10269 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10270 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10271 | if (! peer) |
| 10272 | return CMD_WARNING; |
| 10273 | |
| 10274 | if (strncmp (argv[0], "m", 1) == 0) |
| 10275 | { |
| 10276 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 10277 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10278 | if (count) |
| 10279 | { |
| 10280 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 10281 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10282 | } |
| 10283 | } |
| 10284 | else |
| 10285 | { |
| 10286 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10287 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10288 | if (count) |
| 10289 | { |
| 10290 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10291 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10292 | } |
| 10293 | } |
| 10294 | |
| 10295 | return CMD_SUCCESS; |
| 10296 | } |
| 10297 | |
| 10298 | |
| 10299 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10300 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10301 | show_bgp_neighbor_received_routes_cmd, |
| 10302 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10303 | SHOW_STR |
| 10304 | BGP_STR |
| 10305 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10306 | "Neighbor to display information about\n" |
| 10307 | "Neighbor to display information about\n" |
| 10308 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10309 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10310 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10311 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 10312 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10313 | SHOW_STR |
| 10314 | BGP_STR |
| 10315 | "Address family\n" |
| 10316 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10317 | "Neighbor to display information about\n" |
| 10318 | "Neighbor to display information about\n" |
| 10319 | "Display the received routes from neighbor\n") |
| 10320 | |
| 10321 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 10322 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 10323 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10324 | SHOW_STR |
| 10325 | BGP_STR |
| 10326 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10327 | "Neighbor to display information about\n" |
| 10328 | "Neighbor to display information about\n" |
| 10329 | "Display information received from a BGP neighbor\n" |
| 10330 | "Display the prefixlist filter\n") |
| 10331 | { |
| 10332 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10333 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10334 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10335 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10336 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10337 | ret = str2sockunion (argv[0], &su); |
| 10338 | if (ret < 0) |
| 10339 | { |
| 10340 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10341 | return CMD_WARNING; |
| 10342 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10343 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10344 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10345 | if (! peer) |
| 10346 | return CMD_WARNING; |
| 10347 | |
| 10348 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10349 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10350 | if (count) |
| 10351 | { |
| 10352 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10353 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10354 | } |
| 10355 | |
| 10356 | return CMD_SUCCESS; |
| 10357 | } |
| 10358 | |
| 10359 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 10360 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 10361 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10362 | SHOW_STR |
| 10363 | BGP_STR |
| 10364 | "Address family\n" |
| 10365 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10366 | "Neighbor to display information about\n" |
| 10367 | "Neighbor to display information about\n" |
| 10368 | "Display information received from a BGP neighbor\n" |
| 10369 | "Display the prefixlist filter\n") |
| 10370 | |
| 10371 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10372 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10373 | ipv6_bgp_neighbor_received_routes_cmd, |
| 10374 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10375 | SHOW_STR |
| 10376 | IPV6_STR |
| 10377 | BGP_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") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10382 | |
| 10383 | /* old command */ |
| 10384 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 10385 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 10386 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10387 | SHOW_STR |
| 10388 | IPV6_STR |
| 10389 | MBGP_STR |
| 10390 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10391 | "Neighbor to display information about\n" |
| 10392 | "Neighbor to display information about\n" |
| 10393 | "Display the received routes from neighbor\n") |
| 10394 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10395 | struct peer *peer; |
| 10396 | |
| 10397 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10398 | if (! peer) |
| 10399 | return CMD_WARNING; |
| 10400 | |
| 10401 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10402 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10403 | |
| 10404 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 10405 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 10406 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10407 | SHOW_STR |
| 10408 | BGP_STR |
| 10409 | "BGP view\n" |
| 10410 | "View name\n" |
| 10411 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10412 | "Neighbor to display information about\n" |
| 10413 | "Neighbor to display information about\n" |
| 10414 | "Display information received from a BGP neighbor\n" |
| 10415 | "Display the prefixlist filter\n") |
| 10416 | { |
| 10417 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10418 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10419 | struct peer *peer; |
| 10420 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10421 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10422 | |
| 10423 | /* BGP structure lookup. */ |
| 10424 | bgp = bgp_lookup_by_name (argv[0]); |
| 10425 | if (bgp == NULL) |
| 10426 | { |
| 10427 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10428 | return CMD_WARNING; |
| 10429 | } |
| 10430 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10431 | ret = str2sockunion (argv[1], &su); |
| 10432 | if (ret < 0) |
| 10433 | { |
| 10434 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10435 | return CMD_WARNING; |
| 10436 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10437 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10438 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10439 | if (! peer) |
| 10440 | return CMD_WARNING; |
| 10441 | |
| 10442 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10443 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10444 | if (count) |
| 10445 | { |
| 10446 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10447 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10448 | } |
| 10449 | |
| 10450 | return CMD_SUCCESS; |
| 10451 | } |
| 10452 | |
| 10453 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 10454 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 10455 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10456 | SHOW_STR |
| 10457 | BGP_STR |
| 10458 | "BGP view\n" |
| 10459 | "View name\n" |
| 10460 | "Address family\n" |
| 10461 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10462 | "Neighbor to display information about\n" |
| 10463 | "Neighbor to display information about\n" |
| 10464 | "Display information received from a BGP neighbor\n" |
| 10465 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10466 | #endif /* HAVE_IPV6 */ |
| 10467 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10468 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10469 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10470 | safi_t safi, enum bgp_show_type type) |
| 10471 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10472 | if (! peer || ! peer->afc[afi][safi]) |
| 10473 | { |
| 10474 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10475 | return CMD_WARNING; |
| 10476 | } |
| 10477 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10478 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10479 | } |
| 10480 | |
| 10481 | DEFUN (show_ip_bgp_neighbor_routes, |
| 10482 | show_ip_bgp_neighbor_routes_cmd, |
| 10483 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10484 | SHOW_STR |
| 10485 | IP_STR |
| 10486 | BGP_STR |
| 10487 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10488 | "Neighbor to display information about\n" |
| 10489 | "Neighbor to display information about\n" |
| 10490 | "Display routes learned from neighbor\n") |
| 10491 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10492 | struct peer *peer; |
| 10493 | |
| 10494 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10495 | if (! peer) |
| 10496 | return CMD_WARNING; |
| 10497 | |
| 10498 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10499 | bgp_show_type_neighbor); |
| 10500 | } |
| 10501 | |
| 10502 | DEFUN (show_ip_bgp_neighbor_flap, |
| 10503 | show_ip_bgp_neighbor_flap_cmd, |
| 10504 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10505 | SHOW_STR |
| 10506 | IP_STR |
| 10507 | BGP_STR |
| 10508 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10509 | "Neighbor to display information about\n" |
| 10510 | "Neighbor to display information about\n" |
| 10511 | "Display flap statistics of the routes learned from neighbor\n") |
| 10512 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10513 | struct peer *peer; |
| 10514 | |
| 10515 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10516 | if (! peer) |
| 10517 | return CMD_WARNING; |
| 10518 | |
| 10519 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10520 | bgp_show_type_flap_neighbor); |
| 10521 | } |
| 10522 | |
| 10523 | DEFUN (show_ip_bgp_neighbor_damp, |
| 10524 | show_ip_bgp_neighbor_damp_cmd, |
| 10525 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10526 | SHOW_STR |
| 10527 | IP_STR |
| 10528 | BGP_STR |
| 10529 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10530 | "Neighbor to display information about\n" |
| 10531 | "Neighbor to display information about\n" |
| 10532 | "Display the dampened routes received from neighbor\n") |
| 10533 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10534 | struct peer *peer; |
| 10535 | |
| 10536 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10537 | if (! peer) |
| 10538 | return CMD_WARNING; |
| 10539 | |
| 10540 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10541 | bgp_show_type_damp_neighbor); |
| 10542 | } |
| 10543 | |
| 10544 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 10545 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 10546 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 10547 | SHOW_STR |
| 10548 | IP_STR |
| 10549 | BGP_STR |
| 10550 | "Address family\n" |
| 10551 | "Address Family modifier\n" |
| 10552 | "Address Family modifier\n" |
| 10553 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10554 | "Neighbor to display information about\n" |
| 10555 | "Neighbor to display information about\n" |
| 10556 | "Display routes learned from neighbor\n") |
| 10557 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10558 | struct peer *peer; |
| 10559 | |
| 10560 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10561 | if (! peer) |
| 10562 | return CMD_WARNING; |
| 10563 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10564 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10565 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10566 | bgp_show_type_neighbor); |
| 10567 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10568 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10569 | bgp_show_type_neighbor); |
| 10570 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10571 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10572 | DEFUN (show_ip_bgp_view_rsclient, |
| 10573 | show_ip_bgp_view_rsclient_cmd, |
| 10574 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 10575 | SHOW_STR |
| 10576 | IP_STR |
| 10577 | BGP_STR |
| 10578 | "BGP view\n" |
| 10579 | "BGP view name\n" |
| 10580 | "Information about Route Server Client\n" |
| 10581 | NEIGHBOR_ADDR_STR) |
| 10582 | { |
| 10583 | struct bgp_table *table; |
| 10584 | struct peer *peer; |
| 10585 | |
| 10586 | if (argc == 2) |
| 10587 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10588 | else |
| 10589 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10590 | |
| 10591 | if (! peer) |
| 10592 | return CMD_WARNING; |
| 10593 | |
| 10594 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10595 | { |
| 10596 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10597 | VTY_NEWLINE); |
| 10598 | return CMD_WARNING; |
| 10599 | } |
| 10600 | |
| 10601 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10602 | PEER_FLAG_RSERVER_CLIENT)) |
| 10603 | { |
| 10604 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10605 | VTY_NEWLINE); |
| 10606 | return CMD_WARNING; |
| 10607 | } |
| 10608 | |
| 10609 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 10610 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10611 | 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] | 10612 | } |
| 10613 | |
| 10614 | ALIAS (show_ip_bgp_view_rsclient, |
| 10615 | show_ip_bgp_rsclient_cmd, |
| 10616 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 10617 | SHOW_STR |
| 10618 | IP_STR |
| 10619 | BGP_STR |
| 10620 | "Information about Route Server Client\n" |
| 10621 | NEIGHBOR_ADDR_STR) |
| 10622 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10623 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 10624 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 10625 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10626 | SHOW_STR |
| 10627 | BGP_STR |
| 10628 | "BGP view\n" |
| 10629 | "BGP view name\n" |
| 10630 | "Address family\n" |
| 10631 | "Address Family modifier\n" |
| 10632 | "Address Family modifier\n" |
| 10633 | "Information about Route Server Client\n" |
| 10634 | NEIGHBOR_ADDR_STR) |
| 10635 | { |
| 10636 | struct bgp_table *table; |
| 10637 | struct peer *peer; |
| 10638 | safi_t safi; |
| 10639 | |
| 10640 | if (argc == 3) { |
| 10641 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10642 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10643 | } else { |
| 10644 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10645 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10646 | } |
| 10647 | |
| 10648 | if (! peer) |
| 10649 | return CMD_WARNING; |
| 10650 | |
| 10651 | if (! peer->afc[AFI_IP][safi]) |
| 10652 | { |
| 10653 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10654 | VTY_NEWLINE); |
| 10655 | return CMD_WARNING; |
| 10656 | } |
| 10657 | |
| 10658 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10659 | PEER_FLAG_RSERVER_CLIENT)) |
| 10660 | { |
| 10661 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10662 | VTY_NEWLINE); |
| 10663 | return CMD_WARNING; |
| 10664 | } |
| 10665 | |
| 10666 | table = peer->rib[AFI_IP][safi]; |
| 10667 | |
| 10668 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 10669 | } |
| 10670 | |
| 10671 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 10672 | show_bgp_ipv4_safi_rsclient_cmd, |
| 10673 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10674 | SHOW_STR |
| 10675 | BGP_STR |
| 10676 | "Address family\n" |
| 10677 | "Address Family modifier\n" |
| 10678 | "Address Family modifier\n" |
| 10679 | "Information about Route Server Client\n" |
| 10680 | NEIGHBOR_ADDR_STR) |
| 10681 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10682 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 10683 | show_ip_bgp_view_rsclient_route_cmd, |
Michael Lambert | a8bf6f5 | 2008-09-24 17:23:11 +0100 | [diff] [blame] | 10684 | "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] | 10685 | SHOW_STR |
| 10686 | IP_STR |
| 10687 | BGP_STR |
| 10688 | "BGP view\n" |
| 10689 | "BGP view name\n" |
| 10690 | "Information about Route Server Client\n" |
| 10691 | NEIGHBOR_ADDR_STR |
| 10692 | "Network in the BGP routing table to display\n") |
| 10693 | { |
| 10694 | struct bgp *bgp; |
| 10695 | struct peer *peer; |
| 10696 | |
| 10697 | /* BGP structure lookup. */ |
| 10698 | if (argc == 3) |
| 10699 | { |
| 10700 | bgp = bgp_lookup_by_name (argv[0]); |
| 10701 | if (bgp == NULL) |
| 10702 | { |
| 10703 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10704 | return CMD_WARNING; |
| 10705 | } |
| 10706 | } |
| 10707 | else |
| 10708 | { |
| 10709 | bgp = bgp_get_default (); |
| 10710 | if (bgp == NULL) |
| 10711 | { |
| 10712 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10713 | return CMD_WARNING; |
| 10714 | } |
| 10715 | } |
| 10716 | |
| 10717 | if (argc == 3) |
| 10718 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10719 | else |
| 10720 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10721 | |
| 10722 | if (! peer) |
| 10723 | return CMD_WARNING; |
| 10724 | |
| 10725 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10726 | { |
| 10727 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10728 | VTY_NEWLINE); |
| 10729 | return CMD_WARNING; |
| 10730 | } |
| 10731 | |
| 10732 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10733 | PEER_FLAG_RSERVER_CLIENT)) |
| 10734 | { |
| 10735 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10736 | VTY_NEWLINE); |
| 10737 | return CMD_WARNING; |
| 10738 | } |
| 10739 | |
| 10740 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10741 | (argc == 3) ? argv[2] : argv[1], |
| 10742 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 10743 | } |
| 10744 | |
| 10745 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 10746 | show_ip_bgp_rsclient_route_cmd, |
| 10747 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10748 | SHOW_STR |
| 10749 | IP_STR |
| 10750 | BGP_STR |
| 10751 | "Information about Route Server Client\n" |
| 10752 | NEIGHBOR_ADDR_STR |
| 10753 | "Network in the BGP routing table to display\n") |
| 10754 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10755 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 10756 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 10757 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10758 | SHOW_STR |
| 10759 | BGP_STR |
| 10760 | "BGP view\n" |
| 10761 | "BGP view name\n" |
| 10762 | "Address family\n" |
| 10763 | "Address Family modifier\n" |
| 10764 | "Address Family modifier\n" |
| 10765 | "Information about Route Server Client\n" |
| 10766 | NEIGHBOR_ADDR_STR |
| 10767 | "Network in the BGP routing table to display\n") |
| 10768 | { |
| 10769 | struct bgp *bgp; |
| 10770 | struct peer *peer; |
| 10771 | safi_t safi; |
| 10772 | |
| 10773 | /* BGP structure lookup. */ |
| 10774 | if (argc == 4) |
| 10775 | { |
| 10776 | bgp = bgp_lookup_by_name (argv[0]); |
| 10777 | if (bgp == NULL) |
| 10778 | { |
| 10779 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10780 | return CMD_WARNING; |
| 10781 | } |
| 10782 | } |
| 10783 | else |
| 10784 | { |
| 10785 | bgp = bgp_get_default (); |
| 10786 | if (bgp == NULL) |
| 10787 | { |
| 10788 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10789 | return CMD_WARNING; |
| 10790 | } |
| 10791 | } |
| 10792 | |
| 10793 | if (argc == 4) { |
| 10794 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10795 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10796 | } else { |
| 10797 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10798 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10799 | } |
| 10800 | |
| 10801 | if (! peer) |
| 10802 | return CMD_WARNING; |
| 10803 | |
| 10804 | if (! peer->afc[AFI_IP][safi]) |
| 10805 | { |
| 10806 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10807 | VTY_NEWLINE); |
| 10808 | return CMD_WARNING; |
| 10809 | } |
| 10810 | |
| 10811 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10812 | PEER_FLAG_RSERVER_CLIENT)) |
| 10813 | { |
| 10814 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10815 | VTY_NEWLINE); |
| 10816 | return CMD_WARNING; |
| 10817 | } |
| 10818 | |
| 10819 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10820 | (argc == 4) ? argv[3] : argv[2], |
| 10821 | AFI_IP, safi, NULL, 0); |
| 10822 | } |
| 10823 | |
| 10824 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 10825 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 10826 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10827 | SHOW_STR |
| 10828 | BGP_STR |
| 10829 | "Address family\n" |
| 10830 | "Address Family modifier\n" |
| 10831 | "Address Family modifier\n" |
| 10832 | "Information about Route Server Client\n" |
| 10833 | NEIGHBOR_ADDR_STR |
| 10834 | "Network in the BGP routing table to display\n") |
| 10835 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10836 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 10837 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 10838 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10839 | SHOW_STR |
| 10840 | IP_STR |
| 10841 | BGP_STR |
| 10842 | "BGP view\n" |
| 10843 | "BGP view name\n" |
| 10844 | "Information about Route Server Client\n" |
| 10845 | NEIGHBOR_ADDR_STR |
| 10846 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10847 | { |
| 10848 | struct bgp *bgp; |
| 10849 | struct peer *peer; |
| 10850 | |
| 10851 | /* BGP structure lookup. */ |
| 10852 | if (argc == 3) |
| 10853 | { |
| 10854 | bgp = bgp_lookup_by_name (argv[0]); |
| 10855 | if (bgp == NULL) |
| 10856 | { |
| 10857 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10858 | return CMD_WARNING; |
| 10859 | } |
| 10860 | } |
| 10861 | else |
| 10862 | { |
| 10863 | bgp = bgp_get_default (); |
| 10864 | if (bgp == NULL) |
| 10865 | { |
| 10866 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10867 | return CMD_WARNING; |
| 10868 | } |
| 10869 | } |
| 10870 | |
| 10871 | if (argc == 3) |
| 10872 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10873 | else |
| 10874 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10875 | |
| 10876 | if (! peer) |
| 10877 | return CMD_WARNING; |
| 10878 | |
| 10879 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10880 | { |
| 10881 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10882 | VTY_NEWLINE); |
| 10883 | return CMD_WARNING; |
| 10884 | } |
| 10885 | |
| 10886 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10887 | PEER_FLAG_RSERVER_CLIENT)) |
| 10888 | { |
| 10889 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10890 | VTY_NEWLINE); |
| 10891 | return CMD_WARNING; |
| 10892 | } |
| 10893 | |
| 10894 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10895 | (argc == 3) ? argv[2] : argv[1], |
| 10896 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 10897 | } |
| 10898 | |
| 10899 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 10900 | show_ip_bgp_rsclient_prefix_cmd, |
| 10901 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10902 | SHOW_STR |
| 10903 | IP_STR |
| 10904 | BGP_STR |
| 10905 | "Information about Route Server Client\n" |
| 10906 | NEIGHBOR_ADDR_STR |
| 10907 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10908 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10909 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 10910 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 10911 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10912 | SHOW_STR |
| 10913 | BGP_STR |
| 10914 | "BGP view\n" |
| 10915 | "BGP view name\n" |
| 10916 | "Address family\n" |
| 10917 | "Address Family modifier\n" |
| 10918 | "Address Family modifier\n" |
| 10919 | "Information about Route Server Client\n" |
| 10920 | NEIGHBOR_ADDR_STR |
| 10921 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10922 | { |
| 10923 | struct bgp *bgp; |
| 10924 | struct peer *peer; |
| 10925 | safi_t safi; |
| 10926 | |
| 10927 | /* BGP structure lookup. */ |
| 10928 | if (argc == 4) |
| 10929 | { |
| 10930 | bgp = bgp_lookup_by_name (argv[0]); |
| 10931 | if (bgp == NULL) |
| 10932 | { |
| 10933 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10934 | return CMD_WARNING; |
| 10935 | } |
| 10936 | } |
| 10937 | else |
| 10938 | { |
| 10939 | bgp = bgp_get_default (); |
| 10940 | if (bgp == NULL) |
| 10941 | { |
| 10942 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10943 | return CMD_WARNING; |
| 10944 | } |
| 10945 | } |
| 10946 | |
| 10947 | if (argc == 4) { |
| 10948 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10949 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10950 | } else { |
| 10951 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10952 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10953 | } |
| 10954 | |
| 10955 | if (! peer) |
| 10956 | return CMD_WARNING; |
| 10957 | |
| 10958 | if (! peer->afc[AFI_IP][safi]) |
| 10959 | { |
| 10960 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10961 | VTY_NEWLINE); |
| 10962 | return CMD_WARNING; |
| 10963 | } |
| 10964 | |
| 10965 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10966 | PEER_FLAG_RSERVER_CLIENT)) |
| 10967 | { |
| 10968 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10969 | VTY_NEWLINE); |
| 10970 | return CMD_WARNING; |
| 10971 | } |
| 10972 | |
| 10973 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10974 | (argc == 4) ? argv[3] : argv[2], |
| 10975 | AFI_IP, safi, NULL, 1); |
| 10976 | } |
| 10977 | |
| 10978 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 10979 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 10980 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10981 | SHOW_STR |
| 10982 | BGP_STR |
| 10983 | "Address family\n" |
| 10984 | "Address Family modifier\n" |
| 10985 | "Address Family modifier\n" |
| 10986 | "Information about Route Server Client\n" |
| 10987 | NEIGHBOR_ADDR_STR |
| 10988 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10989 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10990 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10991 | DEFUN (show_bgp_view_neighbor_routes, |
| 10992 | show_bgp_view_neighbor_routes_cmd, |
| 10993 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 10994 | SHOW_STR |
| 10995 | BGP_STR |
| 10996 | "BGP view\n" |
| 10997 | "BGP view name\n" |
| 10998 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10999 | "Neighbor to display information about\n" |
| 11000 | "Neighbor to display information about\n" |
| 11001 | "Display routes learned from neighbor\n") |
| 11002 | { |
| 11003 | struct peer *peer; |
| 11004 | |
| 11005 | if (argc == 2) |
| 11006 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11007 | else |
| 11008 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11009 | |
| 11010 | if (! peer) |
| 11011 | return CMD_WARNING; |
| 11012 | |
| 11013 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11014 | bgp_show_type_neighbor); |
| 11015 | } |
| 11016 | |
| 11017 | ALIAS (show_bgp_view_neighbor_routes, |
| 11018 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 11019 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11020 | SHOW_STR |
| 11021 | BGP_STR |
| 11022 | "BGP view\n" |
| 11023 | "BGP view name\n" |
| 11024 | "Address family\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 routes learned from neighbor\n") |
| 11029 | |
| 11030 | DEFUN (show_bgp_view_neighbor_damp, |
| 11031 | show_bgp_view_neighbor_damp_cmd, |
| 11032 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11033 | SHOW_STR |
| 11034 | BGP_STR |
| 11035 | "BGP view\n" |
| 11036 | "BGP view name\n" |
| 11037 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11038 | "Neighbor to display information about\n" |
| 11039 | "Neighbor to display information about\n" |
| 11040 | "Display the dampened routes received from neighbor\n") |
| 11041 | { |
| 11042 | struct peer *peer; |
| 11043 | |
| 11044 | if (argc == 2) |
| 11045 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11046 | else |
| 11047 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11048 | |
| 11049 | if (! peer) |
| 11050 | return CMD_WARNING; |
| 11051 | |
| 11052 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11053 | bgp_show_type_damp_neighbor); |
| 11054 | } |
| 11055 | |
| 11056 | ALIAS (show_bgp_view_neighbor_damp, |
| 11057 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 11058 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11059 | SHOW_STR |
| 11060 | BGP_STR |
| 11061 | "BGP view\n" |
| 11062 | "BGP view name\n" |
| 11063 | "Address family\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 the dampened routes received from neighbor\n") |
| 11068 | |
| 11069 | DEFUN (show_bgp_view_neighbor_flap, |
| 11070 | show_bgp_view_neighbor_flap_cmd, |
| 11071 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11072 | SHOW_STR |
| 11073 | BGP_STR |
| 11074 | "BGP view\n" |
| 11075 | "BGP view name\n" |
| 11076 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11077 | "Neighbor to display information about\n" |
| 11078 | "Neighbor to display information about\n" |
| 11079 | "Display flap statistics of the routes learned from neighbor\n") |
| 11080 | { |
| 11081 | struct peer *peer; |
| 11082 | |
| 11083 | if (argc == 2) |
| 11084 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11085 | else |
| 11086 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11087 | |
| 11088 | if (! peer) |
| 11089 | return CMD_WARNING; |
| 11090 | |
| 11091 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11092 | bgp_show_type_flap_neighbor); |
| 11093 | } |
| 11094 | |
| 11095 | ALIAS (show_bgp_view_neighbor_flap, |
| 11096 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 11097 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11098 | SHOW_STR |
| 11099 | BGP_STR |
| 11100 | "BGP view\n" |
| 11101 | "BGP view name\n" |
| 11102 | "Address family\n" |
| 11103 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11104 | "Neighbor to display information about\n" |
| 11105 | "Neighbor to display information about\n" |
| 11106 | "Display flap statistics of the routes learned from neighbor\n") |
| 11107 | |
| 11108 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11109 | show_bgp_neighbor_routes_cmd, |
| 11110 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11111 | SHOW_STR |
| 11112 | BGP_STR |
| 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") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11117 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11118 | |
| 11119 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11120 | show_bgp_ipv6_neighbor_routes_cmd, |
| 11121 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11122 | SHOW_STR |
| 11123 | BGP_STR |
| 11124 | "Address family\n" |
| 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") |
| 11129 | |
| 11130 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11131 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11132 | ipv6_bgp_neighbor_routes_cmd, |
| 11133 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11134 | SHOW_STR |
| 11135 | IPV6_STR |
| 11136 | BGP_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") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11141 | |
| 11142 | /* old command */ |
| 11143 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 11144 | ipv6_mbgp_neighbor_routes_cmd, |
| 11145 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11146 | SHOW_STR |
| 11147 | IPV6_STR |
| 11148 | MBGP_STR |
| 11149 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11150 | "Neighbor to display information about\n" |
| 11151 | "Neighbor to display information about\n" |
| 11152 | "Display routes learned from neighbor\n") |
| 11153 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11154 | struct peer *peer; |
| 11155 | |
| 11156 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11157 | if (! peer) |
| 11158 | return CMD_WARNING; |
| 11159 | |
| 11160 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11161 | bgp_show_type_neighbor); |
| 11162 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11163 | |
| 11164 | ALIAS (show_bgp_view_neighbor_flap, |
| 11165 | show_bgp_neighbor_flap_cmd, |
| 11166 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11167 | SHOW_STR |
| 11168 | BGP_STR |
| 11169 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11170 | "Neighbor to display information about\n" |
| 11171 | "Neighbor to display information about\n" |
| 11172 | "Display flap statistics of the routes learned from neighbor\n") |
| 11173 | |
| 11174 | ALIAS (show_bgp_view_neighbor_flap, |
| 11175 | show_bgp_ipv6_neighbor_flap_cmd, |
| 11176 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11177 | SHOW_STR |
| 11178 | BGP_STR |
| 11179 | "Address family\n" |
| 11180 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11181 | "Neighbor to display information about\n" |
| 11182 | "Neighbor to display information about\n" |
| 11183 | "Display flap statistics of the routes learned from neighbor\n") |
| 11184 | |
| 11185 | ALIAS (show_bgp_view_neighbor_damp, |
| 11186 | show_bgp_neighbor_damp_cmd, |
| 11187 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11188 | SHOW_STR |
| 11189 | BGP_STR |
| 11190 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11191 | "Neighbor to display information about\n" |
| 11192 | "Neighbor to display information about\n" |
| 11193 | "Display the dampened routes received from neighbor\n") |
| 11194 | |
| 11195 | ALIAS (show_bgp_view_neighbor_damp, |
| 11196 | show_bgp_ipv6_neighbor_damp_cmd, |
| 11197 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11198 | SHOW_STR |
| 11199 | BGP_STR |
| 11200 | "Address family\n" |
| 11201 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11202 | "Neighbor to display information about\n" |
| 11203 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 11204 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11205 | |
| 11206 | DEFUN (show_bgp_view_rsclient, |
| 11207 | show_bgp_view_rsclient_cmd, |
| 11208 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 11209 | SHOW_STR |
| 11210 | BGP_STR |
| 11211 | "BGP view\n" |
| 11212 | "BGP view name\n" |
| 11213 | "Information about Route Server Client\n" |
| 11214 | NEIGHBOR_ADDR_STR) |
| 11215 | { |
| 11216 | struct bgp_table *table; |
| 11217 | struct peer *peer; |
| 11218 | |
| 11219 | if (argc == 2) |
| 11220 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11221 | else |
| 11222 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11223 | |
| 11224 | if (! peer) |
| 11225 | return CMD_WARNING; |
| 11226 | |
| 11227 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11228 | { |
| 11229 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11230 | VTY_NEWLINE); |
| 11231 | return CMD_WARNING; |
| 11232 | } |
| 11233 | |
| 11234 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11235 | PEER_FLAG_RSERVER_CLIENT)) |
| 11236 | { |
| 11237 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11238 | VTY_NEWLINE); |
| 11239 | return CMD_WARNING; |
| 11240 | } |
| 11241 | |
| 11242 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 11243 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11244 | 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] | 11245 | } |
| 11246 | |
| 11247 | ALIAS (show_bgp_view_rsclient, |
| 11248 | show_bgp_rsclient_cmd, |
| 11249 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 11250 | SHOW_STR |
| 11251 | BGP_STR |
| 11252 | "Information about Route Server Client\n" |
| 11253 | NEIGHBOR_ADDR_STR) |
| 11254 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11255 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 11256 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 11257 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11258 | SHOW_STR |
| 11259 | BGP_STR |
| 11260 | "BGP view\n" |
| 11261 | "BGP view name\n" |
| 11262 | "Address family\n" |
| 11263 | "Address Family modifier\n" |
| 11264 | "Address Family modifier\n" |
| 11265 | "Information about Route Server Client\n" |
| 11266 | NEIGHBOR_ADDR_STR) |
| 11267 | { |
| 11268 | struct bgp_table *table; |
| 11269 | struct peer *peer; |
| 11270 | safi_t safi; |
| 11271 | |
| 11272 | if (argc == 3) { |
| 11273 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11274 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11275 | } else { |
| 11276 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11277 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11278 | } |
| 11279 | |
| 11280 | if (! peer) |
| 11281 | return CMD_WARNING; |
| 11282 | |
| 11283 | if (! peer->afc[AFI_IP6][safi]) |
| 11284 | { |
| 11285 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11286 | VTY_NEWLINE); |
| 11287 | return CMD_WARNING; |
| 11288 | } |
| 11289 | |
| 11290 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11291 | PEER_FLAG_RSERVER_CLIENT)) |
| 11292 | { |
| 11293 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11294 | VTY_NEWLINE); |
| 11295 | return CMD_WARNING; |
| 11296 | } |
| 11297 | |
| 11298 | table = peer->rib[AFI_IP6][safi]; |
| 11299 | |
| 11300 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 11301 | } |
| 11302 | |
| 11303 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 11304 | show_bgp_ipv6_safi_rsclient_cmd, |
| 11305 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11306 | SHOW_STR |
| 11307 | BGP_STR |
| 11308 | "Address family\n" |
| 11309 | "Address Family modifier\n" |
| 11310 | "Address Family modifier\n" |
| 11311 | "Information about Route Server Client\n" |
| 11312 | NEIGHBOR_ADDR_STR) |
| 11313 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11314 | DEFUN (show_bgp_view_rsclient_route, |
| 11315 | show_bgp_view_rsclient_route_cmd, |
| 11316 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11317 | SHOW_STR |
| 11318 | BGP_STR |
| 11319 | "BGP view\n" |
| 11320 | "BGP view name\n" |
| 11321 | "Information about Route Server Client\n" |
| 11322 | NEIGHBOR_ADDR_STR |
| 11323 | "Network in the BGP routing table to display\n") |
| 11324 | { |
| 11325 | struct bgp *bgp; |
| 11326 | struct peer *peer; |
| 11327 | |
| 11328 | /* BGP structure lookup. */ |
| 11329 | if (argc == 3) |
| 11330 | { |
| 11331 | bgp = bgp_lookup_by_name (argv[0]); |
| 11332 | if (bgp == NULL) |
| 11333 | { |
| 11334 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11335 | return CMD_WARNING; |
| 11336 | } |
| 11337 | } |
| 11338 | else |
| 11339 | { |
| 11340 | bgp = bgp_get_default (); |
| 11341 | if (bgp == NULL) |
| 11342 | { |
| 11343 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11344 | return CMD_WARNING; |
| 11345 | } |
| 11346 | } |
| 11347 | |
| 11348 | if (argc == 3) |
| 11349 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11350 | else |
| 11351 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11352 | |
| 11353 | if (! peer) |
| 11354 | return CMD_WARNING; |
| 11355 | |
| 11356 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11357 | { |
| 11358 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11359 | VTY_NEWLINE); |
| 11360 | return CMD_WARNING; |
| 11361 | } |
| 11362 | |
| 11363 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11364 | PEER_FLAG_RSERVER_CLIENT)) |
| 11365 | { |
| 11366 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11367 | VTY_NEWLINE); |
| 11368 | return CMD_WARNING; |
| 11369 | } |
| 11370 | |
| 11371 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11372 | (argc == 3) ? argv[2] : argv[1], |
| 11373 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 11374 | } |
| 11375 | |
| 11376 | ALIAS (show_bgp_view_rsclient_route, |
| 11377 | show_bgp_rsclient_route_cmd, |
| 11378 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11379 | SHOW_STR |
| 11380 | BGP_STR |
| 11381 | "Information about Route Server Client\n" |
| 11382 | NEIGHBOR_ADDR_STR |
| 11383 | "Network in the BGP routing table to display\n") |
| 11384 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11385 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 11386 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 11387 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11388 | SHOW_STR |
| 11389 | BGP_STR |
| 11390 | "BGP view\n" |
| 11391 | "BGP view name\n" |
| 11392 | "Address family\n" |
| 11393 | "Address Family modifier\n" |
| 11394 | "Address Family modifier\n" |
| 11395 | "Information about Route Server Client\n" |
| 11396 | NEIGHBOR_ADDR_STR |
| 11397 | "Network in the BGP routing table to display\n") |
| 11398 | { |
| 11399 | struct bgp *bgp; |
| 11400 | struct peer *peer; |
| 11401 | safi_t safi; |
| 11402 | |
| 11403 | /* BGP structure lookup. */ |
| 11404 | if (argc == 4) |
| 11405 | { |
| 11406 | bgp = bgp_lookup_by_name (argv[0]); |
| 11407 | if (bgp == NULL) |
| 11408 | { |
| 11409 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11410 | return CMD_WARNING; |
| 11411 | } |
| 11412 | } |
| 11413 | else |
| 11414 | { |
| 11415 | bgp = bgp_get_default (); |
| 11416 | if (bgp == NULL) |
| 11417 | { |
| 11418 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11419 | return CMD_WARNING; |
| 11420 | } |
| 11421 | } |
| 11422 | |
| 11423 | if (argc == 4) { |
| 11424 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11425 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11426 | } else { |
| 11427 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11428 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11429 | } |
| 11430 | |
| 11431 | if (! peer) |
| 11432 | return CMD_WARNING; |
| 11433 | |
| 11434 | if (! peer->afc[AFI_IP6][safi]) |
| 11435 | { |
| 11436 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11437 | VTY_NEWLINE); |
| 11438 | return CMD_WARNING; |
| 11439 | } |
| 11440 | |
| 11441 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11442 | PEER_FLAG_RSERVER_CLIENT)) |
| 11443 | { |
| 11444 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11445 | VTY_NEWLINE); |
| 11446 | return CMD_WARNING; |
| 11447 | } |
| 11448 | |
| 11449 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11450 | (argc == 4) ? argv[3] : argv[2], |
| 11451 | AFI_IP6, safi, NULL, 0); |
| 11452 | } |
| 11453 | |
| 11454 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 11455 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 11456 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11457 | SHOW_STR |
| 11458 | BGP_STR |
| 11459 | "Address family\n" |
| 11460 | "Address Family modifier\n" |
| 11461 | "Address Family modifier\n" |
| 11462 | "Information about Route Server Client\n" |
| 11463 | NEIGHBOR_ADDR_STR |
| 11464 | "Network in the BGP routing table to display\n") |
| 11465 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11466 | DEFUN (show_bgp_view_rsclient_prefix, |
| 11467 | show_bgp_view_rsclient_prefix_cmd, |
| 11468 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11469 | SHOW_STR |
| 11470 | BGP_STR |
| 11471 | "BGP view\n" |
| 11472 | "BGP view name\n" |
| 11473 | "Information about Route Server Client\n" |
| 11474 | NEIGHBOR_ADDR_STR |
| 11475 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11476 | { |
| 11477 | struct bgp *bgp; |
| 11478 | struct peer *peer; |
| 11479 | |
| 11480 | /* BGP structure lookup. */ |
| 11481 | if (argc == 3) |
| 11482 | { |
| 11483 | bgp = bgp_lookup_by_name (argv[0]); |
| 11484 | if (bgp == NULL) |
| 11485 | { |
| 11486 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11487 | return CMD_WARNING; |
| 11488 | } |
| 11489 | } |
| 11490 | else |
| 11491 | { |
| 11492 | bgp = bgp_get_default (); |
| 11493 | if (bgp == NULL) |
| 11494 | { |
| 11495 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11496 | return CMD_WARNING; |
| 11497 | } |
| 11498 | } |
| 11499 | |
| 11500 | if (argc == 3) |
| 11501 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11502 | else |
| 11503 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11504 | |
| 11505 | if (! peer) |
| 11506 | return CMD_WARNING; |
| 11507 | |
| 11508 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11509 | { |
| 11510 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11511 | VTY_NEWLINE); |
| 11512 | return CMD_WARNING; |
| 11513 | } |
| 11514 | |
| 11515 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11516 | PEER_FLAG_RSERVER_CLIENT)) |
| 11517 | { |
| 11518 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11519 | VTY_NEWLINE); |
| 11520 | return CMD_WARNING; |
| 11521 | } |
| 11522 | |
| 11523 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11524 | (argc == 3) ? argv[2] : argv[1], |
| 11525 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 11526 | } |
| 11527 | |
| 11528 | ALIAS (show_bgp_view_rsclient_prefix, |
| 11529 | show_bgp_rsclient_prefix_cmd, |
| 11530 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11531 | SHOW_STR |
| 11532 | BGP_STR |
| 11533 | "Information about Route Server Client\n" |
| 11534 | NEIGHBOR_ADDR_STR |
| 11535 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11536 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11537 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11538 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 11539 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11540 | SHOW_STR |
| 11541 | BGP_STR |
| 11542 | "BGP view\n" |
| 11543 | "BGP view name\n" |
| 11544 | "Address family\n" |
| 11545 | "Address Family modifier\n" |
| 11546 | "Address Family modifier\n" |
| 11547 | "Information about Route Server Client\n" |
| 11548 | NEIGHBOR_ADDR_STR |
| 11549 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11550 | { |
| 11551 | struct bgp *bgp; |
| 11552 | struct peer *peer; |
| 11553 | safi_t safi; |
| 11554 | |
| 11555 | /* BGP structure lookup. */ |
| 11556 | if (argc == 4) |
| 11557 | { |
| 11558 | bgp = bgp_lookup_by_name (argv[0]); |
| 11559 | if (bgp == NULL) |
| 11560 | { |
| 11561 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11562 | return CMD_WARNING; |
| 11563 | } |
| 11564 | } |
| 11565 | else |
| 11566 | { |
| 11567 | bgp = bgp_get_default (); |
| 11568 | if (bgp == NULL) |
| 11569 | { |
| 11570 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11571 | return CMD_WARNING; |
| 11572 | } |
| 11573 | } |
| 11574 | |
| 11575 | if (argc == 4) { |
| 11576 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11577 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11578 | } else { |
| 11579 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11580 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11581 | } |
| 11582 | |
| 11583 | if (! peer) |
| 11584 | return CMD_WARNING; |
| 11585 | |
| 11586 | if (! peer->afc[AFI_IP6][safi]) |
| 11587 | { |
| 11588 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11589 | VTY_NEWLINE); |
| 11590 | return CMD_WARNING; |
| 11591 | } |
| 11592 | |
| 11593 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11594 | PEER_FLAG_RSERVER_CLIENT)) |
| 11595 | { |
| 11596 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11597 | VTY_NEWLINE); |
| 11598 | return CMD_WARNING; |
| 11599 | } |
| 11600 | |
| 11601 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11602 | (argc == 4) ? argv[3] : argv[2], |
| 11603 | AFI_IP6, safi, NULL, 1); |
| 11604 | } |
| 11605 | |
| 11606 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11607 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 11608 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11609 | SHOW_STR |
| 11610 | BGP_STR |
| 11611 | "Address family\n" |
| 11612 | "Address Family modifier\n" |
| 11613 | "Address Family modifier\n" |
| 11614 | "Information about Route Server Client\n" |
| 11615 | NEIGHBOR_ADDR_STR |
| 11616 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11617 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11618 | #endif /* HAVE_IPV6 */ |
| 11619 | |
| 11620 | struct bgp_table *bgp_distance_table; |
| 11621 | |
| 11622 | struct bgp_distance |
| 11623 | { |
| 11624 | /* Distance value for the IP source prefix. */ |
| 11625 | u_char distance; |
| 11626 | |
| 11627 | /* Name of the access-list to be matched. */ |
| 11628 | char *access_list; |
| 11629 | }; |
| 11630 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11631 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 11632 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11633 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 11634 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11635 | } |
| 11636 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11637 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11638 | bgp_distance_free (struct bgp_distance *bdistance) |
| 11639 | { |
| 11640 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 11641 | } |
| 11642 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11643 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11644 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 11645 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11646 | { |
| 11647 | int ret; |
| 11648 | struct prefix_ipv4 p; |
| 11649 | u_char distance; |
| 11650 | struct bgp_node *rn; |
| 11651 | struct bgp_distance *bdistance; |
| 11652 | |
| 11653 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11654 | if (ret == 0) |
| 11655 | { |
| 11656 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11657 | return CMD_WARNING; |
| 11658 | } |
| 11659 | |
| 11660 | distance = atoi (distance_str); |
| 11661 | |
| 11662 | /* Get BGP distance node. */ |
| 11663 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 11664 | if (rn->info) |
| 11665 | { |
| 11666 | bdistance = rn->info; |
| 11667 | bgp_unlock_node (rn); |
| 11668 | } |
| 11669 | else |
| 11670 | { |
| 11671 | bdistance = bgp_distance_new (); |
| 11672 | rn->info = bdistance; |
| 11673 | } |
| 11674 | |
| 11675 | /* Set distance value. */ |
| 11676 | bdistance->distance = distance; |
| 11677 | |
| 11678 | /* Reset access-list configuration. */ |
| 11679 | if (bdistance->access_list) |
| 11680 | { |
| 11681 | free (bdistance->access_list); |
| 11682 | bdistance->access_list = NULL; |
| 11683 | } |
| 11684 | if (access_list_str) |
| 11685 | bdistance->access_list = strdup (access_list_str); |
| 11686 | |
| 11687 | return CMD_SUCCESS; |
| 11688 | } |
| 11689 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11690 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11691 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 11692 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11693 | { |
| 11694 | int ret; |
| 11695 | struct prefix_ipv4 p; |
| 11696 | u_char distance; |
| 11697 | struct bgp_node *rn; |
| 11698 | struct bgp_distance *bdistance; |
| 11699 | |
| 11700 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11701 | if (ret == 0) |
| 11702 | { |
| 11703 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11704 | return CMD_WARNING; |
| 11705 | } |
| 11706 | |
| 11707 | distance = atoi (distance_str); |
| 11708 | |
| 11709 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 11710 | if (! rn) |
| 11711 | { |
| 11712 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 11713 | return CMD_WARNING; |
| 11714 | } |
| 11715 | |
| 11716 | bdistance = rn->info; |
| 11717 | |
| 11718 | if (bdistance->access_list) |
| 11719 | free (bdistance->access_list); |
| 11720 | bgp_distance_free (bdistance); |
| 11721 | |
| 11722 | rn->info = NULL; |
| 11723 | bgp_unlock_node (rn); |
| 11724 | bgp_unlock_node (rn); |
| 11725 | |
| 11726 | return CMD_SUCCESS; |
| 11727 | } |
| 11728 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11729 | /* Apply BGP information to distance method. */ |
| 11730 | u_char |
| 11731 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 11732 | { |
| 11733 | struct bgp_node *rn; |
| 11734 | struct prefix_ipv4 q; |
| 11735 | struct peer *peer; |
| 11736 | struct bgp_distance *bdistance; |
| 11737 | struct access_list *alist; |
| 11738 | struct bgp_static *bgp_static; |
| 11739 | |
| 11740 | if (! bgp) |
| 11741 | return 0; |
| 11742 | |
| 11743 | if (p->family != AF_INET) |
| 11744 | return 0; |
| 11745 | |
| 11746 | peer = rinfo->peer; |
| 11747 | |
| 11748 | if (peer->su.sa.sa_family != AF_INET) |
| 11749 | return 0; |
| 11750 | |
| 11751 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 11752 | q.family = AF_INET; |
| 11753 | q.prefix = peer->su.sin.sin_addr; |
| 11754 | q.prefixlen = IPV4_MAX_BITLEN; |
| 11755 | |
| 11756 | /* Check source address. */ |
| 11757 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 11758 | if (rn) |
| 11759 | { |
| 11760 | bdistance = rn->info; |
| 11761 | bgp_unlock_node (rn); |
| 11762 | |
| 11763 | if (bdistance->access_list) |
| 11764 | { |
| 11765 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 11766 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 11767 | return bdistance->distance; |
| 11768 | } |
| 11769 | else |
| 11770 | return bdistance->distance; |
| 11771 | } |
| 11772 | |
| 11773 | /* Backdoor check. */ |
| 11774 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 11775 | if (rn) |
| 11776 | { |
| 11777 | bgp_static = rn->info; |
| 11778 | bgp_unlock_node (rn); |
| 11779 | |
| 11780 | if (bgp_static->backdoor) |
| 11781 | { |
| 11782 | if (bgp->distance_local) |
| 11783 | return bgp->distance_local; |
| 11784 | else |
| 11785 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11786 | } |
| 11787 | } |
| 11788 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 11789 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11790 | { |
| 11791 | if (bgp->distance_ebgp) |
| 11792 | return bgp->distance_ebgp; |
| 11793 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 11794 | } |
| 11795 | else |
| 11796 | { |
| 11797 | if (bgp->distance_ibgp) |
| 11798 | return bgp->distance_ibgp; |
| 11799 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11800 | } |
| 11801 | } |
| 11802 | |
| 11803 | DEFUN (bgp_distance, |
| 11804 | bgp_distance_cmd, |
| 11805 | "distance bgp <1-255> <1-255> <1-255>", |
| 11806 | "Define an administrative distance\n" |
| 11807 | "BGP distance\n" |
| 11808 | "Distance for routes external to the AS\n" |
| 11809 | "Distance for routes internal to the AS\n" |
| 11810 | "Distance for local routes\n") |
| 11811 | { |
| 11812 | struct bgp *bgp; |
| 11813 | |
| 11814 | bgp = vty->index; |
| 11815 | |
| 11816 | bgp->distance_ebgp = atoi (argv[0]); |
| 11817 | bgp->distance_ibgp = atoi (argv[1]); |
| 11818 | bgp->distance_local = atoi (argv[2]); |
| 11819 | return CMD_SUCCESS; |
| 11820 | } |
| 11821 | |
| 11822 | DEFUN (no_bgp_distance, |
| 11823 | no_bgp_distance_cmd, |
| 11824 | "no distance bgp <1-255> <1-255> <1-255>", |
| 11825 | NO_STR |
| 11826 | "Define an administrative distance\n" |
| 11827 | "BGP distance\n" |
| 11828 | "Distance for routes external to the AS\n" |
| 11829 | "Distance for routes internal to the AS\n" |
| 11830 | "Distance for local routes\n") |
| 11831 | { |
| 11832 | struct bgp *bgp; |
| 11833 | |
| 11834 | bgp = vty->index; |
| 11835 | |
| 11836 | bgp->distance_ebgp= 0; |
| 11837 | bgp->distance_ibgp = 0; |
| 11838 | bgp->distance_local = 0; |
| 11839 | return CMD_SUCCESS; |
| 11840 | } |
| 11841 | |
| 11842 | ALIAS (no_bgp_distance, |
| 11843 | no_bgp_distance2_cmd, |
| 11844 | "no distance bgp", |
| 11845 | NO_STR |
| 11846 | "Define an administrative distance\n" |
| 11847 | "BGP distance\n") |
| 11848 | |
| 11849 | DEFUN (bgp_distance_source, |
| 11850 | bgp_distance_source_cmd, |
| 11851 | "distance <1-255> A.B.C.D/M", |
| 11852 | "Define an administrative distance\n" |
| 11853 | "Administrative distance\n" |
| 11854 | "IP source prefix\n") |
| 11855 | { |
| 11856 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 11857 | return CMD_SUCCESS; |
| 11858 | } |
| 11859 | |
| 11860 | DEFUN (no_bgp_distance_source, |
| 11861 | no_bgp_distance_source_cmd, |
| 11862 | "no distance <1-255> A.B.C.D/M", |
| 11863 | NO_STR |
| 11864 | "Define an administrative distance\n" |
| 11865 | "Administrative distance\n" |
| 11866 | "IP source prefix\n") |
| 11867 | { |
| 11868 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 11869 | return CMD_SUCCESS; |
| 11870 | } |
| 11871 | |
| 11872 | DEFUN (bgp_distance_source_access_list, |
| 11873 | bgp_distance_source_access_list_cmd, |
| 11874 | "distance <1-255> A.B.C.D/M WORD", |
| 11875 | "Define an administrative distance\n" |
| 11876 | "Administrative distance\n" |
| 11877 | "IP source prefix\n" |
| 11878 | "Access list name\n") |
| 11879 | { |
| 11880 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 11881 | return CMD_SUCCESS; |
| 11882 | } |
| 11883 | |
| 11884 | DEFUN (no_bgp_distance_source_access_list, |
| 11885 | no_bgp_distance_source_access_list_cmd, |
| 11886 | "no distance <1-255> A.B.C.D/M WORD", |
| 11887 | NO_STR |
| 11888 | "Define an administrative distance\n" |
| 11889 | "Administrative distance\n" |
| 11890 | "IP source prefix\n" |
| 11891 | "Access list name\n") |
| 11892 | { |
| 11893 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 11894 | return CMD_SUCCESS; |
| 11895 | } |
| 11896 | |
| 11897 | DEFUN (bgp_damp_set, |
| 11898 | bgp_damp_set_cmd, |
| 11899 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 11900 | "BGP Specific commands\n" |
| 11901 | "Enable route-flap dampening\n" |
| 11902 | "Half-life time for the penalty\n" |
| 11903 | "Value to start reusing a route\n" |
| 11904 | "Value to start suppressing a route\n" |
| 11905 | "Maximum duration to suppress a stable route\n") |
| 11906 | { |
| 11907 | struct bgp *bgp; |
| 11908 | int half = DEFAULT_HALF_LIFE * 60; |
| 11909 | int reuse = DEFAULT_REUSE; |
| 11910 | int suppress = DEFAULT_SUPPRESS; |
| 11911 | int max = 4 * half; |
| 11912 | |
| 11913 | if (argc == 4) |
| 11914 | { |
| 11915 | half = atoi (argv[0]) * 60; |
| 11916 | reuse = atoi (argv[1]); |
| 11917 | suppress = atoi (argv[2]); |
| 11918 | max = atoi (argv[3]) * 60; |
| 11919 | } |
| 11920 | else if (argc == 1) |
| 11921 | { |
| 11922 | half = atoi (argv[0]) * 60; |
| 11923 | max = 4 * half; |
| 11924 | } |
| 11925 | |
| 11926 | bgp = vty->index; |
| 11927 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 11928 | half, reuse, suppress, max); |
| 11929 | } |
| 11930 | |
| 11931 | ALIAS (bgp_damp_set, |
| 11932 | bgp_damp_set2_cmd, |
| 11933 | "bgp dampening <1-45>", |
| 11934 | "BGP Specific commands\n" |
| 11935 | "Enable route-flap dampening\n" |
| 11936 | "Half-life time for the penalty\n") |
| 11937 | |
| 11938 | ALIAS (bgp_damp_set, |
| 11939 | bgp_damp_set3_cmd, |
| 11940 | "bgp dampening", |
| 11941 | "BGP Specific commands\n" |
| 11942 | "Enable route-flap dampening\n") |
| 11943 | |
| 11944 | DEFUN (bgp_damp_unset, |
| 11945 | bgp_damp_unset_cmd, |
| 11946 | "no bgp dampening", |
| 11947 | NO_STR |
| 11948 | "BGP Specific commands\n" |
| 11949 | "Enable route-flap dampening\n") |
| 11950 | { |
| 11951 | struct bgp *bgp; |
| 11952 | |
| 11953 | bgp = vty->index; |
| 11954 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 11955 | } |
| 11956 | |
| 11957 | ALIAS (bgp_damp_unset, |
| 11958 | bgp_damp_unset2_cmd, |
| 11959 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 11960 | NO_STR |
| 11961 | "BGP Specific commands\n" |
| 11962 | "Enable route-flap dampening\n" |
| 11963 | "Half-life time for the penalty\n" |
| 11964 | "Value to start reusing a route\n" |
| 11965 | "Value to start suppressing a route\n" |
| 11966 | "Maximum duration to suppress a stable route\n") |
| 11967 | |
| 11968 | DEFUN (show_ip_bgp_dampened_paths, |
| 11969 | show_ip_bgp_dampened_paths_cmd, |
| 11970 | "show ip bgp dampened-paths", |
| 11971 | SHOW_STR |
| 11972 | IP_STR |
| 11973 | BGP_STR |
| 11974 | "Display paths suppressed due to dampening\n") |
| 11975 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11976 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 11977 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11978 | } |
| 11979 | |
| 11980 | DEFUN (show_ip_bgp_flap_statistics, |
| 11981 | show_ip_bgp_flap_statistics_cmd, |
| 11982 | "show ip bgp flap-statistics", |
| 11983 | SHOW_STR |
| 11984 | IP_STR |
| 11985 | BGP_STR |
| 11986 | "Display flap statistics of routes\n") |
| 11987 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11988 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 11989 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11990 | } |
| 11991 | |
| 11992 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11993 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11994 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 11995 | const char *ip_str, afi_t afi, safi_t safi, |
| 11996 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11997 | { |
| 11998 | int ret; |
| 11999 | struct prefix match; |
| 12000 | struct bgp_node *rn; |
| 12001 | struct bgp_node *rm; |
| 12002 | struct bgp_info *ri; |
| 12003 | struct bgp_info *ri_temp; |
| 12004 | struct bgp *bgp; |
| 12005 | struct bgp_table *table; |
| 12006 | |
| 12007 | /* BGP structure lookup. */ |
| 12008 | if (view_name) |
| 12009 | { |
| 12010 | bgp = bgp_lookup_by_name (view_name); |
| 12011 | if (bgp == NULL) |
| 12012 | { |
| 12013 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 12014 | return CMD_WARNING; |
| 12015 | } |
| 12016 | } |
| 12017 | else |
| 12018 | { |
| 12019 | bgp = bgp_get_default (); |
| 12020 | if (bgp == NULL) |
| 12021 | { |
| 12022 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 12023 | return CMD_WARNING; |
| 12024 | } |
| 12025 | } |
| 12026 | |
| 12027 | /* Check IP address argument. */ |
| 12028 | ret = str2prefix (ip_str, &match); |
| 12029 | if (! ret) |
| 12030 | { |
| 12031 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 12032 | return CMD_WARNING; |
| 12033 | } |
| 12034 | |
| 12035 | match.family = afi2family (afi); |
| 12036 | |
| 12037 | if (safi == SAFI_MPLS_VPN) |
| 12038 | { |
| 12039 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 12040 | { |
| 12041 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 12042 | continue; |
| 12043 | |
| 12044 | if ((table = rn->info) != NULL) |
| 12045 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12046 | { |
| 12047 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 12048 | { |
| 12049 | ri = rm->info; |
| 12050 | while (ri) |
| 12051 | { |
| 12052 | if (ri->extra && ri->extra->damp_info) |
| 12053 | { |
| 12054 | ri_temp = ri->next; |
| 12055 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12056 | ri = ri_temp; |
| 12057 | } |
| 12058 | else |
| 12059 | ri = ri->next; |
| 12060 | } |
| 12061 | } |
| 12062 | |
| 12063 | bgp_unlock_node (rm); |
| 12064 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12065 | } |
| 12066 | } |
| 12067 | else |
| 12068 | { |
| 12069 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12070 | { |
| 12071 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 12072 | { |
| 12073 | ri = rn->info; |
| 12074 | while (ri) |
| 12075 | { |
| 12076 | if (ri->extra && ri->extra->damp_info) |
| 12077 | { |
| 12078 | ri_temp = ri->next; |
| 12079 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12080 | ri = ri_temp; |
| 12081 | } |
| 12082 | else |
| 12083 | ri = ri->next; |
| 12084 | } |
| 12085 | } |
| 12086 | |
| 12087 | bgp_unlock_node (rn); |
| 12088 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12089 | } |
| 12090 | |
| 12091 | return CMD_SUCCESS; |
| 12092 | } |
| 12093 | |
| 12094 | DEFUN (clear_ip_bgp_dampening, |
| 12095 | clear_ip_bgp_dampening_cmd, |
| 12096 | "clear ip bgp dampening", |
| 12097 | CLEAR_STR |
| 12098 | IP_STR |
| 12099 | BGP_STR |
| 12100 | "Clear route flap dampening information\n") |
| 12101 | { |
| 12102 | bgp_damp_info_clean (); |
| 12103 | return CMD_SUCCESS; |
| 12104 | } |
| 12105 | |
| 12106 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 12107 | clear_ip_bgp_dampening_prefix_cmd, |
| 12108 | "clear ip bgp dampening A.B.C.D/M", |
| 12109 | CLEAR_STR |
| 12110 | IP_STR |
| 12111 | BGP_STR |
| 12112 | "Clear route flap dampening information\n" |
| 12113 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 12114 | { |
| 12115 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12116 | SAFI_UNICAST, NULL, 1); |
| 12117 | } |
| 12118 | |
| 12119 | DEFUN (clear_ip_bgp_dampening_address, |
| 12120 | clear_ip_bgp_dampening_address_cmd, |
| 12121 | "clear ip bgp dampening A.B.C.D", |
| 12122 | CLEAR_STR |
| 12123 | IP_STR |
| 12124 | BGP_STR |
| 12125 | "Clear route flap dampening information\n" |
| 12126 | "Network to clear damping information\n") |
| 12127 | { |
| 12128 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12129 | SAFI_UNICAST, NULL, 0); |
| 12130 | } |
| 12131 | |
| 12132 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 12133 | clear_ip_bgp_dampening_address_mask_cmd, |
| 12134 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 12135 | CLEAR_STR |
| 12136 | IP_STR |
| 12137 | BGP_STR |
| 12138 | "Clear route flap dampening information\n" |
| 12139 | "Network to clear damping information\n" |
| 12140 | "Network mask\n") |
| 12141 | { |
| 12142 | int ret; |
| 12143 | char prefix_str[BUFSIZ]; |
| 12144 | |
| 12145 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 12146 | if (! ret) |
| 12147 | { |
| 12148 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 12149 | return CMD_WARNING; |
| 12150 | } |
| 12151 | |
| 12152 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 12153 | SAFI_UNICAST, NULL, 0); |
| 12154 | } |
| 12155 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12156 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12157 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 12158 | afi_t afi, safi_t safi, int *write) |
| 12159 | { |
| 12160 | struct bgp_node *prn; |
| 12161 | struct bgp_node *rn; |
| 12162 | struct bgp_table *table; |
| 12163 | struct prefix *p; |
| 12164 | struct prefix_rd *prd; |
| 12165 | struct bgp_static *bgp_static; |
| 12166 | u_int32_t label; |
| 12167 | char buf[SU_ADDRSTRLEN]; |
| 12168 | char rdbuf[RD_ADDRSTRLEN]; |
| 12169 | |
| 12170 | /* Network configuration. */ |
| 12171 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 12172 | if ((table = prn->info) != NULL) |
| 12173 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12174 | if ((bgp_static = rn->info) != NULL) |
| 12175 | { |
| 12176 | p = &rn->p; |
| 12177 | prd = (struct prefix_rd *) &prn->p; |
| 12178 | |
| 12179 | /* "address-family" display. */ |
| 12180 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12181 | |
| 12182 | /* "network" configuration display. */ |
| 12183 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 12184 | label = decode_label (bgp_static->tag); |
| 12185 | |
| 12186 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 12187 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12188 | p->prefixlen, |
| 12189 | rdbuf, label); |
| 12190 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12191 | } |
| 12192 | return 0; |
| 12193 | } |
| 12194 | |
| 12195 | /* Configuration of static route announcement and aggregate |
| 12196 | information. */ |
| 12197 | int |
| 12198 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 12199 | afi_t afi, safi_t safi, int *write) |
| 12200 | { |
| 12201 | struct bgp_node *rn; |
| 12202 | struct prefix *p; |
| 12203 | struct bgp_static *bgp_static; |
| 12204 | struct bgp_aggregate *bgp_aggregate; |
| 12205 | char buf[SU_ADDRSTRLEN]; |
| 12206 | |
| 12207 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 12208 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 12209 | |
| 12210 | /* Network configuration. */ |
| 12211 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12212 | if ((bgp_static = rn->info) != NULL) |
| 12213 | { |
| 12214 | p = &rn->p; |
| 12215 | |
| 12216 | /* "address-family" display. */ |
| 12217 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12218 | |
| 12219 | /* "network" configuration display. */ |
| 12220 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12221 | { |
| 12222 | u_int32_t destination; |
| 12223 | struct in_addr netmask; |
| 12224 | |
| 12225 | destination = ntohl (p->u.prefix4.s_addr); |
| 12226 | masklen2ip (p->prefixlen, &netmask); |
| 12227 | vty_out (vty, " network %s", |
| 12228 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 12229 | |
| 12230 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 12231 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 12232 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 12233 | || p->u.prefix4.s_addr == 0) |
| 12234 | { |
| 12235 | /* Natural mask is not display. */ |
| 12236 | } |
| 12237 | else |
| 12238 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 12239 | } |
| 12240 | else |
| 12241 | { |
| 12242 | vty_out (vty, " network %s/%d", |
| 12243 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12244 | p->prefixlen); |
| 12245 | } |
| 12246 | |
| 12247 | if (bgp_static->rmap.name) |
| 12248 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12249 | else |
| 12250 | { |
| 12251 | if (bgp_static->backdoor) |
| 12252 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12253 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12254 | |
| 12255 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12256 | } |
| 12257 | |
| 12258 | /* Aggregate-address configuration. */ |
| 12259 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12260 | if ((bgp_aggregate = rn->info) != NULL) |
| 12261 | { |
| 12262 | p = &rn->p; |
| 12263 | |
| 12264 | /* "address-family" display. */ |
| 12265 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12266 | |
| 12267 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12268 | { |
| 12269 | struct in_addr netmask; |
| 12270 | |
| 12271 | masklen2ip (p->prefixlen, &netmask); |
| 12272 | vty_out (vty, " aggregate-address %s %s", |
| 12273 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12274 | inet_ntoa (netmask)); |
| 12275 | } |
| 12276 | else |
| 12277 | { |
| 12278 | vty_out (vty, " aggregate-address %s/%d", |
| 12279 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12280 | p->prefixlen); |
| 12281 | } |
| 12282 | |
| 12283 | if (bgp_aggregate->as_set) |
| 12284 | vty_out (vty, " as-set"); |
| 12285 | |
| 12286 | if (bgp_aggregate->summary_only) |
| 12287 | vty_out (vty, " summary-only"); |
| 12288 | |
| 12289 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12290 | } |
| 12291 | |
| 12292 | return 0; |
| 12293 | } |
| 12294 | |
| 12295 | int |
| 12296 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 12297 | { |
| 12298 | struct bgp_node *rn; |
| 12299 | struct bgp_distance *bdistance; |
| 12300 | |
| 12301 | /* Distance configuration. */ |
| 12302 | if (bgp->distance_ebgp |
| 12303 | && bgp->distance_ibgp |
| 12304 | && bgp->distance_local |
| 12305 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 12306 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 12307 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 12308 | vty_out (vty, " distance bgp %d %d %d%s", |
| 12309 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 12310 | VTY_NEWLINE); |
| 12311 | |
| 12312 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 12313 | if ((bdistance = rn->info) != NULL) |
| 12314 | { |
| 12315 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 12316 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 12317 | bdistance->access_list ? bdistance->access_list : "", |
| 12318 | VTY_NEWLINE); |
| 12319 | } |
| 12320 | |
| 12321 | return 0; |
| 12322 | } |
| 12323 | |
| 12324 | /* Allocate routing table structure and install commands. */ |
| 12325 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 12326 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12327 | { |
| 12328 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 12329 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12330 | |
| 12331 | /* IPv4 BGP commands. */ |
| 12332 | install_element (BGP_NODE, &bgp_network_cmd); |
| 12333 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 12334 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 12335 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 12336 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 12337 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12338 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 12339 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 12340 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 12341 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 12342 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 12343 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 12344 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 12345 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12346 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12347 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 12348 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 12349 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 12350 | |
| 12351 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 12352 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 12353 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 12354 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12355 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 12356 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 12357 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 12358 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12359 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 12360 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12361 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 12362 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 12363 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 12364 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12365 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12366 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 12367 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12368 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12369 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12370 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12371 | |
| 12372 | /* IPv4 unicast configuration. */ |
| 12373 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 12374 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 12375 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 12376 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 12377 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 12378 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 12379 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12380 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 12381 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 12382 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 12383 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12384 | 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] | 12385 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12386 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 12387 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 12388 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 12389 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12390 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 12391 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 12392 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 12393 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12394 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 12395 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12396 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 12397 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 12398 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 12399 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12400 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12401 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 12402 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12403 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12404 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12405 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12406 | |
| 12407 | /* IPv4 multicast configuration. */ |
| 12408 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 12409 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 12410 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 12411 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 12412 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 12413 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12414 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 12415 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 12416 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 12417 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 12418 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12419 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12420 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 12421 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 12422 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 12423 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12424 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 12425 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 12426 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 12427 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12428 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 12429 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12430 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 12431 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 12432 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 12433 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12434 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12435 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 12436 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12437 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12438 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12439 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12440 | |
| 12441 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 12442 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12443 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12444 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 12445 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12446 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12447 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12448 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12449 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 12450 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12451 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12452 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12453 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12454 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 12455 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 12456 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12457 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 12458 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12459 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12460 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12461 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 12462 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12463 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 12464 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12465 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12466 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12467 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 12468 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12469 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 12470 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 12471 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 12472 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 12473 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12474 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12475 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12476 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12477 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12478 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12479 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12480 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12481 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12482 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 12483 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12484 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12485 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12486 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12487 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12488 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12489 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12490 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 12491 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12492 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12493 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12494 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12495 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12496 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12497 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12498 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12499 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12500 | 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] | 12501 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12502 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12503 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12504 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 12505 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 12506 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 12507 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 12508 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12509 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 12510 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12511 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 12512 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 12513 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 12514 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 12515 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12516 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12517 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12518 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12519 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12520 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12521 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12522 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12523 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12524 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12525 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12526 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12527 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12528 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12529 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12530 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12531 | |
| 12532 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
| 12533 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
| 12534 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12535 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12536 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12537 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 12538 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12539 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12540 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12541 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12542 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 12543 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12544 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 12545 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 12546 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 12547 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 12548 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12549 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12550 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12551 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12552 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12553 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12554 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12555 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12556 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12557 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 12558 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12559 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12560 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12561 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12562 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12563 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12564 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12565 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12566 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12567 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12568 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12569 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12570 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12571 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12572 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12573 | |
| 12574 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 12575 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12576 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12577 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 12578 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12579 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12580 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12581 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12582 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 12583 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12584 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12585 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12586 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12587 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 12588 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 12589 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12590 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 12591 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12592 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12593 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12594 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 12595 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12596 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 12597 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12598 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12599 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12600 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 12601 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12602 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 12603 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 12604 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 12605 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 12606 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12607 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12608 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12609 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12610 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12611 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12612 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12613 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12614 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12615 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 12616 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12617 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12618 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12619 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12620 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12621 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12622 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12623 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 12624 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12625 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12626 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12627 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12628 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12629 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12630 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12631 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12632 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12633 | 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] | 12634 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12635 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12636 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12637 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 12638 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 12639 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 12640 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 12641 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12642 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 12643 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12644 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 12645 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 12646 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 12647 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 12648 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12649 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12650 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12651 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12652 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12653 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12654 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12655 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12656 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12657 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12658 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12659 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12660 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12661 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12662 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12663 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12664 | |
| 12665 | /* BGP dampening clear commands */ |
| 12666 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 12667 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 12668 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 12669 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 12670 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12671 | /* prefix count */ |
| 12672 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 12673 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 12674 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12675 | #ifdef HAVE_IPV6 |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12676 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 12677 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12678 | /* New config IPv6 BGP commands. */ |
| 12679 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 12680 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 12681 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 12682 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 12683 | |
| 12684 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 12685 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 12686 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 12687 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 12688 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 12689 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 12690 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 12691 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12692 | /* Old config IPv6 BGP commands. */ |
| 12693 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 12694 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 12695 | |
| 12696 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 12697 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 12698 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 12699 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 12700 | |
| 12701 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 12702 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12703 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12704 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 12705 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12706 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12707 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 12708 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12709 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12710 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 12711 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12712 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 12713 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12714 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 12715 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12716 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 12717 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12718 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 12719 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12720 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 12721 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 12722 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 12723 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 12724 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 12725 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 12726 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 12727 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 12728 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 12729 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12730 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 12731 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12732 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 12733 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12734 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 12735 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12736 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 12737 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12738 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 12739 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12740 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 12741 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12742 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12743 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12744 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12745 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12746 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 12747 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12748 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12749 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12750 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 12751 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12752 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 12753 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12754 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12755 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12756 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12757 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12758 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12759 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12760 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 12761 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 12762 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 12763 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12764 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 12765 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12766 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12767 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12768 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12769 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12770 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12771 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12772 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12773 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12774 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12775 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12776 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12777 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12778 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12779 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12780 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12781 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12782 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12783 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12784 | |
| 12785 | /* Restricted: |
| 12786 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 12787 | */ |
| 12788 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 12789 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12790 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12791 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
| 12792 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12793 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12794 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 12795 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 12796 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 12797 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 12798 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 12799 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 12800 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 12801 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 12802 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 12803 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12804 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 12805 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12806 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 12807 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12808 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 12809 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12810 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12811 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12812 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12813 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12814 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 12815 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12816 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 12817 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12818 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12819 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12820 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12821 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12822 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12823 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12824 | |
| 12825 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 12826 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12827 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12828 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 12829 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12830 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12831 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 12832 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12833 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12834 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 12835 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12836 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 12837 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12838 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 12839 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12840 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 12841 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12842 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 12843 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12844 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 12845 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 12846 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 12847 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 12848 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 12849 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 12850 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 12851 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 12852 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 12853 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12854 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 12855 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12856 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 12857 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12858 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 12859 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12860 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 12861 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12862 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 12863 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12864 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 12865 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12866 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12867 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12868 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12869 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12870 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 12871 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12872 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12873 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12874 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 12875 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12876 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 12877 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12878 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12879 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12880 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12881 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12882 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12883 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12884 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 12885 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 12886 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 12887 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12888 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 12889 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12890 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12891 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12892 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12893 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12894 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12895 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12896 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12897 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12898 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12899 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12900 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12901 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12902 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12903 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12904 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12905 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12906 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12907 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12908 | |
| 12909 | /* Statistics */ |
| 12910 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
| 12911 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 12912 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
| 12913 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
| 12914 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12915 | /* old command */ |
| 12916 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 12917 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 12918 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 12919 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 12920 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 12921 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 12922 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 12923 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 12924 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 12925 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 12926 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 12927 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 12928 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 12929 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 12930 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 12931 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 12932 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 12933 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 12934 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 12935 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 12936 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 12937 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 12938 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 12939 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 12940 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 12941 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 12942 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 12943 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 12944 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 12945 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 12946 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 12947 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 12948 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 12949 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 12950 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 12951 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12952 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12953 | /* old command */ |
| 12954 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 12955 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 12956 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 12957 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 12958 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 12959 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 12960 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 12961 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 12962 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 12963 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 12964 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 12965 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 12966 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 12967 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 12968 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 12969 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 12970 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 12971 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 12972 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 12973 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 12974 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 12975 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 12976 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 12977 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 12978 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 12979 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 12980 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 12981 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 12982 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 12983 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 12984 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 12985 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 12986 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 12987 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 12988 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 12989 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 12990 | |
| 12991 | /* old command */ |
| 12992 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 12993 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 12994 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 12995 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 12996 | |
| 12997 | /* old command */ |
| 12998 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 12999 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13000 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13001 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13002 | |
| 13003 | /* old command */ |
| 13004 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13005 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13006 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13007 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13008 | #endif /* HAVE_IPV6 */ |
| 13009 | |
| 13010 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 13011 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 13012 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 13013 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 13014 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 13015 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 13016 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 13017 | |
| 13018 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 13019 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 13020 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 13021 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 13022 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 13023 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 13024 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 13025 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 13026 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 13027 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13028 | |
| 13029 | /* Deprecated AS-Pathlimit commands */ |
| 13030 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 13031 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 13032 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13033 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13034 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13035 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13036 | |
| 13037 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 13038 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13039 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13040 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13041 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13042 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13043 | |
| 13044 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 13045 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 13046 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13047 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13048 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13049 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13050 | |
| 13051 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 13052 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13053 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13054 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13055 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13056 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13057 | |
| 13058 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 13059 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 13060 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13061 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13062 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13063 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13064 | |
| 13065 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 13066 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13067 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13068 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13069 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13070 | 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] | 13071 | |
| 13072 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13073 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 13074 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 13075 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13076 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 13077 | |
| 13078 | void |
| 13079 | bgp_route_finish (void) |
| 13080 | { |
| 13081 | bgp_table_unlock (bgp_distance_table); |
| 13082 | bgp_distance_table = NULL; |
| 13083 | } |