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; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2813 | |
| 2814 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2815 | * queued for every clearing peer, regardless of whether it is |
| 2816 | * relevant to the peer at hand. |
| 2817 | * |
| 2818 | * Overview: There are 3 different indices which need to be |
| 2819 | * scrubbed, potentially, when a peer is removed: |
| 2820 | * |
| 2821 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2822 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2823 | * 3 other routes visible by the peer's adj-out index |
| 2824 | * |
| 2825 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2826 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2827 | * adj-outs at our leisure. |
| 2828 | * |
| 2829 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2830 | * invisible via RIB index before peer session is allowed to be |
| 2831 | * brought back up. So one needs to know when such a 'search' is |
| 2832 | * complete. |
| 2833 | * |
| 2834 | * Ideally: |
| 2835 | * |
| 2836 | * - there'd be a single global queue or a single RIB walker |
| 2837 | * - rather than tracking which route_nodes still need to be |
| 2838 | * examined on a peer basis, we'd track which peers still |
| 2839 | * aren't cleared |
| 2840 | * |
| 2841 | * Given that our per-peer prefix-counts now should be reliable, |
| 2842 | * this may actually be achievable. It doesn't seem to be a huge |
| 2843 | * problem at this time, |
| 2844 | */ |
| 2845 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2846 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2847 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2848 | struct bgp_clear_node_queue *cnq; |
| 2849 | |
| 2850 | /* both unlocked in bgp_clear_node_queue_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2851 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2852 | bgp_lock_node (rn); |
| 2853 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2854 | sizeof (struct bgp_clear_node_queue)); |
| 2855 | cnq->rn = rn; |
| 2856 | cnq->purpose = purpose; |
| 2857 | work_queue_add (peer->clear_node_queue, cnq); |
| 2858 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2859 | } |
| 2860 | |
| 2861 | for (ain = rn->adj_in; ain; ain = ain->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2862 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2863 | { |
| 2864 | bgp_adj_in_remove (rn, ain); |
| 2865 | bgp_unlock_node (rn); |
| 2866 | break; |
| 2867 | } |
| 2868 | for (aout = rn->adj_out; aout; aout = aout->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2869 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2870 | { |
| 2871 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2872 | bgp_unlock_node (rn); |
| 2873 | break; |
| 2874 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2875 | } |
| 2876 | return; |
| 2877 | } |
| 2878 | |
| 2879 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2880 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2881 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2882 | { |
| 2883 | struct bgp_node *rn; |
| 2884 | struct bgp_table *table; |
| 2885 | struct peer *rsclient; |
| 2886 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2887 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2888 | if (peer->clear_node_queue == NULL) |
| 2889 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2890 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2891 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 2892 | * Idle until it receives a Clearing_Completed event. This protects |
| 2893 | * against peers which flap faster than we can we clear, which could |
| 2894 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2895 | * |
| 2896 | * a) race with routes from the new session being installed before |
| 2897 | * clear_route_node visits the node (to delete the route of that |
| 2898 | * peer) |
| 2899 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 2900 | * on the process_main queue. Fast-flapping could cause that queue |
| 2901 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2902 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2903 | if (!peer->clear_node_queue->thread) |
| 2904 | peer_lock (peer); /* bgp_clear_node_complete */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2905 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2906 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2907 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2908 | case BGP_CLEAR_ROUTE_NORMAL: |
| 2909 | if (safi != SAFI_MPLS_VPN) |
| 2910 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 2911 | else |
| 2912 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2913 | rn = bgp_route_next (rn)) |
| 2914 | if ((table = rn->info) != NULL) |
| 2915 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 2916 | |
| 2917 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 2918 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 2919 | PEER_FLAG_RSERVER_CLIENT)) |
| 2920 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 2921 | break; |
| 2922 | |
| 2923 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
| 2924 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 2925 | break; |
| 2926 | |
| 2927 | default: |
| 2928 | assert (0); |
| 2929 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2930 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2931 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2932 | /* If no routes were cleared, nothing was added to workqueue, the |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2933 | * completion function won't be run by workqueue code - call it here. |
| 2934 | * XXX: Actually, this assumption doesn't hold, see |
| 2935 | * bgp_clear_route_table(), we queue all non-empty nodes. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2936 | * |
| 2937 | * Additionally, there is a presumption in FSM that clearing is only |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2938 | * really needed if peer state is Established - peers in |
| 2939 | * pre-Established states shouldn't have any route-update state |
| 2940 | * associated with them (in or out). |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2941 | * |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2942 | * We still can get here in pre-Established though, through |
| 2943 | * peer_delete -> bgp_fsm_change_status, so this is a useful sanity |
| 2944 | * check to ensure the assumption above holds. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2945 | * |
| 2946 | * At some future point, this check could be move to the top of the |
| 2947 | * function, and do a quick early-return when state is |
| 2948 | * pre-Established, avoiding above list and table scans. Once we're |
| 2949 | * sure it is safe.. |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2950 | */ |
| 2951 | if (!peer->clear_node_queue->thread) |
| 2952 | bgp_clear_node_complete (peer->clear_node_queue); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2953 | } |
| 2954 | |
| 2955 | void |
| 2956 | bgp_clear_route_all (struct peer *peer) |
| 2957 | { |
| 2958 | afi_t afi; |
| 2959 | safi_t safi; |
| 2960 | |
| 2961 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2962 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2963 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2964 | } |
| 2965 | |
| 2966 | void |
| 2967 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2968 | { |
| 2969 | struct bgp_table *table; |
| 2970 | struct bgp_node *rn; |
| 2971 | struct bgp_adj_in *ain; |
| 2972 | |
| 2973 | table = peer->bgp->rib[afi][safi]; |
| 2974 | |
| 2975 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2976 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 2977 | if (ain->peer == peer) |
| 2978 | { |
| 2979 | bgp_adj_in_remove (rn, ain); |
| 2980 | bgp_unlock_node (rn); |
| 2981 | break; |
| 2982 | } |
| 2983 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2984 | |
| 2985 | void |
| 2986 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2987 | { |
| 2988 | struct bgp_node *rn; |
| 2989 | struct bgp_info *ri; |
| 2990 | struct bgp_table *table; |
| 2991 | |
| 2992 | table = peer->bgp->rib[afi][safi]; |
| 2993 | |
| 2994 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2995 | { |
| 2996 | for (ri = rn->info; ri; ri = ri->next) |
| 2997 | if (ri->peer == peer) |
| 2998 | { |
| 2999 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 3000 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3001 | break; |
| 3002 | } |
| 3003 | } |
| 3004 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3005 | |
| 3006 | /* Delete all kernel routes. */ |
| 3007 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3008 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3009 | { |
| 3010 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3011 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3012 | struct bgp_node *rn; |
| 3013 | struct bgp_table *table; |
| 3014 | struct bgp_info *ri; |
| 3015 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3016 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3017 | { |
| 3018 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 3019 | |
| 3020 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3021 | for (ri = rn->info; ri; ri = ri->next) |
| 3022 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3023 | && ri->type == ZEBRA_ROUTE_BGP |
| 3024 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3025 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3026 | |
| 3027 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 3028 | |
| 3029 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3030 | for (ri = rn->info; ri; ri = ri->next) |
| 3031 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3032 | && ri->type == ZEBRA_ROUTE_BGP |
| 3033 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3034 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3035 | } |
| 3036 | } |
| 3037 | |
| 3038 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3039 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3040 | { |
| 3041 | vty_reset (); |
| 3042 | bgp_zclient_reset (); |
| 3043 | access_list_reset (); |
| 3044 | prefix_list_reset (); |
| 3045 | } |
| 3046 | |
| 3047 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3048 | value. */ |
| 3049 | int |
| 3050 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 3051 | { |
| 3052 | u_char *pnt; |
| 3053 | u_char *lim; |
| 3054 | struct prefix p; |
| 3055 | int psize; |
| 3056 | int ret; |
| 3057 | |
| 3058 | /* Check peer status. */ |
| 3059 | if (peer->status != Established) |
| 3060 | return 0; |
| 3061 | |
| 3062 | pnt = packet->nlri; |
| 3063 | lim = pnt + packet->length; |
| 3064 | |
| 3065 | for (; pnt < lim; pnt += psize) |
| 3066 | { |
| 3067 | /* Clear prefix structure. */ |
| 3068 | memset (&p, 0, sizeof (struct prefix)); |
| 3069 | |
| 3070 | /* Fetch prefix length. */ |
| 3071 | p.prefixlen = *pnt++; |
| 3072 | p.family = afi2family (packet->afi); |
| 3073 | |
| 3074 | /* Already checked in nlri_sanity_check(). We do double check |
| 3075 | here. */ |
| 3076 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 3077 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 3078 | return -1; |
| 3079 | |
| 3080 | /* Packet size overflow check. */ |
| 3081 | psize = PSIZE (p.prefixlen); |
| 3082 | |
| 3083 | /* When packet overflow occur return immediately. */ |
| 3084 | if (pnt + psize > lim) |
| 3085 | return -1; |
| 3086 | |
| 3087 | /* Fetch prefix from NLRI packet. */ |
| 3088 | memcpy (&p.u.prefix, pnt, psize); |
| 3089 | |
| 3090 | /* Check address. */ |
| 3091 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3092 | { |
| 3093 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3094 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3095 | /* |
| 3096 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 3097 | * If a BGP router receives an UPDATE message with a |
| 3098 | * semantically incorrect NLRI field, in which a prefix is |
| 3099 | * semantically incorrect (eg. an unexpected multicast IP |
| 3100 | * address), it should ignore the prefix. |
| 3101 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3102 | zlog (peer->log, LOG_ERR, |
| 3103 | "IPv4 unicast NLRI is multicast address %s", |
| 3104 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3105 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3106 | return -1; |
| 3107 | } |
| 3108 | } |
| 3109 | |
| 3110 | #ifdef HAVE_IPV6 |
| 3111 | /* Check address. */ |
| 3112 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3113 | { |
| 3114 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3115 | { |
| 3116 | char buf[BUFSIZ]; |
| 3117 | |
| 3118 | zlog (peer->log, LOG_WARNING, |
| 3119 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 3120 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3121 | |
| 3122 | continue; |
| 3123 | } |
| 3124 | } |
| 3125 | #endif /* HAVE_IPV6 */ |
| 3126 | |
| 3127 | /* Normal process. */ |
| 3128 | if (attr) |
| 3129 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3130 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3131 | else |
| 3132 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3133 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3134 | |
| 3135 | /* Address family configuration mismatch or maximum-prefix count |
| 3136 | overflow. */ |
| 3137 | if (ret < 0) |
| 3138 | return -1; |
| 3139 | } |
| 3140 | |
| 3141 | /* Packet length consistency check. */ |
| 3142 | if (pnt != lim) |
| 3143 | return -1; |
| 3144 | |
| 3145 | return 0; |
| 3146 | } |
| 3147 | |
| 3148 | /* NLRI encode syntax check routine. */ |
| 3149 | int |
| 3150 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 3151 | bgp_size_t length) |
| 3152 | { |
| 3153 | u_char *end; |
| 3154 | u_char prefixlen; |
| 3155 | int psize; |
| 3156 | |
| 3157 | end = pnt + length; |
| 3158 | |
| 3159 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 3160 | syntactic validity. If the field is syntactically incorrect, |
| 3161 | then the Error Subcode is set to Invalid Network Field. */ |
| 3162 | |
| 3163 | while (pnt < end) |
| 3164 | { |
| 3165 | prefixlen = *pnt++; |
| 3166 | |
| 3167 | /* Prefix length check. */ |
| 3168 | if ((afi == AFI_IP && prefixlen > 32) |
| 3169 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 3170 | { |
| 3171 | plog_err (peer->log, |
| 3172 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 3173 | peer->host, prefixlen); |
| 3174 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3175 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3176 | return -1; |
| 3177 | } |
| 3178 | |
| 3179 | /* Packet size overflow check. */ |
| 3180 | psize = PSIZE (prefixlen); |
| 3181 | |
| 3182 | if (pnt + psize > end) |
| 3183 | { |
| 3184 | plog_err (peer->log, |
| 3185 | "%s [Error] Update packet error" |
| 3186 | " (prefix data overflow prefix size is %d)", |
| 3187 | peer->host, psize); |
| 3188 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3189 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3190 | return -1; |
| 3191 | } |
| 3192 | |
| 3193 | pnt += psize; |
| 3194 | } |
| 3195 | |
| 3196 | /* Packet length consistency check. */ |
| 3197 | if (pnt != end) |
| 3198 | { |
| 3199 | plog_err (peer->log, |
| 3200 | "%s [Error] Update packet error" |
| 3201 | " (prefix length mismatch with total length)", |
| 3202 | peer->host); |
| 3203 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3204 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3205 | return -1; |
| 3206 | } |
| 3207 | return 0; |
| 3208 | } |
| 3209 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3210 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3211 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3212 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3213 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3214 | } |
| 3215 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3216 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3217 | bgp_static_free (struct bgp_static *bgp_static) |
| 3218 | { |
| 3219 | if (bgp_static->rmap.name) |
| 3220 | free (bgp_static->rmap.name); |
| 3221 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3222 | } |
| 3223 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3224 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3225 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3226 | struct prefix *p, afi_t afi, safi_t safi) |
| 3227 | { |
| 3228 | struct bgp_node *rn; |
| 3229 | struct bgp_info *ri; |
| 3230 | |
| 3231 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3232 | |
| 3233 | /* Check selected route and self inserted route. */ |
| 3234 | for (ri = rn->info; ri; ri = ri->next) |
| 3235 | if (ri->peer == bgp->peer_self |
| 3236 | && ri->type == ZEBRA_ROUTE_BGP |
| 3237 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3238 | break; |
| 3239 | |
| 3240 | /* Withdraw static BGP route from routing table. */ |
| 3241 | if (ri) |
| 3242 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3243 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3244 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3245 | } |
| 3246 | |
| 3247 | /* Unlock bgp_node_lookup. */ |
| 3248 | bgp_unlock_node (rn); |
| 3249 | } |
| 3250 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3251 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3252 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3253 | struct bgp_static *bgp_static, |
| 3254 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3255 | { |
| 3256 | struct bgp_node *rn; |
| 3257 | struct bgp_info *ri; |
| 3258 | struct bgp_info *new; |
| 3259 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3260 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3261 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3262 | struct attr new_attr; |
| 3263 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3264 | struct bgp *bgp; |
| 3265 | int ret; |
| 3266 | char buf[SU_ADDRSTRLEN]; |
| 3267 | |
| 3268 | bgp = rsclient->bgp; |
| 3269 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3270 | assert (bgp_static); |
| 3271 | if (!bgp_static) |
| 3272 | return; |
| 3273 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3274 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3275 | |
| 3276 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3277 | |
| 3278 | attr.nexthop = bgp_static->igpnexthop; |
| 3279 | attr.med = bgp_static->igpmetric; |
| 3280 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3281 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3282 | if (bgp_static->atomic) |
| 3283 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3284 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3285 | /* Apply network route-map for export to this rsclient. */ |
| 3286 | if (bgp_static->rmap.name) |
| 3287 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3288 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3289 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3290 | info.attr = &attr_tmp; |
| 3291 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3292 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3293 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3294 | |
| 3295 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3296 | |
| 3297 | rsclient->rmap_type = 0; |
| 3298 | |
| 3299 | if (ret == RMAP_DENYMATCH) |
| 3300 | { |
| 3301 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3302 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3303 | |
| 3304 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3305 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3306 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3307 | bgp_attr_extra_free (&attr); |
| 3308 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3309 | return; |
| 3310 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3311 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3312 | } |
| 3313 | else |
| 3314 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3315 | |
| 3316 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3317 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3318 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3319 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3320 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3321 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3322 | == RMAP_DENY) |
| 3323 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3324 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3325 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3326 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3327 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3328 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3329 | p->prefixlen, rsclient->host); |
| 3330 | |
| 3331 | bgp->peer_self->rmap_type = 0; |
| 3332 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3333 | bgp_attr_unintern (&attr_new); |
| 3334 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3335 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3336 | |
| 3337 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3338 | |
| 3339 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3340 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3341 | |
| 3342 | bgp->peer_self->rmap_type = 0; |
| 3343 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3344 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3345 | attr_new = bgp_attr_intern (&new_attr); |
| 3346 | |
| 3347 | for (ri = rn->info; ri; ri = ri->next) |
| 3348 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3349 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3350 | break; |
| 3351 | |
| 3352 | if (ri) |
| 3353 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3354 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3355 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3356 | { |
| 3357 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3358 | bgp_attr_unintern (&attr_new); |
| 3359 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3360 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3361 | return; |
| 3362 | } |
| 3363 | else |
| 3364 | { |
| 3365 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3366 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3367 | |
| 3368 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3369 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3370 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3371 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3372 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3373 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3374 | |
| 3375 | /* Process change. */ |
| 3376 | bgp_process (bgp, rn, afi, safi); |
| 3377 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3378 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3379 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3380 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3381 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3382 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3383 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3384 | /* Make new BGP info. */ |
| 3385 | new = bgp_info_new (); |
| 3386 | new->type = ZEBRA_ROUTE_BGP; |
| 3387 | new->sub_type = BGP_ROUTE_STATIC; |
| 3388 | new->peer = bgp->peer_self; |
| 3389 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3390 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3391 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3392 | |
| 3393 | /* Register new BGP information. */ |
| 3394 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3395 | |
| 3396 | /* route_node_get lock */ |
| 3397 | bgp_unlock_node (rn); |
| 3398 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3399 | /* Process change. */ |
| 3400 | bgp_process (bgp, rn, afi, safi); |
| 3401 | |
| 3402 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3403 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3404 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3405 | } |
| 3406 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3407 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3408 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3409 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3410 | { |
| 3411 | struct bgp_node *rn; |
| 3412 | struct bgp_info *ri; |
| 3413 | struct bgp_info *new; |
| 3414 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3415 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3416 | struct attr *attr_new; |
| 3417 | int ret; |
| 3418 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3419 | assert (bgp_static); |
| 3420 | if (!bgp_static) |
| 3421 | return; |
| 3422 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3423 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3424 | |
| 3425 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3426 | |
| 3427 | attr.nexthop = bgp_static->igpnexthop; |
| 3428 | attr.med = bgp_static->igpmetric; |
| 3429 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3430 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3431 | if (bgp_static->atomic) |
| 3432 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3433 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3434 | /* Apply route-map. */ |
| 3435 | if (bgp_static->rmap.name) |
| 3436 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3437 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3438 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3439 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3440 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3441 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3442 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3443 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3444 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3445 | bgp->peer_self->rmap_type = 0; |
| 3446 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3447 | if (ret == RMAP_DENYMATCH) |
| 3448 | { |
| 3449 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3450 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3451 | |
| 3452 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3453 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3454 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3455 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3456 | return; |
| 3457 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3458 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3459 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3460 | else |
| 3461 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3462 | |
| 3463 | for (ri = rn->info; ri; ri = ri->next) |
| 3464 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3465 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3466 | break; |
| 3467 | |
| 3468 | if (ri) |
| 3469 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3470 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3471 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3472 | { |
| 3473 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3474 | bgp_attr_unintern (&attr_new); |
| 3475 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3476 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3477 | return; |
| 3478 | } |
| 3479 | else |
| 3480 | { |
| 3481 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3482 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3483 | |
| 3484 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3485 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3486 | bgp_info_restore(rn, ri); |
| 3487 | else |
| 3488 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3489 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3490 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3491 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3492 | |
| 3493 | /* Process change. */ |
| 3494 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3495 | bgp_process (bgp, rn, afi, safi); |
| 3496 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3497 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3498 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3499 | return; |
| 3500 | } |
| 3501 | } |
| 3502 | |
| 3503 | /* Make new BGP info. */ |
| 3504 | new = bgp_info_new (); |
| 3505 | new->type = ZEBRA_ROUTE_BGP; |
| 3506 | new->sub_type = BGP_ROUTE_STATIC; |
| 3507 | new->peer = bgp->peer_self; |
| 3508 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3509 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3510 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3511 | |
| 3512 | /* Aggregate address increment. */ |
| 3513 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3514 | |
| 3515 | /* Register new BGP information. */ |
| 3516 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3517 | |
| 3518 | /* route_node_get lock */ |
| 3519 | bgp_unlock_node (rn); |
| 3520 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3521 | /* Process change. */ |
| 3522 | bgp_process (bgp, rn, afi, safi); |
| 3523 | |
| 3524 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3525 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3526 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3527 | } |
| 3528 | |
| 3529 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3530 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3531 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3532 | { |
| 3533 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3534 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3535 | |
| 3536 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3537 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3538 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3539 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3540 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3541 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3542 | } |
| 3543 | } |
| 3544 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3545 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3546 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3547 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3548 | { |
| 3549 | struct bgp_node *rn; |
| 3550 | struct bgp_info *new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3551 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3552 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3553 | |
| 3554 | /* Make new BGP info. */ |
| 3555 | new = bgp_info_new (); |
| 3556 | new->type = ZEBRA_ROUTE_BGP; |
| 3557 | new->sub_type = BGP_ROUTE_STATIC; |
| 3558 | new->peer = bgp->peer_self; |
| 3559 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 3560 | SET_FLAG (new->flags, BGP_INFO_VALID); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3561 | new->uptime = bgp_clock (); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3562 | new->extra = bgp_info_extra_new(); |
| 3563 | memcpy (new->extra->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3564 | |
| 3565 | /* Aggregate address increment. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3566 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3567 | |
| 3568 | /* Register new BGP information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3569 | bgp_info_add (rn, new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3570 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3571 | /* route_node_get lock */ |
| 3572 | bgp_unlock_node (rn); |
| 3573 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3574 | /* Process change. */ |
| 3575 | bgp_process (bgp, rn, afi, safi); |
| 3576 | } |
| 3577 | |
| 3578 | void |
| 3579 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3580 | safi_t safi) |
| 3581 | { |
| 3582 | struct bgp_node *rn; |
| 3583 | struct bgp_info *ri; |
| 3584 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3585 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3586 | |
| 3587 | /* Check selected route and self inserted route. */ |
| 3588 | for (ri = rn->info; ri; ri = ri->next) |
| 3589 | if (ri->peer == bgp->peer_self |
| 3590 | && ri->type == ZEBRA_ROUTE_BGP |
| 3591 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3592 | break; |
| 3593 | |
| 3594 | /* Withdraw static BGP route from routing table. */ |
| 3595 | if (ri) |
| 3596 | { |
| 3597 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3598 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3599 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3600 | } |
| 3601 | |
| 3602 | /* Unlock bgp_node_lookup. */ |
| 3603 | bgp_unlock_node (rn); |
| 3604 | } |
| 3605 | |
| 3606 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3607 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3608 | { |
| 3609 | struct bgp_static *bgp_static; |
| 3610 | struct bgp *bgp; |
| 3611 | struct bgp_node *rn; |
| 3612 | struct prefix *p; |
| 3613 | |
| 3614 | bgp = rsclient->bgp; |
| 3615 | |
| 3616 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3617 | if ((bgp_static = rn->info) != NULL) |
| 3618 | { |
| 3619 | p = &rn->p; |
| 3620 | |
| 3621 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3622 | afi, safi); |
| 3623 | } |
| 3624 | } |
| 3625 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3626 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3627 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3628 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3629 | { |
| 3630 | struct bgp_node *rn; |
| 3631 | struct bgp_info *ri; |
| 3632 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3633 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3634 | |
| 3635 | /* Check selected route and self inserted route. */ |
| 3636 | for (ri = rn->info; ri; ri = ri->next) |
| 3637 | if (ri->peer == bgp->peer_self |
| 3638 | && ri->type == ZEBRA_ROUTE_BGP |
| 3639 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3640 | break; |
| 3641 | |
| 3642 | /* Withdraw static BGP route from routing table. */ |
| 3643 | if (ri) |
| 3644 | { |
| 3645 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3646 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3647 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3648 | } |
| 3649 | |
| 3650 | /* Unlock bgp_node_lookup. */ |
| 3651 | bgp_unlock_node (rn); |
| 3652 | } |
| 3653 | |
| 3654 | /* Configure static BGP network. When user don't run zebra, static |
| 3655 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3656 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3657 | 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] | 3658 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3659 | { |
| 3660 | int ret; |
| 3661 | struct prefix p; |
| 3662 | struct bgp_static *bgp_static; |
| 3663 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3664 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3665 | |
| 3666 | /* Convert IP prefix string to struct prefix. */ |
| 3667 | ret = str2prefix (ip_str, &p); |
| 3668 | if (! ret) |
| 3669 | { |
| 3670 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3671 | return CMD_WARNING; |
| 3672 | } |
| 3673 | #ifdef HAVE_IPV6 |
| 3674 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3675 | { |
| 3676 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3677 | VTY_NEWLINE); |
| 3678 | return CMD_WARNING; |
| 3679 | } |
| 3680 | #endif /* HAVE_IPV6 */ |
| 3681 | |
| 3682 | apply_mask (&p); |
| 3683 | |
| 3684 | /* Set BGP static route configuration. */ |
| 3685 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3686 | |
| 3687 | if (rn->info) |
| 3688 | { |
| 3689 | /* Configuration change. */ |
| 3690 | bgp_static = rn->info; |
| 3691 | |
| 3692 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3693 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 3694 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3695 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3696 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3697 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3698 | if (rmap) |
| 3699 | { |
| 3700 | if (bgp_static->rmap.name) |
| 3701 | free (bgp_static->rmap.name); |
| 3702 | bgp_static->rmap.name = strdup (rmap); |
| 3703 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3704 | } |
| 3705 | else |
| 3706 | { |
| 3707 | if (bgp_static->rmap.name) |
| 3708 | free (bgp_static->rmap.name); |
| 3709 | bgp_static->rmap.name = NULL; |
| 3710 | bgp_static->rmap.map = NULL; |
| 3711 | bgp_static->valid = 0; |
| 3712 | } |
| 3713 | bgp_unlock_node (rn); |
| 3714 | } |
| 3715 | else |
| 3716 | { |
| 3717 | /* New configuration. */ |
| 3718 | bgp_static = bgp_static_new (); |
| 3719 | bgp_static->backdoor = backdoor; |
| 3720 | bgp_static->valid = 0; |
| 3721 | bgp_static->igpmetric = 0; |
| 3722 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3723 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3724 | if (rmap) |
| 3725 | { |
| 3726 | if (bgp_static->rmap.name) |
| 3727 | free (bgp_static->rmap.name); |
| 3728 | bgp_static->rmap.name = strdup (rmap); |
| 3729 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3730 | } |
| 3731 | rn->info = bgp_static; |
| 3732 | } |
| 3733 | |
| 3734 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3735 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3736 | { |
| 3737 | bgp_static->valid = 1; |
| 3738 | |
| 3739 | if (need_update) |
| 3740 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3741 | |
| 3742 | if (! bgp_static->backdoor) |
| 3743 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3744 | } |
| 3745 | |
| 3746 | return CMD_SUCCESS; |
| 3747 | } |
| 3748 | |
| 3749 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3750 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3751 | 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] | 3752 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3753 | { |
| 3754 | int ret; |
| 3755 | struct prefix p; |
| 3756 | struct bgp_static *bgp_static; |
| 3757 | struct bgp_node *rn; |
| 3758 | |
| 3759 | /* Convert IP prefix string to struct prefix. */ |
| 3760 | ret = str2prefix (ip_str, &p); |
| 3761 | if (! ret) |
| 3762 | { |
| 3763 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3764 | return CMD_WARNING; |
| 3765 | } |
| 3766 | #ifdef HAVE_IPV6 |
| 3767 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3768 | { |
| 3769 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3770 | VTY_NEWLINE); |
| 3771 | return CMD_WARNING; |
| 3772 | } |
| 3773 | #endif /* HAVE_IPV6 */ |
| 3774 | |
| 3775 | apply_mask (&p); |
| 3776 | |
| 3777 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3778 | if (! rn) |
| 3779 | { |
| 3780 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3781 | VTY_NEWLINE); |
| 3782 | return CMD_WARNING; |
| 3783 | } |
| 3784 | |
| 3785 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3786 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3787 | /* Update BGP RIB. */ |
| 3788 | if (! bgp_static->backdoor) |
| 3789 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3790 | |
| 3791 | /* Clear configuration. */ |
| 3792 | bgp_static_free (bgp_static); |
| 3793 | rn->info = NULL; |
| 3794 | bgp_unlock_node (rn); |
| 3795 | bgp_unlock_node (rn); |
| 3796 | |
| 3797 | return CMD_SUCCESS; |
| 3798 | } |
| 3799 | |
| 3800 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3801 | instance. */ |
| 3802 | void |
| 3803 | bgp_static_delete (struct bgp *bgp) |
| 3804 | { |
| 3805 | afi_t afi; |
| 3806 | safi_t safi; |
| 3807 | struct bgp_node *rn; |
| 3808 | struct bgp_node *rm; |
| 3809 | struct bgp_table *table; |
| 3810 | struct bgp_static *bgp_static; |
| 3811 | |
| 3812 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3813 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3814 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3815 | if (rn->info != NULL) |
| 3816 | { |
| 3817 | if (safi == SAFI_MPLS_VPN) |
| 3818 | { |
| 3819 | table = rn->info; |
| 3820 | |
| 3821 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3822 | { |
| 3823 | bgp_static = rn->info; |
| 3824 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3825 | AFI_IP, SAFI_MPLS_VPN, |
| 3826 | (struct prefix_rd *)&rn->p, |
| 3827 | bgp_static->tag); |
| 3828 | bgp_static_free (bgp_static); |
| 3829 | rn->info = NULL; |
| 3830 | bgp_unlock_node (rn); |
| 3831 | } |
| 3832 | } |
| 3833 | else |
| 3834 | { |
| 3835 | bgp_static = rn->info; |
| 3836 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3837 | bgp_static_free (bgp_static); |
| 3838 | rn->info = NULL; |
| 3839 | bgp_unlock_node (rn); |
| 3840 | } |
| 3841 | } |
| 3842 | } |
| 3843 | |
| 3844 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3845 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3846 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3847 | { |
| 3848 | int ret; |
| 3849 | struct prefix p; |
| 3850 | struct prefix_rd prd; |
| 3851 | struct bgp *bgp; |
| 3852 | struct bgp_node *prn; |
| 3853 | struct bgp_node *rn; |
| 3854 | struct bgp_table *table; |
| 3855 | struct bgp_static *bgp_static; |
| 3856 | u_char tag[3]; |
| 3857 | |
| 3858 | bgp = vty->index; |
| 3859 | |
| 3860 | ret = str2prefix (ip_str, &p); |
| 3861 | if (! ret) |
| 3862 | { |
| 3863 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3864 | return CMD_WARNING; |
| 3865 | } |
| 3866 | apply_mask (&p); |
| 3867 | |
| 3868 | ret = str2prefix_rd (rd_str, &prd); |
| 3869 | if (! ret) |
| 3870 | { |
| 3871 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3872 | return CMD_WARNING; |
| 3873 | } |
| 3874 | |
| 3875 | ret = str2tag (tag_str, tag); |
| 3876 | if (! ret) |
| 3877 | { |
| 3878 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3879 | return CMD_WARNING; |
| 3880 | } |
| 3881 | |
| 3882 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3883 | (struct prefix *)&prd); |
| 3884 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3885 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3886 | else |
| 3887 | bgp_unlock_node (prn); |
| 3888 | table = prn->info; |
| 3889 | |
| 3890 | rn = bgp_node_get (table, &p); |
| 3891 | |
| 3892 | if (rn->info) |
| 3893 | { |
| 3894 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3895 | bgp_unlock_node (rn); |
| 3896 | } |
| 3897 | else |
| 3898 | { |
| 3899 | /* New configuration. */ |
| 3900 | bgp_static = bgp_static_new (); |
| 3901 | bgp_static->valid = 1; |
| 3902 | memcpy (bgp_static->tag, tag, 3); |
| 3903 | rn->info = bgp_static; |
| 3904 | |
| 3905 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3906 | } |
| 3907 | |
| 3908 | return CMD_SUCCESS; |
| 3909 | } |
| 3910 | |
| 3911 | /* Configure static BGP network. */ |
| 3912 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3913 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3914 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3915 | { |
| 3916 | int ret; |
| 3917 | struct bgp *bgp; |
| 3918 | struct prefix p; |
| 3919 | struct prefix_rd prd; |
| 3920 | struct bgp_node *prn; |
| 3921 | struct bgp_node *rn; |
| 3922 | struct bgp_table *table; |
| 3923 | struct bgp_static *bgp_static; |
| 3924 | u_char tag[3]; |
| 3925 | |
| 3926 | bgp = vty->index; |
| 3927 | |
| 3928 | /* Convert IP prefix string to struct prefix. */ |
| 3929 | ret = str2prefix (ip_str, &p); |
| 3930 | if (! ret) |
| 3931 | { |
| 3932 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3933 | return CMD_WARNING; |
| 3934 | } |
| 3935 | apply_mask (&p); |
| 3936 | |
| 3937 | ret = str2prefix_rd (rd_str, &prd); |
| 3938 | if (! ret) |
| 3939 | { |
| 3940 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3941 | return CMD_WARNING; |
| 3942 | } |
| 3943 | |
| 3944 | ret = str2tag (tag_str, tag); |
| 3945 | if (! ret) |
| 3946 | { |
| 3947 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3948 | return CMD_WARNING; |
| 3949 | } |
| 3950 | |
| 3951 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3952 | (struct prefix *)&prd); |
| 3953 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3954 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3955 | else |
| 3956 | bgp_unlock_node (prn); |
| 3957 | table = prn->info; |
| 3958 | |
| 3959 | rn = bgp_node_lookup (table, &p); |
| 3960 | |
| 3961 | if (rn) |
| 3962 | { |
| 3963 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3964 | |
| 3965 | bgp_static = rn->info; |
| 3966 | bgp_static_free (bgp_static); |
| 3967 | rn->info = NULL; |
| 3968 | bgp_unlock_node (rn); |
| 3969 | bgp_unlock_node (rn); |
| 3970 | } |
| 3971 | else |
| 3972 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 3973 | |
| 3974 | return CMD_SUCCESS; |
| 3975 | } |
| 3976 | |
| 3977 | DEFUN (bgp_network, |
| 3978 | bgp_network_cmd, |
| 3979 | "network A.B.C.D/M", |
| 3980 | "Specify a network to announce via BGP\n" |
| 3981 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3982 | { |
| 3983 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3984 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3985 | } |
| 3986 | |
| 3987 | DEFUN (bgp_network_route_map, |
| 3988 | bgp_network_route_map_cmd, |
| 3989 | "network A.B.C.D/M route-map WORD", |
| 3990 | "Specify a network to announce via BGP\n" |
| 3991 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3992 | "Route-map to modify the attributes\n" |
| 3993 | "Name of the route map\n") |
| 3994 | { |
| 3995 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3996 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3997 | } |
| 3998 | |
| 3999 | DEFUN (bgp_network_backdoor, |
| 4000 | bgp_network_backdoor_cmd, |
| 4001 | "network A.B.C.D/M backdoor", |
| 4002 | "Specify a network to announce via BGP\n" |
| 4003 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4004 | "Specify a BGP backdoor route\n") |
| 4005 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4006 | 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] | 4007 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4008 | } |
| 4009 | |
| 4010 | DEFUN (bgp_network_mask, |
| 4011 | bgp_network_mask_cmd, |
| 4012 | "network A.B.C.D mask A.B.C.D", |
| 4013 | "Specify a network to announce via BGP\n" |
| 4014 | "Network number\n" |
| 4015 | "Network mask\n" |
| 4016 | "Network mask\n") |
| 4017 | { |
| 4018 | int ret; |
| 4019 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4020 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4021 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4022 | if (! ret) |
| 4023 | { |
| 4024 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4025 | return CMD_WARNING; |
| 4026 | } |
| 4027 | |
| 4028 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4029 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4030 | } |
| 4031 | |
| 4032 | DEFUN (bgp_network_mask_route_map, |
| 4033 | bgp_network_mask_route_map_cmd, |
| 4034 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4035 | "Specify a network to announce via BGP\n" |
| 4036 | "Network number\n" |
| 4037 | "Network mask\n" |
| 4038 | "Network mask\n" |
| 4039 | "Route-map to modify the attributes\n" |
| 4040 | "Name of the route map\n") |
| 4041 | { |
| 4042 | int ret; |
| 4043 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4044 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4045 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4046 | if (! ret) |
| 4047 | { |
| 4048 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4049 | return CMD_WARNING; |
| 4050 | } |
| 4051 | |
| 4052 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4053 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4054 | } |
| 4055 | |
| 4056 | DEFUN (bgp_network_mask_backdoor, |
| 4057 | bgp_network_mask_backdoor_cmd, |
| 4058 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4059 | "Specify a network to announce via BGP\n" |
| 4060 | "Network number\n" |
| 4061 | "Network mask\n" |
| 4062 | "Network mask\n" |
| 4063 | "Specify a BGP backdoor route\n") |
| 4064 | { |
| 4065 | int ret; |
| 4066 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4067 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4068 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4069 | if (! ret) |
| 4070 | { |
| 4071 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4072 | return CMD_WARNING; |
| 4073 | } |
| 4074 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4075 | 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] | 4076 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4077 | } |
| 4078 | |
| 4079 | DEFUN (bgp_network_mask_natural, |
| 4080 | bgp_network_mask_natural_cmd, |
| 4081 | "network A.B.C.D", |
| 4082 | "Specify a network to announce via BGP\n" |
| 4083 | "Network number\n") |
| 4084 | { |
| 4085 | int ret; |
| 4086 | char prefix_str[BUFSIZ]; |
| 4087 | |
| 4088 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4089 | if (! ret) |
| 4090 | { |
| 4091 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4092 | return CMD_WARNING; |
| 4093 | } |
| 4094 | |
| 4095 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4096 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4097 | } |
| 4098 | |
| 4099 | DEFUN (bgp_network_mask_natural_route_map, |
| 4100 | bgp_network_mask_natural_route_map_cmd, |
| 4101 | "network A.B.C.D route-map WORD", |
| 4102 | "Specify a network to announce via BGP\n" |
| 4103 | "Network number\n" |
| 4104 | "Route-map to modify the attributes\n" |
| 4105 | "Name of the route map\n") |
| 4106 | { |
| 4107 | int ret; |
| 4108 | char prefix_str[BUFSIZ]; |
| 4109 | |
| 4110 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4111 | if (! ret) |
| 4112 | { |
| 4113 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4114 | return CMD_WARNING; |
| 4115 | } |
| 4116 | |
| 4117 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4118 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4119 | } |
| 4120 | |
| 4121 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4122 | bgp_network_mask_natural_backdoor_cmd, |
| 4123 | "network A.B.C.D backdoor", |
| 4124 | "Specify a network to announce via BGP\n" |
| 4125 | "Network number\n" |
| 4126 | "Specify a BGP backdoor route\n") |
| 4127 | { |
| 4128 | int ret; |
| 4129 | char prefix_str[BUFSIZ]; |
| 4130 | |
| 4131 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4132 | if (! ret) |
| 4133 | { |
| 4134 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4135 | return CMD_WARNING; |
| 4136 | } |
| 4137 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4138 | 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] | 4139 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4140 | } |
| 4141 | |
| 4142 | DEFUN (no_bgp_network, |
| 4143 | no_bgp_network_cmd, |
| 4144 | "no network A.B.C.D/M", |
| 4145 | NO_STR |
| 4146 | "Specify a network to announce via BGP\n" |
| 4147 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4148 | { |
| 4149 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4150 | bgp_node_safi (vty)); |
| 4151 | } |
| 4152 | |
| 4153 | ALIAS (no_bgp_network, |
| 4154 | no_bgp_network_route_map_cmd, |
| 4155 | "no network A.B.C.D/M route-map WORD", |
| 4156 | NO_STR |
| 4157 | "Specify a network to announce via BGP\n" |
| 4158 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4159 | "Route-map to modify the attributes\n" |
| 4160 | "Name of the route map\n") |
| 4161 | |
| 4162 | ALIAS (no_bgp_network, |
| 4163 | no_bgp_network_backdoor_cmd, |
| 4164 | "no network A.B.C.D/M backdoor", |
| 4165 | NO_STR |
| 4166 | "Specify a network to announce via BGP\n" |
| 4167 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4168 | "Specify a BGP backdoor route\n") |
| 4169 | |
| 4170 | DEFUN (no_bgp_network_mask, |
| 4171 | no_bgp_network_mask_cmd, |
| 4172 | "no network A.B.C.D mask A.B.C.D", |
| 4173 | NO_STR |
| 4174 | "Specify a network to announce via BGP\n" |
| 4175 | "Network number\n" |
| 4176 | "Network mask\n" |
| 4177 | "Network mask\n") |
| 4178 | { |
| 4179 | int ret; |
| 4180 | char prefix_str[BUFSIZ]; |
| 4181 | |
| 4182 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4183 | if (! ret) |
| 4184 | { |
| 4185 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4186 | return CMD_WARNING; |
| 4187 | } |
| 4188 | |
| 4189 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4190 | bgp_node_safi (vty)); |
| 4191 | } |
| 4192 | |
| 4193 | ALIAS (no_bgp_network_mask, |
| 4194 | no_bgp_network_mask_route_map_cmd, |
| 4195 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4196 | NO_STR |
| 4197 | "Specify a network to announce via BGP\n" |
| 4198 | "Network number\n" |
| 4199 | "Network mask\n" |
| 4200 | "Network mask\n" |
| 4201 | "Route-map to modify the attributes\n" |
| 4202 | "Name of the route map\n") |
| 4203 | |
| 4204 | ALIAS (no_bgp_network_mask, |
| 4205 | no_bgp_network_mask_backdoor_cmd, |
| 4206 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4207 | NO_STR |
| 4208 | "Specify a network to announce via BGP\n" |
| 4209 | "Network number\n" |
| 4210 | "Network mask\n" |
| 4211 | "Network mask\n" |
| 4212 | "Specify a BGP backdoor route\n") |
| 4213 | |
| 4214 | DEFUN (no_bgp_network_mask_natural, |
| 4215 | no_bgp_network_mask_natural_cmd, |
| 4216 | "no network A.B.C.D", |
| 4217 | NO_STR |
| 4218 | "Specify a network to announce via BGP\n" |
| 4219 | "Network number\n") |
| 4220 | { |
| 4221 | int ret; |
| 4222 | char prefix_str[BUFSIZ]; |
| 4223 | |
| 4224 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4225 | if (! ret) |
| 4226 | { |
| 4227 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4228 | return CMD_WARNING; |
| 4229 | } |
| 4230 | |
| 4231 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4232 | bgp_node_safi (vty)); |
| 4233 | } |
| 4234 | |
| 4235 | ALIAS (no_bgp_network_mask_natural, |
| 4236 | no_bgp_network_mask_natural_route_map_cmd, |
| 4237 | "no network A.B.C.D route-map WORD", |
| 4238 | NO_STR |
| 4239 | "Specify a network to announce via BGP\n" |
| 4240 | "Network number\n" |
| 4241 | "Route-map to modify the attributes\n" |
| 4242 | "Name of the route map\n") |
| 4243 | |
| 4244 | ALIAS (no_bgp_network_mask_natural, |
| 4245 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4246 | "no network A.B.C.D backdoor", |
| 4247 | NO_STR |
| 4248 | "Specify a network to announce via BGP\n" |
| 4249 | "Network number\n" |
| 4250 | "Specify a BGP backdoor route\n") |
| 4251 | |
| 4252 | #ifdef HAVE_IPV6 |
| 4253 | DEFUN (ipv6_bgp_network, |
| 4254 | ipv6_bgp_network_cmd, |
| 4255 | "network X:X::X:X/M", |
| 4256 | "Specify a network to announce via BGP\n" |
| 4257 | "IPv6 prefix <network>/<length>\n") |
| 4258 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4259 | 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] | 4260 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4261 | } |
| 4262 | |
| 4263 | DEFUN (ipv6_bgp_network_route_map, |
| 4264 | ipv6_bgp_network_route_map_cmd, |
| 4265 | "network X:X::X:X/M route-map WORD", |
| 4266 | "Specify a network to announce via BGP\n" |
| 4267 | "IPv6 prefix <network>/<length>\n" |
| 4268 | "Route-map to modify the attributes\n" |
| 4269 | "Name of the route map\n") |
| 4270 | { |
| 4271 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4272 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4273 | } |
| 4274 | |
| 4275 | DEFUN (no_ipv6_bgp_network, |
| 4276 | no_ipv6_bgp_network_cmd, |
| 4277 | "no network X:X::X:X/M", |
| 4278 | NO_STR |
| 4279 | "Specify a network to announce via BGP\n" |
| 4280 | "IPv6 prefix <network>/<length>\n") |
| 4281 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4282 | 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] | 4283 | } |
| 4284 | |
| 4285 | ALIAS (no_ipv6_bgp_network, |
| 4286 | no_ipv6_bgp_network_route_map_cmd, |
| 4287 | "no network X:X::X:X/M route-map WORD", |
| 4288 | NO_STR |
| 4289 | "Specify a network to announce via BGP\n" |
| 4290 | "IPv6 prefix <network>/<length>\n" |
| 4291 | "Route-map to modify the attributes\n" |
| 4292 | "Name of the route map\n") |
| 4293 | |
| 4294 | ALIAS (ipv6_bgp_network, |
| 4295 | old_ipv6_bgp_network_cmd, |
| 4296 | "ipv6 bgp network X:X::X:X/M", |
| 4297 | IPV6_STR |
| 4298 | BGP_STR |
| 4299 | "Specify a network to announce via BGP\n" |
| 4300 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4301 | |
| 4302 | ALIAS (no_ipv6_bgp_network, |
| 4303 | old_no_ipv6_bgp_network_cmd, |
| 4304 | "no ipv6 bgp network X:X::X:X/M", |
| 4305 | NO_STR |
| 4306 | IPV6_STR |
| 4307 | BGP_STR |
| 4308 | "Specify a network to announce via BGP\n" |
| 4309 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4310 | #endif /* HAVE_IPV6 */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4311 | |
| 4312 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4313 | ALIAS_DEPRECATED (bgp_network, |
| 4314 | bgp_network_ttl_cmd, |
| 4315 | "network A.B.C.D/M pathlimit <0-255>", |
| 4316 | "Specify a network to announce via BGP\n" |
| 4317 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4318 | "AS-Path hopcount limit attribute\n" |
| 4319 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4320 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4321 | bgp_network_backdoor_ttl_cmd, |
| 4322 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4323 | "Specify a network to announce via BGP\n" |
| 4324 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4325 | "Specify a BGP backdoor route\n" |
| 4326 | "AS-Path hopcount limit attribute\n" |
| 4327 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4328 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4329 | bgp_network_mask_ttl_cmd, |
| 4330 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4331 | "Specify a network to announce via BGP\n" |
| 4332 | "Network number\n" |
| 4333 | "Network mask\n" |
| 4334 | "Network mask\n" |
| 4335 | "AS-Path hopcount limit attribute\n" |
| 4336 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4337 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4338 | bgp_network_mask_backdoor_ttl_cmd, |
| 4339 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4340 | "Specify a network to announce via BGP\n" |
| 4341 | "Network number\n" |
| 4342 | "Network mask\n" |
| 4343 | "Network mask\n" |
| 4344 | "Specify a BGP backdoor route\n" |
| 4345 | "AS-Path hopcount limit attribute\n" |
| 4346 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4347 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4348 | bgp_network_mask_natural_ttl_cmd, |
| 4349 | "network A.B.C.D pathlimit <0-255>", |
| 4350 | "Specify a network to announce via BGP\n" |
| 4351 | "Network number\n" |
| 4352 | "AS-Path hopcount limit attribute\n" |
| 4353 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4354 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4355 | bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4356 | "network A.B.C.D backdoor pathlimit (1-255>", |
| 4357 | "Specify a network to announce via BGP\n" |
| 4358 | "Network number\n" |
| 4359 | "Specify a BGP backdoor route\n" |
| 4360 | "AS-Path hopcount limit attribute\n" |
| 4361 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4362 | ALIAS_DEPRECATED (no_bgp_network, |
| 4363 | no_bgp_network_ttl_cmd, |
| 4364 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4365 | NO_STR |
| 4366 | "Specify a network to announce via BGP\n" |
| 4367 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4368 | "AS-Path hopcount limit attribute\n" |
| 4369 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4370 | ALIAS_DEPRECATED (no_bgp_network, |
| 4371 | no_bgp_network_backdoor_ttl_cmd, |
| 4372 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4373 | NO_STR |
| 4374 | "Specify a network to announce via BGP\n" |
| 4375 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4376 | "Specify a BGP backdoor route\n" |
| 4377 | "AS-Path hopcount limit attribute\n" |
| 4378 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4379 | ALIAS_DEPRECATED (no_bgp_network, |
| 4380 | no_bgp_network_mask_ttl_cmd, |
| 4381 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4382 | NO_STR |
| 4383 | "Specify a network to announce via BGP\n" |
| 4384 | "Network number\n" |
| 4385 | "Network mask\n" |
| 4386 | "Network mask\n" |
| 4387 | "AS-Path hopcount limit attribute\n" |
| 4388 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4389 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4390 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4391 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4392 | NO_STR |
| 4393 | "Specify a network to announce via BGP\n" |
| 4394 | "Network number\n" |
| 4395 | "Network mask\n" |
| 4396 | "Network mask\n" |
| 4397 | "Specify a BGP backdoor route\n" |
| 4398 | "AS-Path hopcount limit attribute\n" |
| 4399 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4400 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4401 | no_bgp_network_mask_natural_ttl_cmd, |
| 4402 | "no network A.B.C.D pathlimit <0-255>", |
| 4403 | NO_STR |
| 4404 | "Specify a network to announce via BGP\n" |
| 4405 | "Network number\n" |
| 4406 | "AS-Path hopcount limit attribute\n" |
| 4407 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4408 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4409 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4410 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4411 | NO_STR |
| 4412 | "Specify a network to announce via BGP\n" |
| 4413 | "Network number\n" |
| 4414 | "Specify a BGP backdoor route\n" |
| 4415 | "AS-Path hopcount limit attribute\n" |
| 4416 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4417 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4418 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4419 | ipv6_bgp_network_ttl_cmd, |
| 4420 | "network X:X::X:X/M pathlimit <0-255>", |
| 4421 | "Specify a network to announce via BGP\n" |
| 4422 | "IPv6 prefix <network>/<length>\n" |
| 4423 | "AS-Path hopcount limit attribute\n" |
| 4424 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4425 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4426 | no_ipv6_bgp_network_ttl_cmd, |
| 4427 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4428 | NO_STR |
| 4429 | "Specify a network to announce via BGP\n" |
| 4430 | "IPv6 prefix <network>/<length>\n" |
| 4431 | "AS-Path hopcount limit attribute\n" |
| 4432 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4433 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4434 | |
| 4435 | /* Aggreagete address: |
| 4436 | |
| 4437 | advertise-map Set condition to advertise attribute |
| 4438 | as-set Generate AS set path information |
| 4439 | attribute-map Set attributes of aggregate |
| 4440 | route-map Set parameters of aggregate |
| 4441 | summary-only Filter more specific routes from updates |
| 4442 | suppress-map Conditionally filter more specific routes from updates |
| 4443 | <cr> |
| 4444 | */ |
| 4445 | struct bgp_aggregate |
| 4446 | { |
| 4447 | /* Summary-only flag. */ |
| 4448 | u_char summary_only; |
| 4449 | |
| 4450 | /* AS set generation. */ |
| 4451 | u_char as_set; |
| 4452 | |
| 4453 | /* Route-map for aggregated route. */ |
| 4454 | struct route_map *map; |
| 4455 | |
| 4456 | /* Suppress-count. */ |
| 4457 | unsigned long count; |
| 4458 | |
| 4459 | /* SAFI configuration. */ |
| 4460 | safi_t safi; |
| 4461 | }; |
| 4462 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4463 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4464 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4465 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4466 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4467 | } |
| 4468 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4469 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4470 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4471 | { |
| 4472 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4473 | } |
| 4474 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4475 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4476 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4477 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4478 | struct bgp_aggregate *aggregate) |
| 4479 | { |
| 4480 | struct bgp_table *table; |
| 4481 | struct bgp_node *top; |
| 4482 | struct bgp_node *rn; |
| 4483 | u_char origin; |
| 4484 | struct aspath *aspath = NULL; |
| 4485 | struct aspath *asmerge = NULL; |
| 4486 | struct community *community = NULL; |
| 4487 | struct community *commerge = NULL; |
| 4488 | struct in_addr nexthop; |
| 4489 | u_int32_t med = 0; |
| 4490 | struct bgp_info *ri; |
| 4491 | struct bgp_info *new; |
| 4492 | int first = 1; |
| 4493 | unsigned long match = 0; |
| 4494 | |
| 4495 | /* Record adding route's nexthop and med. */ |
| 4496 | if (rinew) |
| 4497 | { |
| 4498 | nexthop = rinew->attr->nexthop; |
| 4499 | med = rinew->attr->med; |
| 4500 | } |
| 4501 | |
| 4502 | /* ORIGIN attribute: If at least one route among routes that are |
| 4503 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4504 | aggregated route must have the ORIGIN attribute with the value |
| 4505 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4506 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4507 | route must have the origin attribute with the value EGP. In all |
| 4508 | other case the value of the ORIGIN attribute of the aggregated |
| 4509 | route is INTERNAL. */ |
| 4510 | origin = BGP_ORIGIN_IGP; |
| 4511 | |
| 4512 | table = bgp->rib[afi][safi]; |
| 4513 | |
| 4514 | top = bgp_node_get (table, p); |
| 4515 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4516 | if (rn->p.prefixlen > p->prefixlen) |
| 4517 | { |
| 4518 | match = 0; |
| 4519 | |
| 4520 | for (ri = rn->info; ri; ri = ri->next) |
| 4521 | { |
| 4522 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4523 | continue; |
| 4524 | |
| 4525 | if (del && ri == del) |
| 4526 | continue; |
| 4527 | |
| 4528 | if (! rinew && first) |
| 4529 | { |
| 4530 | nexthop = ri->attr->nexthop; |
| 4531 | med = ri->attr->med; |
| 4532 | first = 0; |
| 4533 | } |
| 4534 | |
| 4535 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4536 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4537 | || ri->attr->med != med) |
| 4538 | { |
| 4539 | if (aspath) |
| 4540 | aspath_free (aspath); |
| 4541 | if (community) |
| 4542 | community_free (community); |
| 4543 | bgp_unlock_node (rn); |
| 4544 | bgp_unlock_node (top); |
| 4545 | return; |
| 4546 | } |
| 4547 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4548 | |
| 4549 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4550 | { |
| 4551 | if (aggregate->summary_only) |
| 4552 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4553 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4554 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4555 | match++; |
| 4556 | } |
| 4557 | |
| 4558 | aggregate->count++; |
| 4559 | |
| 4560 | if (aggregate->as_set) |
| 4561 | { |
| 4562 | if (origin < ri->attr->origin) |
| 4563 | origin = ri->attr->origin; |
| 4564 | |
| 4565 | if (aspath) |
| 4566 | { |
| 4567 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4568 | aspath_free (aspath); |
| 4569 | aspath = asmerge; |
| 4570 | } |
| 4571 | else |
| 4572 | aspath = aspath_dup (ri->attr->aspath); |
| 4573 | |
| 4574 | if (ri->attr->community) |
| 4575 | { |
| 4576 | if (community) |
| 4577 | { |
| 4578 | commerge = community_merge (community, |
| 4579 | ri->attr->community); |
| 4580 | community = community_uniq_sort (commerge); |
| 4581 | community_free (commerge); |
| 4582 | } |
| 4583 | else |
| 4584 | community = community_dup (ri->attr->community); |
| 4585 | } |
| 4586 | } |
| 4587 | } |
| 4588 | } |
| 4589 | if (match) |
| 4590 | bgp_process (bgp, rn, afi, safi); |
| 4591 | } |
| 4592 | bgp_unlock_node (top); |
| 4593 | |
| 4594 | if (rinew) |
| 4595 | { |
| 4596 | aggregate->count++; |
| 4597 | |
| 4598 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4599 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4600 | |
| 4601 | if (aggregate->as_set) |
| 4602 | { |
| 4603 | if (origin < rinew->attr->origin) |
| 4604 | origin = rinew->attr->origin; |
| 4605 | |
| 4606 | if (aspath) |
| 4607 | { |
| 4608 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4609 | aspath_free (aspath); |
| 4610 | aspath = asmerge; |
| 4611 | } |
| 4612 | else |
| 4613 | aspath = aspath_dup (rinew->attr->aspath); |
| 4614 | |
| 4615 | if (rinew->attr->community) |
| 4616 | { |
| 4617 | if (community) |
| 4618 | { |
| 4619 | commerge = community_merge (community, |
| 4620 | rinew->attr->community); |
| 4621 | community = community_uniq_sort (commerge); |
| 4622 | community_free (commerge); |
| 4623 | } |
| 4624 | else |
| 4625 | community = community_dup (rinew->attr->community); |
| 4626 | } |
| 4627 | } |
| 4628 | } |
| 4629 | |
| 4630 | if (aggregate->count > 0) |
| 4631 | { |
| 4632 | rn = bgp_node_get (table, p); |
| 4633 | new = bgp_info_new (); |
| 4634 | new->type = ZEBRA_ROUTE_BGP; |
| 4635 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4636 | new->peer = bgp->peer_self; |
| 4637 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4638 | 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] | 4639 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4640 | |
| 4641 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4642 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4643 | bgp_process (bgp, rn, afi, safi); |
| 4644 | } |
| 4645 | else |
| 4646 | { |
| 4647 | if (aspath) |
| 4648 | aspath_free (aspath); |
| 4649 | if (community) |
| 4650 | community_free (community); |
| 4651 | } |
| 4652 | } |
| 4653 | |
| 4654 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4655 | struct bgp_aggregate *); |
| 4656 | |
| 4657 | void |
| 4658 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4659 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4660 | { |
| 4661 | struct bgp_node *child; |
| 4662 | struct bgp_node *rn; |
| 4663 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4664 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4665 | |
| 4666 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4667 | if (safi == SAFI_MPLS_VPN) |
| 4668 | return; |
| 4669 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4670 | table = bgp->aggregate[afi][safi]; |
| 4671 | |
| 4672 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4673 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4674 | return; |
| 4675 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4676 | if (p->prefixlen == 0) |
| 4677 | return; |
| 4678 | |
| 4679 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4680 | return; |
| 4681 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4682 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4683 | |
| 4684 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4685 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4686 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4687 | { |
| 4688 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4689 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4690 | } |
| 4691 | bgp_unlock_node (child); |
| 4692 | } |
| 4693 | |
| 4694 | void |
| 4695 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4696 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4697 | { |
| 4698 | struct bgp_node *child; |
| 4699 | struct bgp_node *rn; |
| 4700 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4701 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4702 | |
| 4703 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4704 | if (safi == SAFI_MPLS_VPN) |
| 4705 | return; |
| 4706 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4707 | table = bgp->aggregate[afi][safi]; |
| 4708 | |
| 4709 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4710 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4711 | return; |
| 4712 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4713 | if (p->prefixlen == 0) |
| 4714 | return; |
| 4715 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4716 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4717 | |
| 4718 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4719 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4720 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4721 | { |
| 4722 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4723 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4724 | } |
| 4725 | bgp_unlock_node (child); |
| 4726 | } |
| 4727 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4728 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4729 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4730 | struct bgp_aggregate *aggregate) |
| 4731 | { |
| 4732 | struct bgp_table *table; |
| 4733 | struct bgp_node *top; |
| 4734 | struct bgp_node *rn; |
| 4735 | struct bgp_info *new; |
| 4736 | struct bgp_info *ri; |
| 4737 | unsigned long match; |
| 4738 | u_char origin = BGP_ORIGIN_IGP; |
| 4739 | struct aspath *aspath = NULL; |
| 4740 | struct aspath *asmerge = NULL; |
| 4741 | struct community *community = NULL; |
| 4742 | struct community *commerge = NULL; |
| 4743 | |
| 4744 | table = bgp->rib[afi][safi]; |
| 4745 | |
| 4746 | /* Sanity check. */ |
| 4747 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4748 | return; |
| 4749 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4750 | return; |
| 4751 | |
| 4752 | /* If routes exists below this node, generate aggregate routes. */ |
| 4753 | top = bgp_node_get (table, p); |
| 4754 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4755 | if (rn->p.prefixlen > p->prefixlen) |
| 4756 | { |
| 4757 | match = 0; |
| 4758 | |
| 4759 | for (ri = rn->info; ri; ri = ri->next) |
| 4760 | { |
| 4761 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4762 | continue; |
| 4763 | |
| 4764 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4765 | { |
| 4766 | /* summary-only aggregate route suppress aggregated |
| 4767 | route announcement. */ |
| 4768 | if (aggregate->summary_only) |
| 4769 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4770 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4771 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4772 | match++; |
| 4773 | } |
| 4774 | /* as-set aggregate route generate origin, as path, |
| 4775 | community aggregation. */ |
| 4776 | if (aggregate->as_set) |
| 4777 | { |
| 4778 | if (origin < ri->attr->origin) |
| 4779 | origin = ri->attr->origin; |
| 4780 | |
| 4781 | if (aspath) |
| 4782 | { |
| 4783 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4784 | aspath_free (aspath); |
| 4785 | aspath = asmerge; |
| 4786 | } |
| 4787 | else |
| 4788 | aspath = aspath_dup (ri->attr->aspath); |
| 4789 | |
| 4790 | if (ri->attr->community) |
| 4791 | { |
| 4792 | if (community) |
| 4793 | { |
| 4794 | commerge = community_merge (community, |
| 4795 | ri->attr->community); |
| 4796 | community = community_uniq_sort (commerge); |
| 4797 | community_free (commerge); |
| 4798 | } |
| 4799 | else |
| 4800 | community = community_dup (ri->attr->community); |
| 4801 | } |
| 4802 | } |
| 4803 | aggregate->count++; |
| 4804 | } |
| 4805 | } |
| 4806 | |
| 4807 | /* If this node is suppressed, process the change. */ |
| 4808 | if (match) |
| 4809 | bgp_process (bgp, rn, afi, safi); |
| 4810 | } |
| 4811 | bgp_unlock_node (top); |
| 4812 | |
| 4813 | /* Add aggregate route to BGP table. */ |
| 4814 | if (aggregate->count) |
| 4815 | { |
| 4816 | rn = bgp_node_get (table, p); |
| 4817 | |
| 4818 | new = bgp_info_new (); |
| 4819 | new->type = ZEBRA_ROUTE_BGP; |
| 4820 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4821 | new->peer = bgp->peer_self; |
| 4822 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4823 | 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] | 4824 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4825 | |
| 4826 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4827 | bgp_unlock_node (rn); |
| 4828 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4829 | /* Process change. */ |
| 4830 | bgp_process (bgp, rn, afi, safi); |
| 4831 | } |
| 4832 | } |
| 4833 | |
| 4834 | void |
| 4835 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4836 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4837 | { |
| 4838 | struct bgp_table *table; |
| 4839 | struct bgp_node *top; |
| 4840 | struct bgp_node *rn; |
| 4841 | struct bgp_info *ri; |
| 4842 | unsigned long match; |
| 4843 | |
| 4844 | table = bgp->rib[afi][safi]; |
| 4845 | |
| 4846 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4847 | return; |
| 4848 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4849 | return; |
| 4850 | |
| 4851 | /* If routes exists below this node, generate aggregate routes. */ |
| 4852 | top = bgp_node_get (table, p); |
| 4853 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4854 | if (rn->p.prefixlen > p->prefixlen) |
| 4855 | { |
| 4856 | match = 0; |
| 4857 | |
| 4858 | for (ri = rn->info; ri; ri = ri->next) |
| 4859 | { |
| 4860 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4861 | continue; |
| 4862 | |
| 4863 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4864 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4865 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4866 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4867 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4868 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4869 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4870 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4871 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4872 | match++; |
| 4873 | } |
| 4874 | } |
| 4875 | aggregate->count--; |
| 4876 | } |
| 4877 | } |
| 4878 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4879 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4880 | if (match) |
| 4881 | bgp_process (bgp, rn, afi, safi); |
| 4882 | } |
| 4883 | bgp_unlock_node (top); |
| 4884 | |
| 4885 | /* Delete aggregate route from BGP table. */ |
| 4886 | rn = bgp_node_get (table, p); |
| 4887 | |
| 4888 | for (ri = rn->info; ri; ri = ri->next) |
| 4889 | if (ri->peer == bgp->peer_self |
| 4890 | && ri->type == ZEBRA_ROUTE_BGP |
| 4891 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4892 | break; |
| 4893 | |
| 4894 | /* Withdraw static BGP route from routing table. */ |
| 4895 | if (ri) |
| 4896 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4897 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4898 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4899 | } |
| 4900 | |
| 4901 | /* Unlock bgp_node_lookup. */ |
| 4902 | bgp_unlock_node (rn); |
| 4903 | } |
| 4904 | |
| 4905 | /* Aggregate route attribute. */ |
| 4906 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4907 | #define AGGREGATE_AS_SET 1 |
| 4908 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4909 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4910 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4911 | afi_t afi, safi_t safi) |
| 4912 | { |
| 4913 | int ret; |
| 4914 | struct prefix p; |
| 4915 | struct bgp_node *rn; |
| 4916 | struct bgp *bgp; |
| 4917 | struct bgp_aggregate *aggregate; |
| 4918 | |
| 4919 | /* Convert string to prefix structure. */ |
| 4920 | ret = str2prefix (prefix_str, &p); |
| 4921 | if (!ret) |
| 4922 | { |
| 4923 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4924 | return CMD_WARNING; |
| 4925 | } |
| 4926 | apply_mask (&p); |
| 4927 | |
| 4928 | /* Get BGP structure. */ |
| 4929 | bgp = vty->index; |
| 4930 | |
| 4931 | /* Old configuration check. */ |
| 4932 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4933 | if (! rn) |
| 4934 | { |
| 4935 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4936 | VTY_NEWLINE); |
| 4937 | return CMD_WARNING; |
| 4938 | } |
| 4939 | |
| 4940 | aggregate = rn->info; |
| 4941 | if (aggregate->safi & SAFI_UNICAST) |
| 4942 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4943 | if (aggregate->safi & SAFI_MULTICAST) |
| 4944 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4945 | |
| 4946 | /* Unlock aggregate address configuration. */ |
| 4947 | rn->info = NULL; |
| 4948 | bgp_aggregate_free (aggregate); |
| 4949 | bgp_unlock_node (rn); |
| 4950 | bgp_unlock_node (rn); |
| 4951 | |
| 4952 | return CMD_SUCCESS; |
| 4953 | } |
| 4954 | |
| 4955 | static int |
| 4956 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4957 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4958 | u_char summary_only, u_char as_set) |
| 4959 | { |
| 4960 | int ret; |
| 4961 | struct prefix p; |
| 4962 | struct bgp_node *rn; |
| 4963 | struct bgp *bgp; |
| 4964 | struct bgp_aggregate *aggregate; |
| 4965 | |
| 4966 | /* Convert string to prefix structure. */ |
| 4967 | ret = str2prefix (prefix_str, &p); |
| 4968 | if (!ret) |
| 4969 | { |
| 4970 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4971 | return CMD_WARNING; |
| 4972 | } |
| 4973 | apply_mask (&p); |
| 4974 | |
| 4975 | /* Get BGP structure. */ |
| 4976 | bgp = vty->index; |
| 4977 | |
| 4978 | /* Old configuration check. */ |
| 4979 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 4980 | |
| 4981 | if (rn->info) |
| 4982 | { |
| 4983 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 4984 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4985 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 4986 | if (ret) |
| 4987 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 4988 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 4989 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4990 | return CMD_WARNING; |
| 4991 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4992 | } |
| 4993 | |
| 4994 | /* Make aggregate address structure. */ |
| 4995 | aggregate = bgp_aggregate_new (); |
| 4996 | aggregate->summary_only = summary_only; |
| 4997 | aggregate->as_set = as_set; |
| 4998 | aggregate->safi = safi; |
| 4999 | rn->info = aggregate; |
| 5000 | |
| 5001 | /* Aggregate address insert into BGP routing table. */ |
| 5002 | if (safi & SAFI_UNICAST) |
| 5003 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5004 | if (safi & SAFI_MULTICAST) |
| 5005 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5006 | |
| 5007 | return CMD_SUCCESS; |
| 5008 | } |
| 5009 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5010 | DEFUN (aggregate_address, |
| 5011 | aggregate_address_cmd, |
| 5012 | "aggregate-address A.B.C.D/M", |
| 5013 | "Configure BGP aggregate entries\n" |
| 5014 | "Aggregate prefix\n") |
| 5015 | { |
| 5016 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5017 | } |
| 5018 | |
| 5019 | DEFUN (aggregate_address_mask, |
| 5020 | aggregate_address_mask_cmd, |
| 5021 | "aggregate-address A.B.C.D A.B.C.D", |
| 5022 | "Configure BGP aggregate entries\n" |
| 5023 | "Aggregate address\n" |
| 5024 | "Aggregate mask\n") |
| 5025 | { |
| 5026 | int ret; |
| 5027 | char prefix_str[BUFSIZ]; |
| 5028 | |
| 5029 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5030 | |
| 5031 | if (! ret) |
| 5032 | { |
| 5033 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5034 | return CMD_WARNING; |
| 5035 | } |
| 5036 | |
| 5037 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5038 | 0, 0); |
| 5039 | } |
| 5040 | |
| 5041 | DEFUN (aggregate_address_summary_only, |
| 5042 | aggregate_address_summary_only_cmd, |
| 5043 | "aggregate-address A.B.C.D/M summary-only", |
| 5044 | "Configure BGP aggregate entries\n" |
| 5045 | "Aggregate prefix\n" |
| 5046 | "Filter more specific routes from updates\n") |
| 5047 | { |
| 5048 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5049 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5050 | } |
| 5051 | |
| 5052 | DEFUN (aggregate_address_mask_summary_only, |
| 5053 | aggregate_address_mask_summary_only_cmd, |
| 5054 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5055 | "Configure BGP aggregate entries\n" |
| 5056 | "Aggregate address\n" |
| 5057 | "Aggregate mask\n" |
| 5058 | "Filter more specific routes from updates\n") |
| 5059 | { |
| 5060 | int ret; |
| 5061 | char prefix_str[BUFSIZ]; |
| 5062 | |
| 5063 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5064 | |
| 5065 | if (! ret) |
| 5066 | { |
| 5067 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5068 | return CMD_WARNING; |
| 5069 | } |
| 5070 | |
| 5071 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5072 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5073 | } |
| 5074 | |
| 5075 | DEFUN (aggregate_address_as_set, |
| 5076 | aggregate_address_as_set_cmd, |
| 5077 | "aggregate-address A.B.C.D/M as-set", |
| 5078 | "Configure BGP aggregate entries\n" |
| 5079 | "Aggregate prefix\n" |
| 5080 | "Generate AS set path information\n") |
| 5081 | { |
| 5082 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5083 | 0, AGGREGATE_AS_SET); |
| 5084 | } |
| 5085 | |
| 5086 | DEFUN (aggregate_address_mask_as_set, |
| 5087 | aggregate_address_mask_as_set_cmd, |
| 5088 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5089 | "Configure BGP aggregate entries\n" |
| 5090 | "Aggregate address\n" |
| 5091 | "Aggregate mask\n" |
| 5092 | "Generate AS set path information\n") |
| 5093 | { |
| 5094 | int ret; |
| 5095 | char prefix_str[BUFSIZ]; |
| 5096 | |
| 5097 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5098 | |
| 5099 | if (! ret) |
| 5100 | { |
| 5101 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5102 | return CMD_WARNING; |
| 5103 | } |
| 5104 | |
| 5105 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5106 | 0, AGGREGATE_AS_SET); |
| 5107 | } |
| 5108 | |
| 5109 | |
| 5110 | DEFUN (aggregate_address_as_set_summary, |
| 5111 | aggregate_address_as_set_summary_cmd, |
| 5112 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5113 | "Configure BGP aggregate entries\n" |
| 5114 | "Aggregate prefix\n" |
| 5115 | "Generate AS set path information\n" |
| 5116 | "Filter more specific routes from updates\n") |
| 5117 | { |
| 5118 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5119 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5120 | } |
| 5121 | |
| 5122 | ALIAS (aggregate_address_as_set_summary, |
| 5123 | aggregate_address_summary_as_set_cmd, |
| 5124 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5125 | "Configure BGP aggregate entries\n" |
| 5126 | "Aggregate prefix\n" |
| 5127 | "Filter more specific routes from updates\n" |
| 5128 | "Generate AS set path information\n") |
| 5129 | |
| 5130 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5131 | aggregate_address_mask_as_set_summary_cmd, |
| 5132 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5133 | "Configure BGP aggregate entries\n" |
| 5134 | "Aggregate address\n" |
| 5135 | "Aggregate mask\n" |
| 5136 | "Generate AS set path information\n" |
| 5137 | "Filter more specific routes from updates\n") |
| 5138 | { |
| 5139 | int ret; |
| 5140 | char prefix_str[BUFSIZ]; |
| 5141 | |
| 5142 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5143 | |
| 5144 | if (! ret) |
| 5145 | { |
| 5146 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5147 | return CMD_WARNING; |
| 5148 | } |
| 5149 | |
| 5150 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5151 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5152 | } |
| 5153 | |
| 5154 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5155 | aggregate_address_mask_summary_as_set_cmd, |
| 5156 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5157 | "Configure BGP aggregate entries\n" |
| 5158 | "Aggregate address\n" |
| 5159 | "Aggregate mask\n" |
| 5160 | "Filter more specific routes from updates\n" |
| 5161 | "Generate AS set path information\n") |
| 5162 | |
| 5163 | DEFUN (no_aggregate_address, |
| 5164 | no_aggregate_address_cmd, |
| 5165 | "no aggregate-address A.B.C.D/M", |
| 5166 | NO_STR |
| 5167 | "Configure BGP aggregate entries\n" |
| 5168 | "Aggregate prefix\n") |
| 5169 | { |
| 5170 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5171 | } |
| 5172 | |
| 5173 | ALIAS (no_aggregate_address, |
| 5174 | no_aggregate_address_summary_only_cmd, |
| 5175 | "no aggregate-address A.B.C.D/M summary-only", |
| 5176 | NO_STR |
| 5177 | "Configure BGP aggregate entries\n" |
| 5178 | "Aggregate prefix\n" |
| 5179 | "Filter more specific routes from updates\n") |
| 5180 | |
| 5181 | ALIAS (no_aggregate_address, |
| 5182 | no_aggregate_address_as_set_cmd, |
| 5183 | "no aggregate-address A.B.C.D/M as-set", |
| 5184 | NO_STR |
| 5185 | "Configure BGP aggregate entries\n" |
| 5186 | "Aggregate prefix\n" |
| 5187 | "Generate AS set path information\n") |
| 5188 | |
| 5189 | ALIAS (no_aggregate_address, |
| 5190 | no_aggregate_address_as_set_summary_cmd, |
| 5191 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5192 | NO_STR |
| 5193 | "Configure BGP aggregate entries\n" |
| 5194 | "Aggregate prefix\n" |
| 5195 | "Generate AS set path information\n" |
| 5196 | "Filter more specific routes from updates\n") |
| 5197 | |
| 5198 | ALIAS (no_aggregate_address, |
| 5199 | no_aggregate_address_summary_as_set_cmd, |
| 5200 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5201 | NO_STR |
| 5202 | "Configure BGP aggregate entries\n" |
| 5203 | "Aggregate prefix\n" |
| 5204 | "Filter more specific routes from updates\n" |
| 5205 | "Generate AS set path information\n") |
| 5206 | |
| 5207 | DEFUN (no_aggregate_address_mask, |
| 5208 | no_aggregate_address_mask_cmd, |
| 5209 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5210 | NO_STR |
| 5211 | "Configure BGP aggregate entries\n" |
| 5212 | "Aggregate address\n" |
| 5213 | "Aggregate mask\n") |
| 5214 | { |
| 5215 | int ret; |
| 5216 | char prefix_str[BUFSIZ]; |
| 5217 | |
| 5218 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5219 | |
| 5220 | if (! ret) |
| 5221 | { |
| 5222 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5223 | return CMD_WARNING; |
| 5224 | } |
| 5225 | |
| 5226 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5227 | } |
| 5228 | |
| 5229 | ALIAS (no_aggregate_address_mask, |
| 5230 | no_aggregate_address_mask_summary_only_cmd, |
| 5231 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5232 | NO_STR |
| 5233 | "Configure BGP aggregate entries\n" |
| 5234 | "Aggregate address\n" |
| 5235 | "Aggregate mask\n" |
| 5236 | "Filter more specific routes from updates\n") |
| 5237 | |
| 5238 | ALIAS (no_aggregate_address_mask, |
| 5239 | no_aggregate_address_mask_as_set_cmd, |
| 5240 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5241 | NO_STR |
| 5242 | "Configure BGP aggregate entries\n" |
| 5243 | "Aggregate address\n" |
| 5244 | "Aggregate mask\n" |
| 5245 | "Generate AS set path information\n") |
| 5246 | |
| 5247 | ALIAS (no_aggregate_address_mask, |
| 5248 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5249 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5250 | NO_STR |
| 5251 | "Configure BGP aggregate entries\n" |
| 5252 | "Aggregate address\n" |
| 5253 | "Aggregate mask\n" |
| 5254 | "Generate AS set path information\n" |
| 5255 | "Filter more specific routes from updates\n") |
| 5256 | |
| 5257 | ALIAS (no_aggregate_address_mask, |
| 5258 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5259 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5260 | NO_STR |
| 5261 | "Configure BGP aggregate entries\n" |
| 5262 | "Aggregate address\n" |
| 5263 | "Aggregate mask\n" |
| 5264 | "Filter more specific routes from updates\n" |
| 5265 | "Generate AS set path information\n") |
| 5266 | |
| 5267 | #ifdef HAVE_IPV6 |
| 5268 | DEFUN (ipv6_aggregate_address, |
| 5269 | ipv6_aggregate_address_cmd, |
| 5270 | "aggregate-address X:X::X:X/M", |
| 5271 | "Configure BGP aggregate entries\n" |
| 5272 | "Aggregate prefix\n") |
| 5273 | { |
| 5274 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5275 | } |
| 5276 | |
| 5277 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5278 | ipv6_aggregate_address_summary_only_cmd, |
| 5279 | "aggregate-address X:X::X:X/M summary-only", |
| 5280 | "Configure BGP aggregate entries\n" |
| 5281 | "Aggregate prefix\n" |
| 5282 | "Filter more specific routes from updates\n") |
| 5283 | { |
| 5284 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5285 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5286 | } |
| 5287 | |
| 5288 | DEFUN (no_ipv6_aggregate_address, |
| 5289 | no_ipv6_aggregate_address_cmd, |
| 5290 | "no aggregate-address X:X::X:X/M", |
| 5291 | NO_STR |
| 5292 | "Configure BGP aggregate entries\n" |
| 5293 | "Aggregate prefix\n") |
| 5294 | { |
| 5295 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5296 | } |
| 5297 | |
| 5298 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5299 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5300 | "no aggregate-address X:X::X:X/M summary-only", |
| 5301 | NO_STR |
| 5302 | "Configure BGP aggregate entries\n" |
| 5303 | "Aggregate prefix\n" |
| 5304 | "Filter more specific routes from updates\n") |
| 5305 | { |
| 5306 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5307 | } |
| 5308 | |
| 5309 | ALIAS (ipv6_aggregate_address, |
| 5310 | old_ipv6_aggregate_address_cmd, |
| 5311 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5312 | IPV6_STR |
| 5313 | BGP_STR |
| 5314 | "Configure BGP aggregate entries\n" |
| 5315 | "Aggregate prefix\n") |
| 5316 | |
| 5317 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5318 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5319 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5320 | IPV6_STR |
| 5321 | BGP_STR |
| 5322 | "Configure BGP aggregate entries\n" |
| 5323 | "Aggregate prefix\n" |
| 5324 | "Filter more specific routes from updates\n") |
| 5325 | |
| 5326 | ALIAS (no_ipv6_aggregate_address, |
| 5327 | old_no_ipv6_aggregate_address_cmd, |
| 5328 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5329 | NO_STR |
| 5330 | IPV6_STR |
| 5331 | BGP_STR |
| 5332 | "Configure BGP aggregate entries\n" |
| 5333 | "Aggregate prefix\n") |
| 5334 | |
| 5335 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5336 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5337 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5338 | NO_STR |
| 5339 | IPV6_STR |
| 5340 | BGP_STR |
| 5341 | "Configure BGP aggregate entries\n" |
| 5342 | "Aggregate prefix\n" |
| 5343 | "Filter more specific routes from updates\n") |
| 5344 | #endif /* HAVE_IPV6 */ |
| 5345 | |
| 5346 | /* Redistribute route treatment. */ |
| 5347 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5348 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5349 | const struct in6_addr *nexthop6, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5350 | u_int32_t metric, u_char type) |
| 5351 | { |
| 5352 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5353 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5354 | struct bgp_info *new; |
| 5355 | struct bgp_info *bi; |
| 5356 | struct bgp_info info; |
| 5357 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5358 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5359 | struct attr *new_attr; |
| 5360 | afi_t afi; |
| 5361 | int ret; |
| 5362 | |
| 5363 | /* Make default attribute. */ |
| 5364 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5365 | if (nexthop) |
| 5366 | attr.nexthop = *nexthop; |
| 5367 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5368 | #ifdef HAVE_IPV6 |
| 5369 | if (nexthop6) |
| 5370 | { |
| 5371 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5372 | extra->mp_nexthop_global = *nexthop6; |
| 5373 | extra->mp_nexthop_len = 16; |
| 5374 | } |
| 5375 | #endif |
| 5376 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5377 | attr.med = metric; |
| 5378 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5379 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5380 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5381 | { |
| 5382 | afi = family2afi (p->family); |
| 5383 | |
| 5384 | if (bgp->redist[afi][type]) |
| 5385 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5386 | struct attr attr_new; |
| 5387 | struct attr_extra extra_new; |
| 5388 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5389 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5390 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5391 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5392 | |
| 5393 | if (bgp->redist_metric_flag[afi][type]) |
| 5394 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5395 | |
| 5396 | /* Apply route-map. */ |
| 5397 | if (bgp->rmap[afi][type].map) |
| 5398 | { |
| 5399 | info.peer = bgp->peer_self; |
| 5400 | info.attr = &attr_new; |
| 5401 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5402 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5403 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5404 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5405 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5406 | |
| 5407 | bgp->peer_self->rmap_type = 0; |
| 5408 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5409 | if (ret == RMAP_DENYMATCH) |
| 5410 | { |
| 5411 | /* Free uninterned attribute. */ |
| 5412 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5413 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5414 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5415 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5416 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5417 | bgp_redistribute_delete (p, type); |
| 5418 | return; |
| 5419 | } |
| 5420 | } |
| 5421 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5422 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5423 | afi, SAFI_UNICAST, p, NULL); |
| 5424 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5425 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5426 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5427 | for (bi = bn->info; bi; bi = bi->next) |
| 5428 | if (bi->peer == bgp->peer_self |
| 5429 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5430 | break; |
| 5431 | |
| 5432 | if (bi) |
| 5433 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5434 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5435 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5436 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5437 | bgp_attr_unintern (&new_attr); |
| 5438 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5439 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5440 | bgp_unlock_node (bn); |
| 5441 | return; |
| 5442 | } |
| 5443 | else |
| 5444 | { |
| 5445 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5446 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5447 | |
| 5448 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5449 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5450 | bgp_info_restore(bn, bi); |
| 5451 | else |
| 5452 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5453 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5454 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5455 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5456 | |
| 5457 | /* Process change. */ |
| 5458 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5459 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5460 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5461 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5462 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5463 | return; |
| 5464 | } |
| 5465 | } |
| 5466 | |
| 5467 | new = bgp_info_new (); |
| 5468 | new->type = type; |
| 5469 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 5470 | new->peer = bgp->peer_self; |
| 5471 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5472 | new->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5473 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5474 | |
| 5475 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5476 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5477 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5478 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5479 | } |
| 5480 | } |
| 5481 | |
| 5482 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5483 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5484 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5485 | } |
| 5486 | |
| 5487 | void |
| 5488 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5489 | { |
| 5490 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5491 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5492 | afi_t afi; |
| 5493 | struct bgp_node *rn; |
| 5494 | struct bgp_info *ri; |
| 5495 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5496 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5497 | { |
| 5498 | afi = family2afi (p->family); |
| 5499 | |
| 5500 | if (bgp->redist[afi][type]) |
| 5501 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5502 | 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] | 5503 | |
| 5504 | for (ri = rn->info; ri; ri = ri->next) |
| 5505 | if (ri->peer == bgp->peer_self |
| 5506 | && ri->type == type) |
| 5507 | break; |
| 5508 | |
| 5509 | if (ri) |
| 5510 | { |
| 5511 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5512 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5513 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5514 | } |
| 5515 | bgp_unlock_node (rn); |
| 5516 | } |
| 5517 | } |
| 5518 | } |
| 5519 | |
| 5520 | /* Withdraw specified route type's route. */ |
| 5521 | void |
| 5522 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5523 | { |
| 5524 | struct bgp_node *rn; |
| 5525 | struct bgp_info *ri; |
| 5526 | struct bgp_table *table; |
| 5527 | |
| 5528 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5529 | |
| 5530 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5531 | { |
| 5532 | for (ri = rn->info; ri; ri = ri->next) |
| 5533 | if (ri->peer == bgp->peer_self |
| 5534 | && ri->type == type) |
| 5535 | break; |
| 5536 | |
| 5537 | if (ri) |
| 5538 | { |
| 5539 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5540 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5541 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5542 | } |
| 5543 | } |
| 5544 | } |
| 5545 | |
| 5546 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5547 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5548 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5549 | { |
| 5550 | int len; |
| 5551 | u_int32_t destination; |
| 5552 | char buf[BUFSIZ]; |
| 5553 | |
| 5554 | if (p->family == AF_INET) |
| 5555 | { |
| 5556 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5557 | destination = ntohl (p->u.prefix4.s_addr); |
| 5558 | |
| 5559 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5560 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5561 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5562 | || p->u.prefix4.s_addr == 0) |
| 5563 | { |
| 5564 | /* When mask is natural, mask is not displayed. */ |
| 5565 | } |
| 5566 | else |
| 5567 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5568 | } |
| 5569 | else |
| 5570 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5571 | p->prefixlen); |
| 5572 | |
| 5573 | len = 17 - len; |
| 5574 | if (len < 1) |
| 5575 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5576 | else |
| 5577 | vty_out (vty, "%*s", len, " "); |
| 5578 | } |
| 5579 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5580 | enum bgp_display_type |
| 5581 | { |
| 5582 | normal_list, |
| 5583 | }; |
| 5584 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5585 | /* Print the short form route status for a bgp_info */ |
| 5586 | static void |
| 5587 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5588 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5589 | /* Route status display. */ |
| 5590 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5591 | vty_out (vty, "R"); |
| 5592 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5593 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5594 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5595 | vty_out (vty, "s"); |
| 5596 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5597 | vty_out (vty, "*"); |
| 5598 | else |
| 5599 | vty_out (vty, " "); |
| 5600 | |
| 5601 | /* Selected */ |
| 5602 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5603 | vty_out (vty, "h"); |
| 5604 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5605 | vty_out (vty, "d"); |
| 5606 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5607 | vty_out (vty, ">"); |
| 5608 | else |
| 5609 | vty_out (vty, " "); |
| 5610 | |
| 5611 | /* Internal route. */ |
| 5612 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5613 | vty_out (vty, "i"); |
| 5614 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5615 | vty_out (vty, " "); |
| 5616 | } |
| 5617 | |
| 5618 | /* called from terminal list command */ |
| 5619 | void |
| 5620 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5621 | struct bgp_info *binfo, int display, safi_t safi) |
| 5622 | { |
| 5623 | struct attr *attr; |
| 5624 | |
| 5625 | /* short status lead text */ |
| 5626 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5627 | |
| 5628 | /* print prefix and mask */ |
| 5629 | if (! display) |
| 5630 | route_vty_out_route (p, vty); |
| 5631 | else |
| 5632 | vty_out (vty, "%*s", 17, " "); |
| 5633 | |
| 5634 | /* Print attribute */ |
| 5635 | attr = binfo->attr; |
| 5636 | if (attr) |
| 5637 | { |
| 5638 | if (p->family == AF_INET) |
| 5639 | { |
| 5640 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5641 | vty_out (vty, "%-16s", |
| 5642 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5643 | else |
| 5644 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5645 | } |
| 5646 | #ifdef HAVE_IPV6 |
| 5647 | else if (p->family == AF_INET6) |
| 5648 | { |
| 5649 | int len; |
| 5650 | char buf[BUFSIZ]; |
| 5651 | |
| 5652 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5653 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5654 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5655 | len = 16 - len; |
| 5656 | if (len < 1) |
| 5657 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5658 | else |
| 5659 | vty_out (vty, "%*s", len, " "); |
| 5660 | } |
| 5661 | #endif /* HAVE_IPV6 */ |
| 5662 | |
| 5663 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5664 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5665 | else |
| 5666 | vty_out (vty, " "); |
| 5667 | |
| 5668 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5669 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5670 | else |
| 5671 | vty_out (vty, " "); |
| 5672 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5673 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5674 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5675 | /* Print aspath */ |
| 5676 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5677 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5678 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5679 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5680 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5681 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5682 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5683 | } |
| 5684 | |
| 5685 | /* called from terminal list command */ |
| 5686 | void |
| 5687 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5688 | struct attr *attr, safi_t safi) |
| 5689 | { |
| 5690 | /* Route status display. */ |
| 5691 | vty_out (vty, "*"); |
| 5692 | vty_out (vty, ">"); |
| 5693 | vty_out (vty, " "); |
| 5694 | |
| 5695 | /* print prefix and mask */ |
| 5696 | route_vty_out_route (p, vty); |
| 5697 | |
| 5698 | /* Print attribute */ |
| 5699 | if (attr) |
| 5700 | { |
| 5701 | if (p->family == AF_INET) |
| 5702 | { |
| 5703 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5704 | vty_out (vty, "%-16s", |
| 5705 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5706 | else |
| 5707 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5708 | } |
| 5709 | #ifdef HAVE_IPV6 |
| 5710 | else if (p->family == AF_INET6) |
| 5711 | { |
| 5712 | int len; |
| 5713 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5714 | |
| 5715 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5716 | |
| 5717 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5718 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5719 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5720 | len = 16 - len; |
| 5721 | if (len < 1) |
| 5722 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5723 | else |
| 5724 | vty_out (vty, "%*s", len, " "); |
| 5725 | } |
| 5726 | #endif /* HAVE_IPV6 */ |
| 5727 | |
| 5728 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5729 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5730 | else |
| 5731 | vty_out (vty, " "); |
| 5732 | |
| 5733 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5734 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5735 | else |
| 5736 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5737 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5738 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5739 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5740 | /* Print aspath */ |
| 5741 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5742 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5743 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5744 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5745 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5746 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5747 | |
| 5748 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5749 | } |
| 5750 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5751 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5752 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 5753 | struct bgp_info *binfo, int display, safi_t safi) |
| 5754 | { |
| 5755 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5756 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5757 | |
| 5758 | if (!binfo->extra) |
| 5759 | return; |
| 5760 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5761 | /* short status lead text */ |
| 5762 | route_vty_short_status_out (vty, binfo); |
| 5763 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5764 | /* print prefix and mask */ |
| 5765 | if (! display) |
| 5766 | route_vty_out_route (p, vty); |
| 5767 | else |
| 5768 | vty_out (vty, "%*s", 17, " "); |
| 5769 | |
| 5770 | /* Print attribute */ |
| 5771 | attr = binfo->attr; |
| 5772 | if (attr) |
| 5773 | { |
| 5774 | if (p->family == AF_INET) |
| 5775 | { |
| 5776 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5777 | vty_out (vty, "%-16s", |
| 5778 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5779 | else |
| 5780 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5781 | } |
| 5782 | #ifdef HAVE_IPV6 |
| 5783 | else if (p->family == AF_INET6) |
| 5784 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5785 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5786 | char buf[BUFSIZ]; |
| 5787 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5788 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5789 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5790 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5791 | buf, BUFSIZ)); |
| 5792 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5793 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5794 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5795 | buf, BUFSIZ), |
| 5796 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 5797 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5798 | |
| 5799 | } |
| 5800 | #endif /* HAVE_IPV6 */ |
| 5801 | } |
| 5802 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5803 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5804 | |
| 5805 | vty_out (vty, "notag/%d", label); |
| 5806 | |
| 5807 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5808 | } |
| 5809 | |
| 5810 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5811 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5812 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5813 | struct bgp_info *binfo, int display, safi_t safi) |
| 5814 | { |
| 5815 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5816 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5817 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5818 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5819 | /* short status lead text */ |
| 5820 | route_vty_short_status_out (vty, binfo); |
| 5821 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5822 | /* print prefix and mask */ |
| 5823 | if (! display) |
| 5824 | route_vty_out_route (p, vty); |
| 5825 | else |
| 5826 | vty_out (vty, "%*s", 17, " "); |
| 5827 | |
| 5828 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5829 | len = 17 - len; |
| 5830 | if (len < 1) |
| 5831 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5832 | else |
| 5833 | vty_out (vty, "%*s", len, " "); |
| 5834 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5835 | 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] | 5836 | |
| 5837 | /* Print attribute */ |
| 5838 | attr = binfo->attr; |
| 5839 | if (attr) |
| 5840 | { |
| 5841 | /* Print aspath */ |
| 5842 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5843 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5844 | |
| 5845 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5846 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5847 | } |
| 5848 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5849 | } |
| 5850 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5851 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5852 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5853 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5854 | struct bgp_info *binfo, int display, safi_t safi) |
| 5855 | { |
| 5856 | struct attr *attr; |
| 5857 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5858 | char timebuf[BGP_UPTIME_LEN]; |
| 5859 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5860 | |
| 5861 | if (!binfo->extra) |
| 5862 | return; |
| 5863 | |
| 5864 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5865 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5866 | /* short status lead text */ |
| 5867 | route_vty_short_status_out (vty, binfo); |
| 5868 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5869 | /* print prefix and mask */ |
| 5870 | if (! display) |
| 5871 | route_vty_out_route (p, vty); |
| 5872 | else |
| 5873 | vty_out (vty, "%*s", 17, " "); |
| 5874 | |
| 5875 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5876 | len = 16 - len; |
| 5877 | if (len < 1) |
| 5878 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5879 | else |
| 5880 | vty_out (vty, "%*s", len, " "); |
| 5881 | |
| 5882 | len = vty_out (vty, "%d", bdi->flap); |
| 5883 | len = 5 - len; |
| 5884 | if (len < 1) |
| 5885 | vty_out (vty, " "); |
| 5886 | else |
| 5887 | vty_out (vty, "%*s ", len, " "); |
| 5888 | |
| 5889 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5890 | timebuf, BGP_UPTIME_LEN)); |
| 5891 | |
| 5892 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5893 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5894 | 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] | 5895 | else |
| 5896 | vty_out (vty, "%*s ", 8, " "); |
| 5897 | |
| 5898 | /* Print attribute */ |
| 5899 | attr = binfo->attr; |
| 5900 | if (attr) |
| 5901 | { |
| 5902 | /* Print aspath */ |
| 5903 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5904 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5905 | |
| 5906 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5907 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5908 | } |
| 5909 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5910 | } |
| 5911 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5912 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5913 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5914 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5915 | { |
| 5916 | char buf[INET6_ADDRSTRLEN]; |
| 5917 | char buf1[BUFSIZ]; |
| 5918 | struct attr *attr; |
| 5919 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 5920 | #ifdef HAVE_CLOCK_MONOTONIC |
| 5921 | time_t tbuf; |
| 5922 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5923 | |
| 5924 | attr = binfo->attr; |
| 5925 | |
| 5926 | if (attr) |
| 5927 | { |
| 5928 | /* Line1 display AS-path, Aggregator */ |
| 5929 | if (attr->aspath) |
| 5930 | { |
| 5931 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 5932 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5933 | vty_out (vty, "Local"); |
| 5934 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5935 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5936 | } |
| 5937 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5938 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5939 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5940 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 5941 | vty_out (vty, ", (stale)"); |
| 5942 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 5943 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5944 | attr->extra->aggregator_as, |
| 5945 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5946 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 5947 | vty_out (vty, ", (Received from a RR-client)"); |
| 5948 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 5949 | vty_out (vty, ", (Received from a RS-client)"); |
| 5950 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5951 | vty_out (vty, ", (history entry)"); |
| 5952 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5953 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5954 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5955 | |
| 5956 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 5957 | if (p->family == AF_INET) |
| 5958 | { |
| 5959 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5960 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5961 | inet_ntoa (attr->nexthop)); |
| 5962 | } |
| 5963 | #ifdef HAVE_IPV6 |
| 5964 | else |
| 5965 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5966 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5967 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5968 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5969 | buf, INET6_ADDRSTRLEN)); |
| 5970 | } |
| 5971 | #endif /* HAVE_IPV6 */ |
| 5972 | |
| 5973 | if (binfo->peer == bgp->peer_self) |
| 5974 | { |
| 5975 | vty_out (vty, " from %s ", |
| 5976 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 5977 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 5978 | } |
| 5979 | else |
| 5980 | { |
| 5981 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 5982 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5983 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 5984 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 5985 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5986 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5987 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5988 | else |
| 5989 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 5990 | } |
| 5991 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5992 | |
| 5993 | #ifdef HAVE_IPV6 |
| 5994 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5995 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5996 | { |
| 5997 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5998 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5999 | buf, INET6_ADDRSTRLEN), |
| 6000 | VTY_NEWLINE); |
| 6001 | } |
| 6002 | #endif /* HAVE_IPV6 */ |
| 6003 | |
| 6004 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 6005 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 6006 | |
| 6007 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6008 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6009 | |
| 6010 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6011 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6012 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6013 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6014 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6015 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6016 | vty_out (vty, ", weight %u", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6017 | |
| 6018 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6019 | vty_out (vty, ", valid"); |
| 6020 | |
| 6021 | if (binfo->peer != bgp->peer_self) |
| 6022 | { |
| 6023 | if (binfo->peer->as == binfo->peer->local_as) |
| 6024 | vty_out (vty, ", internal"); |
| 6025 | else |
| 6026 | vty_out (vty, ", %s", |
| 6027 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6028 | } |
| 6029 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6030 | vty_out (vty, ", aggregated, local"); |
| 6031 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6032 | vty_out (vty, ", sourced"); |
| 6033 | else |
| 6034 | vty_out (vty, ", sourced, local"); |
| 6035 | |
| 6036 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6037 | vty_out (vty, ", atomic-aggregate"); |
| 6038 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6039 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6040 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6041 | bgp_info_mpath_count (binfo))) |
| 6042 | vty_out (vty, ", multipath"); |
| 6043 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6044 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6045 | vty_out (vty, ", best"); |
| 6046 | |
| 6047 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6048 | |
| 6049 | /* Line 4 display Community */ |
| 6050 | if (attr->community) |
| 6051 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6052 | VTY_NEWLINE); |
| 6053 | |
| 6054 | /* Line 5 display Extended-community */ |
| 6055 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6056 | vty_out (vty, " Extended Community: %s%s", |
| 6057 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6058 | |
| 6059 | /* Line 6 display Originator, Cluster-id */ |
| 6060 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6061 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6062 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6063 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6064 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6065 | vty_out (vty, " Originator: %s", |
| 6066 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6067 | |
| 6068 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6069 | { |
| 6070 | int i; |
| 6071 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6072 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6073 | vty_out (vty, "%s ", |
| 6074 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6075 | } |
| 6076 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6077 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6078 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6079 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6080 | bgp_damp_info_vty (vty, binfo); |
| 6081 | |
| 6082 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6083 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6084 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6085 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6086 | #else |
| 6087 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6088 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6089 | } |
| 6090 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6091 | } |
| 6092 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6093 | #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] | 6094 | #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] | 6095 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6096 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6097 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6098 | |
| 6099 | enum bgp_show_type |
| 6100 | { |
| 6101 | bgp_show_type_normal, |
| 6102 | bgp_show_type_regexp, |
| 6103 | bgp_show_type_prefix_list, |
| 6104 | bgp_show_type_filter_list, |
| 6105 | bgp_show_type_route_map, |
| 6106 | bgp_show_type_neighbor, |
| 6107 | bgp_show_type_cidr_only, |
| 6108 | bgp_show_type_prefix_longer, |
| 6109 | bgp_show_type_community_all, |
| 6110 | bgp_show_type_community, |
| 6111 | bgp_show_type_community_exact, |
| 6112 | bgp_show_type_community_list, |
| 6113 | bgp_show_type_community_list_exact, |
| 6114 | bgp_show_type_flap_statistics, |
| 6115 | bgp_show_type_flap_address, |
| 6116 | bgp_show_type_flap_prefix, |
| 6117 | bgp_show_type_flap_cidr_only, |
| 6118 | bgp_show_type_flap_regexp, |
| 6119 | bgp_show_type_flap_filter_list, |
| 6120 | bgp_show_type_flap_prefix_list, |
| 6121 | bgp_show_type_flap_prefix_longer, |
| 6122 | bgp_show_type_flap_route_map, |
| 6123 | bgp_show_type_flap_neighbor, |
| 6124 | bgp_show_type_dampend_paths, |
| 6125 | bgp_show_type_damp_neighbor |
| 6126 | }; |
| 6127 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6128 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6129 | 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] | 6130 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6131 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6132 | struct bgp_info *ri; |
| 6133 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6134 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6135 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6136 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6137 | |
| 6138 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6139 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6140 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6141 | /* Start processing of routes. */ |
| 6142 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6143 | if (rn->info != NULL) |
| 6144 | { |
| 6145 | display = 0; |
| 6146 | |
| 6147 | for (ri = rn->info; ri; ri = ri->next) |
| 6148 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6149 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6150 | || type == bgp_show_type_flap_address |
| 6151 | || type == bgp_show_type_flap_prefix |
| 6152 | || type == bgp_show_type_flap_cidr_only |
| 6153 | || type == bgp_show_type_flap_regexp |
| 6154 | || type == bgp_show_type_flap_filter_list |
| 6155 | || type == bgp_show_type_flap_prefix_list |
| 6156 | || type == bgp_show_type_flap_prefix_longer |
| 6157 | || type == bgp_show_type_flap_route_map |
| 6158 | || type == bgp_show_type_flap_neighbor |
| 6159 | || type == bgp_show_type_dampend_paths |
| 6160 | || type == bgp_show_type_damp_neighbor) |
| 6161 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6162 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6163 | continue; |
| 6164 | } |
| 6165 | if (type == bgp_show_type_regexp |
| 6166 | || type == bgp_show_type_flap_regexp) |
| 6167 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6168 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6169 | |
| 6170 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6171 | continue; |
| 6172 | } |
| 6173 | if (type == bgp_show_type_prefix_list |
| 6174 | || type == bgp_show_type_flap_prefix_list) |
| 6175 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6176 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6177 | |
| 6178 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6179 | continue; |
| 6180 | } |
| 6181 | if (type == bgp_show_type_filter_list |
| 6182 | || type == bgp_show_type_flap_filter_list) |
| 6183 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6184 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6185 | |
| 6186 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6187 | continue; |
| 6188 | } |
| 6189 | if (type == bgp_show_type_route_map |
| 6190 | || type == bgp_show_type_flap_route_map) |
| 6191 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6192 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6193 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6194 | struct attr dummy_attr; |
| 6195 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6196 | int ret; |
| 6197 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6198 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6199 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6200 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6201 | binfo.peer = ri->peer; |
| 6202 | binfo.attr = &dummy_attr; |
| 6203 | |
| 6204 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6205 | if (ret == RMAP_DENYMATCH) |
| 6206 | continue; |
| 6207 | } |
| 6208 | if (type == bgp_show_type_neighbor |
| 6209 | || type == bgp_show_type_flap_neighbor |
| 6210 | || type == bgp_show_type_damp_neighbor) |
| 6211 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6212 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6213 | |
| 6214 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6215 | continue; |
| 6216 | } |
| 6217 | if (type == bgp_show_type_cidr_only |
| 6218 | || type == bgp_show_type_flap_cidr_only) |
| 6219 | { |
| 6220 | u_int32_t destination; |
| 6221 | |
| 6222 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6223 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6224 | continue; |
| 6225 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6226 | continue; |
| 6227 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6228 | continue; |
| 6229 | } |
| 6230 | if (type == bgp_show_type_prefix_longer |
| 6231 | || type == bgp_show_type_flap_prefix_longer) |
| 6232 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6233 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6234 | |
| 6235 | if (! prefix_match (p, &rn->p)) |
| 6236 | continue; |
| 6237 | } |
| 6238 | if (type == bgp_show_type_community_all) |
| 6239 | { |
| 6240 | if (! ri->attr->community) |
| 6241 | continue; |
| 6242 | } |
| 6243 | if (type == bgp_show_type_community) |
| 6244 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6245 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6246 | |
| 6247 | if (! ri->attr->community || |
| 6248 | ! community_match (ri->attr->community, com)) |
| 6249 | continue; |
| 6250 | } |
| 6251 | if (type == bgp_show_type_community_exact) |
| 6252 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6253 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6254 | |
| 6255 | if (! ri->attr->community || |
| 6256 | ! community_cmp (ri->attr->community, com)) |
| 6257 | continue; |
| 6258 | } |
| 6259 | if (type == bgp_show_type_community_list) |
| 6260 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6261 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6262 | |
| 6263 | if (! community_list_match (ri->attr->community, list)) |
| 6264 | continue; |
| 6265 | } |
| 6266 | if (type == bgp_show_type_community_list_exact) |
| 6267 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6268 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6269 | |
| 6270 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6271 | continue; |
| 6272 | } |
| 6273 | if (type == bgp_show_type_flap_address |
| 6274 | || type == bgp_show_type_flap_prefix) |
| 6275 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6276 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6277 | |
| 6278 | if (! prefix_match (&rn->p, p)) |
| 6279 | continue; |
| 6280 | |
| 6281 | if (type == bgp_show_type_flap_prefix) |
| 6282 | if (p->prefixlen != rn->p.prefixlen) |
| 6283 | continue; |
| 6284 | } |
| 6285 | if (type == bgp_show_type_dampend_paths |
| 6286 | || type == bgp_show_type_damp_neighbor) |
| 6287 | { |
| 6288 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6289 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6290 | continue; |
| 6291 | } |
| 6292 | |
| 6293 | if (header) |
| 6294 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6295 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6296 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6297 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6298 | if (type == bgp_show_type_dampend_paths |
| 6299 | || type == bgp_show_type_damp_neighbor) |
| 6300 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6301 | else if (type == bgp_show_type_flap_statistics |
| 6302 | || type == bgp_show_type_flap_address |
| 6303 | || type == bgp_show_type_flap_prefix |
| 6304 | || type == bgp_show_type_flap_cidr_only |
| 6305 | || type == bgp_show_type_flap_regexp |
| 6306 | || type == bgp_show_type_flap_filter_list |
| 6307 | || type == bgp_show_type_flap_prefix_list |
| 6308 | || type == bgp_show_type_flap_prefix_longer |
| 6309 | || type == bgp_show_type_flap_route_map |
| 6310 | || type == bgp_show_type_flap_neighbor) |
| 6311 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6312 | else |
| 6313 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6314 | header = 0; |
| 6315 | } |
| 6316 | |
| 6317 | if (type == bgp_show_type_dampend_paths |
| 6318 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6319 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6320 | else if (type == bgp_show_type_flap_statistics |
| 6321 | || type == bgp_show_type_flap_address |
| 6322 | || type == bgp_show_type_flap_prefix |
| 6323 | || type == bgp_show_type_flap_cidr_only |
| 6324 | || type == bgp_show_type_flap_regexp |
| 6325 | || type == bgp_show_type_flap_filter_list |
| 6326 | || type == bgp_show_type_flap_prefix_list |
| 6327 | || type == bgp_show_type_flap_prefix_longer |
| 6328 | || type == bgp_show_type_flap_route_map |
| 6329 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6330 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6331 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6332 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6333 | display++; |
| 6334 | } |
| 6335 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6336 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6337 | } |
| 6338 | |
| 6339 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6340 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6341 | { |
| 6342 | if (type == bgp_show_type_normal) |
| 6343 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 6344 | } |
| 6345 | else |
| 6346 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6347 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6348 | |
| 6349 | return CMD_SUCCESS; |
| 6350 | } |
| 6351 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6352 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6353 | 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] | 6354 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6355 | { |
| 6356 | struct bgp_table *table; |
| 6357 | |
| 6358 | if (bgp == NULL) { |
| 6359 | bgp = bgp_get_default (); |
| 6360 | } |
| 6361 | |
| 6362 | if (bgp == NULL) |
| 6363 | { |
| 6364 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6365 | return CMD_WARNING; |
| 6366 | } |
| 6367 | |
| 6368 | |
| 6369 | table = bgp->rib[afi][safi]; |
| 6370 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6371 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6372 | } |
| 6373 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6374 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6375 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6376 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6377 | struct bgp_node *rn, |
| 6378 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6379 | { |
| 6380 | struct bgp_info *ri; |
| 6381 | struct prefix *p; |
| 6382 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6383 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6384 | char buf1[INET6_ADDRSTRLEN]; |
| 6385 | char buf2[INET6_ADDRSTRLEN]; |
| 6386 | int count = 0; |
| 6387 | int best = 0; |
| 6388 | int suppress = 0; |
| 6389 | int no_export = 0; |
| 6390 | int no_advertise = 0; |
| 6391 | int local_as = 0; |
| 6392 | int first = 0; |
| 6393 | |
| 6394 | p = &rn->p; |
| 6395 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 6396 | (safi == SAFI_MPLS_VPN ? |
| 6397 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6398 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 6399 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6400 | p->prefixlen, VTY_NEWLINE); |
| 6401 | |
| 6402 | for (ri = rn->info; ri; ri = ri->next) |
| 6403 | { |
| 6404 | count++; |
| 6405 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6406 | { |
| 6407 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6408 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6409 | suppress = 1; |
| 6410 | if (ri->attr->community != NULL) |
| 6411 | { |
| 6412 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6413 | no_advertise = 1; |
| 6414 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6415 | no_export = 1; |
| 6416 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6417 | local_as = 1; |
| 6418 | } |
| 6419 | } |
| 6420 | } |
| 6421 | |
| 6422 | vty_out (vty, "Paths: (%d available", count); |
| 6423 | if (best) |
| 6424 | { |
| 6425 | vty_out (vty, ", best #%d", best); |
| 6426 | if (safi == SAFI_UNICAST) |
| 6427 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6428 | } |
| 6429 | else |
| 6430 | vty_out (vty, ", no best path"); |
| 6431 | if (no_advertise) |
| 6432 | vty_out (vty, ", not advertised to any peer"); |
| 6433 | else if (no_export) |
| 6434 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6435 | else if (local_as) |
| 6436 | vty_out (vty, ", not advertised outside local AS"); |
| 6437 | if (suppress) |
| 6438 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6439 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6440 | |
| 6441 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6442 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6443 | { |
| 6444 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6445 | { |
| 6446 | if (! first) |
| 6447 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6448 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6449 | first = 1; |
| 6450 | } |
| 6451 | } |
| 6452 | if (! first) |
| 6453 | vty_out (vty, " Not advertised to any peer"); |
| 6454 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6455 | } |
| 6456 | |
| 6457 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6458 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6459 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6460 | struct bgp_table *rib, const char *ip_str, |
| 6461 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6462 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6463 | { |
| 6464 | int ret; |
| 6465 | int header; |
| 6466 | int display = 0; |
| 6467 | struct prefix match; |
| 6468 | struct bgp_node *rn; |
| 6469 | struct bgp_node *rm; |
| 6470 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6471 | struct bgp_table *table; |
| 6472 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6473 | /* Check IP address argument. */ |
| 6474 | ret = str2prefix (ip_str, &match); |
| 6475 | if (! ret) |
| 6476 | { |
| 6477 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6478 | return CMD_WARNING; |
| 6479 | } |
| 6480 | |
| 6481 | match.family = afi2family (afi); |
| 6482 | |
| 6483 | if (safi == SAFI_MPLS_VPN) |
| 6484 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6485 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6486 | { |
| 6487 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6488 | continue; |
| 6489 | |
| 6490 | if ((table = rn->info) != NULL) |
| 6491 | { |
| 6492 | header = 1; |
| 6493 | |
| 6494 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6495 | { |
| 6496 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6497 | { |
| 6498 | bgp_unlock_node (rm); |
| 6499 | continue; |
| 6500 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6501 | |
| 6502 | for (ri = rm->info; ri; ri = ri->next) |
| 6503 | { |
| 6504 | if (header) |
| 6505 | { |
| 6506 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 6507 | AFI_IP, SAFI_MPLS_VPN); |
| 6508 | |
| 6509 | header = 0; |
| 6510 | } |
| 6511 | display++; |
| 6512 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 6513 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6514 | |
| 6515 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6516 | } |
| 6517 | } |
| 6518 | } |
| 6519 | } |
| 6520 | else |
| 6521 | { |
| 6522 | header = 1; |
| 6523 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6524 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6525 | { |
| 6526 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6527 | { |
| 6528 | for (ri = rn->info; ri; ri = ri->next) |
| 6529 | { |
| 6530 | if (header) |
| 6531 | { |
| 6532 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6533 | header = 0; |
| 6534 | } |
| 6535 | display++; |
| 6536 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6537 | } |
| 6538 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6539 | |
| 6540 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6541 | } |
| 6542 | } |
| 6543 | |
| 6544 | if (! display) |
| 6545 | { |
| 6546 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6547 | return CMD_WARNING; |
| 6548 | } |
| 6549 | |
| 6550 | return CMD_SUCCESS; |
| 6551 | } |
| 6552 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6553 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6554 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6555 | 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] | 6556 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6557 | int prefix_check) |
| 6558 | { |
| 6559 | struct bgp *bgp; |
| 6560 | |
| 6561 | /* BGP structure lookup. */ |
| 6562 | if (view_name) |
| 6563 | { |
| 6564 | bgp = bgp_lookup_by_name (view_name); |
| 6565 | if (bgp == NULL) |
| 6566 | { |
| 6567 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6568 | return CMD_WARNING; |
| 6569 | } |
| 6570 | } |
| 6571 | else |
| 6572 | { |
| 6573 | bgp = bgp_get_default (); |
| 6574 | if (bgp == NULL) |
| 6575 | { |
| 6576 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6577 | return CMD_WARNING; |
| 6578 | } |
| 6579 | } |
| 6580 | |
| 6581 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6582 | afi, safi, prd, prefix_check); |
| 6583 | } |
| 6584 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6585 | /* BGP route print out function. */ |
| 6586 | DEFUN (show_ip_bgp, |
| 6587 | show_ip_bgp_cmd, |
| 6588 | "show ip bgp", |
| 6589 | SHOW_STR |
| 6590 | IP_STR |
| 6591 | BGP_STR) |
| 6592 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6593 | 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] | 6594 | } |
| 6595 | |
| 6596 | DEFUN (show_ip_bgp_ipv4, |
| 6597 | show_ip_bgp_ipv4_cmd, |
| 6598 | "show ip bgp ipv4 (unicast|multicast)", |
| 6599 | SHOW_STR |
| 6600 | IP_STR |
| 6601 | BGP_STR |
| 6602 | "Address family\n" |
| 6603 | "Address Family modifier\n" |
| 6604 | "Address Family modifier\n") |
| 6605 | { |
| 6606 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6607 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6608 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6609 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6610 | 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] | 6611 | } |
| 6612 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6613 | ALIAS (show_ip_bgp_ipv4, |
| 6614 | show_bgp_ipv4_safi_cmd, |
| 6615 | "show bgp ipv4 (unicast|multicast)", |
| 6616 | SHOW_STR |
| 6617 | BGP_STR |
| 6618 | "Address family\n" |
| 6619 | "Address Family modifier\n" |
| 6620 | "Address Family modifier\n") |
| 6621 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6622 | DEFUN (show_ip_bgp_route, |
| 6623 | show_ip_bgp_route_cmd, |
| 6624 | "show ip bgp A.B.C.D", |
| 6625 | SHOW_STR |
| 6626 | IP_STR |
| 6627 | BGP_STR |
| 6628 | "Network in the BGP routing table to display\n") |
| 6629 | { |
| 6630 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6631 | } |
| 6632 | |
| 6633 | DEFUN (show_ip_bgp_ipv4_route, |
| 6634 | show_ip_bgp_ipv4_route_cmd, |
| 6635 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6636 | SHOW_STR |
| 6637 | IP_STR |
| 6638 | BGP_STR |
| 6639 | "Address family\n" |
| 6640 | "Address Family modifier\n" |
| 6641 | "Address Family modifier\n" |
| 6642 | "Network in the BGP routing table to display\n") |
| 6643 | { |
| 6644 | if (strncmp (argv[0], "m", 1) == 0) |
| 6645 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6646 | |
| 6647 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6648 | } |
| 6649 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6650 | ALIAS (show_ip_bgp_ipv4_route, |
| 6651 | show_bgp_ipv4_safi_route_cmd, |
| 6652 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6653 | SHOW_STR |
| 6654 | BGP_STR |
| 6655 | "Address family\n" |
| 6656 | "Address Family modifier\n" |
| 6657 | "Address Family modifier\n" |
| 6658 | "Network in the BGP routing table to display\n") |
| 6659 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6660 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6661 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6662 | "show ip bgp vpnv4 all A.B.C.D", |
| 6663 | SHOW_STR |
| 6664 | IP_STR |
| 6665 | BGP_STR |
| 6666 | "Display VPNv4 NLRI specific information\n" |
| 6667 | "Display information about all VPNv4 NLRIs\n" |
| 6668 | "Network in the BGP routing table to display\n") |
| 6669 | { |
| 6670 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6671 | } |
| 6672 | |
| 6673 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6674 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6675 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6676 | SHOW_STR |
| 6677 | IP_STR |
| 6678 | BGP_STR |
| 6679 | "Display VPNv4 NLRI specific information\n" |
| 6680 | "Display information for a route distinguisher\n" |
| 6681 | "VPN Route Distinguisher\n" |
| 6682 | "Network in the BGP routing table to display\n") |
| 6683 | { |
| 6684 | int ret; |
| 6685 | struct prefix_rd prd; |
| 6686 | |
| 6687 | ret = str2prefix_rd (argv[0], &prd); |
| 6688 | if (! ret) |
| 6689 | { |
| 6690 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6691 | return CMD_WARNING; |
| 6692 | } |
| 6693 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6694 | } |
| 6695 | |
| 6696 | DEFUN (show_ip_bgp_prefix, |
| 6697 | show_ip_bgp_prefix_cmd, |
| 6698 | "show ip bgp A.B.C.D/M", |
| 6699 | SHOW_STR |
| 6700 | IP_STR |
| 6701 | BGP_STR |
| 6702 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6703 | { |
| 6704 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6705 | } |
| 6706 | |
| 6707 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6708 | show_ip_bgp_ipv4_prefix_cmd, |
| 6709 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6710 | SHOW_STR |
| 6711 | IP_STR |
| 6712 | BGP_STR |
| 6713 | "Address family\n" |
| 6714 | "Address Family modifier\n" |
| 6715 | "Address Family modifier\n" |
| 6716 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6717 | { |
| 6718 | if (strncmp (argv[0], "m", 1) == 0) |
| 6719 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6720 | |
| 6721 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6722 | } |
| 6723 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6724 | ALIAS (show_ip_bgp_ipv4_prefix, |
| 6725 | show_bgp_ipv4_safi_prefix_cmd, |
| 6726 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6727 | SHOW_STR |
| 6728 | BGP_STR |
| 6729 | "Address family\n" |
| 6730 | "Address Family modifier\n" |
| 6731 | "Address Family modifier\n" |
| 6732 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6733 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6734 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 6735 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 6736 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 6737 | SHOW_STR |
| 6738 | IP_STR |
| 6739 | BGP_STR |
| 6740 | "Display VPNv4 NLRI specific information\n" |
| 6741 | "Display information about all VPNv4 NLRIs\n" |
| 6742 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6743 | { |
| 6744 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 6745 | } |
| 6746 | |
| 6747 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 6748 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 6749 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 6750 | SHOW_STR |
| 6751 | IP_STR |
| 6752 | BGP_STR |
| 6753 | "Display VPNv4 NLRI specific information\n" |
| 6754 | "Display information for a route distinguisher\n" |
| 6755 | "VPN Route Distinguisher\n" |
| 6756 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6757 | { |
| 6758 | int ret; |
| 6759 | struct prefix_rd prd; |
| 6760 | |
| 6761 | ret = str2prefix_rd (argv[0], &prd); |
| 6762 | if (! ret) |
| 6763 | { |
| 6764 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6765 | return CMD_WARNING; |
| 6766 | } |
| 6767 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 6768 | } |
| 6769 | |
| 6770 | DEFUN (show_ip_bgp_view, |
| 6771 | show_ip_bgp_view_cmd, |
| 6772 | "show ip bgp view WORD", |
| 6773 | SHOW_STR |
| 6774 | IP_STR |
| 6775 | BGP_STR |
| 6776 | "BGP view\n" |
| 6777 | "BGP view name\n") |
| 6778 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6779 | struct bgp *bgp; |
| 6780 | |
| 6781 | /* BGP structure lookup. */ |
| 6782 | bgp = bgp_lookup_by_name (argv[0]); |
| 6783 | if (bgp == NULL) |
| 6784 | { |
| 6785 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6786 | return CMD_WARNING; |
| 6787 | } |
| 6788 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6789 | 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] | 6790 | } |
| 6791 | |
| 6792 | DEFUN (show_ip_bgp_view_route, |
| 6793 | show_ip_bgp_view_route_cmd, |
| 6794 | "show ip bgp view WORD A.B.C.D", |
| 6795 | SHOW_STR |
| 6796 | IP_STR |
| 6797 | BGP_STR |
| 6798 | "BGP view\n" |
| 6799 | "BGP view name\n" |
| 6800 | "Network in the BGP routing table to display\n") |
| 6801 | { |
| 6802 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6803 | } |
| 6804 | |
| 6805 | DEFUN (show_ip_bgp_view_prefix, |
| 6806 | show_ip_bgp_view_prefix_cmd, |
| 6807 | "show ip bgp view WORD A.B.C.D/M", |
| 6808 | SHOW_STR |
| 6809 | IP_STR |
| 6810 | BGP_STR |
| 6811 | "BGP view\n" |
| 6812 | "BGP view name\n" |
| 6813 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6814 | { |
| 6815 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6816 | } |
| 6817 | |
| 6818 | #ifdef HAVE_IPV6 |
| 6819 | DEFUN (show_bgp, |
| 6820 | show_bgp_cmd, |
| 6821 | "show bgp", |
| 6822 | SHOW_STR |
| 6823 | BGP_STR) |
| 6824 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6825 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6826 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6827 | } |
| 6828 | |
| 6829 | ALIAS (show_bgp, |
| 6830 | show_bgp_ipv6_cmd, |
| 6831 | "show bgp ipv6", |
| 6832 | SHOW_STR |
| 6833 | BGP_STR |
| 6834 | "Address family\n") |
| 6835 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6836 | DEFUN (show_bgp_ipv6_safi, |
| 6837 | show_bgp_ipv6_safi_cmd, |
| 6838 | "show bgp ipv6 (unicast|multicast)", |
| 6839 | SHOW_STR |
| 6840 | BGP_STR |
| 6841 | "Address family\n" |
| 6842 | "Address Family modifier\n" |
| 6843 | "Address Family modifier\n") |
| 6844 | { |
| 6845 | if (strncmp (argv[0], "m", 1) == 0) |
| 6846 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6847 | NULL); |
| 6848 | |
| 6849 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6850 | } |
| 6851 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6852 | /* old command */ |
| 6853 | DEFUN (show_ipv6_bgp, |
| 6854 | show_ipv6_bgp_cmd, |
| 6855 | "show ipv6 bgp", |
| 6856 | SHOW_STR |
| 6857 | IP_STR |
| 6858 | BGP_STR) |
| 6859 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6860 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6861 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6862 | } |
| 6863 | |
| 6864 | DEFUN (show_bgp_route, |
| 6865 | show_bgp_route_cmd, |
| 6866 | "show bgp X:X::X:X", |
| 6867 | SHOW_STR |
| 6868 | BGP_STR |
| 6869 | "Network in the BGP routing table to display\n") |
| 6870 | { |
| 6871 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6872 | } |
| 6873 | |
| 6874 | ALIAS (show_bgp_route, |
| 6875 | show_bgp_ipv6_route_cmd, |
| 6876 | "show bgp ipv6 X:X::X:X", |
| 6877 | SHOW_STR |
| 6878 | BGP_STR |
| 6879 | "Address family\n" |
| 6880 | "Network in the BGP routing table to display\n") |
| 6881 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6882 | DEFUN (show_bgp_ipv6_safi_route, |
| 6883 | show_bgp_ipv6_safi_route_cmd, |
| 6884 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
| 6885 | SHOW_STR |
| 6886 | BGP_STR |
| 6887 | "Address family\n" |
| 6888 | "Address Family modifier\n" |
| 6889 | "Address Family modifier\n" |
| 6890 | "Network in the BGP routing table to display\n") |
| 6891 | { |
| 6892 | if (strncmp (argv[0], "m", 1) == 0) |
| 6893 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6894 | |
| 6895 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6896 | } |
| 6897 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6898 | /* old command */ |
| 6899 | DEFUN (show_ipv6_bgp_route, |
| 6900 | show_ipv6_bgp_route_cmd, |
| 6901 | "show ipv6 bgp X:X::X:X", |
| 6902 | SHOW_STR |
| 6903 | IP_STR |
| 6904 | BGP_STR |
| 6905 | "Network in the BGP routing table to display\n") |
| 6906 | { |
| 6907 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6908 | } |
| 6909 | |
| 6910 | DEFUN (show_bgp_prefix, |
| 6911 | show_bgp_prefix_cmd, |
| 6912 | "show bgp X:X::X:X/M", |
| 6913 | SHOW_STR |
| 6914 | BGP_STR |
| 6915 | "IPv6 prefix <network>/<length>\n") |
| 6916 | { |
| 6917 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6918 | } |
| 6919 | |
| 6920 | ALIAS (show_bgp_prefix, |
| 6921 | show_bgp_ipv6_prefix_cmd, |
| 6922 | "show bgp ipv6 X:X::X:X/M", |
| 6923 | SHOW_STR |
| 6924 | BGP_STR |
| 6925 | "Address family\n" |
| 6926 | "IPv6 prefix <network>/<length>\n") |
| 6927 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6928 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 6929 | show_bgp_ipv6_safi_prefix_cmd, |
| 6930 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 6931 | SHOW_STR |
| 6932 | BGP_STR |
| 6933 | "Address family\n" |
| 6934 | "Address Family modifier\n" |
| 6935 | "Address Family modifier\n" |
| 6936 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6937 | { |
| 6938 | if (strncmp (argv[0], "m", 1) == 0) |
| 6939 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 6940 | |
| 6941 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6942 | } |
| 6943 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6944 | /* old command */ |
| 6945 | DEFUN (show_ipv6_bgp_prefix, |
| 6946 | show_ipv6_bgp_prefix_cmd, |
| 6947 | "show ipv6 bgp X:X::X:X/M", |
| 6948 | SHOW_STR |
| 6949 | IP_STR |
| 6950 | BGP_STR |
| 6951 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6952 | { |
| 6953 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6954 | } |
| 6955 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6956 | DEFUN (show_bgp_view, |
| 6957 | show_bgp_view_cmd, |
| 6958 | "show bgp view WORD", |
| 6959 | SHOW_STR |
| 6960 | BGP_STR |
| 6961 | "BGP view\n" |
| 6962 | "View name\n") |
| 6963 | { |
| 6964 | struct bgp *bgp; |
| 6965 | |
| 6966 | /* BGP structure lookup. */ |
| 6967 | bgp = bgp_lookup_by_name (argv[0]); |
| 6968 | if (bgp == NULL) |
| 6969 | { |
| 6970 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6971 | return CMD_WARNING; |
| 6972 | } |
| 6973 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6974 | 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] | 6975 | } |
| 6976 | |
| 6977 | ALIAS (show_bgp_view, |
| 6978 | show_bgp_view_ipv6_cmd, |
| 6979 | "show bgp view WORD ipv6", |
| 6980 | SHOW_STR |
| 6981 | BGP_STR |
| 6982 | "BGP view\n" |
| 6983 | "View name\n" |
| 6984 | "Address family\n") |
| 6985 | |
| 6986 | DEFUN (show_bgp_view_route, |
| 6987 | show_bgp_view_route_cmd, |
| 6988 | "show bgp view WORD X:X::X:X", |
| 6989 | SHOW_STR |
| 6990 | BGP_STR |
| 6991 | "BGP view\n" |
| 6992 | "View name\n" |
| 6993 | "Network in the BGP routing table to display\n") |
| 6994 | { |
| 6995 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6996 | } |
| 6997 | |
| 6998 | ALIAS (show_bgp_view_route, |
| 6999 | show_bgp_view_ipv6_route_cmd, |
| 7000 | "show bgp view WORD ipv6 X:X::X:X", |
| 7001 | SHOW_STR |
| 7002 | BGP_STR |
| 7003 | "BGP view\n" |
| 7004 | "View name\n" |
| 7005 | "Address family\n" |
| 7006 | "Network in the BGP routing table to display\n") |
| 7007 | |
| 7008 | DEFUN (show_bgp_view_prefix, |
| 7009 | show_bgp_view_prefix_cmd, |
| 7010 | "show bgp view WORD X:X::X:X/M", |
| 7011 | SHOW_STR |
| 7012 | BGP_STR |
| 7013 | "BGP view\n" |
| 7014 | "View name\n" |
| 7015 | "IPv6 prefix <network>/<length>\n") |
| 7016 | { |
| 7017 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7018 | } |
| 7019 | |
| 7020 | ALIAS (show_bgp_view_prefix, |
| 7021 | show_bgp_view_ipv6_prefix_cmd, |
| 7022 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 7023 | SHOW_STR |
| 7024 | BGP_STR |
| 7025 | "BGP view\n" |
| 7026 | "View name\n" |
| 7027 | "Address family\n" |
| 7028 | "IPv6 prefix <network>/<length>\n") |
| 7029 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7030 | /* old command */ |
| 7031 | DEFUN (show_ipv6_mbgp, |
| 7032 | show_ipv6_mbgp_cmd, |
| 7033 | "show ipv6 mbgp", |
| 7034 | SHOW_STR |
| 7035 | IP_STR |
| 7036 | MBGP_STR) |
| 7037 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7038 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7039 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7040 | } |
| 7041 | |
| 7042 | /* old command */ |
| 7043 | DEFUN (show_ipv6_mbgp_route, |
| 7044 | show_ipv6_mbgp_route_cmd, |
| 7045 | "show ipv6 mbgp X:X::X:X", |
| 7046 | SHOW_STR |
| 7047 | IP_STR |
| 7048 | MBGP_STR |
| 7049 | "Network in the MBGP routing table to display\n") |
| 7050 | { |
| 7051 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7052 | } |
| 7053 | |
| 7054 | /* old command */ |
| 7055 | DEFUN (show_ipv6_mbgp_prefix, |
| 7056 | show_ipv6_mbgp_prefix_cmd, |
| 7057 | "show ipv6 mbgp X:X::X:X/M", |
| 7058 | SHOW_STR |
| 7059 | IP_STR |
| 7060 | MBGP_STR |
| 7061 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7062 | { |
| 7063 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7064 | } |
| 7065 | #endif |
| 7066 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7067 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7068 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7069 | 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] | 7070 | safi_t safi, enum bgp_show_type type) |
| 7071 | { |
| 7072 | int i; |
| 7073 | struct buffer *b; |
| 7074 | char *regstr; |
| 7075 | int first; |
| 7076 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7077 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7078 | |
| 7079 | first = 0; |
| 7080 | b = buffer_new (1024); |
| 7081 | for (i = 0; i < argc; i++) |
| 7082 | { |
| 7083 | if (first) |
| 7084 | buffer_putc (b, ' '); |
| 7085 | else |
| 7086 | { |
| 7087 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7088 | continue; |
| 7089 | first = 1; |
| 7090 | } |
| 7091 | |
| 7092 | buffer_putstr (b, argv[i]); |
| 7093 | } |
| 7094 | buffer_putc (b, '\0'); |
| 7095 | |
| 7096 | regstr = buffer_getstr (b); |
| 7097 | buffer_free (b); |
| 7098 | |
| 7099 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7100 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7101 | if (! regex) |
| 7102 | { |
| 7103 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 7104 | VTY_NEWLINE); |
| 7105 | return CMD_WARNING; |
| 7106 | } |
| 7107 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7108 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 7109 | bgp_regex_free (regex); |
| 7110 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7111 | } |
| 7112 | |
| 7113 | DEFUN (show_ip_bgp_regexp, |
| 7114 | show_ip_bgp_regexp_cmd, |
| 7115 | "show ip bgp regexp .LINE", |
| 7116 | SHOW_STR |
| 7117 | IP_STR |
| 7118 | BGP_STR |
| 7119 | "Display routes matching the AS path regular expression\n" |
| 7120 | "A regular-expression to match the BGP AS paths\n") |
| 7121 | { |
| 7122 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7123 | bgp_show_type_regexp); |
| 7124 | } |
| 7125 | |
| 7126 | DEFUN (show_ip_bgp_flap_regexp, |
| 7127 | show_ip_bgp_flap_regexp_cmd, |
| 7128 | "show ip bgp flap-statistics regexp .LINE", |
| 7129 | SHOW_STR |
| 7130 | IP_STR |
| 7131 | BGP_STR |
| 7132 | "Display flap statistics of routes\n" |
| 7133 | "Display routes matching the AS path regular expression\n" |
| 7134 | "A regular-expression to match the BGP AS paths\n") |
| 7135 | { |
| 7136 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7137 | bgp_show_type_flap_regexp); |
| 7138 | } |
| 7139 | |
| 7140 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 7141 | show_ip_bgp_ipv4_regexp_cmd, |
| 7142 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 7143 | SHOW_STR |
| 7144 | IP_STR |
| 7145 | BGP_STR |
| 7146 | "Address family\n" |
| 7147 | "Address Family modifier\n" |
| 7148 | "Address Family modifier\n" |
| 7149 | "Display routes matching the AS path regular expression\n" |
| 7150 | "A regular-expression to match the BGP AS paths\n") |
| 7151 | { |
| 7152 | if (strncmp (argv[0], "m", 1) == 0) |
| 7153 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 7154 | bgp_show_type_regexp); |
| 7155 | |
| 7156 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7157 | bgp_show_type_regexp); |
| 7158 | } |
| 7159 | |
| 7160 | #ifdef HAVE_IPV6 |
| 7161 | DEFUN (show_bgp_regexp, |
| 7162 | show_bgp_regexp_cmd, |
| 7163 | "show bgp regexp .LINE", |
| 7164 | SHOW_STR |
| 7165 | BGP_STR |
| 7166 | "Display routes matching the AS path regular expression\n" |
| 7167 | "A regular-expression to match the BGP AS paths\n") |
| 7168 | { |
| 7169 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7170 | bgp_show_type_regexp); |
| 7171 | } |
| 7172 | |
| 7173 | ALIAS (show_bgp_regexp, |
| 7174 | show_bgp_ipv6_regexp_cmd, |
| 7175 | "show bgp ipv6 regexp .LINE", |
| 7176 | SHOW_STR |
| 7177 | BGP_STR |
| 7178 | "Address family\n" |
| 7179 | "Display routes matching the AS path regular expression\n" |
| 7180 | "A regular-expression to match the BGP AS paths\n") |
| 7181 | |
| 7182 | /* old command */ |
| 7183 | DEFUN (show_ipv6_bgp_regexp, |
| 7184 | show_ipv6_bgp_regexp_cmd, |
| 7185 | "show ipv6 bgp regexp .LINE", |
| 7186 | SHOW_STR |
| 7187 | IP_STR |
| 7188 | BGP_STR |
| 7189 | "Display routes matching the AS path regular expression\n" |
| 7190 | "A regular-expression to match the BGP AS paths\n") |
| 7191 | { |
| 7192 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7193 | bgp_show_type_regexp); |
| 7194 | } |
| 7195 | |
| 7196 | /* old command */ |
| 7197 | DEFUN (show_ipv6_mbgp_regexp, |
| 7198 | show_ipv6_mbgp_regexp_cmd, |
| 7199 | "show ipv6 mbgp regexp .LINE", |
| 7200 | SHOW_STR |
| 7201 | IP_STR |
| 7202 | BGP_STR |
| 7203 | "Display routes matching the AS path regular expression\n" |
| 7204 | "A regular-expression to match the MBGP AS paths\n") |
| 7205 | { |
| 7206 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 7207 | bgp_show_type_regexp); |
| 7208 | } |
| 7209 | #endif /* HAVE_IPV6 */ |
| 7210 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7211 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7212 | 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] | 7213 | safi_t safi, enum bgp_show_type type) |
| 7214 | { |
| 7215 | struct prefix_list *plist; |
| 7216 | |
| 7217 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 7218 | if (plist == NULL) |
| 7219 | { |
| 7220 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 7221 | prefix_list_str, VTY_NEWLINE); |
| 7222 | return CMD_WARNING; |
| 7223 | } |
| 7224 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7225 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7226 | } |
| 7227 | |
| 7228 | DEFUN (show_ip_bgp_prefix_list, |
| 7229 | show_ip_bgp_prefix_list_cmd, |
| 7230 | "show ip bgp prefix-list WORD", |
| 7231 | SHOW_STR |
| 7232 | IP_STR |
| 7233 | BGP_STR |
| 7234 | "Display routes conforming to the prefix-list\n" |
| 7235 | "IP prefix-list name\n") |
| 7236 | { |
| 7237 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7238 | bgp_show_type_prefix_list); |
| 7239 | } |
| 7240 | |
| 7241 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 7242 | show_ip_bgp_flap_prefix_list_cmd, |
| 7243 | "show ip bgp flap-statistics prefix-list WORD", |
| 7244 | SHOW_STR |
| 7245 | IP_STR |
| 7246 | BGP_STR |
| 7247 | "Display flap statistics of routes\n" |
| 7248 | "Display routes conforming to the prefix-list\n" |
| 7249 | "IP prefix-list name\n") |
| 7250 | { |
| 7251 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7252 | bgp_show_type_flap_prefix_list); |
| 7253 | } |
| 7254 | |
| 7255 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 7256 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 7257 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 7258 | SHOW_STR |
| 7259 | IP_STR |
| 7260 | BGP_STR |
| 7261 | "Address family\n" |
| 7262 | "Address Family modifier\n" |
| 7263 | "Address Family modifier\n" |
| 7264 | "Display routes conforming to the prefix-list\n" |
| 7265 | "IP prefix-list name\n") |
| 7266 | { |
| 7267 | if (strncmp (argv[0], "m", 1) == 0) |
| 7268 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7269 | bgp_show_type_prefix_list); |
| 7270 | |
| 7271 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7272 | bgp_show_type_prefix_list); |
| 7273 | } |
| 7274 | |
| 7275 | #ifdef HAVE_IPV6 |
| 7276 | DEFUN (show_bgp_prefix_list, |
| 7277 | show_bgp_prefix_list_cmd, |
| 7278 | "show bgp prefix-list WORD", |
| 7279 | SHOW_STR |
| 7280 | BGP_STR |
| 7281 | "Display routes conforming to the prefix-list\n" |
| 7282 | "IPv6 prefix-list name\n") |
| 7283 | { |
| 7284 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7285 | bgp_show_type_prefix_list); |
| 7286 | } |
| 7287 | |
| 7288 | ALIAS (show_bgp_prefix_list, |
| 7289 | show_bgp_ipv6_prefix_list_cmd, |
| 7290 | "show bgp ipv6 prefix-list WORD", |
| 7291 | SHOW_STR |
| 7292 | BGP_STR |
| 7293 | "Address family\n" |
| 7294 | "Display routes conforming to the prefix-list\n" |
| 7295 | "IPv6 prefix-list name\n") |
| 7296 | |
| 7297 | /* old command */ |
| 7298 | DEFUN (show_ipv6_bgp_prefix_list, |
| 7299 | show_ipv6_bgp_prefix_list_cmd, |
| 7300 | "show ipv6 bgp prefix-list WORD", |
| 7301 | SHOW_STR |
| 7302 | IPV6_STR |
| 7303 | BGP_STR |
| 7304 | "Display routes matching the prefix-list\n" |
| 7305 | "IPv6 prefix-list name\n") |
| 7306 | { |
| 7307 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7308 | bgp_show_type_prefix_list); |
| 7309 | } |
| 7310 | |
| 7311 | /* old command */ |
| 7312 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 7313 | show_ipv6_mbgp_prefix_list_cmd, |
| 7314 | "show ipv6 mbgp prefix-list WORD", |
| 7315 | SHOW_STR |
| 7316 | IPV6_STR |
| 7317 | MBGP_STR |
| 7318 | "Display routes matching the prefix-list\n" |
| 7319 | "IPv6 prefix-list name\n") |
| 7320 | { |
| 7321 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7322 | bgp_show_type_prefix_list); |
| 7323 | } |
| 7324 | #endif /* HAVE_IPV6 */ |
| 7325 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7326 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7327 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7328 | safi_t safi, enum bgp_show_type type) |
| 7329 | { |
| 7330 | struct as_list *as_list; |
| 7331 | |
| 7332 | as_list = as_list_lookup (filter); |
| 7333 | if (as_list == NULL) |
| 7334 | { |
| 7335 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 7336 | return CMD_WARNING; |
| 7337 | } |
| 7338 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7339 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7340 | } |
| 7341 | |
| 7342 | DEFUN (show_ip_bgp_filter_list, |
| 7343 | show_ip_bgp_filter_list_cmd, |
| 7344 | "show ip bgp filter-list WORD", |
| 7345 | SHOW_STR |
| 7346 | IP_STR |
| 7347 | BGP_STR |
| 7348 | "Display routes conforming to the filter-list\n" |
| 7349 | "Regular expression access list name\n") |
| 7350 | { |
| 7351 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7352 | bgp_show_type_filter_list); |
| 7353 | } |
| 7354 | |
| 7355 | DEFUN (show_ip_bgp_flap_filter_list, |
| 7356 | show_ip_bgp_flap_filter_list_cmd, |
| 7357 | "show ip bgp flap-statistics filter-list WORD", |
| 7358 | SHOW_STR |
| 7359 | IP_STR |
| 7360 | BGP_STR |
| 7361 | "Display flap statistics of routes\n" |
| 7362 | "Display routes conforming to the filter-list\n" |
| 7363 | "Regular expression access list name\n") |
| 7364 | { |
| 7365 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7366 | bgp_show_type_flap_filter_list); |
| 7367 | } |
| 7368 | |
| 7369 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 7370 | show_ip_bgp_ipv4_filter_list_cmd, |
| 7371 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 7372 | SHOW_STR |
| 7373 | IP_STR |
| 7374 | BGP_STR |
| 7375 | "Address family\n" |
| 7376 | "Address Family modifier\n" |
| 7377 | "Address Family modifier\n" |
| 7378 | "Display routes conforming to the filter-list\n" |
| 7379 | "Regular expression access list name\n") |
| 7380 | { |
| 7381 | if (strncmp (argv[0], "m", 1) == 0) |
| 7382 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7383 | bgp_show_type_filter_list); |
| 7384 | |
| 7385 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7386 | bgp_show_type_filter_list); |
| 7387 | } |
| 7388 | |
| 7389 | #ifdef HAVE_IPV6 |
| 7390 | DEFUN (show_bgp_filter_list, |
| 7391 | show_bgp_filter_list_cmd, |
| 7392 | "show bgp filter-list WORD", |
| 7393 | SHOW_STR |
| 7394 | BGP_STR |
| 7395 | "Display routes conforming to the filter-list\n" |
| 7396 | "Regular expression access list name\n") |
| 7397 | { |
| 7398 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7399 | bgp_show_type_filter_list); |
| 7400 | } |
| 7401 | |
| 7402 | ALIAS (show_bgp_filter_list, |
| 7403 | show_bgp_ipv6_filter_list_cmd, |
| 7404 | "show bgp ipv6 filter-list WORD", |
| 7405 | SHOW_STR |
| 7406 | BGP_STR |
| 7407 | "Address family\n" |
| 7408 | "Display routes conforming to the filter-list\n" |
| 7409 | "Regular expression access list name\n") |
| 7410 | |
| 7411 | /* old command */ |
| 7412 | DEFUN (show_ipv6_bgp_filter_list, |
| 7413 | show_ipv6_bgp_filter_list_cmd, |
| 7414 | "show ipv6 bgp filter-list WORD", |
| 7415 | SHOW_STR |
| 7416 | IPV6_STR |
| 7417 | BGP_STR |
| 7418 | "Display routes conforming to the filter-list\n" |
| 7419 | "Regular expression access list name\n") |
| 7420 | { |
| 7421 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7422 | bgp_show_type_filter_list); |
| 7423 | } |
| 7424 | |
| 7425 | /* old command */ |
| 7426 | DEFUN (show_ipv6_mbgp_filter_list, |
| 7427 | show_ipv6_mbgp_filter_list_cmd, |
| 7428 | "show ipv6 mbgp filter-list WORD", |
| 7429 | SHOW_STR |
| 7430 | IPV6_STR |
| 7431 | MBGP_STR |
| 7432 | "Display routes conforming to the filter-list\n" |
| 7433 | "Regular expression access list name\n") |
| 7434 | { |
| 7435 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7436 | bgp_show_type_filter_list); |
| 7437 | } |
| 7438 | #endif /* HAVE_IPV6 */ |
| 7439 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7440 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7441 | 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] | 7442 | safi_t safi, enum bgp_show_type type) |
| 7443 | { |
| 7444 | struct route_map *rmap; |
| 7445 | |
| 7446 | rmap = route_map_lookup_by_name (rmap_str); |
| 7447 | if (! rmap) |
| 7448 | { |
| 7449 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 7450 | rmap_str, VTY_NEWLINE); |
| 7451 | return CMD_WARNING; |
| 7452 | } |
| 7453 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7454 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7455 | } |
| 7456 | |
| 7457 | DEFUN (show_ip_bgp_route_map, |
| 7458 | show_ip_bgp_route_map_cmd, |
| 7459 | "show ip bgp route-map WORD", |
| 7460 | SHOW_STR |
| 7461 | IP_STR |
| 7462 | BGP_STR |
| 7463 | "Display routes matching the route-map\n" |
| 7464 | "A route-map to match on\n") |
| 7465 | { |
| 7466 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7467 | bgp_show_type_route_map); |
| 7468 | } |
| 7469 | |
| 7470 | DEFUN (show_ip_bgp_flap_route_map, |
| 7471 | show_ip_bgp_flap_route_map_cmd, |
| 7472 | "show ip bgp flap-statistics route-map WORD", |
| 7473 | SHOW_STR |
| 7474 | IP_STR |
| 7475 | BGP_STR |
| 7476 | "Display flap statistics of routes\n" |
| 7477 | "Display routes matching the route-map\n" |
| 7478 | "A route-map to match on\n") |
| 7479 | { |
| 7480 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7481 | bgp_show_type_flap_route_map); |
| 7482 | } |
| 7483 | |
| 7484 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 7485 | show_ip_bgp_ipv4_route_map_cmd, |
| 7486 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 7487 | SHOW_STR |
| 7488 | IP_STR |
| 7489 | BGP_STR |
| 7490 | "Address family\n" |
| 7491 | "Address Family modifier\n" |
| 7492 | "Address Family modifier\n" |
| 7493 | "Display routes matching the route-map\n" |
| 7494 | "A route-map to match on\n") |
| 7495 | { |
| 7496 | if (strncmp (argv[0], "m", 1) == 0) |
| 7497 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7498 | bgp_show_type_route_map); |
| 7499 | |
| 7500 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7501 | bgp_show_type_route_map); |
| 7502 | } |
| 7503 | |
| 7504 | DEFUN (show_bgp_route_map, |
| 7505 | show_bgp_route_map_cmd, |
| 7506 | "show bgp route-map WORD", |
| 7507 | SHOW_STR |
| 7508 | BGP_STR |
| 7509 | "Display routes matching the route-map\n" |
| 7510 | "A route-map to match on\n") |
| 7511 | { |
| 7512 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7513 | bgp_show_type_route_map); |
| 7514 | } |
| 7515 | |
| 7516 | ALIAS (show_bgp_route_map, |
| 7517 | show_bgp_ipv6_route_map_cmd, |
| 7518 | "show bgp ipv6 route-map WORD", |
| 7519 | SHOW_STR |
| 7520 | BGP_STR |
| 7521 | "Address family\n" |
| 7522 | "Display routes matching the route-map\n" |
| 7523 | "A route-map to match on\n") |
| 7524 | |
| 7525 | DEFUN (show_ip_bgp_cidr_only, |
| 7526 | show_ip_bgp_cidr_only_cmd, |
| 7527 | "show ip bgp cidr-only", |
| 7528 | SHOW_STR |
| 7529 | IP_STR |
| 7530 | BGP_STR |
| 7531 | "Display only routes with non-natural netmasks\n") |
| 7532 | { |
| 7533 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7534 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7535 | } |
| 7536 | |
| 7537 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 7538 | show_ip_bgp_flap_cidr_only_cmd, |
| 7539 | "show ip bgp flap-statistics cidr-only", |
| 7540 | SHOW_STR |
| 7541 | IP_STR |
| 7542 | BGP_STR |
| 7543 | "Display flap statistics of routes\n" |
| 7544 | "Display only routes with non-natural netmasks\n") |
| 7545 | { |
| 7546 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7547 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7548 | } |
| 7549 | |
| 7550 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 7551 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 7552 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 7553 | SHOW_STR |
| 7554 | IP_STR |
| 7555 | BGP_STR |
| 7556 | "Address family\n" |
| 7557 | "Address Family modifier\n" |
| 7558 | "Address Family modifier\n" |
| 7559 | "Display only routes with non-natural netmasks\n") |
| 7560 | { |
| 7561 | if (strncmp (argv[0], "m", 1) == 0) |
| 7562 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7563 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7564 | |
| 7565 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
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 | |
| 7569 | DEFUN (show_ip_bgp_community_all, |
| 7570 | show_ip_bgp_community_all_cmd, |
| 7571 | "show ip bgp community", |
| 7572 | SHOW_STR |
| 7573 | IP_STR |
| 7574 | BGP_STR |
| 7575 | "Display routes matching the communities\n") |
| 7576 | { |
| 7577 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7578 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7579 | } |
| 7580 | |
| 7581 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 7582 | show_ip_bgp_ipv4_community_all_cmd, |
| 7583 | "show ip bgp ipv4 (unicast|multicast) community", |
| 7584 | SHOW_STR |
| 7585 | IP_STR |
| 7586 | BGP_STR |
| 7587 | "Address family\n" |
| 7588 | "Address Family modifier\n" |
| 7589 | "Address Family modifier\n" |
| 7590 | "Display routes matching the communities\n") |
| 7591 | { |
| 7592 | if (strncmp (argv[0], "m", 1) == 0) |
| 7593 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7594 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7595 | |
| 7596 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
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 | |
| 7600 | #ifdef HAVE_IPV6 |
| 7601 | DEFUN (show_bgp_community_all, |
| 7602 | show_bgp_community_all_cmd, |
| 7603 | "show bgp community", |
| 7604 | SHOW_STR |
| 7605 | BGP_STR |
| 7606 | "Display routes matching the communities\n") |
| 7607 | { |
| 7608 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7609 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7610 | } |
| 7611 | |
| 7612 | ALIAS (show_bgp_community_all, |
| 7613 | show_bgp_ipv6_community_all_cmd, |
| 7614 | "show bgp ipv6 community", |
| 7615 | SHOW_STR |
| 7616 | BGP_STR |
| 7617 | "Address family\n" |
| 7618 | "Display routes matching the communities\n") |
| 7619 | |
| 7620 | /* old command */ |
| 7621 | DEFUN (show_ipv6_bgp_community_all, |
| 7622 | show_ipv6_bgp_community_all_cmd, |
| 7623 | "show ipv6 bgp community", |
| 7624 | SHOW_STR |
| 7625 | IPV6_STR |
| 7626 | BGP_STR |
| 7627 | "Display routes matching the communities\n") |
| 7628 | { |
| 7629 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7630 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7631 | } |
| 7632 | |
| 7633 | /* old command */ |
| 7634 | DEFUN (show_ipv6_mbgp_community_all, |
| 7635 | show_ipv6_mbgp_community_all_cmd, |
| 7636 | "show ipv6 mbgp community", |
| 7637 | SHOW_STR |
| 7638 | IPV6_STR |
| 7639 | MBGP_STR |
| 7640 | "Display routes matching the communities\n") |
| 7641 | { |
| 7642 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7643 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7644 | } |
| 7645 | #endif /* HAVE_IPV6 */ |
| 7646 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7647 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7648 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 7649 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7650 | { |
| 7651 | struct community *com; |
| 7652 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7653 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7654 | int i; |
| 7655 | char *str; |
| 7656 | int first = 0; |
| 7657 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7658 | /* BGP structure lookup */ |
| 7659 | if (view_name) |
| 7660 | { |
| 7661 | bgp = bgp_lookup_by_name (view_name); |
| 7662 | if (bgp == NULL) |
| 7663 | { |
| 7664 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 7665 | return CMD_WARNING; |
| 7666 | } |
| 7667 | } |
| 7668 | else |
| 7669 | { |
| 7670 | bgp = bgp_get_default (); |
| 7671 | if (bgp == NULL) |
| 7672 | { |
| 7673 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 7674 | return CMD_WARNING; |
| 7675 | } |
| 7676 | } |
| 7677 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7678 | b = buffer_new (1024); |
| 7679 | for (i = 0; i < argc; i++) |
| 7680 | { |
| 7681 | if (first) |
| 7682 | buffer_putc (b, ' '); |
| 7683 | else |
| 7684 | { |
| 7685 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7686 | continue; |
| 7687 | first = 1; |
| 7688 | } |
| 7689 | |
| 7690 | buffer_putstr (b, argv[i]); |
| 7691 | } |
| 7692 | buffer_putc (b, '\0'); |
| 7693 | |
| 7694 | str = buffer_getstr (b); |
| 7695 | buffer_free (b); |
| 7696 | |
| 7697 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7698 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7699 | if (! com) |
| 7700 | { |
| 7701 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 7702 | return CMD_WARNING; |
| 7703 | } |
| 7704 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7705 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7706 | (exact ? bgp_show_type_community_exact : |
| 7707 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7708 | } |
| 7709 | |
| 7710 | DEFUN (show_ip_bgp_community, |
| 7711 | show_ip_bgp_community_cmd, |
| 7712 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7713 | SHOW_STR |
| 7714 | IP_STR |
| 7715 | BGP_STR |
| 7716 | "Display routes matching the communities\n" |
| 7717 | "community number\n" |
| 7718 | "Do not send outside local AS (well-known community)\n" |
| 7719 | "Do not advertise to any peer (well-known community)\n" |
| 7720 | "Do not export to next AS (well-known community)\n") |
| 7721 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7722 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7723 | } |
| 7724 | |
| 7725 | ALIAS (show_ip_bgp_community, |
| 7726 | show_ip_bgp_community2_cmd, |
| 7727 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7728 | SHOW_STR |
| 7729 | IP_STR |
| 7730 | BGP_STR |
| 7731 | "Display routes matching the communities\n" |
| 7732 | "community number\n" |
| 7733 | "Do not send outside local AS (well-known community)\n" |
| 7734 | "Do not advertise to any peer (well-known community)\n" |
| 7735 | "Do not export to next AS (well-known community)\n" |
| 7736 | "community number\n" |
| 7737 | "Do not send outside local AS (well-known community)\n" |
| 7738 | "Do not advertise to any peer (well-known community)\n" |
| 7739 | "Do not export to next AS (well-known community)\n") |
| 7740 | |
| 7741 | ALIAS (show_ip_bgp_community, |
| 7742 | show_ip_bgp_community3_cmd, |
| 7743 | "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)", |
| 7744 | SHOW_STR |
| 7745 | IP_STR |
| 7746 | BGP_STR |
| 7747 | "Display routes matching the communities\n" |
| 7748 | "community number\n" |
| 7749 | "Do not send outside local AS (well-known community)\n" |
| 7750 | "Do not advertise to any peer (well-known community)\n" |
| 7751 | "Do not export to next AS (well-known community)\n" |
| 7752 | "community number\n" |
| 7753 | "Do not send outside local AS (well-known community)\n" |
| 7754 | "Do not advertise to any peer (well-known community)\n" |
| 7755 | "Do not export to next AS (well-known community)\n" |
| 7756 | "community number\n" |
| 7757 | "Do not send outside local AS (well-known community)\n" |
| 7758 | "Do not advertise to any peer (well-known community)\n" |
| 7759 | "Do not export to next AS (well-known community)\n") |
| 7760 | |
| 7761 | ALIAS (show_ip_bgp_community, |
| 7762 | show_ip_bgp_community4_cmd, |
| 7763 | "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)", |
| 7764 | SHOW_STR |
| 7765 | IP_STR |
| 7766 | BGP_STR |
| 7767 | "Display routes matching the communities\n" |
| 7768 | "community number\n" |
| 7769 | "Do not send outside local AS (well-known community)\n" |
| 7770 | "Do not advertise to any peer (well-known community)\n" |
| 7771 | "Do not export to next AS (well-known community)\n" |
| 7772 | "community number\n" |
| 7773 | "Do not send outside local AS (well-known community)\n" |
| 7774 | "Do not advertise to any peer (well-known community)\n" |
| 7775 | "Do not export to next AS (well-known community)\n" |
| 7776 | "community number\n" |
| 7777 | "Do not send outside local AS (well-known community)\n" |
| 7778 | "Do not advertise to any peer (well-known community)\n" |
| 7779 | "Do not export to next AS (well-known community)\n" |
| 7780 | "community number\n" |
| 7781 | "Do not send outside local AS (well-known community)\n" |
| 7782 | "Do not advertise to any peer (well-known community)\n" |
| 7783 | "Do not export to next AS (well-known community)\n") |
| 7784 | |
| 7785 | DEFUN (show_ip_bgp_ipv4_community, |
| 7786 | show_ip_bgp_ipv4_community_cmd, |
| 7787 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7788 | SHOW_STR |
| 7789 | IP_STR |
| 7790 | BGP_STR |
| 7791 | "Address family\n" |
| 7792 | "Address Family modifier\n" |
| 7793 | "Address Family modifier\n" |
| 7794 | "Display routes matching the communities\n" |
| 7795 | "community number\n" |
| 7796 | "Do not send outside local AS (well-known community)\n" |
| 7797 | "Do not advertise to any peer (well-known community)\n" |
| 7798 | "Do not export to next AS (well-known community)\n") |
| 7799 | { |
| 7800 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7801 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7802 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7803 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7804 | } |
| 7805 | |
| 7806 | ALIAS (show_ip_bgp_ipv4_community, |
| 7807 | show_ip_bgp_ipv4_community2_cmd, |
| 7808 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7809 | SHOW_STR |
| 7810 | IP_STR |
| 7811 | BGP_STR |
| 7812 | "Address family\n" |
| 7813 | "Address Family modifier\n" |
| 7814 | "Address Family modifier\n" |
| 7815 | "Display routes matching the communities\n" |
| 7816 | "community number\n" |
| 7817 | "Do not send outside local AS (well-known community)\n" |
| 7818 | "Do not advertise to any peer (well-known community)\n" |
| 7819 | "Do not export to next AS (well-known community)\n" |
| 7820 | "community number\n" |
| 7821 | "Do not send outside local AS (well-known community)\n" |
| 7822 | "Do not advertise to any peer (well-known community)\n" |
| 7823 | "Do not export to next AS (well-known community)\n") |
| 7824 | |
| 7825 | ALIAS (show_ip_bgp_ipv4_community, |
| 7826 | show_ip_bgp_ipv4_community3_cmd, |
| 7827 | "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)", |
| 7828 | SHOW_STR |
| 7829 | IP_STR |
| 7830 | BGP_STR |
| 7831 | "Address family\n" |
| 7832 | "Address Family modifier\n" |
| 7833 | "Address Family modifier\n" |
| 7834 | "Display routes matching the communities\n" |
| 7835 | "community number\n" |
| 7836 | "Do not send outside local AS (well-known community)\n" |
| 7837 | "Do not advertise to any peer (well-known community)\n" |
| 7838 | "Do not export to next AS (well-known community)\n" |
| 7839 | "community number\n" |
| 7840 | "Do not send outside local AS (well-known community)\n" |
| 7841 | "Do not advertise to any peer (well-known community)\n" |
| 7842 | "Do not export to next AS (well-known community)\n" |
| 7843 | "community number\n" |
| 7844 | "Do not send outside local AS (well-known community)\n" |
| 7845 | "Do not advertise to any peer (well-known community)\n" |
| 7846 | "Do not export to next AS (well-known community)\n") |
| 7847 | |
| 7848 | ALIAS (show_ip_bgp_ipv4_community, |
| 7849 | show_ip_bgp_ipv4_community4_cmd, |
| 7850 | "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)", |
| 7851 | SHOW_STR |
| 7852 | IP_STR |
| 7853 | BGP_STR |
| 7854 | "Address family\n" |
| 7855 | "Address Family modifier\n" |
| 7856 | "Address Family modifier\n" |
| 7857 | "Display routes matching the communities\n" |
| 7858 | "community number\n" |
| 7859 | "Do not send outside local AS (well-known community)\n" |
| 7860 | "Do not advertise to any peer (well-known community)\n" |
| 7861 | "Do not export to next AS (well-known community)\n" |
| 7862 | "community number\n" |
| 7863 | "Do not send outside local AS (well-known community)\n" |
| 7864 | "Do not advertise to any peer (well-known community)\n" |
| 7865 | "Do not export to next AS (well-known community)\n" |
| 7866 | "community number\n" |
| 7867 | "Do not send outside local AS (well-known community)\n" |
| 7868 | "Do not advertise to any peer (well-known community)\n" |
| 7869 | "Do not export to next AS (well-known community)\n" |
| 7870 | "community number\n" |
| 7871 | "Do not send outside local AS (well-known community)\n" |
| 7872 | "Do not advertise to any peer (well-known community)\n" |
| 7873 | "Do not export to next AS (well-known community)\n") |
| 7874 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7875 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 7876 | show_bgp_view_afi_safi_community_all_cmd, |
| 7877 | #ifdef HAVE_IPV6 |
| 7878 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
| 7879 | #else |
| 7880 | "show bgp view WORD ipv4 (unicast|multicast) community", |
| 7881 | #endif |
| 7882 | SHOW_STR |
| 7883 | BGP_STR |
| 7884 | "BGP view\n" |
| 7885 | "BGP view name\n" |
| 7886 | "Address family\n" |
| 7887 | #ifdef HAVE_IPV6 |
| 7888 | "Address family\n" |
| 7889 | #endif |
| 7890 | "Address Family modifier\n" |
| 7891 | "Address Family modifier\n" |
| 7892 | "Display routes containing communities\n") |
| 7893 | { |
| 7894 | int afi; |
| 7895 | int safi; |
| 7896 | struct bgp *bgp; |
| 7897 | |
| 7898 | /* BGP structure lookup. */ |
| 7899 | bgp = bgp_lookup_by_name (argv[0]); |
| 7900 | if (bgp == NULL) |
| 7901 | { |
| 7902 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7903 | return CMD_WARNING; |
| 7904 | } |
| 7905 | |
| 7906 | #ifdef HAVE_IPV6 |
| 7907 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 7908 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7909 | #else |
| 7910 | afi = AFI_IP; |
| 7911 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7912 | #endif |
| 7913 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 7914 | } |
| 7915 | |
| 7916 | DEFUN (show_bgp_view_afi_safi_community, |
| 7917 | show_bgp_view_afi_safi_community_cmd, |
| 7918 | #ifdef HAVE_IPV6 |
| 7919 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7920 | #else |
| 7921 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7922 | #endif |
| 7923 | SHOW_STR |
| 7924 | BGP_STR |
| 7925 | "BGP view\n" |
| 7926 | "BGP view name\n" |
| 7927 | "Address family\n" |
| 7928 | #ifdef HAVE_IPV6 |
| 7929 | "Address family\n" |
| 7930 | #endif |
| 7931 | "Address family modifier\n" |
| 7932 | "Address family modifier\n" |
| 7933 | "Display routes matching the communities\n" |
| 7934 | "community number\n" |
| 7935 | "Do not send outside local AS (well-known community)\n" |
| 7936 | "Do not advertise to any peer (well-known community)\n" |
| 7937 | "Do not export to next AS (well-known community)\n") |
| 7938 | { |
| 7939 | int afi; |
| 7940 | int safi; |
| 7941 | |
| 7942 | #ifdef HAVE_IPV6 |
| 7943 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 7944 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7945 | return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi); |
| 7946 | #else |
| 7947 | afi = AFI_IP; |
| 7948 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7949 | return bgp_show_community (vty, argv[0], argc-2, &argv[2], 0, afi, safi); |
| 7950 | #endif |
| 7951 | } |
| 7952 | |
| 7953 | ALIAS (show_bgp_view_afi_safi_community, |
| 7954 | show_bgp_view_afi_safi_community2_cmd, |
| 7955 | #ifdef HAVE_IPV6 |
| 7956 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7957 | #else |
| 7958 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7959 | #endif |
| 7960 | SHOW_STR |
| 7961 | BGP_STR |
| 7962 | "BGP view\n" |
| 7963 | "BGP view name\n" |
| 7964 | "Address family\n" |
| 7965 | #ifdef HAVE_IPV6 |
| 7966 | "Address family\n" |
| 7967 | #endif |
| 7968 | "Address family modifier\n" |
| 7969 | "Address family modifier\n" |
| 7970 | "Display routes matching the communities\n" |
| 7971 | "community number\n" |
| 7972 | "Do not send outside local AS (well-known community)\n" |
| 7973 | "Do not advertise to any peer (well-known community)\n" |
| 7974 | "Do not export to next AS (well-known community)\n" |
| 7975 | "community number\n" |
| 7976 | "Do not send outside local AS (well-known community)\n" |
| 7977 | "Do not advertise to any peer (well-known community)\n" |
| 7978 | "Do not export to next AS (well-known community)\n") |
| 7979 | |
| 7980 | ALIAS (show_bgp_view_afi_safi_community, |
| 7981 | show_bgp_view_afi_safi_community3_cmd, |
| 7982 | #ifdef HAVE_IPV6 |
| 7983 | "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)", |
| 7984 | #else |
| 7985 | "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)", |
| 7986 | #endif |
| 7987 | SHOW_STR |
| 7988 | BGP_STR |
| 7989 | "BGP view\n" |
| 7990 | "BGP view name\n" |
| 7991 | "Address family\n" |
| 7992 | #ifdef HAVE_IPV6 |
| 7993 | "Address family\n" |
| 7994 | #endif |
| 7995 | "Address family modifier\n" |
| 7996 | "Address family modifier\n" |
| 7997 | "Display routes matching the communities\n" |
| 7998 | "community number\n" |
| 7999 | "Do not send outside local AS (well-known community)\n" |
| 8000 | "Do not advertise to any peer (well-known community)\n" |
| 8001 | "Do not export to next AS (well-known community)\n" |
| 8002 | "community number\n" |
| 8003 | "Do not send outside local AS (well-known community)\n" |
| 8004 | "Do not advertise to any peer (well-known community)\n" |
| 8005 | "Do not export to next AS (well-known community)\n" |
| 8006 | "community number\n" |
| 8007 | "Do not send outside local AS (well-known community)\n" |
| 8008 | "Do not advertise to any peer (well-known community)\n" |
| 8009 | "Do not export to next AS (well-known community)\n") |
| 8010 | |
| 8011 | ALIAS (show_bgp_view_afi_safi_community, |
| 8012 | show_bgp_view_afi_safi_community4_cmd, |
| 8013 | #ifdef HAVE_IPV6 |
| 8014 | "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)", |
| 8015 | #else |
| 8016 | "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)", |
| 8017 | #endif |
| 8018 | SHOW_STR |
| 8019 | BGP_STR |
| 8020 | "BGP view\n" |
| 8021 | "BGP view name\n" |
| 8022 | "Address family\n" |
| 8023 | #ifdef HAVE_IPV6 |
| 8024 | "Address family\n" |
| 8025 | #endif |
| 8026 | "Address family modifier\n" |
| 8027 | "Address family modifier\n" |
| 8028 | "Display routes matching the communities\n" |
| 8029 | "community number\n" |
| 8030 | "Do not send outside local AS (well-known community)\n" |
| 8031 | "Do not advertise to any peer (well-known community)\n" |
| 8032 | "Do not export to next AS (well-known community)\n" |
| 8033 | "community number\n" |
| 8034 | "Do not send outside local AS (well-known community)\n" |
| 8035 | "Do not advertise to any peer (well-known community)\n" |
| 8036 | "Do not export to next AS (well-known community)\n" |
| 8037 | "community number\n" |
| 8038 | "Do not send outside local AS (well-known community)\n" |
| 8039 | "Do not advertise to any peer (well-known community)\n" |
| 8040 | "Do not export to next AS (well-known community)\n" |
| 8041 | "community number\n" |
| 8042 | "Do not send outside local AS (well-known community)\n" |
| 8043 | "Do not advertise to any peer (well-known community)\n" |
| 8044 | "Do not export to next AS (well-known community)\n") |
| 8045 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8046 | DEFUN (show_ip_bgp_community_exact, |
| 8047 | show_ip_bgp_community_exact_cmd, |
| 8048 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8049 | SHOW_STR |
| 8050 | IP_STR |
| 8051 | BGP_STR |
| 8052 | "Display routes matching the communities\n" |
| 8053 | "community number\n" |
| 8054 | "Do not send outside local AS (well-known community)\n" |
| 8055 | "Do not advertise to any peer (well-known community)\n" |
| 8056 | "Do not export to next AS (well-known community)\n" |
| 8057 | "Exact match of the communities") |
| 8058 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8059 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8060 | } |
| 8061 | |
| 8062 | ALIAS (show_ip_bgp_community_exact, |
| 8063 | show_ip_bgp_community2_exact_cmd, |
| 8064 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8065 | SHOW_STR |
| 8066 | IP_STR |
| 8067 | BGP_STR |
| 8068 | "Display routes matching the communities\n" |
| 8069 | "community number\n" |
| 8070 | "Do not send outside local AS (well-known community)\n" |
| 8071 | "Do not advertise to any peer (well-known community)\n" |
| 8072 | "Do not export to next AS (well-known community)\n" |
| 8073 | "community number\n" |
| 8074 | "Do not send outside local AS (well-known community)\n" |
| 8075 | "Do not advertise to any peer (well-known community)\n" |
| 8076 | "Do not export to next AS (well-known community)\n" |
| 8077 | "Exact match of the communities") |
| 8078 | |
| 8079 | ALIAS (show_ip_bgp_community_exact, |
| 8080 | show_ip_bgp_community3_exact_cmd, |
| 8081 | "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", |
| 8082 | SHOW_STR |
| 8083 | IP_STR |
| 8084 | BGP_STR |
| 8085 | "Display routes matching the communities\n" |
| 8086 | "community number\n" |
| 8087 | "Do not send outside local AS (well-known community)\n" |
| 8088 | "Do not advertise to any peer (well-known community)\n" |
| 8089 | "Do not export to next AS (well-known community)\n" |
| 8090 | "community number\n" |
| 8091 | "Do not send outside local AS (well-known community)\n" |
| 8092 | "Do not advertise to any peer (well-known community)\n" |
| 8093 | "Do not export to next AS (well-known community)\n" |
| 8094 | "community number\n" |
| 8095 | "Do not send outside local AS (well-known community)\n" |
| 8096 | "Do not advertise to any peer (well-known community)\n" |
| 8097 | "Do not export to next AS (well-known community)\n" |
| 8098 | "Exact match of the communities") |
| 8099 | |
| 8100 | ALIAS (show_ip_bgp_community_exact, |
| 8101 | show_ip_bgp_community4_exact_cmd, |
| 8102 | "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", |
| 8103 | SHOW_STR |
| 8104 | IP_STR |
| 8105 | BGP_STR |
| 8106 | "Display routes matching the communities\n" |
| 8107 | "community number\n" |
| 8108 | "Do not send outside local AS (well-known community)\n" |
| 8109 | "Do not advertise to any peer (well-known community)\n" |
| 8110 | "Do not export to next AS (well-known community)\n" |
| 8111 | "community number\n" |
| 8112 | "Do not send outside local AS (well-known community)\n" |
| 8113 | "Do not advertise to any peer (well-known community)\n" |
| 8114 | "Do not export to next AS (well-known community)\n" |
| 8115 | "community number\n" |
| 8116 | "Do not send outside local AS (well-known community)\n" |
| 8117 | "Do not advertise to any peer (well-known community)\n" |
| 8118 | "Do not export to next AS (well-known community)\n" |
| 8119 | "community number\n" |
| 8120 | "Do not send outside local AS (well-known community)\n" |
| 8121 | "Do not advertise to any peer (well-known community)\n" |
| 8122 | "Do not export to next AS (well-known community)\n" |
| 8123 | "Exact match of the communities") |
| 8124 | |
| 8125 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 8126 | show_ip_bgp_ipv4_community_exact_cmd, |
| 8127 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8128 | SHOW_STR |
| 8129 | IP_STR |
| 8130 | BGP_STR |
| 8131 | "Address family\n" |
| 8132 | "Address Family modifier\n" |
| 8133 | "Address Family modifier\n" |
| 8134 | "Display routes matching the communities\n" |
| 8135 | "community number\n" |
| 8136 | "Do not send outside local AS (well-known community)\n" |
| 8137 | "Do not advertise to any peer (well-known community)\n" |
| 8138 | "Do not export to next AS (well-known community)\n" |
| 8139 | "Exact match of the communities") |
| 8140 | { |
| 8141 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8142 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8143 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8144 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8145 | } |
| 8146 | |
| 8147 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8148 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 8149 | "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", |
| 8150 | SHOW_STR |
| 8151 | IP_STR |
| 8152 | BGP_STR |
| 8153 | "Address family\n" |
| 8154 | "Address Family modifier\n" |
| 8155 | "Address Family modifier\n" |
| 8156 | "Display routes matching the communities\n" |
| 8157 | "community number\n" |
| 8158 | "Do not send outside local AS (well-known community)\n" |
| 8159 | "Do not advertise to any peer (well-known community)\n" |
| 8160 | "Do not export to next AS (well-known community)\n" |
| 8161 | "community number\n" |
| 8162 | "Do not send outside local AS (well-known community)\n" |
| 8163 | "Do not advertise to any peer (well-known community)\n" |
| 8164 | "Do not export to next AS (well-known community)\n" |
| 8165 | "Exact match of the communities") |
| 8166 | |
| 8167 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8168 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 8169 | "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", |
| 8170 | SHOW_STR |
| 8171 | IP_STR |
| 8172 | BGP_STR |
| 8173 | "Address family\n" |
| 8174 | "Address Family modifier\n" |
| 8175 | "Address Family modifier\n" |
| 8176 | "Display routes matching the communities\n" |
| 8177 | "community number\n" |
| 8178 | "Do not send outside local AS (well-known community)\n" |
| 8179 | "Do not advertise to any peer (well-known community)\n" |
| 8180 | "Do not export to next AS (well-known community)\n" |
| 8181 | "community number\n" |
| 8182 | "Do not send outside local AS (well-known community)\n" |
| 8183 | "Do not advertise to any peer (well-known community)\n" |
| 8184 | "Do not export to next AS (well-known community)\n" |
| 8185 | "community number\n" |
| 8186 | "Do not send outside local AS (well-known community)\n" |
| 8187 | "Do not advertise to any peer (well-known community)\n" |
| 8188 | "Do not export to next AS (well-known community)\n" |
| 8189 | "Exact match of the communities") |
| 8190 | |
| 8191 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8192 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 8193 | "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", |
| 8194 | SHOW_STR |
| 8195 | IP_STR |
| 8196 | BGP_STR |
| 8197 | "Address family\n" |
| 8198 | "Address Family modifier\n" |
| 8199 | "Address Family modifier\n" |
| 8200 | "Display routes matching the communities\n" |
| 8201 | "community number\n" |
| 8202 | "Do not send outside local AS (well-known community)\n" |
| 8203 | "Do not advertise to any peer (well-known community)\n" |
| 8204 | "Do not export to next AS (well-known community)\n" |
| 8205 | "community number\n" |
| 8206 | "Do not send outside local AS (well-known community)\n" |
| 8207 | "Do not advertise to any peer (well-known community)\n" |
| 8208 | "Do not export to next AS (well-known community)\n" |
| 8209 | "community number\n" |
| 8210 | "Do not send outside local AS (well-known community)\n" |
| 8211 | "Do not advertise to any peer (well-known community)\n" |
| 8212 | "Do not export to next AS (well-known community)\n" |
| 8213 | "community number\n" |
| 8214 | "Do not send outside local AS (well-known community)\n" |
| 8215 | "Do not advertise to any peer (well-known community)\n" |
| 8216 | "Do not export to next AS (well-known community)\n" |
| 8217 | "Exact match of the communities") |
| 8218 | |
| 8219 | #ifdef HAVE_IPV6 |
| 8220 | DEFUN (show_bgp_community, |
| 8221 | show_bgp_community_cmd, |
| 8222 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8223 | SHOW_STR |
| 8224 | BGP_STR |
| 8225 | "Display routes matching the communities\n" |
| 8226 | "community number\n" |
| 8227 | "Do not send outside local AS (well-known community)\n" |
| 8228 | "Do not advertise to any peer (well-known community)\n" |
| 8229 | "Do not export to next AS (well-known community)\n") |
| 8230 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8231 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8232 | } |
| 8233 | |
| 8234 | ALIAS (show_bgp_community, |
| 8235 | show_bgp_ipv6_community_cmd, |
| 8236 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 8237 | SHOW_STR |
| 8238 | BGP_STR |
| 8239 | "Address family\n" |
| 8240 | "Display routes matching the communities\n" |
| 8241 | "community number\n" |
| 8242 | "Do not send outside local AS (well-known community)\n" |
| 8243 | "Do not advertise to any peer (well-known community)\n" |
| 8244 | "Do not export to next AS (well-known community)\n") |
| 8245 | |
| 8246 | ALIAS (show_bgp_community, |
| 8247 | show_bgp_community2_cmd, |
| 8248 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8249 | SHOW_STR |
| 8250 | BGP_STR |
| 8251 | "Display routes matching the communities\n" |
| 8252 | "community number\n" |
| 8253 | "Do not send outside local AS (well-known community)\n" |
| 8254 | "Do not advertise to any peer (well-known community)\n" |
| 8255 | "Do not export to next AS (well-known community)\n" |
| 8256 | "community number\n" |
| 8257 | "Do not send outside local AS (well-known community)\n" |
| 8258 | "Do not advertise to any peer (well-known community)\n" |
| 8259 | "Do not export to next AS (well-known community)\n") |
| 8260 | |
| 8261 | ALIAS (show_bgp_community, |
| 8262 | show_bgp_ipv6_community2_cmd, |
| 8263 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8264 | SHOW_STR |
| 8265 | BGP_STR |
| 8266 | "Address family\n" |
| 8267 | "Display routes matching the communities\n" |
| 8268 | "community number\n" |
| 8269 | "Do not send outside local AS (well-known community)\n" |
| 8270 | "Do not advertise to any peer (well-known community)\n" |
| 8271 | "Do not export to next AS (well-known community)\n" |
| 8272 | "community number\n" |
| 8273 | "Do not send outside local AS (well-known community)\n" |
| 8274 | "Do not advertise to any peer (well-known community)\n" |
| 8275 | "Do not export to next AS (well-known community)\n") |
| 8276 | |
| 8277 | ALIAS (show_bgp_community, |
| 8278 | show_bgp_community3_cmd, |
| 8279 | "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)", |
| 8280 | SHOW_STR |
| 8281 | BGP_STR |
| 8282 | "Display routes matching the communities\n" |
| 8283 | "community number\n" |
| 8284 | "Do not send outside local AS (well-known community)\n" |
| 8285 | "Do not advertise to any peer (well-known community)\n" |
| 8286 | "Do not export to next AS (well-known community)\n" |
| 8287 | "community number\n" |
| 8288 | "Do not send outside local AS (well-known community)\n" |
| 8289 | "Do not advertise to any peer (well-known community)\n" |
| 8290 | "Do not export to next AS (well-known community)\n" |
| 8291 | "community number\n" |
| 8292 | "Do not send outside local AS (well-known community)\n" |
| 8293 | "Do not advertise to any peer (well-known community)\n" |
| 8294 | "Do not export to next AS (well-known community)\n") |
| 8295 | |
| 8296 | ALIAS (show_bgp_community, |
| 8297 | show_bgp_ipv6_community3_cmd, |
| 8298 | "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)", |
| 8299 | SHOW_STR |
| 8300 | BGP_STR |
| 8301 | "Address family\n" |
| 8302 | "Display routes matching the communities\n" |
| 8303 | "community number\n" |
| 8304 | "Do not send outside local AS (well-known community)\n" |
| 8305 | "Do not advertise to any peer (well-known community)\n" |
| 8306 | "Do not export to next AS (well-known community)\n" |
| 8307 | "community number\n" |
| 8308 | "Do not send outside local AS (well-known community)\n" |
| 8309 | "Do not advertise to any peer (well-known community)\n" |
| 8310 | "Do not export to next AS (well-known community)\n" |
| 8311 | "community number\n" |
| 8312 | "Do not send outside local AS (well-known community)\n" |
| 8313 | "Do not advertise to any peer (well-known community)\n" |
| 8314 | "Do not export to next AS (well-known community)\n") |
| 8315 | |
| 8316 | ALIAS (show_bgp_community, |
| 8317 | show_bgp_community4_cmd, |
| 8318 | "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)", |
| 8319 | SHOW_STR |
| 8320 | BGP_STR |
| 8321 | "Display routes matching the communities\n" |
| 8322 | "community number\n" |
| 8323 | "Do not send outside local AS (well-known community)\n" |
| 8324 | "Do not advertise to any peer (well-known community)\n" |
| 8325 | "Do not export to next AS (well-known community)\n" |
| 8326 | "community number\n" |
| 8327 | "Do not send outside local AS (well-known community)\n" |
| 8328 | "Do not advertise to any peer (well-known community)\n" |
| 8329 | "Do not export to next AS (well-known community)\n" |
| 8330 | "community number\n" |
| 8331 | "Do not send outside local AS (well-known community)\n" |
| 8332 | "Do not advertise to any peer (well-known community)\n" |
| 8333 | "Do not export to next AS (well-known community)\n" |
| 8334 | "community number\n" |
| 8335 | "Do not send outside local AS (well-known community)\n" |
| 8336 | "Do not advertise to any peer (well-known community)\n" |
| 8337 | "Do not export to next AS (well-known community)\n") |
| 8338 | |
| 8339 | ALIAS (show_bgp_community, |
| 8340 | show_bgp_ipv6_community4_cmd, |
| 8341 | "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)", |
| 8342 | SHOW_STR |
| 8343 | BGP_STR |
| 8344 | "Address family\n" |
| 8345 | "Display routes matching the communities\n" |
| 8346 | "community number\n" |
| 8347 | "Do not send outside local AS (well-known community)\n" |
| 8348 | "Do not advertise to any peer (well-known community)\n" |
| 8349 | "Do not export to next AS (well-known community)\n" |
| 8350 | "community number\n" |
| 8351 | "Do not send outside local AS (well-known community)\n" |
| 8352 | "Do not advertise to any peer (well-known community)\n" |
| 8353 | "Do not export to next AS (well-known community)\n" |
| 8354 | "community number\n" |
| 8355 | "Do not send outside local AS (well-known community)\n" |
| 8356 | "Do not advertise to any peer (well-known community)\n" |
| 8357 | "Do not export to next AS (well-known community)\n" |
| 8358 | "community number\n" |
| 8359 | "Do not send outside local AS (well-known community)\n" |
| 8360 | "Do not advertise to any peer (well-known community)\n" |
| 8361 | "Do not export to next AS (well-known community)\n") |
| 8362 | |
| 8363 | /* old command */ |
| 8364 | DEFUN (show_ipv6_bgp_community, |
| 8365 | show_ipv6_bgp_community_cmd, |
| 8366 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8367 | SHOW_STR |
| 8368 | IPV6_STR |
| 8369 | BGP_STR |
| 8370 | "Display routes matching the communities\n" |
| 8371 | "community number\n" |
| 8372 | "Do not send outside local AS (well-known community)\n" |
| 8373 | "Do not advertise to any peer (well-known community)\n" |
| 8374 | "Do not export to next AS (well-known community)\n") |
| 8375 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8376 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8377 | } |
| 8378 | |
| 8379 | /* old command */ |
| 8380 | ALIAS (show_ipv6_bgp_community, |
| 8381 | show_ipv6_bgp_community2_cmd, |
| 8382 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8383 | SHOW_STR |
| 8384 | IPV6_STR |
| 8385 | BGP_STR |
| 8386 | "Display routes matching the communities\n" |
| 8387 | "community number\n" |
| 8388 | "Do not send outside local AS (well-known community)\n" |
| 8389 | "Do not advertise to any peer (well-known community)\n" |
| 8390 | "Do not export to next AS (well-known community)\n" |
| 8391 | "community number\n" |
| 8392 | "Do not send outside local AS (well-known community)\n" |
| 8393 | "Do not advertise to any peer (well-known community)\n" |
| 8394 | "Do not export to next AS (well-known community)\n") |
| 8395 | |
| 8396 | /* old command */ |
| 8397 | ALIAS (show_ipv6_bgp_community, |
| 8398 | show_ipv6_bgp_community3_cmd, |
| 8399 | "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)", |
| 8400 | SHOW_STR |
| 8401 | IPV6_STR |
| 8402 | BGP_STR |
| 8403 | "Display routes matching the communities\n" |
| 8404 | "community number\n" |
| 8405 | "Do not send outside local AS (well-known community)\n" |
| 8406 | "Do not advertise to any peer (well-known community)\n" |
| 8407 | "Do not export to next AS (well-known community)\n" |
| 8408 | "community number\n" |
| 8409 | "Do not send outside local AS (well-known community)\n" |
| 8410 | "Do not advertise to any peer (well-known community)\n" |
| 8411 | "Do not export to next AS (well-known community)\n" |
| 8412 | "community number\n" |
| 8413 | "Do not send outside local AS (well-known community)\n" |
| 8414 | "Do not advertise to any peer (well-known community)\n" |
| 8415 | "Do not export to next AS (well-known community)\n") |
| 8416 | |
| 8417 | /* old command */ |
| 8418 | ALIAS (show_ipv6_bgp_community, |
| 8419 | show_ipv6_bgp_community4_cmd, |
| 8420 | "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)", |
| 8421 | SHOW_STR |
| 8422 | IPV6_STR |
| 8423 | BGP_STR |
| 8424 | "Display routes matching the communities\n" |
| 8425 | "community number\n" |
| 8426 | "Do not send outside local AS (well-known community)\n" |
| 8427 | "Do not advertise to any peer (well-known community)\n" |
| 8428 | "Do not export to next AS (well-known community)\n" |
| 8429 | "community number\n" |
| 8430 | "Do not send outside local AS (well-known community)\n" |
| 8431 | "Do not advertise to any peer (well-known community)\n" |
| 8432 | "Do not export to next AS (well-known community)\n" |
| 8433 | "community number\n" |
| 8434 | "Do not send outside local AS (well-known community)\n" |
| 8435 | "Do not advertise to any peer (well-known community)\n" |
| 8436 | "Do not export to next AS (well-known community)\n" |
| 8437 | "community number\n" |
| 8438 | "Do not send outside local AS (well-known community)\n" |
| 8439 | "Do not advertise to any peer (well-known community)\n" |
| 8440 | "Do not export to next AS (well-known community)\n") |
| 8441 | |
| 8442 | DEFUN (show_bgp_community_exact, |
| 8443 | show_bgp_community_exact_cmd, |
| 8444 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8445 | SHOW_STR |
| 8446 | BGP_STR |
| 8447 | "Display routes matching the communities\n" |
| 8448 | "community number\n" |
| 8449 | "Do not send outside local AS (well-known community)\n" |
| 8450 | "Do not advertise to any peer (well-known community)\n" |
| 8451 | "Do not export to next AS (well-known community)\n" |
| 8452 | "Exact match of the communities") |
| 8453 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8454 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8455 | } |
| 8456 | |
| 8457 | ALIAS (show_bgp_community_exact, |
| 8458 | show_bgp_ipv6_community_exact_cmd, |
| 8459 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8460 | SHOW_STR |
| 8461 | BGP_STR |
| 8462 | "Address family\n" |
| 8463 | "Display routes matching the communities\n" |
| 8464 | "community number\n" |
| 8465 | "Do not send outside local AS (well-known community)\n" |
| 8466 | "Do not advertise to any peer (well-known community)\n" |
| 8467 | "Do not export to next AS (well-known community)\n" |
| 8468 | "Exact match of the communities") |
| 8469 | |
| 8470 | ALIAS (show_bgp_community_exact, |
| 8471 | show_bgp_community2_exact_cmd, |
| 8472 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8473 | SHOW_STR |
| 8474 | BGP_STR |
| 8475 | "Display routes matching the communities\n" |
| 8476 | "community number\n" |
| 8477 | "Do not send outside local AS (well-known community)\n" |
| 8478 | "Do not advertise to any peer (well-known community)\n" |
| 8479 | "Do not export to next AS (well-known community)\n" |
| 8480 | "community number\n" |
| 8481 | "Do not send outside local AS (well-known community)\n" |
| 8482 | "Do not advertise to any peer (well-known community)\n" |
| 8483 | "Do not export to next AS (well-known community)\n" |
| 8484 | "Exact match of the communities") |
| 8485 | |
| 8486 | ALIAS (show_bgp_community_exact, |
| 8487 | show_bgp_ipv6_community2_exact_cmd, |
| 8488 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8489 | SHOW_STR |
| 8490 | BGP_STR |
| 8491 | "Address family\n" |
| 8492 | "Display routes matching the communities\n" |
| 8493 | "community number\n" |
| 8494 | "Do not send outside local AS (well-known community)\n" |
| 8495 | "Do not advertise to any peer (well-known community)\n" |
| 8496 | "Do not export to next AS (well-known community)\n" |
| 8497 | "community number\n" |
| 8498 | "Do not send outside local AS (well-known community)\n" |
| 8499 | "Do not advertise to any peer (well-known community)\n" |
| 8500 | "Do not export to next AS (well-known community)\n" |
| 8501 | "Exact match of the communities") |
| 8502 | |
| 8503 | ALIAS (show_bgp_community_exact, |
| 8504 | show_bgp_community3_exact_cmd, |
| 8505 | "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", |
| 8506 | SHOW_STR |
| 8507 | BGP_STR |
| 8508 | "Display routes matching the communities\n" |
| 8509 | "community number\n" |
| 8510 | "Do not send outside local AS (well-known community)\n" |
| 8511 | "Do not advertise to any peer (well-known community)\n" |
| 8512 | "Do not export to next AS (well-known community)\n" |
| 8513 | "community number\n" |
| 8514 | "Do not send outside local AS (well-known community)\n" |
| 8515 | "Do not advertise to any peer (well-known community)\n" |
| 8516 | "Do not export to next AS (well-known community)\n" |
| 8517 | "community number\n" |
| 8518 | "Do not send outside local AS (well-known community)\n" |
| 8519 | "Do not advertise to any peer (well-known community)\n" |
| 8520 | "Do not export to next AS (well-known community)\n" |
| 8521 | "Exact match of the communities") |
| 8522 | |
| 8523 | ALIAS (show_bgp_community_exact, |
| 8524 | show_bgp_ipv6_community3_exact_cmd, |
| 8525 | "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", |
| 8526 | SHOW_STR |
| 8527 | BGP_STR |
| 8528 | "Address family\n" |
| 8529 | "Display routes matching the communities\n" |
| 8530 | "community number\n" |
| 8531 | "Do not send outside local AS (well-known community)\n" |
| 8532 | "Do not advertise to any peer (well-known community)\n" |
| 8533 | "Do not export to next AS (well-known community)\n" |
| 8534 | "community number\n" |
| 8535 | "Do not send outside local AS (well-known community)\n" |
| 8536 | "Do not advertise to any peer (well-known community)\n" |
| 8537 | "Do not export to next AS (well-known community)\n" |
| 8538 | "community number\n" |
| 8539 | "Do not send outside local AS (well-known community)\n" |
| 8540 | "Do not advertise to any peer (well-known community)\n" |
| 8541 | "Do not export to next AS (well-known community)\n" |
| 8542 | "Exact match of the communities") |
| 8543 | |
| 8544 | ALIAS (show_bgp_community_exact, |
| 8545 | show_bgp_community4_exact_cmd, |
| 8546 | "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", |
| 8547 | SHOW_STR |
| 8548 | BGP_STR |
| 8549 | "Display routes matching the communities\n" |
| 8550 | "community number\n" |
| 8551 | "Do not send outside local AS (well-known community)\n" |
| 8552 | "Do not advertise to any peer (well-known community)\n" |
| 8553 | "Do not export to next AS (well-known community)\n" |
| 8554 | "community number\n" |
| 8555 | "Do not send outside local AS (well-known community)\n" |
| 8556 | "Do not advertise to any peer (well-known community)\n" |
| 8557 | "Do not export to next AS (well-known community)\n" |
| 8558 | "community number\n" |
| 8559 | "Do not send outside local AS (well-known community)\n" |
| 8560 | "Do not advertise to any peer (well-known community)\n" |
| 8561 | "Do not export to next AS (well-known community)\n" |
| 8562 | "community number\n" |
| 8563 | "Do not send outside local AS (well-known community)\n" |
| 8564 | "Do not advertise to any peer (well-known community)\n" |
| 8565 | "Do not export to next AS (well-known community)\n" |
| 8566 | "Exact match of the communities") |
| 8567 | |
| 8568 | ALIAS (show_bgp_community_exact, |
| 8569 | show_bgp_ipv6_community4_exact_cmd, |
| 8570 | "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", |
| 8571 | SHOW_STR |
| 8572 | BGP_STR |
| 8573 | "Address family\n" |
| 8574 | "Display routes matching the communities\n" |
| 8575 | "community number\n" |
| 8576 | "Do not send outside local AS (well-known community)\n" |
| 8577 | "Do not advertise to any peer (well-known community)\n" |
| 8578 | "Do not export to next AS (well-known community)\n" |
| 8579 | "community number\n" |
| 8580 | "Do not send outside local AS (well-known community)\n" |
| 8581 | "Do not advertise to any peer (well-known community)\n" |
| 8582 | "Do not export to next AS (well-known community)\n" |
| 8583 | "community number\n" |
| 8584 | "Do not send outside local AS (well-known community)\n" |
| 8585 | "Do not advertise to any peer (well-known community)\n" |
| 8586 | "Do not export to next AS (well-known community)\n" |
| 8587 | "community number\n" |
| 8588 | "Do not send outside local AS (well-known community)\n" |
| 8589 | "Do not advertise to any peer (well-known community)\n" |
| 8590 | "Do not export to next AS (well-known community)\n" |
| 8591 | "Exact match of the communities") |
| 8592 | |
| 8593 | /* old command */ |
| 8594 | DEFUN (show_ipv6_bgp_community_exact, |
| 8595 | show_ipv6_bgp_community_exact_cmd, |
| 8596 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8597 | SHOW_STR |
| 8598 | IPV6_STR |
| 8599 | BGP_STR |
| 8600 | "Display routes matching the communities\n" |
| 8601 | "community number\n" |
| 8602 | "Do not send outside local AS (well-known community)\n" |
| 8603 | "Do not advertise to any peer (well-known community)\n" |
| 8604 | "Do not export to next AS (well-known community)\n" |
| 8605 | "Exact match of the communities") |
| 8606 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8607 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8608 | } |
| 8609 | |
| 8610 | /* old command */ |
| 8611 | ALIAS (show_ipv6_bgp_community_exact, |
| 8612 | show_ipv6_bgp_community2_exact_cmd, |
| 8613 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8614 | SHOW_STR |
| 8615 | IPV6_STR |
| 8616 | BGP_STR |
| 8617 | "Display routes matching the communities\n" |
| 8618 | "community number\n" |
| 8619 | "Do not send outside local AS (well-known community)\n" |
| 8620 | "Do not advertise to any peer (well-known community)\n" |
| 8621 | "Do not export to next AS (well-known community)\n" |
| 8622 | "community number\n" |
| 8623 | "Do not send outside local AS (well-known community)\n" |
| 8624 | "Do not advertise to any peer (well-known community)\n" |
| 8625 | "Do not export to next AS (well-known community)\n" |
| 8626 | "Exact match of the communities") |
| 8627 | |
| 8628 | /* old command */ |
| 8629 | ALIAS (show_ipv6_bgp_community_exact, |
| 8630 | show_ipv6_bgp_community3_exact_cmd, |
| 8631 | "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", |
| 8632 | SHOW_STR |
| 8633 | IPV6_STR |
| 8634 | BGP_STR |
| 8635 | "Display routes matching the communities\n" |
| 8636 | "community number\n" |
| 8637 | "Do not send outside local AS (well-known community)\n" |
| 8638 | "Do not advertise to any peer (well-known community)\n" |
| 8639 | "Do not export to next AS (well-known community)\n" |
| 8640 | "community number\n" |
| 8641 | "Do not send outside local AS (well-known community)\n" |
| 8642 | "Do not advertise to any peer (well-known community)\n" |
| 8643 | "Do not export to next AS (well-known community)\n" |
| 8644 | "community number\n" |
| 8645 | "Do not send outside local AS (well-known community)\n" |
| 8646 | "Do not advertise to any peer (well-known community)\n" |
| 8647 | "Do not export to next AS (well-known community)\n" |
| 8648 | "Exact match of the communities") |
| 8649 | |
| 8650 | /* old command */ |
| 8651 | ALIAS (show_ipv6_bgp_community_exact, |
| 8652 | show_ipv6_bgp_community4_exact_cmd, |
| 8653 | "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", |
| 8654 | SHOW_STR |
| 8655 | IPV6_STR |
| 8656 | BGP_STR |
| 8657 | "Display routes matching the communities\n" |
| 8658 | "community number\n" |
| 8659 | "Do not send outside local AS (well-known community)\n" |
| 8660 | "Do not advertise to any peer (well-known community)\n" |
| 8661 | "Do not export to next AS (well-known community)\n" |
| 8662 | "community number\n" |
| 8663 | "Do not send outside local AS (well-known community)\n" |
| 8664 | "Do not advertise to any peer (well-known community)\n" |
| 8665 | "Do not export to next AS (well-known community)\n" |
| 8666 | "community number\n" |
| 8667 | "Do not send outside local AS (well-known community)\n" |
| 8668 | "Do not advertise to any peer (well-known community)\n" |
| 8669 | "Do not export to next AS (well-known community)\n" |
| 8670 | "community number\n" |
| 8671 | "Do not send outside local AS (well-known community)\n" |
| 8672 | "Do not advertise to any peer (well-known community)\n" |
| 8673 | "Do not export to next AS (well-known community)\n" |
| 8674 | "Exact match of the communities") |
| 8675 | |
| 8676 | /* old command */ |
| 8677 | DEFUN (show_ipv6_mbgp_community, |
| 8678 | show_ipv6_mbgp_community_cmd, |
| 8679 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8680 | SHOW_STR |
| 8681 | IPV6_STR |
| 8682 | MBGP_STR |
| 8683 | "Display routes matching the communities\n" |
| 8684 | "community number\n" |
| 8685 | "Do not send outside local AS (well-known community)\n" |
| 8686 | "Do not advertise to any peer (well-known community)\n" |
| 8687 | "Do not export to next AS (well-known community)\n") |
| 8688 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8689 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8690 | } |
| 8691 | |
| 8692 | /* old command */ |
| 8693 | ALIAS (show_ipv6_mbgp_community, |
| 8694 | show_ipv6_mbgp_community2_cmd, |
| 8695 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8696 | SHOW_STR |
| 8697 | IPV6_STR |
| 8698 | MBGP_STR |
| 8699 | "Display routes matching the communities\n" |
| 8700 | "community number\n" |
| 8701 | "Do not send outside local AS (well-known community)\n" |
| 8702 | "Do not advertise to any peer (well-known community)\n" |
| 8703 | "Do not export to next AS (well-known community)\n" |
| 8704 | "community number\n" |
| 8705 | "Do not send outside local AS (well-known community)\n" |
| 8706 | "Do not advertise to any peer (well-known community)\n" |
| 8707 | "Do not export to next AS (well-known community)\n") |
| 8708 | |
| 8709 | /* old command */ |
| 8710 | ALIAS (show_ipv6_mbgp_community, |
| 8711 | show_ipv6_mbgp_community3_cmd, |
| 8712 | "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)", |
| 8713 | SHOW_STR |
| 8714 | IPV6_STR |
| 8715 | MBGP_STR |
| 8716 | "Display routes matching the communities\n" |
| 8717 | "community number\n" |
| 8718 | "Do not send outside local AS (well-known community)\n" |
| 8719 | "Do not advertise to any peer (well-known community)\n" |
| 8720 | "Do not export to next AS (well-known community)\n" |
| 8721 | "community number\n" |
| 8722 | "Do not send outside local AS (well-known community)\n" |
| 8723 | "Do not advertise to any peer (well-known community)\n" |
| 8724 | "Do not export to next AS (well-known community)\n" |
| 8725 | "community number\n" |
| 8726 | "Do not send outside local AS (well-known community)\n" |
| 8727 | "Do not advertise to any peer (well-known community)\n" |
| 8728 | "Do not export to next AS (well-known community)\n") |
| 8729 | |
| 8730 | /* old command */ |
| 8731 | ALIAS (show_ipv6_mbgp_community, |
| 8732 | show_ipv6_mbgp_community4_cmd, |
| 8733 | "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)", |
| 8734 | SHOW_STR |
| 8735 | IPV6_STR |
| 8736 | MBGP_STR |
| 8737 | "Display routes matching the communities\n" |
| 8738 | "community number\n" |
| 8739 | "Do not send outside local AS (well-known community)\n" |
| 8740 | "Do not advertise to any peer (well-known community)\n" |
| 8741 | "Do not export to next AS (well-known community)\n" |
| 8742 | "community number\n" |
| 8743 | "Do not send outside local AS (well-known community)\n" |
| 8744 | "Do not advertise to any peer (well-known community)\n" |
| 8745 | "Do not export to next AS (well-known community)\n" |
| 8746 | "community number\n" |
| 8747 | "Do not send outside local AS (well-known community)\n" |
| 8748 | "Do not advertise to any peer (well-known community)\n" |
| 8749 | "Do not export to next AS (well-known community)\n" |
| 8750 | "community number\n" |
| 8751 | "Do not send outside local AS (well-known community)\n" |
| 8752 | "Do not advertise to any peer (well-known community)\n" |
| 8753 | "Do not export to next AS (well-known community)\n") |
| 8754 | |
| 8755 | /* old command */ |
| 8756 | DEFUN (show_ipv6_mbgp_community_exact, |
| 8757 | show_ipv6_mbgp_community_exact_cmd, |
| 8758 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8759 | SHOW_STR |
| 8760 | IPV6_STR |
| 8761 | MBGP_STR |
| 8762 | "Display routes matching the communities\n" |
| 8763 | "community number\n" |
| 8764 | "Do not send outside local AS (well-known community)\n" |
| 8765 | "Do not advertise to any peer (well-known community)\n" |
| 8766 | "Do not export to next AS (well-known community)\n" |
| 8767 | "Exact match of the communities") |
| 8768 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8769 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8770 | } |
| 8771 | |
| 8772 | /* old command */ |
| 8773 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8774 | show_ipv6_mbgp_community2_exact_cmd, |
| 8775 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8776 | SHOW_STR |
| 8777 | IPV6_STR |
| 8778 | MBGP_STR |
| 8779 | "Display routes matching the communities\n" |
| 8780 | "community number\n" |
| 8781 | "Do not send outside local AS (well-known community)\n" |
| 8782 | "Do not advertise to any peer (well-known community)\n" |
| 8783 | "Do not export to next AS (well-known community)\n" |
| 8784 | "community number\n" |
| 8785 | "Do not send outside local AS (well-known community)\n" |
| 8786 | "Do not advertise to any peer (well-known community)\n" |
| 8787 | "Do not export to next AS (well-known community)\n" |
| 8788 | "Exact match of the communities") |
| 8789 | |
| 8790 | /* old command */ |
| 8791 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8792 | show_ipv6_mbgp_community3_exact_cmd, |
| 8793 | "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", |
| 8794 | SHOW_STR |
| 8795 | IPV6_STR |
| 8796 | MBGP_STR |
| 8797 | "Display routes matching the communities\n" |
| 8798 | "community number\n" |
| 8799 | "Do not send outside local AS (well-known community)\n" |
| 8800 | "Do not advertise to any peer (well-known community)\n" |
| 8801 | "Do not export to next AS (well-known community)\n" |
| 8802 | "community number\n" |
| 8803 | "Do not send outside local AS (well-known community)\n" |
| 8804 | "Do not advertise to any peer (well-known community)\n" |
| 8805 | "Do not export to next AS (well-known community)\n" |
| 8806 | "community number\n" |
| 8807 | "Do not send outside local AS (well-known community)\n" |
| 8808 | "Do not advertise to any peer (well-known community)\n" |
| 8809 | "Do not export to next AS (well-known community)\n" |
| 8810 | "Exact match of the communities") |
| 8811 | |
| 8812 | /* old command */ |
| 8813 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8814 | show_ipv6_mbgp_community4_exact_cmd, |
| 8815 | "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", |
| 8816 | SHOW_STR |
| 8817 | IPV6_STR |
| 8818 | MBGP_STR |
| 8819 | "Display routes matching the communities\n" |
| 8820 | "community number\n" |
| 8821 | "Do not send outside local AS (well-known community)\n" |
| 8822 | "Do not advertise to any peer (well-known community)\n" |
| 8823 | "Do not export to next AS (well-known community)\n" |
| 8824 | "community number\n" |
| 8825 | "Do not send outside local AS (well-known community)\n" |
| 8826 | "Do not advertise to any peer (well-known community)\n" |
| 8827 | "Do not export to next AS (well-known community)\n" |
| 8828 | "community number\n" |
| 8829 | "Do not send outside local AS (well-known community)\n" |
| 8830 | "Do not advertise to any peer (well-known community)\n" |
| 8831 | "Do not export to next AS (well-known community)\n" |
| 8832 | "community number\n" |
| 8833 | "Do not send outside local AS (well-known community)\n" |
| 8834 | "Do not advertise to any peer (well-known community)\n" |
| 8835 | "Do not export to next AS (well-known community)\n" |
| 8836 | "Exact match of the communities") |
| 8837 | #endif /* HAVE_IPV6 */ |
| 8838 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8839 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8840 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 8841 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8842 | { |
| 8843 | struct community_list *list; |
| 8844 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8845 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8846 | if (list == NULL) |
| 8847 | { |
| 8848 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 8849 | VTY_NEWLINE); |
| 8850 | return CMD_WARNING; |
| 8851 | } |
| 8852 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8853 | return bgp_show (vty, NULL, afi, safi, |
| 8854 | (exact ? bgp_show_type_community_list_exact : |
| 8855 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8856 | } |
| 8857 | |
| 8858 | DEFUN (show_ip_bgp_community_list, |
| 8859 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8860 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8861 | SHOW_STR |
| 8862 | IP_STR |
| 8863 | BGP_STR |
| 8864 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8865 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8866 | "community-list name\n") |
| 8867 | { |
| 8868 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 8869 | } |
| 8870 | |
| 8871 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 8872 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8873 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8874 | SHOW_STR |
| 8875 | IP_STR |
| 8876 | BGP_STR |
| 8877 | "Address family\n" |
| 8878 | "Address Family modifier\n" |
| 8879 | "Address Family modifier\n" |
| 8880 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8881 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8882 | "community-list name\n") |
| 8883 | { |
| 8884 | if (strncmp (argv[0], "m", 1) == 0) |
| 8885 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 8886 | |
| 8887 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 8888 | } |
| 8889 | |
| 8890 | DEFUN (show_ip_bgp_community_list_exact, |
| 8891 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8892 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8893 | SHOW_STR |
| 8894 | IP_STR |
| 8895 | BGP_STR |
| 8896 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8897 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8898 | "community-list name\n" |
| 8899 | "Exact match of the communities\n") |
| 8900 | { |
| 8901 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 8902 | } |
| 8903 | |
| 8904 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 8905 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8906 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8907 | SHOW_STR |
| 8908 | IP_STR |
| 8909 | BGP_STR |
| 8910 | "Address family\n" |
| 8911 | "Address Family modifier\n" |
| 8912 | "Address Family modifier\n" |
| 8913 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8914 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8915 | "community-list name\n" |
| 8916 | "Exact match of the communities\n") |
| 8917 | { |
| 8918 | if (strncmp (argv[0], "m", 1) == 0) |
| 8919 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 8920 | |
| 8921 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 8922 | } |
| 8923 | |
| 8924 | #ifdef HAVE_IPV6 |
| 8925 | DEFUN (show_bgp_community_list, |
| 8926 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8927 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8928 | SHOW_STR |
| 8929 | BGP_STR |
| 8930 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8931 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8932 | "community-list name\n") |
| 8933 | { |
| 8934 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8935 | } |
| 8936 | |
| 8937 | ALIAS (show_bgp_community_list, |
| 8938 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8939 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8940 | SHOW_STR |
| 8941 | BGP_STR |
| 8942 | "Address family\n" |
| 8943 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8944 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 8945 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8946 | |
| 8947 | /* old command */ |
| 8948 | DEFUN (show_ipv6_bgp_community_list, |
| 8949 | show_ipv6_bgp_community_list_cmd, |
| 8950 | "show ipv6 bgp community-list WORD", |
| 8951 | SHOW_STR |
| 8952 | IPV6_STR |
| 8953 | BGP_STR |
| 8954 | "Display routes matching the community-list\n" |
| 8955 | "community-list name\n") |
| 8956 | { |
| 8957 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8958 | } |
| 8959 | |
| 8960 | /* old command */ |
| 8961 | DEFUN (show_ipv6_mbgp_community_list, |
| 8962 | show_ipv6_mbgp_community_list_cmd, |
| 8963 | "show ipv6 mbgp community-list WORD", |
| 8964 | SHOW_STR |
| 8965 | IPV6_STR |
| 8966 | MBGP_STR |
| 8967 | "Display routes matching the community-list\n" |
| 8968 | "community-list name\n") |
| 8969 | { |
| 8970 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 8971 | } |
| 8972 | |
| 8973 | DEFUN (show_bgp_community_list_exact, |
| 8974 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8975 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8976 | SHOW_STR |
| 8977 | BGP_STR |
| 8978 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8979 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8980 | "community-list name\n" |
| 8981 | "Exact match of the communities\n") |
| 8982 | { |
| 8983 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8984 | } |
| 8985 | |
| 8986 | ALIAS (show_bgp_community_list_exact, |
| 8987 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8988 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8989 | SHOW_STR |
| 8990 | BGP_STR |
| 8991 | "Address family\n" |
| 8992 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8993 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8994 | "community-list name\n" |
| 8995 | "Exact match of the communities\n") |
| 8996 | |
| 8997 | /* old command */ |
| 8998 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 8999 | show_ipv6_bgp_community_list_exact_cmd, |
| 9000 | "show ipv6 bgp community-list WORD exact-match", |
| 9001 | SHOW_STR |
| 9002 | IPV6_STR |
| 9003 | BGP_STR |
| 9004 | "Display routes matching the community-list\n" |
| 9005 | "community-list name\n" |
| 9006 | "Exact match of the communities\n") |
| 9007 | { |
| 9008 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9009 | } |
| 9010 | |
| 9011 | /* old command */ |
| 9012 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 9013 | show_ipv6_mbgp_community_list_exact_cmd, |
| 9014 | "show ipv6 mbgp community-list WORD exact-match", |
| 9015 | SHOW_STR |
| 9016 | IPV6_STR |
| 9017 | MBGP_STR |
| 9018 | "Display routes matching the community-list\n" |
| 9019 | "community-list name\n" |
| 9020 | "Exact match of the communities\n") |
| 9021 | { |
| 9022 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 9023 | } |
| 9024 | #endif /* HAVE_IPV6 */ |
| 9025 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9026 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9027 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9028 | safi_t safi, enum bgp_show_type type) |
| 9029 | { |
| 9030 | int ret; |
| 9031 | struct prefix *p; |
| 9032 | |
| 9033 | p = prefix_new(); |
| 9034 | |
| 9035 | ret = str2prefix (prefix, p); |
| 9036 | if (! ret) |
| 9037 | { |
| 9038 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 9039 | return CMD_WARNING; |
| 9040 | } |
| 9041 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9042 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 9043 | prefix_free(p); |
| 9044 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9045 | } |
| 9046 | |
| 9047 | DEFUN (show_ip_bgp_prefix_longer, |
| 9048 | show_ip_bgp_prefix_longer_cmd, |
| 9049 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 9050 | SHOW_STR |
| 9051 | IP_STR |
| 9052 | BGP_STR |
| 9053 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9054 | "Display route and more specific routes\n") |
| 9055 | { |
| 9056 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9057 | bgp_show_type_prefix_longer); |
| 9058 | } |
| 9059 | |
| 9060 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 9061 | show_ip_bgp_flap_prefix_longer_cmd, |
| 9062 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 9063 | SHOW_STR |
| 9064 | IP_STR |
| 9065 | BGP_STR |
| 9066 | "Display flap statistics of routes\n" |
| 9067 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9068 | "Display route and more specific routes\n") |
| 9069 | { |
| 9070 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9071 | bgp_show_type_flap_prefix_longer); |
| 9072 | } |
| 9073 | |
| 9074 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 9075 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 9076 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 9077 | SHOW_STR |
| 9078 | IP_STR |
| 9079 | BGP_STR |
| 9080 | "Address family\n" |
| 9081 | "Address Family modifier\n" |
| 9082 | "Address Family modifier\n" |
| 9083 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9084 | "Display route and more specific routes\n") |
| 9085 | { |
| 9086 | if (strncmp (argv[0], "m", 1) == 0) |
| 9087 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 9088 | bgp_show_type_prefix_longer); |
| 9089 | |
| 9090 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 9091 | bgp_show_type_prefix_longer); |
| 9092 | } |
| 9093 | |
| 9094 | DEFUN (show_ip_bgp_flap_address, |
| 9095 | show_ip_bgp_flap_address_cmd, |
| 9096 | "show ip bgp flap-statistics A.B.C.D", |
| 9097 | SHOW_STR |
| 9098 | IP_STR |
| 9099 | BGP_STR |
| 9100 | "Display flap statistics of routes\n" |
| 9101 | "Network in the BGP routing table to display\n") |
| 9102 | { |
| 9103 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9104 | bgp_show_type_flap_address); |
| 9105 | } |
| 9106 | |
| 9107 | DEFUN (show_ip_bgp_flap_prefix, |
| 9108 | show_ip_bgp_flap_prefix_cmd, |
| 9109 | "show ip bgp flap-statistics A.B.C.D/M", |
| 9110 | SHOW_STR |
| 9111 | IP_STR |
| 9112 | BGP_STR |
| 9113 | "Display flap statistics of routes\n" |
| 9114 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9115 | { |
| 9116 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9117 | bgp_show_type_flap_prefix); |
| 9118 | } |
| 9119 | #ifdef HAVE_IPV6 |
| 9120 | DEFUN (show_bgp_prefix_longer, |
| 9121 | show_bgp_prefix_longer_cmd, |
| 9122 | "show bgp X:X::X:X/M longer-prefixes", |
| 9123 | SHOW_STR |
| 9124 | BGP_STR |
| 9125 | "IPv6 prefix <network>/<length>\n" |
| 9126 | "Display route and more specific routes\n") |
| 9127 | { |
| 9128 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9129 | bgp_show_type_prefix_longer); |
| 9130 | } |
| 9131 | |
| 9132 | ALIAS (show_bgp_prefix_longer, |
| 9133 | show_bgp_ipv6_prefix_longer_cmd, |
| 9134 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 9135 | SHOW_STR |
| 9136 | BGP_STR |
| 9137 | "Address family\n" |
| 9138 | "IPv6 prefix <network>/<length>\n" |
| 9139 | "Display route and more specific routes\n") |
| 9140 | |
| 9141 | /* old command */ |
| 9142 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 9143 | show_ipv6_bgp_prefix_longer_cmd, |
| 9144 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 9145 | SHOW_STR |
| 9146 | IPV6_STR |
| 9147 | BGP_STR |
| 9148 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9149 | "Display route and more specific routes\n") |
| 9150 | { |
| 9151 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9152 | bgp_show_type_prefix_longer); |
| 9153 | } |
| 9154 | |
| 9155 | /* old command */ |
| 9156 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 9157 | show_ipv6_mbgp_prefix_longer_cmd, |
| 9158 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 9159 | SHOW_STR |
| 9160 | IPV6_STR |
| 9161 | MBGP_STR |
| 9162 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9163 | "Display route and more specific routes\n") |
| 9164 | { |
| 9165 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 9166 | bgp_show_type_prefix_longer); |
| 9167 | } |
| 9168 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9169 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9170 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9171 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 9172 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9173 | { |
| 9174 | int ret; |
| 9175 | struct bgp *bgp; |
| 9176 | struct peer *peer; |
| 9177 | union sockunion su; |
| 9178 | |
| 9179 | /* BGP structure lookup. */ |
| 9180 | if (view_name) |
| 9181 | { |
| 9182 | bgp = bgp_lookup_by_name (view_name); |
| 9183 | if (! bgp) |
| 9184 | { |
| 9185 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9186 | return NULL; |
| 9187 | } |
| 9188 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 9189 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9190 | { |
| 9191 | bgp = bgp_get_default (); |
| 9192 | if (! bgp) |
| 9193 | { |
| 9194 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9195 | return NULL; |
| 9196 | } |
| 9197 | } |
| 9198 | |
| 9199 | /* Get peer sockunion. */ |
| 9200 | ret = str2sockunion (ip_str, &su); |
| 9201 | if (ret < 0) |
| 9202 | { |
| 9203 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 9204 | return NULL; |
| 9205 | } |
| 9206 | |
| 9207 | /* Peer structure lookup. */ |
| 9208 | peer = peer_lookup (bgp, &su); |
| 9209 | if (! peer) |
| 9210 | { |
| 9211 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 9212 | return NULL; |
| 9213 | } |
| 9214 | |
| 9215 | return peer; |
| 9216 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9217 | |
| 9218 | enum bgp_stats |
| 9219 | { |
| 9220 | BGP_STATS_MAXBITLEN = 0, |
| 9221 | BGP_STATS_RIB, |
| 9222 | BGP_STATS_PREFIXES, |
| 9223 | BGP_STATS_TOTPLEN, |
| 9224 | BGP_STATS_UNAGGREGATEABLE, |
| 9225 | BGP_STATS_MAX_AGGREGATEABLE, |
| 9226 | BGP_STATS_AGGREGATES, |
| 9227 | BGP_STATS_SPACE, |
| 9228 | BGP_STATS_ASPATH_COUNT, |
| 9229 | BGP_STATS_ASPATH_MAXHOPS, |
| 9230 | BGP_STATS_ASPATH_TOTHOPS, |
| 9231 | BGP_STATS_ASPATH_MAXSIZE, |
| 9232 | BGP_STATS_ASPATH_TOTSIZE, |
| 9233 | BGP_STATS_ASN_HIGHEST, |
| 9234 | BGP_STATS_MAX, |
| 9235 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9236 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9237 | static const char *table_stats_strs[] = |
| 9238 | { |
| 9239 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 9240 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 9241 | [BGP_STATS_RIB] = "Total Advertisements", |
| 9242 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 9243 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 9244 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 9245 | [BGP_STATS_SPACE] = "Address space advertised", |
| 9246 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 9247 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 9248 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 9249 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 9250 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 9251 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 9252 | [BGP_STATS_MAX] = NULL, |
| 9253 | }; |
| 9254 | |
| 9255 | struct bgp_table_stats |
| 9256 | { |
| 9257 | struct bgp_table *table; |
| 9258 | unsigned long long counts[BGP_STATS_MAX]; |
| 9259 | }; |
| 9260 | |
| 9261 | #if 0 |
| 9262 | #define TALLY_SIGFIG 100000 |
| 9263 | static unsigned long |
| 9264 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 9265 | { |
| 9266 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 9267 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 9268 | unsigned long ret = newtot / count; |
| 9269 | |
| 9270 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 9271 | return ret + 1; |
| 9272 | else |
| 9273 | return ret; |
| 9274 | } |
| 9275 | #endif |
| 9276 | |
| 9277 | static int |
| 9278 | bgp_table_stats_walker (struct thread *t) |
| 9279 | { |
| 9280 | struct bgp_node *rn; |
| 9281 | struct bgp_node *top; |
| 9282 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 9283 | unsigned int space = 0; |
| 9284 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 9285 | if (!(top = bgp_table_top (ts->table))) |
| 9286 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9287 | |
| 9288 | switch (top->p.family) |
| 9289 | { |
| 9290 | case AF_INET: |
| 9291 | space = IPV4_MAX_BITLEN; |
| 9292 | break; |
| 9293 | case AF_INET6: |
| 9294 | space = IPV6_MAX_BITLEN; |
| 9295 | break; |
| 9296 | } |
| 9297 | |
| 9298 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 9299 | |
| 9300 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 9301 | { |
| 9302 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9303 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9304 | unsigned int rinum = 0; |
| 9305 | |
| 9306 | if (rn == top) |
| 9307 | continue; |
| 9308 | |
| 9309 | if (!rn->info) |
| 9310 | continue; |
| 9311 | |
| 9312 | ts->counts[BGP_STATS_PREFIXES]++; |
| 9313 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 9314 | |
| 9315 | #if 0 |
| 9316 | ts->counts[BGP_STATS_AVGPLEN] |
| 9317 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 9318 | ts->counts[BGP_STATS_AVGPLEN], |
| 9319 | rn->p.prefixlen); |
| 9320 | #endif |
| 9321 | |
| 9322 | /* check if the prefix is included by any other announcements */ |
| 9323 | while (prn && !prn->info) |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9324 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9325 | |
| 9326 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 9327 | { |
| 9328 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 9329 | /* announced address space */ |
| 9330 | if (space) |
| 9331 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 9332 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9333 | else if (prn->info) |
| 9334 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 9335 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9336 | for (ri = rn->info; ri; ri = ri->next) |
| 9337 | { |
| 9338 | rinum++; |
| 9339 | ts->counts[BGP_STATS_RIB]++; |
| 9340 | |
| 9341 | if (ri->attr && |
| 9342 | (CHECK_FLAG (ri->attr->flag, |
| 9343 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 9344 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 9345 | |
| 9346 | /* as-path stats */ |
| 9347 | if (ri->attr && ri->attr->aspath) |
| 9348 | { |
| 9349 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 9350 | unsigned int size = aspath_size (ri->attr->aspath); |
| 9351 | as_t highest = aspath_highest (ri->attr->aspath); |
| 9352 | |
| 9353 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 9354 | |
| 9355 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 9356 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 9357 | |
| 9358 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 9359 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 9360 | |
| 9361 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 9362 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 9363 | #if 0 |
| 9364 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 9365 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9366 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 9367 | hops); |
| 9368 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 9369 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9370 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 9371 | size); |
| 9372 | #endif |
| 9373 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 9374 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 9375 | } |
| 9376 | } |
| 9377 | } |
| 9378 | return 0; |
| 9379 | } |
| 9380 | |
| 9381 | static int |
| 9382 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 9383 | { |
| 9384 | struct bgp_table_stats ts; |
| 9385 | unsigned int i; |
| 9386 | |
| 9387 | if (!bgp->rib[afi][safi]) |
| 9388 | { |
| 9389 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); |
| 9390 | return CMD_WARNING; |
| 9391 | } |
| 9392 | |
| 9393 | memset (&ts, 0, sizeof (ts)); |
| 9394 | ts.table = bgp->rib[afi][safi]; |
| 9395 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 9396 | |
| 9397 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 9398 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 9399 | |
| 9400 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 9401 | { |
| 9402 | if (!table_stats_strs[i]) |
| 9403 | continue; |
| 9404 | |
| 9405 | switch (i) |
| 9406 | { |
| 9407 | #if 0 |
| 9408 | case BGP_STATS_ASPATH_AVGHOPS: |
| 9409 | case BGP_STATS_ASPATH_AVGSIZE: |
| 9410 | case BGP_STATS_AVGPLEN: |
| 9411 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9412 | vty_out (vty, "%12.2f", |
| 9413 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 9414 | break; |
| 9415 | #endif |
| 9416 | case BGP_STATS_ASPATH_TOTHOPS: |
| 9417 | case BGP_STATS_ASPATH_TOTSIZE: |
| 9418 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9419 | vty_out (vty, "%12.2f", |
| 9420 | ts.counts[i] ? |
| 9421 | (float)ts.counts[i] / |
| 9422 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 9423 | : 0); |
| 9424 | break; |
| 9425 | case BGP_STATS_TOTPLEN: |
| 9426 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9427 | vty_out (vty, "%12.2f", |
| 9428 | ts.counts[i] ? |
| 9429 | (float)ts.counts[i] / |
| 9430 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 9431 | : 0); |
| 9432 | break; |
| 9433 | case BGP_STATS_SPACE: |
| 9434 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9435 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 9436 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 9437 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 9438 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9439 | vty_out (vty, "%12.2f%s", |
| 9440 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 9441 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9442 | VTY_NEWLINE); |
| 9443 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 9444 | vty_out (vty, "%12.2f%s", |
| 9445 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9446 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 9447 | VTY_NEWLINE); |
| 9448 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 9449 | break; |
| 9450 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 9451 | vty_out (vty, "%12.2f", |
| 9452 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9453 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 9454 | break; |
| 9455 | default: |
| 9456 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9457 | vty_out (vty, "%12llu", ts.counts[i]); |
| 9458 | } |
| 9459 | |
| 9460 | vty_out (vty, "%s", VTY_NEWLINE); |
| 9461 | } |
| 9462 | return CMD_SUCCESS; |
| 9463 | } |
| 9464 | |
| 9465 | static int |
| 9466 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 9467 | const char *afi_str, const char *safi_str) |
| 9468 | { |
| 9469 | struct bgp *bgp; |
| 9470 | afi_t afi; |
| 9471 | safi_t safi; |
| 9472 | |
| 9473 | if (name) |
| 9474 | bgp = bgp_lookup_by_name (name); |
| 9475 | else |
| 9476 | bgp = bgp_get_default (); |
| 9477 | |
| 9478 | if (!bgp) |
| 9479 | { |
| 9480 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); |
| 9481 | return CMD_WARNING; |
| 9482 | } |
| 9483 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 9484 | { |
| 9485 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 9486 | afi = AFI_IP; |
| 9487 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 9488 | afi = AFI_IP6; |
| 9489 | else |
| 9490 | { |
| 9491 | vty_out (vty, "%% Invalid address family %s%s", |
| 9492 | afi_str, VTY_NEWLINE); |
| 9493 | return CMD_WARNING; |
| 9494 | } |
| 9495 | if (strncmp (safi_str, "m", 1) == 0) |
| 9496 | safi = SAFI_MULTICAST; |
| 9497 | else if (strncmp (safi_str, "u", 1) == 0) |
| 9498 | safi = SAFI_UNICAST; |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 9499 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
| 9500 | safi = SAFI_MPLS_LABELED_VPN; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9501 | else |
| 9502 | { |
| 9503 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
| 9504 | safi_str, VTY_NEWLINE); |
| 9505 | return CMD_WARNING; |
| 9506 | } |
| 9507 | } |
| 9508 | else |
| 9509 | { |
| 9510 | vty_out (vty, "%% Invalid address family %s%s", |
| 9511 | afi_str, VTY_NEWLINE); |
| 9512 | return CMD_WARNING; |
| 9513 | } |
| 9514 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9515 | return bgp_table_stats (vty, bgp, afi, safi); |
| 9516 | } |
| 9517 | |
| 9518 | DEFUN (show_bgp_statistics, |
| 9519 | show_bgp_statistics_cmd, |
| 9520 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", |
| 9521 | SHOW_STR |
| 9522 | BGP_STR |
| 9523 | "Address family\n" |
| 9524 | "Address family\n" |
| 9525 | "Address Family modifier\n" |
| 9526 | "Address Family modifier\n" |
| 9527 | "BGP RIB advertisement statistics\n") |
| 9528 | { |
| 9529 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9530 | } |
| 9531 | |
| 9532 | ALIAS (show_bgp_statistics, |
| 9533 | show_bgp_statistics_vpnv4_cmd, |
| 9534 | "show bgp (ipv4) (vpnv4) statistics", |
| 9535 | SHOW_STR |
| 9536 | BGP_STR |
| 9537 | "Address family\n" |
| 9538 | "Address Family modifier\n" |
| 9539 | "BGP RIB advertisement statistics\n") |
| 9540 | |
| 9541 | DEFUN (show_bgp_statistics_view, |
| 9542 | show_bgp_statistics_view_cmd, |
| 9543 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", |
| 9544 | SHOW_STR |
| 9545 | BGP_STR |
| 9546 | "BGP view\n" |
| 9547 | "Address family\n" |
| 9548 | "Address family\n" |
| 9549 | "Address Family modifier\n" |
| 9550 | "Address Family modifier\n" |
| 9551 | "BGP RIB advertisement statistics\n") |
| 9552 | { |
| 9553 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9554 | } |
| 9555 | |
| 9556 | ALIAS (show_bgp_statistics_view, |
| 9557 | show_bgp_statistics_view_vpnv4_cmd, |
| 9558 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
| 9559 | SHOW_STR |
| 9560 | BGP_STR |
| 9561 | "BGP view\n" |
| 9562 | "Address family\n" |
| 9563 | "Address Family modifier\n" |
| 9564 | "BGP RIB advertisement statistics\n") |
| 9565 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9566 | enum bgp_pcounts |
| 9567 | { |
| 9568 | PCOUNT_ADJ_IN = 0, |
| 9569 | PCOUNT_DAMPED, |
| 9570 | PCOUNT_REMOVED, |
| 9571 | PCOUNT_HISTORY, |
| 9572 | PCOUNT_STALE, |
| 9573 | PCOUNT_VALID, |
| 9574 | PCOUNT_ALL, |
| 9575 | PCOUNT_COUNTED, |
| 9576 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 9577 | PCOUNT_MAX, |
| 9578 | }; |
| 9579 | |
| 9580 | static const char *pcount_strs[] = |
| 9581 | { |
| 9582 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 9583 | [PCOUNT_DAMPED] = "Damped", |
| 9584 | [PCOUNT_REMOVED] = "Removed", |
| 9585 | [PCOUNT_HISTORY] = "History", |
| 9586 | [PCOUNT_STALE] = "Stale", |
| 9587 | [PCOUNT_VALID] = "Valid", |
| 9588 | [PCOUNT_ALL] = "All RIB", |
| 9589 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 9590 | [PCOUNT_PFCNT] = "Useable", |
| 9591 | [PCOUNT_MAX] = NULL, |
| 9592 | }; |
| 9593 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9594 | struct peer_pcounts |
| 9595 | { |
| 9596 | unsigned int count[PCOUNT_MAX]; |
| 9597 | const struct peer *peer; |
| 9598 | const struct bgp_table *table; |
| 9599 | }; |
| 9600 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9601 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9602 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9603 | { |
| 9604 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9605 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 9606 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9607 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9608 | 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] | 9609 | { |
| 9610 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9611 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9612 | |
| 9613 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9614 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9615 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9616 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9617 | for (ri = rn->info; ri; ri = ri->next) |
| 9618 | { |
| 9619 | char buf[SU_ADDRSTRLEN]; |
| 9620 | |
| 9621 | if (ri->peer != peer) |
| 9622 | continue; |
| 9623 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9624 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9625 | |
| 9626 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9627 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9628 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9629 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9630 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9631 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9632 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9633 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9634 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9635 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9636 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9637 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9638 | |
| 9639 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 9640 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9641 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9642 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9643 | plog_warn (peer->log, |
| 9644 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 9645 | peer->host, |
| 9646 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9647 | buf, SU_ADDRSTRLEN), |
| 9648 | rn->p.prefixlen, |
| 9649 | ri->flags); |
| 9650 | } |
| 9651 | else |
| 9652 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9653 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9654 | plog_warn (peer->log, |
| 9655 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 9656 | peer->host, |
| 9657 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9658 | buf, SU_ADDRSTRLEN), |
| 9659 | rn->p.prefixlen, |
| 9660 | ri->flags); |
| 9661 | } |
| 9662 | } |
| 9663 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9664 | return 0; |
| 9665 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9666 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9667 | static int |
| 9668 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 9669 | { |
| 9670 | struct peer_pcounts pcounts = { .peer = peer }; |
| 9671 | unsigned int i; |
| 9672 | |
| 9673 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 9674 | || !peer->bgp->rib[afi][safi]) |
| 9675 | { |
| 9676 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9677 | return CMD_WARNING; |
| 9678 | } |
| 9679 | |
| 9680 | memset (&pcounts, 0, sizeof(pcounts)); |
| 9681 | pcounts.peer = peer; |
| 9682 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 9683 | |
| 9684 | /* in-place call via thread subsystem so as to record execution time |
| 9685 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 9686 | * on just vty_read()). |
| 9687 | */ |
| 9688 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 9689 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9690 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 9691 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 9692 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 9693 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 9694 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 9695 | |
| 9696 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9697 | vty_out (vty, "%20s: %-10d%s", |
| 9698 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9699 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9700 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9701 | { |
| 9702 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 9703 | peer->host, VTY_NEWLINE); |
| 9704 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 9705 | VTY_NEWLINE); |
| 9706 | } |
| 9707 | |
| 9708 | return CMD_SUCCESS; |
| 9709 | } |
| 9710 | |
| 9711 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 9712 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 9713 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9714 | SHOW_STR |
| 9715 | IP_STR |
| 9716 | BGP_STR |
| 9717 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9718 | "Neighbor to display information about\n" |
| 9719 | "Neighbor to display information about\n" |
| 9720 | "Display detailed prefix count information\n") |
| 9721 | { |
| 9722 | struct peer *peer; |
| 9723 | |
| 9724 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9725 | if (! peer) |
| 9726 | return CMD_WARNING; |
| 9727 | |
| 9728 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9729 | } |
| 9730 | |
| 9731 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 9732 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 9733 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9734 | SHOW_STR |
| 9735 | BGP_STR |
| 9736 | "Address family\n" |
| 9737 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9738 | "Neighbor to display information about\n" |
| 9739 | "Neighbor to display information about\n" |
| 9740 | "Display detailed prefix count information\n") |
| 9741 | { |
| 9742 | struct peer *peer; |
| 9743 | |
| 9744 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9745 | if (! peer) |
| 9746 | return CMD_WARNING; |
| 9747 | |
| 9748 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 9749 | } |
| 9750 | |
| 9751 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 9752 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 9753 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9754 | SHOW_STR |
| 9755 | IP_STR |
| 9756 | BGP_STR |
| 9757 | "Address family\n" |
| 9758 | "Address Family modifier\n" |
| 9759 | "Address Family modifier\n" |
| 9760 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9761 | "Neighbor to display information about\n" |
| 9762 | "Neighbor to display information about\n" |
| 9763 | "Display detailed prefix count information\n") |
| 9764 | { |
| 9765 | struct peer *peer; |
| 9766 | |
| 9767 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9768 | if (! peer) |
| 9769 | return CMD_WARNING; |
| 9770 | |
| 9771 | if (strncmp (argv[0], "m", 1) == 0) |
| 9772 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 9773 | |
| 9774 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9775 | } |
| 9776 | |
| 9777 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 9778 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 9779 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9780 | SHOW_STR |
| 9781 | IP_STR |
| 9782 | BGP_STR |
| 9783 | "Address family\n" |
| 9784 | "Address Family modifier\n" |
| 9785 | "Address Family modifier\n" |
| 9786 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9787 | "Neighbor to display information about\n" |
| 9788 | "Neighbor to display information about\n" |
| 9789 | "Display detailed prefix count information\n") |
| 9790 | { |
| 9791 | struct peer *peer; |
| 9792 | |
| 9793 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9794 | if (! peer) |
| 9795 | return CMD_WARNING; |
| 9796 | |
| 9797 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 9798 | } |
| 9799 | |
| 9800 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9801 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9802 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 9803 | int in) |
| 9804 | { |
| 9805 | struct bgp_table *table; |
| 9806 | struct bgp_adj_in *ain; |
| 9807 | struct bgp_adj_out *adj; |
| 9808 | unsigned long output_count; |
| 9809 | struct bgp_node *rn; |
| 9810 | int header1 = 1; |
| 9811 | struct bgp *bgp; |
| 9812 | int header2 = 1; |
| 9813 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9814 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9815 | |
| 9816 | if (! bgp) |
| 9817 | return; |
| 9818 | |
| 9819 | table = bgp->rib[afi][safi]; |
| 9820 | |
| 9821 | output_count = 0; |
| 9822 | |
| 9823 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 9824 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 9825 | { |
| 9826 | 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] | 9827 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9828 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9829 | |
| 9830 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 9831 | VTY_NEWLINE, VTY_NEWLINE); |
| 9832 | header1 = 0; |
| 9833 | } |
| 9834 | |
| 9835 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 9836 | if (in) |
| 9837 | { |
| 9838 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9839 | if (ain->peer == peer) |
| 9840 | { |
| 9841 | if (header1) |
| 9842 | { |
| 9843 | 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] | 9844 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9845 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9846 | header1 = 0; |
| 9847 | } |
| 9848 | if (header2) |
| 9849 | { |
| 9850 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9851 | header2 = 0; |
| 9852 | } |
| 9853 | if (ain->attr) |
| 9854 | { |
| 9855 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 9856 | output_count++; |
| 9857 | } |
| 9858 | } |
| 9859 | } |
| 9860 | else |
| 9861 | { |
| 9862 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 9863 | if (adj->peer == peer) |
| 9864 | { |
| 9865 | if (header1) |
| 9866 | { |
| 9867 | 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] | 9868 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9869 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9870 | header1 = 0; |
| 9871 | } |
| 9872 | if (header2) |
| 9873 | { |
| 9874 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9875 | header2 = 0; |
| 9876 | } |
| 9877 | if (adj->attr) |
| 9878 | { |
| 9879 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 9880 | output_count++; |
| 9881 | } |
| 9882 | } |
| 9883 | } |
| 9884 | |
| 9885 | if (output_count != 0) |
| 9886 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 9887 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 9888 | } |
| 9889 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9890 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9891 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 9892 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9893 | if (! peer || ! peer->afc[afi][safi]) |
| 9894 | { |
| 9895 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9896 | return CMD_WARNING; |
| 9897 | } |
| 9898 | |
| 9899 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 9900 | { |
| 9901 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 9902 | VTY_NEWLINE); |
| 9903 | return CMD_WARNING; |
| 9904 | } |
| 9905 | |
| 9906 | show_adj_route (vty, peer, afi, safi, in); |
| 9907 | |
| 9908 | return CMD_SUCCESS; |
| 9909 | } |
| 9910 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 9911 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 9912 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 9913 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9914 | SHOW_STR |
| 9915 | IP_STR |
| 9916 | BGP_STR |
| 9917 | "BGP view\n" |
| 9918 | "View name\n" |
| 9919 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9920 | "Neighbor to display information about\n" |
| 9921 | "Neighbor to display information about\n" |
| 9922 | "Display the routes advertised to a BGP neighbor\n") |
| 9923 | { |
| 9924 | struct peer *peer; |
| 9925 | |
| 9926 | if (argc == 2) |
| 9927 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9928 | else |
| 9929 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9930 | |
| 9931 | if (! peer) |
| 9932 | return CMD_WARNING; |
| 9933 | |
| 9934 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 9935 | } |
| 9936 | |
| 9937 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9938 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 9939 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9940 | SHOW_STR |
| 9941 | IP_STR |
| 9942 | BGP_STR |
| 9943 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9944 | "Neighbor to display information about\n" |
| 9945 | "Neighbor to display information about\n" |
| 9946 | "Display the routes advertised to a BGP neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9947 | |
| 9948 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 9949 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 9950 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9951 | SHOW_STR |
| 9952 | IP_STR |
| 9953 | BGP_STR |
| 9954 | "Address family\n" |
| 9955 | "Address Family modifier\n" |
| 9956 | "Address Family modifier\n" |
| 9957 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9958 | "Neighbor to display information about\n" |
| 9959 | "Neighbor to display information about\n" |
| 9960 | "Display the routes advertised to a BGP neighbor\n") |
| 9961 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9962 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9963 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9964 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9965 | if (! peer) |
| 9966 | return CMD_WARNING; |
| 9967 | |
| 9968 | if (strncmp (argv[0], "m", 1) == 0) |
| 9969 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 9970 | |
| 9971 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9972 | } |
| 9973 | |
| 9974 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9975 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 9976 | show_bgp_view_neighbor_advertised_route_cmd, |
| 9977 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9978 | SHOW_STR |
| 9979 | BGP_STR |
| 9980 | "BGP view\n" |
| 9981 | "View name\n" |
| 9982 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9983 | "Neighbor to display information about\n" |
| 9984 | "Neighbor to display information about\n" |
| 9985 | "Display the routes advertised to a BGP neighbor\n") |
| 9986 | { |
| 9987 | struct peer *peer; |
| 9988 | |
| 9989 | if (argc == 2) |
| 9990 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9991 | else |
| 9992 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9993 | |
| 9994 | if (! peer) |
| 9995 | return CMD_WARNING; |
| 9996 | |
| 9997 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 9998 | } |
| 9999 | |
| 10000 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 10001 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 10002 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10003 | SHOW_STR |
| 10004 | BGP_STR |
| 10005 | "BGP view\n" |
| 10006 | "View name\n" |
| 10007 | "Address family\n" |
| 10008 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10009 | "Neighbor to display information about\n" |
| 10010 | "Neighbor to display information about\n" |
| 10011 | "Display the routes advertised to a BGP neighbor\n") |
| 10012 | |
| 10013 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 10014 | show_bgp_view_neighbor_received_routes_cmd, |
| 10015 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10016 | SHOW_STR |
| 10017 | BGP_STR |
| 10018 | "BGP view\n" |
| 10019 | "View name\n" |
| 10020 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10021 | "Neighbor to display information about\n" |
| 10022 | "Neighbor to display information about\n" |
| 10023 | "Display the received routes from neighbor\n") |
| 10024 | { |
| 10025 | struct peer *peer; |
| 10026 | |
| 10027 | if (argc == 2) |
| 10028 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10029 | else |
| 10030 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10031 | |
| 10032 | if (! peer) |
| 10033 | return CMD_WARNING; |
| 10034 | |
| 10035 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 10036 | } |
| 10037 | |
| 10038 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 10039 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 10040 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10041 | SHOW_STR |
| 10042 | BGP_STR |
| 10043 | "BGP view\n" |
| 10044 | "View name\n" |
| 10045 | "Address family\n" |
| 10046 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10047 | "Neighbor to display information about\n" |
| 10048 | "Neighbor to display information about\n" |
| 10049 | "Display the received routes from neighbor\n") |
| 10050 | |
| 10051 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10052 | show_bgp_neighbor_advertised_route_cmd, |
| 10053 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10054 | SHOW_STR |
| 10055 | BGP_STR |
| 10056 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10057 | "Neighbor to display information about\n" |
| 10058 | "Neighbor to display information about\n" |
| 10059 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10060 | |
| 10061 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10062 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 10063 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10064 | SHOW_STR |
| 10065 | BGP_STR |
| 10066 | "Address family\n" |
| 10067 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10068 | "Neighbor to display information about\n" |
| 10069 | "Neighbor to display information about\n" |
| 10070 | "Display the routes advertised to a BGP neighbor\n") |
| 10071 | |
| 10072 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10073 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10074 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 10075 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10076 | SHOW_STR |
| 10077 | IPV6_STR |
| 10078 | BGP_STR |
| 10079 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10080 | "Neighbor to display information about\n" |
| 10081 | "Neighbor to display information about\n" |
| 10082 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10083 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10084 | /* old command */ |
| 10085 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 10086 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 10087 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10088 | SHOW_STR |
| 10089 | IPV6_STR |
| 10090 | MBGP_STR |
| 10091 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10092 | "Neighbor to display information about\n" |
| 10093 | "Neighbor to display information about\n" |
| 10094 | "Display the routes advertised to a BGP neighbor\n") |
| 10095 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10096 | struct peer *peer; |
| 10097 | |
| 10098 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10099 | if (! peer) |
| 10100 | return CMD_WARNING; |
| 10101 | |
| 10102 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10103 | } |
| 10104 | #endif /* HAVE_IPV6 */ |
| 10105 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10106 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 10107 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 10108 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10109 | SHOW_STR |
| 10110 | IP_STR |
| 10111 | BGP_STR |
| 10112 | "BGP view\n" |
| 10113 | "View name\n" |
| 10114 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10115 | "Neighbor to display information about\n" |
| 10116 | "Neighbor to display information about\n" |
| 10117 | "Display the received routes from neighbor\n") |
| 10118 | { |
| 10119 | struct peer *peer; |
| 10120 | |
| 10121 | if (argc == 2) |
| 10122 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10123 | else |
| 10124 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10125 | |
| 10126 | if (! peer) |
| 10127 | return CMD_WARNING; |
| 10128 | |
| 10129 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 10130 | } |
| 10131 | |
| 10132 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10133 | show_ip_bgp_neighbor_received_routes_cmd, |
| 10134 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10135 | SHOW_STR |
| 10136 | IP_STR |
| 10137 | BGP_STR |
| 10138 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10139 | "Neighbor to display information about\n" |
| 10140 | "Neighbor to display information about\n" |
| 10141 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10142 | |
| 10143 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 10144 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 10145 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10146 | SHOW_STR |
| 10147 | IP_STR |
| 10148 | BGP_STR |
| 10149 | "Address family\n" |
| 10150 | "Address Family modifier\n" |
| 10151 | "Address Family modifier\n" |
| 10152 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10153 | "Neighbor to display information about\n" |
| 10154 | "Neighbor to display information about\n" |
| 10155 | "Display the received routes from neighbor\n") |
| 10156 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10157 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10158 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10159 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10160 | if (! peer) |
| 10161 | return CMD_WARNING; |
| 10162 | |
| 10163 | if (strncmp (argv[0], "m", 1) == 0) |
| 10164 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 10165 | |
| 10166 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10167 | } |
| 10168 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10169 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 10170 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
| 10171 | #ifdef HAVE_IPV6 |
| 10172 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
| 10173 | #else |
| 10174 | "show bgp view WORD ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
| 10175 | #endif |
| 10176 | SHOW_STR |
| 10177 | BGP_STR |
| 10178 | "BGP view\n" |
| 10179 | "BGP view name\n" |
| 10180 | "Address family\n" |
| 10181 | #ifdef HAVE_IPV6 |
| 10182 | "Address family\n" |
| 10183 | #endif |
| 10184 | "Address family modifier\n" |
| 10185 | "Address family modifier\n" |
| 10186 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10187 | "Neighbor to display information about\n" |
| 10188 | "Neighbor to display information about\n" |
| 10189 | "Display the advertised routes to neighbor\n" |
| 10190 | "Display the received routes from neighbor\n") |
| 10191 | { |
| 10192 | int afi; |
| 10193 | int safi; |
| 10194 | int in; |
| 10195 | struct peer *peer; |
| 10196 | |
| 10197 | #ifdef HAVE_IPV6 |
| 10198 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
| 10199 | #else |
| 10200 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10201 | #endif |
| 10202 | |
| 10203 | if (! peer) |
| 10204 | return CMD_WARNING; |
| 10205 | |
| 10206 | #ifdef HAVE_IPV6 |
| 10207 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10208 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10209 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
| 10210 | #else |
| 10211 | afi = AFI_IP; |
| 10212 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10213 | in = (strncmp (argv[3], "r", 1) == 0) ? 1 : 0; |
| 10214 | #endif |
| 10215 | |
| 10216 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 10217 | } |
| 10218 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10219 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 10220 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 10221 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10222 | SHOW_STR |
| 10223 | IP_STR |
| 10224 | BGP_STR |
| 10225 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10226 | "Neighbor to display information about\n" |
| 10227 | "Neighbor to display information about\n" |
| 10228 | "Display information received from a BGP neighbor\n" |
| 10229 | "Display the prefixlist filter\n") |
| 10230 | { |
| 10231 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10232 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10233 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10234 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10235 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10236 | ret = str2sockunion (argv[0], &su); |
| 10237 | if (ret < 0) |
| 10238 | { |
| 10239 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10240 | return CMD_WARNING; |
| 10241 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10242 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10243 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10244 | if (! peer) |
| 10245 | return CMD_WARNING; |
| 10246 | |
| 10247 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10248 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10249 | if (count) |
| 10250 | { |
| 10251 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10252 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10253 | } |
| 10254 | |
| 10255 | return CMD_SUCCESS; |
| 10256 | } |
| 10257 | |
| 10258 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 10259 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 10260 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10261 | SHOW_STR |
| 10262 | IP_STR |
| 10263 | BGP_STR |
| 10264 | "Address family\n" |
| 10265 | "Address Family modifier\n" |
| 10266 | "Address Family modifier\n" |
| 10267 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10268 | "Neighbor to display information about\n" |
| 10269 | "Neighbor to display information about\n" |
| 10270 | "Display information received from a BGP neighbor\n" |
| 10271 | "Display the prefixlist filter\n") |
| 10272 | { |
| 10273 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10274 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10275 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10276 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10277 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10278 | ret = str2sockunion (argv[1], &su); |
| 10279 | if (ret < 0) |
| 10280 | { |
| 10281 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10282 | return CMD_WARNING; |
| 10283 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10284 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10285 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10286 | if (! peer) |
| 10287 | return CMD_WARNING; |
| 10288 | |
| 10289 | if (strncmp (argv[0], "m", 1) == 0) |
| 10290 | { |
| 10291 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 10292 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10293 | if (count) |
| 10294 | { |
| 10295 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 10296 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10297 | } |
| 10298 | } |
| 10299 | else |
| 10300 | { |
| 10301 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10302 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10303 | if (count) |
| 10304 | { |
| 10305 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10306 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10307 | } |
| 10308 | } |
| 10309 | |
| 10310 | return CMD_SUCCESS; |
| 10311 | } |
| 10312 | |
| 10313 | |
| 10314 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10315 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10316 | show_bgp_neighbor_received_routes_cmd, |
| 10317 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10318 | SHOW_STR |
| 10319 | BGP_STR |
| 10320 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10321 | "Neighbor to display information about\n" |
| 10322 | "Neighbor to display information about\n" |
| 10323 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10324 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10325 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10326 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 10327 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10328 | SHOW_STR |
| 10329 | BGP_STR |
| 10330 | "Address family\n" |
| 10331 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10332 | "Neighbor to display information about\n" |
| 10333 | "Neighbor to display information about\n" |
| 10334 | "Display the received routes from neighbor\n") |
| 10335 | |
| 10336 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 10337 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 10338 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10339 | SHOW_STR |
| 10340 | BGP_STR |
| 10341 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10342 | "Neighbor to display information about\n" |
| 10343 | "Neighbor to display information about\n" |
| 10344 | "Display information received from a BGP neighbor\n" |
| 10345 | "Display the prefixlist filter\n") |
| 10346 | { |
| 10347 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10348 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10349 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10350 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10351 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10352 | ret = str2sockunion (argv[0], &su); |
| 10353 | if (ret < 0) |
| 10354 | { |
| 10355 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10356 | return CMD_WARNING; |
| 10357 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10358 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10359 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10360 | if (! peer) |
| 10361 | return CMD_WARNING; |
| 10362 | |
| 10363 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10364 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10365 | if (count) |
| 10366 | { |
| 10367 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10368 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10369 | } |
| 10370 | |
| 10371 | return CMD_SUCCESS; |
| 10372 | } |
| 10373 | |
| 10374 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 10375 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 10376 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10377 | SHOW_STR |
| 10378 | BGP_STR |
| 10379 | "Address family\n" |
| 10380 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10381 | "Neighbor to display information about\n" |
| 10382 | "Neighbor to display information about\n" |
| 10383 | "Display information received from a BGP neighbor\n" |
| 10384 | "Display the prefixlist filter\n") |
| 10385 | |
| 10386 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10387 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10388 | ipv6_bgp_neighbor_received_routes_cmd, |
| 10389 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10390 | SHOW_STR |
| 10391 | IPV6_STR |
| 10392 | BGP_STR |
| 10393 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10394 | "Neighbor to display information about\n" |
| 10395 | "Neighbor to display information about\n" |
| 10396 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10397 | |
| 10398 | /* old command */ |
| 10399 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 10400 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 10401 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10402 | SHOW_STR |
| 10403 | IPV6_STR |
| 10404 | MBGP_STR |
| 10405 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10406 | "Neighbor to display information about\n" |
| 10407 | "Neighbor to display information about\n" |
| 10408 | "Display the received routes from neighbor\n") |
| 10409 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10410 | struct peer *peer; |
| 10411 | |
| 10412 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10413 | if (! peer) |
| 10414 | return CMD_WARNING; |
| 10415 | |
| 10416 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10417 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10418 | |
| 10419 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 10420 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 10421 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10422 | SHOW_STR |
| 10423 | BGP_STR |
| 10424 | "BGP view\n" |
| 10425 | "View name\n" |
| 10426 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10427 | "Neighbor to display information about\n" |
| 10428 | "Neighbor to display information about\n" |
| 10429 | "Display information received from a BGP neighbor\n" |
| 10430 | "Display the prefixlist filter\n") |
| 10431 | { |
| 10432 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10433 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10434 | struct peer *peer; |
| 10435 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10436 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10437 | |
| 10438 | /* BGP structure lookup. */ |
| 10439 | bgp = bgp_lookup_by_name (argv[0]); |
| 10440 | if (bgp == NULL) |
| 10441 | { |
| 10442 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10443 | return CMD_WARNING; |
| 10444 | } |
| 10445 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10446 | ret = str2sockunion (argv[1], &su); |
| 10447 | if (ret < 0) |
| 10448 | { |
| 10449 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10450 | return CMD_WARNING; |
| 10451 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10452 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10453 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10454 | if (! peer) |
| 10455 | return CMD_WARNING; |
| 10456 | |
| 10457 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10458 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10459 | if (count) |
| 10460 | { |
| 10461 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10462 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10463 | } |
| 10464 | |
| 10465 | return CMD_SUCCESS; |
| 10466 | } |
| 10467 | |
| 10468 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 10469 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 10470 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10471 | SHOW_STR |
| 10472 | BGP_STR |
| 10473 | "BGP view\n" |
| 10474 | "View name\n" |
| 10475 | "Address family\n" |
| 10476 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10477 | "Neighbor to display information about\n" |
| 10478 | "Neighbor to display information about\n" |
| 10479 | "Display information received from a BGP neighbor\n" |
| 10480 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10481 | #endif /* HAVE_IPV6 */ |
| 10482 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10483 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10484 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10485 | safi_t safi, enum bgp_show_type type) |
| 10486 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10487 | if (! peer || ! peer->afc[afi][safi]) |
| 10488 | { |
| 10489 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10490 | return CMD_WARNING; |
| 10491 | } |
| 10492 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10493 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10494 | } |
| 10495 | |
| 10496 | DEFUN (show_ip_bgp_neighbor_routes, |
| 10497 | show_ip_bgp_neighbor_routes_cmd, |
| 10498 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10499 | SHOW_STR |
| 10500 | IP_STR |
| 10501 | BGP_STR |
| 10502 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10503 | "Neighbor to display information about\n" |
| 10504 | "Neighbor to display information about\n" |
| 10505 | "Display routes learned from neighbor\n") |
| 10506 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10507 | struct peer *peer; |
| 10508 | |
| 10509 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10510 | if (! peer) |
| 10511 | return CMD_WARNING; |
| 10512 | |
| 10513 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10514 | bgp_show_type_neighbor); |
| 10515 | } |
| 10516 | |
| 10517 | DEFUN (show_ip_bgp_neighbor_flap, |
| 10518 | show_ip_bgp_neighbor_flap_cmd, |
| 10519 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10520 | SHOW_STR |
| 10521 | IP_STR |
| 10522 | BGP_STR |
| 10523 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10524 | "Neighbor to display information about\n" |
| 10525 | "Neighbor to display information about\n" |
| 10526 | "Display flap statistics of the routes learned from neighbor\n") |
| 10527 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10528 | struct peer *peer; |
| 10529 | |
| 10530 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10531 | if (! peer) |
| 10532 | return CMD_WARNING; |
| 10533 | |
| 10534 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10535 | bgp_show_type_flap_neighbor); |
| 10536 | } |
| 10537 | |
| 10538 | DEFUN (show_ip_bgp_neighbor_damp, |
| 10539 | show_ip_bgp_neighbor_damp_cmd, |
| 10540 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10541 | SHOW_STR |
| 10542 | IP_STR |
| 10543 | BGP_STR |
| 10544 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10545 | "Neighbor to display information about\n" |
| 10546 | "Neighbor to display information about\n" |
| 10547 | "Display the dampened routes received from neighbor\n") |
| 10548 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10549 | struct peer *peer; |
| 10550 | |
| 10551 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10552 | if (! peer) |
| 10553 | return CMD_WARNING; |
| 10554 | |
| 10555 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10556 | bgp_show_type_damp_neighbor); |
| 10557 | } |
| 10558 | |
| 10559 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 10560 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 10561 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 10562 | SHOW_STR |
| 10563 | IP_STR |
| 10564 | BGP_STR |
| 10565 | "Address family\n" |
| 10566 | "Address Family modifier\n" |
| 10567 | "Address Family modifier\n" |
| 10568 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10569 | "Neighbor to display information about\n" |
| 10570 | "Neighbor to display information about\n" |
| 10571 | "Display routes learned from neighbor\n") |
| 10572 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10573 | struct peer *peer; |
| 10574 | |
| 10575 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10576 | if (! peer) |
| 10577 | return CMD_WARNING; |
| 10578 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10579 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10580 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10581 | bgp_show_type_neighbor); |
| 10582 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10583 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
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 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10587 | DEFUN (show_ip_bgp_view_rsclient, |
| 10588 | show_ip_bgp_view_rsclient_cmd, |
| 10589 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 10590 | SHOW_STR |
| 10591 | IP_STR |
| 10592 | BGP_STR |
| 10593 | "BGP view\n" |
| 10594 | "BGP view name\n" |
| 10595 | "Information about Route Server Client\n" |
| 10596 | NEIGHBOR_ADDR_STR) |
| 10597 | { |
| 10598 | struct bgp_table *table; |
| 10599 | struct peer *peer; |
| 10600 | |
| 10601 | if (argc == 2) |
| 10602 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10603 | else |
| 10604 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10605 | |
| 10606 | if (! peer) |
| 10607 | return CMD_WARNING; |
| 10608 | |
| 10609 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10610 | { |
| 10611 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10612 | VTY_NEWLINE); |
| 10613 | return CMD_WARNING; |
| 10614 | } |
| 10615 | |
| 10616 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10617 | PEER_FLAG_RSERVER_CLIENT)) |
| 10618 | { |
| 10619 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10620 | VTY_NEWLINE); |
| 10621 | return CMD_WARNING; |
| 10622 | } |
| 10623 | |
| 10624 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 10625 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10626 | 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] | 10627 | } |
| 10628 | |
| 10629 | ALIAS (show_ip_bgp_view_rsclient, |
| 10630 | show_ip_bgp_rsclient_cmd, |
| 10631 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 10632 | SHOW_STR |
| 10633 | IP_STR |
| 10634 | BGP_STR |
| 10635 | "Information about Route Server Client\n" |
| 10636 | NEIGHBOR_ADDR_STR) |
| 10637 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10638 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 10639 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 10640 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10641 | SHOW_STR |
| 10642 | BGP_STR |
| 10643 | "BGP view\n" |
| 10644 | "BGP view name\n" |
| 10645 | "Address family\n" |
| 10646 | "Address Family modifier\n" |
| 10647 | "Address Family modifier\n" |
| 10648 | "Information about Route Server Client\n" |
| 10649 | NEIGHBOR_ADDR_STR) |
| 10650 | { |
| 10651 | struct bgp_table *table; |
| 10652 | struct peer *peer; |
| 10653 | safi_t safi; |
| 10654 | |
| 10655 | if (argc == 3) { |
| 10656 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10657 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10658 | } else { |
| 10659 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10660 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10661 | } |
| 10662 | |
| 10663 | if (! peer) |
| 10664 | return CMD_WARNING; |
| 10665 | |
| 10666 | if (! peer->afc[AFI_IP][safi]) |
| 10667 | { |
| 10668 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10669 | VTY_NEWLINE); |
| 10670 | return CMD_WARNING; |
| 10671 | } |
| 10672 | |
| 10673 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10674 | PEER_FLAG_RSERVER_CLIENT)) |
| 10675 | { |
| 10676 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10677 | VTY_NEWLINE); |
| 10678 | return CMD_WARNING; |
| 10679 | } |
| 10680 | |
| 10681 | table = peer->rib[AFI_IP][safi]; |
| 10682 | |
| 10683 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 10684 | } |
| 10685 | |
| 10686 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 10687 | show_bgp_ipv4_safi_rsclient_cmd, |
| 10688 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10689 | SHOW_STR |
| 10690 | BGP_STR |
| 10691 | "Address family\n" |
| 10692 | "Address Family modifier\n" |
| 10693 | "Address Family modifier\n" |
| 10694 | "Information about Route Server Client\n" |
| 10695 | NEIGHBOR_ADDR_STR) |
| 10696 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10697 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 10698 | show_ip_bgp_view_rsclient_route_cmd, |
Michael Lambert | a8bf6f5 | 2008-09-24 17:23:11 +0100 | [diff] [blame] | 10699 | "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] | 10700 | SHOW_STR |
| 10701 | IP_STR |
| 10702 | BGP_STR |
| 10703 | "BGP view\n" |
| 10704 | "BGP view name\n" |
| 10705 | "Information about Route Server Client\n" |
| 10706 | NEIGHBOR_ADDR_STR |
| 10707 | "Network in the BGP routing table to display\n") |
| 10708 | { |
| 10709 | struct bgp *bgp; |
| 10710 | struct peer *peer; |
| 10711 | |
| 10712 | /* BGP structure lookup. */ |
| 10713 | if (argc == 3) |
| 10714 | { |
| 10715 | bgp = bgp_lookup_by_name (argv[0]); |
| 10716 | if (bgp == NULL) |
| 10717 | { |
| 10718 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10719 | return CMD_WARNING; |
| 10720 | } |
| 10721 | } |
| 10722 | else |
| 10723 | { |
| 10724 | bgp = bgp_get_default (); |
| 10725 | if (bgp == NULL) |
| 10726 | { |
| 10727 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10728 | return CMD_WARNING; |
| 10729 | } |
| 10730 | } |
| 10731 | |
| 10732 | if (argc == 3) |
| 10733 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10734 | else |
| 10735 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10736 | |
| 10737 | if (! peer) |
| 10738 | return CMD_WARNING; |
| 10739 | |
| 10740 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10741 | { |
| 10742 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10743 | VTY_NEWLINE); |
| 10744 | return CMD_WARNING; |
| 10745 | } |
| 10746 | |
| 10747 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10748 | PEER_FLAG_RSERVER_CLIENT)) |
| 10749 | { |
| 10750 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10751 | VTY_NEWLINE); |
| 10752 | return CMD_WARNING; |
| 10753 | } |
| 10754 | |
| 10755 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10756 | (argc == 3) ? argv[2] : argv[1], |
| 10757 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 10758 | } |
| 10759 | |
| 10760 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 10761 | show_ip_bgp_rsclient_route_cmd, |
| 10762 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10763 | SHOW_STR |
| 10764 | IP_STR |
| 10765 | BGP_STR |
| 10766 | "Information about Route Server Client\n" |
| 10767 | NEIGHBOR_ADDR_STR |
| 10768 | "Network in the BGP routing table to display\n") |
| 10769 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10770 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 10771 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 10772 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10773 | SHOW_STR |
| 10774 | BGP_STR |
| 10775 | "BGP view\n" |
| 10776 | "BGP view name\n" |
| 10777 | "Address family\n" |
| 10778 | "Address Family modifier\n" |
| 10779 | "Address Family modifier\n" |
| 10780 | "Information about Route Server Client\n" |
| 10781 | NEIGHBOR_ADDR_STR |
| 10782 | "Network in the BGP routing table to display\n") |
| 10783 | { |
| 10784 | struct bgp *bgp; |
| 10785 | struct peer *peer; |
| 10786 | safi_t safi; |
| 10787 | |
| 10788 | /* BGP structure lookup. */ |
| 10789 | if (argc == 4) |
| 10790 | { |
| 10791 | bgp = bgp_lookup_by_name (argv[0]); |
| 10792 | if (bgp == NULL) |
| 10793 | { |
| 10794 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10795 | return CMD_WARNING; |
| 10796 | } |
| 10797 | } |
| 10798 | else |
| 10799 | { |
| 10800 | bgp = bgp_get_default (); |
| 10801 | if (bgp == NULL) |
| 10802 | { |
| 10803 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10804 | return CMD_WARNING; |
| 10805 | } |
| 10806 | } |
| 10807 | |
| 10808 | if (argc == 4) { |
| 10809 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10810 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10811 | } else { |
| 10812 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10813 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10814 | } |
| 10815 | |
| 10816 | if (! peer) |
| 10817 | return CMD_WARNING; |
| 10818 | |
| 10819 | if (! peer->afc[AFI_IP][safi]) |
| 10820 | { |
| 10821 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10822 | VTY_NEWLINE); |
| 10823 | return CMD_WARNING; |
| 10824 | } |
| 10825 | |
| 10826 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10827 | PEER_FLAG_RSERVER_CLIENT)) |
| 10828 | { |
| 10829 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10830 | VTY_NEWLINE); |
| 10831 | return CMD_WARNING; |
| 10832 | } |
| 10833 | |
| 10834 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10835 | (argc == 4) ? argv[3] : argv[2], |
| 10836 | AFI_IP, safi, NULL, 0); |
| 10837 | } |
| 10838 | |
| 10839 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 10840 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 10841 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10842 | SHOW_STR |
| 10843 | BGP_STR |
| 10844 | "Address family\n" |
| 10845 | "Address Family modifier\n" |
| 10846 | "Address Family modifier\n" |
| 10847 | "Information about Route Server Client\n" |
| 10848 | NEIGHBOR_ADDR_STR |
| 10849 | "Network in the BGP routing table to display\n") |
| 10850 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10851 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 10852 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 10853 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10854 | SHOW_STR |
| 10855 | IP_STR |
| 10856 | BGP_STR |
| 10857 | "BGP view\n" |
| 10858 | "BGP view name\n" |
| 10859 | "Information about Route Server Client\n" |
| 10860 | NEIGHBOR_ADDR_STR |
| 10861 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10862 | { |
| 10863 | struct bgp *bgp; |
| 10864 | struct peer *peer; |
| 10865 | |
| 10866 | /* BGP structure lookup. */ |
| 10867 | if (argc == 3) |
| 10868 | { |
| 10869 | bgp = bgp_lookup_by_name (argv[0]); |
| 10870 | if (bgp == NULL) |
| 10871 | { |
| 10872 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10873 | return CMD_WARNING; |
| 10874 | } |
| 10875 | } |
| 10876 | else |
| 10877 | { |
| 10878 | bgp = bgp_get_default (); |
| 10879 | if (bgp == NULL) |
| 10880 | { |
| 10881 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10882 | return CMD_WARNING; |
| 10883 | } |
| 10884 | } |
| 10885 | |
| 10886 | if (argc == 3) |
| 10887 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10888 | else |
| 10889 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10890 | |
| 10891 | if (! peer) |
| 10892 | return CMD_WARNING; |
| 10893 | |
| 10894 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10895 | { |
| 10896 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10897 | VTY_NEWLINE); |
| 10898 | return CMD_WARNING; |
| 10899 | } |
| 10900 | |
| 10901 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10902 | PEER_FLAG_RSERVER_CLIENT)) |
| 10903 | { |
| 10904 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10905 | VTY_NEWLINE); |
| 10906 | return CMD_WARNING; |
| 10907 | } |
| 10908 | |
| 10909 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10910 | (argc == 3) ? argv[2] : argv[1], |
| 10911 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 10912 | } |
| 10913 | |
| 10914 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 10915 | show_ip_bgp_rsclient_prefix_cmd, |
| 10916 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10917 | SHOW_STR |
| 10918 | IP_STR |
| 10919 | BGP_STR |
| 10920 | "Information about Route Server Client\n" |
| 10921 | NEIGHBOR_ADDR_STR |
| 10922 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10923 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10924 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 10925 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 10926 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10927 | SHOW_STR |
| 10928 | BGP_STR |
| 10929 | "BGP view\n" |
| 10930 | "BGP view name\n" |
| 10931 | "Address family\n" |
| 10932 | "Address Family modifier\n" |
| 10933 | "Address Family modifier\n" |
| 10934 | "Information about Route Server Client\n" |
| 10935 | NEIGHBOR_ADDR_STR |
| 10936 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10937 | { |
| 10938 | struct bgp *bgp; |
| 10939 | struct peer *peer; |
| 10940 | safi_t safi; |
| 10941 | |
| 10942 | /* BGP structure lookup. */ |
| 10943 | if (argc == 4) |
| 10944 | { |
| 10945 | bgp = bgp_lookup_by_name (argv[0]); |
| 10946 | if (bgp == NULL) |
| 10947 | { |
| 10948 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10949 | return CMD_WARNING; |
| 10950 | } |
| 10951 | } |
| 10952 | else |
| 10953 | { |
| 10954 | bgp = bgp_get_default (); |
| 10955 | if (bgp == NULL) |
| 10956 | { |
| 10957 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10958 | return CMD_WARNING; |
| 10959 | } |
| 10960 | } |
| 10961 | |
| 10962 | if (argc == 4) { |
| 10963 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10964 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10965 | } else { |
| 10966 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10967 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10968 | } |
| 10969 | |
| 10970 | if (! peer) |
| 10971 | return CMD_WARNING; |
| 10972 | |
| 10973 | if (! peer->afc[AFI_IP][safi]) |
| 10974 | { |
| 10975 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10976 | VTY_NEWLINE); |
| 10977 | return CMD_WARNING; |
| 10978 | } |
| 10979 | |
| 10980 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10981 | PEER_FLAG_RSERVER_CLIENT)) |
| 10982 | { |
| 10983 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10984 | VTY_NEWLINE); |
| 10985 | return CMD_WARNING; |
| 10986 | } |
| 10987 | |
| 10988 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10989 | (argc == 4) ? argv[3] : argv[2], |
| 10990 | AFI_IP, safi, NULL, 1); |
| 10991 | } |
| 10992 | |
| 10993 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 10994 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 10995 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10996 | SHOW_STR |
| 10997 | BGP_STR |
| 10998 | "Address family\n" |
| 10999 | "Address Family modifier\n" |
| 11000 | "Address Family modifier\n" |
| 11001 | "Information about Route Server Client\n" |
| 11002 | NEIGHBOR_ADDR_STR |
| 11003 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11004 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11005 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11006 | DEFUN (show_bgp_view_neighbor_routes, |
| 11007 | show_bgp_view_neighbor_routes_cmd, |
| 11008 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 11009 | SHOW_STR |
| 11010 | BGP_STR |
| 11011 | "BGP view\n" |
| 11012 | "BGP view name\n" |
| 11013 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11014 | "Neighbor to display information about\n" |
| 11015 | "Neighbor to display information about\n" |
| 11016 | "Display routes learned from neighbor\n") |
| 11017 | { |
| 11018 | struct peer *peer; |
| 11019 | |
| 11020 | if (argc == 2) |
| 11021 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11022 | else |
| 11023 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11024 | |
| 11025 | if (! peer) |
| 11026 | return CMD_WARNING; |
| 11027 | |
| 11028 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11029 | bgp_show_type_neighbor); |
| 11030 | } |
| 11031 | |
| 11032 | ALIAS (show_bgp_view_neighbor_routes, |
| 11033 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 11034 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11035 | SHOW_STR |
| 11036 | BGP_STR |
| 11037 | "BGP view\n" |
| 11038 | "BGP view name\n" |
| 11039 | "Address family\n" |
| 11040 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11041 | "Neighbor to display information about\n" |
| 11042 | "Neighbor to display information about\n" |
| 11043 | "Display routes learned from neighbor\n") |
| 11044 | |
| 11045 | DEFUN (show_bgp_view_neighbor_damp, |
| 11046 | show_bgp_view_neighbor_damp_cmd, |
| 11047 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11048 | SHOW_STR |
| 11049 | BGP_STR |
| 11050 | "BGP view\n" |
| 11051 | "BGP view name\n" |
| 11052 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11053 | "Neighbor to display information about\n" |
| 11054 | "Neighbor to display information about\n" |
| 11055 | "Display the dampened routes received from neighbor\n") |
| 11056 | { |
| 11057 | struct peer *peer; |
| 11058 | |
| 11059 | if (argc == 2) |
| 11060 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11061 | else |
| 11062 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11063 | |
| 11064 | if (! peer) |
| 11065 | return CMD_WARNING; |
| 11066 | |
| 11067 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11068 | bgp_show_type_damp_neighbor); |
| 11069 | } |
| 11070 | |
| 11071 | ALIAS (show_bgp_view_neighbor_damp, |
| 11072 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 11073 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11074 | SHOW_STR |
| 11075 | BGP_STR |
| 11076 | "BGP view\n" |
| 11077 | "BGP view name\n" |
| 11078 | "Address family\n" |
| 11079 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11080 | "Neighbor to display information about\n" |
| 11081 | "Neighbor to display information about\n" |
| 11082 | "Display the dampened routes received from neighbor\n") |
| 11083 | |
| 11084 | DEFUN (show_bgp_view_neighbor_flap, |
| 11085 | show_bgp_view_neighbor_flap_cmd, |
| 11086 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11087 | SHOW_STR |
| 11088 | BGP_STR |
| 11089 | "BGP view\n" |
| 11090 | "BGP view name\n" |
| 11091 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11092 | "Neighbor to display information about\n" |
| 11093 | "Neighbor to display information about\n" |
| 11094 | "Display flap statistics of the routes learned from neighbor\n") |
| 11095 | { |
| 11096 | struct peer *peer; |
| 11097 | |
| 11098 | if (argc == 2) |
| 11099 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11100 | else |
| 11101 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11102 | |
| 11103 | if (! peer) |
| 11104 | return CMD_WARNING; |
| 11105 | |
| 11106 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11107 | bgp_show_type_flap_neighbor); |
| 11108 | } |
| 11109 | |
| 11110 | ALIAS (show_bgp_view_neighbor_flap, |
| 11111 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 11112 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11113 | SHOW_STR |
| 11114 | BGP_STR |
| 11115 | "BGP view\n" |
| 11116 | "BGP view name\n" |
| 11117 | "Address family\n" |
| 11118 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11119 | "Neighbor to display information about\n" |
| 11120 | "Neighbor to display information about\n" |
| 11121 | "Display flap statistics of the routes learned from neighbor\n") |
| 11122 | |
| 11123 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11124 | show_bgp_neighbor_routes_cmd, |
| 11125 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11126 | SHOW_STR |
| 11127 | BGP_STR |
| 11128 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11129 | "Neighbor to display information about\n" |
| 11130 | "Neighbor to display information about\n" |
| 11131 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11132 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11133 | |
| 11134 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11135 | show_bgp_ipv6_neighbor_routes_cmd, |
| 11136 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11137 | SHOW_STR |
| 11138 | BGP_STR |
| 11139 | "Address family\n" |
| 11140 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11141 | "Neighbor to display information about\n" |
| 11142 | "Neighbor to display information about\n" |
| 11143 | "Display routes learned from neighbor\n") |
| 11144 | |
| 11145 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11146 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11147 | ipv6_bgp_neighbor_routes_cmd, |
| 11148 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11149 | SHOW_STR |
| 11150 | IPV6_STR |
| 11151 | BGP_STR |
| 11152 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11153 | "Neighbor to display information about\n" |
| 11154 | "Neighbor to display information about\n" |
| 11155 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11156 | |
| 11157 | /* old command */ |
| 11158 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 11159 | ipv6_mbgp_neighbor_routes_cmd, |
| 11160 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11161 | SHOW_STR |
| 11162 | IPV6_STR |
| 11163 | MBGP_STR |
| 11164 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11165 | "Neighbor to display information about\n" |
| 11166 | "Neighbor to display information about\n" |
| 11167 | "Display routes learned from neighbor\n") |
| 11168 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11169 | struct peer *peer; |
| 11170 | |
| 11171 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11172 | if (! peer) |
| 11173 | return CMD_WARNING; |
| 11174 | |
| 11175 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11176 | bgp_show_type_neighbor); |
| 11177 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11178 | |
| 11179 | ALIAS (show_bgp_view_neighbor_flap, |
| 11180 | show_bgp_neighbor_flap_cmd, |
| 11181 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11182 | SHOW_STR |
| 11183 | BGP_STR |
| 11184 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11185 | "Neighbor to display information about\n" |
| 11186 | "Neighbor to display information about\n" |
| 11187 | "Display flap statistics of the routes learned from neighbor\n") |
| 11188 | |
| 11189 | ALIAS (show_bgp_view_neighbor_flap, |
| 11190 | show_bgp_ipv6_neighbor_flap_cmd, |
| 11191 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11192 | SHOW_STR |
| 11193 | BGP_STR |
| 11194 | "Address family\n" |
| 11195 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11196 | "Neighbor to display information about\n" |
| 11197 | "Neighbor to display information about\n" |
| 11198 | "Display flap statistics of the routes learned from neighbor\n") |
| 11199 | |
| 11200 | ALIAS (show_bgp_view_neighbor_damp, |
| 11201 | show_bgp_neighbor_damp_cmd, |
| 11202 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11203 | SHOW_STR |
| 11204 | BGP_STR |
| 11205 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11206 | "Neighbor to display information about\n" |
| 11207 | "Neighbor to display information about\n" |
| 11208 | "Display the dampened routes received from neighbor\n") |
| 11209 | |
| 11210 | ALIAS (show_bgp_view_neighbor_damp, |
| 11211 | show_bgp_ipv6_neighbor_damp_cmd, |
| 11212 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11213 | SHOW_STR |
| 11214 | BGP_STR |
| 11215 | "Address family\n" |
| 11216 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11217 | "Neighbor to display information about\n" |
| 11218 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 11219 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11220 | |
| 11221 | DEFUN (show_bgp_view_rsclient, |
| 11222 | show_bgp_view_rsclient_cmd, |
| 11223 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 11224 | SHOW_STR |
| 11225 | BGP_STR |
| 11226 | "BGP view\n" |
| 11227 | "BGP view name\n" |
| 11228 | "Information about Route Server Client\n" |
| 11229 | NEIGHBOR_ADDR_STR) |
| 11230 | { |
| 11231 | struct bgp_table *table; |
| 11232 | struct peer *peer; |
| 11233 | |
| 11234 | if (argc == 2) |
| 11235 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11236 | else |
| 11237 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11238 | |
| 11239 | if (! peer) |
| 11240 | return CMD_WARNING; |
| 11241 | |
| 11242 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11243 | { |
| 11244 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11245 | VTY_NEWLINE); |
| 11246 | return CMD_WARNING; |
| 11247 | } |
| 11248 | |
| 11249 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11250 | PEER_FLAG_RSERVER_CLIENT)) |
| 11251 | { |
| 11252 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11253 | VTY_NEWLINE); |
| 11254 | return CMD_WARNING; |
| 11255 | } |
| 11256 | |
| 11257 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 11258 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11259 | 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] | 11260 | } |
| 11261 | |
| 11262 | ALIAS (show_bgp_view_rsclient, |
| 11263 | show_bgp_rsclient_cmd, |
| 11264 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 11265 | SHOW_STR |
| 11266 | BGP_STR |
| 11267 | "Information about Route Server Client\n" |
| 11268 | NEIGHBOR_ADDR_STR) |
| 11269 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11270 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 11271 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 11272 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11273 | SHOW_STR |
| 11274 | BGP_STR |
| 11275 | "BGP view\n" |
| 11276 | "BGP view name\n" |
| 11277 | "Address family\n" |
| 11278 | "Address Family modifier\n" |
| 11279 | "Address Family modifier\n" |
| 11280 | "Information about Route Server Client\n" |
| 11281 | NEIGHBOR_ADDR_STR) |
| 11282 | { |
| 11283 | struct bgp_table *table; |
| 11284 | struct peer *peer; |
| 11285 | safi_t safi; |
| 11286 | |
| 11287 | if (argc == 3) { |
| 11288 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11289 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11290 | } else { |
| 11291 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11292 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11293 | } |
| 11294 | |
| 11295 | if (! peer) |
| 11296 | return CMD_WARNING; |
| 11297 | |
| 11298 | if (! peer->afc[AFI_IP6][safi]) |
| 11299 | { |
| 11300 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11301 | VTY_NEWLINE); |
| 11302 | return CMD_WARNING; |
| 11303 | } |
| 11304 | |
| 11305 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11306 | PEER_FLAG_RSERVER_CLIENT)) |
| 11307 | { |
| 11308 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11309 | VTY_NEWLINE); |
| 11310 | return CMD_WARNING; |
| 11311 | } |
| 11312 | |
| 11313 | table = peer->rib[AFI_IP6][safi]; |
| 11314 | |
| 11315 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 11316 | } |
| 11317 | |
| 11318 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 11319 | show_bgp_ipv6_safi_rsclient_cmd, |
| 11320 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11321 | SHOW_STR |
| 11322 | BGP_STR |
| 11323 | "Address family\n" |
| 11324 | "Address Family modifier\n" |
| 11325 | "Address Family modifier\n" |
| 11326 | "Information about Route Server Client\n" |
| 11327 | NEIGHBOR_ADDR_STR) |
| 11328 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11329 | DEFUN (show_bgp_view_rsclient_route, |
| 11330 | show_bgp_view_rsclient_route_cmd, |
| 11331 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11332 | SHOW_STR |
| 11333 | BGP_STR |
| 11334 | "BGP view\n" |
| 11335 | "BGP view name\n" |
| 11336 | "Information about Route Server Client\n" |
| 11337 | NEIGHBOR_ADDR_STR |
| 11338 | "Network in the BGP routing table to display\n") |
| 11339 | { |
| 11340 | struct bgp *bgp; |
| 11341 | struct peer *peer; |
| 11342 | |
| 11343 | /* BGP structure lookup. */ |
| 11344 | if (argc == 3) |
| 11345 | { |
| 11346 | bgp = bgp_lookup_by_name (argv[0]); |
| 11347 | if (bgp == NULL) |
| 11348 | { |
| 11349 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11350 | return CMD_WARNING; |
| 11351 | } |
| 11352 | } |
| 11353 | else |
| 11354 | { |
| 11355 | bgp = bgp_get_default (); |
| 11356 | if (bgp == NULL) |
| 11357 | { |
| 11358 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11359 | return CMD_WARNING; |
| 11360 | } |
| 11361 | } |
| 11362 | |
| 11363 | if (argc == 3) |
| 11364 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11365 | else |
| 11366 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11367 | |
| 11368 | if (! peer) |
| 11369 | return CMD_WARNING; |
| 11370 | |
| 11371 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11372 | { |
| 11373 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11374 | VTY_NEWLINE); |
| 11375 | return CMD_WARNING; |
| 11376 | } |
| 11377 | |
| 11378 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11379 | PEER_FLAG_RSERVER_CLIENT)) |
| 11380 | { |
| 11381 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11382 | VTY_NEWLINE); |
| 11383 | return CMD_WARNING; |
| 11384 | } |
| 11385 | |
| 11386 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11387 | (argc == 3) ? argv[2] : argv[1], |
| 11388 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 11389 | } |
| 11390 | |
| 11391 | ALIAS (show_bgp_view_rsclient_route, |
| 11392 | show_bgp_rsclient_route_cmd, |
| 11393 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11394 | SHOW_STR |
| 11395 | BGP_STR |
| 11396 | "Information about Route Server Client\n" |
| 11397 | NEIGHBOR_ADDR_STR |
| 11398 | "Network in the BGP routing table to display\n") |
| 11399 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11400 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 11401 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 11402 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11403 | SHOW_STR |
| 11404 | BGP_STR |
| 11405 | "BGP view\n" |
| 11406 | "BGP view name\n" |
| 11407 | "Address family\n" |
| 11408 | "Address Family modifier\n" |
| 11409 | "Address Family modifier\n" |
| 11410 | "Information about Route Server Client\n" |
| 11411 | NEIGHBOR_ADDR_STR |
| 11412 | "Network in the BGP routing table to display\n") |
| 11413 | { |
| 11414 | struct bgp *bgp; |
| 11415 | struct peer *peer; |
| 11416 | safi_t safi; |
| 11417 | |
| 11418 | /* BGP structure lookup. */ |
| 11419 | if (argc == 4) |
| 11420 | { |
| 11421 | bgp = bgp_lookup_by_name (argv[0]); |
| 11422 | if (bgp == NULL) |
| 11423 | { |
| 11424 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11425 | return CMD_WARNING; |
| 11426 | } |
| 11427 | } |
| 11428 | else |
| 11429 | { |
| 11430 | bgp = bgp_get_default (); |
| 11431 | if (bgp == NULL) |
| 11432 | { |
| 11433 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11434 | return CMD_WARNING; |
| 11435 | } |
| 11436 | } |
| 11437 | |
| 11438 | if (argc == 4) { |
| 11439 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11440 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11441 | } else { |
| 11442 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11443 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11444 | } |
| 11445 | |
| 11446 | if (! peer) |
| 11447 | return CMD_WARNING; |
| 11448 | |
| 11449 | if (! peer->afc[AFI_IP6][safi]) |
| 11450 | { |
| 11451 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11452 | VTY_NEWLINE); |
| 11453 | return CMD_WARNING; |
| 11454 | } |
| 11455 | |
| 11456 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11457 | PEER_FLAG_RSERVER_CLIENT)) |
| 11458 | { |
| 11459 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11460 | VTY_NEWLINE); |
| 11461 | return CMD_WARNING; |
| 11462 | } |
| 11463 | |
| 11464 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11465 | (argc == 4) ? argv[3] : argv[2], |
| 11466 | AFI_IP6, safi, NULL, 0); |
| 11467 | } |
| 11468 | |
| 11469 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 11470 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 11471 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11472 | SHOW_STR |
| 11473 | BGP_STR |
| 11474 | "Address family\n" |
| 11475 | "Address Family modifier\n" |
| 11476 | "Address Family modifier\n" |
| 11477 | "Information about Route Server Client\n" |
| 11478 | NEIGHBOR_ADDR_STR |
| 11479 | "Network in the BGP routing table to display\n") |
| 11480 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11481 | DEFUN (show_bgp_view_rsclient_prefix, |
| 11482 | show_bgp_view_rsclient_prefix_cmd, |
| 11483 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11484 | SHOW_STR |
| 11485 | BGP_STR |
| 11486 | "BGP view\n" |
| 11487 | "BGP view name\n" |
| 11488 | "Information about Route Server Client\n" |
| 11489 | NEIGHBOR_ADDR_STR |
| 11490 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11491 | { |
| 11492 | struct bgp *bgp; |
| 11493 | struct peer *peer; |
| 11494 | |
| 11495 | /* BGP structure lookup. */ |
| 11496 | if (argc == 3) |
| 11497 | { |
| 11498 | bgp = bgp_lookup_by_name (argv[0]); |
| 11499 | if (bgp == NULL) |
| 11500 | { |
| 11501 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11502 | return CMD_WARNING; |
| 11503 | } |
| 11504 | } |
| 11505 | else |
| 11506 | { |
| 11507 | bgp = bgp_get_default (); |
| 11508 | if (bgp == NULL) |
| 11509 | { |
| 11510 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11511 | return CMD_WARNING; |
| 11512 | } |
| 11513 | } |
| 11514 | |
| 11515 | if (argc == 3) |
| 11516 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11517 | else |
| 11518 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11519 | |
| 11520 | if (! peer) |
| 11521 | return CMD_WARNING; |
| 11522 | |
| 11523 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11524 | { |
| 11525 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11526 | VTY_NEWLINE); |
| 11527 | return CMD_WARNING; |
| 11528 | } |
| 11529 | |
| 11530 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11531 | PEER_FLAG_RSERVER_CLIENT)) |
| 11532 | { |
| 11533 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11534 | VTY_NEWLINE); |
| 11535 | return CMD_WARNING; |
| 11536 | } |
| 11537 | |
| 11538 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11539 | (argc == 3) ? argv[2] : argv[1], |
| 11540 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 11541 | } |
| 11542 | |
| 11543 | ALIAS (show_bgp_view_rsclient_prefix, |
| 11544 | show_bgp_rsclient_prefix_cmd, |
| 11545 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11546 | SHOW_STR |
| 11547 | BGP_STR |
| 11548 | "Information about Route Server Client\n" |
| 11549 | NEIGHBOR_ADDR_STR |
| 11550 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11551 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11552 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11553 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 11554 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11555 | SHOW_STR |
| 11556 | BGP_STR |
| 11557 | "BGP view\n" |
| 11558 | "BGP view name\n" |
| 11559 | "Address family\n" |
| 11560 | "Address Family modifier\n" |
| 11561 | "Address Family modifier\n" |
| 11562 | "Information about Route Server Client\n" |
| 11563 | NEIGHBOR_ADDR_STR |
| 11564 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11565 | { |
| 11566 | struct bgp *bgp; |
| 11567 | struct peer *peer; |
| 11568 | safi_t safi; |
| 11569 | |
| 11570 | /* BGP structure lookup. */ |
| 11571 | if (argc == 4) |
| 11572 | { |
| 11573 | bgp = bgp_lookup_by_name (argv[0]); |
| 11574 | if (bgp == NULL) |
| 11575 | { |
| 11576 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11577 | return CMD_WARNING; |
| 11578 | } |
| 11579 | } |
| 11580 | else |
| 11581 | { |
| 11582 | bgp = bgp_get_default (); |
| 11583 | if (bgp == NULL) |
| 11584 | { |
| 11585 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11586 | return CMD_WARNING; |
| 11587 | } |
| 11588 | } |
| 11589 | |
| 11590 | if (argc == 4) { |
| 11591 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11592 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11593 | } else { |
| 11594 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11595 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11596 | } |
| 11597 | |
| 11598 | if (! peer) |
| 11599 | return CMD_WARNING; |
| 11600 | |
| 11601 | if (! peer->afc[AFI_IP6][safi]) |
| 11602 | { |
| 11603 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11604 | VTY_NEWLINE); |
| 11605 | return CMD_WARNING; |
| 11606 | } |
| 11607 | |
| 11608 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11609 | PEER_FLAG_RSERVER_CLIENT)) |
| 11610 | { |
| 11611 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11612 | VTY_NEWLINE); |
| 11613 | return CMD_WARNING; |
| 11614 | } |
| 11615 | |
| 11616 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11617 | (argc == 4) ? argv[3] : argv[2], |
| 11618 | AFI_IP6, safi, NULL, 1); |
| 11619 | } |
| 11620 | |
| 11621 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11622 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 11623 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11624 | SHOW_STR |
| 11625 | BGP_STR |
| 11626 | "Address family\n" |
| 11627 | "Address Family modifier\n" |
| 11628 | "Address Family modifier\n" |
| 11629 | "Information about Route Server Client\n" |
| 11630 | NEIGHBOR_ADDR_STR |
| 11631 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11632 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11633 | #endif /* HAVE_IPV6 */ |
| 11634 | |
| 11635 | struct bgp_table *bgp_distance_table; |
| 11636 | |
| 11637 | struct bgp_distance |
| 11638 | { |
| 11639 | /* Distance value for the IP source prefix. */ |
| 11640 | u_char distance; |
| 11641 | |
| 11642 | /* Name of the access-list to be matched. */ |
| 11643 | char *access_list; |
| 11644 | }; |
| 11645 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11646 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 11647 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11648 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 11649 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11650 | } |
| 11651 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11652 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11653 | bgp_distance_free (struct bgp_distance *bdistance) |
| 11654 | { |
| 11655 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 11656 | } |
| 11657 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11658 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11659 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 11660 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11661 | { |
| 11662 | int ret; |
| 11663 | struct prefix_ipv4 p; |
| 11664 | u_char distance; |
| 11665 | struct bgp_node *rn; |
| 11666 | struct bgp_distance *bdistance; |
| 11667 | |
| 11668 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11669 | if (ret == 0) |
| 11670 | { |
| 11671 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11672 | return CMD_WARNING; |
| 11673 | } |
| 11674 | |
| 11675 | distance = atoi (distance_str); |
| 11676 | |
| 11677 | /* Get BGP distance node. */ |
| 11678 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 11679 | if (rn->info) |
| 11680 | { |
| 11681 | bdistance = rn->info; |
| 11682 | bgp_unlock_node (rn); |
| 11683 | } |
| 11684 | else |
| 11685 | { |
| 11686 | bdistance = bgp_distance_new (); |
| 11687 | rn->info = bdistance; |
| 11688 | } |
| 11689 | |
| 11690 | /* Set distance value. */ |
| 11691 | bdistance->distance = distance; |
| 11692 | |
| 11693 | /* Reset access-list configuration. */ |
| 11694 | if (bdistance->access_list) |
| 11695 | { |
| 11696 | free (bdistance->access_list); |
| 11697 | bdistance->access_list = NULL; |
| 11698 | } |
| 11699 | if (access_list_str) |
| 11700 | bdistance->access_list = strdup (access_list_str); |
| 11701 | |
| 11702 | return CMD_SUCCESS; |
| 11703 | } |
| 11704 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11705 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11706 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 11707 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11708 | { |
| 11709 | int ret; |
| 11710 | struct prefix_ipv4 p; |
| 11711 | u_char distance; |
| 11712 | struct bgp_node *rn; |
| 11713 | struct bgp_distance *bdistance; |
| 11714 | |
| 11715 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11716 | if (ret == 0) |
| 11717 | { |
| 11718 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11719 | return CMD_WARNING; |
| 11720 | } |
| 11721 | |
| 11722 | distance = atoi (distance_str); |
| 11723 | |
| 11724 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 11725 | if (! rn) |
| 11726 | { |
| 11727 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 11728 | return CMD_WARNING; |
| 11729 | } |
| 11730 | |
| 11731 | bdistance = rn->info; |
| 11732 | |
| 11733 | if (bdistance->access_list) |
| 11734 | free (bdistance->access_list); |
| 11735 | bgp_distance_free (bdistance); |
| 11736 | |
| 11737 | rn->info = NULL; |
| 11738 | bgp_unlock_node (rn); |
| 11739 | bgp_unlock_node (rn); |
| 11740 | |
| 11741 | return CMD_SUCCESS; |
| 11742 | } |
| 11743 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11744 | /* Apply BGP information to distance method. */ |
| 11745 | u_char |
| 11746 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 11747 | { |
| 11748 | struct bgp_node *rn; |
| 11749 | struct prefix_ipv4 q; |
| 11750 | struct peer *peer; |
| 11751 | struct bgp_distance *bdistance; |
| 11752 | struct access_list *alist; |
| 11753 | struct bgp_static *bgp_static; |
| 11754 | |
| 11755 | if (! bgp) |
| 11756 | return 0; |
| 11757 | |
| 11758 | if (p->family != AF_INET) |
| 11759 | return 0; |
| 11760 | |
| 11761 | peer = rinfo->peer; |
| 11762 | |
| 11763 | if (peer->su.sa.sa_family != AF_INET) |
| 11764 | return 0; |
| 11765 | |
| 11766 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 11767 | q.family = AF_INET; |
| 11768 | q.prefix = peer->su.sin.sin_addr; |
| 11769 | q.prefixlen = IPV4_MAX_BITLEN; |
| 11770 | |
| 11771 | /* Check source address. */ |
| 11772 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 11773 | if (rn) |
| 11774 | { |
| 11775 | bdistance = rn->info; |
| 11776 | bgp_unlock_node (rn); |
| 11777 | |
| 11778 | if (bdistance->access_list) |
| 11779 | { |
| 11780 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 11781 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 11782 | return bdistance->distance; |
| 11783 | } |
| 11784 | else |
| 11785 | return bdistance->distance; |
| 11786 | } |
| 11787 | |
| 11788 | /* Backdoor check. */ |
| 11789 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 11790 | if (rn) |
| 11791 | { |
| 11792 | bgp_static = rn->info; |
| 11793 | bgp_unlock_node (rn); |
| 11794 | |
| 11795 | if (bgp_static->backdoor) |
| 11796 | { |
| 11797 | if (bgp->distance_local) |
| 11798 | return bgp->distance_local; |
| 11799 | else |
| 11800 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11801 | } |
| 11802 | } |
| 11803 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 11804 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11805 | { |
| 11806 | if (bgp->distance_ebgp) |
| 11807 | return bgp->distance_ebgp; |
| 11808 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 11809 | } |
| 11810 | else |
| 11811 | { |
| 11812 | if (bgp->distance_ibgp) |
| 11813 | return bgp->distance_ibgp; |
| 11814 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11815 | } |
| 11816 | } |
| 11817 | |
| 11818 | DEFUN (bgp_distance, |
| 11819 | bgp_distance_cmd, |
| 11820 | "distance bgp <1-255> <1-255> <1-255>", |
| 11821 | "Define an administrative distance\n" |
| 11822 | "BGP distance\n" |
| 11823 | "Distance for routes external to the AS\n" |
| 11824 | "Distance for routes internal to the AS\n" |
| 11825 | "Distance for local routes\n") |
| 11826 | { |
| 11827 | struct bgp *bgp; |
| 11828 | |
| 11829 | bgp = vty->index; |
| 11830 | |
| 11831 | bgp->distance_ebgp = atoi (argv[0]); |
| 11832 | bgp->distance_ibgp = atoi (argv[1]); |
| 11833 | bgp->distance_local = atoi (argv[2]); |
| 11834 | return CMD_SUCCESS; |
| 11835 | } |
| 11836 | |
| 11837 | DEFUN (no_bgp_distance, |
| 11838 | no_bgp_distance_cmd, |
| 11839 | "no distance bgp <1-255> <1-255> <1-255>", |
| 11840 | NO_STR |
| 11841 | "Define an administrative distance\n" |
| 11842 | "BGP distance\n" |
| 11843 | "Distance for routes external to the AS\n" |
| 11844 | "Distance for routes internal to the AS\n" |
| 11845 | "Distance for local routes\n") |
| 11846 | { |
| 11847 | struct bgp *bgp; |
| 11848 | |
| 11849 | bgp = vty->index; |
| 11850 | |
| 11851 | bgp->distance_ebgp= 0; |
| 11852 | bgp->distance_ibgp = 0; |
| 11853 | bgp->distance_local = 0; |
| 11854 | return CMD_SUCCESS; |
| 11855 | } |
| 11856 | |
| 11857 | ALIAS (no_bgp_distance, |
| 11858 | no_bgp_distance2_cmd, |
| 11859 | "no distance bgp", |
| 11860 | NO_STR |
| 11861 | "Define an administrative distance\n" |
| 11862 | "BGP distance\n") |
| 11863 | |
| 11864 | DEFUN (bgp_distance_source, |
| 11865 | bgp_distance_source_cmd, |
| 11866 | "distance <1-255> A.B.C.D/M", |
| 11867 | "Define an administrative distance\n" |
| 11868 | "Administrative distance\n" |
| 11869 | "IP source prefix\n") |
| 11870 | { |
| 11871 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 11872 | return CMD_SUCCESS; |
| 11873 | } |
| 11874 | |
| 11875 | DEFUN (no_bgp_distance_source, |
| 11876 | no_bgp_distance_source_cmd, |
| 11877 | "no distance <1-255> A.B.C.D/M", |
| 11878 | NO_STR |
| 11879 | "Define an administrative distance\n" |
| 11880 | "Administrative distance\n" |
| 11881 | "IP source prefix\n") |
| 11882 | { |
| 11883 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 11884 | return CMD_SUCCESS; |
| 11885 | } |
| 11886 | |
| 11887 | DEFUN (bgp_distance_source_access_list, |
| 11888 | bgp_distance_source_access_list_cmd, |
| 11889 | "distance <1-255> A.B.C.D/M WORD", |
| 11890 | "Define an administrative distance\n" |
| 11891 | "Administrative distance\n" |
| 11892 | "IP source prefix\n" |
| 11893 | "Access list name\n") |
| 11894 | { |
| 11895 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 11896 | return CMD_SUCCESS; |
| 11897 | } |
| 11898 | |
| 11899 | DEFUN (no_bgp_distance_source_access_list, |
| 11900 | no_bgp_distance_source_access_list_cmd, |
| 11901 | "no distance <1-255> A.B.C.D/M WORD", |
| 11902 | NO_STR |
| 11903 | "Define an administrative distance\n" |
| 11904 | "Administrative distance\n" |
| 11905 | "IP source prefix\n" |
| 11906 | "Access list name\n") |
| 11907 | { |
| 11908 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 11909 | return CMD_SUCCESS; |
| 11910 | } |
| 11911 | |
| 11912 | DEFUN (bgp_damp_set, |
| 11913 | bgp_damp_set_cmd, |
| 11914 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 11915 | "BGP Specific commands\n" |
| 11916 | "Enable route-flap dampening\n" |
| 11917 | "Half-life time for the penalty\n" |
| 11918 | "Value to start reusing a route\n" |
| 11919 | "Value to start suppressing a route\n" |
| 11920 | "Maximum duration to suppress a stable route\n") |
| 11921 | { |
| 11922 | struct bgp *bgp; |
| 11923 | int half = DEFAULT_HALF_LIFE * 60; |
| 11924 | int reuse = DEFAULT_REUSE; |
| 11925 | int suppress = DEFAULT_SUPPRESS; |
| 11926 | int max = 4 * half; |
| 11927 | |
| 11928 | if (argc == 4) |
| 11929 | { |
| 11930 | half = atoi (argv[0]) * 60; |
| 11931 | reuse = atoi (argv[1]); |
| 11932 | suppress = atoi (argv[2]); |
| 11933 | max = atoi (argv[3]) * 60; |
| 11934 | } |
| 11935 | else if (argc == 1) |
| 11936 | { |
| 11937 | half = atoi (argv[0]) * 60; |
| 11938 | max = 4 * half; |
| 11939 | } |
| 11940 | |
| 11941 | bgp = vty->index; |
| 11942 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 11943 | half, reuse, suppress, max); |
| 11944 | } |
| 11945 | |
| 11946 | ALIAS (bgp_damp_set, |
| 11947 | bgp_damp_set2_cmd, |
| 11948 | "bgp dampening <1-45>", |
| 11949 | "BGP Specific commands\n" |
| 11950 | "Enable route-flap dampening\n" |
| 11951 | "Half-life time for the penalty\n") |
| 11952 | |
| 11953 | ALIAS (bgp_damp_set, |
| 11954 | bgp_damp_set3_cmd, |
| 11955 | "bgp dampening", |
| 11956 | "BGP Specific commands\n" |
| 11957 | "Enable route-flap dampening\n") |
| 11958 | |
| 11959 | DEFUN (bgp_damp_unset, |
| 11960 | bgp_damp_unset_cmd, |
| 11961 | "no bgp dampening", |
| 11962 | NO_STR |
| 11963 | "BGP Specific commands\n" |
| 11964 | "Enable route-flap dampening\n") |
| 11965 | { |
| 11966 | struct bgp *bgp; |
| 11967 | |
| 11968 | bgp = vty->index; |
| 11969 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 11970 | } |
| 11971 | |
| 11972 | ALIAS (bgp_damp_unset, |
| 11973 | bgp_damp_unset2_cmd, |
| 11974 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 11975 | NO_STR |
| 11976 | "BGP Specific commands\n" |
| 11977 | "Enable route-flap dampening\n" |
| 11978 | "Half-life time for the penalty\n" |
| 11979 | "Value to start reusing a route\n" |
| 11980 | "Value to start suppressing a route\n" |
| 11981 | "Maximum duration to suppress a stable route\n") |
| 11982 | |
| 11983 | DEFUN (show_ip_bgp_dampened_paths, |
| 11984 | show_ip_bgp_dampened_paths_cmd, |
| 11985 | "show ip bgp dampened-paths", |
| 11986 | SHOW_STR |
| 11987 | IP_STR |
| 11988 | BGP_STR |
| 11989 | "Display paths suppressed due to dampening\n") |
| 11990 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11991 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 11992 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11993 | } |
| 11994 | |
| 11995 | DEFUN (show_ip_bgp_flap_statistics, |
| 11996 | show_ip_bgp_flap_statistics_cmd, |
| 11997 | "show ip bgp flap-statistics", |
| 11998 | SHOW_STR |
| 11999 | IP_STR |
| 12000 | BGP_STR |
| 12001 | "Display flap statistics of routes\n") |
| 12002 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12003 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 12004 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12005 | } |
| 12006 | |
| 12007 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12008 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 12009 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 12010 | const char *ip_str, afi_t afi, safi_t safi, |
| 12011 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12012 | { |
| 12013 | int ret; |
| 12014 | struct prefix match; |
| 12015 | struct bgp_node *rn; |
| 12016 | struct bgp_node *rm; |
| 12017 | struct bgp_info *ri; |
| 12018 | struct bgp_info *ri_temp; |
| 12019 | struct bgp *bgp; |
| 12020 | struct bgp_table *table; |
| 12021 | |
| 12022 | /* BGP structure lookup. */ |
| 12023 | if (view_name) |
| 12024 | { |
| 12025 | bgp = bgp_lookup_by_name (view_name); |
| 12026 | if (bgp == NULL) |
| 12027 | { |
| 12028 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 12029 | return CMD_WARNING; |
| 12030 | } |
| 12031 | } |
| 12032 | else |
| 12033 | { |
| 12034 | bgp = bgp_get_default (); |
| 12035 | if (bgp == NULL) |
| 12036 | { |
| 12037 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 12038 | return CMD_WARNING; |
| 12039 | } |
| 12040 | } |
| 12041 | |
| 12042 | /* Check IP address argument. */ |
| 12043 | ret = str2prefix (ip_str, &match); |
| 12044 | if (! ret) |
| 12045 | { |
| 12046 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 12047 | return CMD_WARNING; |
| 12048 | } |
| 12049 | |
| 12050 | match.family = afi2family (afi); |
| 12051 | |
| 12052 | if (safi == SAFI_MPLS_VPN) |
| 12053 | { |
| 12054 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 12055 | { |
| 12056 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 12057 | continue; |
| 12058 | |
| 12059 | if ((table = rn->info) != NULL) |
| 12060 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12061 | { |
| 12062 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 12063 | { |
| 12064 | ri = rm->info; |
| 12065 | while (ri) |
| 12066 | { |
| 12067 | if (ri->extra && ri->extra->damp_info) |
| 12068 | { |
| 12069 | ri_temp = ri->next; |
| 12070 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12071 | ri = ri_temp; |
| 12072 | } |
| 12073 | else |
| 12074 | ri = ri->next; |
| 12075 | } |
| 12076 | } |
| 12077 | |
| 12078 | bgp_unlock_node (rm); |
| 12079 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12080 | } |
| 12081 | } |
| 12082 | else |
| 12083 | { |
| 12084 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12085 | { |
| 12086 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 12087 | { |
| 12088 | ri = rn->info; |
| 12089 | while (ri) |
| 12090 | { |
| 12091 | if (ri->extra && ri->extra->damp_info) |
| 12092 | { |
| 12093 | ri_temp = ri->next; |
| 12094 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12095 | ri = ri_temp; |
| 12096 | } |
| 12097 | else |
| 12098 | ri = ri->next; |
| 12099 | } |
| 12100 | } |
| 12101 | |
| 12102 | bgp_unlock_node (rn); |
| 12103 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12104 | } |
| 12105 | |
| 12106 | return CMD_SUCCESS; |
| 12107 | } |
| 12108 | |
| 12109 | DEFUN (clear_ip_bgp_dampening, |
| 12110 | clear_ip_bgp_dampening_cmd, |
| 12111 | "clear ip bgp dampening", |
| 12112 | CLEAR_STR |
| 12113 | IP_STR |
| 12114 | BGP_STR |
| 12115 | "Clear route flap dampening information\n") |
| 12116 | { |
| 12117 | bgp_damp_info_clean (); |
| 12118 | return CMD_SUCCESS; |
| 12119 | } |
| 12120 | |
| 12121 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 12122 | clear_ip_bgp_dampening_prefix_cmd, |
| 12123 | "clear ip bgp dampening A.B.C.D/M", |
| 12124 | CLEAR_STR |
| 12125 | IP_STR |
| 12126 | BGP_STR |
| 12127 | "Clear route flap dampening information\n" |
| 12128 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 12129 | { |
| 12130 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12131 | SAFI_UNICAST, NULL, 1); |
| 12132 | } |
| 12133 | |
| 12134 | DEFUN (clear_ip_bgp_dampening_address, |
| 12135 | clear_ip_bgp_dampening_address_cmd, |
| 12136 | "clear ip bgp dampening A.B.C.D", |
| 12137 | CLEAR_STR |
| 12138 | IP_STR |
| 12139 | BGP_STR |
| 12140 | "Clear route flap dampening information\n" |
| 12141 | "Network to clear damping information\n") |
| 12142 | { |
| 12143 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12144 | SAFI_UNICAST, NULL, 0); |
| 12145 | } |
| 12146 | |
| 12147 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 12148 | clear_ip_bgp_dampening_address_mask_cmd, |
| 12149 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 12150 | CLEAR_STR |
| 12151 | IP_STR |
| 12152 | BGP_STR |
| 12153 | "Clear route flap dampening information\n" |
| 12154 | "Network to clear damping information\n" |
| 12155 | "Network mask\n") |
| 12156 | { |
| 12157 | int ret; |
| 12158 | char prefix_str[BUFSIZ]; |
| 12159 | |
| 12160 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 12161 | if (! ret) |
| 12162 | { |
| 12163 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 12164 | return CMD_WARNING; |
| 12165 | } |
| 12166 | |
| 12167 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 12168 | SAFI_UNICAST, NULL, 0); |
| 12169 | } |
| 12170 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12171 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12172 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 12173 | afi_t afi, safi_t safi, int *write) |
| 12174 | { |
| 12175 | struct bgp_node *prn; |
| 12176 | struct bgp_node *rn; |
| 12177 | struct bgp_table *table; |
| 12178 | struct prefix *p; |
| 12179 | struct prefix_rd *prd; |
| 12180 | struct bgp_static *bgp_static; |
| 12181 | u_int32_t label; |
| 12182 | char buf[SU_ADDRSTRLEN]; |
| 12183 | char rdbuf[RD_ADDRSTRLEN]; |
| 12184 | |
| 12185 | /* Network configuration. */ |
| 12186 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 12187 | if ((table = prn->info) != NULL) |
| 12188 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12189 | if ((bgp_static = rn->info) != NULL) |
| 12190 | { |
| 12191 | p = &rn->p; |
| 12192 | prd = (struct prefix_rd *) &prn->p; |
| 12193 | |
| 12194 | /* "address-family" display. */ |
| 12195 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12196 | |
| 12197 | /* "network" configuration display. */ |
| 12198 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 12199 | label = decode_label (bgp_static->tag); |
| 12200 | |
| 12201 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 12202 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12203 | p->prefixlen, |
| 12204 | rdbuf, label); |
| 12205 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12206 | } |
| 12207 | return 0; |
| 12208 | } |
| 12209 | |
| 12210 | /* Configuration of static route announcement and aggregate |
| 12211 | information. */ |
| 12212 | int |
| 12213 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 12214 | afi_t afi, safi_t safi, int *write) |
| 12215 | { |
| 12216 | struct bgp_node *rn; |
| 12217 | struct prefix *p; |
| 12218 | struct bgp_static *bgp_static; |
| 12219 | struct bgp_aggregate *bgp_aggregate; |
| 12220 | char buf[SU_ADDRSTRLEN]; |
| 12221 | |
| 12222 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 12223 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 12224 | |
| 12225 | /* Network configuration. */ |
| 12226 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12227 | if ((bgp_static = rn->info) != NULL) |
| 12228 | { |
| 12229 | p = &rn->p; |
| 12230 | |
| 12231 | /* "address-family" display. */ |
| 12232 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12233 | |
| 12234 | /* "network" configuration display. */ |
| 12235 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12236 | { |
| 12237 | u_int32_t destination; |
| 12238 | struct in_addr netmask; |
| 12239 | |
| 12240 | destination = ntohl (p->u.prefix4.s_addr); |
| 12241 | masklen2ip (p->prefixlen, &netmask); |
| 12242 | vty_out (vty, " network %s", |
| 12243 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 12244 | |
| 12245 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 12246 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 12247 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 12248 | || p->u.prefix4.s_addr == 0) |
| 12249 | { |
| 12250 | /* Natural mask is not display. */ |
| 12251 | } |
| 12252 | else |
| 12253 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 12254 | } |
| 12255 | else |
| 12256 | { |
| 12257 | vty_out (vty, " network %s/%d", |
| 12258 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12259 | p->prefixlen); |
| 12260 | } |
| 12261 | |
| 12262 | if (bgp_static->rmap.name) |
| 12263 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12264 | else |
| 12265 | { |
| 12266 | if (bgp_static->backdoor) |
| 12267 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12268 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12269 | |
| 12270 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12271 | } |
| 12272 | |
| 12273 | /* Aggregate-address configuration. */ |
| 12274 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12275 | if ((bgp_aggregate = rn->info) != NULL) |
| 12276 | { |
| 12277 | p = &rn->p; |
| 12278 | |
| 12279 | /* "address-family" display. */ |
| 12280 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12281 | |
| 12282 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12283 | { |
| 12284 | struct in_addr netmask; |
| 12285 | |
| 12286 | masklen2ip (p->prefixlen, &netmask); |
| 12287 | vty_out (vty, " aggregate-address %s %s", |
| 12288 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12289 | inet_ntoa (netmask)); |
| 12290 | } |
| 12291 | else |
| 12292 | { |
| 12293 | vty_out (vty, " aggregate-address %s/%d", |
| 12294 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12295 | p->prefixlen); |
| 12296 | } |
| 12297 | |
| 12298 | if (bgp_aggregate->as_set) |
| 12299 | vty_out (vty, " as-set"); |
| 12300 | |
| 12301 | if (bgp_aggregate->summary_only) |
| 12302 | vty_out (vty, " summary-only"); |
| 12303 | |
| 12304 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12305 | } |
| 12306 | |
| 12307 | return 0; |
| 12308 | } |
| 12309 | |
| 12310 | int |
| 12311 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 12312 | { |
| 12313 | struct bgp_node *rn; |
| 12314 | struct bgp_distance *bdistance; |
| 12315 | |
| 12316 | /* Distance configuration. */ |
| 12317 | if (bgp->distance_ebgp |
| 12318 | && bgp->distance_ibgp |
| 12319 | && bgp->distance_local |
| 12320 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 12321 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 12322 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 12323 | vty_out (vty, " distance bgp %d %d %d%s", |
| 12324 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 12325 | VTY_NEWLINE); |
| 12326 | |
| 12327 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 12328 | if ((bdistance = rn->info) != NULL) |
| 12329 | { |
| 12330 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 12331 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 12332 | bdistance->access_list ? bdistance->access_list : "", |
| 12333 | VTY_NEWLINE); |
| 12334 | } |
| 12335 | |
| 12336 | return 0; |
| 12337 | } |
| 12338 | |
| 12339 | /* Allocate routing table structure and install commands. */ |
| 12340 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 12341 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12342 | { |
| 12343 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 12344 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12345 | |
| 12346 | /* IPv4 BGP commands. */ |
| 12347 | install_element (BGP_NODE, &bgp_network_cmd); |
| 12348 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 12349 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 12350 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 12351 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 12352 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12353 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 12354 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 12355 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 12356 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 12357 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 12358 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 12359 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 12360 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12361 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12362 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 12363 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 12364 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 12365 | |
| 12366 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 12367 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 12368 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 12369 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12370 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 12371 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 12372 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 12373 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12374 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 12375 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12376 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 12377 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 12378 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 12379 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12380 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12381 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 12382 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12383 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12384 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12385 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12386 | |
| 12387 | /* IPv4 unicast configuration. */ |
| 12388 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 12389 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 12390 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 12391 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 12392 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 12393 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 12394 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12395 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 12396 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 12397 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 12398 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12399 | 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] | 12400 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12401 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 12402 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 12403 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 12404 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12405 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 12406 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 12407 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 12408 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12409 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 12410 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12411 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 12412 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 12413 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 12414 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12415 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12416 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 12417 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12418 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12419 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12420 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12421 | |
| 12422 | /* IPv4 multicast configuration. */ |
| 12423 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 12424 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 12425 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 12426 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 12427 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 12428 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12429 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 12430 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 12431 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 12432 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 12433 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12434 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12435 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 12436 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 12437 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 12438 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12439 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 12440 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 12441 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 12442 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12443 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 12444 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12445 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 12446 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 12447 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 12448 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12449 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12450 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 12451 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12452 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12453 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12454 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12455 | |
| 12456 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 12457 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12458 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12459 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 12460 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12461 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12462 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12463 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12464 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 12465 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12466 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12467 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12468 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12469 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 12470 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 12471 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12472 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 12473 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12474 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12475 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12476 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 12477 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12478 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 12479 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12480 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12481 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12482 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 12483 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12484 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 12485 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 12486 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 12487 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 12488 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12489 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12490 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12491 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12492 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12493 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12494 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12495 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12496 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12497 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 12498 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12499 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12500 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12501 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12502 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12503 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12504 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12505 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 12506 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12507 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12508 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12509 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12510 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12511 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12512 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12513 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12514 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12515 | 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] | 12516 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12517 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12518 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12519 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 12520 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 12521 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 12522 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 12523 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12524 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 12525 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12526 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 12527 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 12528 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 12529 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 12530 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12531 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12532 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12533 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12534 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12535 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12536 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12537 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12538 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12539 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12540 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12541 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12542 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12543 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12544 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12545 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12546 | |
| 12547 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
| 12548 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
| 12549 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12550 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12551 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12552 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 12553 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12554 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12555 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12556 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12557 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 12558 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12559 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 12560 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 12561 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 12562 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 12563 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12564 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12565 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12566 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12567 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12568 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12569 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12570 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12571 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12572 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 12573 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12574 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12575 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12576 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12577 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12578 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12579 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12580 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12581 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12582 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12583 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12584 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12585 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12586 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12587 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12588 | |
| 12589 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 12590 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12591 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12592 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 12593 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12594 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12595 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12596 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12597 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 12598 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12599 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12600 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12601 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12602 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 12603 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 12604 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12605 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 12606 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12607 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12608 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12609 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 12610 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12611 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 12612 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12613 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12614 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12615 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 12616 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12617 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 12618 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 12619 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 12620 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 12621 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12622 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12623 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12624 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12625 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12626 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12627 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12628 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12629 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12630 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 12631 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12632 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12633 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12634 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12635 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12636 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12637 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12638 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 12639 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12640 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12641 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12642 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12643 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12644 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12645 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12646 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12647 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12648 | 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] | 12649 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12650 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12651 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12652 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 12653 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 12654 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 12655 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 12656 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12657 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 12658 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12659 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 12660 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 12661 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 12662 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 12663 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12664 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12665 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12666 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12667 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12668 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12669 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12670 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12671 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12672 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12673 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12674 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12675 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12676 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12677 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12678 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12679 | |
| 12680 | /* BGP dampening clear commands */ |
| 12681 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 12682 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 12683 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 12684 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 12685 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12686 | /* prefix count */ |
| 12687 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 12688 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 12689 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12690 | #ifdef HAVE_IPV6 |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12691 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 12692 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12693 | /* New config IPv6 BGP commands. */ |
| 12694 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 12695 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 12696 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 12697 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 12698 | |
| 12699 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 12700 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 12701 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 12702 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 12703 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 12704 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 12705 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 12706 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12707 | /* Old config IPv6 BGP commands. */ |
| 12708 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 12709 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 12710 | |
| 12711 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 12712 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 12713 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 12714 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 12715 | |
| 12716 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 12717 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12718 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12719 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 12720 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12721 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12722 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 12723 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12724 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12725 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 12726 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12727 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 12728 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12729 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 12730 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12731 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 12732 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12733 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 12734 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12735 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 12736 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 12737 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 12738 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 12739 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 12740 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 12741 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 12742 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 12743 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 12744 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12745 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 12746 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12747 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 12748 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12749 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 12750 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12751 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 12752 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12753 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 12754 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12755 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 12756 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12757 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12758 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12759 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12760 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12761 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 12762 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12763 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12764 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12765 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 12766 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12767 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 12768 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12769 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12770 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12771 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12772 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12773 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12774 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12775 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 12776 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 12777 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 12778 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12779 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 12780 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12781 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12782 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12783 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12784 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12785 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12786 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12787 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12788 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12789 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12790 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12791 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12792 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12793 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12794 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12795 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12796 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12797 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12798 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12799 | |
| 12800 | /* Restricted: |
| 12801 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 12802 | */ |
| 12803 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 12804 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12805 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12806 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
| 12807 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12808 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12809 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 12810 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 12811 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 12812 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 12813 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 12814 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 12815 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 12816 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 12817 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 12818 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12819 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 12820 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12821 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 12822 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12823 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 12824 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12825 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12826 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12827 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12828 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12829 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 12830 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12831 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 12832 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12833 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12834 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12835 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12836 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12837 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12838 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12839 | |
| 12840 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 12841 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12842 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12843 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 12844 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12845 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12846 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 12847 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12848 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12849 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 12850 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12851 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 12852 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12853 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 12854 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12855 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 12856 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12857 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 12858 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12859 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 12860 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 12861 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 12862 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 12863 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 12864 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 12865 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 12866 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 12867 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 12868 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12869 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 12870 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12871 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 12872 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12873 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 12874 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12875 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 12876 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12877 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 12878 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12879 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 12880 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12881 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12882 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12883 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12884 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12885 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 12886 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12887 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12888 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12889 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 12890 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12891 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 12892 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12893 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12894 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12895 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12896 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12897 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12898 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12899 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 12900 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 12901 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 12902 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12903 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 12904 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12905 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12906 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12907 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12908 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12909 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12910 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12911 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12912 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12913 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12914 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12915 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12916 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12917 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12918 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12919 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12920 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12921 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12922 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12923 | |
| 12924 | /* Statistics */ |
| 12925 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
| 12926 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 12927 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
| 12928 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
| 12929 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12930 | /* old command */ |
| 12931 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 12932 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 12933 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 12934 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 12935 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 12936 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 12937 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 12938 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 12939 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 12940 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 12941 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 12942 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 12943 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 12944 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 12945 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 12946 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 12947 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 12948 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 12949 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 12950 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 12951 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 12952 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 12953 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 12954 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 12955 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 12956 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 12957 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 12958 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 12959 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 12960 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 12961 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 12962 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 12963 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 12964 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 12965 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 12966 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12967 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12968 | /* old command */ |
| 12969 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 12970 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 12971 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 12972 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 12973 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 12974 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 12975 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 12976 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 12977 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 12978 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 12979 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 12980 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 12981 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 12982 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 12983 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 12984 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 12985 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 12986 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 12987 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 12988 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 12989 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 12990 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 12991 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 12992 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 12993 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 12994 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 12995 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 12996 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 12997 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 12998 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 12999 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 13000 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 13001 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 13002 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 13003 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 13004 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 13005 | |
| 13006 | /* old command */ |
| 13007 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13008 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13009 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13010 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13011 | |
| 13012 | /* old command */ |
| 13013 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13014 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13015 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13016 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13017 | |
| 13018 | /* old command */ |
| 13019 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13020 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13021 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13022 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13023 | #endif /* HAVE_IPV6 */ |
| 13024 | |
| 13025 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 13026 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 13027 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 13028 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 13029 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 13030 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 13031 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 13032 | |
| 13033 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 13034 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 13035 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 13036 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 13037 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 13038 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 13039 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 13040 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 13041 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 13042 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13043 | |
| 13044 | /* Deprecated AS-Pathlimit commands */ |
| 13045 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 13046 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 13047 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13048 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13049 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13050 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13051 | |
| 13052 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 13053 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13054 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13055 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13056 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13057 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13058 | |
| 13059 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 13060 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 13061 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13062 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13063 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13064 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13065 | |
| 13066 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 13067 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13068 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13069 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13070 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13071 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13072 | |
| 13073 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 13074 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 13075 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13076 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13077 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13078 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13079 | |
| 13080 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 13081 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13082 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13083 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13084 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13085 | 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] | 13086 | |
| 13087 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13088 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 13089 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 13090 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13091 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 13092 | |
| 13093 | void |
| 13094 | bgp_route_finish (void) |
| 13095 | { |
| 13096 | bgp_table_unlock (bgp_distance_table); |
| 13097 | bgp_distance_table = NULL; |
| 13098 | } |