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 | { |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 243 | struct bgp_table *table; |
| 244 | |
| 245 | assert (rn && bgp_node_table (rn)); |
Paul Jakma | 6f58544 | 2006-10-22 19:13:07 +0000 | [diff] [blame] | 246 | assert (ri && ri->peer && ri->peer->bgp); |
| 247 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 248 | table = bgp_node_table (rn); |
| 249 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 250 | /* Ignore 'pcount' for RS-client tables */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 251 | if (table->type != BGP_TABLE_MAIN |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 252 | || ri->peer == ri->peer->bgp->peer_self) |
| 253 | return; |
| 254 | |
| 255 | if (BGP_INFO_HOLDDOWN (ri) |
| 256 | && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 257 | { |
| 258 | |
| 259 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 260 | |
| 261 | /* slight hack, but more robust against errors. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 262 | if (ri->peer->pcount[table->afi][table->safi]) |
| 263 | ri->peer->pcount[table->afi][table->safi]--; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 264 | else |
| 265 | { |
| 266 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", |
| 267 | __func__, ri->peer->host); |
| 268 | zlog_backtrace (LOG_WARNING); |
| 269 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); |
| 270 | } |
| 271 | } |
| 272 | else if (!BGP_INFO_HOLDDOWN (ri) |
| 273 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 274 | { |
| 275 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 276 | ri->peer->pcount[table->afi][table->safi]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 277 | } |
| 278 | } |
| 279 | |
| 280 | |
| 281 | /* Set/unset bgp_info flags, adjusting any other state as needed. |
| 282 | * This is here primarily to keep prefix-count in check. |
| 283 | */ |
| 284 | void |
| 285 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 286 | { |
| 287 | SET_FLAG (ri->flags, flag); |
| 288 | |
| 289 | /* early bath if we know it's not a flag that changes useability state */ |
| 290 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 291 | return; |
| 292 | |
| 293 | bgp_pcount_adjust (rn, ri); |
| 294 | } |
| 295 | |
| 296 | void |
| 297 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 298 | { |
| 299 | UNSET_FLAG (ri->flags, flag); |
| 300 | |
| 301 | /* early bath if we know it's not a flag that changes useability state */ |
| 302 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 303 | return; |
| 304 | |
| 305 | bgp_pcount_adjust (rn, ri); |
| 306 | } |
| 307 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 308 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 309 | missing-as-worst" is specified, treat it as the worst value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 310 | static u_int32_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 311 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
| 312 | { |
| 313 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 314 | return attr->med; |
| 315 | else |
| 316 | { |
| 317 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 318 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 319 | else |
| 320 | return 0; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | /* Compare two bgp route entity. br is preferable then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 325 | static int |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 326 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, |
| 327 | int *paths_eq) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 328 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 329 | struct attr *newattr, *existattr; |
| 330 | struct attr_extra *newattre, *existattre; |
| 331 | bgp_peer_sort_t new_sort; |
| 332 | bgp_peer_sort_t exist_sort; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 333 | u_int32_t new_pref; |
| 334 | u_int32_t exist_pref; |
| 335 | u_int32_t new_med; |
| 336 | u_int32_t exist_med; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 337 | u_int32_t new_weight; |
| 338 | u_int32_t exist_weight; |
| 339 | uint32_t newm, existm; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 340 | struct in_addr new_id; |
| 341 | struct in_addr exist_id; |
| 342 | int new_cluster; |
| 343 | int exist_cluster; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 344 | int internal_as_route; |
| 345 | int confed_as_route; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 346 | int ret; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 347 | |
| 348 | *paths_eq = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 349 | |
| 350 | /* 0. Null check. */ |
| 351 | if (new == NULL) |
| 352 | return 0; |
| 353 | if (exist == NULL) |
| 354 | return 1; |
| 355 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 356 | newattr = new->attr; |
| 357 | existattr = exist->attr; |
| 358 | newattre = newattr->extra; |
| 359 | existattre = existattr->extra; |
| 360 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 361 | /* 1. Weight check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 362 | new_weight = exist_weight = 0; |
| 363 | |
| 364 | if (newattre) |
| 365 | new_weight = newattre->weight; |
| 366 | if (existattre) |
| 367 | exist_weight = existattre->weight; |
| 368 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 369 | if (new_weight > exist_weight) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 370 | return 1; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 371 | if (new_weight < exist_weight) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 372 | return 0; |
| 373 | |
| 374 | /* 2. Local preference check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 375 | new_pref = exist_pref = bgp->default_local_pref; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 376 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 377 | if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 378 | new_pref = newattr->local_pref; |
| 379 | if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 380 | exist_pref = existattr->local_pref; |
| 381 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 382 | if (new_pref > exist_pref) |
| 383 | return 1; |
| 384 | if (new_pref < exist_pref) |
| 385 | return 0; |
| 386 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 387 | /* 3. Local route check. We prefer: |
| 388 | * - BGP_ROUTE_STATIC |
| 389 | * - BGP_ROUTE_AGGREGATE |
| 390 | * - BGP_ROUTE_REDISTRIBUTE |
| 391 | */ |
| 392 | if (! (new->sub_type == BGP_ROUTE_NORMAL)) |
| 393 | return 1; |
| 394 | if (! (exist->sub_type == BGP_ROUTE_NORMAL)) |
| 395 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 396 | |
| 397 | /* 4. AS path length check. */ |
| 398 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 399 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 400 | int exist_hops = aspath_count_hops (existattr->aspath); |
| 401 | int exist_confeds = aspath_count_confeds (existattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 402 | |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 403 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
| 404 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 405 | int aspath_hops; |
| 406 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 407 | aspath_hops = aspath_count_hops (newattr->aspath); |
| 408 | aspath_hops += aspath_count_confeds (newattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 409 | |
| 410 | if ( aspath_hops < (exist_hops + exist_confeds)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 411 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 412 | if ( aspath_hops > (exist_hops + exist_confeds)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 413 | return 0; |
| 414 | } |
| 415 | else |
| 416 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 417 | int newhops = aspath_count_hops (newattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 418 | |
| 419 | if (newhops < exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 420 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 421 | if (newhops > exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 422 | return 0; |
| 423 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | /* 5. Origin check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 427 | if (newattr->origin < existattr->origin) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 428 | return 1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 429 | if (newattr->origin > existattr->origin) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 430 | return 0; |
| 431 | |
| 432 | /* 6. MED check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 433 | internal_as_route = (aspath_count_hops (newattr->aspath) == 0 |
| 434 | && aspath_count_hops (existattr->aspath) == 0); |
| 435 | confed_as_route = (aspath_count_confeds (newattr->aspath) > 0 |
| 436 | && aspath_count_confeds (existattr->aspath) > 0 |
| 437 | && aspath_count_hops (newattr->aspath) == 0 |
| 438 | && aspath_count_hops (existattr->aspath) == 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 439 | |
| 440 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 441 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 442 | && confed_as_route) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 443 | || aspath_cmp_left (newattr->aspath, existattr->aspath) |
| 444 | || aspath_cmp_left_confed (newattr->aspath, existattr->aspath) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 445 | || internal_as_route) |
| 446 | { |
| 447 | new_med = bgp_med_value (new->attr, bgp); |
| 448 | exist_med = bgp_med_value (exist->attr, bgp); |
| 449 | |
| 450 | if (new_med < exist_med) |
| 451 | return 1; |
| 452 | if (new_med > exist_med) |
| 453 | return 0; |
| 454 | } |
| 455 | |
| 456 | /* 7. Peer type check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 457 | new_sort = new->peer->sort; |
| 458 | exist_sort = exist->peer->sort; |
| 459 | |
| 460 | if (new_sort == BGP_PEER_EBGP |
| 461 | && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 462 | return 1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 463 | if (exist_sort == BGP_PEER_EBGP |
| 464 | && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 465 | return 0; |
| 466 | |
| 467 | /* 8. IGP metric check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 468 | newm = existm = 0; |
| 469 | |
| 470 | if (new->extra) |
| 471 | newm = new->extra->igpmetric; |
| 472 | if (exist->extra) |
| 473 | existm = exist->extra->igpmetric; |
| 474 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 475 | if (newm < existm) |
| 476 | ret = 1; |
| 477 | if (newm > existm) |
| 478 | ret = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 479 | |
| 480 | /* 9. Maximum path check. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 481 | if (newm == existm) |
| 482 | { |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 483 | if (new->peer->sort == BGP_PEER_IBGP) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 484 | { |
| 485 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) |
| 486 | *paths_eq = 1; |
| 487 | } |
| 488 | else if (new->peer->as == exist->peer->as) |
| 489 | *paths_eq = 1; |
| 490 | } |
| 491 | else |
| 492 | { |
| 493 | /* |
| 494 | * TODO: If unequal cost ibgp multipath is enabled we can |
| 495 | * mark the paths as equal here instead of returning |
| 496 | */ |
| 497 | return ret; |
| 498 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 499 | |
| 500 | /* 10. If both paths are external, prefer the path that was received |
| 501 | first (the oldest one). This step minimizes route-flap, since a |
| 502 | newer path won't displace an older one, even if it was the |
| 503 | preferred route based on the additional decision criteria below. */ |
| 504 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 505 | && new_sort == BGP_PEER_EBGP |
| 506 | && exist_sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 507 | { |
| 508 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
| 509 | return 1; |
| 510 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
| 511 | return 0; |
| 512 | } |
| 513 | |
| 514 | /* 11. Rourter-ID comparision. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 515 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 516 | new_id.s_addr = newattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 517 | else |
| 518 | new_id.s_addr = new->peer->remote_id.s_addr; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 519 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 520 | exist_id.s_addr = existattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 521 | else |
| 522 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 523 | |
| 524 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 525 | return 1; |
| 526 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 527 | return 0; |
| 528 | |
| 529 | /* 12. Cluster length comparision. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 530 | new_cluster = exist_cluster = 0; |
| 531 | |
| 532 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 533 | new_cluster = newattre->cluster->length; |
| 534 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 535 | exist_cluster = existattre->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 536 | |
| 537 | if (new_cluster < exist_cluster) |
| 538 | return 1; |
| 539 | if (new_cluster > exist_cluster) |
| 540 | return 0; |
| 541 | |
| 542 | /* 13. Neighbor address comparision. */ |
| 543 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 544 | |
| 545 | if (ret == 1) |
| 546 | return 0; |
| 547 | if (ret == -1) |
| 548 | return 1; |
| 549 | |
| 550 | return 1; |
| 551 | } |
| 552 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 553 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 554 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 555 | afi_t afi, safi_t safi) |
| 556 | { |
| 557 | struct bgp_filter *filter; |
| 558 | |
| 559 | filter = &peer->filter[afi][safi]; |
| 560 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 561 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 562 | if (BGP_DEBUG (update, UPDATE_IN) \ |
| 563 | && !(F ## _IN (filter))) \ |
| 564 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ |
| 565 | peer->host, #f, F ## _IN_NAME(filter)); |
| 566 | |
| 567 | if (DISTRIBUTE_IN_NAME (filter)) { |
| 568 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 569 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 570 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 571 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 572 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 573 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 574 | if (PREFIX_LIST_IN_NAME (filter)) { |
| 575 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 576 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 577 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 578 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 579 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 580 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 581 | if (FILTER_LIST_IN_NAME (filter)) { |
| 582 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 583 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 584 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 585 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 586 | } |
| 587 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 588 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 589 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 590 | } |
| 591 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 592 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 593 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 594 | afi_t afi, safi_t safi) |
| 595 | { |
| 596 | struct bgp_filter *filter; |
| 597 | |
| 598 | filter = &peer->filter[afi][safi]; |
| 599 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 600 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 601 | if (BGP_DEBUG (update, UPDATE_OUT) \ |
| 602 | && !(F ## _OUT (filter))) \ |
| 603 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ |
| 604 | peer->host, #f, F ## _OUT_NAME(filter)); |
| 605 | |
| 606 | if (DISTRIBUTE_OUT_NAME (filter)) { |
| 607 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 608 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 609 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 610 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 611 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 612 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 613 | if (PREFIX_LIST_OUT_NAME (filter)) { |
| 614 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 615 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 616 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 617 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 618 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 619 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 620 | if (FILTER_LIST_OUT_NAME (filter)) { |
| 621 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 622 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 623 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 624 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 625 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 626 | |
| 627 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 628 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 632 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 633 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 634 | { |
| 635 | if (attr->community) |
| 636 | { |
| 637 | /* NO_ADVERTISE check. */ |
| 638 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 639 | return 1; |
| 640 | |
| 641 | /* NO_EXPORT check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 642 | if (peer->sort == BGP_PEER_EBGP && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 643 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 644 | return 1; |
| 645 | |
| 646 | /* NO_EXPORT_SUBCONFED check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 647 | if (peer->sort == BGP_PEER_EBGP |
| 648 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 649 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 650 | return 1; |
| 651 | } |
| 652 | return 0; |
| 653 | } |
| 654 | |
| 655 | /* Route reflection loop check. */ |
| 656 | static int |
| 657 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 658 | { |
| 659 | struct in_addr cluster_id; |
| 660 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 661 | if (attr->extra && attr->extra->cluster) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 662 | { |
| 663 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 664 | cluster_id = peer->bgp->cluster_id; |
| 665 | else |
| 666 | cluster_id = peer->bgp->router_id; |
| 667 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 668 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 669 | return 1; |
| 670 | } |
| 671 | return 0; |
| 672 | } |
| 673 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 674 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 675 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 676 | afi_t afi, safi_t safi) |
| 677 | { |
| 678 | struct bgp_filter *filter; |
| 679 | struct bgp_info info; |
| 680 | route_map_result_t ret; |
| 681 | |
| 682 | filter = &peer->filter[afi][safi]; |
| 683 | |
| 684 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 685 | if (peer->weight) |
| 686 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 687 | |
| 688 | /* Route map apply. */ |
| 689 | if (ROUTE_MAP_IN_NAME (filter)) |
| 690 | { |
| 691 | /* Duplicate current value to new strucutre for modification. */ |
| 692 | info.peer = peer; |
| 693 | info.attr = attr; |
| 694 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 695 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 696 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 697 | /* Apply BGP route map to the attribute. */ |
| 698 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 699 | |
| 700 | peer->rmap_type = 0; |
| 701 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 702 | if (ret == RMAP_DENYMATCH) |
| 703 | { |
| 704 | /* Free newly generated AS path and community by route-map. */ |
| 705 | bgp_attr_flush (attr); |
| 706 | return RMAP_DENY; |
| 707 | } |
| 708 | } |
| 709 | return RMAP_PERMIT; |
| 710 | } |
| 711 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 712 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 713 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 714 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 715 | { |
| 716 | struct bgp_filter *filter; |
| 717 | struct bgp_info info; |
| 718 | route_map_result_t ret; |
| 719 | |
| 720 | filter = &peer->filter[afi][safi]; |
| 721 | |
| 722 | /* Route map apply. */ |
| 723 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 724 | { |
| 725 | /* Duplicate current value to new strucutre for modification. */ |
| 726 | info.peer = rsclient; |
| 727 | info.attr = attr; |
| 728 | |
| 729 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 730 | |
| 731 | /* Apply BGP route map to the attribute. */ |
| 732 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 733 | |
| 734 | rsclient->rmap_type = 0; |
| 735 | |
| 736 | if (ret == RMAP_DENYMATCH) |
| 737 | { |
| 738 | /* Free newly generated AS path and community by route-map. */ |
| 739 | bgp_attr_flush (attr); |
| 740 | return RMAP_DENY; |
| 741 | } |
| 742 | } |
| 743 | return RMAP_PERMIT; |
| 744 | } |
| 745 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 746 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 747 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 748 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 749 | { |
| 750 | struct bgp_filter *filter; |
| 751 | struct bgp_info info; |
| 752 | route_map_result_t ret; |
| 753 | |
| 754 | filter = &rsclient->filter[afi][safi]; |
| 755 | |
| 756 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 757 | if (peer->weight) |
| 758 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 759 | |
| 760 | /* Route map apply. */ |
| 761 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 762 | { |
| 763 | /* Duplicate current value to new strucutre for modification. */ |
| 764 | info.peer = peer; |
| 765 | info.attr = attr; |
| 766 | |
| 767 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 768 | |
| 769 | /* Apply BGP route map to the attribute. */ |
| 770 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 771 | |
| 772 | peer->rmap_type = 0; |
| 773 | |
| 774 | if (ret == RMAP_DENYMATCH) |
| 775 | { |
| 776 | /* Free newly generated AS path and community by route-map. */ |
| 777 | bgp_attr_flush (attr); |
| 778 | return RMAP_DENY; |
| 779 | } |
| 780 | } |
| 781 | return RMAP_PERMIT; |
| 782 | } |
| 783 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 784 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 785 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 786 | struct attr *attr, afi_t afi, safi_t safi) |
| 787 | { |
| 788 | int ret; |
| 789 | char buf[SU_ADDRSTRLEN]; |
| 790 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 791 | struct peer *from; |
| 792 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 793 | int transparent; |
| 794 | int reflect; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 795 | struct attr *riattr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 796 | |
| 797 | from = ri->peer; |
| 798 | filter = &peer->filter[afi][safi]; |
| 799 | bgp = peer->bgp; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 800 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 801 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 802 | if (DISABLE_BGP_ANNOUNCE) |
| 803 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 804 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 805 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 806 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 807 | return 0; |
| 808 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 809 | /* Do not send back route to sender. */ |
| 810 | if (from == peer) |
| 811 | return 0; |
| 812 | |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 813 | /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */ |
| 814 | if (p->family == AF_INET |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 815 | && IPV4_ADDR_SAME(&peer->remote_id, &riattr->nexthop)) |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 816 | return 0; |
| 817 | #ifdef HAVE_IPV6 |
| 818 | if (p->family == AF_INET6 |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 819 | && IPV6_ADDR_SAME(&peer->remote_id, &riattr->nexthop)) |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 820 | return 0; |
| 821 | #endif |
| 822 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 823 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 824 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 825 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 826 | return 0; |
| 827 | |
| 828 | /* Default route check. */ |
| 829 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 830 | { |
| 831 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 832 | return 0; |
| 833 | #ifdef HAVE_IPV6 |
| 834 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 835 | return 0; |
| 836 | #endif /* HAVE_IPV6 */ |
| 837 | } |
| 838 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 839 | /* Transparency check. */ |
| 840 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 841 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 842 | transparent = 1; |
| 843 | else |
| 844 | transparent = 0; |
| 845 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 846 | /* If community is not disabled check the no-export and local. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 847 | if (! transparent && bgp_community_filter (peer, riattr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 848 | return 0; |
| 849 | |
| 850 | /* If the attribute has originator-id and it is same as remote |
| 851 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 852 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 853 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 854 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 855 | { |
| 856 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 857 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 858 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 859 | peer->host, |
| 860 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 861 | p->prefixlen); |
| 862 | return 0; |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | /* ORF prefix-list filter check */ |
| 867 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 868 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 869 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 870 | if (peer->orf_plist[afi][safi]) |
| 871 | { |
| 872 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 873 | return 0; |
| 874 | } |
| 875 | |
| 876 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 877 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 878 | { |
| 879 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 880 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 881 | "%s [Update:SEND] %s/%d is filtered", |
| 882 | peer->host, |
| 883 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 884 | p->prefixlen); |
| 885 | return 0; |
| 886 | } |
| 887 | |
| 888 | #ifdef BGP_SEND_ASPATH_CHECK |
| 889 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 890 | if (aspath_loop_check (riattr->aspath, peer->as)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 891 | { |
| 892 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 893 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 894 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 895 | peer->host, peer->as); |
| 896 | return 0; |
| 897 | } |
| 898 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 899 | |
| 900 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 901 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 902 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 903 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 904 | { |
| 905 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 906 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 907 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 908 | peer->host, |
| 909 | bgp->confed_id); |
| 910 | return 0; |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | /* Route-Reflect check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 915 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 916 | reflect = 1; |
| 917 | else |
| 918 | reflect = 0; |
| 919 | |
| 920 | /* IBGP reflection check. */ |
| 921 | if (reflect) |
| 922 | { |
| 923 | /* A route from a Client peer. */ |
| 924 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 925 | { |
| 926 | /* Reflect to all the Non-Client peers and also to the |
| 927 | Client peers other than the originator. Originator check |
| 928 | is already done. So there is noting to do. */ |
| 929 | /* no bgp client-to-client reflection check. */ |
| 930 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 931 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 932 | return 0; |
| 933 | } |
| 934 | else |
| 935 | { |
| 936 | /* A route from a Non-client peer. Reflect to all other |
| 937 | clients. */ |
| 938 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 939 | return 0; |
| 940 | } |
| 941 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 942 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 943 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 944 | bgp_attr_dup (attr, riattr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 945 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 946 | /* If local-preference is not set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 947 | if ((peer->sort == BGP_PEER_IBGP |
| 948 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 949 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 950 | { |
| 951 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 952 | attr->local_pref = bgp->default_local_pref; |
| 953 | } |
| 954 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 955 | /* 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] | 956 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 957 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 958 | { |
| 959 | if (ri->peer != bgp->peer_self && ! transparent |
| 960 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 961 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 962 | } |
| 963 | |
| 964 | /* next-hop-set */ |
| 965 | if (transparent || reflect |
| 966 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 967 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 968 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 969 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 970 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 971 | #endif /* HAVE_IPV6 */ |
| 972 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 973 | { |
| 974 | /* NEXT-HOP Unchanged. */ |
| 975 | } |
| 976 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 977 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 978 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 979 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 980 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 981 | #endif /* HAVE_IPV6 */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 982 | || (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 983 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 984 | { |
| 985 | /* Set IPv4 nexthop. */ |
| 986 | if (p->family == AF_INET) |
| 987 | { |
| 988 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 989 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 990 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 991 | else |
| 992 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 993 | } |
| 994 | #ifdef HAVE_IPV6 |
| 995 | /* Set IPv6 nexthop. */ |
| 996 | if (p->family == AF_INET6) |
| 997 | { |
| 998 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 999 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1000 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1001 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1002 | } |
| 1003 | #endif /* HAVE_IPV6 */ |
| 1004 | } |
| 1005 | |
| 1006 | #ifdef HAVE_IPV6 |
| 1007 | if (p->family == AF_INET6) |
| 1008 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1009 | /* Left nexthop_local unchanged if so configured. */ |
| 1010 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 1011 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1012 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1013 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 1014 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1015 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1016 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1017 | } |
| 1018 | |
| 1019 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 1020 | else |
| 1021 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1022 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1023 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1024 | |
| 1025 | /* Set link-local address for shared network peer. */ |
| 1026 | if (peer->shared_network |
| 1027 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 1028 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1029 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1030 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1031 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1032 | } |
| 1033 | |
| 1034 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 1035 | address.*/ |
| 1036 | if (reflect) |
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 | |
| 1039 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 1040 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1041 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1042 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1043 | |
| 1044 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1045 | #endif /* HAVE_IPV6 */ |
| 1046 | |
| 1047 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1048 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1049 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1050 | && aspath_private_as_check (attr->aspath)) |
| 1051 | attr->aspath = aspath_empty_get (); |
| 1052 | |
| 1053 | /* Route map & unsuppress-map apply. */ |
| 1054 | if (ROUTE_MAP_OUT_NAME (filter) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1055 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1056 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1057 | struct bgp_info info; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1058 | struct attr dummy_attr; |
| 1059 | struct attr_extra dummy_extra; |
| 1060 | |
| 1061 | dummy_attr.extra = &dummy_extra; |
| 1062 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1063 | info.peer = peer; |
| 1064 | info.attr = attr; |
| 1065 | |
| 1066 | /* The route reflector is not allowed to modify the attributes |
| 1067 | of the reflected IBGP routes. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1068 | if (from->sort == BGP_PEER_IBGP |
| 1069 | && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1070 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1071 | bgp_attr_dup (&dummy_attr, attr); |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1072 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1073 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1074 | |
| 1075 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1076 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1077 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1078 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1079 | else |
| 1080 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1081 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1082 | peer->rmap_type = 0; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1083 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1084 | if (ret == RMAP_DENYMATCH) |
| 1085 | { |
| 1086 | bgp_attr_flush (attr); |
| 1087 | return 0; |
| 1088 | } |
| 1089 | } |
| 1090 | return 1; |
| 1091 | } |
| 1092 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1093 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1094 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1095 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1096 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1097 | int ret; |
| 1098 | char buf[SU_ADDRSTRLEN]; |
| 1099 | struct bgp_filter *filter; |
| 1100 | struct bgp_info info; |
| 1101 | struct peer *from; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1102 | struct attr *riattr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1103 | |
| 1104 | from = ri->peer; |
| 1105 | filter = &rsclient->filter[afi][safi]; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1106 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1107 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 1108 | if (DISABLE_BGP_ANNOUNCE) |
| 1109 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1110 | |
| 1111 | /* Do not send back route to sender. */ |
| 1112 | if (from == rsclient) |
| 1113 | return 0; |
| 1114 | |
| 1115 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1116 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1117 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 1118 | return 0; |
| 1119 | |
| 1120 | /* Default route check. */ |
| 1121 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1122 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1123 | { |
| 1124 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1125 | return 0; |
| 1126 | #ifdef HAVE_IPV6 |
| 1127 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1128 | return 0; |
| 1129 | #endif /* HAVE_IPV6 */ |
| 1130 | } |
| 1131 | |
| 1132 | /* If the attribute has originator-id and it is same as remote |
| 1133 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1134 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1135 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1136 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1137 | &riattr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1138 | { |
| 1139 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1140 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1141 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1142 | rsclient->host, |
| 1143 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1144 | p->prefixlen); |
| 1145 | return 0; |
| 1146 | } |
| 1147 | } |
| 1148 | |
| 1149 | /* ORF prefix-list filter check */ |
| 1150 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1151 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1152 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1153 | if (rsclient->orf_plist[afi][safi]) |
| 1154 | { |
| 1155 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1156 | return 0; |
| 1157 | } |
| 1158 | |
| 1159 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1160 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1161 | { |
| 1162 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1163 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1164 | "%s [Update:SEND] %s/%d is filtered", |
| 1165 | rsclient->host, |
| 1166 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1167 | p->prefixlen); |
| 1168 | return 0; |
| 1169 | } |
| 1170 | |
| 1171 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1172 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1173 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1174 | { |
| 1175 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1176 | zlog (rsclient->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 1177 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1178 | rsclient->host, rsclient->as); |
| 1179 | return 0; |
| 1180 | } |
| 1181 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1182 | |
| 1183 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1184 | bgp_attr_dup (attr, riattr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1185 | |
| 1186 | /* next-hop-set */ |
| 1187 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1188 | #ifdef HAVE_IPV6 |
| 1189 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1190 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1191 | #endif /* HAVE_IPV6 */ |
| 1192 | ) |
| 1193 | { |
| 1194 | /* Set IPv4 nexthop. */ |
| 1195 | if (p->family == AF_INET) |
| 1196 | { |
| 1197 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1198 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1199 | IPV4_MAX_BYTELEN); |
| 1200 | else |
| 1201 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1202 | } |
| 1203 | #ifdef HAVE_IPV6 |
| 1204 | /* Set IPv6 nexthop. */ |
| 1205 | if (p->family == AF_INET6) |
| 1206 | { |
| 1207 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1208 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1209 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1210 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1211 | } |
| 1212 | #endif /* HAVE_IPV6 */ |
| 1213 | } |
| 1214 | |
| 1215 | #ifdef HAVE_IPV6 |
| 1216 | if (p->family == AF_INET6) |
| 1217 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1218 | struct attr_extra *attre = attr->extra; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1219 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1220 | /* Left nexthop_local unchanged if so configured. */ |
| 1221 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1222 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1223 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1224 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1225 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1226 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1227 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1228 | } |
| 1229 | |
| 1230 | /* Default nexthop_local treatment for RS-Clients */ |
| 1231 | else |
| 1232 | { |
| 1233 | /* Announcer and RS-Client are both in the same network */ |
| 1234 | if (rsclient->shared_network && from->shared_network && |
| 1235 | (rsclient->ifindex == from->ifindex)) |
| 1236 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1237 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1238 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1239 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1240 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1241 | } |
| 1242 | |
| 1243 | /* Set link-local address for shared network peer. */ |
| 1244 | else if (rsclient->shared_network |
| 1245 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1246 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1247 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1248 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1249 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1250 | } |
| 1251 | |
| 1252 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1253 | attre->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1254 | } |
| 1255 | |
| 1256 | } |
| 1257 | #endif /* HAVE_IPV6 */ |
| 1258 | |
| 1259 | |
| 1260 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1261 | if (rsclient->sort == BGP_PEER_EBGP |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1262 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1263 | && aspath_private_as_check (attr->aspath)) |
| 1264 | attr->aspath = aspath_empty_get (); |
| 1265 | |
| 1266 | /* Route map & unsuppress-map apply. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1267 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1268 | { |
| 1269 | info.peer = rsclient; |
| 1270 | info.attr = attr; |
| 1271 | |
| 1272 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1273 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1274 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1275 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1276 | else |
| 1277 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1278 | |
| 1279 | rsclient->rmap_type = 0; |
| 1280 | |
| 1281 | if (ret == RMAP_DENYMATCH) |
| 1282 | { |
| 1283 | bgp_attr_flush (attr); |
| 1284 | return 0; |
| 1285 | } |
| 1286 | } |
| 1287 | |
| 1288 | return 1; |
| 1289 | } |
| 1290 | |
| 1291 | struct bgp_info_pair |
| 1292 | { |
| 1293 | struct bgp_info *old; |
| 1294 | struct bgp_info *new; |
| 1295 | }; |
| 1296 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1297 | static void |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1298 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
| 1299 | struct bgp_maxpaths_cfg *mpath_cfg, |
| 1300 | struct bgp_info_pair *result) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1301 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1302 | struct bgp_info *new_select; |
| 1303 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1304 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1305 | struct bgp_info *ri1; |
| 1306 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1307 | struct bgp_info *nextri = NULL; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1308 | int paths_eq, do_mpath; |
| 1309 | struct list mp_list; |
| 1310 | |
| 1311 | bgp_mp_list_init (&mp_list); |
| 1312 | do_mpath = (mpath_cfg->maxpaths_ebgp != BGP_DEFAULT_MAXPATHS || |
| 1313 | mpath_cfg->maxpaths_ibgp != BGP_DEFAULT_MAXPATHS); |
| 1314 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1315 | /* bgp deterministic-med */ |
| 1316 | new_select = NULL; |
| 1317 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1318 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1319 | { |
| 1320 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1321 | continue; |
| 1322 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1323 | continue; |
| 1324 | |
| 1325 | new_select = ri1; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1326 | if (do_mpath) |
| 1327 | bgp_mp_list_add (&mp_list, ri1); |
| 1328 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1329 | if (ri1->next) |
| 1330 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1331 | { |
| 1332 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1333 | continue; |
| 1334 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1335 | continue; |
| 1336 | |
| 1337 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1338 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1339 | ri2->attr->aspath)) |
| 1340 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1341 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
| 1342 | old_select = ri2; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1343 | if (bgp_info_cmp (bgp, ri2, new_select, &paths_eq)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1344 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1345 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1346 | new_select = ri2; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1347 | if (do_mpath && !paths_eq) |
| 1348 | { |
| 1349 | bgp_mp_list_clear (&mp_list); |
| 1350 | bgp_mp_list_add (&mp_list, ri2); |
| 1351 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1352 | } |
| 1353 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1354 | if (do_mpath && paths_eq) |
| 1355 | bgp_mp_list_add (&mp_list, ri2); |
| 1356 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1357 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1358 | } |
| 1359 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1360 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1361 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1362 | |
| 1363 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); |
| 1364 | bgp_mp_list_clear (&mp_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1365 | } |
| 1366 | |
| 1367 | /* Check old selected route and new selected route. */ |
| 1368 | old_select = NULL; |
| 1369 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1370 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1371 | { |
| 1372 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1373 | old_select = ri; |
| 1374 | |
| 1375 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1376 | { |
| 1377 | /* reap REMOVED routes, if needs be |
| 1378 | * selected route must stay for a while longer though |
| 1379 | */ |
| 1380 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1381 | && (ri != old_select)) |
| 1382 | bgp_info_reap (rn, ri); |
| 1383 | |
| 1384 | continue; |
| 1385 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1386 | |
| 1387 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1388 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1389 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1390 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1391 | continue; |
| 1392 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1393 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1394 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1395 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1396 | if (bgp_info_cmp (bgp, ri, new_select, &paths_eq)) |
| 1397 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1398 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1399 | bgp_mp_dmed_deselect (new_select); |
| 1400 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1401 | new_select = ri; |
| 1402 | |
| 1403 | if (do_mpath && !paths_eq) |
| 1404 | { |
| 1405 | bgp_mp_list_clear (&mp_list); |
| 1406 | bgp_mp_list_add (&mp_list, ri); |
| 1407 | } |
| 1408 | } |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1409 | else if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1410 | bgp_mp_dmed_deselect (ri); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1411 | |
| 1412 | if (do_mpath && paths_eq) |
| 1413 | bgp_mp_list_add (&mp_list, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1414 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1415 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1416 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1417 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1418 | 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] | 1419 | |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1420 | bgp_info_mpath_aggregate_update (new_select, old_select); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1421 | bgp_mp_list_clear (&mp_list); |
| 1422 | |
| 1423 | result->old = old_select; |
| 1424 | result->new = new_select; |
| 1425 | |
| 1426 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1427 | } |
| 1428 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1429 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1430 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1431 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1432 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1433 | struct prefix *p; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1434 | struct attr attr; |
| 1435 | struct attr_extra extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1436 | |
| 1437 | p = &rn->p; |
| 1438 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1439 | /* Announce route to Established peer. */ |
| 1440 | if (peer->status != Established) |
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 | /* Address family configuration check. */ |
| 1444 | if (! peer->afc_nego[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1445 | return 0; |
| 1446 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1447 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1448 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1449 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1450 | return 0; |
| 1451 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1452 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 1453 | attr.extra = &extra; |
| 1454 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1455 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1456 | { |
| 1457 | case BGP_TABLE_MAIN: |
| 1458 | /* Announcement to peer->conf. If the route is filtered, |
| 1459 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1460 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
| 1461 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1462 | else |
| 1463 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1464 | break; |
| 1465 | case BGP_TABLE_RSCLIENT: |
| 1466 | /* Announcement to peer->conf. If the route is filtered, |
| 1467 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1468 | if (selected && |
| 1469 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) |
| 1470 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
| 1471 | else |
| 1472 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1473 | break; |
| 1474 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1475 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1476 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1477 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1478 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1479 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1480 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1481 | struct bgp *bgp; |
| 1482 | struct bgp_node *rn; |
| 1483 | afi_t afi; |
| 1484 | safi_t safi; |
| 1485 | }; |
| 1486 | |
| 1487 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1488 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1489 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1490 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1491 | struct bgp *bgp = pq->bgp; |
| 1492 | struct bgp_node *rn = pq->rn; |
| 1493 | afi_t afi = pq->afi; |
| 1494 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1495 | struct bgp_info *new_select; |
| 1496 | struct bgp_info *old_select; |
| 1497 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1498 | struct listnode *node, *nnode; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1499 | struct peer *rsclient = bgp_node_table (rn)->owner; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1500 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1501 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1502 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1503 | new_select = old_and_new.new; |
| 1504 | old_select = old_and_new.old; |
| 1505 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1506 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1507 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1508 | if (rsclient->group) |
| 1509 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1510 | { |
| 1511 | /* Nothing to do. */ |
| 1512 | if (old_select && old_select == new_select) |
| 1513 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1514 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1515 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1516 | if (old_select) |
| 1517 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
| 1518 | if (new_select) |
| 1519 | { |
| 1520 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1521 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1522 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
| 1523 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1524 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1525 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1526 | afi, safi); |
| 1527 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1528 | } |
| 1529 | else |
| 1530 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1531 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1532 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1533 | if (new_select) |
| 1534 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1535 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1536 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1537 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1538 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1539 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1540 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1541 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1542 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1543 | bgp_info_reap (rn, old_select); |
| 1544 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1545 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1546 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1547 | } |
| 1548 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1549 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1550 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1551 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1552 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1553 | struct bgp *bgp = pq->bgp; |
| 1554 | struct bgp_node *rn = pq->rn; |
| 1555 | afi_t afi = pq->afi; |
| 1556 | safi_t safi = pq->safi; |
| 1557 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1558 | struct bgp_info *new_select; |
| 1559 | struct bgp_info *old_select; |
| 1560 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1561 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1562 | struct peer *peer; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1563 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1564 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1565 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1566 | old_select = old_and_new.old; |
| 1567 | new_select = old_and_new.new; |
| 1568 | |
| 1569 | /* Nothing to do. */ |
| 1570 | if (old_select && old_select == new_select) |
| 1571 | { |
| 1572 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
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 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
| 1575 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1576 | bgp_zebra_announce (p, old_select, bgp, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1577 | |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1578 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1579 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1580 | return WQ_SUCCESS; |
| 1581 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1582 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1583 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1584 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1585 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1586 | if (new_select) |
| 1587 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1588 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1589 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1590 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1591 | } |
| 1592 | |
| 1593 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1594 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1595 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1596 | { |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1597 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1598 | } |
| 1599 | |
| 1600 | /* FIB update. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1601 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
| 1602 | ! bgp_option_check (BGP_OPT_NO_FIB))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1603 | { |
| 1604 | if (new_select |
| 1605 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1606 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1607 | bgp_zebra_announce (p, new_select, bgp, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1608 | else |
| 1609 | { |
| 1610 | /* Withdraw the route from the kernel. */ |
| 1611 | if (old_select |
| 1612 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1613 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1614 | bgp_zebra_withdraw (p, old_select, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1615 | } |
| 1616 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1617 | |
| 1618 | /* Reap old select bgp_info, it it has been removed */ |
| 1619 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1620 | bgp_info_reap (rn, old_select); |
| 1621 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1622 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1623 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1624 | } |
| 1625 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1626 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1627 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1628 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1629 | struct bgp_process_queue *pq = data; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1630 | struct bgp_table *table = bgp_node_table (pq->rn); |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1631 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1632 | bgp_unlock (pq->bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1633 | bgp_unlock_node (pq->rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1634 | bgp_table_unlock (table); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1635 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1636 | } |
| 1637 | |
| 1638 | static void |
| 1639 | bgp_process_queue_init (void) |
| 1640 | { |
| 1641 | bm->process_main_queue |
| 1642 | = work_queue_new (bm->master, "process_main_queue"); |
| 1643 | bm->process_rsclient_queue |
| 1644 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1645 | |
| 1646 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1647 | { |
| 1648 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1649 | exit (1); |
| 1650 | } |
| 1651 | |
| 1652 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1653 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1654 | bm->process_main_queue->spec.max_retries = 0; |
| 1655 | bm->process_main_queue->spec.hold = 50; |
| 1656 | |
| 1657 | memcpy (bm->process_rsclient_queue, bm->process_main_queue, |
| 1658 | sizeof (struct work_queue *)); |
| 1659 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1660 | } |
| 1661 | |
| 1662 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1663 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1664 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1665 | struct bgp_process_queue *pqnode; |
| 1666 | |
| 1667 | /* already scheduled for processing? */ |
| 1668 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1669 | return; |
| 1670 | |
| 1671 | if ( (bm->process_main_queue == NULL) || |
| 1672 | (bm->process_rsclient_queue == NULL) ) |
| 1673 | bgp_process_queue_init (); |
| 1674 | |
| 1675 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1676 | sizeof (struct bgp_process_queue)); |
| 1677 | if (!pqnode) |
| 1678 | return; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1679 | |
| 1680 | /* all unlocked in bgp_processq_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1681 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1682 | pqnode->rn = bgp_lock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1683 | pqnode->bgp = bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1684 | bgp_lock (bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1685 | pqnode->afi = afi; |
| 1686 | pqnode->safi = safi; |
| 1687 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1688 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1689 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1690 | case BGP_TABLE_MAIN: |
| 1691 | work_queue_add (bm->process_main_queue, pqnode); |
| 1692 | break; |
| 1693 | case BGP_TABLE_RSCLIENT: |
| 1694 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1695 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1696 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1697 | |
| 1698 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1699 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1700 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1701 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1702 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1703 | { |
| 1704 | struct peer *peer; |
| 1705 | |
| 1706 | peer = THREAD_ARG (thread); |
| 1707 | peer->t_pmax_restart = NULL; |
| 1708 | |
| 1709 | if (BGP_DEBUG (events, EVENTS)) |
| 1710 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1711 | peer->host); |
| 1712 | |
| 1713 | peer_clear (peer); |
| 1714 | |
| 1715 | return 0; |
| 1716 | } |
| 1717 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1718 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1719 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1720 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1721 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1722 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1723 | return 0; |
| 1724 | |
| 1725 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1726 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1727 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1728 | && ! always) |
| 1729 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1730 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1731 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1732 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1733 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1734 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1735 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1736 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1737 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1738 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1739 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1740 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1741 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1742 | |
| 1743 | if (safi == SAFI_MPLS_VPN) |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 1744 | safi = SAFI_MPLS_LABELED_VPN; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1745 | |
| 1746 | ndata[0] = (afi >> 8); |
| 1747 | ndata[1] = afi; |
| 1748 | ndata[2] = safi; |
| 1749 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1750 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1751 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1752 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1753 | |
| 1754 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1755 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1756 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1757 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1758 | |
| 1759 | /* restart timer start */ |
| 1760 | if (peer->pmax_restart[afi][safi]) |
| 1761 | { |
| 1762 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1763 | |
| 1764 | if (BGP_DEBUG (events, EVENTS)) |
| 1765 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1766 | peer->host, peer->v_pmax_restart); |
| 1767 | |
| 1768 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1769 | peer->v_pmax_restart); |
| 1770 | } |
| 1771 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1772 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1773 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1774 | else |
| 1775 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1776 | |
| 1777 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1778 | { |
| 1779 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1780 | && ! always) |
| 1781 | return 0; |
| 1782 | |
| 1783 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1784 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1785 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1786 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1787 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1788 | } |
| 1789 | else |
| 1790 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1791 | return 0; |
| 1792 | } |
| 1793 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1794 | /* Unconditionally remove the route from the RIB, without taking |
| 1795 | * damping into consideration (eg, because the session went down) |
| 1796 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1797 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1798 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1799 | afi_t afi, safi_t safi) |
| 1800 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1801 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1802 | |
| 1803 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1804 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1805 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1806 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1807 | } |
| 1808 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1809 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1810 | 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] | 1811 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1812 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1813 | int status = BGP_DAMP_NONE; |
| 1814 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1815 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1816 | * the bgp_info in the RIB for historical reference. |
| 1817 | */ |
| 1818 | 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] | 1819 | && peer->sort == BGP_PEER_EBGP) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1820 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1821 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1822 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1823 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1824 | return; |
| 1825 | } |
| 1826 | |
| 1827 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1828 | } |
| 1829 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1830 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1831 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1832 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1833 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1834 | { |
| 1835 | struct bgp_node *rn; |
| 1836 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1837 | struct attr new_attr; |
| 1838 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1839 | struct attr *attr_new; |
| 1840 | struct attr *attr_new2; |
| 1841 | struct bgp_info *ri; |
| 1842 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1843 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1844 | char buf[SU_ADDRSTRLEN]; |
| 1845 | |
| 1846 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1847 | if (peer == rsclient) |
| 1848 | return; |
| 1849 | |
| 1850 | bgp = peer->bgp; |
| 1851 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1852 | |
| 1853 | /* Check previously received route. */ |
| 1854 | for (ri = rn->info; ri; ri = ri->next) |
| 1855 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1856 | break; |
| 1857 | |
| 1858 | /* AS path loop check. */ |
| 1859 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) |
| 1860 | { |
| 1861 | reason = "as-path contains our own AS;"; |
| 1862 | goto filtered; |
| 1863 | } |
| 1864 | |
| 1865 | /* Route reflector originator ID check. */ |
| 1866 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1867 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1868 | { |
| 1869 | reason = "originator is us;"; |
| 1870 | goto filtered; |
| 1871 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1872 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1873 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1874 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1875 | |
| 1876 | /* Apply export policy. */ |
| 1877 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1878 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1879 | { |
| 1880 | reason = "export-policy;"; |
| 1881 | goto filtered; |
| 1882 | } |
| 1883 | |
| 1884 | attr_new2 = bgp_attr_intern (&new_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1885 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1886 | /* Apply import policy. */ |
| 1887 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1888 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1889 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1890 | |
| 1891 | reason = "import-policy;"; |
| 1892 | goto filtered; |
| 1893 | } |
| 1894 | |
| 1895 | attr_new = bgp_attr_intern (&new_attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1896 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1897 | |
| 1898 | /* IPv4 unicast next hop check. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1899 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1900 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1901 | /* 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] | 1902 | if (new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1903 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1904 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1905 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1906 | |
| 1907 | reason = "martian next-hop;"; |
| 1908 | goto filtered; |
| 1909 | } |
| 1910 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1911 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1912 | /* If the update is implicit withdraw. */ |
| 1913 | if (ri) |
| 1914 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1915 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1916 | |
| 1917 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1918 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1919 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1920 | { |
| 1921 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1922 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1923 | |
| 1924 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1925 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1926 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1927 | peer->host, |
| 1928 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1929 | p->prefixlen, rsclient->host); |
| 1930 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1931 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1932 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1933 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1934 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1935 | } |
| 1936 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1937 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 1938 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 1939 | bgp_info_restore (rn, ri); |
| 1940 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1941 | /* Received Logging. */ |
| 1942 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1943 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1944 | peer->host, |
| 1945 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1946 | p->prefixlen, rsclient->host); |
| 1947 | |
| 1948 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1949 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1950 | |
| 1951 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1952 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1953 | ri->attr = attr_new; |
| 1954 | |
| 1955 | /* Update MPLS tag. */ |
| 1956 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1957 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1958 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1959 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1960 | |
| 1961 | /* Process change. */ |
| 1962 | bgp_process (bgp, rn, afi, safi); |
| 1963 | bgp_unlock_node (rn); |
| 1964 | |
| 1965 | return; |
| 1966 | } |
| 1967 | |
| 1968 | /* Received Logging. */ |
| 1969 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1970 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1971 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1972 | peer->host, |
| 1973 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1974 | p->prefixlen, rsclient->host); |
| 1975 | } |
| 1976 | |
| 1977 | /* Make new BGP info. */ |
| 1978 | new = bgp_info_new (); |
| 1979 | new->type = type; |
| 1980 | new->sub_type = sub_type; |
| 1981 | new->peer = peer; |
| 1982 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1983 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1984 | |
| 1985 | /* Update MPLS tag. */ |
| 1986 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1987 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1988 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1989 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1990 | |
| 1991 | /* Register new BGP information. */ |
| 1992 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1993 | |
| 1994 | /* route_node_get lock */ |
| 1995 | bgp_unlock_node (rn); |
| 1996 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1997 | /* Process change. */ |
| 1998 | bgp_process (bgp, rn, afi, safi); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1999 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2000 | return; |
| 2001 | |
| 2002 | filtered: |
| 2003 | |
| 2004 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2005 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2006 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2007 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 2008 | peer->host, |
| 2009 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2010 | p->prefixlen, rsclient->host, reason); |
| 2011 | |
| 2012 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2013 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2014 | |
| 2015 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2016 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2017 | return; |
| 2018 | } |
| 2019 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2020 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2021 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 2022 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 2023 | struct prefix_rd *prd, u_char *tag) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2024 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2025 | struct bgp_node *rn; |
| 2026 | struct bgp_info *ri; |
| 2027 | char buf[SU_ADDRSTRLEN]; |
| 2028 | |
| 2029 | if (rsclient == peer) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2030 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2031 | |
| 2032 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 2033 | |
| 2034 | /* Lookup withdrawn route. */ |
| 2035 | for (ri = rn->info; ri; ri = ri->next) |
| 2036 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2037 | break; |
| 2038 | |
| 2039 | /* Withdraw specified route from routing table. */ |
| 2040 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2041 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2042 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2043 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2044 | "%s Can't find the route %s/%d", peer->host, |
| 2045 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2046 | p->prefixlen); |
| 2047 | |
| 2048 | /* Unlock bgp_node_get() lock. */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2049 | bgp_unlock_node (rn); |
| 2050 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2051 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2052 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2053 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2054 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2055 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2056 | { |
| 2057 | int ret; |
| 2058 | int aspath_loop_count = 0; |
| 2059 | struct bgp_node *rn; |
| 2060 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2061 | struct attr new_attr; |
| 2062 | struct attr_extra new_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2063 | struct attr *attr_new; |
| 2064 | struct bgp_info *ri; |
| 2065 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2066 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2067 | char buf[SU_ADDRSTRLEN]; |
| 2068 | |
| 2069 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2070 | 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] | 2071 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2072 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2073 | Adj-RIBs-In. */ |
Jorge Boncompte [DTI2] | 343aa82 | 2012-05-07 16:53:08 +0000 | [diff] [blame] | 2074 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2075 | && peer != bgp->peer_self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2076 | bgp_adj_in_set (rn, peer, attr); |
| 2077 | |
| 2078 | /* Check previously received route. */ |
| 2079 | for (ri = rn->info; ri; ri = ri->next) |
| 2080 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2081 | break; |
| 2082 | |
| 2083 | /* AS path local-as loop check. */ |
| 2084 | if (peer->change_local_as) |
| 2085 | { |
| 2086 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 2087 | aspath_loop_count = 1; |
| 2088 | |
| 2089 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 2090 | { |
| 2091 | reason = "as-path contains our own AS;"; |
| 2092 | goto filtered; |
| 2093 | } |
| 2094 | } |
| 2095 | |
| 2096 | /* AS path loop check. */ |
| 2097 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 2098 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2099 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2100 | > peer->allowas_in[afi][safi])) |
| 2101 | { |
| 2102 | reason = "as-path contains our own AS;"; |
| 2103 | goto filtered; |
| 2104 | } |
| 2105 | |
| 2106 | /* Route reflector originator ID check. */ |
| 2107 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2108 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2109 | { |
| 2110 | reason = "originator is us;"; |
| 2111 | goto filtered; |
| 2112 | } |
| 2113 | |
| 2114 | /* Route reflector cluster ID check. */ |
| 2115 | if (bgp_cluster_filter (peer, attr)) |
| 2116 | { |
| 2117 | reason = "reflected from the same cluster;"; |
| 2118 | goto filtered; |
| 2119 | } |
| 2120 | |
| 2121 | /* Apply incoming filter. */ |
| 2122 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2123 | { |
| 2124 | reason = "filter;"; |
| 2125 | goto filtered; |
| 2126 | } |
| 2127 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2128 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2129 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2130 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2131 | /* Apply incoming route-map. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2132 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2133 | { |
| 2134 | reason = "route-map;"; |
| 2135 | goto filtered; |
| 2136 | } |
| 2137 | |
| 2138 | /* IPv4 unicast next hop check. */ |
| 2139 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2140 | { |
| 2141 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2142 | discard it. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2143 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 |
Denis Ovsienko | 8e80bdf | 2011-08-05 18:52:52 +0400 | [diff] [blame] | 2144 | && ! bgp_nexthop_onlink (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2145 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2146 | { |
| 2147 | reason = "non-connected next-hop;"; |
| 2148 | goto filtered; |
| 2149 | } |
| 2150 | |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2151 | /* 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] | 2152 | must not be my own address. */ |
Jorge Boncompte [DTI2] | 10f9bf3 | 2012-05-07 16:52:52 +0000 | [diff] [blame] | 2153 | if (new_attr.nexthop.s_addr == 0 |
| 2154 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) |
| 2155 | || bgp_nexthop_self (&new_attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2156 | { |
| 2157 | reason = "martian next-hop;"; |
| 2158 | goto filtered; |
| 2159 | } |
| 2160 | } |
| 2161 | |
| 2162 | attr_new = bgp_attr_intern (&new_attr); |
| 2163 | |
| 2164 | /* If the update is implicit withdraw. */ |
| 2165 | if (ri) |
| 2166 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2167 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2168 | |
| 2169 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2170 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2171 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2172 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2173 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2174 | |
| 2175 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2176 | && peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2177 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2178 | { |
| 2179 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2180 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2181 | peer->host, |
| 2182 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2183 | p->prefixlen); |
| 2184 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2185 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2186 | { |
| 2187 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2188 | bgp_process (bgp, rn, afi, safi); |
| 2189 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2190 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2191 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2192 | { |
| 2193 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2194 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2195 | "%s rcvd %s/%d...duplicate ignored", |
| 2196 | peer->host, |
| 2197 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2198 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2199 | |
| 2200 | /* graceful restart STALE flag unset. */ |
| 2201 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2202 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2203 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2204 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2205 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2206 | } |
| 2207 | |
| 2208 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2209 | bgp_attr_unintern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2210 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2211 | return 0; |
| 2212 | } |
| 2213 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2214 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2215 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2216 | { |
| 2217 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2218 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2219 | peer->host, |
| 2220 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2221 | p->prefixlen); |
| 2222 | bgp_info_restore (rn, ri); |
| 2223 | } |
| 2224 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2225 | /* Received Logging. */ |
| 2226 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2227 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2228 | peer->host, |
| 2229 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2230 | p->prefixlen); |
| 2231 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2232 | /* graceful restart STALE flag unset. */ |
| 2233 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2234 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2235 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2236 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2237 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2238 | |
| 2239 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2240 | * only if update is accepted, they'll increment below. |
| 2241 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2242 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2243 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2244 | /* Update bgp route dampening information. */ |
| 2245 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2246 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2247 | { |
| 2248 | /* This is implicit withdraw so we should update dampening |
| 2249 | information. */ |
| 2250 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2251 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2252 | } |
| 2253 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2254 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2255 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2256 | ri->attr = attr_new; |
| 2257 | |
| 2258 | /* Update MPLS tag. */ |
| 2259 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2260 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2261 | |
| 2262 | /* Update bgp route dampening information. */ |
| 2263 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2264 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2265 | { |
| 2266 | /* Now we do normal update dampening. */ |
| 2267 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2268 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2269 | { |
| 2270 | bgp_unlock_node (rn); |
| 2271 | return 0; |
| 2272 | } |
| 2273 | } |
| 2274 | |
| 2275 | /* Nexthop reachability check. */ |
| 2276 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2277 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2278 | && (peer->sort == BGP_PEER_IBGP |
| 2279 | || peer->sort == BGP_PEER_CONFED |
| 2280 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2281 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2282 | { |
| 2283 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2284 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2285 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2286 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2287 | } |
| 2288 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2289 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2290 | |
| 2291 | /* Process change. */ |
| 2292 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2293 | |
| 2294 | bgp_process (bgp, rn, afi, safi); |
| 2295 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2296 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2297 | return 0; |
| 2298 | } |
| 2299 | |
| 2300 | /* Received Logging. */ |
| 2301 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2302 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2303 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2304 | peer->host, |
| 2305 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2306 | p->prefixlen); |
| 2307 | } |
| 2308 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2309 | /* Make new BGP info. */ |
| 2310 | new = bgp_info_new (); |
| 2311 | new->type = type; |
| 2312 | new->sub_type = sub_type; |
| 2313 | new->peer = peer; |
| 2314 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2315 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2316 | |
| 2317 | /* Update MPLS tag. */ |
| 2318 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2319 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2320 | |
| 2321 | /* Nexthop reachability check. */ |
| 2322 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2323 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2324 | && (peer->sort == BGP_PEER_IBGP |
| 2325 | || peer->sort == BGP_PEER_CONFED |
| 2326 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2327 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2328 | { |
| 2329 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2330 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2331 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2332 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2333 | } |
| 2334 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2335 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2336 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2337 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2338 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2339 | |
| 2340 | /* Register new BGP information. */ |
| 2341 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2342 | |
| 2343 | /* route_node_get lock */ |
| 2344 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2345 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2346 | /* If maximum prefix count is configured and current prefix |
| 2347 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2348 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2349 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2350 | |
| 2351 | /* Process change. */ |
| 2352 | bgp_process (bgp, rn, afi, safi); |
| 2353 | |
| 2354 | return 0; |
| 2355 | |
| 2356 | /* This BGP update is filtered. Log the reason then update BGP |
| 2357 | entry. */ |
| 2358 | filtered: |
| 2359 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2360 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2361 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2362 | peer->host, |
| 2363 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2364 | p->prefixlen, reason); |
| 2365 | |
| 2366 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2367 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2368 | |
| 2369 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2370 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2371 | return 0; |
| 2372 | } |
| 2373 | |
| 2374 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2375 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2376 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2377 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2378 | { |
| 2379 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2380 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2381 | struct bgp *bgp; |
| 2382 | int ret; |
| 2383 | |
| 2384 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2385 | soft_reconfig); |
| 2386 | |
| 2387 | bgp = peer->bgp; |
| 2388 | |
| 2389 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2390 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2391 | { |
| 2392 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2393 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2394 | sub_type, prd, tag); |
| 2395 | } |
| 2396 | |
| 2397 | return ret; |
| 2398 | } |
| 2399 | |
| 2400 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2401 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2402 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2403 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2404 | { |
| 2405 | struct bgp *bgp; |
| 2406 | char buf[SU_ADDRSTRLEN]; |
| 2407 | struct bgp_node *rn; |
| 2408 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2409 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2410 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2411 | |
| 2412 | bgp = peer->bgp; |
| 2413 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2414 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2415 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2416 | { |
| 2417 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2418 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2419 | } |
| 2420 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2421 | /* Logging. */ |
| 2422 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2423 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2424 | peer->host, |
| 2425 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2426 | p->prefixlen); |
| 2427 | |
| 2428 | /* Lookup node. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2429 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2430 | |
| 2431 | /* If peer is soft reconfiguration enabled. Record input packet for |
| 2432 | further calculation. */ |
| 2433 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2434 | && peer != bgp->peer_self) |
| 2435 | bgp_adj_in_unset (rn, peer); |
| 2436 | |
| 2437 | /* Lookup withdrawn route. */ |
| 2438 | for (ri = rn->info; ri; ri = ri->next) |
| 2439 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2440 | break; |
| 2441 | |
| 2442 | /* Withdraw specified route from routing table. */ |
| 2443 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2444 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2445 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2446 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2447 | "%s Can't find the route %s/%d", peer->host, |
| 2448 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2449 | p->prefixlen); |
| 2450 | |
| 2451 | /* Unlock bgp_node_get() lock. */ |
| 2452 | bgp_unlock_node (rn); |
| 2453 | |
| 2454 | return 0; |
| 2455 | } |
| 2456 | |
| 2457 | void |
| 2458 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2459 | { |
| 2460 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 2461 | struct attr attr; |
Jorge Boncompte [DTI2] | 577ac57 | 2012-05-07 16:53:06 +0000 | [diff] [blame] | 2462 | struct aspath *aspath; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2463 | struct prefix p; |
| 2464 | struct bgp_info binfo; |
| 2465 | struct peer *from; |
| 2466 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2467 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2468 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2469 | return; |
| 2470 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2471 | bgp = peer->bgp; |
| 2472 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2473 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2474 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2475 | aspath = attr.aspath; |
| 2476 | attr.local_pref = bgp->default_local_pref; |
| 2477 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2478 | |
| 2479 | if (afi == AFI_IP) |
| 2480 | str2prefix ("0.0.0.0/0", &p); |
| 2481 | #ifdef HAVE_IPV6 |
| 2482 | else if (afi == AFI_IP6) |
| 2483 | { |
Jorge Boncompte [DTI2] | 6182d65 | 2012-05-07 16:53:02 +0000 | [diff] [blame] | 2484 | struct attr_extra *ae = attr.extra; |
| 2485 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2486 | str2prefix ("::/0", &p); |
| 2487 | |
| 2488 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2489 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2490 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2491 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2492 | |
| 2493 | /* If the peer is on shared nextwork and we have link-local |
| 2494 | nexthop set it. */ |
| 2495 | if (peer->shared_network |
| 2496 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2497 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2498 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2499 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2500 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2501 | } |
| 2502 | } |
| 2503 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2504 | |
| 2505 | if (peer->default_rmap[afi][safi].name) |
| 2506 | { |
| 2507 | binfo.peer = bgp->peer_self; |
| 2508 | binfo.attr = &attr; |
| 2509 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2510 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
| 2511 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2512 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
| 2513 | RMAP_BGP, &binfo); |
| 2514 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2515 | bgp->peer_self->rmap_type = 0; |
| 2516 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2517 | if (ret == RMAP_DENYMATCH) |
| 2518 | { |
| 2519 | bgp_attr_flush (&attr); |
| 2520 | withdraw = 1; |
| 2521 | } |
| 2522 | } |
| 2523 | |
| 2524 | if (withdraw) |
| 2525 | { |
| 2526 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2527 | bgp_default_withdraw_send (peer, afi, safi); |
| 2528 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2529 | } |
| 2530 | else |
| 2531 | { |
| 2532 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2533 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2534 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2535 | |
| 2536 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2537 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2538 | } |
| 2539 | |
| 2540 | static void |
| 2541 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2542 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2543 | { |
| 2544 | struct bgp_node *rn; |
| 2545 | struct bgp_info *ri; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2546 | struct attr attr; |
| 2547 | struct attr_extra extra; |
| 2548 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2549 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2550 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2551 | |
| 2552 | if (safi != SAFI_MPLS_VPN |
| 2553 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2554 | bgp_default_originate (peer, afi, safi, 0); |
| 2555 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2556 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 2557 | attr.extra = &extra; |
| 2558 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2559 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2560 | for (ri = rn->info; ri; ri = ri->next) |
| 2561 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2562 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2563 | if ( (rsclient) ? |
| 2564 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2565 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2566 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2567 | else |
| 2568 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2569 | } |
| 2570 | } |
| 2571 | |
| 2572 | void |
| 2573 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2574 | { |
| 2575 | struct bgp_node *rn; |
| 2576 | struct bgp_table *table; |
| 2577 | |
| 2578 | if (peer->status != Established) |
| 2579 | return; |
| 2580 | |
| 2581 | if (! peer->afc_nego[afi][safi]) |
| 2582 | return; |
| 2583 | |
| 2584 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2585 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2586 | return; |
| 2587 | |
| 2588 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2589 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2590 | else |
| 2591 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2592 | rn = bgp_route_next(rn)) |
| 2593 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2594 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2595 | |
| 2596 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2597 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2598 | } |
| 2599 | |
| 2600 | void |
| 2601 | bgp_announce_route_all (struct peer *peer) |
| 2602 | { |
| 2603 | afi_t afi; |
| 2604 | safi_t safi; |
| 2605 | |
| 2606 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2607 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2608 | bgp_announce_route (peer, afi, safi); |
| 2609 | } |
| 2610 | |
| 2611 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2612 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2613 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2614 | { |
| 2615 | struct bgp_node *rn; |
| 2616 | struct bgp_adj_in *ain; |
| 2617 | |
| 2618 | if (! table) |
| 2619 | table = rsclient->bgp->rib[afi][safi]; |
| 2620 | |
| 2621 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2622 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2623 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2624 | struct bgp_info *ri = rn->info; |
| 2625 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2626 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2627 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, |
| 2628 | (bgp_info_extra_get (ri))->tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2629 | } |
| 2630 | } |
| 2631 | |
| 2632 | void |
| 2633 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2634 | { |
| 2635 | struct bgp_table *table; |
| 2636 | struct bgp_node *rn; |
| 2637 | |
| 2638 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2639 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2640 | |
| 2641 | else |
| 2642 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2643 | rn = bgp_route_next (rn)) |
| 2644 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2645 | { |
| 2646 | struct prefix_rd prd; |
| 2647 | prd.family = AF_UNSPEC; |
| 2648 | prd.prefixlen = 64; |
| 2649 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2650 | |
| 2651 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); |
| 2652 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2653 | } |
| 2654 | |
| 2655 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2656 | 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] | 2657 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2658 | { |
| 2659 | int ret; |
| 2660 | struct bgp_node *rn; |
| 2661 | struct bgp_adj_in *ain; |
| 2662 | |
| 2663 | if (! table) |
| 2664 | table = peer->bgp->rib[afi][safi]; |
| 2665 | |
| 2666 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2667 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2668 | { |
| 2669 | if (ain->peer == peer) |
| 2670 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2671 | struct bgp_info *ri = rn->info; |
| 2672 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2673 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2674 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2675 | prd, (bgp_info_extra_get (ri))->tag, 1); |
| 2676 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2677 | if (ret < 0) |
| 2678 | { |
| 2679 | bgp_unlock_node (rn); |
| 2680 | return; |
| 2681 | } |
| 2682 | continue; |
| 2683 | } |
| 2684 | } |
| 2685 | } |
| 2686 | |
| 2687 | void |
| 2688 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2689 | { |
| 2690 | struct bgp_node *rn; |
| 2691 | struct bgp_table *table; |
| 2692 | |
| 2693 | if (peer->status != Established) |
| 2694 | return; |
| 2695 | |
| 2696 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2697 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2698 | else |
| 2699 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2700 | rn = bgp_route_next (rn)) |
| 2701 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2702 | { |
| 2703 | struct prefix_rd prd; |
| 2704 | prd.family = AF_UNSPEC; |
| 2705 | prd.prefixlen = 64; |
| 2706 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2707 | |
| 2708 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); |
| 2709 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2710 | } |
| 2711 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2712 | |
| 2713 | struct bgp_clear_node_queue |
| 2714 | { |
| 2715 | struct bgp_node *rn; |
| 2716 | enum bgp_clear_route_type purpose; |
| 2717 | }; |
| 2718 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2719 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2720 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2721 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2722 | struct bgp_clear_node_queue *cnq = data; |
| 2723 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2724 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2725 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2726 | afi_t afi = bgp_node_table (rn)->afi; |
| 2727 | safi_t safi = bgp_node_table (rn)->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2728 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2729 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2730 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2731 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2732 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2733 | { |
| 2734 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2735 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2736 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2737 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2738 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2739 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2740 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2741 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2742 | break; |
| 2743 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2744 | return WQ_SUCCESS; |
| 2745 | } |
| 2746 | |
| 2747 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2748 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2749 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2750 | struct bgp_clear_node_queue *cnq = data; |
| 2751 | struct bgp_node *rn = cnq->rn; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2752 | struct bgp_table *table = bgp_node_table (rn); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2753 | |
| 2754 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2755 | bgp_table_unlock (table); |
| 2756 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2757 | } |
| 2758 | |
| 2759 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2760 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2761 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2762 | struct peer *peer = wq->spec.data; |
| 2763 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2764 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2765 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2766 | |
| 2767 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2768 | } |
| 2769 | |
| 2770 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2771 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2772 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2773 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2774 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2775 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2776 | #undef CLEAR_QUEUE_NAME_LEN |
| 2777 | |
| 2778 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2779 | { |
| 2780 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2781 | exit (1); |
| 2782 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2783 | peer->clear_node_queue->spec.hold = 10; |
| 2784 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2785 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2786 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2787 | peer->clear_node_queue->spec.max_retries = 0; |
| 2788 | |
| 2789 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2790 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2791 | } |
| 2792 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2793 | static void |
| 2794 | 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] | 2795 | struct bgp_table *table, struct peer *rsclient, |
| 2796 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2797 | { |
| 2798 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2799 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2800 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2801 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2802 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2803 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2804 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2805 | if (! table) |
| 2806 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2807 | |
| 2808 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2809 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2810 | struct bgp_info *ri; |
| 2811 | struct bgp_adj_in *ain; |
| 2812 | struct bgp_adj_out *aout; |
| 2813 | |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2814 | if (rn->info == NULL) |
| 2815 | continue; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2816 | |
| 2817 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2818 | * queued for every clearing peer, regardless of whether it is |
| 2819 | * relevant to the peer at hand. |
| 2820 | * |
| 2821 | * Overview: There are 3 different indices which need to be |
| 2822 | * scrubbed, potentially, when a peer is removed: |
| 2823 | * |
| 2824 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2825 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2826 | * 3 other routes visible by the peer's adj-out index |
| 2827 | * |
| 2828 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2829 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2830 | * adj-outs at our leisure. |
| 2831 | * |
| 2832 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2833 | * invisible via RIB index before peer session is allowed to be |
| 2834 | * brought back up. So one needs to know when such a 'search' is |
| 2835 | * complete. |
| 2836 | * |
| 2837 | * Ideally: |
| 2838 | * |
| 2839 | * - there'd be a single global queue or a single RIB walker |
| 2840 | * - rather than tracking which route_nodes still need to be |
| 2841 | * examined on a peer basis, we'd track which peers still |
| 2842 | * aren't cleared |
| 2843 | * |
| 2844 | * Given that our per-peer prefix-counts now should be reliable, |
| 2845 | * this may actually be achievable. It doesn't seem to be a huge |
| 2846 | * problem at this time, |
| 2847 | */ |
| 2848 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2849 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2850 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2851 | struct bgp_clear_node_queue *cnq; |
| 2852 | |
| 2853 | /* both unlocked in bgp_clear_node_queue_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2854 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2855 | bgp_lock_node (rn); |
| 2856 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2857 | sizeof (struct bgp_clear_node_queue)); |
| 2858 | cnq->rn = rn; |
| 2859 | cnq->purpose = purpose; |
| 2860 | work_queue_add (peer->clear_node_queue, cnq); |
| 2861 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2862 | } |
| 2863 | |
| 2864 | for (ain = rn->adj_in; ain; ain = ain->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2865 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2866 | { |
| 2867 | bgp_adj_in_remove (rn, ain); |
| 2868 | bgp_unlock_node (rn); |
| 2869 | break; |
| 2870 | } |
| 2871 | for (aout = rn->adj_out; aout; aout = aout->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2872 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2873 | { |
| 2874 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2875 | bgp_unlock_node (rn); |
| 2876 | break; |
| 2877 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2878 | } |
| 2879 | return; |
| 2880 | } |
| 2881 | |
| 2882 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2883 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2884 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2885 | { |
| 2886 | struct bgp_node *rn; |
| 2887 | struct bgp_table *table; |
| 2888 | struct peer *rsclient; |
| 2889 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2890 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2891 | if (peer->clear_node_queue == NULL) |
| 2892 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2893 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2894 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 2895 | * Idle until it receives a Clearing_Completed event. This protects |
| 2896 | * against peers which flap faster than we can we clear, which could |
| 2897 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2898 | * |
| 2899 | * a) race with routes from the new session being installed before |
| 2900 | * clear_route_node visits the node (to delete the route of that |
| 2901 | * peer) |
| 2902 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 2903 | * on the process_main queue. Fast-flapping could cause that queue |
| 2904 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2905 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2906 | if (!peer->clear_node_queue->thread) |
| 2907 | peer_lock (peer); /* bgp_clear_node_complete */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2908 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2909 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2910 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2911 | case BGP_CLEAR_ROUTE_NORMAL: |
| 2912 | if (safi != SAFI_MPLS_VPN) |
| 2913 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 2914 | else |
| 2915 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2916 | rn = bgp_route_next (rn)) |
| 2917 | if ((table = rn->info) != NULL) |
| 2918 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 2919 | |
| 2920 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 2921 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 2922 | PEER_FLAG_RSERVER_CLIENT)) |
| 2923 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 2924 | break; |
| 2925 | |
| 2926 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
| 2927 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 2928 | break; |
| 2929 | |
| 2930 | default: |
| 2931 | assert (0); |
| 2932 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2933 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2934 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2935 | /* If no routes were cleared, nothing was added to workqueue, the |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2936 | * completion function won't be run by workqueue code - call it here. |
| 2937 | * XXX: Actually, this assumption doesn't hold, see |
| 2938 | * bgp_clear_route_table(), we queue all non-empty nodes. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2939 | * |
| 2940 | * Additionally, there is a presumption in FSM that clearing is only |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2941 | * really needed if peer state is Established - peers in |
| 2942 | * pre-Established states shouldn't have any route-update state |
| 2943 | * associated with them (in or out). |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2944 | * |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2945 | * We still can get here in pre-Established though, through |
| 2946 | * peer_delete -> bgp_fsm_change_status, so this is a useful sanity |
| 2947 | * check to ensure the assumption above holds. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2948 | * |
| 2949 | * At some future point, this check could be move to the top of the |
| 2950 | * function, and do a quick early-return when state is |
| 2951 | * pre-Established, avoiding above list and table scans. Once we're |
| 2952 | * sure it is safe.. |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2953 | */ |
| 2954 | if (!peer->clear_node_queue->thread) |
| 2955 | bgp_clear_node_complete (peer->clear_node_queue); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2956 | } |
| 2957 | |
| 2958 | void |
| 2959 | bgp_clear_route_all (struct peer *peer) |
| 2960 | { |
| 2961 | afi_t afi; |
| 2962 | safi_t safi; |
| 2963 | |
| 2964 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2965 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2966 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2967 | } |
| 2968 | |
| 2969 | void |
| 2970 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2971 | { |
| 2972 | struct bgp_table *table; |
| 2973 | struct bgp_node *rn; |
| 2974 | struct bgp_adj_in *ain; |
| 2975 | |
| 2976 | table = peer->bgp->rib[afi][safi]; |
| 2977 | |
| 2978 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2979 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 2980 | if (ain->peer == peer) |
| 2981 | { |
| 2982 | bgp_adj_in_remove (rn, ain); |
| 2983 | bgp_unlock_node (rn); |
| 2984 | break; |
| 2985 | } |
| 2986 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2987 | |
| 2988 | void |
| 2989 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2990 | { |
| 2991 | struct bgp_node *rn; |
| 2992 | struct bgp_info *ri; |
| 2993 | struct bgp_table *table; |
| 2994 | |
| 2995 | table = peer->bgp->rib[afi][safi]; |
| 2996 | |
| 2997 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2998 | { |
| 2999 | for (ri = rn->info; ri; ri = ri->next) |
| 3000 | if (ri->peer == peer) |
| 3001 | { |
| 3002 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 3003 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3004 | break; |
| 3005 | } |
| 3006 | } |
| 3007 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3008 | |
| 3009 | /* Delete all kernel routes. */ |
| 3010 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3011 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3012 | { |
| 3013 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3014 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3015 | struct bgp_node *rn; |
| 3016 | struct bgp_table *table; |
| 3017 | struct bgp_info *ri; |
| 3018 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3019 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3020 | { |
| 3021 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 3022 | |
| 3023 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3024 | for (ri = rn->info; ri; ri = ri->next) |
| 3025 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3026 | && ri->type == ZEBRA_ROUTE_BGP |
| 3027 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3028 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3029 | |
| 3030 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 3031 | |
| 3032 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3033 | for (ri = rn->info; ri; ri = ri->next) |
| 3034 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3035 | && ri->type == ZEBRA_ROUTE_BGP |
| 3036 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3037 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3038 | } |
| 3039 | } |
| 3040 | |
| 3041 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3042 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3043 | { |
| 3044 | vty_reset (); |
| 3045 | bgp_zclient_reset (); |
| 3046 | access_list_reset (); |
| 3047 | prefix_list_reset (); |
| 3048 | } |
| 3049 | |
| 3050 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3051 | value. */ |
| 3052 | int |
| 3053 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 3054 | { |
| 3055 | u_char *pnt; |
| 3056 | u_char *lim; |
| 3057 | struct prefix p; |
| 3058 | int psize; |
| 3059 | int ret; |
| 3060 | |
| 3061 | /* Check peer status. */ |
| 3062 | if (peer->status != Established) |
| 3063 | return 0; |
| 3064 | |
| 3065 | pnt = packet->nlri; |
| 3066 | lim = pnt + packet->length; |
| 3067 | |
| 3068 | for (; pnt < lim; pnt += psize) |
| 3069 | { |
| 3070 | /* Clear prefix structure. */ |
| 3071 | memset (&p, 0, sizeof (struct prefix)); |
| 3072 | |
| 3073 | /* Fetch prefix length. */ |
| 3074 | p.prefixlen = *pnt++; |
| 3075 | p.family = afi2family (packet->afi); |
| 3076 | |
| 3077 | /* Already checked in nlri_sanity_check(). We do double check |
| 3078 | here. */ |
| 3079 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 3080 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 3081 | return -1; |
| 3082 | |
| 3083 | /* Packet size overflow check. */ |
| 3084 | psize = PSIZE (p.prefixlen); |
| 3085 | |
| 3086 | /* When packet overflow occur return immediately. */ |
| 3087 | if (pnt + psize > lim) |
| 3088 | return -1; |
| 3089 | |
| 3090 | /* Fetch prefix from NLRI packet. */ |
| 3091 | memcpy (&p.u.prefix, pnt, psize); |
| 3092 | |
| 3093 | /* Check address. */ |
| 3094 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3095 | { |
| 3096 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3097 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3098 | /* |
| 3099 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 3100 | * If a BGP router receives an UPDATE message with a |
| 3101 | * semantically incorrect NLRI field, in which a prefix is |
| 3102 | * semantically incorrect (eg. an unexpected multicast IP |
| 3103 | * address), it should ignore the prefix. |
| 3104 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3105 | zlog (peer->log, LOG_ERR, |
| 3106 | "IPv4 unicast NLRI is multicast address %s", |
| 3107 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3108 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3109 | return -1; |
| 3110 | } |
| 3111 | } |
| 3112 | |
| 3113 | #ifdef HAVE_IPV6 |
| 3114 | /* Check address. */ |
| 3115 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3116 | { |
| 3117 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3118 | { |
| 3119 | char buf[BUFSIZ]; |
| 3120 | |
| 3121 | zlog (peer->log, LOG_WARNING, |
| 3122 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 3123 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3124 | |
| 3125 | continue; |
| 3126 | } |
| 3127 | } |
| 3128 | #endif /* HAVE_IPV6 */ |
| 3129 | |
| 3130 | /* Normal process. */ |
| 3131 | if (attr) |
| 3132 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3133 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3134 | else |
| 3135 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3136 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3137 | |
| 3138 | /* Address family configuration mismatch or maximum-prefix count |
| 3139 | overflow. */ |
| 3140 | if (ret < 0) |
| 3141 | return -1; |
| 3142 | } |
| 3143 | |
| 3144 | /* Packet length consistency check. */ |
| 3145 | if (pnt != lim) |
| 3146 | return -1; |
| 3147 | |
| 3148 | return 0; |
| 3149 | } |
| 3150 | |
| 3151 | /* NLRI encode syntax check routine. */ |
| 3152 | int |
| 3153 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 3154 | bgp_size_t length) |
| 3155 | { |
| 3156 | u_char *end; |
| 3157 | u_char prefixlen; |
| 3158 | int psize; |
| 3159 | |
| 3160 | end = pnt + length; |
| 3161 | |
| 3162 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 3163 | syntactic validity. If the field is syntactically incorrect, |
| 3164 | then the Error Subcode is set to Invalid Network Field. */ |
| 3165 | |
| 3166 | while (pnt < end) |
| 3167 | { |
| 3168 | prefixlen = *pnt++; |
| 3169 | |
| 3170 | /* Prefix length check. */ |
| 3171 | if ((afi == AFI_IP && prefixlen > 32) |
| 3172 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 3173 | { |
| 3174 | plog_err (peer->log, |
| 3175 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 3176 | peer->host, prefixlen); |
| 3177 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3178 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3179 | return -1; |
| 3180 | } |
| 3181 | |
| 3182 | /* Packet size overflow check. */ |
| 3183 | psize = PSIZE (prefixlen); |
| 3184 | |
| 3185 | if (pnt + psize > end) |
| 3186 | { |
| 3187 | plog_err (peer->log, |
| 3188 | "%s [Error] Update packet error" |
| 3189 | " (prefix data overflow prefix size is %d)", |
| 3190 | peer->host, psize); |
| 3191 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3192 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3193 | return -1; |
| 3194 | } |
| 3195 | |
| 3196 | pnt += psize; |
| 3197 | } |
| 3198 | |
| 3199 | /* Packet length consistency check. */ |
| 3200 | if (pnt != end) |
| 3201 | { |
| 3202 | plog_err (peer->log, |
| 3203 | "%s [Error] Update packet error" |
| 3204 | " (prefix length mismatch with total length)", |
| 3205 | peer->host); |
| 3206 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3207 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3208 | return -1; |
| 3209 | } |
| 3210 | return 0; |
| 3211 | } |
| 3212 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3213 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3214 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3215 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3216 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3217 | } |
| 3218 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3219 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3220 | bgp_static_free (struct bgp_static *bgp_static) |
| 3221 | { |
| 3222 | if (bgp_static->rmap.name) |
| 3223 | free (bgp_static->rmap.name); |
| 3224 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3225 | } |
| 3226 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3227 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3228 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3229 | struct prefix *p, afi_t afi, safi_t safi) |
| 3230 | { |
| 3231 | struct bgp_node *rn; |
| 3232 | struct bgp_info *ri; |
| 3233 | |
| 3234 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3235 | |
| 3236 | /* Check selected route and self inserted route. */ |
| 3237 | for (ri = rn->info; ri; ri = ri->next) |
| 3238 | if (ri->peer == bgp->peer_self |
| 3239 | && ri->type == ZEBRA_ROUTE_BGP |
| 3240 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3241 | break; |
| 3242 | |
| 3243 | /* Withdraw static BGP route from routing table. */ |
| 3244 | if (ri) |
| 3245 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3246 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3247 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3248 | } |
| 3249 | |
| 3250 | /* Unlock bgp_node_lookup. */ |
| 3251 | bgp_unlock_node (rn); |
| 3252 | } |
| 3253 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3254 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3255 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3256 | struct bgp_static *bgp_static, |
| 3257 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3258 | { |
| 3259 | struct bgp_node *rn; |
| 3260 | struct bgp_info *ri; |
| 3261 | struct bgp_info *new; |
| 3262 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3263 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3264 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3265 | struct attr new_attr; |
| 3266 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3267 | struct bgp *bgp; |
| 3268 | int ret; |
| 3269 | char buf[SU_ADDRSTRLEN]; |
| 3270 | |
| 3271 | bgp = rsclient->bgp; |
| 3272 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3273 | assert (bgp_static); |
| 3274 | if (!bgp_static) |
| 3275 | return; |
| 3276 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3277 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3278 | |
| 3279 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3280 | |
| 3281 | attr.nexthop = bgp_static->igpnexthop; |
| 3282 | attr.med = bgp_static->igpmetric; |
| 3283 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3284 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3285 | if (bgp_static->atomic) |
| 3286 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3287 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3288 | /* Apply network route-map for export to this rsclient. */ |
| 3289 | if (bgp_static->rmap.name) |
| 3290 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3291 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3292 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3293 | info.attr = &attr_tmp; |
| 3294 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3295 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3296 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3297 | |
| 3298 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3299 | |
| 3300 | rsclient->rmap_type = 0; |
| 3301 | |
| 3302 | if (ret == RMAP_DENYMATCH) |
| 3303 | { |
| 3304 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3305 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3306 | |
| 3307 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3308 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3309 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3310 | bgp_attr_extra_free (&attr); |
| 3311 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3312 | return; |
| 3313 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3314 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3315 | } |
| 3316 | else |
| 3317 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3318 | |
| 3319 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3320 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3321 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3322 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3323 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3324 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3325 | == RMAP_DENY) |
| 3326 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3327 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3328 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3329 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3330 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3331 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3332 | p->prefixlen, rsclient->host); |
| 3333 | |
| 3334 | bgp->peer_self->rmap_type = 0; |
| 3335 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3336 | bgp_attr_unintern (&attr_new); |
| 3337 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3338 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3339 | |
| 3340 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3341 | |
| 3342 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3343 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3344 | |
| 3345 | bgp->peer_self->rmap_type = 0; |
| 3346 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3347 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3348 | attr_new = bgp_attr_intern (&new_attr); |
| 3349 | |
| 3350 | for (ri = rn->info; ri; ri = ri->next) |
| 3351 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3352 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3353 | break; |
| 3354 | |
| 3355 | if (ri) |
| 3356 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3357 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3358 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3359 | { |
| 3360 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3361 | bgp_attr_unintern (&attr_new); |
| 3362 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3363 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3364 | return; |
| 3365 | } |
| 3366 | else |
| 3367 | { |
| 3368 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3369 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3370 | |
| 3371 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3372 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3373 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3374 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3375 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3376 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3377 | |
| 3378 | /* Process change. */ |
| 3379 | bgp_process (bgp, rn, afi, safi); |
| 3380 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3381 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3382 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3383 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3384 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3385 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3386 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3387 | /* Make new BGP info. */ |
| 3388 | new = bgp_info_new (); |
| 3389 | new->type = ZEBRA_ROUTE_BGP; |
| 3390 | new->sub_type = BGP_ROUTE_STATIC; |
| 3391 | new->peer = bgp->peer_self; |
| 3392 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3393 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3394 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3395 | |
| 3396 | /* Register new BGP information. */ |
| 3397 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3398 | |
| 3399 | /* route_node_get lock */ |
| 3400 | bgp_unlock_node (rn); |
| 3401 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3402 | /* Process change. */ |
| 3403 | bgp_process (bgp, rn, afi, safi); |
| 3404 | |
| 3405 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3406 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3407 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3408 | } |
| 3409 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3410 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3411 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3412 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3413 | { |
| 3414 | struct bgp_node *rn; |
| 3415 | struct bgp_info *ri; |
| 3416 | struct bgp_info *new; |
| 3417 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3418 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3419 | struct attr *attr_new; |
| 3420 | int ret; |
| 3421 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3422 | assert (bgp_static); |
| 3423 | if (!bgp_static) |
| 3424 | return; |
| 3425 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3426 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3427 | |
| 3428 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3429 | |
| 3430 | attr.nexthop = bgp_static->igpnexthop; |
| 3431 | attr.med = bgp_static->igpmetric; |
| 3432 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3433 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3434 | if (bgp_static->atomic) |
| 3435 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3436 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3437 | /* Apply route-map. */ |
| 3438 | if (bgp_static->rmap.name) |
| 3439 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3440 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3441 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3442 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3443 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3444 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3445 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3446 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3447 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3448 | bgp->peer_self->rmap_type = 0; |
| 3449 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3450 | if (ret == RMAP_DENYMATCH) |
| 3451 | { |
| 3452 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3453 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3454 | |
| 3455 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3456 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3457 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3458 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3459 | return; |
| 3460 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3461 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3462 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3463 | else |
| 3464 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3465 | |
| 3466 | for (ri = rn->info; ri; ri = ri->next) |
| 3467 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3468 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3469 | break; |
| 3470 | |
| 3471 | if (ri) |
| 3472 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3473 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3474 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3475 | { |
| 3476 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3477 | bgp_attr_unintern (&attr_new); |
| 3478 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3479 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3480 | return; |
| 3481 | } |
| 3482 | else |
| 3483 | { |
| 3484 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3485 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3486 | |
| 3487 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3488 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3489 | bgp_info_restore(rn, ri); |
| 3490 | else |
| 3491 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3492 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3493 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3494 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3495 | |
| 3496 | /* Process change. */ |
| 3497 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3498 | bgp_process (bgp, rn, afi, safi); |
| 3499 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3500 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3501 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3502 | return; |
| 3503 | } |
| 3504 | } |
| 3505 | |
| 3506 | /* Make new BGP info. */ |
| 3507 | new = bgp_info_new (); |
| 3508 | new->type = ZEBRA_ROUTE_BGP; |
| 3509 | new->sub_type = BGP_ROUTE_STATIC; |
| 3510 | new->peer = bgp->peer_self; |
| 3511 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3512 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3513 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3514 | |
| 3515 | /* Aggregate address increment. */ |
| 3516 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3517 | |
| 3518 | /* Register new BGP information. */ |
| 3519 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3520 | |
| 3521 | /* route_node_get lock */ |
| 3522 | bgp_unlock_node (rn); |
| 3523 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3524 | /* Process change. */ |
| 3525 | bgp_process (bgp, rn, afi, safi); |
| 3526 | |
| 3527 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3528 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3529 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3530 | } |
| 3531 | |
| 3532 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3533 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3534 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3535 | { |
| 3536 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3537 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3538 | |
| 3539 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3540 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3541 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3542 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3543 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3544 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3545 | } |
| 3546 | } |
| 3547 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3548 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3549 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3550 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3551 | { |
| 3552 | struct bgp_node *rn; |
| 3553 | struct bgp_info *new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3554 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3555 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3556 | |
| 3557 | /* Make new BGP info. */ |
| 3558 | new = bgp_info_new (); |
| 3559 | new->type = ZEBRA_ROUTE_BGP; |
| 3560 | new->sub_type = BGP_ROUTE_STATIC; |
| 3561 | new->peer = bgp->peer_self; |
| 3562 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 3563 | SET_FLAG (new->flags, BGP_INFO_VALID); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3564 | new->uptime = bgp_clock (); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3565 | new->extra = bgp_info_extra_new(); |
| 3566 | memcpy (new->extra->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3567 | |
| 3568 | /* Aggregate address increment. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3569 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3570 | |
| 3571 | /* Register new BGP information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3572 | bgp_info_add (rn, new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3573 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3574 | /* route_node_get lock */ |
| 3575 | bgp_unlock_node (rn); |
| 3576 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3577 | /* Process change. */ |
| 3578 | bgp_process (bgp, rn, afi, safi); |
| 3579 | } |
| 3580 | |
| 3581 | void |
| 3582 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3583 | safi_t safi) |
| 3584 | { |
| 3585 | struct bgp_node *rn; |
| 3586 | struct bgp_info *ri; |
| 3587 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3588 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3589 | |
| 3590 | /* Check selected route and self inserted route. */ |
| 3591 | for (ri = rn->info; ri; ri = ri->next) |
| 3592 | if (ri->peer == bgp->peer_self |
| 3593 | && ri->type == ZEBRA_ROUTE_BGP |
| 3594 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3595 | break; |
| 3596 | |
| 3597 | /* Withdraw static BGP route from routing table. */ |
| 3598 | if (ri) |
| 3599 | { |
| 3600 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3601 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3602 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3603 | } |
| 3604 | |
| 3605 | /* Unlock bgp_node_lookup. */ |
| 3606 | bgp_unlock_node (rn); |
| 3607 | } |
| 3608 | |
| 3609 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3610 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3611 | { |
| 3612 | struct bgp_static *bgp_static; |
| 3613 | struct bgp *bgp; |
| 3614 | struct bgp_node *rn; |
| 3615 | struct prefix *p; |
| 3616 | |
| 3617 | bgp = rsclient->bgp; |
| 3618 | |
| 3619 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3620 | if ((bgp_static = rn->info) != NULL) |
| 3621 | { |
| 3622 | p = &rn->p; |
| 3623 | |
| 3624 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3625 | afi, safi); |
| 3626 | } |
| 3627 | } |
| 3628 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3629 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3630 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3631 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3632 | { |
| 3633 | struct bgp_node *rn; |
| 3634 | struct bgp_info *ri; |
| 3635 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3636 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3637 | |
| 3638 | /* Check selected route and self inserted route. */ |
| 3639 | for (ri = rn->info; ri; ri = ri->next) |
| 3640 | if (ri->peer == bgp->peer_self |
| 3641 | && ri->type == ZEBRA_ROUTE_BGP |
| 3642 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3643 | break; |
| 3644 | |
| 3645 | /* Withdraw static BGP route from routing table. */ |
| 3646 | if (ri) |
| 3647 | { |
| 3648 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3649 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3650 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3651 | } |
| 3652 | |
| 3653 | /* Unlock bgp_node_lookup. */ |
| 3654 | bgp_unlock_node (rn); |
| 3655 | } |
| 3656 | |
| 3657 | /* Configure static BGP network. When user don't run zebra, static |
| 3658 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3659 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3660 | 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] | 3661 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3662 | { |
| 3663 | int ret; |
| 3664 | struct prefix p; |
| 3665 | struct bgp_static *bgp_static; |
| 3666 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3667 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3668 | |
| 3669 | /* Convert IP prefix string to struct prefix. */ |
| 3670 | ret = str2prefix (ip_str, &p); |
| 3671 | if (! ret) |
| 3672 | { |
| 3673 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3674 | return CMD_WARNING; |
| 3675 | } |
| 3676 | #ifdef HAVE_IPV6 |
| 3677 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3678 | { |
| 3679 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3680 | VTY_NEWLINE); |
| 3681 | return CMD_WARNING; |
| 3682 | } |
| 3683 | #endif /* HAVE_IPV6 */ |
| 3684 | |
| 3685 | apply_mask (&p); |
| 3686 | |
| 3687 | /* Set BGP static route configuration. */ |
| 3688 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3689 | |
| 3690 | if (rn->info) |
| 3691 | { |
| 3692 | /* Configuration change. */ |
| 3693 | bgp_static = rn->info; |
| 3694 | |
| 3695 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3696 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 3697 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3698 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3699 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3700 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3701 | if (rmap) |
| 3702 | { |
| 3703 | if (bgp_static->rmap.name) |
| 3704 | free (bgp_static->rmap.name); |
| 3705 | bgp_static->rmap.name = strdup (rmap); |
| 3706 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3707 | } |
| 3708 | else |
| 3709 | { |
| 3710 | if (bgp_static->rmap.name) |
| 3711 | free (bgp_static->rmap.name); |
| 3712 | bgp_static->rmap.name = NULL; |
| 3713 | bgp_static->rmap.map = NULL; |
| 3714 | bgp_static->valid = 0; |
| 3715 | } |
| 3716 | bgp_unlock_node (rn); |
| 3717 | } |
| 3718 | else |
| 3719 | { |
| 3720 | /* New configuration. */ |
| 3721 | bgp_static = bgp_static_new (); |
| 3722 | bgp_static->backdoor = backdoor; |
| 3723 | bgp_static->valid = 0; |
| 3724 | bgp_static->igpmetric = 0; |
| 3725 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3726 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3727 | if (rmap) |
| 3728 | { |
| 3729 | if (bgp_static->rmap.name) |
| 3730 | free (bgp_static->rmap.name); |
| 3731 | bgp_static->rmap.name = strdup (rmap); |
| 3732 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3733 | } |
| 3734 | rn->info = bgp_static; |
| 3735 | } |
| 3736 | |
| 3737 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3738 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3739 | { |
| 3740 | bgp_static->valid = 1; |
| 3741 | |
| 3742 | if (need_update) |
| 3743 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3744 | |
| 3745 | if (! bgp_static->backdoor) |
| 3746 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3747 | } |
| 3748 | |
| 3749 | return CMD_SUCCESS; |
| 3750 | } |
| 3751 | |
| 3752 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3753 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3754 | 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] | 3755 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3756 | { |
| 3757 | int ret; |
| 3758 | struct prefix p; |
| 3759 | struct bgp_static *bgp_static; |
| 3760 | struct bgp_node *rn; |
| 3761 | |
| 3762 | /* Convert IP prefix string to struct prefix. */ |
| 3763 | ret = str2prefix (ip_str, &p); |
| 3764 | if (! ret) |
| 3765 | { |
| 3766 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3767 | return CMD_WARNING; |
| 3768 | } |
| 3769 | #ifdef HAVE_IPV6 |
| 3770 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3771 | { |
| 3772 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3773 | VTY_NEWLINE); |
| 3774 | return CMD_WARNING; |
| 3775 | } |
| 3776 | #endif /* HAVE_IPV6 */ |
| 3777 | |
| 3778 | apply_mask (&p); |
| 3779 | |
| 3780 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3781 | if (! rn) |
| 3782 | { |
| 3783 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3784 | VTY_NEWLINE); |
| 3785 | return CMD_WARNING; |
| 3786 | } |
| 3787 | |
| 3788 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3789 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3790 | /* Update BGP RIB. */ |
| 3791 | if (! bgp_static->backdoor) |
| 3792 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3793 | |
| 3794 | /* Clear configuration. */ |
| 3795 | bgp_static_free (bgp_static); |
| 3796 | rn->info = NULL; |
| 3797 | bgp_unlock_node (rn); |
| 3798 | bgp_unlock_node (rn); |
| 3799 | |
| 3800 | return CMD_SUCCESS; |
| 3801 | } |
| 3802 | |
| 3803 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3804 | instance. */ |
| 3805 | void |
| 3806 | bgp_static_delete (struct bgp *bgp) |
| 3807 | { |
| 3808 | afi_t afi; |
| 3809 | safi_t safi; |
| 3810 | struct bgp_node *rn; |
| 3811 | struct bgp_node *rm; |
| 3812 | struct bgp_table *table; |
| 3813 | struct bgp_static *bgp_static; |
| 3814 | |
| 3815 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3816 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3817 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3818 | if (rn->info != NULL) |
| 3819 | { |
| 3820 | if (safi == SAFI_MPLS_VPN) |
| 3821 | { |
| 3822 | table = rn->info; |
| 3823 | |
| 3824 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3825 | { |
| 3826 | bgp_static = rn->info; |
| 3827 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3828 | AFI_IP, SAFI_MPLS_VPN, |
| 3829 | (struct prefix_rd *)&rn->p, |
| 3830 | bgp_static->tag); |
| 3831 | bgp_static_free (bgp_static); |
| 3832 | rn->info = NULL; |
| 3833 | bgp_unlock_node (rn); |
| 3834 | } |
| 3835 | } |
| 3836 | else |
| 3837 | { |
| 3838 | bgp_static = rn->info; |
| 3839 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3840 | bgp_static_free (bgp_static); |
| 3841 | rn->info = NULL; |
| 3842 | bgp_unlock_node (rn); |
| 3843 | } |
| 3844 | } |
| 3845 | } |
| 3846 | |
| 3847 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3848 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3849 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3850 | { |
| 3851 | int ret; |
| 3852 | struct prefix p; |
| 3853 | struct prefix_rd prd; |
| 3854 | struct bgp *bgp; |
| 3855 | struct bgp_node *prn; |
| 3856 | struct bgp_node *rn; |
| 3857 | struct bgp_table *table; |
| 3858 | struct bgp_static *bgp_static; |
| 3859 | u_char tag[3]; |
| 3860 | |
| 3861 | bgp = vty->index; |
| 3862 | |
| 3863 | ret = str2prefix (ip_str, &p); |
| 3864 | if (! ret) |
| 3865 | { |
| 3866 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3867 | return CMD_WARNING; |
| 3868 | } |
| 3869 | apply_mask (&p); |
| 3870 | |
| 3871 | ret = str2prefix_rd (rd_str, &prd); |
| 3872 | if (! ret) |
| 3873 | { |
| 3874 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3875 | return CMD_WARNING; |
| 3876 | } |
| 3877 | |
| 3878 | ret = str2tag (tag_str, tag); |
| 3879 | if (! ret) |
| 3880 | { |
| 3881 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3882 | return CMD_WARNING; |
| 3883 | } |
| 3884 | |
| 3885 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3886 | (struct prefix *)&prd); |
| 3887 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3888 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3889 | else |
| 3890 | bgp_unlock_node (prn); |
| 3891 | table = prn->info; |
| 3892 | |
| 3893 | rn = bgp_node_get (table, &p); |
| 3894 | |
| 3895 | if (rn->info) |
| 3896 | { |
| 3897 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3898 | bgp_unlock_node (rn); |
| 3899 | } |
| 3900 | else |
| 3901 | { |
| 3902 | /* New configuration. */ |
| 3903 | bgp_static = bgp_static_new (); |
| 3904 | bgp_static->valid = 1; |
| 3905 | memcpy (bgp_static->tag, tag, 3); |
| 3906 | rn->info = bgp_static; |
| 3907 | |
| 3908 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3909 | } |
| 3910 | |
| 3911 | return CMD_SUCCESS; |
| 3912 | } |
| 3913 | |
| 3914 | /* Configure static BGP network. */ |
| 3915 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3916 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3917 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3918 | { |
| 3919 | int ret; |
| 3920 | struct bgp *bgp; |
| 3921 | struct prefix p; |
| 3922 | struct prefix_rd prd; |
| 3923 | struct bgp_node *prn; |
| 3924 | struct bgp_node *rn; |
| 3925 | struct bgp_table *table; |
| 3926 | struct bgp_static *bgp_static; |
| 3927 | u_char tag[3]; |
| 3928 | |
| 3929 | bgp = vty->index; |
| 3930 | |
| 3931 | /* Convert IP prefix string to struct prefix. */ |
| 3932 | ret = str2prefix (ip_str, &p); |
| 3933 | if (! ret) |
| 3934 | { |
| 3935 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3936 | return CMD_WARNING; |
| 3937 | } |
| 3938 | apply_mask (&p); |
| 3939 | |
| 3940 | ret = str2prefix_rd (rd_str, &prd); |
| 3941 | if (! ret) |
| 3942 | { |
| 3943 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3944 | return CMD_WARNING; |
| 3945 | } |
| 3946 | |
| 3947 | ret = str2tag (tag_str, tag); |
| 3948 | if (! ret) |
| 3949 | { |
| 3950 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3951 | return CMD_WARNING; |
| 3952 | } |
| 3953 | |
| 3954 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3955 | (struct prefix *)&prd); |
| 3956 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3957 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3958 | else |
| 3959 | bgp_unlock_node (prn); |
| 3960 | table = prn->info; |
| 3961 | |
| 3962 | rn = bgp_node_lookup (table, &p); |
| 3963 | |
| 3964 | if (rn) |
| 3965 | { |
| 3966 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3967 | |
| 3968 | bgp_static = rn->info; |
| 3969 | bgp_static_free (bgp_static); |
| 3970 | rn->info = NULL; |
| 3971 | bgp_unlock_node (rn); |
| 3972 | bgp_unlock_node (rn); |
| 3973 | } |
| 3974 | else |
| 3975 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 3976 | |
| 3977 | return CMD_SUCCESS; |
| 3978 | } |
| 3979 | |
| 3980 | DEFUN (bgp_network, |
| 3981 | bgp_network_cmd, |
| 3982 | "network A.B.C.D/M", |
| 3983 | "Specify a network to announce via BGP\n" |
| 3984 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3985 | { |
| 3986 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3987 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3988 | } |
| 3989 | |
| 3990 | DEFUN (bgp_network_route_map, |
| 3991 | bgp_network_route_map_cmd, |
| 3992 | "network A.B.C.D/M route-map WORD", |
| 3993 | "Specify a network to announce via BGP\n" |
| 3994 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3995 | "Route-map to modify the attributes\n" |
| 3996 | "Name of the route map\n") |
| 3997 | { |
| 3998 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3999 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4000 | } |
| 4001 | |
| 4002 | DEFUN (bgp_network_backdoor, |
| 4003 | bgp_network_backdoor_cmd, |
| 4004 | "network A.B.C.D/M backdoor", |
| 4005 | "Specify a network to announce via BGP\n" |
| 4006 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4007 | "Specify a BGP backdoor route\n") |
| 4008 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4009 | 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] | 4010 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4011 | } |
| 4012 | |
| 4013 | DEFUN (bgp_network_mask, |
| 4014 | bgp_network_mask_cmd, |
| 4015 | "network A.B.C.D mask A.B.C.D", |
| 4016 | "Specify a network to announce via BGP\n" |
| 4017 | "Network number\n" |
| 4018 | "Network mask\n" |
| 4019 | "Network mask\n") |
| 4020 | { |
| 4021 | int ret; |
| 4022 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4023 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4024 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4025 | if (! ret) |
| 4026 | { |
| 4027 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4028 | return CMD_WARNING; |
| 4029 | } |
| 4030 | |
| 4031 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4032 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4033 | } |
| 4034 | |
| 4035 | DEFUN (bgp_network_mask_route_map, |
| 4036 | bgp_network_mask_route_map_cmd, |
| 4037 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4038 | "Specify a network to announce via BGP\n" |
| 4039 | "Network number\n" |
| 4040 | "Network mask\n" |
| 4041 | "Network mask\n" |
| 4042 | "Route-map to modify the attributes\n" |
| 4043 | "Name of the route map\n") |
| 4044 | { |
| 4045 | int ret; |
| 4046 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4047 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4048 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4049 | if (! ret) |
| 4050 | { |
| 4051 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4052 | return CMD_WARNING; |
| 4053 | } |
| 4054 | |
| 4055 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4056 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4057 | } |
| 4058 | |
| 4059 | DEFUN (bgp_network_mask_backdoor, |
| 4060 | bgp_network_mask_backdoor_cmd, |
| 4061 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4062 | "Specify a network to announce via BGP\n" |
| 4063 | "Network number\n" |
| 4064 | "Network mask\n" |
| 4065 | "Network mask\n" |
| 4066 | "Specify a BGP backdoor route\n") |
| 4067 | { |
| 4068 | int ret; |
| 4069 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4070 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4071 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4072 | if (! ret) |
| 4073 | { |
| 4074 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4075 | return CMD_WARNING; |
| 4076 | } |
| 4077 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4078 | 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] | 4079 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4080 | } |
| 4081 | |
| 4082 | DEFUN (bgp_network_mask_natural, |
| 4083 | bgp_network_mask_natural_cmd, |
| 4084 | "network A.B.C.D", |
| 4085 | "Specify a network to announce via BGP\n" |
| 4086 | "Network number\n") |
| 4087 | { |
| 4088 | int ret; |
| 4089 | char prefix_str[BUFSIZ]; |
| 4090 | |
| 4091 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4092 | if (! ret) |
| 4093 | { |
| 4094 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4095 | return CMD_WARNING; |
| 4096 | } |
| 4097 | |
| 4098 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4099 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4100 | } |
| 4101 | |
| 4102 | DEFUN (bgp_network_mask_natural_route_map, |
| 4103 | bgp_network_mask_natural_route_map_cmd, |
| 4104 | "network A.B.C.D route-map WORD", |
| 4105 | "Specify a network to announce via BGP\n" |
| 4106 | "Network number\n" |
| 4107 | "Route-map to modify the attributes\n" |
| 4108 | "Name of the route map\n") |
| 4109 | { |
| 4110 | int ret; |
| 4111 | char prefix_str[BUFSIZ]; |
| 4112 | |
| 4113 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4114 | if (! ret) |
| 4115 | { |
| 4116 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4117 | return CMD_WARNING; |
| 4118 | } |
| 4119 | |
| 4120 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4121 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4122 | } |
| 4123 | |
| 4124 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4125 | bgp_network_mask_natural_backdoor_cmd, |
| 4126 | "network A.B.C.D backdoor", |
| 4127 | "Specify a network to announce via BGP\n" |
| 4128 | "Network number\n" |
| 4129 | "Specify a BGP backdoor route\n") |
| 4130 | { |
| 4131 | int ret; |
| 4132 | char prefix_str[BUFSIZ]; |
| 4133 | |
| 4134 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4135 | if (! ret) |
| 4136 | { |
| 4137 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4138 | return CMD_WARNING; |
| 4139 | } |
| 4140 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4141 | 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] | 4142 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4143 | } |
| 4144 | |
| 4145 | DEFUN (no_bgp_network, |
| 4146 | no_bgp_network_cmd, |
| 4147 | "no network A.B.C.D/M", |
| 4148 | NO_STR |
| 4149 | "Specify a network to announce via BGP\n" |
| 4150 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4151 | { |
| 4152 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4153 | bgp_node_safi (vty)); |
| 4154 | } |
| 4155 | |
| 4156 | ALIAS (no_bgp_network, |
| 4157 | no_bgp_network_route_map_cmd, |
| 4158 | "no network A.B.C.D/M route-map WORD", |
| 4159 | NO_STR |
| 4160 | "Specify a network to announce via BGP\n" |
| 4161 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4162 | "Route-map to modify the attributes\n" |
| 4163 | "Name of the route map\n") |
| 4164 | |
| 4165 | ALIAS (no_bgp_network, |
| 4166 | no_bgp_network_backdoor_cmd, |
| 4167 | "no network A.B.C.D/M backdoor", |
| 4168 | NO_STR |
| 4169 | "Specify a network to announce via BGP\n" |
| 4170 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4171 | "Specify a BGP backdoor route\n") |
| 4172 | |
| 4173 | DEFUN (no_bgp_network_mask, |
| 4174 | no_bgp_network_mask_cmd, |
| 4175 | "no network A.B.C.D mask A.B.C.D", |
| 4176 | NO_STR |
| 4177 | "Specify a network to announce via BGP\n" |
| 4178 | "Network number\n" |
| 4179 | "Network mask\n" |
| 4180 | "Network mask\n") |
| 4181 | { |
| 4182 | int ret; |
| 4183 | char prefix_str[BUFSIZ]; |
| 4184 | |
| 4185 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4186 | if (! ret) |
| 4187 | { |
| 4188 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4189 | return CMD_WARNING; |
| 4190 | } |
| 4191 | |
| 4192 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4193 | bgp_node_safi (vty)); |
| 4194 | } |
| 4195 | |
| 4196 | ALIAS (no_bgp_network_mask, |
| 4197 | no_bgp_network_mask_route_map_cmd, |
| 4198 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4199 | NO_STR |
| 4200 | "Specify a network to announce via BGP\n" |
| 4201 | "Network number\n" |
| 4202 | "Network mask\n" |
| 4203 | "Network mask\n" |
| 4204 | "Route-map to modify the attributes\n" |
| 4205 | "Name of the route map\n") |
| 4206 | |
| 4207 | ALIAS (no_bgp_network_mask, |
| 4208 | no_bgp_network_mask_backdoor_cmd, |
| 4209 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4210 | NO_STR |
| 4211 | "Specify a network to announce via BGP\n" |
| 4212 | "Network number\n" |
| 4213 | "Network mask\n" |
| 4214 | "Network mask\n" |
| 4215 | "Specify a BGP backdoor route\n") |
| 4216 | |
| 4217 | DEFUN (no_bgp_network_mask_natural, |
| 4218 | no_bgp_network_mask_natural_cmd, |
| 4219 | "no network A.B.C.D", |
| 4220 | NO_STR |
| 4221 | "Specify a network to announce via BGP\n" |
| 4222 | "Network number\n") |
| 4223 | { |
| 4224 | int ret; |
| 4225 | char prefix_str[BUFSIZ]; |
| 4226 | |
| 4227 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4228 | if (! ret) |
| 4229 | { |
| 4230 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4231 | return CMD_WARNING; |
| 4232 | } |
| 4233 | |
| 4234 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4235 | bgp_node_safi (vty)); |
| 4236 | } |
| 4237 | |
| 4238 | ALIAS (no_bgp_network_mask_natural, |
| 4239 | no_bgp_network_mask_natural_route_map_cmd, |
| 4240 | "no network A.B.C.D route-map WORD", |
| 4241 | NO_STR |
| 4242 | "Specify a network to announce via BGP\n" |
| 4243 | "Network number\n" |
| 4244 | "Route-map to modify the attributes\n" |
| 4245 | "Name of the route map\n") |
| 4246 | |
| 4247 | ALIAS (no_bgp_network_mask_natural, |
| 4248 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4249 | "no network A.B.C.D backdoor", |
| 4250 | NO_STR |
| 4251 | "Specify a network to announce via BGP\n" |
| 4252 | "Network number\n" |
| 4253 | "Specify a BGP backdoor route\n") |
| 4254 | |
| 4255 | #ifdef HAVE_IPV6 |
| 4256 | DEFUN (ipv6_bgp_network, |
| 4257 | ipv6_bgp_network_cmd, |
| 4258 | "network X:X::X:X/M", |
| 4259 | "Specify a network to announce via BGP\n" |
| 4260 | "IPv6 prefix <network>/<length>\n") |
| 4261 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4262 | 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] | 4263 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4264 | } |
| 4265 | |
| 4266 | DEFUN (ipv6_bgp_network_route_map, |
| 4267 | ipv6_bgp_network_route_map_cmd, |
| 4268 | "network X:X::X:X/M route-map WORD", |
| 4269 | "Specify a network to announce via BGP\n" |
| 4270 | "IPv6 prefix <network>/<length>\n" |
| 4271 | "Route-map to modify the attributes\n" |
| 4272 | "Name of the route map\n") |
| 4273 | { |
| 4274 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4275 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4276 | } |
| 4277 | |
| 4278 | DEFUN (no_ipv6_bgp_network, |
| 4279 | no_ipv6_bgp_network_cmd, |
| 4280 | "no network X:X::X:X/M", |
| 4281 | NO_STR |
| 4282 | "Specify a network to announce via BGP\n" |
| 4283 | "IPv6 prefix <network>/<length>\n") |
| 4284 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4285 | 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] | 4286 | } |
| 4287 | |
| 4288 | ALIAS (no_ipv6_bgp_network, |
| 4289 | no_ipv6_bgp_network_route_map_cmd, |
| 4290 | "no network X:X::X:X/M route-map WORD", |
| 4291 | NO_STR |
| 4292 | "Specify a network to announce via BGP\n" |
| 4293 | "IPv6 prefix <network>/<length>\n" |
| 4294 | "Route-map to modify the attributes\n" |
| 4295 | "Name of the route map\n") |
| 4296 | |
| 4297 | ALIAS (ipv6_bgp_network, |
| 4298 | old_ipv6_bgp_network_cmd, |
| 4299 | "ipv6 bgp network X:X::X:X/M", |
| 4300 | IPV6_STR |
| 4301 | BGP_STR |
| 4302 | "Specify a network to announce via BGP\n" |
| 4303 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4304 | |
| 4305 | ALIAS (no_ipv6_bgp_network, |
| 4306 | old_no_ipv6_bgp_network_cmd, |
| 4307 | "no ipv6 bgp network X:X::X:X/M", |
| 4308 | NO_STR |
| 4309 | IPV6_STR |
| 4310 | BGP_STR |
| 4311 | "Specify a network to announce via BGP\n" |
| 4312 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4313 | #endif /* HAVE_IPV6 */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4314 | |
| 4315 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4316 | ALIAS_DEPRECATED (bgp_network, |
| 4317 | bgp_network_ttl_cmd, |
| 4318 | "network A.B.C.D/M pathlimit <0-255>", |
| 4319 | "Specify a network to announce via BGP\n" |
| 4320 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4321 | "AS-Path hopcount limit attribute\n" |
| 4322 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4323 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4324 | bgp_network_backdoor_ttl_cmd, |
| 4325 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4326 | "Specify a network to announce via BGP\n" |
| 4327 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4328 | "Specify a BGP backdoor route\n" |
| 4329 | "AS-Path hopcount limit attribute\n" |
| 4330 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4331 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4332 | bgp_network_mask_ttl_cmd, |
| 4333 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4334 | "Specify a network to announce via BGP\n" |
| 4335 | "Network number\n" |
| 4336 | "Network mask\n" |
| 4337 | "Network mask\n" |
| 4338 | "AS-Path hopcount limit attribute\n" |
| 4339 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4340 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4341 | bgp_network_mask_backdoor_ttl_cmd, |
| 4342 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4343 | "Specify a network to announce via BGP\n" |
| 4344 | "Network number\n" |
| 4345 | "Network mask\n" |
| 4346 | "Network mask\n" |
| 4347 | "Specify a BGP backdoor route\n" |
| 4348 | "AS-Path hopcount limit attribute\n" |
| 4349 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4350 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4351 | bgp_network_mask_natural_ttl_cmd, |
| 4352 | "network A.B.C.D pathlimit <0-255>", |
| 4353 | "Specify a network to announce via BGP\n" |
| 4354 | "Network number\n" |
| 4355 | "AS-Path hopcount limit attribute\n" |
| 4356 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4357 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4358 | bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4359 | "network A.B.C.D backdoor pathlimit (1-255>", |
| 4360 | "Specify a network to announce via BGP\n" |
| 4361 | "Network number\n" |
| 4362 | "Specify a BGP backdoor route\n" |
| 4363 | "AS-Path hopcount limit attribute\n" |
| 4364 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4365 | ALIAS_DEPRECATED (no_bgp_network, |
| 4366 | no_bgp_network_ttl_cmd, |
| 4367 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4368 | NO_STR |
| 4369 | "Specify a network to announce via BGP\n" |
| 4370 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4371 | "AS-Path hopcount limit attribute\n" |
| 4372 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4373 | ALIAS_DEPRECATED (no_bgp_network, |
| 4374 | no_bgp_network_backdoor_ttl_cmd, |
| 4375 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4376 | NO_STR |
| 4377 | "Specify a network to announce via BGP\n" |
| 4378 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4379 | "Specify a BGP backdoor route\n" |
| 4380 | "AS-Path hopcount limit attribute\n" |
| 4381 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4382 | ALIAS_DEPRECATED (no_bgp_network, |
| 4383 | no_bgp_network_mask_ttl_cmd, |
| 4384 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4385 | NO_STR |
| 4386 | "Specify a network to announce via BGP\n" |
| 4387 | "Network number\n" |
| 4388 | "Network mask\n" |
| 4389 | "Network mask\n" |
| 4390 | "AS-Path hopcount limit attribute\n" |
| 4391 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4392 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4393 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4394 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4395 | NO_STR |
| 4396 | "Specify a network to announce via BGP\n" |
| 4397 | "Network number\n" |
| 4398 | "Network mask\n" |
| 4399 | "Network mask\n" |
| 4400 | "Specify a BGP backdoor route\n" |
| 4401 | "AS-Path hopcount limit attribute\n" |
| 4402 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4403 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4404 | no_bgp_network_mask_natural_ttl_cmd, |
| 4405 | "no network A.B.C.D pathlimit <0-255>", |
| 4406 | NO_STR |
| 4407 | "Specify a network to announce via BGP\n" |
| 4408 | "Network number\n" |
| 4409 | "AS-Path hopcount limit attribute\n" |
| 4410 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4411 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4412 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4413 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4414 | NO_STR |
| 4415 | "Specify a network to announce via BGP\n" |
| 4416 | "Network number\n" |
| 4417 | "Specify a BGP backdoor route\n" |
| 4418 | "AS-Path hopcount limit attribute\n" |
| 4419 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4420 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4421 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4422 | ipv6_bgp_network_ttl_cmd, |
| 4423 | "network X:X::X:X/M pathlimit <0-255>", |
| 4424 | "Specify a network to announce via BGP\n" |
| 4425 | "IPv6 prefix <network>/<length>\n" |
| 4426 | "AS-Path hopcount limit attribute\n" |
| 4427 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4428 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4429 | no_ipv6_bgp_network_ttl_cmd, |
| 4430 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4431 | NO_STR |
| 4432 | "Specify a network to announce via BGP\n" |
| 4433 | "IPv6 prefix <network>/<length>\n" |
| 4434 | "AS-Path hopcount limit attribute\n" |
| 4435 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4436 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4437 | |
| 4438 | /* Aggreagete address: |
| 4439 | |
| 4440 | advertise-map Set condition to advertise attribute |
| 4441 | as-set Generate AS set path information |
| 4442 | attribute-map Set attributes of aggregate |
| 4443 | route-map Set parameters of aggregate |
| 4444 | summary-only Filter more specific routes from updates |
| 4445 | suppress-map Conditionally filter more specific routes from updates |
| 4446 | <cr> |
| 4447 | */ |
| 4448 | struct bgp_aggregate |
| 4449 | { |
| 4450 | /* Summary-only flag. */ |
| 4451 | u_char summary_only; |
| 4452 | |
| 4453 | /* AS set generation. */ |
| 4454 | u_char as_set; |
| 4455 | |
| 4456 | /* Route-map for aggregated route. */ |
| 4457 | struct route_map *map; |
| 4458 | |
| 4459 | /* Suppress-count. */ |
| 4460 | unsigned long count; |
| 4461 | |
| 4462 | /* SAFI configuration. */ |
| 4463 | safi_t safi; |
| 4464 | }; |
| 4465 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4466 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4467 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4468 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4469 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4470 | } |
| 4471 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4472 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4473 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4474 | { |
| 4475 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4476 | } |
| 4477 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4478 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4479 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4480 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4481 | struct bgp_aggregate *aggregate) |
| 4482 | { |
| 4483 | struct bgp_table *table; |
| 4484 | struct bgp_node *top; |
| 4485 | struct bgp_node *rn; |
| 4486 | u_char origin; |
| 4487 | struct aspath *aspath = NULL; |
| 4488 | struct aspath *asmerge = NULL; |
| 4489 | struct community *community = NULL; |
| 4490 | struct community *commerge = NULL; |
| 4491 | struct in_addr nexthop; |
| 4492 | u_int32_t med = 0; |
| 4493 | struct bgp_info *ri; |
| 4494 | struct bgp_info *new; |
| 4495 | int first = 1; |
| 4496 | unsigned long match = 0; |
| 4497 | |
| 4498 | /* Record adding route's nexthop and med. */ |
| 4499 | if (rinew) |
| 4500 | { |
| 4501 | nexthop = rinew->attr->nexthop; |
| 4502 | med = rinew->attr->med; |
| 4503 | } |
| 4504 | |
| 4505 | /* ORIGIN attribute: If at least one route among routes that are |
| 4506 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4507 | aggregated route must have the ORIGIN attribute with the value |
| 4508 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4509 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4510 | route must have the origin attribute with the value EGP. In all |
| 4511 | other case the value of the ORIGIN attribute of the aggregated |
| 4512 | route is INTERNAL. */ |
| 4513 | origin = BGP_ORIGIN_IGP; |
| 4514 | |
| 4515 | table = bgp->rib[afi][safi]; |
| 4516 | |
| 4517 | top = bgp_node_get (table, p); |
| 4518 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4519 | if (rn->p.prefixlen > p->prefixlen) |
| 4520 | { |
| 4521 | match = 0; |
| 4522 | |
| 4523 | for (ri = rn->info; ri; ri = ri->next) |
| 4524 | { |
| 4525 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4526 | continue; |
| 4527 | |
| 4528 | if (del && ri == del) |
| 4529 | continue; |
| 4530 | |
| 4531 | if (! rinew && first) |
| 4532 | { |
| 4533 | nexthop = ri->attr->nexthop; |
| 4534 | med = ri->attr->med; |
| 4535 | first = 0; |
| 4536 | } |
| 4537 | |
| 4538 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4539 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4540 | || ri->attr->med != med) |
| 4541 | { |
| 4542 | if (aspath) |
| 4543 | aspath_free (aspath); |
| 4544 | if (community) |
| 4545 | community_free (community); |
| 4546 | bgp_unlock_node (rn); |
| 4547 | bgp_unlock_node (top); |
| 4548 | return; |
| 4549 | } |
| 4550 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4551 | |
| 4552 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4553 | { |
| 4554 | if (aggregate->summary_only) |
| 4555 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4556 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4557 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4558 | match++; |
| 4559 | } |
| 4560 | |
| 4561 | aggregate->count++; |
| 4562 | |
| 4563 | if (aggregate->as_set) |
| 4564 | { |
| 4565 | if (origin < ri->attr->origin) |
| 4566 | origin = ri->attr->origin; |
| 4567 | |
| 4568 | if (aspath) |
| 4569 | { |
| 4570 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4571 | aspath_free (aspath); |
| 4572 | aspath = asmerge; |
| 4573 | } |
| 4574 | else |
| 4575 | aspath = aspath_dup (ri->attr->aspath); |
| 4576 | |
| 4577 | if (ri->attr->community) |
| 4578 | { |
| 4579 | if (community) |
| 4580 | { |
| 4581 | commerge = community_merge (community, |
| 4582 | ri->attr->community); |
| 4583 | community = community_uniq_sort (commerge); |
| 4584 | community_free (commerge); |
| 4585 | } |
| 4586 | else |
| 4587 | community = community_dup (ri->attr->community); |
| 4588 | } |
| 4589 | } |
| 4590 | } |
| 4591 | } |
| 4592 | if (match) |
| 4593 | bgp_process (bgp, rn, afi, safi); |
| 4594 | } |
| 4595 | bgp_unlock_node (top); |
| 4596 | |
| 4597 | if (rinew) |
| 4598 | { |
| 4599 | aggregate->count++; |
| 4600 | |
| 4601 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4602 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4603 | |
| 4604 | if (aggregate->as_set) |
| 4605 | { |
| 4606 | if (origin < rinew->attr->origin) |
| 4607 | origin = rinew->attr->origin; |
| 4608 | |
| 4609 | if (aspath) |
| 4610 | { |
| 4611 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4612 | aspath_free (aspath); |
| 4613 | aspath = asmerge; |
| 4614 | } |
| 4615 | else |
| 4616 | aspath = aspath_dup (rinew->attr->aspath); |
| 4617 | |
| 4618 | if (rinew->attr->community) |
| 4619 | { |
| 4620 | if (community) |
| 4621 | { |
| 4622 | commerge = community_merge (community, |
| 4623 | rinew->attr->community); |
| 4624 | community = community_uniq_sort (commerge); |
| 4625 | community_free (commerge); |
| 4626 | } |
| 4627 | else |
| 4628 | community = community_dup (rinew->attr->community); |
| 4629 | } |
| 4630 | } |
| 4631 | } |
| 4632 | |
| 4633 | if (aggregate->count > 0) |
| 4634 | { |
| 4635 | rn = bgp_node_get (table, p); |
| 4636 | new = bgp_info_new (); |
| 4637 | new->type = ZEBRA_ROUTE_BGP; |
| 4638 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4639 | new->peer = bgp->peer_self; |
| 4640 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4641 | 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] | 4642 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4643 | |
| 4644 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4645 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4646 | bgp_process (bgp, rn, afi, safi); |
| 4647 | } |
| 4648 | else |
| 4649 | { |
| 4650 | if (aspath) |
| 4651 | aspath_free (aspath); |
| 4652 | if (community) |
| 4653 | community_free (community); |
| 4654 | } |
| 4655 | } |
| 4656 | |
| 4657 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4658 | struct bgp_aggregate *); |
| 4659 | |
| 4660 | void |
| 4661 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4662 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4663 | { |
| 4664 | struct bgp_node *child; |
| 4665 | struct bgp_node *rn; |
| 4666 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4667 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4668 | |
| 4669 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4670 | if (safi == SAFI_MPLS_VPN) |
| 4671 | return; |
| 4672 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4673 | table = bgp->aggregate[afi][safi]; |
| 4674 | |
| 4675 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4676 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4677 | return; |
| 4678 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4679 | if (p->prefixlen == 0) |
| 4680 | return; |
| 4681 | |
| 4682 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4683 | return; |
| 4684 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4685 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4686 | |
| 4687 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4688 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4689 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4690 | { |
| 4691 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4692 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4693 | } |
| 4694 | bgp_unlock_node (child); |
| 4695 | } |
| 4696 | |
| 4697 | void |
| 4698 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4699 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4700 | { |
| 4701 | struct bgp_node *child; |
| 4702 | struct bgp_node *rn; |
| 4703 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4704 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4705 | |
| 4706 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4707 | if (safi == SAFI_MPLS_VPN) |
| 4708 | return; |
| 4709 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4710 | table = bgp->aggregate[afi][safi]; |
| 4711 | |
| 4712 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4713 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4714 | return; |
| 4715 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4716 | if (p->prefixlen == 0) |
| 4717 | return; |
| 4718 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4719 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4720 | |
| 4721 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4722 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4723 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4724 | { |
| 4725 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4726 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4727 | } |
| 4728 | bgp_unlock_node (child); |
| 4729 | } |
| 4730 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4731 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4732 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4733 | struct bgp_aggregate *aggregate) |
| 4734 | { |
| 4735 | struct bgp_table *table; |
| 4736 | struct bgp_node *top; |
| 4737 | struct bgp_node *rn; |
| 4738 | struct bgp_info *new; |
| 4739 | struct bgp_info *ri; |
| 4740 | unsigned long match; |
| 4741 | u_char origin = BGP_ORIGIN_IGP; |
| 4742 | struct aspath *aspath = NULL; |
| 4743 | struct aspath *asmerge = NULL; |
| 4744 | struct community *community = NULL; |
| 4745 | struct community *commerge = NULL; |
| 4746 | |
| 4747 | table = bgp->rib[afi][safi]; |
| 4748 | |
| 4749 | /* Sanity check. */ |
| 4750 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4751 | return; |
| 4752 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4753 | return; |
| 4754 | |
| 4755 | /* If routes exists below this node, generate aggregate routes. */ |
| 4756 | top = bgp_node_get (table, p); |
| 4757 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4758 | if (rn->p.prefixlen > p->prefixlen) |
| 4759 | { |
| 4760 | match = 0; |
| 4761 | |
| 4762 | for (ri = rn->info; ri; ri = ri->next) |
| 4763 | { |
| 4764 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4765 | continue; |
| 4766 | |
| 4767 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4768 | { |
| 4769 | /* summary-only aggregate route suppress aggregated |
| 4770 | route announcement. */ |
| 4771 | if (aggregate->summary_only) |
| 4772 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4773 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4774 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4775 | match++; |
| 4776 | } |
| 4777 | /* as-set aggregate route generate origin, as path, |
| 4778 | community aggregation. */ |
| 4779 | if (aggregate->as_set) |
| 4780 | { |
| 4781 | if (origin < ri->attr->origin) |
| 4782 | origin = ri->attr->origin; |
| 4783 | |
| 4784 | if (aspath) |
| 4785 | { |
| 4786 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4787 | aspath_free (aspath); |
| 4788 | aspath = asmerge; |
| 4789 | } |
| 4790 | else |
| 4791 | aspath = aspath_dup (ri->attr->aspath); |
| 4792 | |
| 4793 | if (ri->attr->community) |
| 4794 | { |
| 4795 | if (community) |
| 4796 | { |
| 4797 | commerge = community_merge (community, |
| 4798 | ri->attr->community); |
| 4799 | community = community_uniq_sort (commerge); |
| 4800 | community_free (commerge); |
| 4801 | } |
| 4802 | else |
| 4803 | community = community_dup (ri->attr->community); |
| 4804 | } |
| 4805 | } |
| 4806 | aggregate->count++; |
| 4807 | } |
| 4808 | } |
| 4809 | |
| 4810 | /* If this node is suppressed, process the change. */ |
| 4811 | if (match) |
| 4812 | bgp_process (bgp, rn, afi, safi); |
| 4813 | } |
| 4814 | bgp_unlock_node (top); |
| 4815 | |
| 4816 | /* Add aggregate route to BGP table. */ |
| 4817 | if (aggregate->count) |
| 4818 | { |
| 4819 | rn = bgp_node_get (table, p); |
| 4820 | |
| 4821 | new = bgp_info_new (); |
| 4822 | new->type = ZEBRA_ROUTE_BGP; |
| 4823 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4824 | new->peer = bgp->peer_self; |
| 4825 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4826 | 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] | 4827 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4828 | |
| 4829 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4830 | bgp_unlock_node (rn); |
| 4831 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4832 | /* Process change. */ |
| 4833 | bgp_process (bgp, rn, afi, safi); |
| 4834 | } |
| 4835 | } |
| 4836 | |
| 4837 | void |
| 4838 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4839 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4840 | { |
| 4841 | struct bgp_table *table; |
| 4842 | struct bgp_node *top; |
| 4843 | struct bgp_node *rn; |
| 4844 | struct bgp_info *ri; |
| 4845 | unsigned long match; |
| 4846 | |
| 4847 | table = bgp->rib[afi][safi]; |
| 4848 | |
| 4849 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4850 | return; |
| 4851 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4852 | return; |
| 4853 | |
| 4854 | /* If routes exists below this node, generate aggregate routes. */ |
| 4855 | top = bgp_node_get (table, p); |
| 4856 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4857 | if (rn->p.prefixlen > p->prefixlen) |
| 4858 | { |
| 4859 | match = 0; |
| 4860 | |
| 4861 | for (ri = rn->info; ri; ri = ri->next) |
| 4862 | { |
| 4863 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4864 | continue; |
| 4865 | |
| 4866 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4867 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4868 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4869 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4870 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4871 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4872 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4873 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4874 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4875 | match++; |
| 4876 | } |
| 4877 | } |
| 4878 | aggregate->count--; |
| 4879 | } |
| 4880 | } |
| 4881 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4882 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4883 | if (match) |
| 4884 | bgp_process (bgp, rn, afi, safi); |
| 4885 | } |
| 4886 | bgp_unlock_node (top); |
| 4887 | |
| 4888 | /* Delete aggregate route from BGP table. */ |
| 4889 | rn = bgp_node_get (table, p); |
| 4890 | |
| 4891 | for (ri = rn->info; ri; ri = ri->next) |
| 4892 | if (ri->peer == bgp->peer_self |
| 4893 | && ri->type == ZEBRA_ROUTE_BGP |
| 4894 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4895 | break; |
| 4896 | |
| 4897 | /* Withdraw static BGP route from routing table. */ |
| 4898 | if (ri) |
| 4899 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4900 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4901 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4902 | } |
| 4903 | |
| 4904 | /* Unlock bgp_node_lookup. */ |
| 4905 | bgp_unlock_node (rn); |
| 4906 | } |
| 4907 | |
| 4908 | /* Aggregate route attribute. */ |
| 4909 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4910 | #define AGGREGATE_AS_SET 1 |
| 4911 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4912 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4913 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4914 | afi_t afi, safi_t safi) |
| 4915 | { |
| 4916 | int ret; |
| 4917 | struct prefix p; |
| 4918 | struct bgp_node *rn; |
| 4919 | struct bgp *bgp; |
| 4920 | struct bgp_aggregate *aggregate; |
| 4921 | |
| 4922 | /* Convert string to prefix structure. */ |
| 4923 | ret = str2prefix (prefix_str, &p); |
| 4924 | if (!ret) |
| 4925 | { |
| 4926 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4927 | return CMD_WARNING; |
| 4928 | } |
| 4929 | apply_mask (&p); |
| 4930 | |
| 4931 | /* Get BGP structure. */ |
| 4932 | bgp = vty->index; |
| 4933 | |
| 4934 | /* Old configuration check. */ |
| 4935 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4936 | if (! rn) |
| 4937 | { |
| 4938 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4939 | VTY_NEWLINE); |
| 4940 | return CMD_WARNING; |
| 4941 | } |
| 4942 | |
| 4943 | aggregate = rn->info; |
| 4944 | if (aggregate->safi & SAFI_UNICAST) |
| 4945 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4946 | if (aggregate->safi & SAFI_MULTICAST) |
| 4947 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4948 | |
| 4949 | /* Unlock aggregate address configuration. */ |
| 4950 | rn->info = NULL; |
| 4951 | bgp_aggregate_free (aggregate); |
| 4952 | bgp_unlock_node (rn); |
| 4953 | bgp_unlock_node (rn); |
| 4954 | |
| 4955 | return CMD_SUCCESS; |
| 4956 | } |
| 4957 | |
| 4958 | static int |
| 4959 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4960 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4961 | u_char summary_only, u_char as_set) |
| 4962 | { |
| 4963 | int ret; |
| 4964 | struct prefix p; |
| 4965 | struct bgp_node *rn; |
| 4966 | struct bgp *bgp; |
| 4967 | struct bgp_aggregate *aggregate; |
| 4968 | |
| 4969 | /* Convert string to prefix structure. */ |
| 4970 | ret = str2prefix (prefix_str, &p); |
| 4971 | if (!ret) |
| 4972 | { |
| 4973 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4974 | return CMD_WARNING; |
| 4975 | } |
| 4976 | apply_mask (&p); |
| 4977 | |
| 4978 | /* Get BGP structure. */ |
| 4979 | bgp = vty->index; |
| 4980 | |
| 4981 | /* Old configuration check. */ |
| 4982 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 4983 | |
| 4984 | if (rn->info) |
| 4985 | { |
| 4986 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 4987 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4988 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 4989 | if (ret) |
| 4990 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 4991 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 4992 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4993 | return CMD_WARNING; |
| 4994 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4995 | } |
| 4996 | |
| 4997 | /* Make aggregate address structure. */ |
| 4998 | aggregate = bgp_aggregate_new (); |
| 4999 | aggregate->summary_only = summary_only; |
| 5000 | aggregate->as_set = as_set; |
| 5001 | aggregate->safi = safi; |
| 5002 | rn->info = aggregate; |
| 5003 | |
| 5004 | /* Aggregate address insert into BGP routing table. */ |
| 5005 | if (safi & SAFI_UNICAST) |
| 5006 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5007 | if (safi & SAFI_MULTICAST) |
| 5008 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5009 | |
| 5010 | return CMD_SUCCESS; |
| 5011 | } |
| 5012 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5013 | DEFUN (aggregate_address, |
| 5014 | aggregate_address_cmd, |
| 5015 | "aggregate-address A.B.C.D/M", |
| 5016 | "Configure BGP aggregate entries\n" |
| 5017 | "Aggregate prefix\n") |
| 5018 | { |
| 5019 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5020 | } |
| 5021 | |
| 5022 | DEFUN (aggregate_address_mask, |
| 5023 | aggregate_address_mask_cmd, |
| 5024 | "aggregate-address A.B.C.D A.B.C.D", |
| 5025 | "Configure BGP aggregate entries\n" |
| 5026 | "Aggregate address\n" |
| 5027 | "Aggregate mask\n") |
| 5028 | { |
| 5029 | int ret; |
| 5030 | char prefix_str[BUFSIZ]; |
| 5031 | |
| 5032 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5033 | |
| 5034 | if (! ret) |
| 5035 | { |
| 5036 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5037 | return CMD_WARNING; |
| 5038 | } |
| 5039 | |
| 5040 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5041 | 0, 0); |
| 5042 | } |
| 5043 | |
| 5044 | DEFUN (aggregate_address_summary_only, |
| 5045 | aggregate_address_summary_only_cmd, |
| 5046 | "aggregate-address A.B.C.D/M summary-only", |
| 5047 | "Configure BGP aggregate entries\n" |
| 5048 | "Aggregate prefix\n" |
| 5049 | "Filter more specific routes from updates\n") |
| 5050 | { |
| 5051 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5052 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5053 | } |
| 5054 | |
| 5055 | DEFUN (aggregate_address_mask_summary_only, |
| 5056 | aggregate_address_mask_summary_only_cmd, |
| 5057 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5058 | "Configure BGP aggregate entries\n" |
| 5059 | "Aggregate address\n" |
| 5060 | "Aggregate mask\n" |
| 5061 | "Filter more specific routes from updates\n") |
| 5062 | { |
| 5063 | int ret; |
| 5064 | char prefix_str[BUFSIZ]; |
| 5065 | |
| 5066 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5067 | |
| 5068 | if (! ret) |
| 5069 | { |
| 5070 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5071 | return CMD_WARNING; |
| 5072 | } |
| 5073 | |
| 5074 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5075 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5076 | } |
| 5077 | |
| 5078 | DEFUN (aggregate_address_as_set, |
| 5079 | aggregate_address_as_set_cmd, |
| 5080 | "aggregate-address A.B.C.D/M as-set", |
| 5081 | "Configure BGP aggregate entries\n" |
| 5082 | "Aggregate prefix\n" |
| 5083 | "Generate AS set path information\n") |
| 5084 | { |
| 5085 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5086 | 0, AGGREGATE_AS_SET); |
| 5087 | } |
| 5088 | |
| 5089 | DEFUN (aggregate_address_mask_as_set, |
| 5090 | aggregate_address_mask_as_set_cmd, |
| 5091 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5092 | "Configure BGP aggregate entries\n" |
| 5093 | "Aggregate address\n" |
| 5094 | "Aggregate mask\n" |
| 5095 | "Generate AS set path information\n") |
| 5096 | { |
| 5097 | int ret; |
| 5098 | char prefix_str[BUFSIZ]; |
| 5099 | |
| 5100 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5101 | |
| 5102 | if (! ret) |
| 5103 | { |
| 5104 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5105 | return CMD_WARNING; |
| 5106 | } |
| 5107 | |
| 5108 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5109 | 0, AGGREGATE_AS_SET); |
| 5110 | } |
| 5111 | |
| 5112 | |
| 5113 | DEFUN (aggregate_address_as_set_summary, |
| 5114 | aggregate_address_as_set_summary_cmd, |
| 5115 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5116 | "Configure BGP aggregate entries\n" |
| 5117 | "Aggregate prefix\n" |
| 5118 | "Generate AS set path information\n" |
| 5119 | "Filter more specific routes from updates\n") |
| 5120 | { |
| 5121 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5122 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5123 | } |
| 5124 | |
| 5125 | ALIAS (aggregate_address_as_set_summary, |
| 5126 | aggregate_address_summary_as_set_cmd, |
| 5127 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5128 | "Configure BGP aggregate entries\n" |
| 5129 | "Aggregate prefix\n" |
| 5130 | "Filter more specific routes from updates\n" |
| 5131 | "Generate AS set path information\n") |
| 5132 | |
| 5133 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5134 | aggregate_address_mask_as_set_summary_cmd, |
| 5135 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5136 | "Configure BGP aggregate entries\n" |
| 5137 | "Aggregate address\n" |
| 5138 | "Aggregate mask\n" |
| 5139 | "Generate AS set path information\n" |
| 5140 | "Filter more specific routes from updates\n") |
| 5141 | { |
| 5142 | int ret; |
| 5143 | char prefix_str[BUFSIZ]; |
| 5144 | |
| 5145 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5146 | |
| 5147 | if (! ret) |
| 5148 | { |
| 5149 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5150 | return CMD_WARNING; |
| 5151 | } |
| 5152 | |
| 5153 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5154 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5155 | } |
| 5156 | |
| 5157 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5158 | aggregate_address_mask_summary_as_set_cmd, |
| 5159 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5160 | "Configure BGP aggregate entries\n" |
| 5161 | "Aggregate address\n" |
| 5162 | "Aggregate mask\n" |
| 5163 | "Filter more specific routes from updates\n" |
| 5164 | "Generate AS set path information\n") |
| 5165 | |
| 5166 | DEFUN (no_aggregate_address, |
| 5167 | no_aggregate_address_cmd, |
| 5168 | "no aggregate-address A.B.C.D/M", |
| 5169 | NO_STR |
| 5170 | "Configure BGP aggregate entries\n" |
| 5171 | "Aggregate prefix\n") |
| 5172 | { |
| 5173 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5174 | } |
| 5175 | |
| 5176 | ALIAS (no_aggregate_address, |
| 5177 | no_aggregate_address_summary_only_cmd, |
| 5178 | "no aggregate-address A.B.C.D/M summary-only", |
| 5179 | NO_STR |
| 5180 | "Configure BGP aggregate entries\n" |
| 5181 | "Aggregate prefix\n" |
| 5182 | "Filter more specific routes from updates\n") |
| 5183 | |
| 5184 | ALIAS (no_aggregate_address, |
| 5185 | no_aggregate_address_as_set_cmd, |
| 5186 | "no aggregate-address A.B.C.D/M as-set", |
| 5187 | NO_STR |
| 5188 | "Configure BGP aggregate entries\n" |
| 5189 | "Aggregate prefix\n" |
| 5190 | "Generate AS set path information\n") |
| 5191 | |
| 5192 | ALIAS (no_aggregate_address, |
| 5193 | no_aggregate_address_as_set_summary_cmd, |
| 5194 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5195 | NO_STR |
| 5196 | "Configure BGP aggregate entries\n" |
| 5197 | "Aggregate prefix\n" |
| 5198 | "Generate AS set path information\n" |
| 5199 | "Filter more specific routes from updates\n") |
| 5200 | |
| 5201 | ALIAS (no_aggregate_address, |
| 5202 | no_aggregate_address_summary_as_set_cmd, |
| 5203 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5204 | NO_STR |
| 5205 | "Configure BGP aggregate entries\n" |
| 5206 | "Aggregate prefix\n" |
| 5207 | "Filter more specific routes from updates\n" |
| 5208 | "Generate AS set path information\n") |
| 5209 | |
| 5210 | DEFUN (no_aggregate_address_mask, |
| 5211 | no_aggregate_address_mask_cmd, |
| 5212 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5213 | NO_STR |
| 5214 | "Configure BGP aggregate entries\n" |
| 5215 | "Aggregate address\n" |
| 5216 | "Aggregate mask\n") |
| 5217 | { |
| 5218 | int ret; |
| 5219 | char prefix_str[BUFSIZ]; |
| 5220 | |
| 5221 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5222 | |
| 5223 | if (! ret) |
| 5224 | { |
| 5225 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5226 | return CMD_WARNING; |
| 5227 | } |
| 5228 | |
| 5229 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5230 | } |
| 5231 | |
| 5232 | ALIAS (no_aggregate_address_mask, |
| 5233 | no_aggregate_address_mask_summary_only_cmd, |
| 5234 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5235 | NO_STR |
| 5236 | "Configure BGP aggregate entries\n" |
| 5237 | "Aggregate address\n" |
| 5238 | "Aggregate mask\n" |
| 5239 | "Filter more specific routes from updates\n") |
| 5240 | |
| 5241 | ALIAS (no_aggregate_address_mask, |
| 5242 | no_aggregate_address_mask_as_set_cmd, |
| 5243 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5244 | NO_STR |
| 5245 | "Configure BGP aggregate entries\n" |
| 5246 | "Aggregate address\n" |
| 5247 | "Aggregate mask\n" |
| 5248 | "Generate AS set path information\n") |
| 5249 | |
| 5250 | ALIAS (no_aggregate_address_mask, |
| 5251 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5252 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5253 | NO_STR |
| 5254 | "Configure BGP aggregate entries\n" |
| 5255 | "Aggregate address\n" |
| 5256 | "Aggregate mask\n" |
| 5257 | "Generate AS set path information\n" |
| 5258 | "Filter more specific routes from updates\n") |
| 5259 | |
| 5260 | ALIAS (no_aggregate_address_mask, |
| 5261 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5262 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5263 | NO_STR |
| 5264 | "Configure BGP aggregate entries\n" |
| 5265 | "Aggregate address\n" |
| 5266 | "Aggregate mask\n" |
| 5267 | "Filter more specific routes from updates\n" |
| 5268 | "Generate AS set path information\n") |
| 5269 | |
| 5270 | #ifdef HAVE_IPV6 |
| 5271 | DEFUN (ipv6_aggregate_address, |
| 5272 | ipv6_aggregate_address_cmd, |
| 5273 | "aggregate-address X:X::X:X/M", |
| 5274 | "Configure BGP aggregate entries\n" |
| 5275 | "Aggregate prefix\n") |
| 5276 | { |
| 5277 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5278 | } |
| 5279 | |
| 5280 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5281 | ipv6_aggregate_address_summary_only_cmd, |
| 5282 | "aggregate-address X:X::X:X/M summary-only", |
| 5283 | "Configure BGP aggregate entries\n" |
| 5284 | "Aggregate prefix\n" |
| 5285 | "Filter more specific routes from updates\n") |
| 5286 | { |
| 5287 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5288 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5289 | } |
| 5290 | |
| 5291 | DEFUN (no_ipv6_aggregate_address, |
| 5292 | no_ipv6_aggregate_address_cmd, |
| 5293 | "no aggregate-address X:X::X:X/M", |
| 5294 | NO_STR |
| 5295 | "Configure BGP aggregate entries\n" |
| 5296 | "Aggregate prefix\n") |
| 5297 | { |
| 5298 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5299 | } |
| 5300 | |
| 5301 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5302 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5303 | "no aggregate-address X:X::X:X/M summary-only", |
| 5304 | NO_STR |
| 5305 | "Configure BGP aggregate entries\n" |
| 5306 | "Aggregate prefix\n" |
| 5307 | "Filter more specific routes from updates\n") |
| 5308 | { |
| 5309 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5310 | } |
| 5311 | |
| 5312 | ALIAS (ipv6_aggregate_address, |
| 5313 | old_ipv6_aggregate_address_cmd, |
| 5314 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5315 | IPV6_STR |
| 5316 | BGP_STR |
| 5317 | "Configure BGP aggregate entries\n" |
| 5318 | "Aggregate prefix\n") |
| 5319 | |
| 5320 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5321 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5322 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5323 | IPV6_STR |
| 5324 | BGP_STR |
| 5325 | "Configure BGP aggregate entries\n" |
| 5326 | "Aggregate prefix\n" |
| 5327 | "Filter more specific routes from updates\n") |
| 5328 | |
| 5329 | ALIAS (no_ipv6_aggregate_address, |
| 5330 | old_no_ipv6_aggregate_address_cmd, |
| 5331 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5332 | NO_STR |
| 5333 | IPV6_STR |
| 5334 | BGP_STR |
| 5335 | "Configure BGP aggregate entries\n" |
| 5336 | "Aggregate prefix\n") |
| 5337 | |
| 5338 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5339 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5340 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5341 | NO_STR |
| 5342 | IPV6_STR |
| 5343 | BGP_STR |
| 5344 | "Configure BGP aggregate entries\n" |
| 5345 | "Aggregate prefix\n" |
| 5346 | "Filter more specific routes from updates\n") |
| 5347 | #endif /* HAVE_IPV6 */ |
| 5348 | |
| 5349 | /* Redistribute route treatment. */ |
| 5350 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5351 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5352 | const struct in6_addr *nexthop6, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5353 | u_int32_t metric, u_char type) |
| 5354 | { |
| 5355 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5356 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5357 | struct bgp_info *new; |
| 5358 | struct bgp_info *bi; |
| 5359 | struct bgp_info info; |
| 5360 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5361 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5362 | struct attr *new_attr; |
| 5363 | afi_t afi; |
| 5364 | int ret; |
| 5365 | |
| 5366 | /* Make default attribute. */ |
| 5367 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5368 | if (nexthop) |
| 5369 | attr.nexthop = *nexthop; |
| 5370 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5371 | #ifdef HAVE_IPV6 |
| 5372 | if (nexthop6) |
| 5373 | { |
| 5374 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5375 | extra->mp_nexthop_global = *nexthop6; |
| 5376 | extra->mp_nexthop_len = 16; |
| 5377 | } |
| 5378 | #endif |
| 5379 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5380 | attr.med = metric; |
| 5381 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5382 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5383 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5384 | { |
| 5385 | afi = family2afi (p->family); |
| 5386 | |
| 5387 | if (bgp->redist[afi][type]) |
| 5388 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5389 | struct attr attr_new; |
| 5390 | struct attr_extra extra_new; |
| 5391 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5392 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5393 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5394 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5395 | |
| 5396 | if (bgp->redist_metric_flag[afi][type]) |
| 5397 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5398 | |
| 5399 | /* Apply route-map. */ |
| 5400 | if (bgp->rmap[afi][type].map) |
| 5401 | { |
| 5402 | info.peer = bgp->peer_self; |
| 5403 | info.attr = &attr_new; |
| 5404 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5405 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5406 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5407 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5408 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5409 | |
| 5410 | bgp->peer_self->rmap_type = 0; |
| 5411 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5412 | if (ret == RMAP_DENYMATCH) |
| 5413 | { |
| 5414 | /* Free uninterned attribute. */ |
| 5415 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5416 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5417 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5418 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5419 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5420 | bgp_redistribute_delete (p, type); |
| 5421 | return; |
| 5422 | } |
| 5423 | } |
| 5424 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5425 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5426 | afi, SAFI_UNICAST, p, NULL); |
| 5427 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5428 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5429 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5430 | for (bi = bn->info; bi; bi = bi->next) |
| 5431 | if (bi->peer == bgp->peer_self |
| 5432 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5433 | break; |
| 5434 | |
| 5435 | if (bi) |
| 5436 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5437 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5438 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5439 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5440 | bgp_attr_unintern (&new_attr); |
| 5441 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5442 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5443 | bgp_unlock_node (bn); |
| 5444 | return; |
| 5445 | } |
| 5446 | else |
| 5447 | { |
| 5448 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5449 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5450 | |
| 5451 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5452 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5453 | bgp_info_restore(bn, bi); |
| 5454 | else |
| 5455 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5456 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5457 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5458 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5459 | |
| 5460 | /* Process change. */ |
| 5461 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5462 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5463 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5464 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5465 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5466 | return; |
| 5467 | } |
| 5468 | } |
| 5469 | |
| 5470 | new = bgp_info_new (); |
| 5471 | new->type = type; |
| 5472 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 5473 | new->peer = bgp->peer_self; |
| 5474 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5475 | new->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5476 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5477 | |
| 5478 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5479 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5480 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5481 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5482 | } |
| 5483 | } |
| 5484 | |
| 5485 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5486 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5487 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5488 | } |
| 5489 | |
| 5490 | void |
| 5491 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5492 | { |
| 5493 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5494 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5495 | afi_t afi; |
| 5496 | struct bgp_node *rn; |
| 5497 | struct bgp_info *ri; |
| 5498 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5499 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5500 | { |
| 5501 | afi = family2afi (p->family); |
| 5502 | |
| 5503 | if (bgp->redist[afi][type]) |
| 5504 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5505 | 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] | 5506 | |
| 5507 | for (ri = rn->info; ri; ri = ri->next) |
| 5508 | if (ri->peer == bgp->peer_self |
| 5509 | && ri->type == type) |
| 5510 | break; |
| 5511 | |
| 5512 | if (ri) |
| 5513 | { |
| 5514 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5515 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5516 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5517 | } |
| 5518 | bgp_unlock_node (rn); |
| 5519 | } |
| 5520 | } |
| 5521 | } |
| 5522 | |
| 5523 | /* Withdraw specified route type's route. */ |
| 5524 | void |
| 5525 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5526 | { |
| 5527 | struct bgp_node *rn; |
| 5528 | struct bgp_info *ri; |
| 5529 | struct bgp_table *table; |
| 5530 | |
| 5531 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5532 | |
| 5533 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5534 | { |
| 5535 | for (ri = rn->info; ri; ri = ri->next) |
| 5536 | if (ri->peer == bgp->peer_self |
| 5537 | && ri->type == type) |
| 5538 | break; |
| 5539 | |
| 5540 | if (ri) |
| 5541 | { |
| 5542 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5543 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5544 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5545 | } |
| 5546 | } |
| 5547 | } |
| 5548 | |
| 5549 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5550 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5551 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5552 | { |
| 5553 | int len; |
| 5554 | u_int32_t destination; |
| 5555 | char buf[BUFSIZ]; |
| 5556 | |
| 5557 | if (p->family == AF_INET) |
| 5558 | { |
| 5559 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5560 | destination = ntohl (p->u.prefix4.s_addr); |
| 5561 | |
| 5562 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5563 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5564 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5565 | || p->u.prefix4.s_addr == 0) |
| 5566 | { |
| 5567 | /* When mask is natural, mask is not displayed. */ |
| 5568 | } |
| 5569 | else |
| 5570 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5571 | } |
| 5572 | else |
| 5573 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5574 | p->prefixlen); |
| 5575 | |
| 5576 | len = 17 - len; |
| 5577 | if (len < 1) |
| 5578 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5579 | else |
| 5580 | vty_out (vty, "%*s", len, " "); |
| 5581 | } |
| 5582 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5583 | enum bgp_display_type |
| 5584 | { |
| 5585 | normal_list, |
| 5586 | }; |
| 5587 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5588 | /* Print the short form route status for a bgp_info */ |
| 5589 | static void |
| 5590 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5591 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5592 | /* Route status display. */ |
| 5593 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5594 | vty_out (vty, "R"); |
| 5595 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5596 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5597 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5598 | vty_out (vty, "s"); |
| 5599 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5600 | vty_out (vty, "*"); |
| 5601 | else |
| 5602 | vty_out (vty, " "); |
| 5603 | |
| 5604 | /* Selected */ |
| 5605 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5606 | vty_out (vty, "h"); |
| 5607 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5608 | vty_out (vty, "d"); |
| 5609 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5610 | vty_out (vty, ">"); |
| 5611 | else |
| 5612 | vty_out (vty, " "); |
| 5613 | |
| 5614 | /* Internal route. */ |
| 5615 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5616 | vty_out (vty, "i"); |
| 5617 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5618 | vty_out (vty, " "); |
| 5619 | } |
| 5620 | |
| 5621 | /* called from terminal list command */ |
| 5622 | void |
| 5623 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5624 | struct bgp_info *binfo, int display, safi_t safi) |
| 5625 | { |
| 5626 | struct attr *attr; |
| 5627 | |
| 5628 | /* short status lead text */ |
| 5629 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5630 | |
| 5631 | /* print prefix and mask */ |
| 5632 | if (! display) |
| 5633 | route_vty_out_route (p, vty); |
| 5634 | else |
| 5635 | vty_out (vty, "%*s", 17, " "); |
| 5636 | |
| 5637 | /* Print attribute */ |
| 5638 | attr = binfo->attr; |
| 5639 | if (attr) |
| 5640 | { |
| 5641 | if (p->family == AF_INET) |
| 5642 | { |
| 5643 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5644 | vty_out (vty, "%-16s", |
| 5645 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5646 | else |
| 5647 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5648 | } |
| 5649 | #ifdef HAVE_IPV6 |
| 5650 | else if (p->family == AF_INET6) |
| 5651 | { |
| 5652 | int len; |
| 5653 | char buf[BUFSIZ]; |
| 5654 | |
| 5655 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5656 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5657 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5658 | len = 16 - len; |
| 5659 | if (len < 1) |
| 5660 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5661 | else |
| 5662 | vty_out (vty, "%*s", len, " "); |
| 5663 | } |
| 5664 | #endif /* HAVE_IPV6 */ |
| 5665 | |
| 5666 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5667 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5668 | else |
| 5669 | vty_out (vty, " "); |
| 5670 | |
| 5671 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5672 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5673 | else |
| 5674 | vty_out (vty, " "); |
| 5675 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5676 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5677 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5678 | /* Print aspath */ |
| 5679 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5680 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5681 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5682 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5683 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5684 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5685 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5686 | } |
| 5687 | |
| 5688 | /* called from terminal list command */ |
| 5689 | void |
| 5690 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5691 | struct attr *attr, safi_t safi) |
| 5692 | { |
| 5693 | /* Route status display. */ |
| 5694 | vty_out (vty, "*"); |
| 5695 | vty_out (vty, ">"); |
| 5696 | vty_out (vty, " "); |
| 5697 | |
| 5698 | /* print prefix and mask */ |
| 5699 | route_vty_out_route (p, vty); |
| 5700 | |
| 5701 | /* Print attribute */ |
| 5702 | if (attr) |
| 5703 | { |
| 5704 | if (p->family == AF_INET) |
| 5705 | { |
| 5706 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5707 | vty_out (vty, "%-16s", |
| 5708 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5709 | else |
| 5710 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5711 | } |
| 5712 | #ifdef HAVE_IPV6 |
| 5713 | else if (p->family == AF_INET6) |
| 5714 | { |
| 5715 | int len; |
| 5716 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5717 | |
| 5718 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5719 | |
| 5720 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5721 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5722 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5723 | len = 16 - len; |
| 5724 | if (len < 1) |
| 5725 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5726 | else |
| 5727 | vty_out (vty, "%*s", len, " "); |
| 5728 | } |
| 5729 | #endif /* HAVE_IPV6 */ |
| 5730 | |
| 5731 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5732 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5733 | else |
| 5734 | vty_out (vty, " "); |
| 5735 | |
| 5736 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5737 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5738 | else |
| 5739 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5740 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5741 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5742 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5743 | /* Print aspath */ |
| 5744 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5745 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5746 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5747 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5748 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5749 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5750 | |
| 5751 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5752 | } |
| 5753 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5754 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5755 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 5756 | struct bgp_info *binfo, int display, safi_t safi) |
| 5757 | { |
| 5758 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5759 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5760 | |
| 5761 | if (!binfo->extra) |
| 5762 | return; |
| 5763 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5764 | /* short status lead text */ |
| 5765 | route_vty_short_status_out (vty, binfo); |
| 5766 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5767 | /* print prefix and mask */ |
| 5768 | if (! display) |
| 5769 | route_vty_out_route (p, vty); |
| 5770 | else |
| 5771 | vty_out (vty, "%*s", 17, " "); |
| 5772 | |
| 5773 | /* Print attribute */ |
| 5774 | attr = binfo->attr; |
| 5775 | if (attr) |
| 5776 | { |
| 5777 | if (p->family == AF_INET) |
| 5778 | { |
| 5779 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5780 | vty_out (vty, "%-16s", |
| 5781 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5782 | else |
| 5783 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5784 | } |
| 5785 | #ifdef HAVE_IPV6 |
| 5786 | else if (p->family == AF_INET6) |
| 5787 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5788 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5789 | char buf[BUFSIZ]; |
| 5790 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5791 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5792 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5793 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5794 | buf, BUFSIZ)); |
| 5795 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5796 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5797 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5798 | buf, BUFSIZ), |
| 5799 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 5800 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5801 | |
| 5802 | } |
| 5803 | #endif /* HAVE_IPV6 */ |
| 5804 | } |
| 5805 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5806 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5807 | |
| 5808 | vty_out (vty, "notag/%d", label); |
| 5809 | |
| 5810 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5811 | } |
| 5812 | |
| 5813 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5814 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5815 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5816 | struct bgp_info *binfo, int display, safi_t safi) |
| 5817 | { |
| 5818 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5819 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5820 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5821 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5822 | /* short status lead text */ |
| 5823 | route_vty_short_status_out (vty, binfo); |
| 5824 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5825 | /* print prefix and mask */ |
| 5826 | if (! display) |
| 5827 | route_vty_out_route (p, vty); |
| 5828 | else |
| 5829 | vty_out (vty, "%*s", 17, " "); |
| 5830 | |
| 5831 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5832 | len = 17 - len; |
| 5833 | if (len < 1) |
| 5834 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5835 | else |
| 5836 | vty_out (vty, "%*s", len, " "); |
| 5837 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5838 | 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] | 5839 | |
| 5840 | /* Print attribute */ |
| 5841 | attr = binfo->attr; |
| 5842 | if (attr) |
| 5843 | { |
| 5844 | /* Print aspath */ |
| 5845 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5846 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5847 | |
| 5848 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5849 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5850 | } |
| 5851 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5852 | } |
| 5853 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5854 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5855 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5856 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5857 | struct bgp_info *binfo, int display, safi_t safi) |
| 5858 | { |
| 5859 | struct attr *attr; |
| 5860 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5861 | char timebuf[BGP_UPTIME_LEN]; |
| 5862 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5863 | |
| 5864 | if (!binfo->extra) |
| 5865 | return; |
| 5866 | |
| 5867 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5868 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5869 | /* short status lead text */ |
| 5870 | route_vty_short_status_out (vty, binfo); |
| 5871 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5872 | /* print prefix and mask */ |
| 5873 | if (! display) |
| 5874 | route_vty_out_route (p, vty); |
| 5875 | else |
| 5876 | vty_out (vty, "%*s", 17, " "); |
| 5877 | |
| 5878 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5879 | len = 16 - len; |
| 5880 | if (len < 1) |
| 5881 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5882 | else |
| 5883 | vty_out (vty, "%*s", len, " "); |
| 5884 | |
| 5885 | len = vty_out (vty, "%d", bdi->flap); |
| 5886 | len = 5 - len; |
| 5887 | if (len < 1) |
| 5888 | vty_out (vty, " "); |
| 5889 | else |
| 5890 | vty_out (vty, "%*s ", len, " "); |
| 5891 | |
| 5892 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5893 | timebuf, BGP_UPTIME_LEN)); |
| 5894 | |
| 5895 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5896 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5897 | 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] | 5898 | else |
| 5899 | vty_out (vty, "%*s ", 8, " "); |
| 5900 | |
| 5901 | /* Print attribute */ |
| 5902 | attr = binfo->attr; |
| 5903 | if (attr) |
| 5904 | { |
| 5905 | /* Print aspath */ |
| 5906 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5907 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5908 | |
| 5909 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5910 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5911 | } |
| 5912 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5913 | } |
| 5914 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5915 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5916 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5917 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5918 | { |
| 5919 | char buf[INET6_ADDRSTRLEN]; |
| 5920 | char buf1[BUFSIZ]; |
| 5921 | struct attr *attr; |
| 5922 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 5923 | #ifdef HAVE_CLOCK_MONOTONIC |
| 5924 | time_t tbuf; |
| 5925 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5926 | |
| 5927 | attr = binfo->attr; |
| 5928 | |
| 5929 | if (attr) |
| 5930 | { |
| 5931 | /* Line1 display AS-path, Aggregator */ |
| 5932 | if (attr->aspath) |
| 5933 | { |
| 5934 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 5935 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5936 | vty_out (vty, "Local"); |
| 5937 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5938 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5939 | } |
| 5940 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5941 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5942 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5943 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 5944 | vty_out (vty, ", (stale)"); |
| 5945 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 5946 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5947 | attr->extra->aggregator_as, |
| 5948 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5949 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 5950 | vty_out (vty, ", (Received from a RR-client)"); |
| 5951 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 5952 | vty_out (vty, ", (Received from a RS-client)"); |
| 5953 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5954 | vty_out (vty, ", (history entry)"); |
| 5955 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5956 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5957 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5958 | |
| 5959 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 5960 | if (p->family == AF_INET) |
| 5961 | { |
| 5962 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5963 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5964 | inet_ntoa (attr->nexthop)); |
| 5965 | } |
| 5966 | #ifdef HAVE_IPV6 |
| 5967 | else |
| 5968 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5969 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5970 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5971 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5972 | buf, INET6_ADDRSTRLEN)); |
| 5973 | } |
| 5974 | #endif /* HAVE_IPV6 */ |
| 5975 | |
| 5976 | if (binfo->peer == bgp->peer_self) |
| 5977 | { |
| 5978 | vty_out (vty, " from %s ", |
| 5979 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 5980 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 5981 | } |
| 5982 | else |
| 5983 | { |
| 5984 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 5985 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5986 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 5987 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 5988 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5989 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5990 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5991 | else |
| 5992 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 5993 | } |
| 5994 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5995 | |
| 5996 | #ifdef HAVE_IPV6 |
| 5997 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5998 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5999 | { |
| 6000 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6001 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6002 | buf, INET6_ADDRSTRLEN), |
| 6003 | VTY_NEWLINE); |
| 6004 | } |
| 6005 | #endif /* HAVE_IPV6 */ |
| 6006 | |
| 6007 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 6008 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 6009 | |
| 6010 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6011 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6012 | |
| 6013 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6014 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6015 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6016 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6017 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6018 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6019 | vty_out (vty, ", weight %u", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6020 | |
| 6021 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6022 | vty_out (vty, ", valid"); |
| 6023 | |
| 6024 | if (binfo->peer != bgp->peer_self) |
| 6025 | { |
| 6026 | if (binfo->peer->as == binfo->peer->local_as) |
| 6027 | vty_out (vty, ", internal"); |
| 6028 | else |
| 6029 | vty_out (vty, ", %s", |
| 6030 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6031 | } |
| 6032 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6033 | vty_out (vty, ", aggregated, local"); |
| 6034 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6035 | vty_out (vty, ", sourced"); |
| 6036 | else |
| 6037 | vty_out (vty, ", sourced, local"); |
| 6038 | |
| 6039 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6040 | vty_out (vty, ", atomic-aggregate"); |
| 6041 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6042 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6043 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6044 | bgp_info_mpath_count (binfo))) |
| 6045 | vty_out (vty, ", multipath"); |
| 6046 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6047 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6048 | vty_out (vty, ", best"); |
| 6049 | |
| 6050 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6051 | |
| 6052 | /* Line 4 display Community */ |
| 6053 | if (attr->community) |
| 6054 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6055 | VTY_NEWLINE); |
| 6056 | |
| 6057 | /* Line 5 display Extended-community */ |
| 6058 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6059 | vty_out (vty, " Extended Community: %s%s", |
| 6060 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6061 | |
| 6062 | /* Line 6 display Originator, Cluster-id */ |
| 6063 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6064 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6065 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6066 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6067 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6068 | vty_out (vty, " Originator: %s", |
| 6069 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6070 | |
| 6071 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6072 | { |
| 6073 | int i; |
| 6074 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6075 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6076 | vty_out (vty, "%s ", |
| 6077 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6078 | } |
| 6079 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6080 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6081 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6082 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6083 | bgp_damp_info_vty (vty, binfo); |
| 6084 | |
| 6085 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6086 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6087 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6088 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6089 | #else |
| 6090 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6091 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6092 | } |
| 6093 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6094 | } |
| 6095 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6096 | #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] | 6097 | #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] | 6098 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6099 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6100 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6101 | |
| 6102 | enum bgp_show_type |
| 6103 | { |
| 6104 | bgp_show_type_normal, |
| 6105 | bgp_show_type_regexp, |
| 6106 | bgp_show_type_prefix_list, |
| 6107 | bgp_show_type_filter_list, |
| 6108 | bgp_show_type_route_map, |
| 6109 | bgp_show_type_neighbor, |
| 6110 | bgp_show_type_cidr_only, |
| 6111 | bgp_show_type_prefix_longer, |
| 6112 | bgp_show_type_community_all, |
| 6113 | bgp_show_type_community, |
| 6114 | bgp_show_type_community_exact, |
| 6115 | bgp_show_type_community_list, |
| 6116 | bgp_show_type_community_list_exact, |
| 6117 | bgp_show_type_flap_statistics, |
| 6118 | bgp_show_type_flap_address, |
| 6119 | bgp_show_type_flap_prefix, |
| 6120 | bgp_show_type_flap_cidr_only, |
| 6121 | bgp_show_type_flap_regexp, |
| 6122 | bgp_show_type_flap_filter_list, |
| 6123 | bgp_show_type_flap_prefix_list, |
| 6124 | bgp_show_type_flap_prefix_longer, |
| 6125 | bgp_show_type_flap_route_map, |
| 6126 | bgp_show_type_flap_neighbor, |
| 6127 | bgp_show_type_dampend_paths, |
| 6128 | bgp_show_type_damp_neighbor |
| 6129 | }; |
| 6130 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6131 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6132 | 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] | 6133 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6134 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6135 | struct bgp_info *ri; |
| 6136 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6137 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6138 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6139 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6140 | |
| 6141 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6142 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6143 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6144 | /* Start processing of routes. */ |
| 6145 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6146 | if (rn->info != NULL) |
| 6147 | { |
| 6148 | display = 0; |
| 6149 | |
| 6150 | for (ri = rn->info; ri; ri = ri->next) |
| 6151 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6152 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6153 | || type == bgp_show_type_flap_address |
| 6154 | || type == bgp_show_type_flap_prefix |
| 6155 | || type == bgp_show_type_flap_cidr_only |
| 6156 | || type == bgp_show_type_flap_regexp |
| 6157 | || type == bgp_show_type_flap_filter_list |
| 6158 | || type == bgp_show_type_flap_prefix_list |
| 6159 | || type == bgp_show_type_flap_prefix_longer |
| 6160 | || type == bgp_show_type_flap_route_map |
| 6161 | || type == bgp_show_type_flap_neighbor |
| 6162 | || type == bgp_show_type_dampend_paths |
| 6163 | || type == bgp_show_type_damp_neighbor) |
| 6164 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6165 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6166 | continue; |
| 6167 | } |
| 6168 | if (type == bgp_show_type_regexp |
| 6169 | || type == bgp_show_type_flap_regexp) |
| 6170 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6171 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6172 | |
| 6173 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6174 | continue; |
| 6175 | } |
| 6176 | if (type == bgp_show_type_prefix_list |
| 6177 | || type == bgp_show_type_flap_prefix_list) |
| 6178 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6179 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6180 | |
| 6181 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6182 | continue; |
| 6183 | } |
| 6184 | if (type == bgp_show_type_filter_list |
| 6185 | || type == bgp_show_type_flap_filter_list) |
| 6186 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6187 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6188 | |
| 6189 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6190 | continue; |
| 6191 | } |
| 6192 | if (type == bgp_show_type_route_map |
| 6193 | || type == bgp_show_type_flap_route_map) |
| 6194 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6195 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6196 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6197 | struct attr dummy_attr; |
| 6198 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6199 | int ret; |
| 6200 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6201 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6202 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6203 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6204 | binfo.peer = ri->peer; |
| 6205 | binfo.attr = &dummy_attr; |
| 6206 | |
| 6207 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6208 | if (ret == RMAP_DENYMATCH) |
| 6209 | continue; |
| 6210 | } |
| 6211 | if (type == bgp_show_type_neighbor |
| 6212 | || type == bgp_show_type_flap_neighbor |
| 6213 | || type == bgp_show_type_damp_neighbor) |
| 6214 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6215 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6216 | |
| 6217 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6218 | continue; |
| 6219 | } |
| 6220 | if (type == bgp_show_type_cidr_only |
| 6221 | || type == bgp_show_type_flap_cidr_only) |
| 6222 | { |
| 6223 | u_int32_t destination; |
| 6224 | |
| 6225 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6226 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6227 | continue; |
| 6228 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6229 | continue; |
| 6230 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6231 | continue; |
| 6232 | } |
| 6233 | if (type == bgp_show_type_prefix_longer |
| 6234 | || type == bgp_show_type_flap_prefix_longer) |
| 6235 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6236 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6237 | |
| 6238 | if (! prefix_match (p, &rn->p)) |
| 6239 | continue; |
| 6240 | } |
| 6241 | if (type == bgp_show_type_community_all) |
| 6242 | { |
| 6243 | if (! ri->attr->community) |
| 6244 | continue; |
| 6245 | } |
| 6246 | if (type == bgp_show_type_community) |
| 6247 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6248 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6249 | |
| 6250 | if (! ri->attr->community || |
| 6251 | ! community_match (ri->attr->community, com)) |
| 6252 | continue; |
| 6253 | } |
| 6254 | if (type == bgp_show_type_community_exact) |
| 6255 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6256 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6257 | |
| 6258 | if (! ri->attr->community || |
| 6259 | ! community_cmp (ri->attr->community, com)) |
| 6260 | continue; |
| 6261 | } |
| 6262 | if (type == bgp_show_type_community_list) |
| 6263 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6264 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6265 | |
| 6266 | if (! community_list_match (ri->attr->community, list)) |
| 6267 | continue; |
| 6268 | } |
| 6269 | if (type == bgp_show_type_community_list_exact) |
| 6270 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6271 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6272 | |
| 6273 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6274 | continue; |
| 6275 | } |
| 6276 | if (type == bgp_show_type_flap_address |
| 6277 | || type == bgp_show_type_flap_prefix) |
| 6278 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6279 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6280 | |
| 6281 | if (! prefix_match (&rn->p, p)) |
| 6282 | continue; |
| 6283 | |
| 6284 | if (type == bgp_show_type_flap_prefix) |
| 6285 | if (p->prefixlen != rn->p.prefixlen) |
| 6286 | continue; |
| 6287 | } |
| 6288 | if (type == bgp_show_type_dampend_paths |
| 6289 | || type == bgp_show_type_damp_neighbor) |
| 6290 | { |
| 6291 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6292 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6293 | continue; |
| 6294 | } |
| 6295 | |
| 6296 | if (header) |
| 6297 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6298 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6299 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6300 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6301 | if (type == bgp_show_type_dampend_paths |
| 6302 | || type == bgp_show_type_damp_neighbor) |
| 6303 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6304 | else if (type == bgp_show_type_flap_statistics |
| 6305 | || type == bgp_show_type_flap_address |
| 6306 | || type == bgp_show_type_flap_prefix |
| 6307 | || type == bgp_show_type_flap_cidr_only |
| 6308 | || type == bgp_show_type_flap_regexp |
| 6309 | || type == bgp_show_type_flap_filter_list |
| 6310 | || type == bgp_show_type_flap_prefix_list |
| 6311 | || type == bgp_show_type_flap_prefix_longer |
| 6312 | || type == bgp_show_type_flap_route_map |
| 6313 | || type == bgp_show_type_flap_neighbor) |
| 6314 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6315 | else |
| 6316 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6317 | header = 0; |
| 6318 | } |
| 6319 | |
| 6320 | if (type == bgp_show_type_dampend_paths |
| 6321 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6322 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6323 | else if (type == bgp_show_type_flap_statistics |
| 6324 | || type == bgp_show_type_flap_address |
| 6325 | || type == bgp_show_type_flap_prefix |
| 6326 | || type == bgp_show_type_flap_cidr_only |
| 6327 | || type == bgp_show_type_flap_regexp |
| 6328 | || type == bgp_show_type_flap_filter_list |
| 6329 | || type == bgp_show_type_flap_prefix_list |
| 6330 | || type == bgp_show_type_flap_prefix_longer |
| 6331 | || type == bgp_show_type_flap_route_map |
| 6332 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6333 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6334 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6335 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6336 | display++; |
| 6337 | } |
| 6338 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6339 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6340 | } |
| 6341 | |
| 6342 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6343 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6344 | { |
| 6345 | if (type == bgp_show_type_normal) |
| 6346 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 6347 | } |
| 6348 | else |
| 6349 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6350 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6351 | |
| 6352 | return CMD_SUCCESS; |
| 6353 | } |
| 6354 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6355 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6356 | 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] | 6357 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6358 | { |
| 6359 | struct bgp_table *table; |
| 6360 | |
| 6361 | if (bgp == NULL) { |
| 6362 | bgp = bgp_get_default (); |
| 6363 | } |
| 6364 | |
| 6365 | if (bgp == NULL) |
| 6366 | { |
| 6367 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6368 | return CMD_WARNING; |
| 6369 | } |
| 6370 | |
| 6371 | |
| 6372 | table = bgp->rib[afi][safi]; |
| 6373 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6374 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6375 | } |
| 6376 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6377 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6378 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6379 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6380 | struct bgp_node *rn, |
| 6381 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6382 | { |
| 6383 | struct bgp_info *ri; |
| 6384 | struct prefix *p; |
| 6385 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6386 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6387 | char buf1[INET6_ADDRSTRLEN]; |
| 6388 | char buf2[INET6_ADDRSTRLEN]; |
| 6389 | int count = 0; |
| 6390 | int best = 0; |
| 6391 | int suppress = 0; |
| 6392 | int no_export = 0; |
| 6393 | int no_advertise = 0; |
| 6394 | int local_as = 0; |
| 6395 | int first = 0; |
| 6396 | |
| 6397 | p = &rn->p; |
| 6398 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 6399 | (safi == SAFI_MPLS_VPN ? |
| 6400 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6401 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 6402 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6403 | p->prefixlen, VTY_NEWLINE); |
| 6404 | |
| 6405 | for (ri = rn->info; ri; ri = ri->next) |
| 6406 | { |
| 6407 | count++; |
| 6408 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6409 | { |
| 6410 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6411 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6412 | suppress = 1; |
| 6413 | if (ri->attr->community != NULL) |
| 6414 | { |
| 6415 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6416 | no_advertise = 1; |
| 6417 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6418 | no_export = 1; |
| 6419 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6420 | local_as = 1; |
| 6421 | } |
| 6422 | } |
| 6423 | } |
| 6424 | |
| 6425 | vty_out (vty, "Paths: (%d available", count); |
| 6426 | if (best) |
| 6427 | { |
| 6428 | vty_out (vty, ", best #%d", best); |
| 6429 | if (safi == SAFI_UNICAST) |
| 6430 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6431 | } |
| 6432 | else |
| 6433 | vty_out (vty, ", no best path"); |
| 6434 | if (no_advertise) |
| 6435 | vty_out (vty, ", not advertised to any peer"); |
| 6436 | else if (no_export) |
| 6437 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6438 | else if (local_as) |
| 6439 | vty_out (vty, ", not advertised outside local AS"); |
| 6440 | if (suppress) |
| 6441 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6442 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6443 | |
| 6444 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6445 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6446 | { |
| 6447 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6448 | { |
| 6449 | if (! first) |
| 6450 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6451 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6452 | first = 1; |
| 6453 | } |
| 6454 | } |
| 6455 | if (! first) |
| 6456 | vty_out (vty, " Not advertised to any peer"); |
| 6457 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6458 | } |
| 6459 | |
| 6460 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6461 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6462 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6463 | struct bgp_table *rib, const char *ip_str, |
| 6464 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6465 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6466 | { |
| 6467 | int ret; |
| 6468 | int header; |
| 6469 | int display = 0; |
| 6470 | struct prefix match; |
| 6471 | struct bgp_node *rn; |
| 6472 | struct bgp_node *rm; |
| 6473 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6474 | struct bgp_table *table; |
| 6475 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6476 | /* Check IP address argument. */ |
| 6477 | ret = str2prefix (ip_str, &match); |
| 6478 | if (! ret) |
| 6479 | { |
| 6480 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6481 | return CMD_WARNING; |
| 6482 | } |
| 6483 | |
| 6484 | match.family = afi2family (afi); |
| 6485 | |
| 6486 | if (safi == SAFI_MPLS_VPN) |
| 6487 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6488 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6489 | { |
| 6490 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6491 | continue; |
| 6492 | |
| 6493 | if ((table = rn->info) != NULL) |
| 6494 | { |
| 6495 | header = 1; |
| 6496 | |
| 6497 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6498 | { |
| 6499 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6500 | { |
| 6501 | bgp_unlock_node (rm); |
| 6502 | continue; |
| 6503 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6504 | |
| 6505 | for (ri = rm->info; ri; ri = ri->next) |
| 6506 | { |
| 6507 | if (header) |
| 6508 | { |
| 6509 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 6510 | AFI_IP, SAFI_MPLS_VPN); |
| 6511 | |
| 6512 | header = 0; |
| 6513 | } |
| 6514 | display++; |
| 6515 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 6516 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6517 | |
| 6518 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6519 | } |
| 6520 | } |
| 6521 | } |
| 6522 | } |
| 6523 | else |
| 6524 | { |
| 6525 | header = 1; |
| 6526 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6527 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6528 | { |
| 6529 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6530 | { |
| 6531 | for (ri = rn->info; ri; ri = ri->next) |
| 6532 | { |
| 6533 | if (header) |
| 6534 | { |
| 6535 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6536 | header = 0; |
| 6537 | } |
| 6538 | display++; |
| 6539 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6540 | } |
| 6541 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6542 | |
| 6543 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6544 | } |
| 6545 | } |
| 6546 | |
| 6547 | if (! display) |
| 6548 | { |
| 6549 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6550 | return CMD_WARNING; |
| 6551 | } |
| 6552 | |
| 6553 | return CMD_SUCCESS; |
| 6554 | } |
| 6555 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6556 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6557 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6558 | 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] | 6559 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6560 | int prefix_check) |
| 6561 | { |
| 6562 | struct bgp *bgp; |
| 6563 | |
| 6564 | /* BGP structure lookup. */ |
| 6565 | if (view_name) |
| 6566 | { |
| 6567 | bgp = bgp_lookup_by_name (view_name); |
| 6568 | if (bgp == NULL) |
| 6569 | { |
| 6570 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6571 | return CMD_WARNING; |
| 6572 | } |
| 6573 | } |
| 6574 | else |
| 6575 | { |
| 6576 | bgp = bgp_get_default (); |
| 6577 | if (bgp == NULL) |
| 6578 | { |
| 6579 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6580 | return CMD_WARNING; |
| 6581 | } |
| 6582 | } |
| 6583 | |
| 6584 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6585 | afi, safi, prd, prefix_check); |
| 6586 | } |
| 6587 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6588 | /* BGP route print out function. */ |
| 6589 | DEFUN (show_ip_bgp, |
| 6590 | show_ip_bgp_cmd, |
| 6591 | "show ip bgp", |
| 6592 | SHOW_STR |
| 6593 | IP_STR |
| 6594 | BGP_STR) |
| 6595 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6596 | 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] | 6597 | } |
| 6598 | |
| 6599 | DEFUN (show_ip_bgp_ipv4, |
| 6600 | show_ip_bgp_ipv4_cmd, |
| 6601 | "show ip bgp ipv4 (unicast|multicast)", |
| 6602 | SHOW_STR |
| 6603 | IP_STR |
| 6604 | BGP_STR |
| 6605 | "Address family\n" |
| 6606 | "Address Family modifier\n" |
| 6607 | "Address Family modifier\n") |
| 6608 | { |
| 6609 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6610 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6611 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6612 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6613 | 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] | 6614 | } |
| 6615 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6616 | ALIAS (show_ip_bgp_ipv4, |
| 6617 | show_bgp_ipv4_safi_cmd, |
| 6618 | "show bgp ipv4 (unicast|multicast)", |
| 6619 | SHOW_STR |
| 6620 | BGP_STR |
| 6621 | "Address family\n" |
| 6622 | "Address Family modifier\n" |
| 6623 | "Address Family modifier\n") |
| 6624 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6625 | DEFUN (show_ip_bgp_route, |
| 6626 | show_ip_bgp_route_cmd, |
| 6627 | "show ip bgp A.B.C.D", |
| 6628 | SHOW_STR |
| 6629 | IP_STR |
| 6630 | BGP_STR |
| 6631 | "Network in the BGP routing table to display\n") |
| 6632 | { |
| 6633 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6634 | } |
| 6635 | |
| 6636 | DEFUN (show_ip_bgp_ipv4_route, |
| 6637 | show_ip_bgp_ipv4_route_cmd, |
| 6638 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6639 | SHOW_STR |
| 6640 | IP_STR |
| 6641 | BGP_STR |
| 6642 | "Address family\n" |
| 6643 | "Address Family modifier\n" |
| 6644 | "Address Family modifier\n" |
| 6645 | "Network in the BGP routing table to display\n") |
| 6646 | { |
| 6647 | if (strncmp (argv[0], "m", 1) == 0) |
| 6648 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6649 | |
| 6650 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6651 | } |
| 6652 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6653 | ALIAS (show_ip_bgp_ipv4_route, |
| 6654 | show_bgp_ipv4_safi_route_cmd, |
| 6655 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6656 | SHOW_STR |
| 6657 | BGP_STR |
| 6658 | "Address family\n" |
| 6659 | "Address Family modifier\n" |
| 6660 | "Address Family modifier\n" |
| 6661 | "Network in the BGP routing table to display\n") |
| 6662 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6663 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6664 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6665 | "show ip bgp vpnv4 all A.B.C.D", |
| 6666 | SHOW_STR |
| 6667 | IP_STR |
| 6668 | BGP_STR |
| 6669 | "Display VPNv4 NLRI specific information\n" |
| 6670 | "Display information about all VPNv4 NLRIs\n" |
| 6671 | "Network in the BGP routing table to display\n") |
| 6672 | { |
| 6673 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6674 | } |
| 6675 | |
| 6676 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6677 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6678 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6679 | SHOW_STR |
| 6680 | IP_STR |
| 6681 | BGP_STR |
| 6682 | "Display VPNv4 NLRI specific information\n" |
| 6683 | "Display information for a route distinguisher\n" |
| 6684 | "VPN Route Distinguisher\n" |
| 6685 | "Network in the BGP routing table to display\n") |
| 6686 | { |
| 6687 | int ret; |
| 6688 | struct prefix_rd prd; |
| 6689 | |
| 6690 | ret = str2prefix_rd (argv[0], &prd); |
| 6691 | if (! ret) |
| 6692 | { |
| 6693 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6694 | return CMD_WARNING; |
| 6695 | } |
| 6696 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6697 | } |
| 6698 | |
| 6699 | DEFUN (show_ip_bgp_prefix, |
| 6700 | show_ip_bgp_prefix_cmd, |
| 6701 | "show ip bgp A.B.C.D/M", |
| 6702 | SHOW_STR |
| 6703 | IP_STR |
| 6704 | BGP_STR |
| 6705 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6706 | { |
| 6707 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6708 | } |
| 6709 | |
| 6710 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6711 | show_ip_bgp_ipv4_prefix_cmd, |
| 6712 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6713 | SHOW_STR |
| 6714 | IP_STR |
| 6715 | BGP_STR |
| 6716 | "Address family\n" |
| 6717 | "Address Family modifier\n" |
| 6718 | "Address Family modifier\n" |
| 6719 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6720 | { |
| 6721 | if (strncmp (argv[0], "m", 1) == 0) |
| 6722 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6723 | |
| 6724 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6725 | } |
| 6726 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6727 | ALIAS (show_ip_bgp_ipv4_prefix, |
| 6728 | show_bgp_ipv4_safi_prefix_cmd, |
| 6729 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6730 | SHOW_STR |
| 6731 | BGP_STR |
| 6732 | "Address family\n" |
| 6733 | "Address Family modifier\n" |
| 6734 | "Address Family modifier\n" |
| 6735 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6736 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6737 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 6738 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 6739 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 6740 | SHOW_STR |
| 6741 | IP_STR |
| 6742 | BGP_STR |
| 6743 | "Display VPNv4 NLRI specific information\n" |
| 6744 | "Display information about all VPNv4 NLRIs\n" |
| 6745 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6746 | { |
| 6747 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 6748 | } |
| 6749 | |
| 6750 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 6751 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 6752 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 6753 | SHOW_STR |
| 6754 | IP_STR |
| 6755 | BGP_STR |
| 6756 | "Display VPNv4 NLRI specific information\n" |
| 6757 | "Display information for a route distinguisher\n" |
| 6758 | "VPN Route Distinguisher\n" |
| 6759 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6760 | { |
| 6761 | int ret; |
| 6762 | struct prefix_rd prd; |
| 6763 | |
| 6764 | ret = str2prefix_rd (argv[0], &prd); |
| 6765 | if (! ret) |
| 6766 | { |
| 6767 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6768 | return CMD_WARNING; |
| 6769 | } |
| 6770 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 6771 | } |
| 6772 | |
| 6773 | DEFUN (show_ip_bgp_view, |
| 6774 | show_ip_bgp_view_cmd, |
| 6775 | "show ip bgp view WORD", |
| 6776 | SHOW_STR |
| 6777 | IP_STR |
| 6778 | BGP_STR |
| 6779 | "BGP view\n" |
| 6780 | "BGP view name\n") |
| 6781 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6782 | struct bgp *bgp; |
| 6783 | |
| 6784 | /* BGP structure lookup. */ |
| 6785 | bgp = bgp_lookup_by_name (argv[0]); |
| 6786 | if (bgp == NULL) |
| 6787 | { |
| 6788 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6789 | return CMD_WARNING; |
| 6790 | } |
| 6791 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6792 | 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] | 6793 | } |
| 6794 | |
| 6795 | DEFUN (show_ip_bgp_view_route, |
| 6796 | show_ip_bgp_view_route_cmd, |
| 6797 | "show ip bgp view WORD A.B.C.D", |
| 6798 | SHOW_STR |
| 6799 | IP_STR |
| 6800 | BGP_STR |
| 6801 | "BGP view\n" |
| 6802 | "BGP view name\n" |
| 6803 | "Network in the BGP routing table to display\n") |
| 6804 | { |
| 6805 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6806 | } |
| 6807 | |
| 6808 | DEFUN (show_ip_bgp_view_prefix, |
| 6809 | show_ip_bgp_view_prefix_cmd, |
| 6810 | "show ip bgp view WORD A.B.C.D/M", |
| 6811 | SHOW_STR |
| 6812 | IP_STR |
| 6813 | BGP_STR |
| 6814 | "BGP view\n" |
| 6815 | "BGP view name\n" |
| 6816 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6817 | { |
| 6818 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6819 | } |
| 6820 | |
| 6821 | #ifdef HAVE_IPV6 |
| 6822 | DEFUN (show_bgp, |
| 6823 | show_bgp_cmd, |
| 6824 | "show bgp", |
| 6825 | SHOW_STR |
| 6826 | BGP_STR) |
| 6827 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6828 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6829 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6830 | } |
| 6831 | |
| 6832 | ALIAS (show_bgp, |
| 6833 | show_bgp_ipv6_cmd, |
| 6834 | "show bgp ipv6", |
| 6835 | SHOW_STR |
| 6836 | BGP_STR |
| 6837 | "Address family\n") |
| 6838 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6839 | DEFUN (show_bgp_ipv6_safi, |
| 6840 | show_bgp_ipv6_safi_cmd, |
| 6841 | "show bgp ipv6 (unicast|multicast)", |
| 6842 | SHOW_STR |
| 6843 | BGP_STR |
| 6844 | "Address family\n" |
| 6845 | "Address Family modifier\n" |
| 6846 | "Address Family modifier\n") |
| 6847 | { |
| 6848 | if (strncmp (argv[0], "m", 1) == 0) |
| 6849 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6850 | NULL); |
| 6851 | |
| 6852 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6853 | } |
| 6854 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6855 | /* old command */ |
| 6856 | DEFUN (show_ipv6_bgp, |
| 6857 | show_ipv6_bgp_cmd, |
| 6858 | "show ipv6 bgp", |
| 6859 | SHOW_STR |
| 6860 | IP_STR |
| 6861 | BGP_STR) |
| 6862 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6863 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6864 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6865 | } |
| 6866 | |
| 6867 | DEFUN (show_bgp_route, |
| 6868 | show_bgp_route_cmd, |
| 6869 | "show bgp X:X::X:X", |
| 6870 | SHOW_STR |
| 6871 | BGP_STR |
| 6872 | "Network in the BGP routing table to display\n") |
| 6873 | { |
| 6874 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6875 | } |
| 6876 | |
| 6877 | ALIAS (show_bgp_route, |
| 6878 | show_bgp_ipv6_route_cmd, |
| 6879 | "show bgp ipv6 X:X::X:X", |
| 6880 | SHOW_STR |
| 6881 | BGP_STR |
| 6882 | "Address family\n" |
| 6883 | "Network in the BGP routing table to display\n") |
| 6884 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6885 | DEFUN (show_bgp_ipv6_safi_route, |
| 6886 | show_bgp_ipv6_safi_route_cmd, |
| 6887 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
| 6888 | SHOW_STR |
| 6889 | BGP_STR |
| 6890 | "Address family\n" |
| 6891 | "Address Family modifier\n" |
| 6892 | "Address Family modifier\n" |
| 6893 | "Network in the BGP routing table to display\n") |
| 6894 | { |
| 6895 | if (strncmp (argv[0], "m", 1) == 0) |
| 6896 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6897 | |
| 6898 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6899 | } |
| 6900 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6901 | /* old command */ |
| 6902 | DEFUN (show_ipv6_bgp_route, |
| 6903 | show_ipv6_bgp_route_cmd, |
| 6904 | "show ipv6 bgp X:X::X:X", |
| 6905 | SHOW_STR |
| 6906 | IP_STR |
| 6907 | BGP_STR |
| 6908 | "Network in the BGP routing table to display\n") |
| 6909 | { |
| 6910 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6911 | } |
| 6912 | |
| 6913 | DEFUN (show_bgp_prefix, |
| 6914 | show_bgp_prefix_cmd, |
| 6915 | "show bgp X:X::X:X/M", |
| 6916 | SHOW_STR |
| 6917 | BGP_STR |
| 6918 | "IPv6 prefix <network>/<length>\n") |
| 6919 | { |
| 6920 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6921 | } |
| 6922 | |
| 6923 | ALIAS (show_bgp_prefix, |
| 6924 | show_bgp_ipv6_prefix_cmd, |
| 6925 | "show bgp ipv6 X:X::X:X/M", |
| 6926 | SHOW_STR |
| 6927 | BGP_STR |
| 6928 | "Address family\n" |
| 6929 | "IPv6 prefix <network>/<length>\n") |
| 6930 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6931 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 6932 | show_bgp_ipv6_safi_prefix_cmd, |
| 6933 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 6934 | SHOW_STR |
| 6935 | BGP_STR |
| 6936 | "Address family\n" |
| 6937 | "Address Family modifier\n" |
| 6938 | "Address Family modifier\n" |
| 6939 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6940 | { |
| 6941 | if (strncmp (argv[0], "m", 1) == 0) |
| 6942 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 6943 | |
| 6944 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6945 | } |
| 6946 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6947 | /* old command */ |
| 6948 | DEFUN (show_ipv6_bgp_prefix, |
| 6949 | show_ipv6_bgp_prefix_cmd, |
| 6950 | "show ipv6 bgp X:X::X:X/M", |
| 6951 | SHOW_STR |
| 6952 | IP_STR |
| 6953 | BGP_STR |
| 6954 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6955 | { |
| 6956 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6957 | } |
| 6958 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6959 | DEFUN (show_bgp_view, |
| 6960 | show_bgp_view_cmd, |
| 6961 | "show bgp view WORD", |
| 6962 | SHOW_STR |
| 6963 | BGP_STR |
| 6964 | "BGP view\n" |
| 6965 | "View name\n") |
| 6966 | { |
| 6967 | struct bgp *bgp; |
| 6968 | |
| 6969 | /* BGP structure lookup. */ |
| 6970 | bgp = bgp_lookup_by_name (argv[0]); |
| 6971 | if (bgp == NULL) |
| 6972 | { |
| 6973 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6974 | return CMD_WARNING; |
| 6975 | } |
| 6976 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6977 | 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] | 6978 | } |
| 6979 | |
| 6980 | ALIAS (show_bgp_view, |
| 6981 | show_bgp_view_ipv6_cmd, |
| 6982 | "show bgp view WORD ipv6", |
| 6983 | SHOW_STR |
| 6984 | BGP_STR |
| 6985 | "BGP view\n" |
| 6986 | "View name\n" |
| 6987 | "Address family\n") |
| 6988 | |
| 6989 | DEFUN (show_bgp_view_route, |
| 6990 | show_bgp_view_route_cmd, |
| 6991 | "show bgp view WORD X:X::X:X", |
| 6992 | SHOW_STR |
| 6993 | BGP_STR |
| 6994 | "BGP view\n" |
| 6995 | "View name\n" |
| 6996 | "Network in the BGP routing table to display\n") |
| 6997 | { |
| 6998 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6999 | } |
| 7000 | |
| 7001 | ALIAS (show_bgp_view_route, |
| 7002 | show_bgp_view_ipv6_route_cmd, |
| 7003 | "show bgp view WORD ipv6 X:X::X:X", |
| 7004 | SHOW_STR |
| 7005 | BGP_STR |
| 7006 | "BGP view\n" |
| 7007 | "View name\n" |
| 7008 | "Address family\n" |
| 7009 | "Network in the BGP routing table to display\n") |
| 7010 | |
| 7011 | DEFUN (show_bgp_view_prefix, |
| 7012 | show_bgp_view_prefix_cmd, |
| 7013 | "show bgp view WORD X:X::X:X/M", |
| 7014 | SHOW_STR |
| 7015 | BGP_STR |
| 7016 | "BGP view\n" |
| 7017 | "View name\n" |
| 7018 | "IPv6 prefix <network>/<length>\n") |
| 7019 | { |
| 7020 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7021 | } |
| 7022 | |
| 7023 | ALIAS (show_bgp_view_prefix, |
| 7024 | show_bgp_view_ipv6_prefix_cmd, |
| 7025 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 7026 | SHOW_STR |
| 7027 | BGP_STR |
| 7028 | "BGP view\n" |
| 7029 | "View name\n" |
| 7030 | "Address family\n" |
| 7031 | "IPv6 prefix <network>/<length>\n") |
| 7032 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7033 | /* old command */ |
| 7034 | DEFUN (show_ipv6_mbgp, |
| 7035 | show_ipv6_mbgp_cmd, |
| 7036 | "show ipv6 mbgp", |
| 7037 | SHOW_STR |
| 7038 | IP_STR |
| 7039 | MBGP_STR) |
| 7040 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7041 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7042 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7043 | } |
| 7044 | |
| 7045 | /* old command */ |
| 7046 | DEFUN (show_ipv6_mbgp_route, |
| 7047 | show_ipv6_mbgp_route_cmd, |
| 7048 | "show ipv6 mbgp X:X::X:X", |
| 7049 | SHOW_STR |
| 7050 | IP_STR |
| 7051 | MBGP_STR |
| 7052 | "Network in the MBGP routing table to display\n") |
| 7053 | { |
| 7054 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7055 | } |
| 7056 | |
| 7057 | /* old command */ |
| 7058 | DEFUN (show_ipv6_mbgp_prefix, |
| 7059 | show_ipv6_mbgp_prefix_cmd, |
| 7060 | "show ipv6 mbgp X:X::X:X/M", |
| 7061 | SHOW_STR |
| 7062 | IP_STR |
| 7063 | MBGP_STR |
| 7064 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7065 | { |
| 7066 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7067 | } |
| 7068 | #endif |
| 7069 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7070 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7071 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7072 | 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] | 7073 | safi_t safi, enum bgp_show_type type) |
| 7074 | { |
| 7075 | int i; |
| 7076 | struct buffer *b; |
| 7077 | char *regstr; |
| 7078 | int first; |
| 7079 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7080 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7081 | |
| 7082 | first = 0; |
| 7083 | b = buffer_new (1024); |
| 7084 | for (i = 0; i < argc; i++) |
| 7085 | { |
| 7086 | if (first) |
| 7087 | buffer_putc (b, ' '); |
| 7088 | else |
| 7089 | { |
| 7090 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7091 | continue; |
| 7092 | first = 1; |
| 7093 | } |
| 7094 | |
| 7095 | buffer_putstr (b, argv[i]); |
| 7096 | } |
| 7097 | buffer_putc (b, '\0'); |
| 7098 | |
| 7099 | regstr = buffer_getstr (b); |
| 7100 | buffer_free (b); |
| 7101 | |
| 7102 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7103 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7104 | if (! regex) |
| 7105 | { |
| 7106 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 7107 | VTY_NEWLINE); |
| 7108 | return CMD_WARNING; |
| 7109 | } |
| 7110 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7111 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 7112 | bgp_regex_free (regex); |
| 7113 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7114 | } |
| 7115 | |
| 7116 | DEFUN (show_ip_bgp_regexp, |
| 7117 | show_ip_bgp_regexp_cmd, |
| 7118 | "show ip bgp regexp .LINE", |
| 7119 | SHOW_STR |
| 7120 | IP_STR |
| 7121 | BGP_STR |
| 7122 | "Display routes matching the AS path regular expression\n" |
| 7123 | "A regular-expression to match the BGP AS paths\n") |
| 7124 | { |
| 7125 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7126 | bgp_show_type_regexp); |
| 7127 | } |
| 7128 | |
| 7129 | DEFUN (show_ip_bgp_flap_regexp, |
| 7130 | show_ip_bgp_flap_regexp_cmd, |
| 7131 | "show ip bgp flap-statistics regexp .LINE", |
| 7132 | SHOW_STR |
| 7133 | IP_STR |
| 7134 | BGP_STR |
| 7135 | "Display flap statistics of routes\n" |
| 7136 | "Display routes matching the AS path regular expression\n" |
| 7137 | "A regular-expression to match the BGP AS paths\n") |
| 7138 | { |
| 7139 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7140 | bgp_show_type_flap_regexp); |
| 7141 | } |
| 7142 | |
| 7143 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 7144 | show_ip_bgp_ipv4_regexp_cmd, |
| 7145 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 7146 | SHOW_STR |
| 7147 | IP_STR |
| 7148 | BGP_STR |
| 7149 | "Address family\n" |
| 7150 | "Address Family modifier\n" |
| 7151 | "Address Family modifier\n" |
| 7152 | "Display routes matching the AS path regular expression\n" |
| 7153 | "A regular-expression to match the BGP AS paths\n") |
| 7154 | { |
| 7155 | if (strncmp (argv[0], "m", 1) == 0) |
| 7156 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 7157 | bgp_show_type_regexp); |
| 7158 | |
| 7159 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7160 | bgp_show_type_regexp); |
| 7161 | } |
| 7162 | |
| 7163 | #ifdef HAVE_IPV6 |
| 7164 | DEFUN (show_bgp_regexp, |
| 7165 | show_bgp_regexp_cmd, |
| 7166 | "show bgp regexp .LINE", |
| 7167 | SHOW_STR |
| 7168 | BGP_STR |
| 7169 | "Display routes matching the AS path regular expression\n" |
| 7170 | "A regular-expression to match the BGP AS paths\n") |
| 7171 | { |
| 7172 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7173 | bgp_show_type_regexp); |
| 7174 | } |
| 7175 | |
| 7176 | ALIAS (show_bgp_regexp, |
| 7177 | show_bgp_ipv6_regexp_cmd, |
| 7178 | "show bgp ipv6 regexp .LINE", |
| 7179 | SHOW_STR |
| 7180 | BGP_STR |
| 7181 | "Address family\n" |
| 7182 | "Display routes matching the AS path regular expression\n" |
| 7183 | "A regular-expression to match the BGP AS paths\n") |
| 7184 | |
| 7185 | /* old command */ |
| 7186 | DEFUN (show_ipv6_bgp_regexp, |
| 7187 | show_ipv6_bgp_regexp_cmd, |
| 7188 | "show ipv6 bgp regexp .LINE", |
| 7189 | SHOW_STR |
| 7190 | IP_STR |
| 7191 | BGP_STR |
| 7192 | "Display routes matching the AS path regular expression\n" |
| 7193 | "A regular-expression to match the BGP AS paths\n") |
| 7194 | { |
| 7195 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7196 | bgp_show_type_regexp); |
| 7197 | } |
| 7198 | |
| 7199 | /* old command */ |
| 7200 | DEFUN (show_ipv6_mbgp_regexp, |
| 7201 | show_ipv6_mbgp_regexp_cmd, |
| 7202 | "show ipv6 mbgp regexp .LINE", |
| 7203 | SHOW_STR |
| 7204 | IP_STR |
| 7205 | BGP_STR |
| 7206 | "Display routes matching the AS path regular expression\n" |
| 7207 | "A regular-expression to match the MBGP AS paths\n") |
| 7208 | { |
| 7209 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 7210 | bgp_show_type_regexp); |
| 7211 | } |
| 7212 | #endif /* HAVE_IPV6 */ |
| 7213 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7214 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7215 | 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] | 7216 | safi_t safi, enum bgp_show_type type) |
| 7217 | { |
| 7218 | struct prefix_list *plist; |
| 7219 | |
| 7220 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 7221 | if (plist == NULL) |
| 7222 | { |
| 7223 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 7224 | prefix_list_str, VTY_NEWLINE); |
| 7225 | return CMD_WARNING; |
| 7226 | } |
| 7227 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7228 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7229 | } |
| 7230 | |
| 7231 | DEFUN (show_ip_bgp_prefix_list, |
| 7232 | show_ip_bgp_prefix_list_cmd, |
| 7233 | "show ip bgp prefix-list WORD", |
| 7234 | SHOW_STR |
| 7235 | IP_STR |
| 7236 | BGP_STR |
| 7237 | "Display routes conforming to the prefix-list\n" |
| 7238 | "IP prefix-list name\n") |
| 7239 | { |
| 7240 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7241 | bgp_show_type_prefix_list); |
| 7242 | } |
| 7243 | |
| 7244 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 7245 | show_ip_bgp_flap_prefix_list_cmd, |
| 7246 | "show ip bgp flap-statistics prefix-list WORD", |
| 7247 | SHOW_STR |
| 7248 | IP_STR |
| 7249 | BGP_STR |
| 7250 | "Display flap statistics of routes\n" |
| 7251 | "Display routes conforming to the prefix-list\n" |
| 7252 | "IP prefix-list name\n") |
| 7253 | { |
| 7254 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7255 | bgp_show_type_flap_prefix_list); |
| 7256 | } |
| 7257 | |
| 7258 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 7259 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 7260 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 7261 | SHOW_STR |
| 7262 | IP_STR |
| 7263 | BGP_STR |
| 7264 | "Address family\n" |
| 7265 | "Address Family modifier\n" |
| 7266 | "Address Family modifier\n" |
| 7267 | "Display routes conforming to the prefix-list\n" |
| 7268 | "IP prefix-list name\n") |
| 7269 | { |
| 7270 | if (strncmp (argv[0], "m", 1) == 0) |
| 7271 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7272 | bgp_show_type_prefix_list); |
| 7273 | |
| 7274 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7275 | bgp_show_type_prefix_list); |
| 7276 | } |
| 7277 | |
| 7278 | #ifdef HAVE_IPV6 |
| 7279 | DEFUN (show_bgp_prefix_list, |
| 7280 | show_bgp_prefix_list_cmd, |
| 7281 | "show bgp prefix-list WORD", |
| 7282 | SHOW_STR |
| 7283 | BGP_STR |
| 7284 | "Display routes conforming to the prefix-list\n" |
| 7285 | "IPv6 prefix-list name\n") |
| 7286 | { |
| 7287 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7288 | bgp_show_type_prefix_list); |
| 7289 | } |
| 7290 | |
| 7291 | ALIAS (show_bgp_prefix_list, |
| 7292 | show_bgp_ipv6_prefix_list_cmd, |
| 7293 | "show bgp ipv6 prefix-list WORD", |
| 7294 | SHOW_STR |
| 7295 | BGP_STR |
| 7296 | "Address family\n" |
| 7297 | "Display routes conforming to the prefix-list\n" |
| 7298 | "IPv6 prefix-list name\n") |
| 7299 | |
| 7300 | /* old command */ |
| 7301 | DEFUN (show_ipv6_bgp_prefix_list, |
| 7302 | show_ipv6_bgp_prefix_list_cmd, |
| 7303 | "show ipv6 bgp prefix-list WORD", |
| 7304 | SHOW_STR |
| 7305 | IPV6_STR |
| 7306 | BGP_STR |
| 7307 | "Display routes matching the prefix-list\n" |
| 7308 | "IPv6 prefix-list name\n") |
| 7309 | { |
| 7310 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7311 | bgp_show_type_prefix_list); |
| 7312 | } |
| 7313 | |
| 7314 | /* old command */ |
| 7315 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 7316 | show_ipv6_mbgp_prefix_list_cmd, |
| 7317 | "show ipv6 mbgp prefix-list WORD", |
| 7318 | SHOW_STR |
| 7319 | IPV6_STR |
| 7320 | MBGP_STR |
| 7321 | "Display routes matching the prefix-list\n" |
| 7322 | "IPv6 prefix-list name\n") |
| 7323 | { |
| 7324 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7325 | bgp_show_type_prefix_list); |
| 7326 | } |
| 7327 | #endif /* HAVE_IPV6 */ |
| 7328 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7329 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7330 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7331 | safi_t safi, enum bgp_show_type type) |
| 7332 | { |
| 7333 | struct as_list *as_list; |
| 7334 | |
| 7335 | as_list = as_list_lookup (filter); |
| 7336 | if (as_list == NULL) |
| 7337 | { |
| 7338 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 7339 | return CMD_WARNING; |
| 7340 | } |
| 7341 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7342 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7343 | } |
| 7344 | |
| 7345 | DEFUN (show_ip_bgp_filter_list, |
| 7346 | show_ip_bgp_filter_list_cmd, |
| 7347 | "show ip bgp filter-list WORD", |
| 7348 | SHOW_STR |
| 7349 | IP_STR |
| 7350 | BGP_STR |
| 7351 | "Display routes conforming to the filter-list\n" |
| 7352 | "Regular expression access list name\n") |
| 7353 | { |
| 7354 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7355 | bgp_show_type_filter_list); |
| 7356 | } |
| 7357 | |
| 7358 | DEFUN (show_ip_bgp_flap_filter_list, |
| 7359 | show_ip_bgp_flap_filter_list_cmd, |
| 7360 | "show ip bgp flap-statistics filter-list WORD", |
| 7361 | SHOW_STR |
| 7362 | IP_STR |
| 7363 | BGP_STR |
| 7364 | "Display flap statistics of routes\n" |
| 7365 | "Display routes conforming to the filter-list\n" |
| 7366 | "Regular expression access list name\n") |
| 7367 | { |
| 7368 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7369 | bgp_show_type_flap_filter_list); |
| 7370 | } |
| 7371 | |
| 7372 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 7373 | show_ip_bgp_ipv4_filter_list_cmd, |
| 7374 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 7375 | SHOW_STR |
| 7376 | IP_STR |
| 7377 | BGP_STR |
| 7378 | "Address family\n" |
| 7379 | "Address Family modifier\n" |
| 7380 | "Address Family modifier\n" |
| 7381 | "Display routes conforming to the filter-list\n" |
| 7382 | "Regular expression access list name\n") |
| 7383 | { |
| 7384 | if (strncmp (argv[0], "m", 1) == 0) |
| 7385 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7386 | bgp_show_type_filter_list); |
| 7387 | |
| 7388 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7389 | bgp_show_type_filter_list); |
| 7390 | } |
| 7391 | |
| 7392 | #ifdef HAVE_IPV6 |
| 7393 | DEFUN (show_bgp_filter_list, |
| 7394 | show_bgp_filter_list_cmd, |
| 7395 | "show bgp filter-list WORD", |
| 7396 | SHOW_STR |
| 7397 | BGP_STR |
| 7398 | "Display routes conforming to the filter-list\n" |
| 7399 | "Regular expression access list name\n") |
| 7400 | { |
| 7401 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7402 | bgp_show_type_filter_list); |
| 7403 | } |
| 7404 | |
| 7405 | ALIAS (show_bgp_filter_list, |
| 7406 | show_bgp_ipv6_filter_list_cmd, |
| 7407 | "show bgp ipv6 filter-list WORD", |
| 7408 | SHOW_STR |
| 7409 | BGP_STR |
| 7410 | "Address family\n" |
| 7411 | "Display routes conforming to the filter-list\n" |
| 7412 | "Regular expression access list name\n") |
| 7413 | |
| 7414 | /* old command */ |
| 7415 | DEFUN (show_ipv6_bgp_filter_list, |
| 7416 | show_ipv6_bgp_filter_list_cmd, |
| 7417 | "show ipv6 bgp filter-list WORD", |
| 7418 | SHOW_STR |
| 7419 | IPV6_STR |
| 7420 | BGP_STR |
| 7421 | "Display routes conforming to the filter-list\n" |
| 7422 | "Regular expression access list name\n") |
| 7423 | { |
| 7424 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7425 | bgp_show_type_filter_list); |
| 7426 | } |
| 7427 | |
| 7428 | /* old command */ |
| 7429 | DEFUN (show_ipv6_mbgp_filter_list, |
| 7430 | show_ipv6_mbgp_filter_list_cmd, |
| 7431 | "show ipv6 mbgp filter-list WORD", |
| 7432 | SHOW_STR |
| 7433 | IPV6_STR |
| 7434 | MBGP_STR |
| 7435 | "Display routes conforming to the filter-list\n" |
| 7436 | "Regular expression access list name\n") |
| 7437 | { |
| 7438 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7439 | bgp_show_type_filter_list); |
| 7440 | } |
| 7441 | #endif /* HAVE_IPV6 */ |
| 7442 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7443 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7444 | 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] | 7445 | safi_t safi, enum bgp_show_type type) |
| 7446 | { |
| 7447 | struct route_map *rmap; |
| 7448 | |
| 7449 | rmap = route_map_lookup_by_name (rmap_str); |
| 7450 | if (! rmap) |
| 7451 | { |
| 7452 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 7453 | rmap_str, VTY_NEWLINE); |
| 7454 | return CMD_WARNING; |
| 7455 | } |
| 7456 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7457 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7458 | } |
| 7459 | |
| 7460 | DEFUN (show_ip_bgp_route_map, |
| 7461 | show_ip_bgp_route_map_cmd, |
| 7462 | "show ip bgp route-map WORD", |
| 7463 | SHOW_STR |
| 7464 | IP_STR |
| 7465 | BGP_STR |
| 7466 | "Display routes matching the route-map\n" |
| 7467 | "A route-map to match on\n") |
| 7468 | { |
| 7469 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7470 | bgp_show_type_route_map); |
| 7471 | } |
| 7472 | |
| 7473 | DEFUN (show_ip_bgp_flap_route_map, |
| 7474 | show_ip_bgp_flap_route_map_cmd, |
| 7475 | "show ip bgp flap-statistics route-map WORD", |
| 7476 | SHOW_STR |
| 7477 | IP_STR |
| 7478 | BGP_STR |
| 7479 | "Display flap statistics of routes\n" |
| 7480 | "Display routes matching the route-map\n" |
| 7481 | "A route-map to match on\n") |
| 7482 | { |
| 7483 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7484 | bgp_show_type_flap_route_map); |
| 7485 | } |
| 7486 | |
| 7487 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 7488 | show_ip_bgp_ipv4_route_map_cmd, |
| 7489 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 7490 | SHOW_STR |
| 7491 | IP_STR |
| 7492 | BGP_STR |
| 7493 | "Address family\n" |
| 7494 | "Address Family modifier\n" |
| 7495 | "Address Family modifier\n" |
| 7496 | "Display routes matching the route-map\n" |
| 7497 | "A route-map to match on\n") |
| 7498 | { |
| 7499 | if (strncmp (argv[0], "m", 1) == 0) |
| 7500 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7501 | bgp_show_type_route_map); |
| 7502 | |
| 7503 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7504 | bgp_show_type_route_map); |
| 7505 | } |
| 7506 | |
| 7507 | DEFUN (show_bgp_route_map, |
| 7508 | show_bgp_route_map_cmd, |
| 7509 | "show bgp route-map WORD", |
| 7510 | SHOW_STR |
| 7511 | BGP_STR |
| 7512 | "Display routes matching the route-map\n" |
| 7513 | "A route-map to match on\n") |
| 7514 | { |
| 7515 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7516 | bgp_show_type_route_map); |
| 7517 | } |
| 7518 | |
| 7519 | ALIAS (show_bgp_route_map, |
| 7520 | show_bgp_ipv6_route_map_cmd, |
| 7521 | "show bgp ipv6 route-map WORD", |
| 7522 | SHOW_STR |
| 7523 | BGP_STR |
| 7524 | "Address family\n" |
| 7525 | "Display routes matching the route-map\n" |
| 7526 | "A route-map to match on\n") |
| 7527 | |
| 7528 | DEFUN (show_ip_bgp_cidr_only, |
| 7529 | show_ip_bgp_cidr_only_cmd, |
| 7530 | "show ip bgp cidr-only", |
| 7531 | SHOW_STR |
| 7532 | IP_STR |
| 7533 | BGP_STR |
| 7534 | "Display only routes with non-natural netmasks\n") |
| 7535 | { |
| 7536 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7537 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7538 | } |
| 7539 | |
| 7540 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 7541 | show_ip_bgp_flap_cidr_only_cmd, |
| 7542 | "show ip bgp flap-statistics cidr-only", |
| 7543 | SHOW_STR |
| 7544 | IP_STR |
| 7545 | BGP_STR |
| 7546 | "Display flap statistics of routes\n" |
| 7547 | "Display only routes with non-natural netmasks\n") |
| 7548 | { |
| 7549 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7550 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7551 | } |
| 7552 | |
| 7553 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 7554 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 7555 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 7556 | SHOW_STR |
| 7557 | IP_STR |
| 7558 | BGP_STR |
| 7559 | "Address family\n" |
| 7560 | "Address Family modifier\n" |
| 7561 | "Address Family modifier\n" |
| 7562 | "Display only routes with non-natural netmasks\n") |
| 7563 | { |
| 7564 | if (strncmp (argv[0], "m", 1) == 0) |
| 7565 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7566 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7567 | |
| 7568 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7569 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7570 | } |
| 7571 | |
| 7572 | DEFUN (show_ip_bgp_community_all, |
| 7573 | show_ip_bgp_community_all_cmd, |
| 7574 | "show ip bgp community", |
| 7575 | SHOW_STR |
| 7576 | IP_STR |
| 7577 | BGP_STR |
| 7578 | "Display routes matching the communities\n") |
| 7579 | { |
| 7580 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7581 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7582 | } |
| 7583 | |
| 7584 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 7585 | show_ip_bgp_ipv4_community_all_cmd, |
| 7586 | "show ip bgp ipv4 (unicast|multicast) community", |
| 7587 | SHOW_STR |
| 7588 | IP_STR |
| 7589 | BGP_STR |
| 7590 | "Address family\n" |
| 7591 | "Address Family modifier\n" |
| 7592 | "Address Family modifier\n" |
| 7593 | "Display routes matching the communities\n") |
| 7594 | { |
| 7595 | if (strncmp (argv[0], "m", 1) == 0) |
| 7596 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7597 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7598 | |
| 7599 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7600 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7601 | } |
| 7602 | |
| 7603 | #ifdef HAVE_IPV6 |
| 7604 | DEFUN (show_bgp_community_all, |
| 7605 | show_bgp_community_all_cmd, |
| 7606 | "show bgp community", |
| 7607 | SHOW_STR |
| 7608 | BGP_STR |
| 7609 | "Display routes matching the communities\n") |
| 7610 | { |
| 7611 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7612 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7613 | } |
| 7614 | |
| 7615 | ALIAS (show_bgp_community_all, |
| 7616 | show_bgp_ipv6_community_all_cmd, |
| 7617 | "show bgp ipv6 community", |
| 7618 | SHOW_STR |
| 7619 | BGP_STR |
| 7620 | "Address family\n" |
| 7621 | "Display routes matching the communities\n") |
| 7622 | |
| 7623 | /* old command */ |
| 7624 | DEFUN (show_ipv6_bgp_community_all, |
| 7625 | show_ipv6_bgp_community_all_cmd, |
| 7626 | "show ipv6 bgp community", |
| 7627 | SHOW_STR |
| 7628 | IPV6_STR |
| 7629 | BGP_STR |
| 7630 | "Display routes matching the communities\n") |
| 7631 | { |
| 7632 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7633 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7634 | } |
| 7635 | |
| 7636 | /* old command */ |
| 7637 | DEFUN (show_ipv6_mbgp_community_all, |
| 7638 | show_ipv6_mbgp_community_all_cmd, |
| 7639 | "show ipv6 mbgp community", |
| 7640 | SHOW_STR |
| 7641 | IPV6_STR |
| 7642 | MBGP_STR |
| 7643 | "Display routes matching the communities\n") |
| 7644 | { |
| 7645 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7646 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7647 | } |
| 7648 | #endif /* HAVE_IPV6 */ |
| 7649 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7650 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7651 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 7652 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7653 | { |
| 7654 | struct community *com; |
| 7655 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7656 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7657 | int i; |
| 7658 | char *str; |
| 7659 | int first = 0; |
| 7660 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7661 | /* BGP structure lookup */ |
| 7662 | if (view_name) |
| 7663 | { |
| 7664 | bgp = bgp_lookup_by_name (view_name); |
| 7665 | if (bgp == NULL) |
| 7666 | { |
| 7667 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 7668 | return CMD_WARNING; |
| 7669 | } |
| 7670 | } |
| 7671 | else |
| 7672 | { |
| 7673 | bgp = bgp_get_default (); |
| 7674 | if (bgp == NULL) |
| 7675 | { |
| 7676 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 7677 | return CMD_WARNING; |
| 7678 | } |
| 7679 | } |
| 7680 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7681 | b = buffer_new (1024); |
| 7682 | for (i = 0; i < argc; i++) |
| 7683 | { |
| 7684 | if (first) |
| 7685 | buffer_putc (b, ' '); |
| 7686 | else |
| 7687 | { |
| 7688 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7689 | continue; |
| 7690 | first = 1; |
| 7691 | } |
| 7692 | |
| 7693 | buffer_putstr (b, argv[i]); |
| 7694 | } |
| 7695 | buffer_putc (b, '\0'); |
| 7696 | |
| 7697 | str = buffer_getstr (b); |
| 7698 | buffer_free (b); |
| 7699 | |
| 7700 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7701 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7702 | if (! com) |
| 7703 | { |
| 7704 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 7705 | return CMD_WARNING; |
| 7706 | } |
| 7707 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7708 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7709 | (exact ? bgp_show_type_community_exact : |
| 7710 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7711 | } |
| 7712 | |
| 7713 | DEFUN (show_ip_bgp_community, |
| 7714 | show_ip_bgp_community_cmd, |
| 7715 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7716 | SHOW_STR |
| 7717 | IP_STR |
| 7718 | BGP_STR |
| 7719 | "Display routes matching the communities\n" |
| 7720 | "community number\n" |
| 7721 | "Do not send outside local AS (well-known community)\n" |
| 7722 | "Do not advertise to any peer (well-known community)\n" |
| 7723 | "Do not export to next AS (well-known community)\n") |
| 7724 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7725 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7726 | } |
| 7727 | |
| 7728 | ALIAS (show_ip_bgp_community, |
| 7729 | show_ip_bgp_community2_cmd, |
| 7730 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7731 | SHOW_STR |
| 7732 | IP_STR |
| 7733 | BGP_STR |
| 7734 | "Display routes matching the communities\n" |
| 7735 | "community number\n" |
| 7736 | "Do not send outside local AS (well-known community)\n" |
| 7737 | "Do not advertise to any peer (well-known community)\n" |
| 7738 | "Do not export to next AS (well-known community)\n" |
| 7739 | "community number\n" |
| 7740 | "Do not send outside local AS (well-known community)\n" |
| 7741 | "Do not advertise to any peer (well-known community)\n" |
| 7742 | "Do not export to next AS (well-known community)\n") |
| 7743 | |
| 7744 | ALIAS (show_ip_bgp_community, |
| 7745 | show_ip_bgp_community3_cmd, |
| 7746 | "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)", |
| 7747 | SHOW_STR |
| 7748 | IP_STR |
| 7749 | BGP_STR |
| 7750 | "Display routes matching the communities\n" |
| 7751 | "community number\n" |
| 7752 | "Do not send outside local AS (well-known community)\n" |
| 7753 | "Do not advertise to any peer (well-known community)\n" |
| 7754 | "Do not export to next AS (well-known community)\n" |
| 7755 | "community number\n" |
| 7756 | "Do not send outside local AS (well-known community)\n" |
| 7757 | "Do not advertise to any peer (well-known community)\n" |
| 7758 | "Do not export to next AS (well-known community)\n" |
| 7759 | "community number\n" |
| 7760 | "Do not send outside local AS (well-known community)\n" |
| 7761 | "Do not advertise to any peer (well-known community)\n" |
| 7762 | "Do not export to next AS (well-known community)\n") |
| 7763 | |
| 7764 | ALIAS (show_ip_bgp_community, |
| 7765 | show_ip_bgp_community4_cmd, |
| 7766 | "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)", |
| 7767 | SHOW_STR |
| 7768 | IP_STR |
| 7769 | BGP_STR |
| 7770 | "Display routes matching the communities\n" |
| 7771 | "community number\n" |
| 7772 | "Do not send outside local AS (well-known community)\n" |
| 7773 | "Do not advertise to any peer (well-known community)\n" |
| 7774 | "Do not export to next AS (well-known community)\n" |
| 7775 | "community number\n" |
| 7776 | "Do not send outside local AS (well-known community)\n" |
| 7777 | "Do not advertise to any peer (well-known community)\n" |
| 7778 | "Do not export to next AS (well-known community)\n" |
| 7779 | "community number\n" |
| 7780 | "Do not send outside local AS (well-known community)\n" |
| 7781 | "Do not advertise to any peer (well-known community)\n" |
| 7782 | "Do not export to next AS (well-known community)\n" |
| 7783 | "community number\n" |
| 7784 | "Do not send outside local AS (well-known community)\n" |
| 7785 | "Do not advertise to any peer (well-known community)\n" |
| 7786 | "Do not export to next AS (well-known community)\n") |
| 7787 | |
| 7788 | DEFUN (show_ip_bgp_ipv4_community, |
| 7789 | show_ip_bgp_ipv4_community_cmd, |
| 7790 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7791 | SHOW_STR |
| 7792 | IP_STR |
| 7793 | BGP_STR |
| 7794 | "Address family\n" |
| 7795 | "Address Family modifier\n" |
| 7796 | "Address Family modifier\n" |
| 7797 | "Display routes matching the communities\n" |
| 7798 | "community number\n" |
| 7799 | "Do not send outside local AS (well-known community)\n" |
| 7800 | "Do not advertise to any peer (well-known community)\n" |
| 7801 | "Do not export to next AS (well-known community)\n") |
| 7802 | { |
| 7803 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7804 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7805 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7806 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7807 | } |
| 7808 | |
| 7809 | ALIAS (show_ip_bgp_ipv4_community, |
| 7810 | show_ip_bgp_ipv4_community2_cmd, |
| 7811 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7812 | SHOW_STR |
| 7813 | IP_STR |
| 7814 | BGP_STR |
| 7815 | "Address family\n" |
| 7816 | "Address Family modifier\n" |
| 7817 | "Address Family modifier\n" |
| 7818 | "Display routes matching the communities\n" |
| 7819 | "community number\n" |
| 7820 | "Do not send outside local AS (well-known community)\n" |
| 7821 | "Do not advertise to any peer (well-known community)\n" |
| 7822 | "Do not export to next AS (well-known community)\n" |
| 7823 | "community number\n" |
| 7824 | "Do not send outside local AS (well-known community)\n" |
| 7825 | "Do not advertise to any peer (well-known community)\n" |
| 7826 | "Do not export to next AS (well-known community)\n") |
| 7827 | |
| 7828 | ALIAS (show_ip_bgp_ipv4_community, |
| 7829 | show_ip_bgp_ipv4_community3_cmd, |
| 7830 | "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)", |
| 7831 | SHOW_STR |
| 7832 | IP_STR |
| 7833 | BGP_STR |
| 7834 | "Address family\n" |
| 7835 | "Address Family modifier\n" |
| 7836 | "Address Family modifier\n" |
| 7837 | "Display routes matching the communities\n" |
| 7838 | "community number\n" |
| 7839 | "Do not send outside local AS (well-known community)\n" |
| 7840 | "Do not advertise to any peer (well-known community)\n" |
| 7841 | "Do not export to next AS (well-known community)\n" |
| 7842 | "community number\n" |
| 7843 | "Do not send outside local AS (well-known community)\n" |
| 7844 | "Do not advertise to any peer (well-known community)\n" |
| 7845 | "Do not export to next AS (well-known community)\n" |
| 7846 | "community number\n" |
| 7847 | "Do not send outside local AS (well-known community)\n" |
| 7848 | "Do not advertise to any peer (well-known community)\n" |
| 7849 | "Do not export to next AS (well-known community)\n") |
| 7850 | |
| 7851 | ALIAS (show_ip_bgp_ipv4_community, |
| 7852 | show_ip_bgp_ipv4_community4_cmd, |
| 7853 | "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)", |
| 7854 | SHOW_STR |
| 7855 | IP_STR |
| 7856 | BGP_STR |
| 7857 | "Address family\n" |
| 7858 | "Address Family modifier\n" |
| 7859 | "Address Family modifier\n" |
| 7860 | "Display routes matching the communities\n" |
| 7861 | "community number\n" |
| 7862 | "Do not send outside local AS (well-known community)\n" |
| 7863 | "Do not advertise to any peer (well-known community)\n" |
| 7864 | "Do not export to next AS (well-known community)\n" |
| 7865 | "community number\n" |
| 7866 | "Do not send outside local AS (well-known community)\n" |
| 7867 | "Do not advertise to any peer (well-known community)\n" |
| 7868 | "Do not export to next AS (well-known community)\n" |
| 7869 | "community number\n" |
| 7870 | "Do not send outside local AS (well-known community)\n" |
| 7871 | "Do not advertise to any peer (well-known community)\n" |
| 7872 | "Do not export to next AS (well-known community)\n" |
| 7873 | "community number\n" |
| 7874 | "Do not send outside local AS (well-known community)\n" |
| 7875 | "Do not advertise to any peer (well-known community)\n" |
| 7876 | "Do not export to next AS (well-known community)\n") |
| 7877 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7878 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 7879 | show_bgp_view_afi_safi_community_all_cmd, |
| 7880 | #ifdef HAVE_IPV6 |
| 7881 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
| 7882 | #else |
| 7883 | "show bgp view WORD ipv4 (unicast|multicast) community", |
| 7884 | #endif |
| 7885 | SHOW_STR |
| 7886 | BGP_STR |
| 7887 | "BGP view\n" |
| 7888 | "BGP view name\n" |
| 7889 | "Address family\n" |
| 7890 | #ifdef HAVE_IPV6 |
| 7891 | "Address family\n" |
| 7892 | #endif |
| 7893 | "Address Family modifier\n" |
| 7894 | "Address Family modifier\n" |
| 7895 | "Display routes containing communities\n") |
| 7896 | { |
| 7897 | int afi; |
| 7898 | int safi; |
| 7899 | struct bgp *bgp; |
| 7900 | |
| 7901 | /* BGP structure lookup. */ |
| 7902 | bgp = bgp_lookup_by_name (argv[0]); |
| 7903 | if (bgp == NULL) |
| 7904 | { |
| 7905 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7906 | return CMD_WARNING; |
| 7907 | } |
| 7908 | |
| 7909 | #ifdef HAVE_IPV6 |
| 7910 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 7911 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7912 | #else |
| 7913 | afi = AFI_IP; |
| 7914 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7915 | #endif |
| 7916 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 7917 | } |
| 7918 | |
| 7919 | DEFUN (show_bgp_view_afi_safi_community, |
| 7920 | show_bgp_view_afi_safi_community_cmd, |
| 7921 | #ifdef HAVE_IPV6 |
| 7922 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7923 | #else |
| 7924 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7925 | #endif |
| 7926 | SHOW_STR |
| 7927 | BGP_STR |
| 7928 | "BGP view\n" |
| 7929 | "BGP view name\n" |
| 7930 | "Address family\n" |
| 7931 | #ifdef HAVE_IPV6 |
| 7932 | "Address family\n" |
| 7933 | #endif |
| 7934 | "Address family modifier\n" |
| 7935 | "Address family modifier\n" |
| 7936 | "Display routes matching the communities\n" |
| 7937 | "community number\n" |
| 7938 | "Do not send outside local AS (well-known community)\n" |
| 7939 | "Do not advertise to any peer (well-known community)\n" |
| 7940 | "Do not export to next AS (well-known community)\n") |
| 7941 | { |
| 7942 | int afi; |
| 7943 | int safi; |
| 7944 | |
| 7945 | #ifdef HAVE_IPV6 |
| 7946 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 7947 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7948 | return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi); |
| 7949 | #else |
| 7950 | afi = AFI_IP; |
| 7951 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7952 | return bgp_show_community (vty, argv[0], argc-2, &argv[2], 0, afi, safi); |
| 7953 | #endif |
| 7954 | } |
| 7955 | |
| 7956 | ALIAS (show_bgp_view_afi_safi_community, |
| 7957 | show_bgp_view_afi_safi_community2_cmd, |
| 7958 | #ifdef HAVE_IPV6 |
| 7959 | "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)", |
| 7960 | #else |
| 7961 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7962 | #endif |
| 7963 | SHOW_STR |
| 7964 | BGP_STR |
| 7965 | "BGP view\n" |
| 7966 | "BGP view name\n" |
| 7967 | "Address family\n" |
| 7968 | #ifdef HAVE_IPV6 |
| 7969 | "Address family\n" |
| 7970 | #endif |
| 7971 | "Address family modifier\n" |
| 7972 | "Address family modifier\n" |
| 7973 | "Display routes matching the communities\n" |
| 7974 | "community number\n" |
| 7975 | "Do not send outside local AS (well-known community)\n" |
| 7976 | "Do not advertise to any peer (well-known community)\n" |
| 7977 | "Do not export to next AS (well-known community)\n" |
| 7978 | "community number\n" |
| 7979 | "Do not send outside local AS (well-known community)\n" |
| 7980 | "Do not advertise to any peer (well-known community)\n" |
| 7981 | "Do not export to next AS (well-known community)\n") |
| 7982 | |
| 7983 | ALIAS (show_bgp_view_afi_safi_community, |
| 7984 | show_bgp_view_afi_safi_community3_cmd, |
| 7985 | #ifdef HAVE_IPV6 |
| 7986 | "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)", |
| 7987 | #else |
| 7988 | "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)", |
| 7989 | #endif |
| 7990 | SHOW_STR |
| 7991 | BGP_STR |
| 7992 | "BGP view\n" |
| 7993 | "BGP view name\n" |
| 7994 | "Address family\n" |
| 7995 | #ifdef HAVE_IPV6 |
| 7996 | "Address family\n" |
| 7997 | #endif |
| 7998 | "Address family modifier\n" |
| 7999 | "Address family modifier\n" |
| 8000 | "Display routes matching the communities\n" |
| 8001 | "community number\n" |
| 8002 | "Do not send outside local AS (well-known community)\n" |
| 8003 | "Do not advertise to any peer (well-known community)\n" |
| 8004 | "Do not export to next AS (well-known community)\n" |
| 8005 | "community number\n" |
| 8006 | "Do not send outside local AS (well-known community)\n" |
| 8007 | "Do not advertise to any peer (well-known community)\n" |
| 8008 | "Do not export to next AS (well-known community)\n" |
| 8009 | "community number\n" |
| 8010 | "Do not send outside local AS (well-known community)\n" |
| 8011 | "Do not advertise to any peer (well-known community)\n" |
| 8012 | "Do not export to next AS (well-known community)\n") |
| 8013 | |
| 8014 | ALIAS (show_bgp_view_afi_safi_community, |
| 8015 | show_bgp_view_afi_safi_community4_cmd, |
| 8016 | #ifdef HAVE_IPV6 |
| 8017 | "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)", |
| 8018 | #else |
| 8019 | "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)", |
| 8020 | #endif |
| 8021 | SHOW_STR |
| 8022 | BGP_STR |
| 8023 | "BGP view\n" |
| 8024 | "BGP view name\n" |
| 8025 | "Address family\n" |
| 8026 | #ifdef HAVE_IPV6 |
| 8027 | "Address family\n" |
| 8028 | #endif |
| 8029 | "Address family modifier\n" |
| 8030 | "Address family modifier\n" |
| 8031 | "Display routes matching the communities\n" |
| 8032 | "community number\n" |
| 8033 | "Do not send outside local AS (well-known community)\n" |
| 8034 | "Do not advertise to any peer (well-known community)\n" |
| 8035 | "Do not export to next AS (well-known community)\n" |
| 8036 | "community number\n" |
| 8037 | "Do not send outside local AS (well-known community)\n" |
| 8038 | "Do not advertise to any peer (well-known community)\n" |
| 8039 | "Do not export to next AS (well-known community)\n" |
| 8040 | "community number\n" |
| 8041 | "Do not send outside local AS (well-known community)\n" |
| 8042 | "Do not advertise to any peer (well-known community)\n" |
| 8043 | "Do not export to next AS (well-known community)\n" |
| 8044 | "community number\n" |
| 8045 | "Do not send outside local AS (well-known community)\n" |
| 8046 | "Do not advertise to any peer (well-known community)\n" |
| 8047 | "Do not export to next AS (well-known community)\n") |
| 8048 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8049 | DEFUN (show_ip_bgp_community_exact, |
| 8050 | show_ip_bgp_community_exact_cmd, |
| 8051 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8052 | SHOW_STR |
| 8053 | IP_STR |
| 8054 | BGP_STR |
| 8055 | "Display routes matching the communities\n" |
| 8056 | "community number\n" |
| 8057 | "Do not send outside local AS (well-known community)\n" |
| 8058 | "Do not advertise to any peer (well-known community)\n" |
| 8059 | "Do not export to next AS (well-known community)\n" |
| 8060 | "Exact match of the communities") |
| 8061 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8062 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8063 | } |
| 8064 | |
| 8065 | ALIAS (show_ip_bgp_community_exact, |
| 8066 | show_ip_bgp_community2_exact_cmd, |
| 8067 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8068 | SHOW_STR |
| 8069 | IP_STR |
| 8070 | BGP_STR |
| 8071 | "Display routes matching the communities\n" |
| 8072 | "community number\n" |
| 8073 | "Do not send outside local AS (well-known community)\n" |
| 8074 | "Do not advertise to any peer (well-known community)\n" |
| 8075 | "Do not export to next AS (well-known community)\n" |
| 8076 | "community number\n" |
| 8077 | "Do not send outside local AS (well-known community)\n" |
| 8078 | "Do not advertise to any peer (well-known community)\n" |
| 8079 | "Do not export to next AS (well-known community)\n" |
| 8080 | "Exact match of the communities") |
| 8081 | |
| 8082 | ALIAS (show_ip_bgp_community_exact, |
| 8083 | show_ip_bgp_community3_exact_cmd, |
| 8084 | "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", |
| 8085 | SHOW_STR |
| 8086 | IP_STR |
| 8087 | BGP_STR |
| 8088 | "Display routes matching the communities\n" |
| 8089 | "community number\n" |
| 8090 | "Do not send outside local AS (well-known community)\n" |
| 8091 | "Do not advertise to any peer (well-known community)\n" |
| 8092 | "Do not export to next AS (well-known community)\n" |
| 8093 | "community number\n" |
| 8094 | "Do not send outside local AS (well-known community)\n" |
| 8095 | "Do not advertise to any peer (well-known community)\n" |
| 8096 | "Do not export to next AS (well-known community)\n" |
| 8097 | "community number\n" |
| 8098 | "Do not send outside local AS (well-known community)\n" |
| 8099 | "Do not advertise to any peer (well-known community)\n" |
| 8100 | "Do not export to next AS (well-known community)\n" |
| 8101 | "Exact match of the communities") |
| 8102 | |
| 8103 | ALIAS (show_ip_bgp_community_exact, |
| 8104 | show_ip_bgp_community4_exact_cmd, |
| 8105 | "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", |
| 8106 | SHOW_STR |
| 8107 | IP_STR |
| 8108 | BGP_STR |
| 8109 | "Display routes matching the communities\n" |
| 8110 | "community number\n" |
| 8111 | "Do not send outside local AS (well-known community)\n" |
| 8112 | "Do not advertise to any peer (well-known community)\n" |
| 8113 | "Do not export to next AS (well-known community)\n" |
| 8114 | "community number\n" |
| 8115 | "Do not send outside local AS (well-known community)\n" |
| 8116 | "Do not advertise to any peer (well-known community)\n" |
| 8117 | "Do not export to next AS (well-known community)\n" |
| 8118 | "community number\n" |
| 8119 | "Do not send outside local AS (well-known community)\n" |
| 8120 | "Do not advertise to any peer (well-known community)\n" |
| 8121 | "Do not export to next AS (well-known community)\n" |
| 8122 | "community number\n" |
| 8123 | "Do not send outside local AS (well-known community)\n" |
| 8124 | "Do not advertise to any peer (well-known community)\n" |
| 8125 | "Do not export to next AS (well-known community)\n" |
| 8126 | "Exact match of the communities") |
| 8127 | |
| 8128 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 8129 | show_ip_bgp_ipv4_community_exact_cmd, |
| 8130 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8131 | SHOW_STR |
| 8132 | IP_STR |
| 8133 | BGP_STR |
| 8134 | "Address family\n" |
| 8135 | "Address Family modifier\n" |
| 8136 | "Address Family modifier\n" |
| 8137 | "Display routes matching the communities\n" |
| 8138 | "community number\n" |
| 8139 | "Do not send outside local AS (well-known community)\n" |
| 8140 | "Do not advertise to any peer (well-known community)\n" |
| 8141 | "Do not export to next AS (well-known community)\n" |
| 8142 | "Exact match of the communities") |
| 8143 | { |
| 8144 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8145 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8146 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8147 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8148 | } |
| 8149 | |
| 8150 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8151 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 8152 | "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", |
| 8153 | SHOW_STR |
| 8154 | IP_STR |
| 8155 | BGP_STR |
| 8156 | "Address family\n" |
| 8157 | "Address Family modifier\n" |
| 8158 | "Address Family modifier\n" |
| 8159 | "Display routes matching the communities\n" |
| 8160 | "community number\n" |
| 8161 | "Do not send outside local AS (well-known community)\n" |
| 8162 | "Do not advertise to any peer (well-known community)\n" |
| 8163 | "Do not export to next AS (well-known community)\n" |
| 8164 | "community number\n" |
| 8165 | "Do not send outside local AS (well-known community)\n" |
| 8166 | "Do not advertise to any peer (well-known community)\n" |
| 8167 | "Do not export to next AS (well-known community)\n" |
| 8168 | "Exact match of the communities") |
| 8169 | |
| 8170 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8171 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 8172 | "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", |
| 8173 | SHOW_STR |
| 8174 | IP_STR |
| 8175 | BGP_STR |
| 8176 | "Address family\n" |
| 8177 | "Address Family modifier\n" |
| 8178 | "Address Family modifier\n" |
| 8179 | "Display routes matching the communities\n" |
| 8180 | "community number\n" |
| 8181 | "Do not send outside local AS (well-known community)\n" |
| 8182 | "Do not advertise to any peer (well-known community)\n" |
| 8183 | "Do not export to next AS (well-known community)\n" |
| 8184 | "community number\n" |
| 8185 | "Do not send outside local AS (well-known community)\n" |
| 8186 | "Do not advertise to any peer (well-known community)\n" |
| 8187 | "Do not export to next AS (well-known community)\n" |
| 8188 | "community number\n" |
| 8189 | "Do not send outside local AS (well-known community)\n" |
| 8190 | "Do not advertise to any peer (well-known community)\n" |
| 8191 | "Do not export to next AS (well-known community)\n" |
| 8192 | "Exact match of the communities") |
| 8193 | |
| 8194 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8195 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 8196 | "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", |
| 8197 | SHOW_STR |
| 8198 | IP_STR |
| 8199 | BGP_STR |
| 8200 | "Address family\n" |
| 8201 | "Address Family modifier\n" |
| 8202 | "Address Family modifier\n" |
| 8203 | "Display routes matching the communities\n" |
| 8204 | "community number\n" |
| 8205 | "Do not send outside local AS (well-known community)\n" |
| 8206 | "Do not advertise to any peer (well-known community)\n" |
| 8207 | "Do not export to next AS (well-known community)\n" |
| 8208 | "community number\n" |
| 8209 | "Do not send outside local AS (well-known community)\n" |
| 8210 | "Do not advertise to any peer (well-known community)\n" |
| 8211 | "Do not export to next AS (well-known community)\n" |
| 8212 | "community number\n" |
| 8213 | "Do not send outside local AS (well-known community)\n" |
| 8214 | "Do not advertise to any peer (well-known community)\n" |
| 8215 | "Do not export to next AS (well-known community)\n" |
| 8216 | "community number\n" |
| 8217 | "Do not send outside local AS (well-known community)\n" |
| 8218 | "Do not advertise to any peer (well-known community)\n" |
| 8219 | "Do not export to next AS (well-known community)\n" |
| 8220 | "Exact match of the communities") |
| 8221 | |
| 8222 | #ifdef HAVE_IPV6 |
| 8223 | DEFUN (show_bgp_community, |
| 8224 | show_bgp_community_cmd, |
| 8225 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8226 | SHOW_STR |
| 8227 | BGP_STR |
| 8228 | "Display routes matching the communities\n" |
| 8229 | "community number\n" |
| 8230 | "Do not send outside local AS (well-known community)\n" |
| 8231 | "Do not advertise to any peer (well-known community)\n" |
| 8232 | "Do not export to next AS (well-known community)\n") |
| 8233 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8234 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8235 | } |
| 8236 | |
| 8237 | ALIAS (show_bgp_community, |
| 8238 | show_bgp_ipv6_community_cmd, |
| 8239 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 8240 | SHOW_STR |
| 8241 | BGP_STR |
| 8242 | "Address family\n" |
| 8243 | "Display routes matching the communities\n" |
| 8244 | "community number\n" |
| 8245 | "Do not send outside local AS (well-known community)\n" |
| 8246 | "Do not advertise to any peer (well-known community)\n" |
| 8247 | "Do not export to next AS (well-known community)\n") |
| 8248 | |
| 8249 | ALIAS (show_bgp_community, |
| 8250 | show_bgp_community2_cmd, |
| 8251 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8252 | SHOW_STR |
| 8253 | BGP_STR |
| 8254 | "Display routes matching the communities\n" |
| 8255 | "community number\n" |
| 8256 | "Do not send outside local AS (well-known community)\n" |
| 8257 | "Do not advertise to any peer (well-known community)\n" |
| 8258 | "Do not export to next AS (well-known community)\n" |
| 8259 | "community number\n" |
| 8260 | "Do not send outside local AS (well-known community)\n" |
| 8261 | "Do not advertise to any peer (well-known community)\n" |
| 8262 | "Do not export to next AS (well-known community)\n") |
| 8263 | |
| 8264 | ALIAS (show_bgp_community, |
| 8265 | show_bgp_ipv6_community2_cmd, |
| 8266 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8267 | SHOW_STR |
| 8268 | BGP_STR |
| 8269 | "Address family\n" |
| 8270 | "Display routes matching the communities\n" |
| 8271 | "community number\n" |
| 8272 | "Do not send outside local AS (well-known community)\n" |
| 8273 | "Do not advertise to any peer (well-known community)\n" |
| 8274 | "Do not export to next AS (well-known community)\n" |
| 8275 | "community number\n" |
| 8276 | "Do not send outside local AS (well-known community)\n" |
| 8277 | "Do not advertise to any peer (well-known community)\n" |
| 8278 | "Do not export to next AS (well-known community)\n") |
| 8279 | |
| 8280 | ALIAS (show_bgp_community, |
| 8281 | show_bgp_community3_cmd, |
| 8282 | "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)", |
| 8283 | SHOW_STR |
| 8284 | BGP_STR |
| 8285 | "Display routes matching the communities\n" |
| 8286 | "community number\n" |
| 8287 | "Do not send outside local AS (well-known community)\n" |
| 8288 | "Do not advertise to any peer (well-known community)\n" |
| 8289 | "Do not export to next AS (well-known community)\n" |
| 8290 | "community number\n" |
| 8291 | "Do not send outside local AS (well-known community)\n" |
| 8292 | "Do not advertise to any peer (well-known community)\n" |
| 8293 | "Do not export to next AS (well-known community)\n" |
| 8294 | "community number\n" |
| 8295 | "Do not send outside local AS (well-known community)\n" |
| 8296 | "Do not advertise to any peer (well-known community)\n" |
| 8297 | "Do not export to next AS (well-known community)\n") |
| 8298 | |
| 8299 | ALIAS (show_bgp_community, |
| 8300 | show_bgp_ipv6_community3_cmd, |
| 8301 | "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)", |
| 8302 | SHOW_STR |
| 8303 | BGP_STR |
| 8304 | "Address family\n" |
| 8305 | "Display routes matching the communities\n" |
| 8306 | "community number\n" |
| 8307 | "Do not send outside local AS (well-known community)\n" |
| 8308 | "Do not advertise to any peer (well-known community)\n" |
| 8309 | "Do not export to next AS (well-known community)\n" |
| 8310 | "community number\n" |
| 8311 | "Do not send outside local AS (well-known community)\n" |
| 8312 | "Do not advertise to any peer (well-known community)\n" |
| 8313 | "Do not export to next AS (well-known community)\n" |
| 8314 | "community number\n" |
| 8315 | "Do not send outside local AS (well-known community)\n" |
| 8316 | "Do not advertise to any peer (well-known community)\n" |
| 8317 | "Do not export to next AS (well-known community)\n") |
| 8318 | |
| 8319 | ALIAS (show_bgp_community, |
| 8320 | show_bgp_community4_cmd, |
| 8321 | "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)", |
| 8322 | SHOW_STR |
| 8323 | BGP_STR |
| 8324 | "Display routes matching the communities\n" |
| 8325 | "community number\n" |
| 8326 | "Do not send outside local AS (well-known community)\n" |
| 8327 | "Do not advertise to any peer (well-known community)\n" |
| 8328 | "Do not export to next AS (well-known community)\n" |
| 8329 | "community number\n" |
| 8330 | "Do not send outside local AS (well-known community)\n" |
| 8331 | "Do not advertise to any peer (well-known community)\n" |
| 8332 | "Do not export to next AS (well-known community)\n" |
| 8333 | "community number\n" |
| 8334 | "Do not send outside local AS (well-known community)\n" |
| 8335 | "Do not advertise to any peer (well-known community)\n" |
| 8336 | "Do not export to next AS (well-known community)\n" |
| 8337 | "community number\n" |
| 8338 | "Do not send outside local AS (well-known community)\n" |
| 8339 | "Do not advertise to any peer (well-known community)\n" |
| 8340 | "Do not export to next AS (well-known community)\n") |
| 8341 | |
| 8342 | ALIAS (show_bgp_community, |
| 8343 | show_bgp_ipv6_community4_cmd, |
| 8344 | "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)", |
| 8345 | SHOW_STR |
| 8346 | BGP_STR |
| 8347 | "Address family\n" |
| 8348 | "Display routes matching the communities\n" |
| 8349 | "community number\n" |
| 8350 | "Do not send outside local AS (well-known community)\n" |
| 8351 | "Do not advertise to any peer (well-known community)\n" |
| 8352 | "Do not export to next AS (well-known community)\n" |
| 8353 | "community number\n" |
| 8354 | "Do not send outside local AS (well-known community)\n" |
| 8355 | "Do not advertise to any peer (well-known community)\n" |
| 8356 | "Do not export to next AS (well-known community)\n" |
| 8357 | "community number\n" |
| 8358 | "Do not send outside local AS (well-known community)\n" |
| 8359 | "Do not advertise to any peer (well-known community)\n" |
| 8360 | "Do not export to next AS (well-known community)\n" |
| 8361 | "community number\n" |
| 8362 | "Do not send outside local AS (well-known community)\n" |
| 8363 | "Do not advertise to any peer (well-known community)\n" |
| 8364 | "Do not export to next AS (well-known community)\n") |
| 8365 | |
| 8366 | /* old command */ |
| 8367 | DEFUN (show_ipv6_bgp_community, |
| 8368 | show_ipv6_bgp_community_cmd, |
| 8369 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8370 | SHOW_STR |
| 8371 | IPV6_STR |
| 8372 | BGP_STR |
| 8373 | "Display routes matching the communities\n" |
| 8374 | "community number\n" |
| 8375 | "Do not send outside local AS (well-known community)\n" |
| 8376 | "Do not advertise to any peer (well-known community)\n" |
| 8377 | "Do not export to next AS (well-known community)\n") |
| 8378 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8379 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8380 | } |
| 8381 | |
| 8382 | /* old command */ |
| 8383 | ALIAS (show_ipv6_bgp_community, |
| 8384 | show_ipv6_bgp_community2_cmd, |
| 8385 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8386 | SHOW_STR |
| 8387 | IPV6_STR |
| 8388 | BGP_STR |
| 8389 | "Display routes matching the communities\n" |
| 8390 | "community number\n" |
| 8391 | "Do not send outside local AS (well-known community)\n" |
| 8392 | "Do not advertise to any peer (well-known community)\n" |
| 8393 | "Do not export to next AS (well-known community)\n" |
| 8394 | "community number\n" |
| 8395 | "Do not send outside local AS (well-known community)\n" |
| 8396 | "Do not advertise to any peer (well-known community)\n" |
| 8397 | "Do not export to next AS (well-known community)\n") |
| 8398 | |
| 8399 | /* old command */ |
| 8400 | ALIAS (show_ipv6_bgp_community, |
| 8401 | show_ipv6_bgp_community3_cmd, |
| 8402 | "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)", |
| 8403 | SHOW_STR |
| 8404 | IPV6_STR |
| 8405 | BGP_STR |
| 8406 | "Display routes matching the communities\n" |
| 8407 | "community number\n" |
| 8408 | "Do not send outside local AS (well-known community)\n" |
| 8409 | "Do not advertise to any peer (well-known community)\n" |
| 8410 | "Do not export to next AS (well-known community)\n" |
| 8411 | "community number\n" |
| 8412 | "Do not send outside local AS (well-known community)\n" |
| 8413 | "Do not advertise to any peer (well-known community)\n" |
| 8414 | "Do not export to next AS (well-known community)\n" |
| 8415 | "community number\n" |
| 8416 | "Do not send outside local AS (well-known community)\n" |
| 8417 | "Do not advertise to any peer (well-known community)\n" |
| 8418 | "Do not export to next AS (well-known community)\n") |
| 8419 | |
| 8420 | /* old command */ |
| 8421 | ALIAS (show_ipv6_bgp_community, |
| 8422 | show_ipv6_bgp_community4_cmd, |
| 8423 | "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)", |
| 8424 | SHOW_STR |
| 8425 | IPV6_STR |
| 8426 | BGP_STR |
| 8427 | "Display routes matching the communities\n" |
| 8428 | "community number\n" |
| 8429 | "Do not send outside local AS (well-known community)\n" |
| 8430 | "Do not advertise to any peer (well-known community)\n" |
| 8431 | "Do not export to next AS (well-known community)\n" |
| 8432 | "community number\n" |
| 8433 | "Do not send outside local AS (well-known community)\n" |
| 8434 | "Do not advertise to any peer (well-known community)\n" |
| 8435 | "Do not export to next AS (well-known community)\n" |
| 8436 | "community number\n" |
| 8437 | "Do not send outside local AS (well-known community)\n" |
| 8438 | "Do not advertise to any peer (well-known community)\n" |
| 8439 | "Do not export to next AS (well-known community)\n" |
| 8440 | "community number\n" |
| 8441 | "Do not send outside local AS (well-known community)\n" |
| 8442 | "Do not advertise to any peer (well-known community)\n" |
| 8443 | "Do not export to next AS (well-known community)\n") |
| 8444 | |
| 8445 | DEFUN (show_bgp_community_exact, |
| 8446 | show_bgp_community_exact_cmd, |
| 8447 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8448 | SHOW_STR |
| 8449 | BGP_STR |
| 8450 | "Display routes matching the communities\n" |
| 8451 | "community number\n" |
| 8452 | "Do not send outside local AS (well-known community)\n" |
| 8453 | "Do not advertise to any peer (well-known community)\n" |
| 8454 | "Do not export to next AS (well-known community)\n" |
| 8455 | "Exact match of the communities") |
| 8456 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8457 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8458 | } |
| 8459 | |
| 8460 | ALIAS (show_bgp_community_exact, |
| 8461 | show_bgp_ipv6_community_exact_cmd, |
| 8462 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8463 | SHOW_STR |
| 8464 | BGP_STR |
| 8465 | "Address family\n" |
| 8466 | "Display routes matching the communities\n" |
| 8467 | "community number\n" |
| 8468 | "Do not send outside local AS (well-known community)\n" |
| 8469 | "Do not advertise to any peer (well-known community)\n" |
| 8470 | "Do not export to next AS (well-known community)\n" |
| 8471 | "Exact match of the communities") |
| 8472 | |
| 8473 | ALIAS (show_bgp_community_exact, |
| 8474 | show_bgp_community2_exact_cmd, |
| 8475 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8476 | SHOW_STR |
| 8477 | BGP_STR |
| 8478 | "Display routes matching the communities\n" |
| 8479 | "community number\n" |
| 8480 | "Do not send outside local AS (well-known community)\n" |
| 8481 | "Do not advertise to any peer (well-known community)\n" |
| 8482 | "Do not export to next AS (well-known community)\n" |
| 8483 | "community number\n" |
| 8484 | "Do not send outside local AS (well-known community)\n" |
| 8485 | "Do not advertise to any peer (well-known community)\n" |
| 8486 | "Do not export to next AS (well-known community)\n" |
| 8487 | "Exact match of the communities") |
| 8488 | |
| 8489 | ALIAS (show_bgp_community_exact, |
| 8490 | show_bgp_ipv6_community2_exact_cmd, |
| 8491 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8492 | SHOW_STR |
| 8493 | BGP_STR |
| 8494 | "Address family\n" |
| 8495 | "Display routes matching the communities\n" |
| 8496 | "community number\n" |
| 8497 | "Do not send outside local AS (well-known community)\n" |
| 8498 | "Do not advertise to any peer (well-known community)\n" |
| 8499 | "Do not export to next AS (well-known community)\n" |
| 8500 | "community number\n" |
| 8501 | "Do not send outside local AS (well-known community)\n" |
| 8502 | "Do not advertise to any peer (well-known community)\n" |
| 8503 | "Do not export to next AS (well-known community)\n" |
| 8504 | "Exact match of the communities") |
| 8505 | |
| 8506 | ALIAS (show_bgp_community_exact, |
| 8507 | show_bgp_community3_exact_cmd, |
| 8508 | "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", |
| 8509 | SHOW_STR |
| 8510 | BGP_STR |
| 8511 | "Display routes matching the communities\n" |
| 8512 | "community number\n" |
| 8513 | "Do not send outside local AS (well-known community)\n" |
| 8514 | "Do not advertise to any peer (well-known community)\n" |
| 8515 | "Do not export to next AS (well-known community)\n" |
| 8516 | "community number\n" |
| 8517 | "Do not send outside local AS (well-known community)\n" |
| 8518 | "Do not advertise to any peer (well-known community)\n" |
| 8519 | "Do not export to next AS (well-known community)\n" |
| 8520 | "community number\n" |
| 8521 | "Do not send outside local AS (well-known community)\n" |
| 8522 | "Do not advertise to any peer (well-known community)\n" |
| 8523 | "Do not export to next AS (well-known community)\n" |
| 8524 | "Exact match of the communities") |
| 8525 | |
| 8526 | ALIAS (show_bgp_community_exact, |
| 8527 | show_bgp_ipv6_community3_exact_cmd, |
| 8528 | "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", |
| 8529 | SHOW_STR |
| 8530 | BGP_STR |
| 8531 | "Address family\n" |
| 8532 | "Display routes matching the communities\n" |
| 8533 | "community number\n" |
| 8534 | "Do not send outside local AS (well-known community)\n" |
| 8535 | "Do not advertise to any peer (well-known community)\n" |
| 8536 | "Do not export to next AS (well-known community)\n" |
| 8537 | "community number\n" |
| 8538 | "Do not send outside local AS (well-known community)\n" |
| 8539 | "Do not advertise to any peer (well-known community)\n" |
| 8540 | "Do not export to next AS (well-known community)\n" |
| 8541 | "community number\n" |
| 8542 | "Do not send outside local AS (well-known community)\n" |
| 8543 | "Do not advertise to any peer (well-known community)\n" |
| 8544 | "Do not export to next AS (well-known community)\n" |
| 8545 | "Exact match of the communities") |
| 8546 | |
| 8547 | ALIAS (show_bgp_community_exact, |
| 8548 | show_bgp_community4_exact_cmd, |
| 8549 | "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", |
| 8550 | SHOW_STR |
| 8551 | BGP_STR |
| 8552 | "Display routes matching the communities\n" |
| 8553 | "community number\n" |
| 8554 | "Do not send outside local AS (well-known community)\n" |
| 8555 | "Do not advertise to any peer (well-known community)\n" |
| 8556 | "Do not export to next AS (well-known community)\n" |
| 8557 | "community number\n" |
| 8558 | "Do not send outside local AS (well-known community)\n" |
| 8559 | "Do not advertise to any peer (well-known community)\n" |
| 8560 | "Do not export to next AS (well-known community)\n" |
| 8561 | "community number\n" |
| 8562 | "Do not send outside local AS (well-known community)\n" |
| 8563 | "Do not advertise to any peer (well-known community)\n" |
| 8564 | "Do not export to next AS (well-known community)\n" |
| 8565 | "community number\n" |
| 8566 | "Do not send outside local AS (well-known community)\n" |
| 8567 | "Do not advertise to any peer (well-known community)\n" |
| 8568 | "Do not export to next AS (well-known community)\n" |
| 8569 | "Exact match of the communities") |
| 8570 | |
| 8571 | ALIAS (show_bgp_community_exact, |
| 8572 | show_bgp_ipv6_community4_exact_cmd, |
| 8573 | "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", |
| 8574 | SHOW_STR |
| 8575 | BGP_STR |
| 8576 | "Address family\n" |
| 8577 | "Display routes matching the communities\n" |
| 8578 | "community number\n" |
| 8579 | "Do not send outside local AS (well-known community)\n" |
| 8580 | "Do not advertise to any peer (well-known community)\n" |
| 8581 | "Do not export to next AS (well-known community)\n" |
| 8582 | "community number\n" |
| 8583 | "Do not send outside local AS (well-known community)\n" |
| 8584 | "Do not advertise to any peer (well-known community)\n" |
| 8585 | "Do not export to next AS (well-known community)\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 | "community number\n" |
| 8591 | "Do not send outside local AS (well-known community)\n" |
| 8592 | "Do not advertise to any peer (well-known community)\n" |
| 8593 | "Do not export to next AS (well-known community)\n" |
| 8594 | "Exact match of the communities") |
| 8595 | |
| 8596 | /* old command */ |
| 8597 | DEFUN (show_ipv6_bgp_community_exact, |
| 8598 | show_ipv6_bgp_community_exact_cmd, |
| 8599 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8600 | SHOW_STR |
| 8601 | IPV6_STR |
| 8602 | BGP_STR |
| 8603 | "Display routes matching the communities\n" |
| 8604 | "community number\n" |
| 8605 | "Do not send outside local AS (well-known community)\n" |
| 8606 | "Do not advertise to any peer (well-known community)\n" |
| 8607 | "Do not export to next AS (well-known community)\n" |
| 8608 | "Exact match of the communities") |
| 8609 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8610 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8611 | } |
| 8612 | |
| 8613 | /* old command */ |
| 8614 | ALIAS (show_ipv6_bgp_community_exact, |
| 8615 | show_ipv6_bgp_community2_exact_cmd, |
| 8616 | "show ipv6 bgp community (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 | "Exact match of the communities") |
| 8630 | |
| 8631 | /* old command */ |
| 8632 | ALIAS (show_ipv6_bgp_community_exact, |
| 8633 | show_ipv6_bgp_community3_exact_cmd, |
| 8634 | "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", |
| 8635 | SHOW_STR |
| 8636 | IPV6_STR |
| 8637 | BGP_STR |
| 8638 | "Display routes matching the communities\n" |
| 8639 | "community number\n" |
| 8640 | "Do not send outside local AS (well-known community)\n" |
| 8641 | "Do not advertise to any peer (well-known community)\n" |
| 8642 | "Do not export to next AS (well-known community)\n" |
| 8643 | "community number\n" |
| 8644 | "Do not send outside local AS (well-known community)\n" |
| 8645 | "Do not advertise to any peer (well-known community)\n" |
| 8646 | "Do not export to next AS (well-known community)\n" |
| 8647 | "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 | "Exact match of the communities") |
| 8652 | |
| 8653 | /* old command */ |
| 8654 | ALIAS (show_ipv6_bgp_community_exact, |
| 8655 | show_ipv6_bgp_community4_exact_cmd, |
| 8656 | "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", |
| 8657 | SHOW_STR |
| 8658 | IPV6_STR |
| 8659 | BGP_STR |
| 8660 | "Display routes matching the communities\n" |
| 8661 | "community number\n" |
| 8662 | "Do not send outside local AS (well-known community)\n" |
| 8663 | "Do not advertise to any peer (well-known community)\n" |
| 8664 | "Do not export to next AS (well-known community)\n" |
| 8665 | "community number\n" |
| 8666 | "Do not send outside local AS (well-known community)\n" |
| 8667 | "Do not advertise to any peer (well-known community)\n" |
| 8668 | "Do not export to next AS (well-known community)\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 | "community number\n" |
| 8674 | "Do not send outside local AS (well-known community)\n" |
| 8675 | "Do not advertise to any peer (well-known community)\n" |
| 8676 | "Do not export to next AS (well-known community)\n" |
| 8677 | "Exact match of the communities") |
| 8678 | |
| 8679 | /* old command */ |
| 8680 | DEFUN (show_ipv6_mbgp_community, |
| 8681 | show_ipv6_mbgp_community_cmd, |
| 8682 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8683 | SHOW_STR |
| 8684 | IPV6_STR |
| 8685 | MBGP_STR |
| 8686 | "Display routes matching the communities\n" |
| 8687 | "community number\n" |
| 8688 | "Do not send outside local AS (well-known community)\n" |
| 8689 | "Do not advertise to any peer (well-known community)\n" |
| 8690 | "Do not export to next AS (well-known community)\n") |
| 8691 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8692 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8693 | } |
| 8694 | |
| 8695 | /* old command */ |
| 8696 | ALIAS (show_ipv6_mbgp_community, |
| 8697 | show_ipv6_mbgp_community2_cmd, |
| 8698 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8699 | SHOW_STR |
| 8700 | IPV6_STR |
| 8701 | MBGP_STR |
| 8702 | "Display routes matching the communities\n" |
| 8703 | "community number\n" |
| 8704 | "Do not send outside local AS (well-known community)\n" |
| 8705 | "Do not advertise to any peer (well-known community)\n" |
| 8706 | "Do not export to next AS (well-known community)\n" |
| 8707 | "community number\n" |
| 8708 | "Do not send outside local AS (well-known community)\n" |
| 8709 | "Do not advertise to any peer (well-known community)\n" |
| 8710 | "Do not export to next AS (well-known community)\n") |
| 8711 | |
| 8712 | /* old command */ |
| 8713 | ALIAS (show_ipv6_mbgp_community, |
| 8714 | show_ipv6_mbgp_community3_cmd, |
| 8715 | "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)", |
| 8716 | SHOW_STR |
| 8717 | IPV6_STR |
| 8718 | MBGP_STR |
| 8719 | "Display routes matching the communities\n" |
| 8720 | "community number\n" |
| 8721 | "Do not send outside local AS (well-known community)\n" |
| 8722 | "Do not advertise to any peer (well-known community)\n" |
| 8723 | "Do not export to next AS (well-known community)\n" |
| 8724 | "community number\n" |
| 8725 | "Do not send outside local AS (well-known community)\n" |
| 8726 | "Do not advertise to any peer (well-known community)\n" |
| 8727 | "Do not export to next AS (well-known community)\n" |
| 8728 | "community number\n" |
| 8729 | "Do not send outside local AS (well-known community)\n" |
| 8730 | "Do not advertise to any peer (well-known community)\n" |
| 8731 | "Do not export to next AS (well-known community)\n") |
| 8732 | |
| 8733 | /* old command */ |
| 8734 | ALIAS (show_ipv6_mbgp_community, |
| 8735 | show_ipv6_mbgp_community4_cmd, |
| 8736 | "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)", |
| 8737 | SHOW_STR |
| 8738 | IPV6_STR |
| 8739 | MBGP_STR |
| 8740 | "Display routes matching the communities\n" |
| 8741 | "community number\n" |
| 8742 | "Do not send outside local AS (well-known community)\n" |
| 8743 | "Do not advertise to any peer (well-known community)\n" |
| 8744 | "Do not export to next AS (well-known community)\n" |
| 8745 | "community number\n" |
| 8746 | "Do not send outside local AS (well-known community)\n" |
| 8747 | "Do not advertise to any peer (well-known community)\n" |
| 8748 | "Do not export to next AS (well-known community)\n" |
| 8749 | "community number\n" |
| 8750 | "Do not send outside local AS (well-known community)\n" |
| 8751 | "Do not advertise to any peer (well-known community)\n" |
| 8752 | "Do not export to next AS (well-known community)\n" |
| 8753 | "community number\n" |
| 8754 | "Do not send outside local AS (well-known community)\n" |
| 8755 | "Do not advertise to any peer (well-known community)\n" |
| 8756 | "Do not export to next AS (well-known community)\n") |
| 8757 | |
| 8758 | /* old command */ |
| 8759 | DEFUN (show_ipv6_mbgp_community_exact, |
| 8760 | show_ipv6_mbgp_community_exact_cmd, |
| 8761 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8762 | SHOW_STR |
| 8763 | IPV6_STR |
| 8764 | MBGP_STR |
| 8765 | "Display routes matching the communities\n" |
| 8766 | "community number\n" |
| 8767 | "Do not send outside local AS (well-known community)\n" |
| 8768 | "Do not advertise to any peer (well-known community)\n" |
| 8769 | "Do not export to next AS (well-known community)\n" |
| 8770 | "Exact match of the communities") |
| 8771 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8772 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8773 | } |
| 8774 | |
| 8775 | /* old command */ |
| 8776 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8777 | show_ipv6_mbgp_community2_exact_cmd, |
| 8778 | "show ipv6 mbgp community (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 | "Exact match of the communities") |
| 8792 | |
| 8793 | /* old command */ |
| 8794 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8795 | show_ipv6_mbgp_community3_exact_cmd, |
| 8796 | "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", |
| 8797 | SHOW_STR |
| 8798 | IPV6_STR |
| 8799 | MBGP_STR |
| 8800 | "Display routes matching the communities\n" |
| 8801 | "community number\n" |
| 8802 | "Do not send outside local AS (well-known community)\n" |
| 8803 | "Do not advertise to any peer (well-known community)\n" |
| 8804 | "Do not export to next AS (well-known community)\n" |
| 8805 | "community number\n" |
| 8806 | "Do not send outside local AS (well-known community)\n" |
| 8807 | "Do not advertise to any peer (well-known community)\n" |
| 8808 | "Do not export to next AS (well-known community)\n" |
| 8809 | "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 | "Exact match of the communities") |
| 8814 | |
| 8815 | /* old command */ |
| 8816 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8817 | show_ipv6_mbgp_community4_exact_cmd, |
| 8818 | "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", |
| 8819 | SHOW_STR |
| 8820 | IPV6_STR |
| 8821 | MBGP_STR |
| 8822 | "Display routes matching the communities\n" |
| 8823 | "community number\n" |
| 8824 | "Do not send outside local AS (well-known community)\n" |
| 8825 | "Do not advertise to any peer (well-known community)\n" |
| 8826 | "Do not export to next AS (well-known community)\n" |
| 8827 | "community number\n" |
| 8828 | "Do not send outside local AS (well-known community)\n" |
| 8829 | "Do not advertise to any peer (well-known community)\n" |
| 8830 | "Do not export to next AS (well-known community)\n" |
| 8831 | "community number\n" |
| 8832 | "Do not send outside local AS (well-known community)\n" |
| 8833 | "Do not advertise to any peer (well-known community)\n" |
| 8834 | "Do not export to next AS (well-known community)\n" |
| 8835 | "community number\n" |
| 8836 | "Do not send outside local AS (well-known community)\n" |
| 8837 | "Do not advertise to any peer (well-known community)\n" |
| 8838 | "Do not export to next AS (well-known community)\n" |
| 8839 | "Exact match of the communities") |
| 8840 | #endif /* HAVE_IPV6 */ |
| 8841 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8842 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8843 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 8844 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8845 | { |
| 8846 | struct community_list *list; |
| 8847 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8848 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8849 | if (list == NULL) |
| 8850 | { |
| 8851 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 8852 | VTY_NEWLINE); |
| 8853 | return CMD_WARNING; |
| 8854 | } |
| 8855 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8856 | return bgp_show (vty, NULL, afi, safi, |
| 8857 | (exact ? bgp_show_type_community_list_exact : |
| 8858 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8859 | } |
| 8860 | |
| 8861 | DEFUN (show_ip_bgp_community_list, |
| 8862 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8863 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8864 | SHOW_STR |
| 8865 | IP_STR |
| 8866 | BGP_STR |
| 8867 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8868 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8869 | "community-list name\n") |
| 8870 | { |
| 8871 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 8872 | } |
| 8873 | |
| 8874 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 8875 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8876 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8877 | SHOW_STR |
| 8878 | IP_STR |
| 8879 | BGP_STR |
| 8880 | "Address family\n" |
| 8881 | "Address Family modifier\n" |
| 8882 | "Address Family modifier\n" |
| 8883 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8884 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8885 | "community-list name\n") |
| 8886 | { |
| 8887 | if (strncmp (argv[0], "m", 1) == 0) |
| 8888 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 8889 | |
| 8890 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 8891 | } |
| 8892 | |
| 8893 | DEFUN (show_ip_bgp_community_list_exact, |
| 8894 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8895 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8896 | SHOW_STR |
| 8897 | IP_STR |
| 8898 | BGP_STR |
| 8899 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8900 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8901 | "community-list name\n" |
| 8902 | "Exact match of the communities\n") |
| 8903 | { |
| 8904 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 8905 | } |
| 8906 | |
| 8907 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 8908 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8909 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8910 | SHOW_STR |
| 8911 | IP_STR |
| 8912 | BGP_STR |
| 8913 | "Address family\n" |
| 8914 | "Address Family modifier\n" |
| 8915 | "Address Family modifier\n" |
| 8916 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8917 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8918 | "community-list name\n" |
| 8919 | "Exact match of the communities\n") |
| 8920 | { |
| 8921 | if (strncmp (argv[0], "m", 1) == 0) |
| 8922 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 8923 | |
| 8924 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 8925 | } |
| 8926 | |
| 8927 | #ifdef HAVE_IPV6 |
| 8928 | DEFUN (show_bgp_community_list, |
| 8929 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8930 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8931 | SHOW_STR |
| 8932 | BGP_STR |
| 8933 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8934 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8935 | "community-list name\n") |
| 8936 | { |
| 8937 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8938 | } |
| 8939 | |
| 8940 | ALIAS (show_bgp_community_list, |
| 8941 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8942 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8943 | SHOW_STR |
| 8944 | BGP_STR |
| 8945 | "Address family\n" |
| 8946 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8947 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 8948 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8949 | |
| 8950 | /* old command */ |
| 8951 | DEFUN (show_ipv6_bgp_community_list, |
| 8952 | show_ipv6_bgp_community_list_cmd, |
| 8953 | "show ipv6 bgp community-list WORD", |
| 8954 | SHOW_STR |
| 8955 | IPV6_STR |
| 8956 | BGP_STR |
| 8957 | "Display routes matching the community-list\n" |
| 8958 | "community-list name\n") |
| 8959 | { |
| 8960 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8961 | } |
| 8962 | |
| 8963 | /* old command */ |
| 8964 | DEFUN (show_ipv6_mbgp_community_list, |
| 8965 | show_ipv6_mbgp_community_list_cmd, |
| 8966 | "show ipv6 mbgp community-list WORD", |
| 8967 | SHOW_STR |
| 8968 | IPV6_STR |
| 8969 | MBGP_STR |
| 8970 | "Display routes matching the community-list\n" |
| 8971 | "community-list name\n") |
| 8972 | { |
| 8973 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 8974 | } |
| 8975 | |
| 8976 | DEFUN (show_bgp_community_list_exact, |
| 8977 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8978 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8979 | SHOW_STR |
| 8980 | BGP_STR |
| 8981 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8982 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8983 | "community-list name\n" |
| 8984 | "Exact match of the communities\n") |
| 8985 | { |
| 8986 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8987 | } |
| 8988 | |
| 8989 | ALIAS (show_bgp_community_list_exact, |
| 8990 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8991 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8992 | SHOW_STR |
| 8993 | BGP_STR |
| 8994 | "Address family\n" |
| 8995 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8996 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8997 | "community-list name\n" |
| 8998 | "Exact match of the communities\n") |
| 8999 | |
| 9000 | /* old command */ |
| 9001 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 9002 | show_ipv6_bgp_community_list_exact_cmd, |
| 9003 | "show ipv6 bgp community-list WORD exact-match", |
| 9004 | SHOW_STR |
| 9005 | IPV6_STR |
| 9006 | BGP_STR |
| 9007 | "Display routes matching the community-list\n" |
| 9008 | "community-list name\n" |
| 9009 | "Exact match of the communities\n") |
| 9010 | { |
| 9011 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9012 | } |
| 9013 | |
| 9014 | /* old command */ |
| 9015 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 9016 | show_ipv6_mbgp_community_list_exact_cmd, |
| 9017 | "show ipv6 mbgp community-list WORD exact-match", |
| 9018 | SHOW_STR |
| 9019 | IPV6_STR |
| 9020 | MBGP_STR |
| 9021 | "Display routes matching the community-list\n" |
| 9022 | "community-list name\n" |
| 9023 | "Exact match of the communities\n") |
| 9024 | { |
| 9025 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 9026 | } |
| 9027 | #endif /* HAVE_IPV6 */ |
| 9028 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9029 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9030 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9031 | safi_t safi, enum bgp_show_type type) |
| 9032 | { |
| 9033 | int ret; |
| 9034 | struct prefix *p; |
| 9035 | |
| 9036 | p = prefix_new(); |
| 9037 | |
| 9038 | ret = str2prefix (prefix, p); |
| 9039 | if (! ret) |
| 9040 | { |
| 9041 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 9042 | return CMD_WARNING; |
| 9043 | } |
| 9044 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9045 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 9046 | prefix_free(p); |
| 9047 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9048 | } |
| 9049 | |
| 9050 | DEFUN (show_ip_bgp_prefix_longer, |
| 9051 | show_ip_bgp_prefix_longer_cmd, |
| 9052 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 9053 | SHOW_STR |
| 9054 | IP_STR |
| 9055 | BGP_STR |
| 9056 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9057 | "Display route and more specific routes\n") |
| 9058 | { |
| 9059 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9060 | bgp_show_type_prefix_longer); |
| 9061 | } |
| 9062 | |
| 9063 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 9064 | show_ip_bgp_flap_prefix_longer_cmd, |
| 9065 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 9066 | SHOW_STR |
| 9067 | IP_STR |
| 9068 | BGP_STR |
| 9069 | "Display flap statistics of routes\n" |
| 9070 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9071 | "Display route and more specific routes\n") |
| 9072 | { |
| 9073 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9074 | bgp_show_type_flap_prefix_longer); |
| 9075 | } |
| 9076 | |
| 9077 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 9078 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 9079 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 9080 | SHOW_STR |
| 9081 | IP_STR |
| 9082 | BGP_STR |
| 9083 | "Address family\n" |
| 9084 | "Address Family modifier\n" |
| 9085 | "Address Family modifier\n" |
| 9086 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9087 | "Display route and more specific routes\n") |
| 9088 | { |
| 9089 | if (strncmp (argv[0], "m", 1) == 0) |
| 9090 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 9091 | bgp_show_type_prefix_longer); |
| 9092 | |
| 9093 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 9094 | bgp_show_type_prefix_longer); |
| 9095 | } |
| 9096 | |
| 9097 | DEFUN (show_ip_bgp_flap_address, |
| 9098 | show_ip_bgp_flap_address_cmd, |
| 9099 | "show ip bgp flap-statistics A.B.C.D", |
| 9100 | SHOW_STR |
| 9101 | IP_STR |
| 9102 | BGP_STR |
| 9103 | "Display flap statistics of routes\n" |
| 9104 | "Network in the BGP routing table to display\n") |
| 9105 | { |
| 9106 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9107 | bgp_show_type_flap_address); |
| 9108 | } |
| 9109 | |
| 9110 | DEFUN (show_ip_bgp_flap_prefix, |
| 9111 | show_ip_bgp_flap_prefix_cmd, |
| 9112 | "show ip bgp flap-statistics A.B.C.D/M", |
| 9113 | SHOW_STR |
| 9114 | IP_STR |
| 9115 | BGP_STR |
| 9116 | "Display flap statistics of routes\n" |
| 9117 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9118 | { |
| 9119 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9120 | bgp_show_type_flap_prefix); |
| 9121 | } |
| 9122 | #ifdef HAVE_IPV6 |
| 9123 | DEFUN (show_bgp_prefix_longer, |
| 9124 | show_bgp_prefix_longer_cmd, |
| 9125 | "show bgp X:X::X:X/M longer-prefixes", |
| 9126 | SHOW_STR |
| 9127 | BGP_STR |
| 9128 | "IPv6 prefix <network>/<length>\n" |
| 9129 | "Display route and more specific routes\n") |
| 9130 | { |
| 9131 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9132 | bgp_show_type_prefix_longer); |
| 9133 | } |
| 9134 | |
| 9135 | ALIAS (show_bgp_prefix_longer, |
| 9136 | show_bgp_ipv6_prefix_longer_cmd, |
| 9137 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 9138 | SHOW_STR |
| 9139 | BGP_STR |
| 9140 | "Address family\n" |
| 9141 | "IPv6 prefix <network>/<length>\n" |
| 9142 | "Display route and more specific routes\n") |
| 9143 | |
| 9144 | /* old command */ |
| 9145 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 9146 | show_ipv6_bgp_prefix_longer_cmd, |
| 9147 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 9148 | SHOW_STR |
| 9149 | IPV6_STR |
| 9150 | BGP_STR |
| 9151 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9152 | "Display route and more specific routes\n") |
| 9153 | { |
| 9154 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9155 | bgp_show_type_prefix_longer); |
| 9156 | } |
| 9157 | |
| 9158 | /* old command */ |
| 9159 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 9160 | show_ipv6_mbgp_prefix_longer_cmd, |
| 9161 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 9162 | SHOW_STR |
| 9163 | IPV6_STR |
| 9164 | MBGP_STR |
| 9165 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9166 | "Display route and more specific routes\n") |
| 9167 | { |
| 9168 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 9169 | bgp_show_type_prefix_longer); |
| 9170 | } |
| 9171 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9172 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9173 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9174 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 9175 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9176 | { |
| 9177 | int ret; |
| 9178 | struct bgp *bgp; |
| 9179 | struct peer *peer; |
| 9180 | union sockunion su; |
| 9181 | |
| 9182 | /* BGP structure lookup. */ |
| 9183 | if (view_name) |
| 9184 | { |
| 9185 | bgp = bgp_lookup_by_name (view_name); |
| 9186 | if (! bgp) |
| 9187 | { |
| 9188 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9189 | return NULL; |
| 9190 | } |
| 9191 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 9192 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9193 | { |
| 9194 | bgp = bgp_get_default (); |
| 9195 | if (! bgp) |
| 9196 | { |
| 9197 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9198 | return NULL; |
| 9199 | } |
| 9200 | } |
| 9201 | |
| 9202 | /* Get peer sockunion. */ |
| 9203 | ret = str2sockunion (ip_str, &su); |
| 9204 | if (ret < 0) |
| 9205 | { |
| 9206 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 9207 | return NULL; |
| 9208 | } |
| 9209 | |
| 9210 | /* Peer structure lookup. */ |
| 9211 | peer = peer_lookup (bgp, &su); |
| 9212 | if (! peer) |
| 9213 | { |
| 9214 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 9215 | return NULL; |
| 9216 | } |
| 9217 | |
| 9218 | return peer; |
| 9219 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9220 | |
| 9221 | enum bgp_stats |
| 9222 | { |
| 9223 | BGP_STATS_MAXBITLEN = 0, |
| 9224 | BGP_STATS_RIB, |
| 9225 | BGP_STATS_PREFIXES, |
| 9226 | BGP_STATS_TOTPLEN, |
| 9227 | BGP_STATS_UNAGGREGATEABLE, |
| 9228 | BGP_STATS_MAX_AGGREGATEABLE, |
| 9229 | BGP_STATS_AGGREGATES, |
| 9230 | BGP_STATS_SPACE, |
| 9231 | BGP_STATS_ASPATH_COUNT, |
| 9232 | BGP_STATS_ASPATH_MAXHOPS, |
| 9233 | BGP_STATS_ASPATH_TOTHOPS, |
| 9234 | BGP_STATS_ASPATH_MAXSIZE, |
| 9235 | BGP_STATS_ASPATH_TOTSIZE, |
| 9236 | BGP_STATS_ASN_HIGHEST, |
| 9237 | BGP_STATS_MAX, |
| 9238 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9239 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9240 | static const char *table_stats_strs[] = |
| 9241 | { |
| 9242 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 9243 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 9244 | [BGP_STATS_RIB] = "Total Advertisements", |
| 9245 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 9246 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 9247 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 9248 | [BGP_STATS_SPACE] = "Address space advertised", |
| 9249 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 9250 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 9251 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 9252 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 9253 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 9254 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 9255 | [BGP_STATS_MAX] = NULL, |
| 9256 | }; |
| 9257 | |
| 9258 | struct bgp_table_stats |
| 9259 | { |
| 9260 | struct bgp_table *table; |
| 9261 | unsigned long long counts[BGP_STATS_MAX]; |
| 9262 | }; |
| 9263 | |
| 9264 | #if 0 |
| 9265 | #define TALLY_SIGFIG 100000 |
| 9266 | static unsigned long |
| 9267 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 9268 | { |
| 9269 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 9270 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 9271 | unsigned long ret = newtot / count; |
| 9272 | |
| 9273 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 9274 | return ret + 1; |
| 9275 | else |
| 9276 | return ret; |
| 9277 | } |
| 9278 | #endif |
| 9279 | |
| 9280 | static int |
| 9281 | bgp_table_stats_walker (struct thread *t) |
| 9282 | { |
| 9283 | struct bgp_node *rn; |
| 9284 | struct bgp_node *top; |
| 9285 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 9286 | unsigned int space = 0; |
| 9287 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 9288 | if (!(top = bgp_table_top (ts->table))) |
| 9289 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9290 | |
| 9291 | switch (top->p.family) |
| 9292 | { |
| 9293 | case AF_INET: |
| 9294 | space = IPV4_MAX_BITLEN; |
| 9295 | break; |
| 9296 | case AF_INET6: |
| 9297 | space = IPV6_MAX_BITLEN; |
| 9298 | break; |
| 9299 | } |
| 9300 | |
| 9301 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 9302 | |
| 9303 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 9304 | { |
| 9305 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9306 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9307 | unsigned int rinum = 0; |
| 9308 | |
| 9309 | if (rn == top) |
| 9310 | continue; |
| 9311 | |
| 9312 | if (!rn->info) |
| 9313 | continue; |
| 9314 | |
| 9315 | ts->counts[BGP_STATS_PREFIXES]++; |
| 9316 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 9317 | |
| 9318 | #if 0 |
| 9319 | ts->counts[BGP_STATS_AVGPLEN] |
| 9320 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 9321 | ts->counts[BGP_STATS_AVGPLEN], |
| 9322 | rn->p.prefixlen); |
| 9323 | #endif |
| 9324 | |
| 9325 | /* check if the prefix is included by any other announcements */ |
| 9326 | while (prn && !prn->info) |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9327 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9328 | |
| 9329 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 9330 | { |
| 9331 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 9332 | /* announced address space */ |
| 9333 | if (space) |
| 9334 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 9335 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9336 | else if (prn->info) |
| 9337 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 9338 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9339 | for (ri = rn->info; ri; ri = ri->next) |
| 9340 | { |
| 9341 | rinum++; |
| 9342 | ts->counts[BGP_STATS_RIB]++; |
| 9343 | |
| 9344 | if (ri->attr && |
| 9345 | (CHECK_FLAG (ri->attr->flag, |
| 9346 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 9347 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 9348 | |
| 9349 | /* as-path stats */ |
| 9350 | if (ri->attr && ri->attr->aspath) |
| 9351 | { |
| 9352 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 9353 | unsigned int size = aspath_size (ri->attr->aspath); |
| 9354 | as_t highest = aspath_highest (ri->attr->aspath); |
| 9355 | |
| 9356 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 9357 | |
| 9358 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 9359 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 9360 | |
| 9361 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 9362 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 9363 | |
| 9364 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 9365 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 9366 | #if 0 |
| 9367 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 9368 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9369 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 9370 | hops); |
| 9371 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 9372 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9373 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 9374 | size); |
| 9375 | #endif |
| 9376 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 9377 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 9378 | } |
| 9379 | } |
| 9380 | } |
| 9381 | return 0; |
| 9382 | } |
| 9383 | |
| 9384 | static int |
| 9385 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 9386 | { |
| 9387 | struct bgp_table_stats ts; |
| 9388 | unsigned int i; |
| 9389 | |
| 9390 | if (!bgp->rib[afi][safi]) |
| 9391 | { |
| 9392 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); |
| 9393 | return CMD_WARNING; |
| 9394 | } |
| 9395 | |
| 9396 | memset (&ts, 0, sizeof (ts)); |
| 9397 | ts.table = bgp->rib[afi][safi]; |
| 9398 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 9399 | |
| 9400 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 9401 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 9402 | |
| 9403 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 9404 | { |
| 9405 | if (!table_stats_strs[i]) |
| 9406 | continue; |
| 9407 | |
| 9408 | switch (i) |
| 9409 | { |
| 9410 | #if 0 |
| 9411 | case BGP_STATS_ASPATH_AVGHOPS: |
| 9412 | case BGP_STATS_ASPATH_AVGSIZE: |
| 9413 | case BGP_STATS_AVGPLEN: |
| 9414 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9415 | vty_out (vty, "%12.2f", |
| 9416 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 9417 | break; |
| 9418 | #endif |
| 9419 | case BGP_STATS_ASPATH_TOTHOPS: |
| 9420 | case BGP_STATS_ASPATH_TOTSIZE: |
| 9421 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9422 | vty_out (vty, "%12.2f", |
| 9423 | ts.counts[i] ? |
| 9424 | (float)ts.counts[i] / |
| 9425 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 9426 | : 0); |
| 9427 | break; |
| 9428 | case BGP_STATS_TOTPLEN: |
| 9429 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9430 | vty_out (vty, "%12.2f", |
| 9431 | ts.counts[i] ? |
| 9432 | (float)ts.counts[i] / |
| 9433 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 9434 | : 0); |
| 9435 | break; |
| 9436 | case BGP_STATS_SPACE: |
| 9437 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9438 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 9439 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 9440 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 9441 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9442 | vty_out (vty, "%12.2f%s", |
| 9443 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 9444 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9445 | VTY_NEWLINE); |
| 9446 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 9447 | vty_out (vty, "%12.2f%s", |
| 9448 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9449 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 9450 | VTY_NEWLINE); |
| 9451 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 9452 | break; |
| 9453 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 9454 | vty_out (vty, "%12.2f", |
| 9455 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9456 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 9457 | break; |
| 9458 | default: |
| 9459 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9460 | vty_out (vty, "%12llu", ts.counts[i]); |
| 9461 | } |
| 9462 | |
| 9463 | vty_out (vty, "%s", VTY_NEWLINE); |
| 9464 | } |
| 9465 | return CMD_SUCCESS; |
| 9466 | } |
| 9467 | |
| 9468 | static int |
| 9469 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 9470 | const char *afi_str, const char *safi_str) |
| 9471 | { |
| 9472 | struct bgp *bgp; |
| 9473 | afi_t afi; |
| 9474 | safi_t safi; |
| 9475 | |
| 9476 | if (name) |
| 9477 | bgp = bgp_lookup_by_name (name); |
| 9478 | else |
| 9479 | bgp = bgp_get_default (); |
| 9480 | |
| 9481 | if (!bgp) |
| 9482 | { |
| 9483 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); |
| 9484 | return CMD_WARNING; |
| 9485 | } |
| 9486 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 9487 | { |
| 9488 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 9489 | afi = AFI_IP; |
| 9490 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 9491 | afi = AFI_IP6; |
| 9492 | else |
| 9493 | { |
| 9494 | vty_out (vty, "%% Invalid address family %s%s", |
| 9495 | afi_str, VTY_NEWLINE); |
| 9496 | return CMD_WARNING; |
| 9497 | } |
| 9498 | if (strncmp (safi_str, "m", 1) == 0) |
| 9499 | safi = SAFI_MULTICAST; |
| 9500 | else if (strncmp (safi_str, "u", 1) == 0) |
| 9501 | safi = SAFI_UNICAST; |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 9502 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
| 9503 | safi = SAFI_MPLS_LABELED_VPN; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9504 | else |
| 9505 | { |
| 9506 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
| 9507 | safi_str, VTY_NEWLINE); |
| 9508 | return CMD_WARNING; |
| 9509 | } |
| 9510 | } |
| 9511 | else |
| 9512 | { |
| 9513 | vty_out (vty, "%% Invalid address family %s%s", |
| 9514 | afi_str, VTY_NEWLINE); |
| 9515 | return CMD_WARNING; |
| 9516 | } |
| 9517 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9518 | return bgp_table_stats (vty, bgp, afi, safi); |
| 9519 | } |
| 9520 | |
| 9521 | DEFUN (show_bgp_statistics, |
| 9522 | show_bgp_statistics_cmd, |
| 9523 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", |
| 9524 | SHOW_STR |
| 9525 | BGP_STR |
| 9526 | "Address family\n" |
| 9527 | "Address family\n" |
| 9528 | "Address Family modifier\n" |
| 9529 | "Address Family modifier\n" |
| 9530 | "BGP RIB advertisement statistics\n") |
| 9531 | { |
| 9532 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9533 | } |
| 9534 | |
| 9535 | ALIAS (show_bgp_statistics, |
| 9536 | show_bgp_statistics_vpnv4_cmd, |
| 9537 | "show bgp (ipv4) (vpnv4) statistics", |
| 9538 | SHOW_STR |
| 9539 | BGP_STR |
| 9540 | "Address family\n" |
| 9541 | "Address Family modifier\n" |
| 9542 | "BGP RIB advertisement statistics\n") |
| 9543 | |
| 9544 | DEFUN (show_bgp_statistics_view, |
| 9545 | show_bgp_statistics_view_cmd, |
| 9546 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", |
| 9547 | SHOW_STR |
| 9548 | BGP_STR |
| 9549 | "BGP view\n" |
| 9550 | "Address family\n" |
| 9551 | "Address family\n" |
| 9552 | "Address Family modifier\n" |
| 9553 | "Address Family modifier\n" |
| 9554 | "BGP RIB advertisement statistics\n") |
| 9555 | { |
| 9556 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9557 | } |
| 9558 | |
| 9559 | ALIAS (show_bgp_statistics_view, |
| 9560 | show_bgp_statistics_view_vpnv4_cmd, |
| 9561 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
| 9562 | SHOW_STR |
| 9563 | BGP_STR |
| 9564 | "BGP view\n" |
| 9565 | "Address family\n" |
| 9566 | "Address Family modifier\n" |
| 9567 | "BGP RIB advertisement statistics\n") |
| 9568 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9569 | enum bgp_pcounts |
| 9570 | { |
| 9571 | PCOUNT_ADJ_IN = 0, |
| 9572 | PCOUNT_DAMPED, |
| 9573 | PCOUNT_REMOVED, |
| 9574 | PCOUNT_HISTORY, |
| 9575 | PCOUNT_STALE, |
| 9576 | PCOUNT_VALID, |
| 9577 | PCOUNT_ALL, |
| 9578 | PCOUNT_COUNTED, |
| 9579 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 9580 | PCOUNT_MAX, |
| 9581 | }; |
| 9582 | |
| 9583 | static const char *pcount_strs[] = |
| 9584 | { |
| 9585 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 9586 | [PCOUNT_DAMPED] = "Damped", |
| 9587 | [PCOUNT_REMOVED] = "Removed", |
| 9588 | [PCOUNT_HISTORY] = "History", |
| 9589 | [PCOUNT_STALE] = "Stale", |
| 9590 | [PCOUNT_VALID] = "Valid", |
| 9591 | [PCOUNT_ALL] = "All RIB", |
| 9592 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 9593 | [PCOUNT_PFCNT] = "Useable", |
| 9594 | [PCOUNT_MAX] = NULL, |
| 9595 | }; |
| 9596 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9597 | struct peer_pcounts |
| 9598 | { |
| 9599 | unsigned int count[PCOUNT_MAX]; |
| 9600 | const struct peer *peer; |
| 9601 | const struct bgp_table *table; |
| 9602 | }; |
| 9603 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9604 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9605 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9606 | { |
| 9607 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9608 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 9609 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9610 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9611 | 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] | 9612 | { |
| 9613 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9614 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9615 | |
| 9616 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9617 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9618 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9619 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9620 | for (ri = rn->info; ri; ri = ri->next) |
| 9621 | { |
| 9622 | char buf[SU_ADDRSTRLEN]; |
| 9623 | |
| 9624 | if (ri->peer != peer) |
| 9625 | continue; |
| 9626 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9627 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9628 | |
| 9629 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9630 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9631 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9632 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9633 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9634 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9635 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9636 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9637 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9638 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9639 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9640 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9641 | |
| 9642 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 9643 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9644 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9645 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9646 | plog_warn (peer->log, |
| 9647 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 9648 | peer->host, |
| 9649 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9650 | buf, SU_ADDRSTRLEN), |
| 9651 | rn->p.prefixlen, |
| 9652 | ri->flags); |
| 9653 | } |
| 9654 | else |
| 9655 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9656 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9657 | plog_warn (peer->log, |
| 9658 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 9659 | peer->host, |
| 9660 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9661 | buf, SU_ADDRSTRLEN), |
| 9662 | rn->p.prefixlen, |
| 9663 | ri->flags); |
| 9664 | } |
| 9665 | } |
| 9666 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9667 | return 0; |
| 9668 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9669 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9670 | static int |
| 9671 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 9672 | { |
| 9673 | struct peer_pcounts pcounts = { .peer = peer }; |
| 9674 | unsigned int i; |
| 9675 | |
| 9676 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 9677 | || !peer->bgp->rib[afi][safi]) |
| 9678 | { |
| 9679 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9680 | return CMD_WARNING; |
| 9681 | } |
| 9682 | |
| 9683 | memset (&pcounts, 0, sizeof(pcounts)); |
| 9684 | pcounts.peer = peer; |
| 9685 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 9686 | |
| 9687 | /* in-place call via thread subsystem so as to record execution time |
| 9688 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 9689 | * on just vty_read()). |
| 9690 | */ |
| 9691 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 9692 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9693 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 9694 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 9695 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 9696 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 9697 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 9698 | |
| 9699 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9700 | vty_out (vty, "%20s: %-10d%s", |
| 9701 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9702 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9703 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9704 | { |
| 9705 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 9706 | peer->host, VTY_NEWLINE); |
| 9707 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 9708 | VTY_NEWLINE); |
| 9709 | } |
| 9710 | |
| 9711 | return CMD_SUCCESS; |
| 9712 | } |
| 9713 | |
| 9714 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 9715 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 9716 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9717 | SHOW_STR |
| 9718 | IP_STR |
| 9719 | BGP_STR |
| 9720 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9721 | "Neighbor to display information about\n" |
| 9722 | "Neighbor to display information about\n" |
| 9723 | "Display detailed prefix count information\n") |
| 9724 | { |
| 9725 | struct peer *peer; |
| 9726 | |
| 9727 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9728 | if (! peer) |
| 9729 | return CMD_WARNING; |
| 9730 | |
| 9731 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9732 | } |
| 9733 | |
| 9734 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 9735 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 9736 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9737 | SHOW_STR |
| 9738 | BGP_STR |
| 9739 | "Address family\n" |
| 9740 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9741 | "Neighbor to display information about\n" |
| 9742 | "Neighbor to display information about\n" |
| 9743 | "Display detailed prefix count information\n") |
| 9744 | { |
| 9745 | struct peer *peer; |
| 9746 | |
| 9747 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9748 | if (! peer) |
| 9749 | return CMD_WARNING; |
| 9750 | |
| 9751 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 9752 | } |
| 9753 | |
| 9754 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 9755 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 9756 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9757 | SHOW_STR |
| 9758 | IP_STR |
| 9759 | BGP_STR |
| 9760 | "Address family\n" |
| 9761 | "Address Family modifier\n" |
| 9762 | "Address Family modifier\n" |
| 9763 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9764 | "Neighbor to display information about\n" |
| 9765 | "Neighbor to display information about\n" |
| 9766 | "Display detailed prefix count information\n") |
| 9767 | { |
| 9768 | struct peer *peer; |
| 9769 | |
| 9770 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9771 | if (! peer) |
| 9772 | return CMD_WARNING; |
| 9773 | |
| 9774 | if (strncmp (argv[0], "m", 1) == 0) |
| 9775 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 9776 | |
| 9777 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9778 | } |
| 9779 | |
| 9780 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 9781 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 9782 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9783 | SHOW_STR |
| 9784 | IP_STR |
| 9785 | BGP_STR |
| 9786 | "Address family\n" |
| 9787 | "Address Family modifier\n" |
| 9788 | "Address Family modifier\n" |
| 9789 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9790 | "Neighbor to display information about\n" |
| 9791 | "Neighbor to display information about\n" |
| 9792 | "Display detailed prefix count information\n") |
| 9793 | { |
| 9794 | struct peer *peer; |
| 9795 | |
| 9796 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9797 | if (! peer) |
| 9798 | return CMD_WARNING; |
| 9799 | |
| 9800 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 9801 | } |
| 9802 | |
| 9803 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9804 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9805 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 9806 | int in) |
| 9807 | { |
| 9808 | struct bgp_table *table; |
| 9809 | struct bgp_adj_in *ain; |
| 9810 | struct bgp_adj_out *adj; |
| 9811 | unsigned long output_count; |
| 9812 | struct bgp_node *rn; |
| 9813 | int header1 = 1; |
| 9814 | struct bgp *bgp; |
| 9815 | int header2 = 1; |
| 9816 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9817 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9818 | |
| 9819 | if (! bgp) |
| 9820 | return; |
| 9821 | |
| 9822 | table = bgp->rib[afi][safi]; |
| 9823 | |
| 9824 | output_count = 0; |
| 9825 | |
| 9826 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 9827 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 9828 | { |
| 9829 | 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] | 9830 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9831 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9832 | |
| 9833 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 9834 | VTY_NEWLINE, VTY_NEWLINE); |
| 9835 | header1 = 0; |
| 9836 | } |
| 9837 | |
| 9838 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 9839 | if (in) |
| 9840 | { |
| 9841 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9842 | if (ain->peer == peer) |
| 9843 | { |
| 9844 | if (header1) |
| 9845 | { |
| 9846 | 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] | 9847 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9848 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9849 | header1 = 0; |
| 9850 | } |
| 9851 | if (header2) |
| 9852 | { |
| 9853 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9854 | header2 = 0; |
| 9855 | } |
| 9856 | if (ain->attr) |
| 9857 | { |
| 9858 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 9859 | output_count++; |
| 9860 | } |
| 9861 | } |
| 9862 | } |
| 9863 | else |
| 9864 | { |
| 9865 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 9866 | if (adj->peer == peer) |
| 9867 | { |
| 9868 | if (header1) |
| 9869 | { |
| 9870 | 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] | 9871 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9872 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9873 | header1 = 0; |
| 9874 | } |
| 9875 | if (header2) |
| 9876 | { |
| 9877 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9878 | header2 = 0; |
| 9879 | } |
| 9880 | if (adj->attr) |
| 9881 | { |
| 9882 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 9883 | output_count++; |
| 9884 | } |
| 9885 | } |
| 9886 | } |
| 9887 | |
| 9888 | if (output_count != 0) |
| 9889 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 9890 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 9891 | } |
| 9892 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9893 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9894 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 9895 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9896 | if (! peer || ! peer->afc[afi][safi]) |
| 9897 | { |
| 9898 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9899 | return CMD_WARNING; |
| 9900 | } |
| 9901 | |
| 9902 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 9903 | { |
| 9904 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 9905 | VTY_NEWLINE); |
| 9906 | return CMD_WARNING; |
| 9907 | } |
| 9908 | |
| 9909 | show_adj_route (vty, peer, afi, safi, in); |
| 9910 | |
| 9911 | return CMD_SUCCESS; |
| 9912 | } |
| 9913 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 9914 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 9915 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 9916 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9917 | SHOW_STR |
| 9918 | IP_STR |
| 9919 | BGP_STR |
| 9920 | "BGP view\n" |
| 9921 | "View name\n" |
| 9922 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9923 | "Neighbor to display information about\n" |
| 9924 | "Neighbor to display information about\n" |
| 9925 | "Display the routes advertised to a BGP neighbor\n") |
| 9926 | { |
| 9927 | struct peer *peer; |
| 9928 | |
| 9929 | if (argc == 2) |
| 9930 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9931 | else |
| 9932 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9933 | |
| 9934 | if (! peer) |
| 9935 | return CMD_WARNING; |
| 9936 | |
| 9937 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 9938 | } |
| 9939 | |
| 9940 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9941 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 9942 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9943 | SHOW_STR |
| 9944 | IP_STR |
| 9945 | BGP_STR |
| 9946 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9947 | "Neighbor to display information about\n" |
| 9948 | "Neighbor to display information about\n" |
| 9949 | "Display the routes advertised to a BGP neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9950 | |
| 9951 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 9952 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 9953 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9954 | SHOW_STR |
| 9955 | IP_STR |
| 9956 | BGP_STR |
| 9957 | "Address family\n" |
| 9958 | "Address Family modifier\n" |
| 9959 | "Address Family modifier\n" |
| 9960 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9961 | "Neighbor to display information about\n" |
| 9962 | "Neighbor to display information about\n" |
| 9963 | "Display the routes advertised to a BGP neighbor\n") |
| 9964 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9965 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9966 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9967 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9968 | if (! peer) |
| 9969 | return CMD_WARNING; |
| 9970 | |
| 9971 | if (strncmp (argv[0], "m", 1) == 0) |
| 9972 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 9973 | |
| 9974 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9975 | } |
| 9976 | |
| 9977 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9978 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 9979 | show_bgp_view_neighbor_advertised_route_cmd, |
| 9980 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9981 | SHOW_STR |
| 9982 | BGP_STR |
| 9983 | "BGP view\n" |
| 9984 | "View name\n" |
| 9985 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9986 | "Neighbor to display information about\n" |
| 9987 | "Neighbor to display information about\n" |
| 9988 | "Display the routes advertised to a BGP neighbor\n") |
| 9989 | { |
| 9990 | struct peer *peer; |
| 9991 | |
| 9992 | if (argc == 2) |
| 9993 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9994 | else |
| 9995 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9996 | |
| 9997 | if (! peer) |
| 9998 | return CMD_WARNING; |
| 9999 | |
| 10000 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 10001 | } |
| 10002 | |
| 10003 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 10004 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 10005 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10006 | SHOW_STR |
| 10007 | BGP_STR |
| 10008 | "BGP view\n" |
| 10009 | "View name\n" |
| 10010 | "Address family\n" |
| 10011 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10012 | "Neighbor to display information about\n" |
| 10013 | "Neighbor to display information about\n" |
| 10014 | "Display the routes advertised to a BGP neighbor\n") |
| 10015 | |
| 10016 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 10017 | show_bgp_view_neighbor_received_routes_cmd, |
| 10018 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10019 | SHOW_STR |
| 10020 | BGP_STR |
| 10021 | "BGP view\n" |
| 10022 | "View name\n" |
| 10023 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10024 | "Neighbor to display information about\n" |
| 10025 | "Neighbor to display information about\n" |
| 10026 | "Display the received routes from neighbor\n") |
| 10027 | { |
| 10028 | struct peer *peer; |
| 10029 | |
| 10030 | if (argc == 2) |
| 10031 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10032 | else |
| 10033 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10034 | |
| 10035 | if (! peer) |
| 10036 | return CMD_WARNING; |
| 10037 | |
| 10038 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 10039 | } |
| 10040 | |
| 10041 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 10042 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 10043 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10044 | SHOW_STR |
| 10045 | BGP_STR |
| 10046 | "BGP view\n" |
| 10047 | "View name\n" |
| 10048 | "Address family\n" |
| 10049 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10050 | "Neighbor to display information about\n" |
| 10051 | "Neighbor to display information about\n" |
| 10052 | "Display the received routes from neighbor\n") |
| 10053 | |
| 10054 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10055 | show_bgp_neighbor_advertised_route_cmd, |
| 10056 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10057 | SHOW_STR |
| 10058 | BGP_STR |
| 10059 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10060 | "Neighbor to display information about\n" |
| 10061 | "Neighbor to display information about\n" |
| 10062 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10063 | |
| 10064 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10065 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 10066 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10067 | SHOW_STR |
| 10068 | BGP_STR |
| 10069 | "Address family\n" |
| 10070 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10071 | "Neighbor to display information about\n" |
| 10072 | "Neighbor to display information about\n" |
| 10073 | "Display the routes advertised to a BGP neighbor\n") |
| 10074 | |
| 10075 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10076 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10077 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 10078 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10079 | SHOW_STR |
| 10080 | IPV6_STR |
| 10081 | BGP_STR |
| 10082 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10083 | "Neighbor to display information about\n" |
| 10084 | "Neighbor to display information about\n" |
| 10085 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10086 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10087 | /* old command */ |
| 10088 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 10089 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 10090 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10091 | SHOW_STR |
| 10092 | IPV6_STR |
| 10093 | MBGP_STR |
| 10094 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10095 | "Neighbor to display information about\n" |
| 10096 | "Neighbor to display information about\n" |
| 10097 | "Display the routes advertised to a BGP neighbor\n") |
| 10098 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10099 | struct peer *peer; |
| 10100 | |
| 10101 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10102 | if (! peer) |
| 10103 | return CMD_WARNING; |
| 10104 | |
| 10105 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10106 | } |
| 10107 | #endif /* HAVE_IPV6 */ |
| 10108 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10109 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 10110 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 10111 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10112 | SHOW_STR |
| 10113 | IP_STR |
| 10114 | BGP_STR |
| 10115 | "BGP view\n" |
| 10116 | "View name\n" |
| 10117 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10118 | "Neighbor to display information about\n" |
| 10119 | "Neighbor to display information about\n" |
| 10120 | "Display the received routes from neighbor\n") |
| 10121 | { |
| 10122 | struct peer *peer; |
| 10123 | |
| 10124 | if (argc == 2) |
| 10125 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10126 | else |
| 10127 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10128 | |
| 10129 | if (! peer) |
| 10130 | return CMD_WARNING; |
| 10131 | |
| 10132 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 10133 | } |
| 10134 | |
| 10135 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10136 | show_ip_bgp_neighbor_received_routes_cmd, |
| 10137 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10138 | SHOW_STR |
| 10139 | IP_STR |
| 10140 | BGP_STR |
| 10141 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10142 | "Neighbor to display information about\n" |
| 10143 | "Neighbor to display information about\n" |
| 10144 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10145 | |
| 10146 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 10147 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 10148 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10149 | SHOW_STR |
| 10150 | IP_STR |
| 10151 | BGP_STR |
| 10152 | "Address family\n" |
| 10153 | "Address Family modifier\n" |
| 10154 | "Address Family modifier\n" |
| 10155 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10156 | "Neighbor to display information about\n" |
| 10157 | "Neighbor to display information about\n" |
| 10158 | "Display the received routes from neighbor\n") |
| 10159 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10160 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10161 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10162 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10163 | if (! peer) |
| 10164 | return CMD_WARNING; |
| 10165 | |
| 10166 | if (strncmp (argv[0], "m", 1) == 0) |
| 10167 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 10168 | |
| 10169 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10170 | } |
| 10171 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10172 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 10173 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
| 10174 | #ifdef HAVE_IPV6 |
| 10175 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
| 10176 | #else |
| 10177 | "show bgp view WORD ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
| 10178 | #endif |
| 10179 | SHOW_STR |
| 10180 | BGP_STR |
| 10181 | "BGP view\n" |
| 10182 | "BGP view name\n" |
| 10183 | "Address family\n" |
| 10184 | #ifdef HAVE_IPV6 |
| 10185 | "Address family\n" |
| 10186 | #endif |
| 10187 | "Address family modifier\n" |
| 10188 | "Address family modifier\n" |
| 10189 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10190 | "Neighbor to display information about\n" |
| 10191 | "Neighbor to display information about\n" |
| 10192 | "Display the advertised routes to neighbor\n" |
| 10193 | "Display the received routes from neighbor\n") |
| 10194 | { |
| 10195 | int afi; |
| 10196 | int safi; |
| 10197 | int in; |
| 10198 | struct peer *peer; |
| 10199 | |
| 10200 | #ifdef HAVE_IPV6 |
| 10201 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
| 10202 | #else |
| 10203 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10204 | #endif |
| 10205 | |
| 10206 | if (! peer) |
| 10207 | return CMD_WARNING; |
| 10208 | |
| 10209 | #ifdef HAVE_IPV6 |
| 10210 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10211 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10212 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
| 10213 | #else |
| 10214 | afi = AFI_IP; |
| 10215 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10216 | in = (strncmp (argv[3], "r", 1) == 0) ? 1 : 0; |
| 10217 | #endif |
| 10218 | |
| 10219 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 10220 | } |
| 10221 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10222 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 10223 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 10224 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10225 | SHOW_STR |
| 10226 | IP_STR |
| 10227 | BGP_STR |
| 10228 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10229 | "Neighbor to display information about\n" |
| 10230 | "Neighbor to display information about\n" |
| 10231 | "Display information received from a BGP neighbor\n" |
| 10232 | "Display the prefixlist filter\n") |
| 10233 | { |
| 10234 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10235 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10236 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10237 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10238 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10239 | ret = str2sockunion (argv[0], &su); |
| 10240 | if (ret < 0) |
| 10241 | { |
| 10242 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10243 | return CMD_WARNING; |
| 10244 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10245 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10246 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10247 | if (! peer) |
| 10248 | return CMD_WARNING; |
| 10249 | |
| 10250 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10251 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10252 | if (count) |
| 10253 | { |
| 10254 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10255 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10256 | } |
| 10257 | |
| 10258 | return CMD_SUCCESS; |
| 10259 | } |
| 10260 | |
| 10261 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 10262 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 10263 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10264 | SHOW_STR |
| 10265 | IP_STR |
| 10266 | BGP_STR |
| 10267 | "Address family\n" |
| 10268 | "Address Family modifier\n" |
| 10269 | "Address Family modifier\n" |
| 10270 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10271 | "Neighbor to display information about\n" |
| 10272 | "Neighbor to display information about\n" |
| 10273 | "Display information received from a BGP neighbor\n" |
| 10274 | "Display the prefixlist filter\n") |
| 10275 | { |
| 10276 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10277 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10278 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10279 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10280 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10281 | ret = str2sockunion (argv[1], &su); |
| 10282 | if (ret < 0) |
| 10283 | { |
| 10284 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10285 | return CMD_WARNING; |
| 10286 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10287 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10288 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10289 | if (! peer) |
| 10290 | return CMD_WARNING; |
| 10291 | |
| 10292 | if (strncmp (argv[0], "m", 1) == 0) |
| 10293 | { |
| 10294 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 10295 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10296 | if (count) |
| 10297 | { |
| 10298 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 10299 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10300 | } |
| 10301 | } |
| 10302 | else |
| 10303 | { |
| 10304 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10305 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10306 | if (count) |
| 10307 | { |
| 10308 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10309 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10310 | } |
| 10311 | } |
| 10312 | |
| 10313 | return CMD_SUCCESS; |
| 10314 | } |
| 10315 | |
| 10316 | |
| 10317 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10318 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10319 | show_bgp_neighbor_received_routes_cmd, |
| 10320 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10321 | SHOW_STR |
| 10322 | BGP_STR |
| 10323 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10324 | "Neighbor to display information about\n" |
| 10325 | "Neighbor to display information about\n" |
| 10326 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10327 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10328 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10329 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 10330 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10331 | SHOW_STR |
| 10332 | BGP_STR |
| 10333 | "Address family\n" |
| 10334 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10335 | "Neighbor to display information about\n" |
| 10336 | "Neighbor to display information about\n" |
| 10337 | "Display the received routes from neighbor\n") |
| 10338 | |
| 10339 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 10340 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 10341 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10342 | SHOW_STR |
| 10343 | BGP_STR |
| 10344 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10345 | "Neighbor to display information about\n" |
| 10346 | "Neighbor to display information about\n" |
| 10347 | "Display information received from a BGP neighbor\n" |
| 10348 | "Display the prefixlist filter\n") |
| 10349 | { |
| 10350 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10351 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10352 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10353 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10354 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10355 | ret = str2sockunion (argv[0], &su); |
| 10356 | if (ret < 0) |
| 10357 | { |
| 10358 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10359 | return CMD_WARNING; |
| 10360 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10361 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10362 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10363 | if (! peer) |
| 10364 | return CMD_WARNING; |
| 10365 | |
| 10366 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10367 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10368 | if (count) |
| 10369 | { |
| 10370 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10371 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10372 | } |
| 10373 | |
| 10374 | return CMD_SUCCESS; |
| 10375 | } |
| 10376 | |
| 10377 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 10378 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 10379 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10380 | SHOW_STR |
| 10381 | BGP_STR |
| 10382 | "Address family\n" |
| 10383 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10384 | "Neighbor to display information about\n" |
| 10385 | "Neighbor to display information about\n" |
| 10386 | "Display information received from a BGP neighbor\n" |
| 10387 | "Display the prefixlist filter\n") |
| 10388 | |
| 10389 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10390 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10391 | ipv6_bgp_neighbor_received_routes_cmd, |
| 10392 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10393 | SHOW_STR |
| 10394 | IPV6_STR |
| 10395 | BGP_STR |
| 10396 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10397 | "Neighbor to display information about\n" |
| 10398 | "Neighbor to display information about\n" |
| 10399 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10400 | |
| 10401 | /* old command */ |
| 10402 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 10403 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 10404 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10405 | SHOW_STR |
| 10406 | IPV6_STR |
| 10407 | MBGP_STR |
| 10408 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10409 | "Neighbor to display information about\n" |
| 10410 | "Neighbor to display information about\n" |
| 10411 | "Display the received routes from neighbor\n") |
| 10412 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10413 | struct peer *peer; |
| 10414 | |
| 10415 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10416 | if (! peer) |
| 10417 | return CMD_WARNING; |
| 10418 | |
| 10419 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10420 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10421 | |
| 10422 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 10423 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 10424 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10425 | SHOW_STR |
| 10426 | BGP_STR |
| 10427 | "BGP view\n" |
| 10428 | "View name\n" |
| 10429 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10430 | "Neighbor to display information about\n" |
| 10431 | "Neighbor to display information about\n" |
| 10432 | "Display information received from a BGP neighbor\n" |
| 10433 | "Display the prefixlist filter\n") |
| 10434 | { |
| 10435 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10436 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10437 | struct peer *peer; |
| 10438 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10439 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10440 | |
| 10441 | /* BGP structure lookup. */ |
| 10442 | bgp = bgp_lookup_by_name (argv[0]); |
| 10443 | if (bgp == NULL) |
| 10444 | { |
| 10445 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10446 | return CMD_WARNING; |
| 10447 | } |
| 10448 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10449 | ret = str2sockunion (argv[1], &su); |
| 10450 | if (ret < 0) |
| 10451 | { |
| 10452 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10453 | return CMD_WARNING; |
| 10454 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10455 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10456 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10457 | if (! peer) |
| 10458 | return CMD_WARNING; |
| 10459 | |
| 10460 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10461 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10462 | if (count) |
| 10463 | { |
| 10464 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10465 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10466 | } |
| 10467 | |
| 10468 | return CMD_SUCCESS; |
| 10469 | } |
| 10470 | |
| 10471 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 10472 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 10473 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10474 | SHOW_STR |
| 10475 | BGP_STR |
| 10476 | "BGP view\n" |
| 10477 | "View name\n" |
| 10478 | "Address family\n" |
| 10479 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10480 | "Neighbor to display information about\n" |
| 10481 | "Neighbor to display information about\n" |
| 10482 | "Display information received from a BGP neighbor\n" |
| 10483 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10484 | #endif /* HAVE_IPV6 */ |
| 10485 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10486 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10487 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10488 | safi_t safi, enum bgp_show_type type) |
| 10489 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10490 | if (! peer || ! peer->afc[afi][safi]) |
| 10491 | { |
| 10492 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10493 | return CMD_WARNING; |
| 10494 | } |
| 10495 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10496 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10497 | } |
| 10498 | |
| 10499 | DEFUN (show_ip_bgp_neighbor_routes, |
| 10500 | show_ip_bgp_neighbor_routes_cmd, |
| 10501 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10502 | SHOW_STR |
| 10503 | IP_STR |
| 10504 | BGP_STR |
| 10505 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10506 | "Neighbor to display information about\n" |
| 10507 | "Neighbor to display information about\n" |
| 10508 | "Display routes learned from neighbor\n") |
| 10509 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10510 | struct peer *peer; |
| 10511 | |
| 10512 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10513 | if (! peer) |
| 10514 | return CMD_WARNING; |
| 10515 | |
| 10516 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10517 | bgp_show_type_neighbor); |
| 10518 | } |
| 10519 | |
| 10520 | DEFUN (show_ip_bgp_neighbor_flap, |
| 10521 | show_ip_bgp_neighbor_flap_cmd, |
| 10522 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10523 | SHOW_STR |
| 10524 | IP_STR |
| 10525 | BGP_STR |
| 10526 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10527 | "Neighbor to display information about\n" |
| 10528 | "Neighbor to display information about\n" |
| 10529 | "Display flap statistics of the routes learned from neighbor\n") |
| 10530 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10531 | struct peer *peer; |
| 10532 | |
| 10533 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10534 | if (! peer) |
| 10535 | return CMD_WARNING; |
| 10536 | |
| 10537 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10538 | bgp_show_type_flap_neighbor); |
| 10539 | } |
| 10540 | |
| 10541 | DEFUN (show_ip_bgp_neighbor_damp, |
| 10542 | show_ip_bgp_neighbor_damp_cmd, |
| 10543 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10544 | SHOW_STR |
| 10545 | IP_STR |
| 10546 | BGP_STR |
| 10547 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10548 | "Neighbor to display information about\n" |
| 10549 | "Neighbor to display information about\n" |
| 10550 | "Display the dampened routes received from neighbor\n") |
| 10551 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10552 | struct peer *peer; |
| 10553 | |
| 10554 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10555 | if (! peer) |
| 10556 | return CMD_WARNING; |
| 10557 | |
| 10558 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10559 | bgp_show_type_damp_neighbor); |
| 10560 | } |
| 10561 | |
| 10562 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 10563 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 10564 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 10565 | SHOW_STR |
| 10566 | IP_STR |
| 10567 | BGP_STR |
| 10568 | "Address family\n" |
| 10569 | "Address Family modifier\n" |
| 10570 | "Address Family modifier\n" |
| 10571 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10572 | "Neighbor to display information about\n" |
| 10573 | "Neighbor to display information about\n" |
| 10574 | "Display routes learned from neighbor\n") |
| 10575 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10576 | struct peer *peer; |
| 10577 | |
| 10578 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10579 | if (! peer) |
| 10580 | return CMD_WARNING; |
| 10581 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10582 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10583 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10584 | bgp_show_type_neighbor); |
| 10585 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10586 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10587 | bgp_show_type_neighbor); |
| 10588 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10589 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10590 | DEFUN (show_ip_bgp_view_rsclient, |
| 10591 | show_ip_bgp_view_rsclient_cmd, |
| 10592 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 10593 | SHOW_STR |
| 10594 | IP_STR |
| 10595 | BGP_STR |
| 10596 | "BGP view\n" |
| 10597 | "BGP view name\n" |
| 10598 | "Information about Route Server Client\n" |
| 10599 | NEIGHBOR_ADDR_STR) |
| 10600 | { |
| 10601 | struct bgp_table *table; |
| 10602 | struct peer *peer; |
| 10603 | |
| 10604 | if (argc == 2) |
| 10605 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10606 | else |
| 10607 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10608 | |
| 10609 | if (! peer) |
| 10610 | return CMD_WARNING; |
| 10611 | |
| 10612 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10613 | { |
| 10614 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10615 | VTY_NEWLINE); |
| 10616 | return CMD_WARNING; |
| 10617 | } |
| 10618 | |
| 10619 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10620 | PEER_FLAG_RSERVER_CLIENT)) |
| 10621 | { |
| 10622 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10623 | VTY_NEWLINE); |
| 10624 | return CMD_WARNING; |
| 10625 | } |
| 10626 | |
| 10627 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 10628 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10629 | 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] | 10630 | } |
| 10631 | |
| 10632 | ALIAS (show_ip_bgp_view_rsclient, |
| 10633 | show_ip_bgp_rsclient_cmd, |
| 10634 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 10635 | SHOW_STR |
| 10636 | IP_STR |
| 10637 | BGP_STR |
| 10638 | "Information about Route Server Client\n" |
| 10639 | NEIGHBOR_ADDR_STR) |
| 10640 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10641 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 10642 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 10643 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10644 | SHOW_STR |
| 10645 | BGP_STR |
| 10646 | "BGP view\n" |
| 10647 | "BGP view name\n" |
| 10648 | "Address family\n" |
| 10649 | "Address Family modifier\n" |
| 10650 | "Address Family modifier\n" |
| 10651 | "Information about Route Server Client\n" |
| 10652 | NEIGHBOR_ADDR_STR) |
| 10653 | { |
| 10654 | struct bgp_table *table; |
| 10655 | struct peer *peer; |
| 10656 | safi_t safi; |
| 10657 | |
| 10658 | if (argc == 3) { |
| 10659 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10660 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10661 | } else { |
| 10662 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10663 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10664 | } |
| 10665 | |
| 10666 | if (! peer) |
| 10667 | return CMD_WARNING; |
| 10668 | |
| 10669 | if (! peer->afc[AFI_IP][safi]) |
| 10670 | { |
| 10671 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10672 | VTY_NEWLINE); |
| 10673 | return CMD_WARNING; |
| 10674 | } |
| 10675 | |
| 10676 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10677 | PEER_FLAG_RSERVER_CLIENT)) |
| 10678 | { |
| 10679 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10680 | VTY_NEWLINE); |
| 10681 | return CMD_WARNING; |
| 10682 | } |
| 10683 | |
| 10684 | table = peer->rib[AFI_IP][safi]; |
| 10685 | |
| 10686 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 10687 | } |
| 10688 | |
| 10689 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 10690 | show_bgp_ipv4_safi_rsclient_cmd, |
| 10691 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10692 | SHOW_STR |
| 10693 | BGP_STR |
| 10694 | "Address family\n" |
| 10695 | "Address Family modifier\n" |
| 10696 | "Address Family modifier\n" |
| 10697 | "Information about Route Server Client\n" |
| 10698 | NEIGHBOR_ADDR_STR) |
| 10699 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10700 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 10701 | show_ip_bgp_view_rsclient_route_cmd, |
Michael Lambert | a8bf6f5 | 2008-09-24 17:23:11 +0100 | [diff] [blame] | 10702 | "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] | 10703 | SHOW_STR |
| 10704 | IP_STR |
| 10705 | BGP_STR |
| 10706 | "BGP view\n" |
| 10707 | "BGP view name\n" |
| 10708 | "Information about Route Server Client\n" |
| 10709 | NEIGHBOR_ADDR_STR |
| 10710 | "Network in the BGP routing table to display\n") |
| 10711 | { |
| 10712 | struct bgp *bgp; |
| 10713 | struct peer *peer; |
| 10714 | |
| 10715 | /* BGP structure lookup. */ |
| 10716 | if (argc == 3) |
| 10717 | { |
| 10718 | bgp = bgp_lookup_by_name (argv[0]); |
| 10719 | if (bgp == NULL) |
| 10720 | { |
| 10721 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10722 | return CMD_WARNING; |
| 10723 | } |
| 10724 | } |
| 10725 | else |
| 10726 | { |
| 10727 | bgp = bgp_get_default (); |
| 10728 | if (bgp == NULL) |
| 10729 | { |
| 10730 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10731 | return CMD_WARNING; |
| 10732 | } |
| 10733 | } |
| 10734 | |
| 10735 | if (argc == 3) |
| 10736 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10737 | else |
| 10738 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10739 | |
| 10740 | if (! peer) |
| 10741 | return CMD_WARNING; |
| 10742 | |
| 10743 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10744 | { |
| 10745 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10746 | VTY_NEWLINE); |
| 10747 | return CMD_WARNING; |
| 10748 | } |
| 10749 | |
| 10750 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10751 | PEER_FLAG_RSERVER_CLIENT)) |
| 10752 | { |
| 10753 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10754 | VTY_NEWLINE); |
| 10755 | return CMD_WARNING; |
| 10756 | } |
| 10757 | |
| 10758 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10759 | (argc == 3) ? argv[2] : argv[1], |
| 10760 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 10761 | } |
| 10762 | |
| 10763 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 10764 | show_ip_bgp_rsclient_route_cmd, |
| 10765 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10766 | SHOW_STR |
| 10767 | IP_STR |
| 10768 | BGP_STR |
| 10769 | "Information about Route Server Client\n" |
| 10770 | NEIGHBOR_ADDR_STR |
| 10771 | "Network in the BGP routing table to display\n") |
| 10772 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10773 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 10774 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 10775 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10776 | SHOW_STR |
| 10777 | BGP_STR |
| 10778 | "BGP view\n" |
| 10779 | "BGP view name\n" |
| 10780 | "Address family\n" |
| 10781 | "Address Family modifier\n" |
| 10782 | "Address Family modifier\n" |
| 10783 | "Information about Route Server Client\n" |
| 10784 | NEIGHBOR_ADDR_STR |
| 10785 | "Network in the BGP routing table to display\n") |
| 10786 | { |
| 10787 | struct bgp *bgp; |
| 10788 | struct peer *peer; |
| 10789 | safi_t safi; |
| 10790 | |
| 10791 | /* BGP structure lookup. */ |
| 10792 | if (argc == 4) |
| 10793 | { |
| 10794 | bgp = bgp_lookup_by_name (argv[0]); |
| 10795 | if (bgp == NULL) |
| 10796 | { |
| 10797 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10798 | return CMD_WARNING; |
| 10799 | } |
| 10800 | } |
| 10801 | else |
| 10802 | { |
| 10803 | bgp = bgp_get_default (); |
| 10804 | if (bgp == NULL) |
| 10805 | { |
| 10806 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10807 | return CMD_WARNING; |
| 10808 | } |
| 10809 | } |
| 10810 | |
| 10811 | if (argc == 4) { |
| 10812 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10813 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10814 | } else { |
| 10815 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10816 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10817 | } |
| 10818 | |
| 10819 | if (! peer) |
| 10820 | return CMD_WARNING; |
| 10821 | |
| 10822 | if (! peer->afc[AFI_IP][safi]) |
| 10823 | { |
| 10824 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10825 | VTY_NEWLINE); |
| 10826 | return CMD_WARNING; |
| 10827 | } |
| 10828 | |
| 10829 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10830 | PEER_FLAG_RSERVER_CLIENT)) |
| 10831 | { |
| 10832 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10833 | VTY_NEWLINE); |
| 10834 | return CMD_WARNING; |
| 10835 | } |
| 10836 | |
| 10837 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10838 | (argc == 4) ? argv[3] : argv[2], |
| 10839 | AFI_IP, safi, NULL, 0); |
| 10840 | } |
| 10841 | |
| 10842 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 10843 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 10844 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10845 | SHOW_STR |
| 10846 | BGP_STR |
| 10847 | "Address family\n" |
| 10848 | "Address Family modifier\n" |
| 10849 | "Address Family modifier\n" |
| 10850 | "Information about Route Server Client\n" |
| 10851 | NEIGHBOR_ADDR_STR |
| 10852 | "Network in the BGP routing table to display\n") |
| 10853 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10854 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 10855 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 10856 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10857 | SHOW_STR |
| 10858 | IP_STR |
| 10859 | BGP_STR |
| 10860 | "BGP view\n" |
| 10861 | "BGP view name\n" |
| 10862 | "Information about Route Server Client\n" |
| 10863 | NEIGHBOR_ADDR_STR |
| 10864 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10865 | { |
| 10866 | struct bgp *bgp; |
| 10867 | struct peer *peer; |
| 10868 | |
| 10869 | /* BGP structure lookup. */ |
| 10870 | if (argc == 3) |
| 10871 | { |
| 10872 | bgp = bgp_lookup_by_name (argv[0]); |
| 10873 | if (bgp == NULL) |
| 10874 | { |
| 10875 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10876 | return CMD_WARNING; |
| 10877 | } |
| 10878 | } |
| 10879 | else |
| 10880 | { |
| 10881 | bgp = bgp_get_default (); |
| 10882 | if (bgp == NULL) |
| 10883 | { |
| 10884 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10885 | return CMD_WARNING; |
| 10886 | } |
| 10887 | } |
| 10888 | |
| 10889 | if (argc == 3) |
| 10890 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10891 | else |
| 10892 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10893 | |
| 10894 | if (! peer) |
| 10895 | return CMD_WARNING; |
| 10896 | |
| 10897 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10898 | { |
| 10899 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10900 | VTY_NEWLINE); |
| 10901 | return CMD_WARNING; |
| 10902 | } |
| 10903 | |
| 10904 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10905 | PEER_FLAG_RSERVER_CLIENT)) |
| 10906 | { |
| 10907 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10908 | VTY_NEWLINE); |
| 10909 | return CMD_WARNING; |
| 10910 | } |
| 10911 | |
| 10912 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10913 | (argc == 3) ? argv[2] : argv[1], |
| 10914 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 10915 | } |
| 10916 | |
| 10917 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 10918 | show_ip_bgp_rsclient_prefix_cmd, |
| 10919 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10920 | SHOW_STR |
| 10921 | IP_STR |
| 10922 | BGP_STR |
| 10923 | "Information about Route Server Client\n" |
| 10924 | NEIGHBOR_ADDR_STR |
| 10925 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10926 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10927 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 10928 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 10929 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10930 | SHOW_STR |
| 10931 | BGP_STR |
| 10932 | "BGP view\n" |
| 10933 | "BGP view name\n" |
| 10934 | "Address family\n" |
| 10935 | "Address Family modifier\n" |
| 10936 | "Address Family modifier\n" |
| 10937 | "Information about Route Server Client\n" |
| 10938 | NEIGHBOR_ADDR_STR |
| 10939 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10940 | { |
| 10941 | struct bgp *bgp; |
| 10942 | struct peer *peer; |
| 10943 | safi_t safi; |
| 10944 | |
| 10945 | /* BGP structure lookup. */ |
| 10946 | if (argc == 4) |
| 10947 | { |
| 10948 | bgp = bgp_lookup_by_name (argv[0]); |
| 10949 | if (bgp == NULL) |
| 10950 | { |
| 10951 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10952 | return CMD_WARNING; |
| 10953 | } |
| 10954 | } |
| 10955 | else |
| 10956 | { |
| 10957 | bgp = bgp_get_default (); |
| 10958 | if (bgp == NULL) |
| 10959 | { |
| 10960 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10961 | return CMD_WARNING; |
| 10962 | } |
| 10963 | } |
| 10964 | |
| 10965 | if (argc == 4) { |
| 10966 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10967 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10968 | } else { |
| 10969 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10970 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10971 | } |
| 10972 | |
| 10973 | if (! peer) |
| 10974 | return CMD_WARNING; |
| 10975 | |
| 10976 | if (! peer->afc[AFI_IP][safi]) |
| 10977 | { |
| 10978 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10979 | VTY_NEWLINE); |
| 10980 | return CMD_WARNING; |
| 10981 | } |
| 10982 | |
| 10983 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10984 | PEER_FLAG_RSERVER_CLIENT)) |
| 10985 | { |
| 10986 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10987 | VTY_NEWLINE); |
| 10988 | return CMD_WARNING; |
| 10989 | } |
| 10990 | |
| 10991 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10992 | (argc == 4) ? argv[3] : argv[2], |
| 10993 | AFI_IP, safi, NULL, 1); |
| 10994 | } |
| 10995 | |
| 10996 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 10997 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 10998 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10999 | SHOW_STR |
| 11000 | BGP_STR |
| 11001 | "Address family\n" |
| 11002 | "Address Family modifier\n" |
| 11003 | "Address Family modifier\n" |
| 11004 | "Information about Route Server Client\n" |
| 11005 | NEIGHBOR_ADDR_STR |
| 11006 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11007 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11008 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11009 | DEFUN (show_bgp_view_neighbor_routes, |
| 11010 | show_bgp_view_neighbor_routes_cmd, |
| 11011 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 11012 | SHOW_STR |
| 11013 | BGP_STR |
| 11014 | "BGP view\n" |
| 11015 | "BGP view name\n" |
| 11016 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11017 | "Neighbor to display information about\n" |
| 11018 | "Neighbor to display information about\n" |
| 11019 | "Display routes learned from neighbor\n") |
| 11020 | { |
| 11021 | struct peer *peer; |
| 11022 | |
| 11023 | if (argc == 2) |
| 11024 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11025 | else |
| 11026 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11027 | |
| 11028 | if (! peer) |
| 11029 | return CMD_WARNING; |
| 11030 | |
| 11031 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11032 | bgp_show_type_neighbor); |
| 11033 | } |
| 11034 | |
| 11035 | ALIAS (show_bgp_view_neighbor_routes, |
| 11036 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 11037 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11038 | SHOW_STR |
| 11039 | BGP_STR |
| 11040 | "BGP view\n" |
| 11041 | "BGP view name\n" |
| 11042 | "Address family\n" |
| 11043 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11044 | "Neighbor to display information about\n" |
| 11045 | "Neighbor to display information about\n" |
| 11046 | "Display routes learned from neighbor\n") |
| 11047 | |
| 11048 | DEFUN (show_bgp_view_neighbor_damp, |
| 11049 | show_bgp_view_neighbor_damp_cmd, |
| 11050 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11051 | SHOW_STR |
| 11052 | BGP_STR |
| 11053 | "BGP view\n" |
| 11054 | "BGP view name\n" |
| 11055 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11056 | "Neighbor to display information about\n" |
| 11057 | "Neighbor to display information about\n" |
| 11058 | "Display the dampened routes received from neighbor\n") |
| 11059 | { |
| 11060 | struct peer *peer; |
| 11061 | |
| 11062 | if (argc == 2) |
| 11063 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11064 | else |
| 11065 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11066 | |
| 11067 | if (! peer) |
| 11068 | return CMD_WARNING; |
| 11069 | |
| 11070 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11071 | bgp_show_type_damp_neighbor); |
| 11072 | } |
| 11073 | |
| 11074 | ALIAS (show_bgp_view_neighbor_damp, |
| 11075 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 11076 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11077 | SHOW_STR |
| 11078 | BGP_STR |
| 11079 | "BGP view\n" |
| 11080 | "BGP view name\n" |
| 11081 | "Address family\n" |
| 11082 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11083 | "Neighbor to display information about\n" |
| 11084 | "Neighbor to display information about\n" |
| 11085 | "Display the dampened routes received from neighbor\n") |
| 11086 | |
| 11087 | DEFUN (show_bgp_view_neighbor_flap, |
| 11088 | show_bgp_view_neighbor_flap_cmd, |
| 11089 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11090 | SHOW_STR |
| 11091 | BGP_STR |
| 11092 | "BGP view\n" |
| 11093 | "BGP view name\n" |
| 11094 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11095 | "Neighbor to display information about\n" |
| 11096 | "Neighbor to display information about\n" |
| 11097 | "Display flap statistics of the routes learned from neighbor\n") |
| 11098 | { |
| 11099 | struct peer *peer; |
| 11100 | |
| 11101 | if (argc == 2) |
| 11102 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11103 | else |
| 11104 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11105 | |
| 11106 | if (! peer) |
| 11107 | return CMD_WARNING; |
| 11108 | |
| 11109 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11110 | bgp_show_type_flap_neighbor); |
| 11111 | } |
| 11112 | |
| 11113 | ALIAS (show_bgp_view_neighbor_flap, |
| 11114 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 11115 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11116 | SHOW_STR |
| 11117 | BGP_STR |
| 11118 | "BGP view\n" |
| 11119 | "BGP view name\n" |
| 11120 | "Address family\n" |
| 11121 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11122 | "Neighbor to display information about\n" |
| 11123 | "Neighbor to display information about\n" |
| 11124 | "Display flap statistics of the routes learned from neighbor\n") |
| 11125 | |
| 11126 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11127 | show_bgp_neighbor_routes_cmd, |
| 11128 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11129 | SHOW_STR |
| 11130 | BGP_STR |
| 11131 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11132 | "Neighbor to display information about\n" |
| 11133 | "Neighbor to display information about\n" |
| 11134 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11135 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11136 | |
| 11137 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11138 | show_bgp_ipv6_neighbor_routes_cmd, |
| 11139 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11140 | SHOW_STR |
| 11141 | BGP_STR |
| 11142 | "Address family\n" |
| 11143 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11144 | "Neighbor to display information about\n" |
| 11145 | "Neighbor to display information about\n" |
| 11146 | "Display routes learned from neighbor\n") |
| 11147 | |
| 11148 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11149 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11150 | ipv6_bgp_neighbor_routes_cmd, |
| 11151 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11152 | SHOW_STR |
| 11153 | IPV6_STR |
| 11154 | BGP_STR |
| 11155 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11156 | "Neighbor to display information about\n" |
| 11157 | "Neighbor to display information about\n" |
| 11158 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11159 | |
| 11160 | /* old command */ |
| 11161 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 11162 | ipv6_mbgp_neighbor_routes_cmd, |
| 11163 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11164 | SHOW_STR |
| 11165 | IPV6_STR |
| 11166 | MBGP_STR |
| 11167 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11168 | "Neighbor to display information about\n" |
| 11169 | "Neighbor to display information about\n" |
| 11170 | "Display routes learned from neighbor\n") |
| 11171 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11172 | struct peer *peer; |
| 11173 | |
| 11174 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11175 | if (! peer) |
| 11176 | return CMD_WARNING; |
| 11177 | |
| 11178 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11179 | bgp_show_type_neighbor); |
| 11180 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11181 | |
| 11182 | ALIAS (show_bgp_view_neighbor_flap, |
| 11183 | show_bgp_neighbor_flap_cmd, |
| 11184 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11185 | SHOW_STR |
| 11186 | BGP_STR |
| 11187 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11188 | "Neighbor to display information about\n" |
| 11189 | "Neighbor to display information about\n" |
| 11190 | "Display flap statistics of the routes learned from neighbor\n") |
| 11191 | |
| 11192 | ALIAS (show_bgp_view_neighbor_flap, |
| 11193 | show_bgp_ipv6_neighbor_flap_cmd, |
| 11194 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11195 | SHOW_STR |
| 11196 | BGP_STR |
| 11197 | "Address family\n" |
| 11198 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11199 | "Neighbor to display information about\n" |
| 11200 | "Neighbor to display information about\n" |
| 11201 | "Display flap statistics of the routes learned from neighbor\n") |
| 11202 | |
| 11203 | ALIAS (show_bgp_view_neighbor_damp, |
| 11204 | show_bgp_neighbor_damp_cmd, |
| 11205 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11206 | SHOW_STR |
| 11207 | BGP_STR |
| 11208 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11209 | "Neighbor to display information about\n" |
| 11210 | "Neighbor to display information about\n" |
| 11211 | "Display the dampened routes received from neighbor\n") |
| 11212 | |
| 11213 | ALIAS (show_bgp_view_neighbor_damp, |
| 11214 | show_bgp_ipv6_neighbor_damp_cmd, |
| 11215 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11216 | SHOW_STR |
| 11217 | BGP_STR |
| 11218 | "Address family\n" |
| 11219 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11220 | "Neighbor to display information about\n" |
| 11221 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 11222 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11223 | |
| 11224 | DEFUN (show_bgp_view_rsclient, |
| 11225 | show_bgp_view_rsclient_cmd, |
| 11226 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 11227 | SHOW_STR |
| 11228 | BGP_STR |
| 11229 | "BGP view\n" |
| 11230 | "BGP view name\n" |
| 11231 | "Information about Route Server Client\n" |
| 11232 | NEIGHBOR_ADDR_STR) |
| 11233 | { |
| 11234 | struct bgp_table *table; |
| 11235 | struct peer *peer; |
| 11236 | |
| 11237 | if (argc == 2) |
| 11238 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11239 | else |
| 11240 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11241 | |
| 11242 | if (! peer) |
| 11243 | return CMD_WARNING; |
| 11244 | |
| 11245 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11246 | { |
| 11247 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11248 | VTY_NEWLINE); |
| 11249 | return CMD_WARNING; |
| 11250 | } |
| 11251 | |
| 11252 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11253 | PEER_FLAG_RSERVER_CLIENT)) |
| 11254 | { |
| 11255 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11256 | VTY_NEWLINE); |
| 11257 | return CMD_WARNING; |
| 11258 | } |
| 11259 | |
| 11260 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 11261 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11262 | 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] | 11263 | } |
| 11264 | |
| 11265 | ALIAS (show_bgp_view_rsclient, |
| 11266 | show_bgp_rsclient_cmd, |
| 11267 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 11268 | SHOW_STR |
| 11269 | BGP_STR |
| 11270 | "Information about Route Server Client\n" |
| 11271 | NEIGHBOR_ADDR_STR) |
| 11272 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11273 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 11274 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 11275 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11276 | SHOW_STR |
| 11277 | BGP_STR |
| 11278 | "BGP view\n" |
| 11279 | "BGP view name\n" |
| 11280 | "Address family\n" |
| 11281 | "Address Family modifier\n" |
| 11282 | "Address Family modifier\n" |
| 11283 | "Information about Route Server Client\n" |
| 11284 | NEIGHBOR_ADDR_STR) |
| 11285 | { |
| 11286 | struct bgp_table *table; |
| 11287 | struct peer *peer; |
| 11288 | safi_t safi; |
| 11289 | |
| 11290 | if (argc == 3) { |
| 11291 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11292 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11293 | } else { |
| 11294 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11295 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11296 | } |
| 11297 | |
| 11298 | if (! peer) |
| 11299 | return CMD_WARNING; |
| 11300 | |
| 11301 | if (! peer->afc[AFI_IP6][safi]) |
| 11302 | { |
| 11303 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11304 | VTY_NEWLINE); |
| 11305 | return CMD_WARNING; |
| 11306 | } |
| 11307 | |
| 11308 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11309 | PEER_FLAG_RSERVER_CLIENT)) |
| 11310 | { |
| 11311 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11312 | VTY_NEWLINE); |
| 11313 | return CMD_WARNING; |
| 11314 | } |
| 11315 | |
| 11316 | table = peer->rib[AFI_IP6][safi]; |
| 11317 | |
| 11318 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 11319 | } |
| 11320 | |
| 11321 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 11322 | show_bgp_ipv6_safi_rsclient_cmd, |
| 11323 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11324 | SHOW_STR |
| 11325 | BGP_STR |
| 11326 | "Address family\n" |
| 11327 | "Address Family modifier\n" |
| 11328 | "Address Family modifier\n" |
| 11329 | "Information about Route Server Client\n" |
| 11330 | NEIGHBOR_ADDR_STR) |
| 11331 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11332 | DEFUN (show_bgp_view_rsclient_route, |
| 11333 | show_bgp_view_rsclient_route_cmd, |
| 11334 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11335 | SHOW_STR |
| 11336 | BGP_STR |
| 11337 | "BGP view\n" |
| 11338 | "BGP view name\n" |
| 11339 | "Information about Route Server Client\n" |
| 11340 | NEIGHBOR_ADDR_STR |
| 11341 | "Network in the BGP routing table to display\n") |
| 11342 | { |
| 11343 | struct bgp *bgp; |
| 11344 | struct peer *peer; |
| 11345 | |
| 11346 | /* BGP structure lookup. */ |
| 11347 | if (argc == 3) |
| 11348 | { |
| 11349 | bgp = bgp_lookup_by_name (argv[0]); |
| 11350 | if (bgp == NULL) |
| 11351 | { |
| 11352 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11353 | return CMD_WARNING; |
| 11354 | } |
| 11355 | } |
| 11356 | else |
| 11357 | { |
| 11358 | bgp = bgp_get_default (); |
| 11359 | if (bgp == NULL) |
| 11360 | { |
| 11361 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11362 | return CMD_WARNING; |
| 11363 | } |
| 11364 | } |
| 11365 | |
| 11366 | if (argc == 3) |
| 11367 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11368 | else |
| 11369 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11370 | |
| 11371 | if (! peer) |
| 11372 | return CMD_WARNING; |
| 11373 | |
| 11374 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11375 | { |
| 11376 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11377 | VTY_NEWLINE); |
| 11378 | return CMD_WARNING; |
| 11379 | } |
| 11380 | |
| 11381 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11382 | PEER_FLAG_RSERVER_CLIENT)) |
| 11383 | { |
| 11384 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11385 | VTY_NEWLINE); |
| 11386 | return CMD_WARNING; |
| 11387 | } |
| 11388 | |
| 11389 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11390 | (argc == 3) ? argv[2] : argv[1], |
| 11391 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 11392 | } |
| 11393 | |
| 11394 | ALIAS (show_bgp_view_rsclient_route, |
| 11395 | show_bgp_rsclient_route_cmd, |
| 11396 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11397 | SHOW_STR |
| 11398 | BGP_STR |
| 11399 | "Information about Route Server Client\n" |
| 11400 | NEIGHBOR_ADDR_STR |
| 11401 | "Network in the BGP routing table to display\n") |
| 11402 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11403 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 11404 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 11405 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11406 | SHOW_STR |
| 11407 | BGP_STR |
| 11408 | "BGP view\n" |
| 11409 | "BGP view name\n" |
| 11410 | "Address family\n" |
| 11411 | "Address Family modifier\n" |
| 11412 | "Address Family modifier\n" |
| 11413 | "Information about Route Server Client\n" |
| 11414 | NEIGHBOR_ADDR_STR |
| 11415 | "Network in the BGP routing table to display\n") |
| 11416 | { |
| 11417 | struct bgp *bgp; |
| 11418 | struct peer *peer; |
| 11419 | safi_t safi; |
| 11420 | |
| 11421 | /* BGP structure lookup. */ |
| 11422 | if (argc == 4) |
| 11423 | { |
| 11424 | bgp = bgp_lookup_by_name (argv[0]); |
| 11425 | if (bgp == NULL) |
| 11426 | { |
| 11427 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11428 | return CMD_WARNING; |
| 11429 | } |
| 11430 | } |
| 11431 | else |
| 11432 | { |
| 11433 | bgp = bgp_get_default (); |
| 11434 | if (bgp == NULL) |
| 11435 | { |
| 11436 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11437 | return CMD_WARNING; |
| 11438 | } |
| 11439 | } |
| 11440 | |
| 11441 | if (argc == 4) { |
| 11442 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11443 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11444 | } else { |
| 11445 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11446 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11447 | } |
| 11448 | |
| 11449 | if (! peer) |
| 11450 | return CMD_WARNING; |
| 11451 | |
| 11452 | if (! peer->afc[AFI_IP6][safi]) |
| 11453 | { |
| 11454 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11455 | VTY_NEWLINE); |
| 11456 | return CMD_WARNING; |
| 11457 | } |
| 11458 | |
| 11459 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11460 | PEER_FLAG_RSERVER_CLIENT)) |
| 11461 | { |
| 11462 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11463 | VTY_NEWLINE); |
| 11464 | return CMD_WARNING; |
| 11465 | } |
| 11466 | |
| 11467 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11468 | (argc == 4) ? argv[3] : argv[2], |
| 11469 | AFI_IP6, safi, NULL, 0); |
| 11470 | } |
| 11471 | |
| 11472 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 11473 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 11474 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11475 | SHOW_STR |
| 11476 | BGP_STR |
| 11477 | "Address family\n" |
| 11478 | "Address Family modifier\n" |
| 11479 | "Address Family modifier\n" |
| 11480 | "Information about Route Server Client\n" |
| 11481 | NEIGHBOR_ADDR_STR |
| 11482 | "Network in the BGP routing table to display\n") |
| 11483 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11484 | DEFUN (show_bgp_view_rsclient_prefix, |
| 11485 | show_bgp_view_rsclient_prefix_cmd, |
| 11486 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11487 | SHOW_STR |
| 11488 | BGP_STR |
| 11489 | "BGP view\n" |
| 11490 | "BGP view name\n" |
| 11491 | "Information about Route Server Client\n" |
| 11492 | NEIGHBOR_ADDR_STR |
| 11493 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11494 | { |
| 11495 | struct bgp *bgp; |
| 11496 | struct peer *peer; |
| 11497 | |
| 11498 | /* BGP structure lookup. */ |
| 11499 | if (argc == 3) |
| 11500 | { |
| 11501 | bgp = bgp_lookup_by_name (argv[0]); |
| 11502 | if (bgp == NULL) |
| 11503 | { |
| 11504 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11505 | return CMD_WARNING; |
| 11506 | } |
| 11507 | } |
| 11508 | else |
| 11509 | { |
| 11510 | bgp = bgp_get_default (); |
| 11511 | if (bgp == NULL) |
| 11512 | { |
| 11513 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11514 | return CMD_WARNING; |
| 11515 | } |
| 11516 | } |
| 11517 | |
| 11518 | if (argc == 3) |
| 11519 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11520 | else |
| 11521 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11522 | |
| 11523 | if (! peer) |
| 11524 | return CMD_WARNING; |
| 11525 | |
| 11526 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11527 | { |
| 11528 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11529 | VTY_NEWLINE); |
| 11530 | return CMD_WARNING; |
| 11531 | } |
| 11532 | |
| 11533 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11534 | PEER_FLAG_RSERVER_CLIENT)) |
| 11535 | { |
| 11536 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11537 | VTY_NEWLINE); |
| 11538 | return CMD_WARNING; |
| 11539 | } |
| 11540 | |
| 11541 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11542 | (argc == 3) ? argv[2] : argv[1], |
| 11543 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 11544 | } |
| 11545 | |
| 11546 | ALIAS (show_bgp_view_rsclient_prefix, |
| 11547 | show_bgp_rsclient_prefix_cmd, |
| 11548 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11549 | SHOW_STR |
| 11550 | BGP_STR |
| 11551 | "Information about Route Server Client\n" |
| 11552 | NEIGHBOR_ADDR_STR |
| 11553 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11554 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11555 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11556 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 11557 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11558 | SHOW_STR |
| 11559 | BGP_STR |
| 11560 | "BGP view\n" |
| 11561 | "BGP view name\n" |
| 11562 | "Address family\n" |
| 11563 | "Address Family modifier\n" |
| 11564 | "Address Family modifier\n" |
| 11565 | "Information about Route Server Client\n" |
| 11566 | NEIGHBOR_ADDR_STR |
| 11567 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11568 | { |
| 11569 | struct bgp *bgp; |
| 11570 | struct peer *peer; |
| 11571 | safi_t safi; |
| 11572 | |
| 11573 | /* BGP structure lookup. */ |
| 11574 | if (argc == 4) |
| 11575 | { |
| 11576 | bgp = bgp_lookup_by_name (argv[0]); |
| 11577 | if (bgp == NULL) |
| 11578 | { |
| 11579 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11580 | return CMD_WARNING; |
| 11581 | } |
| 11582 | } |
| 11583 | else |
| 11584 | { |
| 11585 | bgp = bgp_get_default (); |
| 11586 | if (bgp == NULL) |
| 11587 | { |
| 11588 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11589 | return CMD_WARNING; |
| 11590 | } |
| 11591 | } |
| 11592 | |
| 11593 | if (argc == 4) { |
| 11594 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11595 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11596 | } else { |
| 11597 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11598 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11599 | } |
| 11600 | |
| 11601 | if (! peer) |
| 11602 | return CMD_WARNING; |
| 11603 | |
| 11604 | if (! peer->afc[AFI_IP6][safi]) |
| 11605 | { |
| 11606 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11607 | VTY_NEWLINE); |
| 11608 | return CMD_WARNING; |
| 11609 | } |
| 11610 | |
| 11611 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11612 | PEER_FLAG_RSERVER_CLIENT)) |
| 11613 | { |
| 11614 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11615 | VTY_NEWLINE); |
| 11616 | return CMD_WARNING; |
| 11617 | } |
| 11618 | |
| 11619 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11620 | (argc == 4) ? argv[3] : argv[2], |
| 11621 | AFI_IP6, safi, NULL, 1); |
| 11622 | } |
| 11623 | |
| 11624 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11625 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 11626 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11627 | SHOW_STR |
| 11628 | BGP_STR |
| 11629 | "Address family\n" |
| 11630 | "Address Family modifier\n" |
| 11631 | "Address Family modifier\n" |
| 11632 | "Information about Route Server Client\n" |
| 11633 | NEIGHBOR_ADDR_STR |
| 11634 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11635 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11636 | #endif /* HAVE_IPV6 */ |
| 11637 | |
| 11638 | struct bgp_table *bgp_distance_table; |
| 11639 | |
| 11640 | struct bgp_distance |
| 11641 | { |
| 11642 | /* Distance value for the IP source prefix. */ |
| 11643 | u_char distance; |
| 11644 | |
| 11645 | /* Name of the access-list to be matched. */ |
| 11646 | char *access_list; |
| 11647 | }; |
| 11648 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11649 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 11650 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11651 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 11652 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11653 | } |
| 11654 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11655 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11656 | bgp_distance_free (struct bgp_distance *bdistance) |
| 11657 | { |
| 11658 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 11659 | } |
| 11660 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11661 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11662 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 11663 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11664 | { |
| 11665 | int ret; |
| 11666 | struct prefix_ipv4 p; |
| 11667 | u_char distance; |
| 11668 | struct bgp_node *rn; |
| 11669 | struct bgp_distance *bdistance; |
| 11670 | |
| 11671 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11672 | if (ret == 0) |
| 11673 | { |
| 11674 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11675 | return CMD_WARNING; |
| 11676 | } |
| 11677 | |
| 11678 | distance = atoi (distance_str); |
| 11679 | |
| 11680 | /* Get BGP distance node. */ |
| 11681 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 11682 | if (rn->info) |
| 11683 | { |
| 11684 | bdistance = rn->info; |
| 11685 | bgp_unlock_node (rn); |
| 11686 | } |
| 11687 | else |
| 11688 | { |
| 11689 | bdistance = bgp_distance_new (); |
| 11690 | rn->info = bdistance; |
| 11691 | } |
| 11692 | |
| 11693 | /* Set distance value. */ |
| 11694 | bdistance->distance = distance; |
| 11695 | |
| 11696 | /* Reset access-list configuration. */ |
| 11697 | if (bdistance->access_list) |
| 11698 | { |
| 11699 | free (bdistance->access_list); |
| 11700 | bdistance->access_list = NULL; |
| 11701 | } |
| 11702 | if (access_list_str) |
| 11703 | bdistance->access_list = strdup (access_list_str); |
| 11704 | |
| 11705 | return CMD_SUCCESS; |
| 11706 | } |
| 11707 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11708 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11709 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 11710 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11711 | { |
| 11712 | int ret; |
| 11713 | struct prefix_ipv4 p; |
| 11714 | u_char distance; |
| 11715 | struct bgp_node *rn; |
| 11716 | struct bgp_distance *bdistance; |
| 11717 | |
| 11718 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11719 | if (ret == 0) |
| 11720 | { |
| 11721 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11722 | return CMD_WARNING; |
| 11723 | } |
| 11724 | |
| 11725 | distance = atoi (distance_str); |
| 11726 | |
| 11727 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 11728 | if (! rn) |
| 11729 | { |
| 11730 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 11731 | return CMD_WARNING; |
| 11732 | } |
| 11733 | |
| 11734 | bdistance = rn->info; |
| 11735 | |
| 11736 | if (bdistance->access_list) |
| 11737 | free (bdistance->access_list); |
| 11738 | bgp_distance_free (bdistance); |
| 11739 | |
| 11740 | rn->info = NULL; |
| 11741 | bgp_unlock_node (rn); |
| 11742 | bgp_unlock_node (rn); |
| 11743 | |
| 11744 | return CMD_SUCCESS; |
| 11745 | } |
| 11746 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11747 | /* Apply BGP information to distance method. */ |
| 11748 | u_char |
| 11749 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 11750 | { |
| 11751 | struct bgp_node *rn; |
| 11752 | struct prefix_ipv4 q; |
| 11753 | struct peer *peer; |
| 11754 | struct bgp_distance *bdistance; |
| 11755 | struct access_list *alist; |
| 11756 | struct bgp_static *bgp_static; |
| 11757 | |
| 11758 | if (! bgp) |
| 11759 | return 0; |
| 11760 | |
| 11761 | if (p->family != AF_INET) |
| 11762 | return 0; |
| 11763 | |
| 11764 | peer = rinfo->peer; |
| 11765 | |
| 11766 | if (peer->su.sa.sa_family != AF_INET) |
| 11767 | return 0; |
| 11768 | |
| 11769 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 11770 | q.family = AF_INET; |
| 11771 | q.prefix = peer->su.sin.sin_addr; |
| 11772 | q.prefixlen = IPV4_MAX_BITLEN; |
| 11773 | |
| 11774 | /* Check source address. */ |
| 11775 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 11776 | if (rn) |
| 11777 | { |
| 11778 | bdistance = rn->info; |
| 11779 | bgp_unlock_node (rn); |
| 11780 | |
| 11781 | if (bdistance->access_list) |
| 11782 | { |
| 11783 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 11784 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 11785 | return bdistance->distance; |
| 11786 | } |
| 11787 | else |
| 11788 | return bdistance->distance; |
| 11789 | } |
| 11790 | |
| 11791 | /* Backdoor check. */ |
| 11792 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 11793 | if (rn) |
| 11794 | { |
| 11795 | bgp_static = rn->info; |
| 11796 | bgp_unlock_node (rn); |
| 11797 | |
| 11798 | if (bgp_static->backdoor) |
| 11799 | { |
| 11800 | if (bgp->distance_local) |
| 11801 | return bgp->distance_local; |
| 11802 | else |
| 11803 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11804 | } |
| 11805 | } |
| 11806 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 11807 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11808 | { |
| 11809 | if (bgp->distance_ebgp) |
| 11810 | return bgp->distance_ebgp; |
| 11811 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 11812 | } |
| 11813 | else |
| 11814 | { |
| 11815 | if (bgp->distance_ibgp) |
| 11816 | return bgp->distance_ibgp; |
| 11817 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11818 | } |
| 11819 | } |
| 11820 | |
| 11821 | DEFUN (bgp_distance, |
| 11822 | bgp_distance_cmd, |
| 11823 | "distance bgp <1-255> <1-255> <1-255>", |
| 11824 | "Define an administrative distance\n" |
| 11825 | "BGP distance\n" |
| 11826 | "Distance for routes external to the AS\n" |
| 11827 | "Distance for routes internal to the AS\n" |
| 11828 | "Distance for local routes\n") |
| 11829 | { |
| 11830 | struct bgp *bgp; |
| 11831 | |
| 11832 | bgp = vty->index; |
| 11833 | |
| 11834 | bgp->distance_ebgp = atoi (argv[0]); |
| 11835 | bgp->distance_ibgp = atoi (argv[1]); |
| 11836 | bgp->distance_local = atoi (argv[2]); |
| 11837 | return CMD_SUCCESS; |
| 11838 | } |
| 11839 | |
| 11840 | DEFUN (no_bgp_distance, |
| 11841 | no_bgp_distance_cmd, |
| 11842 | "no distance bgp <1-255> <1-255> <1-255>", |
| 11843 | NO_STR |
| 11844 | "Define an administrative distance\n" |
| 11845 | "BGP distance\n" |
| 11846 | "Distance for routes external to the AS\n" |
| 11847 | "Distance for routes internal to the AS\n" |
| 11848 | "Distance for local routes\n") |
| 11849 | { |
| 11850 | struct bgp *bgp; |
| 11851 | |
| 11852 | bgp = vty->index; |
| 11853 | |
| 11854 | bgp->distance_ebgp= 0; |
| 11855 | bgp->distance_ibgp = 0; |
| 11856 | bgp->distance_local = 0; |
| 11857 | return CMD_SUCCESS; |
| 11858 | } |
| 11859 | |
| 11860 | ALIAS (no_bgp_distance, |
| 11861 | no_bgp_distance2_cmd, |
| 11862 | "no distance bgp", |
| 11863 | NO_STR |
| 11864 | "Define an administrative distance\n" |
| 11865 | "BGP distance\n") |
| 11866 | |
| 11867 | DEFUN (bgp_distance_source, |
| 11868 | bgp_distance_source_cmd, |
| 11869 | "distance <1-255> A.B.C.D/M", |
| 11870 | "Define an administrative distance\n" |
| 11871 | "Administrative distance\n" |
| 11872 | "IP source prefix\n") |
| 11873 | { |
| 11874 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 11875 | return CMD_SUCCESS; |
| 11876 | } |
| 11877 | |
| 11878 | DEFUN (no_bgp_distance_source, |
| 11879 | no_bgp_distance_source_cmd, |
| 11880 | "no distance <1-255> A.B.C.D/M", |
| 11881 | NO_STR |
| 11882 | "Define an administrative distance\n" |
| 11883 | "Administrative distance\n" |
| 11884 | "IP source prefix\n") |
| 11885 | { |
| 11886 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 11887 | return CMD_SUCCESS; |
| 11888 | } |
| 11889 | |
| 11890 | DEFUN (bgp_distance_source_access_list, |
| 11891 | bgp_distance_source_access_list_cmd, |
| 11892 | "distance <1-255> A.B.C.D/M WORD", |
| 11893 | "Define an administrative distance\n" |
| 11894 | "Administrative distance\n" |
| 11895 | "IP source prefix\n" |
| 11896 | "Access list name\n") |
| 11897 | { |
| 11898 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 11899 | return CMD_SUCCESS; |
| 11900 | } |
| 11901 | |
| 11902 | DEFUN (no_bgp_distance_source_access_list, |
| 11903 | no_bgp_distance_source_access_list_cmd, |
| 11904 | "no distance <1-255> A.B.C.D/M WORD", |
| 11905 | NO_STR |
| 11906 | "Define an administrative distance\n" |
| 11907 | "Administrative distance\n" |
| 11908 | "IP source prefix\n" |
| 11909 | "Access list name\n") |
| 11910 | { |
| 11911 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 11912 | return CMD_SUCCESS; |
| 11913 | } |
| 11914 | |
| 11915 | DEFUN (bgp_damp_set, |
| 11916 | bgp_damp_set_cmd, |
| 11917 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 11918 | "BGP Specific commands\n" |
| 11919 | "Enable route-flap dampening\n" |
| 11920 | "Half-life time for the penalty\n" |
| 11921 | "Value to start reusing a route\n" |
| 11922 | "Value to start suppressing a route\n" |
| 11923 | "Maximum duration to suppress a stable route\n") |
| 11924 | { |
| 11925 | struct bgp *bgp; |
| 11926 | int half = DEFAULT_HALF_LIFE * 60; |
| 11927 | int reuse = DEFAULT_REUSE; |
| 11928 | int suppress = DEFAULT_SUPPRESS; |
| 11929 | int max = 4 * half; |
| 11930 | |
| 11931 | if (argc == 4) |
| 11932 | { |
| 11933 | half = atoi (argv[0]) * 60; |
| 11934 | reuse = atoi (argv[1]); |
| 11935 | suppress = atoi (argv[2]); |
| 11936 | max = atoi (argv[3]) * 60; |
| 11937 | } |
| 11938 | else if (argc == 1) |
| 11939 | { |
| 11940 | half = atoi (argv[0]) * 60; |
| 11941 | max = 4 * half; |
| 11942 | } |
| 11943 | |
| 11944 | bgp = vty->index; |
| 11945 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 11946 | half, reuse, suppress, max); |
| 11947 | } |
| 11948 | |
| 11949 | ALIAS (bgp_damp_set, |
| 11950 | bgp_damp_set2_cmd, |
| 11951 | "bgp dampening <1-45>", |
| 11952 | "BGP Specific commands\n" |
| 11953 | "Enable route-flap dampening\n" |
| 11954 | "Half-life time for the penalty\n") |
| 11955 | |
| 11956 | ALIAS (bgp_damp_set, |
| 11957 | bgp_damp_set3_cmd, |
| 11958 | "bgp dampening", |
| 11959 | "BGP Specific commands\n" |
| 11960 | "Enable route-flap dampening\n") |
| 11961 | |
| 11962 | DEFUN (bgp_damp_unset, |
| 11963 | bgp_damp_unset_cmd, |
| 11964 | "no bgp dampening", |
| 11965 | NO_STR |
| 11966 | "BGP Specific commands\n" |
| 11967 | "Enable route-flap dampening\n") |
| 11968 | { |
| 11969 | struct bgp *bgp; |
| 11970 | |
| 11971 | bgp = vty->index; |
| 11972 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 11973 | } |
| 11974 | |
| 11975 | ALIAS (bgp_damp_unset, |
| 11976 | bgp_damp_unset2_cmd, |
| 11977 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 11978 | NO_STR |
| 11979 | "BGP Specific commands\n" |
| 11980 | "Enable route-flap dampening\n" |
| 11981 | "Half-life time for the penalty\n" |
| 11982 | "Value to start reusing a route\n" |
| 11983 | "Value to start suppressing a route\n" |
| 11984 | "Maximum duration to suppress a stable route\n") |
| 11985 | |
| 11986 | DEFUN (show_ip_bgp_dampened_paths, |
| 11987 | show_ip_bgp_dampened_paths_cmd, |
| 11988 | "show ip bgp dampened-paths", |
| 11989 | SHOW_STR |
| 11990 | IP_STR |
| 11991 | BGP_STR |
| 11992 | "Display paths suppressed due to dampening\n") |
| 11993 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11994 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 11995 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11996 | } |
| 11997 | |
| 11998 | DEFUN (show_ip_bgp_flap_statistics, |
| 11999 | show_ip_bgp_flap_statistics_cmd, |
| 12000 | "show ip bgp flap-statistics", |
| 12001 | SHOW_STR |
| 12002 | IP_STR |
| 12003 | BGP_STR |
| 12004 | "Display flap statistics of routes\n") |
| 12005 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12006 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 12007 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12008 | } |
| 12009 | |
| 12010 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12011 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 12012 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 12013 | const char *ip_str, afi_t afi, safi_t safi, |
| 12014 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12015 | { |
| 12016 | int ret; |
| 12017 | struct prefix match; |
| 12018 | struct bgp_node *rn; |
| 12019 | struct bgp_node *rm; |
| 12020 | struct bgp_info *ri; |
| 12021 | struct bgp_info *ri_temp; |
| 12022 | struct bgp *bgp; |
| 12023 | struct bgp_table *table; |
| 12024 | |
| 12025 | /* BGP structure lookup. */ |
| 12026 | if (view_name) |
| 12027 | { |
| 12028 | bgp = bgp_lookup_by_name (view_name); |
| 12029 | if (bgp == NULL) |
| 12030 | { |
| 12031 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 12032 | return CMD_WARNING; |
| 12033 | } |
| 12034 | } |
| 12035 | else |
| 12036 | { |
| 12037 | bgp = bgp_get_default (); |
| 12038 | if (bgp == NULL) |
| 12039 | { |
| 12040 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 12041 | return CMD_WARNING; |
| 12042 | } |
| 12043 | } |
| 12044 | |
| 12045 | /* Check IP address argument. */ |
| 12046 | ret = str2prefix (ip_str, &match); |
| 12047 | if (! ret) |
| 12048 | { |
| 12049 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 12050 | return CMD_WARNING; |
| 12051 | } |
| 12052 | |
| 12053 | match.family = afi2family (afi); |
| 12054 | |
| 12055 | if (safi == SAFI_MPLS_VPN) |
| 12056 | { |
| 12057 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 12058 | { |
| 12059 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 12060 | continue; |
| 12061 | |
| 12062 | if ((table = rn->info) != NULL) |
| 12063 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12064 | { |
| 12065 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 12066 | { |
| 12067 | ri = rm->info; |
| 12068 | while (ri) |
| 12069 | { |
| 12070 | if (ri->extra && ri->extra->damp_info) |
| 12071 | { |
| 12072 | ri_temp = ri->next; |
| 12073 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12074 | ri = ri_temp; |
| 12075 | } |
| 12076 | else |
| 12077 | ri = ri->next; |
| 12078 | } |
| 12079 | } |
| 12080 | |
| 12081 | bgp_unlock_node (rm); |
| 12082 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12083 | } |
| 12084 | } |
| 12085 | else |
| 12086 | { |
| 12087 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12088 | { |
| 12089 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 12090 | { |
| 12091 | ri = rn->info; |
| 12092 | while (ri) |
| 12093 | { |
| 12094 | if (ri->extra && ri->extra->damp_info) |
| 12095 | { |
| 12096 | ri_temp = ri->next; |
| 12097 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12098 | ri = ri_temp; |
| 12099 | } |
| 12100 | else |
| 12101 | ri = ri->next; |
| 12102 | } |
| 12103 | } |
| 12104 | |
| 12105 | bgp_unlock_node (rn); |
| 12106 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12107 | } |
| 12108 | |
| 12109 | return CMD_SUCCESS; |
| 12110 | } |
| 12111 | |
| 12112 | DEFUN (clear_ip_bgp_dampening, |
| 12113 | clear_ip_bgp_dampening_cmd, |
| 12114 | "clear ip bgp dampening", |
| 12115 | CLEAR_STR |
| 12116 | IP_STR |
| 12117 | BGP_STR |
| 12118 | "Clear route flap dampening information\n") |
| 12119 | { |
| 12120 | bgp_damp_info_clean (); |
| 12121 | return CMD_SUCCESS; |
| 12122 | } |
| 12123 | |
| 12124 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 12125 | clear_ip_bgp_dampening_prefix_cmd, |
| 12126 | "clear ip bgp dampening A.B.C.D/M", |
| 12127 | CLEAR_STR |
| 12128 | IP_STR |
| 12129 | BGP_STR |
| 12130 | "Clear route flap dampening information\n" |
| 12131 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 12132 | { |
| 12133 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12134 | SAFI_UNICAST, NULL, 1); |
| 12135 | } |
| 12136 | |
| 12137 | DEFUN (clear_ip_bgp_dampening_address, |
| 12138 | clear_ip_bgp_dampening_address_cmd, |
| 12139 | "clear ip bgp dampening A.B.C.D", |
| 12140 | CLEAR_STR |
| 12141 | IP_STR |
| 12142 | BGP_STR |
| 12143 | "Clear route flap dampening information\n" |
| 12144 | "Network to clear damping information\n") |
| 12145 | { |
| 12146 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12147 | SAFI_UNICAST, NULL, 0); |
| 12148 | } |
| 12149 | |
| 12150 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 12151 | clear_ip_bgp_dampening_address_mask_cmd, |
| 12152 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 12153 | CLEAR_STR |
| 12154 | IP_STR |
| 12155 | BGP_STR |
| 12156 | "Clear route flap dampening information\n" |
| 12157 | "Network to clear damping information\n" |
| 12158 | "Network mask\n") |
| 12159 | { |
| 12160 | int ret; |
| 12161 | char prefix_str[BUFSIZ]; |
| 12162 | |
| 12163 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 12164 | if (! ret) |
| 12165 | { |
| 12166 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 12167 | return CMD_WARNING; |
| 12168 | } |
| 12169 | |
| 12170 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 12171 | SAFI_UNICAST, NULL, 0); |
| 12172 | } |
| 12173 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12174 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12175 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 12176 | afi_t afi, safi_t safi, int *write) |
| 12177 | { |
| 12178 | struct bgp_node *prn; |
| 12179 | struct bgp_node *rn; |
| 12180 | struct bgp_table *table; |
| 12181 | struct prefix *p; |
| 12182 | struct prefix_rd *prd; |
| 12183 | struct bgp_static *bgp_static; |
| 12184 | u_int32_t label; |
| 12185 | char buf[SU_ADDRSTRLEN]; |
| 12186 | char rdbuf[RD_ADDRSTRLEN]; |
| 12187 | |
| 12188 | /* Network configuration. */ |
| 12189 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 12190 | if ((table = prn->info) != NULL) |
| 12191 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12192 | if ((bgp_static = rn->info) != NULL) |
| 12193 | { |
| 12194 | p = &rn->p; |
| 12195 | prd = (struct prefix_rd *) &prn->p; |
| 12196 | |
| 12197 | /* "address-family" display. */ |
| 12198 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12199 | |
| 12200 | /* "network" configuration display. */ |
| 12201 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 12202 | label = decode_label (bgp_static->tag); |
| 12203 | |
| 12204 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 12205 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12206 | p->prefixlen, |
| 12207 | rdbuf, label); |
| 12208 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12209 | } |
| 12210 | return 0; |
| 12211 | } |
| 12212 | |
| 12213 | /* Configuration of static route announcement and aggregate |
| 12214 | information. */ |
| 12215 | int |
| 12216 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 12217 | afi_t afi, safi_t safi, int *write) |
| 12218 | { |
| 12219 | struct bgp_node *rn; |
| 12220 | struct prefix *p; |
| 12221 | struct bgp_static *bgp_static; |
| 12222 | struct bgp_aggregate *bgp_aggregate; |
| 12223 | char buf[SU_ADDRSTRLEN]; |
| 12224 | |
| 12225 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 12226 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 12227 | |
| 12228 | /* Network configuration. */ |
| 12229 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12230 | if ((bgp_static = rn->info) != NULL) |
| 12231 | { |
| 12232 | p = &rn->p; |
| 12233 | |
| 12234 | /* "address-family" display. */ |
| 12235 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12236 | |
| 12237 | /* "network" configuration display. */ |
| 12238 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12239 | { |
| 12240 | u_int32_t destination; |
| 12241 | struct in_addr netmask; |
| 12242 | |
| 12243 | destination = ntohl (p->u.prefix4.s_addr); |
| 12244 | masklen2ip (p->prefixlen, &netmask); |
| 12245 | vty_out (vty, " network %s", |
| 12246 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 12247 | |
| 12248 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 12249 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 12250 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 12251 | || p->u.prefix4.s_addr == 0) |
| 12252 | { |
| 12253 | /* Natural mask is not display. */ |
| 12254 | } |
| 12255 | else |
| 12256 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 12257 | } |
| 12258 | else |
| 12259 | { |
| 12260 | vty_out (vty, " network %s/%d", |
| 12261 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12262 | p->prefixlen); |
| 12263 | } |
| 12264 | |
| 12265 | if (bgp_static->rmap.name) |
| 12266 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12267 | else |
| 12268 | { |
| 12269 | if (bgp_static->backdoor) |
| 12270 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12271 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12272 | |
| 12273 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12274 | } |
| 12275 | |
| 12276 | /* Aggregate-address configuration. */ |
| 12277 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12278 | if ((bgp_aggregate = rn->info) != NULL) |
| 12279 | { |
| 12280 | p = &rn->p; |
| 12281 | |
| 12282 | /* "address-family" display. */ |
| 12283 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12284 | |
| 12285 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12286 | { |
| 12287 | struct in_addr netmask; |
| 12288 | |
| 12289 | masklen2ip (p->prefixlen, &netmask); |
| 12290 | vty_out (vty, " aggregate-address %s %s", |
| 12291 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12292 | inet_ntoa (netmask)); |
| 12293 | } |
| 12294 | else |
| 12295 | { |
| 12296 | vty_out (vty, " aggregate-address %s/%d", |
| 12297 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12298 | p->prefixlen); |
| 12299 | } |
| 12300 | |
| 12301 | if (bgp_aggregate->as_set) |
| 12302 | vty_out (vty, " as-set"); |
| 12303 | |
| 12304 | if (bgp_aggregate->summary_only) |
| 12305 | vty_out (vty, " summary-only"); |
| 12306 | |
| 12307 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12308 | } |
| 12309 | |
| 12310 | return 0; |
| 12311 | } |
| 12312 | |
| 12313 | int |
| 12314 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 12315 | { |
| 12316 | struct bgp_node *rn; |
| 12317 | struct bgp_distance *bdistance; |
| 12318 | |
| 12319 | /* Distance configuration. */ |
| 12320 | if (bgp->distance_ebgp |
| 12321 | && bgp->distance_ibgp |
| 12322 | && bgp->distance_local |
| 12323 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 12324 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 12325 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 12326 | vty_out (vty, " distance bgp %d %d %d%s", |
| 12327 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 12328 | VTY_NEWLINE); |
| 12329 | |
| 12330 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 12331 | if ((bdistance = rn->info) != NULL) |
| 12332 | { |
| 12333 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 12334 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 12335 | bdistance->access_list ? bdistance->access_list : "", |
| 12336 | VTY_NEWLINE); |
| 12337 | } |
| 12338 | |
| 12339 | return 0; |
| 12340 | } |
| 12341 | |
| 12342 | /* Allocate routing table structure and install commands. */ |
| 12343 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 12344 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12345 | { |
| 12346 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 12347 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12348 | |
| 12349 | /* IPv4 BGP commands. */ |
| 12350 | install_element (BGP_NODE, &bgp_network_cmd); |
| 12351 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 12352 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 12353 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 12354 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 12355 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12356 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 12357 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 12358 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 12359 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 12360 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 12361 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 12362 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 12363 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12364 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12365 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 12366 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 12367 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 12368 | |
| 12369 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 12370 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 12371 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 12372 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12373 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 12374 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 12375 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 12376 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12377 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 12378 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12379 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 12380 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 12381 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 12382 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12383 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12384 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 12385 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12386 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12387 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12388 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12389 | |
| 12390 | /* IPv4 unicast configuration. */ |
| 12391 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 12392 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 12393 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 12394 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 12395 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 12396 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 12397 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12398 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 12399 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 12400 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 12401 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12402 | 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] | 12403 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12404 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 12405 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 12406 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 12407 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12408 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 12409 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 12410 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 12411 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12412 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 12413 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12414 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 12415 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 12416 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 12417 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12418 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12419 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 12420 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12421 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12422 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12423 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12424 | |
| 12425 | /* IPv4 multicast configuration. */ |
| 12426 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 12427 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 12428 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 12429 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 12430 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 12431 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12432 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 12433 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 12434 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 12435 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 12436 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12437 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12438 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 12439 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 12440 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 12441 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12442 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 12443 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 12444 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 12445 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12446 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 12447 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12448 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 12449 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 12450 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 12451 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12452 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12453 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 12454 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12455 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12456 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12457 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12458 | |
| 12459 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 12460 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12461 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12462 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 12463 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12464 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12465 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12466 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12467 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 12468 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12469 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12470 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12471 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12472 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 12473 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 12474 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12475 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 12476 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12477 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12478 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12479 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 12480 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12481 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 12482 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12483 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12484 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12485 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 12486 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12487 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 12488 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 12489 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 12490 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 12491 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12492 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12493 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12494 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12495 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12496 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12497 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12498 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12499 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12500 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 12501 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12502 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12503 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12504 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12505 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12506 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12507 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12508 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 12509 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12510 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12511 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12512 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12513 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12514 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12515 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12516 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12517 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12518 | 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] | 12519 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12520 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12521 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12522 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 12523 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 12524 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 12525 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 12526 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12527 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 12528 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12529 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 12530 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 12531 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 12532 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 12533 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12534 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12535 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12536 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12537 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12538 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12539 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12540 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12541 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12542 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12543 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12544 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12545 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12546 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12547 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12548 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12549 | |
| 12550 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
| 12551 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
| 12552 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12553 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12554 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12555 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 12556 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12557 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12558 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12559 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12560 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 12561 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12562 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 12563 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 12564 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 12565 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 12566 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12567 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12568 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12569 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12570 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12571 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12572 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12573 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12574 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12575 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 12576 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12577 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12578 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12579 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12580 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12581 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12582 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12583 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12584 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12585 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12586 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12587 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12588 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12589 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12590 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12591 | |
| 12592 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 12593 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12594 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12595 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 12596 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12597 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12598 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12599 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12600 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 12601 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12602 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12603 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12604 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12605 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 12606 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 12607 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12608 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 12609 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12610 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12611 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12612 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 12613 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12614 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 12615 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12616 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12617 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12618 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 12619 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12620 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 12621 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 12622 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 12623 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 12624 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12625 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12626 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12627 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12628 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12629 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12630 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12631 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12632 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12633 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 12634 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12635 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12636 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12637 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12638 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12639 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12640 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12641 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 12642 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12643 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12644 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12645 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12646 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12647 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12648 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12649 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12650 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12651 | 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] | 12652 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12653 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12654 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12655 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 12656 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 12657 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 12658 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 12659 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12660 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 12661 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12662 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 12663 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 12664 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 12665 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 12666 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12667 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12668 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12669 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12670 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12671 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12672 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12673 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12674 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12675 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12676 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12677 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12678 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12679 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12680 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12681 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12682 | |
| 12683 | /* BGP dampening clear commands */ |
| 12684 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 12685 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 12686 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 12687 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 12688 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12689 | /* prefix count */ |
| 12690 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 12691 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 12692 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12693 | #ifdef HAVE_IPV6 |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12694 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 12695 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12696 | /* New config IPv6 BGP commands. */ |
| 12697 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 12698 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 12699 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 12700 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 12701 | |
| 12702 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 12703 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 12704 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 12705 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 12706 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 12707 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 12708 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 12709 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12710 | /* Old config IPv6 BGP commands. */ |
| 12711 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 12712 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 12713 | |
| 12714 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 12715 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 12716 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 12717 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 12718 | |
| 12719 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 12720 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12721 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12722 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 12723 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12724 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12725 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 12726 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12727 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12728 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 12729 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12730 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 12731 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12732 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 12733 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12734 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 12735 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12736 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 12737 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12738 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 12739 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 12740 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 12741 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 12742 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 12743 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 12744 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 12745 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 12746 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 12747 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12748 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 12749 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12750 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 12751 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12752 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 12753 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12754 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 12755 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12756 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 12757 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12758 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 12759 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12760 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12761 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12762 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12763 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12764 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 12765 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12766 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12767 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12768 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 12769 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12770 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 12771 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12772 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12773 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12774 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12775 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12776 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12777 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12778 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 12779 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 12780 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 12781 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12782 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 12783 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12784 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12785 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12786 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12787 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12788 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12789 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12790 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12791 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12792 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12793 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12794 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12795 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12796 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12797 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12798 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12799 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12800 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12801 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12802 | |
| 12803 | /* Restricted: |
| 12804 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 12805 | */ |
| 12806 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 12807 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12808 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12809 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
| 12810 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12811 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12812 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 12813 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 12814 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 12815 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 12816 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 12817 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 12818 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 12819 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 12820 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 12821 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12822 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 12823 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12824 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 12825 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12826 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 12827 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12828 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12829 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12830 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12831 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12832 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 12833 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12834 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 12835 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12836 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12837 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12838 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12839 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12840 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12841 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12842 | |
| 12843 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 12844 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12845 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12846 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 12847 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12848 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12849 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 12850 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12851 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12852 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 12853 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12854 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 12855 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12856 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 12857 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12858 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 12859 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12860 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 12861 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12862 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 12863 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 12864 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 12865 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 12866 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 12867 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 12868 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 12869 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 12870 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 12871 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12872 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 12873 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12874 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 12875 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12876 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 12877 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12878 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 12879 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12880 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 12881 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12882 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 12883 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12884 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12885 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12886 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12887 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12888 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 12889 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12890 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12891 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12892 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 12893 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12894 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 12895 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12896 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12897 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12898 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12899 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12900 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12901 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12902 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 12903 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 12904 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 12905 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12906 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 12907 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12908 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12909 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12910 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12911 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12912 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12913 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12914 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12915 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12916 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12917 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12918 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12919 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12920 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12921 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12922 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12923 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12924 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12925 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12926 | |
| 12927 | /* Statistics */ |
| 12928 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
| 12929 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 12930 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
| 12931 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
| 12932 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12933 | /* old command */ |
| 12934 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 12935 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 12936 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 12937 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 12938 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 12939 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 12940 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 12941 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 12942 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 12943 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 12944 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 12945 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 12946 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 12947 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 12948 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 12949 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 12950 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 12951 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 12952 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 12953 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 12954 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 12955 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 12956 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 12957 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 12958 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 12959 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 12960 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 12961 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 12962 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 12963 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 12964 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 12965 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 12966 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 12967 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 12968 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 12969 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12970 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12971 | /* old command */ |
| 12972 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 12973 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 12974 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 12975 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 12976 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 12977 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 12978 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 12979 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 12980 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 12981 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 12982 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 12983 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 12984 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 12985 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 12986 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 12987 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 12988 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 12989 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 12990 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 12991 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 12992 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 12993 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 12994 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 12995 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 12996 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 12997 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 12998 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 12999 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 13000 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 13001 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 13002 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 13003 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 13004 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 13005 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 13006 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 13007 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 13008 | |
| 13009 | /* old command */ |
| 13010 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13011 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13012 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13013 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13014 | |
| 13015 | /* old command */ |
| 13016 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13017 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13018 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13019 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13020 | |
| 13021 | /* old command */ |
| 13022 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13023 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13024 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13025 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13026 | #endif /* HAVE_IPV6 */ |
| 13027 | |
| 13028 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 13029 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 13030 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 13031 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 13032 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 13033 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 13034 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 13035 | |
| 13036 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 13037 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 13038 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 13039 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 13040 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 13041 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 13042 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 13043 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 13044 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 13045 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13046 | |
| 13047 | /* Deprecated AS-Pathlimit commands */ |
| 13048 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 13049 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 13050 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13051 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13052 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13053 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13054 | |
| 13055 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 13056 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13057 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13058 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13059 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13060 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13061 | |
| 13062 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 13063 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 13064 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13065 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13066 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13067 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13068 | |
| 13069 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 13070 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13071 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13072 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13073 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13074 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13075 | |
| 13076 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 13077 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 13078 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13079 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13080 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13081 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13082 | |
| 13083 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 13084 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13085 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13086 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13087 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13088 | 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] | 13089 | |
| 13090 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13091 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 13092 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 13093 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13094 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 13095 | |
| 13096 | void |
| 13097 | bgp_route_finish (void) |
| 13098 | { |
| 13099 | bgp_table_unlock (bgp_distance_table); |
| 13100 | bgp_distance_table = NULL; |
| 13101 | } |