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[]; |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [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 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 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 | { |
Pradosh Mohapatra | 2fdd455 | 2013-09-07 07:02:36 +0000 | [diff] [blame] | 483 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) |
| 484 | { |
| 485 | |
| 486 | /* |
| 487 | * For the two paths, all comparison steps till IGP metric |
| 488 | * have succeeded - including AS_PATH hop count. Since 'bgp |
| 489 | * bestpath as-path multipath-relax' knob is on, we don't need |
| 490 | * an exact match of AS_PATH. Thus, mark the paths are equal. |
| 491 | * That will trigger both these paths to get into the multipath |
| 492 | * array. |
| 493 | */ |
| 494 | *paths_eq = 1; |
| 495 | } |
| 496 | else if (new->peer->sort == BGP_PEER_IBGP) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 497 | { |
| 498 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) |
| 499 | *paths_eq = 1; |
| 500 | } |
| 501 | else if (new->peer->as == exist->peer->as) |
| 502 | *paths_eq = 1; |
| 503 | } |
| 504 | else |
| 505 | { |
| 506 | /* |
| 507 | * TODO: If unequal cost ibgp multipath is enabled we can |
| 508 | * mark the paths as equal here instead of returning |
| 509 | */ |
| 510 | return ret; |
| 511 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 512 | |
| 513 | /* 10. If both paths are external, prefer the path that was received |
| 514 | first (the oldest one). This step minimizes route-flap, since a |
| 515 | newer path won't displace an older one, even if it was the |
| 516 | preferred route based on the additional decision criteria below. */ |
| 517 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 518 | && new_sort == BGP_PEER_EBGP |
| 519 | && exist_sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 520 | { |
| 521 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
| 522 | return 1; |
| 523 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
| 524 | return 0; |
| 525 | } |
| 526 | |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 527 | /* 11. Router-ID comparision. */ |
| 528 | /* If one of the paths is "stale", the corresponding peer router-id will |
| 529 | * be 0 and would always win over the other path. If originator id is |
| 530 | * used for the comparision, it will decide which path is better. |
| 531 | */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 532 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 533 | new_id.s_addr = newattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 534 | else |
| 535 | new_id.s_addr = new->peer->remote_id.s_addr; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 536 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 537 | exist_id.s_addr = existattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 538 | else |
| 539 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 540 | |
| 541 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 542 | return 1; |
| 543 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 544 | return 0; |
| 545 | |
| 546 | /* 12. Cluster length comparision. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 547 | new_cluster = exist_cluster = 0; |
| 548 | |
| 549 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 550 | new_cluster = newattre->cluster->length; |
| 551 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 552 | exist_cluster = existattre->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 553 | |
| 554 | if (new_cluster < exist_cluster) |
| 555 | return 1; |
| 556 | if (new_cluster > exist_cluster) |
| 557 | return 0; |
| 558 | |
| 559 | /* 13. Neighbor address comparision. */ |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 560 | /* Do this only if neither path is "stale" as stale paths do not have |
| 561 | * valid peer information (as the connection may or may not be up). |
| 562 | */ |
| 563 | if (CHECK_FLAG (exist->flags, BGP_INFO_STALE)) |
| 564 | return 1; |
| 565 | if (CHECK_FLAG (new->flags, BGP_INFO_STALE)) |
| 566 | return 0; |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 567 | /* locally configured routes to advertise do not have su_remote */ |
| 568 | if (new->peer->su_remote == NULL) |
| 569 | return 0; |
| 570 | if (exist->peer->su_remote == NULL) |
| 571 | return 1; |
| 572 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 573 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 574 | |
| 575 | if (ret == 1) |
| 576 | return 0; |
| 577 | if (ret == -1) |
| 578 | return 1; |
| 579 | |
| 580 | return 1; |
| 581 | } |
| 582 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 583 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 584 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 585 | afi_t afi, safi_t safi) |
| 586 | { |
| 587 | struct bgp_filter *filter; |
| 588 | |
| 589 | filter = &peer->filter[afi][safi]; |
| 590 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 591 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 592 | if (BGP_DEBUG (update, UPDATE_IN) \ |
| 593 | && !(F ## _IN (filter))) \ |
| 594 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ |
| 595 | peer->host, #f, F ## _IN_NAME(filter)); |
| 596 | |
| 597 | if (DISTRIBUTE_IN_NAME (filter)) { |
| 598 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 599 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 600 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 601 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 602 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 603 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 604 | if (PREFIX_LIST_IN_NAME (filter)) { |
| 605 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 606 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 607 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 608 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 609 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 610 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 611 | if (FILTER_LIST_IN_NAME (filter)) { |
| 612 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 613 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 614 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 615 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 616 | } |
| 617 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 618 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 619 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 620 | } |
| 621 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 622 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 623 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 624 | afi_t afi, safi_t safi) |
| 625 | { |
| 626 | struct bgp_filter *filter; |
| 627 | |
| 628 | filter = &peer->filter[afi][safi]; |
| 629 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 630 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 631 | if (BGP_DEBUG (update, UPDATE_OUT) \ |
| 632 | && !(F ## _OUT (filter))) \ |
| 633 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ |
| 634 | peer->host, #f, F ## _OUT_NAME(filter)); |
| 635 | |
| 636 | if (DISTRIBUTE_OUT_NAME (filter)) { |
| 637 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 638 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 639 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 640 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 641 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 642 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 643 | if (PREFIX_LIST_OUT_NAME (filter)) { |
| 644 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 645 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 646 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 647 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 648 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 649 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 650 | if (FILTER_LIST_OUT_NAME (filter)) { |
| 651 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 652 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 653 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 654 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 655 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 656 | |
| 657 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 658 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 662 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 663 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 664 | { |
| 665 | if (attr->community) |
| 666 | { |
| 667 | /* NO_ADVERTISE check. */ |
| 668 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 669 | return 1; |
| 670 | |
| 671 | /* NO_EXPORT check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 672 | if (peer->sort == BGP_PEER_EBGP && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 673 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 674 | return 1; |
| 675 | |
| 676 | /* NO_EXPORT_SUBCONFED check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 677 | if (peer->sort == BGP_PEER_EBGP |
| 678 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 679 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 680 | return 1; |
| 681 | } |
| 682 | return 0; |
| 683 | } |
| 684 | |
| 685 | /* Route reflection loop check. */ |
| 686 | static int |
| 687 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 688 | { |
| 689 | struct in_addr cluster_id; |
| 690 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 691 | if (attr->extra && attr->extra->cluster) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 692 | { |
| 693 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 694 | cluster_id = peer->bgp->cluster_id; |
| 695 | else |
| 696 | cluster_id = peer->bgp->router_id; |
| 697 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 698 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 699 | return 1; |
| 700 | } |
| 701 | return 0; |
| 702 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 703 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 704 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 705 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 706 | afi_t afi, safi_t safi) |
| 707 | { |
| 708 | struct bgp_filter *filter; |
| 709 | struct bgp_info info; |
| 710 | route_map_result_t ret; |
| 711 | |
| 712 | filter = &peer->filter[afi][safi]; |
| 713 | |
| 714 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 715 | if (peer->weight) |
| 716 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 717 | |
| 718 | /* Route map apply. */ |
| 719 | if (ROUTE_MAP_IN_NAME (filter)) |
| 720 | { |
| 721 | /* Duplicate current value to new strucutre for modification. */ |
| 722 | info.peer = peer; |
| 723 | info.attr = attr; |
| 724 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 725 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 726 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 727 | /* Apply BGP route map to the attribute. */ |
| 728 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 729 | |
| 730 | peer->rmap_type = 0; |
| 731 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 732 | if (ret == RMAP_DENYMATCH) |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 733 | /* caller has multiple error paths with bgp_attr_flush() */ |
| 734 | return RMAP_DENY; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 735 | } |
| 736 | return RMAP_PERMIT; |
| 737 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 738 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 739 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 740 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 741 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 742 | { |
| 743 | struct bgp_filter *filter; |
| 744 | struct bgp_info info; |
| 745 | route_map_result_t ret; |
| 746 | |
| 747 | filter = &peer->filter[afi][safi]; |
| 748 | |
| 749 | /* Route map apply. */ |
| 750 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 751 | { |
| 752 | /* Duplicate current value to new strucutre for modification. */ |
| 753 | info.peer = rsclient; |
| 754 | info.attr = attr; |
| 755 | |
| 756 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 757 | |
| 758 | /* Apply BGP route map to the attribute. */ |
| 759 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 760 | |
| 761 | rsclient->rmap_type = 0; |
| 762 | |
| 763 | if (ret == RMAP_DENYMATCH) |
| 764 | { |
| 765 | /* Free newly generated AS path and community by route-map. */ |
| 766 | bgp_attr_flush (attr); |
| 767 | return RMAP_DENY; |
| 768 | } |
| 769 | } |
| 770 | return RMAP_PERMIT; |
| 771 | } |
| 772 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 773 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 774 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 775 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 776 | { |
| 777 | struct bgp_filter *filter; |
| 778 | struct bgp_info info; |
| 779 | route_map_result_t ret; |
| 780 | |
| 781 | filter = &rsclient->filter[afi][safi]; |
| 782 | |
| 783 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 784 | if (peer->weight) |
| 785 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 786 | |
| 787 | /* Route map apply. */ |
| 788 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 789 | { |
| 790 | /* Duplicate current value to new strucutre for modification. */ |
| 791 | info.peer = peer; |
| 792 | info.attr = attr; |
| 793 | |
| 794 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 795 | |
| 796 | /* Apply BGP route map to the attribute. */ |
| 797 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 798 | |
| 799 | peer->rmap_type = 0; |
| 800 | |
| 801 | if (ret == RMAP_DENYMATCH) |
| 802 | { |
| 803 | /* Free newly generated AS path and community by route-map. */ |
| 804 | bgp_attr_flush (attr); |
| 805 | return RMAP_DENY; |
| 806 | } |
| 807 | } |
| 808 | return RMAP_PERMIT; |
| 809 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 810 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 811 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 812 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 813 | struct attr *attr, afi_t afi, safi_t safi) |
| 814 | { |
| 815 | int ret; |
| 816 | char buf[SU_ADDRSTRLEN]; |
| 817 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 818 | struct peer *from; |
| 819 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 820 | int transparent; |
| 821 | int reflect; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 822 | struct attr *riattr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 823 | |
| 824 | from = ri->peer; |
| 825 | filter = &peer->filter[afi][safi]; |
| 826 | bgp = peer->bgp; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 827 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 828 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 829 | if (DISABLE_BGP_ANNOUNCE) |
| 830 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 831 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 832 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 833 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 834 | return 0; |
| 835 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 836 | /* Do not send back route to sender. */ |
| 837 | if (from == peer) |
| 838 | return 0; |
| 839 | |
| 840 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 841 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 842 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 843 | return 0; |
| 844 | |
| 845 | /* Default route check. */ |
| 846 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 847 | { |
| 848 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 849 | return 0; |
| 850 | #ifdef HAVE_IPV6 |
| 851 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 852 | return 0; |
| 853 | #endif /* HAVE_IPV6 */ |
| 854 | } |
| 855 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 856 | /* Transparency check. */ |
| 857 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 858 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 859 | transparent = 1; |
| 860 | else |
| 861 | transparent = 0; |
| 862 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 863 | /* If community is not disabled check the no-export and local. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 864 | if (! transparent && bgp_community_filter (peer, riattr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 865 | return 0; |
| 866 | |
| 867 | /* If the attribute has originator-id and it is same as remote |
| 868 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 869 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 870 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 871 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 872 | { |
| 873 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 874 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 875 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 876 | peer->host, |
| 877 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 878 | p->prefixlen); |
| 879 | return 0; |
| 880 | } |
| 881 | } |
| 882 | |
| 883 | /* ORF prefix-list filter check */ |
| 884 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 885 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 886 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 887 | if (peer->orf_plist[afi][safi]) |
| 888 | { |
| 889 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 890 | return 0; |
| 891 | } |
| 892 | |
| 893 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 894 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 895 | { |
| 896 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 897 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 898 | "%s [Update:SEND] %s/%d is filtered", |
| 899 | peer->host, |
| 900 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 901 | p->prefixlen); |
| 902 | return 0; |
| 903 | } |
| 904 | |
| 905 | #ifdef BGP_SEND_ASPATH_CHECK |
| 906 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 907 | if (aspath_loop_check (riattr->aspath, peer->as)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 908 | { |
| 909 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 910 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 911 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 912 | peer->host, peer->as); |
| 913 | return 0; |
| 914 | } |
| 915 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 916 | |
| 917 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 918 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 919 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 920 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 921 | { |
| 922 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 923 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 924 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 925 | peer->host, |
| 926 | bgp->confed_id); |
| 927 | return 0; |
| 928 | } |
| 929 | } |
| 930 | |
| 931 | /* Route-Reflect check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 932 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 933 | reflect = 1; |
| 934 | else |
| 935 | reflect = 0; |
| 936 | |
| 937 | /* IBGP reflection check. */ |
| 938 | if (reflect) |
| 939 | { |
| 940 | /* A route from a Client peer. */ |
| 941 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 942 | { |
| 943 | /* Reflect to all the Non-Client peers and also to the |
| 944 | Client peers other than the originator. Originator check |
| 945 | is already done. So there is noting to do. */ |
| 946 | /* no bgp client-to-client reflection check. */ |
| 947 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 948 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 949 | return 0; |
| 950 | } |
| 951 | else |
| 952 | { |
| 953 | /* A route from a Non-client peer. Reflect to all other |
| 954 | clients. */ |
| 955 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 956 | return 0; |
| 957 | } |
| 958 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 959 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 960 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 961 | bgp_attr_dup (attr, riattr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 962 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 963 | /* If local-preference is not set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 964 | if ((peer->sort == BGP_PEER_IBGP |
| 965 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 966 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 967 | { |
| 968 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 969 | attr->local_pref = bgp->default_local_pref; |
| 970 | } |
| 971 | |
Pradosh Mohapatra | 689bb66 | 2013-09-07 07:13:37 +0000 | [diff] [blame] | 972 | /* If originator-id is not set and the route is to be reflected, |
| 973 | set the originator id */ |
| 974 | if (peer && from && peer->sort == BGP_PEER_IBGP && |
| 975 | from->sort == BGP_PEER_IBGP && |
| 976 | (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) |
| 977 | { |
| 978 | attr->extra = bgp_attr_extra_get(attr); |
| 979 | IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id)); |
| 980 | SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID); |
| 981 | } |
| 982 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 983 | /* 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] | 984 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 985 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 986 | { |
| 987 | if (ri->peer != bgp->peer_self && ! transparent |
| 988 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 989 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 990 | } |
| 991 | |
| 992 | /* next-hop-set */ |
Timo Teräs | 9e7a53c | 2014-04-24 10:22:37 +0300 | [diff] [blame] | 993 | if (transparent |
| 994 | || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 995 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 996 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 997 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 998 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 999 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 1000 | #endif /* HAVE_IPV6 */ |
| 1001 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1002 | { |
| 1003 | /* NEXT-HOP Unchanged. */ |
| 1004 | } |
| 1005 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 1006 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1007 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1008 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1009 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1010 | #endif /* HAVE_IPV6 */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1011 | || (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1012 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 1013 | { |
| 1014 | /* Set IPv4 nexthop. */ |
| 1015 | if (p->family == AF_INET) |
| 1016 | { |
| 1017 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1018 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 1019 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1020 | else |
| 1021 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1022 | } |
| 1023 | #ifdef HAVE_IPV6 |
| 1024 | /* Set IPv6 nexthop. */ |
| 1025 | if (p->family == AF_INET6) |
| 1026 | { |
| 1027 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1028 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1029 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1030 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1031 | } |
| 1032 | #endif /* HAVE_IPV6 */ |
| 1033 | } |
| 1034 | |
| 1035 | #ifdef HAVE_IPV6 |
| 1036 | if (p->family == AF_INET6) |
| 1037 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1038 | /* Left nexthop_local unchanged if so configured. */ |
| 1039 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 1040 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1041 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1042 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 1043 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1044 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1045 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1046 | } |
| 1047 | |
| 1048 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 1049 | else |
| 1050 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1051 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1052 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1053 | |
| 1054 | /* Set link-local address for shared network peer. */ |
| 1055 | if (peer->shared_network |
| 1056 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 1057 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1058 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1059 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1060 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1061 | } |
| 1062 | |
| 1063 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 1064 | address.*/ |
| 1065 | if (reflect) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1066 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1067 | |
| 1068 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 1069 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1070 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1071 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1072 | |
| 1073 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1074 | #endif /* HAVE_IPV6 */ |
| 1075 | |
| 1076 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1077 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1078 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1079 | && aspath_private_as_check (attr->aspath)) |
| 1080 | attr->aspath = aspath_empty_get (); |
| 1081 | |
| 1082 | /* Route map & unsuppress-map apply. */ |
| 1083 | if (ROUTE_MAP_OUT_NAME (filter) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1084 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1085 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1086 | struct bgp_info info; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1087 | struct attr dummy_attr; |
| 1088 | struct attr_extra dummy_extra; |
| 1089 | |
| 1090 | dummy_attr.extra = &dummy_extra; |
| 1091 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1092 | info.peer = peer; |
| 1093 | info.attr = attr; |
| 1094 | |
| 1095 | /* The route reflector is not allowed to modify the attributes |
| 1096 | of the reflected IBGP routes. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1097 | if (from->sort == BGP_PEER_IBGP |
| 1098 | && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1099 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1100 | bgp_attr_dup (&dummy_attr, attr); |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1101 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1102 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1103 | |
| 1104 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1105 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1106 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1107 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1108 | else |
| 1109 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1110 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1111 | peer->rmap_type = 0; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1112 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1113 | if (ret == RMAP_DENYMATCH) |
| 1114 | { |
| 1115 | bgp_attr_flush (attr); |
| 1116 | return 0; |
| 1117 | } |
| 1118 | } |
| 1119 | return 1; |
| 1120 | } |
| 1121 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1122 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1123 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1124 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1125 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1126 | int ret; |
| 1127 | char buf[SU_ADDRSTRLEN]; |
| 1128 | struct bgp_filter *filter; |
| 1129 | struct bgp_info info; |
| 1130 | struct peer *from; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1131 | struct attr *riattr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1132 | |
| 1133 | from = ri->peer; |
| 1134 | filter = &rsclient->filter[afi][safi]; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1135 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1136 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 1137 | if (DISABLE_BGP_ANNOUNCE) |
| 1138 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1139 | |
| 1140 | /* Do not send back route to sender. */ |
| 1141 | if (from == rsclient) |
| 1142 | return 0; |
| 1143 | |
| 1144 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1145 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1146 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 1147 | return 0; |
| 1148 | |
| 1149 | /* Default route check. */ |
| 1150 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1151 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1152 | { |
| 1153 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1154 | return 0; |
| 1155 | #ifdef HAVE_IPV6 |
| 1156 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1157 | return 0; |
| 1158 | #endif /* HAVE_IPV6 */ |
| 1159 | } |
| 1160 | |
| 1161 | /* If the attribute has originator-id and it is same as remote |
| 1162 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1163 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1164 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1165 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1166 | &riattr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1167 | { |
| 1168 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1169 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1170 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1171 | rsclient->host, |
| 1172 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1173 | p->prefixlen); |
| 1174 | return 0; |
| 1175 | } |
| 1176 | } |
| 1177 | |
| 1178 | /* ORF prefix-list filter check */ |
| 1179 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1180 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1181 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1182 | if (rsclient->orf_plist[afi][safi]) |
| 1183 | { |
| 1184 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1185 | return 0; |
| 1186 | } |
| 1187 | |
| 1188 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1189 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1190 | { |
| 1191 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1192 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1193 | "%s [Update:SEND] %s/%d is filtered", |
| 1194 | rsclient->host, |
| 1195 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1196 | p->prefixlen); |
| 1197 | return 0; |
| 1198 | } |
| 1199 | |
| 1200 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1201 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1202 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1203 | { |
| 1204 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1205 | zlog (rsclient->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 1206 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1207 | rsclient->host, rsclient->as); |
| 1208 | return 0; |
| 1209 | } |
| 1210 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1211 | |
| 1212 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1213 | bgp_attr_dup (attr, riattr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1214 | |
| 1215 | /* next-hop-set */ |
| 1216 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1217 | #ifdef HAVE_IPV6 |
| 1218 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1219 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1220 | #endif /* HAVE_IPV6 */ |
| 1221 | ) |
| 1222 | { |
| 1223 | /* Set IPv4 nexthop. */ |
| 1224 | if (p->family == AF_INET) |
| 1225 | { |
| 1226 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1227 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1228 | IPV4_MAX_BYTELEN); |
| 1229 | else |
| 1230 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1231 | } |
| 1232 | #ifdef HAVE_IPV6 |
| 1233 | /* Set IPv6 nexthop. */ |
| 1234 | if (p->family == AF_INET6) |
| 1235 | { |
| 1236 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1237 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1238 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1239 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1240 | } |
| 1241 | #endif /* HAVE_IPV6 */ |
| 1242 | } |
| 1243 | |
| 1244 | #ifdef HAVE_IPV6 |
| 1245 | if (p->family == AF_INET6) |
| 1246 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1247 | struct attr_extra *attre = attr->extra; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1248 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1249 | /* Left nexthop_local unchanged if so configured. */ |
| 1250 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1251 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1252 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1253 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1254 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1255 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1256 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
| 1259 | /* Default nexthop_local treatment for RS-Clients */ |
| 1260 | else |
| 1261 | { |
| 1262 | /* Announcer and RS-Client are both in the same network */ |
| 1263 | if (rsclient->shared_network && from->shared_network && |
| 1264 | (rsclient->ifindex == from->ifindex)) |
| 1265 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1266 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1267 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1268 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1269 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1270 | } |
| 1271 | |
| 1272 | /* Set link-local address for shared network peer. */ |
| 1273 | else if (rsclient->shared_network |
| 1274 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1275 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1276 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1277 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1278 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1279 | } |
| 1280 | |
| 1281 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1282 | attre->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1283 | } |
| 1284 | |
| 1285 | } |
| 1286 | #endif /* HAVE_IPV6 */ |
| 1287 | |
| 1288 | |
| 1289 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1290 | if (rsclient->sort == BGP_PEER_EBGP |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1291 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1292 | && aspath_private_as_check (attr->aspath)) |
| 1293 | attr->aspath = aspath_empty_get (); |
| 1294 | |
| 1295 | /* Route map & unsuppress-map apply. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1296 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1297 | { |
| 1298 | info.peer = rsclient; |
| 1299 | info.attr = attr; |
| 1300 | |
| 1301 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1302 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1303 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1304 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1305 | else |
| 1306 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1307 | |
| 1308 | rsclient->rmap_type = 0; |
| 1309 | |
| 1310 | if (ret == RMAP_DENYMATCH) |
| 1311 | { |
| 1312 | bgp_attr_flush (attr); |
| 1313 | return 0; |
| 1314 | } |
| 1315 | } |
| 1316 | |
| 1317 | return 1; |
| 1318 | } |
| 1319 | |
| 1320 | struct bgp_info_pair |
| 1321 | { |
| 1322 | struct bgp_info *old; |
| 1323 | struct bgp_info *new; |
| 1324 | }; |
| 1325 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1326 | static void |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1327 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
| 1328 | struct bgp_maxpaths_cfg *mpath_cfg, |
| 1329 | struct bgp_info_pair *result) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1330 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1331 | struct bgp_info *new_select; |
| 1332 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1333 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1334 | struct bgp_info *ri1; |
| 1335 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1336 | struct bgp_info *nextri = NULL; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1337 | int paths_eq, do_mpath; |
| 1338 | struct list mp_list; |
| 1339 | |
| 1340 | bgp_mp_list_init (&mp_list); |
| 1341 | do_mpath = (mpath_cfg->maxpaths_ebgp != BGP_DEFAULT_MAXPATHS || |
| 1342 | mpath_cfg->maxpaths_ibgp != BGP_DEFAULT_MAXPATHS); |
| 1343 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1344 | /* bgp deterministic-med */ |
| 1345 | new_select = NULL; |
| 1346 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1347 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1348 | { |
| 1349 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1350 | continue; |
| 1351 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1352 | continue; |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1353 | if (ri1->peer && ri1->peer != bgp->peer_self) |
| 1354 | if (ri1->peer->status != Established) |
| 1355 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1356 | |
| 1357 | new_select = ri1; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1358 | if (do_mpath) |
| 1359 | bgp_mp_list_add (&mp_list, ri1); |
| 1360 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1361 | if (ri1->next) |
| 1362 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1363 | { |
| 1364 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1365 | continue; |
| 1366 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1367 | continue; |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1368 | if (ri2->peer && |
| 1369 | ri2->peer != bgp->peer_self && |
| 1370 | !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT)) |
| 1371 | if (ri2->peer->status != Established) |
| 1372 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1373 | |
| 1374 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1375 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1376 | ri2->attr->aspath)) |
| 1377 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1378 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
| 1379 | old_select = ri2; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1380 | if (bgp_info_cmp (bgp, ri2, new_select, &paths_eq)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1381 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1382 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1383 | new_select = ri2; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1384 | if (do_mpath && !paths_eq) |
| 1385 | { |
| 1386 | bgp_mp_list_clear (&mp_list); |
| 1387 | bgp_mp_list_add (&mp_list, ri2); |
| 1388 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1389 | } |
| 1390 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1391 | if (do_mpath && paths_eq) |
| 1392 | bgp_mp_list_add (&mp_list, ri2); |
| 1393 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1394 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1395 | } |
| 1396 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1397 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1398 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1399 | |
| 1400 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); |
| 1401 | bgp_mp_list_clear (&mp_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1402 | } |
| 1403 | |
| 1404 | /* Check old selected route and new selected route. */ |
| 1405 | old_select = NULL; |
| 1406 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1407 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1408 | { |
| 1409 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1410 | old_select = ri; |
| 1411 | |
| 1412 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1413 | { |
| 1414 | /* reap REMOVED routes, if needs be |
| 1415 | * selected route must stay for a while longer though |
| 1416 | */ |
| 1417 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1418 | && (ri != old_select)) |
| 1419 | bgp_info_reap (rn, ri); |
| 1420 | |
| 1421 | continue; |
| 1422 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1423 | |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1424 | if (ri->peer && |
| 1425 | ri->peer != bgp->peer_self && |
| 1426 | !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT)) |
| 1427 | if (ri->peer->status != Established) |
| 1428 | continue; |
| 1429 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1430 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1431 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1432 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1433 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1434 | continue; |
| 1435 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1436 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1437 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1438 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1439 | if (bgp_info_cmp (bgp, ri, new_select, &paths_eq)) |
| 1440 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1441 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1442 | bgp_mp_dmed_deselect (new_select); |
| 1443 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1444 | new_select = ri; |
| 1445 | |
| 1446 | if (do_mpath && !paths_eq) |
| 1447 | { |
| 1448 | bgp_mp_list_clear (&mp_list); |
| 1449 | bgp_mp_list_add (&mp_list, ri); |
| 1450 | } |
| 1451 | } |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1452 | else if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1453 | bgp_mp_dmed_deselect (ri); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1454 | |
| 1455 | if (do_mpath && paths_eq) |
| 1456 | bgp_mp_list_add (&mp_list, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1457 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1458 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1459 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1460 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1461 | 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] | 1462 | |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1463 | bgp_info_mpath_aggregate_update (new_select, old_select); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1464 | bgp_mp_list_clear (&mp_list); |
| 1465 | |
| 1466 | result->old = old_select; |
| 1467 | result->new = new_select; |
| 1468 | |
| 1469 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1470 | } |
| 1471 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1472 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1473 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1474 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1475 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1476 | struct prefix *p; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1477 | struct attr attr; |
| 1478 | struct attr_extra extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1479 | |
| 1480 | p = &rn->p; |
| 1481 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1482 | /* Announce route to Established peer. */ |
| 1483 | if (peer->status != Established) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1484 | return 0; |
| 1485 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1486 | /* Address family configuration check. */ |
| 1487 | if (! peer->afc_nego[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1488 | return 0; |
| 1489 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1490 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1491 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1492 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1493 | return 0; |
| 1494 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1495 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 1496 | attr.extra = &extra; |
| 1497 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1498 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1499 | { |
| 1500 | case BGP_TABLE_MAIN: |
| 1501 | /* Announcement to peer->conf. If the route is filtered, |
| 1502 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1503 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
| 1504 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1505 | else |
| 1506 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1507 | break; |
| 1508 | case BGP_TABLE_RSCLIENT: |
| 1509 | /* Announcement to peer->conf. If the route is filtered, |
| 1510 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1511 | if (selected && |
| 1512 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) |
| 1513 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
| 1514 | else |
| 1515 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1516 | break; |
| 1517 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1518 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1519 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1520 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1521 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1522 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1523 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1524 | struct bgp *bgp; |
| 1525 | struct bgp_node *rn; |
| 1526 | afi_t afi; |
| 1527 | safi_t safi; |
| 1528 | }; |
| 1529 | |
| 1530 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1531 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1532 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1533 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1534 | struct bgp *bgp = pq->bgp; |
| 1535 | struct bgp_node *rn = pq->rn; |
| 1536 | afi_t afi = pq->afi; |
| 1537 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1538 | struct bgp_info *new_select; |
| 1539 | struct bgp_info *old_select; |
| 1540 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1541 | struct listnode *node, *nnode; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1542 | struct peer *rsclient = bgp_node_table (rn)->owner; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1543 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1544 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1545 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1546 | new_select = old_and_new.new; |
| 1547 | old_select = old_and_new.old; |
| 1548 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1549 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1550 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1551 | if (rsclient->group) |
| 1552 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1553 | { |
| 1554 | /* Nothing to do. */ |
| 1555 | if (old_select && old_select == new_select) |
| 1556 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1557 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1558 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1559 | if (old_select) |
| 1560 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
| 1561 | if (new_select) |
| 1562 | { |
| 1563 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1564 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1565 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
| 1566 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1567 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1568 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1569 | afi, safi); |
| 1570 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1571 | } |
| 1572 | else |
| 1573 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1574 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1575 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1576 | if (new_select) |
| 1577 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1578 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1579 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1580 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1581 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1582 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1583 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1584 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1585 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1586 | bgp_info_reap (rn, old_select); |
| 1587 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1588 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1589 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1590 | } |
| 1591 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1592 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1593 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1594 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1595 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1596 | struct bgp *bgp = pq->bgp; |
| 1597 | struct bgp_node *rn = pq->rn; |
| 1598 | afi_t afi = pq->afi; |
| 1599 | safi_t safi = pq->safi; |
| 1600 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1601 | struct bgp_info *new_select; |
| 1602 | struct bgp_info *old_select; |
| 1603 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1604 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1605 | struct peer *peer; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1606 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1607 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1608 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1609 | old_select = old_and_new.old; |
| 1610 | new_select = old_and_new.new; |
| 1611 | |
| 1612 | /* Nothing to do. */ |
| 1613 | if (old_select && old_select == new_select) |
| 1614 | { |
| 1615 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1616 | { |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1617 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
| 1618 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1619 | bgp_zebra_announce (p, old_select, bgp, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1620 | |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1621 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1622 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1623 | return WQ_SUCCESS; |
| 1624 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1625 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1626 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1627 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1628 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1629 | if (new_select) |
| 1630 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1631 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1632 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1633 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1634 | } |
| 1635 | |
| 1636 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1637 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1638 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1639 | { |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1640 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1641 | } |
| 1642 | |
| 1643 | /* FIB update. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1644 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
| 1645 | ! bgp_option_check (BGP_OPT_NO_FIB))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1646 | { |
| 1647 | if (new_select |
| 1648 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1649 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1650 | bgp_zebra_announce (p, new_select, bgp, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1651 | else |
| 1652 | { |
| 1653 | /* Withdraw the route from the kernel. */ |
| 1654 | if (old_select |
| 1655 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1656 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1657 | bgp_zebra_withdraw (p, old_select, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1658 | } |
| 1659 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1660 | |
| 1661 | /* Reap old select bgp_info, it it has been removed */ |
| 1662 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1663 | bgp_info_reap (rn, old_select); |
| 1664 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1665 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1666 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1667 | } |
| 1668 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1669 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1670 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1671 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1672 | struct bgp_process_queue *pq = data; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1673 | struct bgp_table *table = bgp_node_table (pq->rn); |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1674 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1675 | bgp_unlock (pq->bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1676 | bgp_unlock_node (pq->rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1677 | bgp_table_unlock (table); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1678 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1679 | } |
| 1680 | |
| 1681 | static void |
| 1682 | bgp_process_queue_init (void) |
| 1683 | { |
| 1684 | bm->process_main_queue |
| 1685 | = work_queue_new (bm->master, "process_main_queue"); |
| 1686 | bm->process_rsclient_queue |
| 1687 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1688 | |
| 1689 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1690 | { |
| 1691 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1692 | exit (1); |
| 1693 | } |
| 1694 | |
| 1695 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1696 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1697 | bm->process_main_queue->spec.max_retries = 0; |
| 1698 | bm->process_main_queue->spec.hold = 50; |
| 1699 | |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1700 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
David Lamparter | d43f8b3 | 2015-03-03 08:54:54 +0100 | [diff] [blame] | 1701 | bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del; |
| 1702 | bm->process_rsclient_queue->spec.max_retries = 0; |
| 1703 | bm->process_rsclient_queue->spec.hold = 50; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1704 | } |
| 1705 | |
| 1706 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1707 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1708 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1709 | struct bgp_process_queue *pqnode; |
| 1710 | |
| 1711 | /* already scheduled for processing? */ |
| 1712 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1713 | return; |
| 1714 | |
| 1715 | if ( (bm->process_main_queue == NULL) || |
| 1716 | (bm->process_rsclient_queue == NULL) ) |
| 1717 | bgp_process_queue_init (); |
| 1718 | |
| 1719 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1720 | sizeof (struct bgp_process_queue)); |
| 1721 | if (!pqnode) |
| 1722 | return; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1723 | |
| 1724 | /* all unlocked in bgp_processq_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1725 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1726 | pqnode->rn = bgp_lock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1727 | pqnode->bgp = bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1728 | bgp_lock (bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1729 | pqnode->afi = afi; |
| 1730 | pqnode->safi = safi; |
| 1731 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1732 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1733 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1734 | case BGP_TABLE_MAIN: |
| 1735 | work_queue_add (bm->process_main_queue, pqnode); |
| 1736 | break; |
| 1737 | case BGP_TABLE_RSCLIENT: |
| 1738 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1739 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1740 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1741 | |
Stephen Hemminger | 07ff4dc | 2013-01-04 22:29:20 +0000 | [diff] [blame] | 1742 | SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1743 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1744 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1745 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1746 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1747 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1748 | { |
| 1749 | struct peer *peer; |
| 1750 | |
| 1751 | peer = THREAD_ARG (thread); |
| 1752 | peer->t_pmax_restart = NULL; |
| 1753 | |
| 1754 | if (BGP_DEBUG (events, EVENTS)) |
| 1755 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1756 | peer->host); |
| 1757 | |
| 1758 | peer_clear (peer); |
| 1759 | |
| 1760 | return 0; |
| 1761 | } |
| 1762 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1763 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1764 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1765 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1766 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1767 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1768 | return 0; |
| 1769 | |
| 1770 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1771 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1772 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1773 | && ! always) |
| 1774 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1775 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1776 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1777 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1778 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1779 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1780 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1781 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1782 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1783 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1784 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1785 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1786 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1787 | |
| 1788 | if (safi == SAFI_MPLS_VPN) |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 1789 | safi = SAFI_MPLS_LABELED_VPN; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1790 | |
| 1791 | ndata[0] = (afi >> 8); |
| 1792 | ndata[1] = afi; |
| 1793 | ndata[2] = safi; |
| 1794 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1795 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1796 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1797 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1798 | |
| 1799 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1800 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1801 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1802 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1803 | |
| 1804 | /* restart timer start */ |
| 1805 | if (peer->pmax_restart[afi][safi]) |
| 1806 | { |
| 1807 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1808 | |
| 1809 | if (BGP_DEBUG (events, EVENTS)) |
| 1810 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1811 | peer->host, peer->v_pmax_restart); |
| 1812 | |
| 1813 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1814 | peer->v_pmax_restart); |
| 1815 | } |
| 1816 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1817 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1818 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1819 | else |
| 1820 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1821 | |
| 1822 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1823 | { |
| 1824 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1825 | && ! always) |
| 1826 | return 0; |
| 1827 | |
| 1828 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1829 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1830 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1831 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1832 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1833 | } |
| 1834 | else |
| 1835 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1836 | return 0; |
| 1837 | } |
| 1838 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1839 | /* Unconditionally remove the route from the RIB, without taking |
| 1840 | * damping into consideration (eg, because the session went down) |
| 1841 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1842 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1843 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1844 | afi_t afi, safi_t safi) |
| 1845 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1846 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1847 | |
| 1848 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1849 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1850 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1851 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1852 | } |
| 1853 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1854 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1855 | 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] | 1856 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1857 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1858 | int status = BGP_DAMP_NONE; |
| 1859 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1860 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1861 | * the bgp_info in the RIB for historical reference. |
| 1862 | */ |
| 1863 | 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] | 1864 | && peer->sort == BGP_PEER_EBGP) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1865 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1866 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1867 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1868 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1869 | return; |
| 1870 | } |
| 1871 | |
| 1872 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1873 | } |
| 1874 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1875 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1876 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1877 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1878 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1879 | { |
| 1880 | struct bgp_node *rn; |
| 1881 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1882 | struct attr new_attr; |
| 1883 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1884 | struct attr *attr_new; |
| 1885 | struct attr *attr_new2; |
| 1886 | struct bgp_info *ri; |
| 1887 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1888 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1889 | char buf[SU_ADDRSTRLEN]; |
| 1890 | |
| 1891 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1892 | if (peer == rsclient) |
| 1893 | return; |
| 1894 | |
| 1895 | bgp = peer->bgp; |
| 1896 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1897 | |
| 1898 | /* Check previously received route. */ |
| 1899 | for (ri = rn->info; ri; ri = ri->next) |
| 1900 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1901 | break; |
| 1902 | |
| 1903 | /* AS path loop check. */ |
Milan Kocian | 000e157 | 2013-10-18 07:59:38 +0000 | [diff] [blame] | 1904 | if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1905 | { |
| 1906 | reason = "as-path contains our own AS;"; |
| 1907 | goto filtered; |
| 1908 | } |
| 1909 | |
| 1910 | /* Route reflector originator ID check. */ |
| 1911 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1912 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1913 | { |
| 1914 | reason = "originator is us;"; |
| 1915 | goto filtered; |
| 1916 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1917 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1918 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1919 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1920 | |
| 1921 | /* Apply export policy. */ |
| 1922 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1923 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1924 | { |
| 1925 | reason = "export-policy;"; |
| 1926 | goto filtered; |
| 1927 | } |
| 1928 | |
| 1929 | attr_new2 = bgp_attr_intern (&new_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1930 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1931 | /* Apply import policy. */ |
| 1932 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1933 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1934 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1935 | |
| 1936 | reason = "import-policy;"; |
| 1937 | goto filtered; |
| 1938 | } |
| 1939 | |
| 1940 | attr_new = bgp_attr_intern (&new_attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1941 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1942 | |
| 1943 | /* IPv4 unicast next hop check. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1944 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1945 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1946 | /* 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] | 1947 | if (new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1948 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1949 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1950 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1951 | |
| 1952 | reason = "martian next-hop;"; |
| 1953 | goto filtered; |
| 1954 | } |
| 1955 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1956 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1957 | /* If the update is implicit withdraw. */ |
| 1958 | if (ri) |
| 1959 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1960 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1961 | |
| 1962 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1963 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1964 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1965 | { |
| 1966 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1967 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1968 | |
| 1969 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1970 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1971 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1972 | peer->host, |
| 1973 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1974 | p->prefixlen, rsclient->host); |
| 1975 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1976 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1977 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1978 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1979 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1980 | } |
| 1981 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1982 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 1983 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 1984 | bgp_info_restore (rn, ri); |
| 1985 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1986 | /* Received Logging. */ |
| 1987 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1988 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1989 | peer->host, |
| 1990 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1991 | p->prefixlen, rsclient->host); |
| 1992 | |
| 1993 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1994 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1995 | |
| 1996 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1997 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1998 | ri->attr = attr_new; |
| 1999 | |
| 2000 | /* Update MPLS tag. */ |
| 2001 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2002 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2003 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2004 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2005 | |
| 2006 | /* Process change. */ |
| 2007 | bgp_process (bgp, rn, afi, safi); |
| 2008 | bgp_unlock_node (rn); |
| 2009 | |
| 2010 | return; |
| 2011 | } |
| 2012 | |
| 2013 | /* Received Logging. */ |
| 2014 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2015 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2016 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2017 | peer->host, |
| 2018 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2019 | p->prefixlen, rsclient->host); |
| 2020 | } |
| 2021 | |
| 2022 | /* Make new BGP info. */ |
| 2023 | new = bgp_info_new (); |
| 2024 | new->type = type; |
| 2025 | new->sub_type = sub_type; |
| 2026 | new->peer = peer; |
| 2027 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2028 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2029 | |
| 2030 | /* Update MPLS tag. */ |
| 2031 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2032 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2033 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2034 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2035 | |
| 2036 | /* Register new BGP information. */ |
| 2037 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2038 | |
| 2039 | /* route_node_get lock */ |
| 2040 | bgp_unlock_node (rn); |
| 2041 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2042 | /* Process change. */ |
| 2043 | bgp_process (bgp, rn, afi, safi); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2044 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2045 | return; |
| 2046 | |
| 2047 | filtered: |
| 2048 | |
| 2049 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2050 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2051 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2052 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 2053 | peer->host, |
| 2054 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2055 | p->prefixlen, rsclient->host, reason); |
| 2056 | |
| 2057 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2058 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2059 | |
| 2060 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2061 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2062 | return; |
| 2063 | } |
| 2064 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2065 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2066 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 2067 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 2068 | struct prefix_rd *prd, u_char *tag) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2069 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2070 | struct bgp_node *rn; |
| 2071 | struct bgp_info *ri; |
| 2072 | char buf[SU_ADDRSTRLEN]; |
| 2073 | |
| 2074 | if (rsclient == peer) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2075 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2076 | |
| 2077 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 2078 | |
| 2079 | /* Lookup withdrawn route. */ |
| 2080 | for (ri = rn->info; ri; ri = ri->next) |
| 2081 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2082 | break; |
| 2083 | |
| 2084 | /* Withdraw specified route from routing table. */ |
| 2085 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2086 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2087 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2088 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2089 | "%s Can't find the route %s/%d", peer->host, |
| 2090 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2091 | p->prefixlen); |
| 2092 | |
| 2093 | /* Unlock bgp_node_get() lock. */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2094 | bgp_unlock_node (rn); |
| 2095 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2096 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2097 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2098 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2099 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2100 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2101 | { |
| 2102 | int ret; |
| 2103 | int aspath_loop_count = 0; |
| 2104 | struct bgp_node *rn; |
| 2105 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2106 | struct attr new_attr; |
| 2107 | struct attr_extra new_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2108 | struct attr *attr_new; |
| 2109 | struct bgp_info *ri; |
| 2110 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2111 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2112 | char buf[SU_ADDRSTRLEN]; |
| 2113 | |
| 2114 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2115 | 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] | 2116 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2117 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2118 | Adj-RIBs-In. */ |
Jorge Boncompte [DTI2] | 343aa82 | 2012-05-07 16:53:08 +0000 | [diff] [blame] | 2119 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2120 | && peer != bgp->peer_self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2121 | bgp_adj_in_set (rn, peer, attr); |
| 2122 | |
| 2123 | /* Check previously received route. */ |
| 2124 | for (ri = rn->info; ri; ri = ri->next) |
| 2125 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2126 | break; |
| 2127 | |
| 2128 | /* AS path local-as loop check. */ |
| 2129 | if (peer->change_local_as) |
| 2130 | { |
| 2131 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 2132 | aspath_loop_count = 1; |
| 2133 | |
| 2134 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 2135 | { |
| 2136 | reason = "as-path contains our own AS;"; |
| 2137 | goto filtered; |
| 2138 | } |
| 2139 | } |
| 2140 | |
| 2141 | /* AS path loop check. */ |
| 2142 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 2143 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2144 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2145 | > peer->allowas_in[afi][safi])) |
| 2146 | { |
| 2147 | reason = "as-path contains our own AS;"; |
| 2148 | goto filtered; |
| 2149 | } |
| 2150 | |
| 2151 | /* Route reflector originator ID check. */ |
| 2152 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2153 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2154 | { |
| 2155 | reason = "originator is us;"; |
| 2156 | goto filtered; |
| 2157 | } |
| 2158 | |
| 2159 | /* Route reflector cluster ID check. */ |
| 2160 | if (bgp_cluster_filter (peer, attr)) |
| 2161 | { |
| 2162 | reason = "reflected from the same cluster;"; |
| 2163 | goto filtered; |
| 2164 | } |
| 2165 | |
| 2166 | /* Apply incoming filter. */ |
| 2167 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2168 | { |
| 2169 | reason = "filter;"; |
| 2170 | goto filtered; |
| 2171 | } |
| 2172 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2173 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2174 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2175 | |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2176 | /* Apply incoming route-map. |
| 2177 | * NB: new_attr may now contain newly allocated values from route-map "set" |
| 2178 | * commands, so we need bgp_attr_flush in the error paths, until we intern |
| 2179 | * the attr (which takes over the memory references) */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2180 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2181 | { |
| 2182 | reason = "route-map;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2183 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2184 | goto filtered; |
| 2185 | } |
| 2186 | |
| 2187 | /* IPv4 unicast next hop check. */ |
| 2188 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2189 | { |
| 2190 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2191 | discard it. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2192 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 |
Denis Ovsienko | 8e80bdf | 2011-08-05 18:52:52 +0400 | [diff] [blame] | 2193 | && ! bgp_nexthop_onlink (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2194 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2195 | { |
| 2196 | reason = "non-connected next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2197 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2198 | goto filtered; |
| 2199 | } |
| 2200 | |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2201 | /* 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] | 2202 | must not be my own address. */ |
Jorge Boncompte [DTI2] | 10f9bf3 | 2012-05-07 16:52:52 +0000 | [diff] [blame] | 2203 | if (new_attr.nexthop.s_addr == 0 |
| 2204 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) |
| 2205 | || bgp_nexthop_self (&new_attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2206 | { |
| 2207 | reason = "martian next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2208 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2209 | goto filtered; |
| 2210 | } |
| 2211 | } |
| 2212 | |
| 2213 | attr_new = bgp_attr_intern (&new_attr); |
| 2214 | |
| 2215 | /* If the update is implicit withdraw. */ |
| 2216 | if (ri) |
| 2217 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2218 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2219 | |
| 2220 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2221 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2222 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2223 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2224 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2225 | |
| 2226 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2227 | && peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2228 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2229 | { |
| 2230 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2231 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2232 | peer->host, |
| 2233 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2234 | p->prefixlen); |
| 2235 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2236 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2237 | { |
| 2238 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2239 | bgp_process (bgp, rn, afi, safi); |
| 2240 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2241 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2242 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2243 | { |
| 2244 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2245 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2246 | "%s rcvd %s/%d...duplicate ignored", |
| 2247 | peer->host, |
| 2248 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2249 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2250 | |
| 2251 | /* graceful restart STALE flag unset. */ |
| 2252 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2253 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2254 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2255 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2256 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2257 | } |
| 2258 | |
| 2259 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2260 | bgp_attr_unintern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2261 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2262 | return 0; |
| 2263 | } |
| 2264 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2265 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2266 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2267 | { |
| 2268 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2269 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2270 | peer->host, |
| 2271 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2272 | p->prefixlen); |
| 2273 | bgp_info_restore (rn, ri); |
| 2274 | } |
| 2275 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2276 | /* Received Logging. */ |
| 2277 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2278 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2279 | peer->host, |
| 2280 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2281 | p->prefixlen); |
| 2282 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2283 | /* graceful restart STALE flag unset. */ |
| 2284 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2285 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2286 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2287 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2288 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2289 | |
| 2290 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2291 | * only if update is accepted, they'll increment below. |
| 2292 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2293 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2294 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2295 | /* Update bgp route dampening information. */ |
| 2296 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2297 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2298 | { |
| 2299 | /* This is implicit withdraw so we should update dampening |
| 2300 | information. */ |
| 2301 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2302 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2303 | } |
| 2304 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2305 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2306 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2307 | ri->attr = attr_new; |
| 2308 | |
| 2309 | /* Update MPLS tag. */ |
| 2310 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2311 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2312 | |
| 2313 | /* Update bgp route dampening information. */ |
| 2314 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2315 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2316 | { |
| 2317 | /* Now we do normal update dampening. */ |
| 2318 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2319 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2320 | { |
| 2321 | bgp_unlock_node (rn); |
| 2322 | return 0; |
| 2323 | } |
| 2324 | } |
| 2325 | |
| 2326 | /* Nexthop reachability check. */ |
| 2327 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2328 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2329 | && (peer->sort == BGP_PEER_IBGP |
| 2330 | || peer->sort == BGP_PEER_CONFED |
| 2331 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2332 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2333 | { |
| 2334 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2335 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2336 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2337 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2338 | } |
| 2339 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2340 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2341 | |
| 2342 | /* Process change. */ |
| 2343 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2344 | |
| 2345 | bgp_process (bgp, rn, afi, safi); |
| 2346 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2347 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2348 | return 0; |
| 2349 | } |
| 2350 | |
| 2351 | /* Received Logging. */ |
| 2352 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2353 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2354 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2355 | peer->host, |
| 2356 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2357 | p->prefixlen); |
| 2358 | } |
| 2359 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2360 | /* Make new BGP info. */ |
| 2361 | new = bgp_info_new (); |
| 2362 | new->type = type; |
| 2363 | new->sub_type = sub_type; |
| 2364 | new->peer = peer; |
| 2365 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2366 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2367 | |
| 2368 | /* Update MPLS tag. */ |
| 2369 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2370 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2371 | |
| 2372 | /* Nexthop reachability check. */ |
| 2373 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2374 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2375 | && (peer->sort == BGP_PEER_IBGP |
| 2376 | || peer->sort == BGP_PEER_CONFED |
| 2377 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2378 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2379 | { |
| 2380 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2381 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2382 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2383 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2384 | } |
| 2385 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2386 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2387 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2388 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2389 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2390 | |
| 2391 | /* Register new BGP information. */ |
| 2392 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2393 | |
| 2394 | /* route_node_get lock */ |
| 2395 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2396 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2397 | /* If maximum prefix count is configured and current prefix |
| 2398 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2399 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2400 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2401 | |
| 2402 | /* Process change. */ |
| 2403 | bgp_process (bgp, rn, afi, safi); |
| 2404 | |
| 2405 | return 0; |
| 2406 | |
| 2407 | /* This BGP update is filtered. Log the reason then update BGP |
| 2408 | entry. */ |
| 2409 | filtered: |
| 2410 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2411 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2412 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2413 | peer->host, |
| 2414 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2415 | p->prefixlen, reason); |
| 2416 | |
| 2417 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2418 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2419 | |
| 2420 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2421 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2422 | return 0; |
| 2423 | } |
| 2424 | |
| 2425 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2426 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2427 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2428 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2429 | { |
| 2430 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2431 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2432 | struct bgp *bgp; |
| 2433 | int ret; |
| 2434 | |
| 2435 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2436 | soft_reconfig); |
| 2437 | |
| 2438 | bgp = peer->bgp; |
| 2439 | |
| 2440 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2441 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2442 | { |
| 2443 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2444 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2445 | sub_type, prd, tag); |
| 2446 | } |
| 2447 | |
| 2448 | return ret; |
| 2449 | } |
| 2450 | |
| 2451 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2452 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2453 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2454 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2455 | { |
| 2456 | struct bgp *bgp; |
| 2457 | char buf[SU_ADDRSTRLEN]; |
| 2458 | struct bgp_node *rn; |
| 2459 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2460 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2461 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2462 | |
| 2463 | bgp = peer->bgp; |
| 2464 | |
David Lamparter | 4584c23 | 2015-04-13 09:50:00 +0200 | [diff] [blame] | 2465 | /* Lookup node. */ |
| 2466 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
| 2467 | |
| 2468 | /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all |
| 2469 | * routes that are filtered. This tanks out Quagga RS pretty badly due to |
| 2470 | * the iteration over all RS clients. |
| 2471 | * Since we need to remove the entry from adj_in anyway, do that first and |
| 2472 | * if there was no entry, we don't need to do anything more. */ |
| 2473 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2474 | && peer != bgp->peer_self) |
| 2475 | if (!bgp_adj_in_unset (rn, peer)) |
| 2476 | { |
| 2477 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2478 | zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d " |
| 2479 | "not in adj-in", peer->host, |
| 2480 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2481 | p->prefixlen); |
| 2482 | bgp_unlock_node (rn); |
| 2483 | return 0; |
| 2484 | } |
| 2485 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2486 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2487 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2488 | { |
| 2489 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2490 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2491 | } |
| 2492 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2493 | /* Logging. */ |
| 2494 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2495 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2496 | peer->host, |
| 2497 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2498 | p->prefixlen); |
| 2499 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2500 | /* Lookup withdrawn route. */ |
| 2501 | for (ri = rn->info; ri; ri = ri->next) |
| 2502 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2503 | break; |
| 2504 | |
| 2505 | /* Withdraw specified route from routing table. */ |
| 2506 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2507 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2508 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2509 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2510 | "%s Can't find the route %s/%d", peer->host, |
| 2511 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2512 | p->prefixlen); |
| 2513 | |
| 2514 | /* Unlock bgp_node_get() lock. */ |
| 2515 | bgp_unlock_node (rn); |
| 2516 | |
| 2517 | return 0; |
| 2518 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2519 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2520 | void |
| 2521 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2522 | { |
| 2523 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 2524 | struct attr attr; |
Jorge Boncompte [DTI2] | 577ac57 | 2012-05-07 16:53:06 +0000 | [diff] [blame] | 2525 | struct aspath *aspath; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2526 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2527 | struct peer *from; |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2528 | struct bgp_node *rn; |
| 2529 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2530 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2531 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2532 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2533 | return; |
| 2534 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2535 | bgp = peer->bgp; |
| 2536 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2537 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2538 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2539 | aspath = attr.aspath; |
| 2540 | attr.local_pref = bgp->default_local_pref; |
| 2541 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2542 | |
| 2543 | if (afi == AFI_IP) |
| 2544 | str2prefix ("0.0.0.0/0", &p); |
| 2545 | #ifdef HAVE_IPV6 |
| 2546 | else if (afi == AFI_IP6) |
| 2547 | { |
Jorge Boncompte [DTI2] | 6182d65 | 2012-05-07 16:53:02 +0000 | [diff] [blame] | 2548 | struct attr_extra *ae = attr.extra; |
| 2549 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2550 | str2prefix ("::/0", &p); |
| 2551 | |
| 2552 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2553 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2554 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2555 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2556 | |
| 2557 | /* If the peer is on shared nextwork and we have link-local |
| 2558 | nexthop set it. */ |
| 2559 | if (peer->shared_network |
| 2560 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2561 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2562 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2563 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2564 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2565 | } |
| 2566 | } |
| 2567 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2568 | |
| 2569 | if (peer->default_rmap[afi][safi].name) |
| 2570 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2571 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2572 | for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn)) |
| 2573 | { |
| 2574 | for (ri = rn->info; ri; ri = ri->next) |
| 2575 | { |
| 2576 | struct attr dummy_attr; |
| 2577 | struct attr_extra dummy_extra; |
| 2578 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2579 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2580 | /* Provide dummy so the route-map can't modify the attributes */ |
| 2581 | dummy_attr.extra = &dummy_extra; |
| 2582 | bgp_attr_dup(&dummy_attr, ri->attr); |
| 2583 | info.peer = ri->peer; |
| 2584 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2585 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2586 | ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p, |
| 2587 | RMAP_BGP, &info); |
| 2588 | |
| 2589 | /* The route map might have set attributes. If we don't flush them |
| 2590 | * here, they will be leaked. */ |
| 2591 | bgp_attr_flush(&dummy_attr); |
| 2592 | if (ret != RMAP_DENYMATCH) |
| 2593 | break; |
| 2594 | } |
| 2595 | if (ret != RMAP_DENYMATCH) |
| 2596 | break; |
| 2597 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2598 | bgp->peer_self->rmap_type = 0; |
| 2599 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2600 | if (ret == RMAP_DENYMATCH) |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2601 | withdraw = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2602 | } |
| 2603 | |
| 2604 | if (withdraw) |
| 2605 | { |
| 2606 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2607 | bgp_default_withdraw_send (peer, afi, safi); |
| 2608 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2609 | } |
| 2610 | else |
| 2611 | { |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2612 | if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2613 | { |
| 2614 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2615 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2616 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2617 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2618 | |
| 2619 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2620 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2621 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2622 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2623 | static void |
| 2624 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2625 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2626 | { |
| 2627 | struct bgp_node *rn; |
| 2628 | struct bgp_info *ri; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2629 | struct attr attr; |
| 2630 | struct attr_extra extra; |
| 2631 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2632 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2633 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2634 | |
| 2635 | if (safi != SAFI_MPLS_VPN |
| 2636 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2637 | bgp_default_originate (peer, afi, safi, 0); |
| 2638 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2639 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 2640 | attr.extra = &extra; |
| 2641 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2642 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2643 | for (ri = rn->info; ri; ri = ri->next) |
| 2644 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2645 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2646 | if ( (rsclient) ? |
| 2647 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2648 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2649 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2650 | else |
| 2651 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2652 | } |
| 2653 | } |
| 2654 | |
| 2655 | void |
| 2656 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2657 | { |
| 2658 | struct bgp_node *rn; |
| 2659 | struct bgp_table *table; |
| 2660 | |
| 2661 | if (peer->status != Established) |
| 2662 | return; |
| 2663 | |
| 2664 | if (! peer->afc_nego[afi][safi]) |
| 2665 | return; |
| 2666 | |
| 2667 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2668 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2669 | return; |
| 2670 | |
| 2671 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2672 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2673 | else |
| 2674 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2675 | rn = bgp_route_next(rn)) |
| 2676 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2677 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2678 | |
| 2679 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2680 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2681 | } |
| 2682 | |
| 2683 | void |
| 2684 | bgp_announce_route_all (struct peer *peer) |
| 2685 | { |
| 2686 | afi_t afi; |
| 2687 | safi_t safi; |
| 2688 | |
| 2689 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2690 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2691 | bgp_announce_route (peer, afi, safi); |
| 2692 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2693 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2694 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2695 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2696 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2697 | { |
| 2698 | struct bgp_node *rn; |
| 2699 | struct bgp_adj_in *ain; |
| 2700 | |
| 2701 | if (! table) |
| 2702 | table = rsclient->bgp->rib[afi][safi]; |
| 2703 | |
| 2704 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2705 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2706 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2707 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2708 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2709 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2710 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2711 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2712 | } |
| 2713 | } |
| 2714 | |
| 2715 | void |
| 2716 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2717 | { |
| 2718 | struct bgp_table *table; |
| 2719 | struct bgp_node *rn; |
| 2720 | |
| 2721 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2722 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2723 | |
| 2724 | else |
| 2725 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2726 | rn = bgp_route_next (rn)) |
| 2727 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2728 | { |
| 2729 | struct prefix_rd prd; |
| 2730 | prd.family = AF_UNSPEC; |
| 2731 | prd.prefixlen = 64; |
| 2732 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2733 | |
| 2734 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); |
| 2735 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2736 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2737 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2738 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2739 | 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] | 2740 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2741 | { |
| 2742 | int ret; |
| 2743 | struct bgp_node *rn; |
| 2744 | struct bgp_adj_in *ain; |
| 2745 | |
| 2746 | if (! table) |
| 2747 | table = peer->bgp->rib[afi][safi]; |
| 2748 | |
| 2749 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2750 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2751 | { |
| 2752 | if (ain->peer == peer) |
| 2753 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2754 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2755 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2756 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2757 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2758 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2759 | prd, tag, 1); |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2760 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2761 | if (ret < 0) |
| 2762 | { |
| 2763 | bgp_unlock_node (rn); |
| 2764 | return; |
| 2765 | } |
| 2766 | continue; |
| 2767 | } |
| 2768 | } |
| 2769 | } |
| 2770 | |
| 2771 | void |
| 2772 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2773 | { |
| 2774 | struct bgp_node *rn; |
| 2775 | struct bgp_table *table; |
| 2776 | |
| 2777 | if (peer->status != Established) |
| 2778 | return; |
| 2779 | |
| 2780 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2781 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2782 | else |
| 2783 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2784 | rn = bgp_route_next (rn)) |
| 2785 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2786 | { |
| 2787 | struct prefix_rd prd; |
| 2788 | prd.family = AF_UNSPEC; |
| 2789 | prd.prefixlen = 64; |
| 2790 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2791 | |
| 2792 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); |
| 2793 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2794 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2795 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2796 | |
| 2797 | struct bgp_clear_node_queue |
| 2798 | { |
| 2799 | struct bgp_node *rn; |
| 2800 | enum bgp_clear_route_type purpose; |
| 2801 | }; |
| 2802 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2803 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2804 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2805 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2806 | struct bgp_clear_node_queue *cnq = data; |
| 2807 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2808 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2809 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2810 | afi_t afi = bgp_node_table (rn)->afi; |
| 2811 | safi_t safi = bgp_node_table (rn)->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2812 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2813 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2814 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2815 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2816 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2817 | { |
| 2818 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2819 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2820 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2821 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2822 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2823 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2824 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2825 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2826 | break; |
| 2827 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2828 | return WQ_SUCCESS; |
| 2829 | } |
| 2830 | |
| 2831 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2832 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2833 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2834 | struct bgp_clear_node_queue *cnq = data; |
| 2835 | struct bgp_node *rn = cnq->rn; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2836 | struct bgp_table *table = bgp_node_table (rn); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2837 | |
| 2838 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2839 | bgp_table_unlock (table); |
| 2840 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2841 | } |
| 2842 | |
| 2843 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2844 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2845 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2846 | struct peer *peer = wq->spec.data; |
| 2847 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2848 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2849 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2850 | |
| 2851 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2852 | } |
| 2853 | |
| 2854 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2855 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2856 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2857 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2858 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2859 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2860 | #undef CLEAR_QUEUE_NAME_LEN |
| 2861 | |
| 2862 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2863 | { |
| 2864 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2865 | exit (1); |
| 2866 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2867 | peer->clear_node_queue->spec.hold = 10; |
| 2868 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2869 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2870 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2871 | peer->clear_node_queue->spec.max_retries = 0; |
| 2872 | |
| 2873 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2874 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2875 | } |
| 2876 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2877 | static void |
| 2878 | 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] | 2879 | struct bgp_table *table, struct peer *rsclient, |
| 2880 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2881 | { |
| 2882 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2883 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2884 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2885 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2886 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2887 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2888 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2889 | if (! table) |
| 2890 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2891 | |
| 2892 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2893 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2894 | struct bgp_info *ri; |
| 2895 | struct bgp_adj_in *ain; |
| 2896 | struct bgp_adj_out *aout; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2897 | |
| 2898 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2899 | * queued for every clearing peer, regardless of whether it is |
| 2900 | * relevant to the peer at hand. |
| 2901 | * |
| 2902 | * Overview: There are 3 different indices which need to be |
| 2903 | * scrubbed, potentially, when a peer is removed: |
| 2904 | * |
| 2905 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2906 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2907 | * 3 other routes visible by the peer's adj-out index |
| 2908 | * |
| 2909 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2910 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2911 | * adj-outs at our leisure. |
| 2912 | * |
| 2913 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2914 | * invisible via RIB index before peer session is allowed to be |
| 2915 | * brought back up. So one needs to know when such a 'search' is |
| 2916 | * complete. |
| 2917 | * |
| 2918 | * Ideally: |
| 2919 | * |
| 2920 | * - there'd be a single global queue or a single RIB walker |
| 2921 | * - rather than tracking which route_nodes still need to be |
| 2922 | * examined on a peer basis, we'd track which peers still |
| 2923 | * aren't cleared |
| 2924 | * |
| 2925 | * Given that our per-peer prefix-counts now should be reliable, |
| 2926 | * this may actually be achievable. It doesn't seem to be a huge |
| 2927 | * problem at this time, |
| 2928 | */ |
Jorge Boncompte [DTI2] | 24e50f2 | 2012-05-07 15:17:33 +0000 | [diff] [blame] | 2929 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2930 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2931 | { |
| 2932 | bgp_adj_in_remove (rn, ain); |
| 2933 | bgp_unlock_node (rn); |
| 2934 | break; |
| 2935 | } |
| 2936 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2937 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2938 | { |
| 2939 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2940 | bgp_unlock_node (rn); |
| 2941 | break; |
| 2942 | } |
| 2943 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2944 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2945 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2946 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2947 | struct bgp_clear_node_queue *cnq; |
| 2948 | |
| 2949 | /* both unlocked in bgp_clear_node_queue_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2950 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2951 | bgp_lock_node (rn); |
| 2952 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2953 | sizeof (struct bgp_clear_node_queue)); |
| 2954 | cnq->rn = rn; |
| 2955 | cnq->purpose = purpose; |
| 2956 | work_queue_add (peer->clear_node_queue, cnq); |
| 2957 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2958 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2959 | } |
| 2960 | return; |
| 2961 | } |
| 2962 | |
| 2963 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2964 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2965 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2966 | { |
| 2967 | struct bgp_node *rn; |
| 2968 | struct bgp_table *table; |
| 2969 | struct peer *rsclient; |
| 2970 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2971 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2972 | if (peer->clear_node_queue == NULL) |
| 2973 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2974 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2975 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 2976 | * Idle until it receives a Clearing_Completed event. This protects |
| 2977 | * against peers which flap faster than we can we clear, which could |
| 2978 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2979 | * |
| 2980 | * a) race with routes from the new session being installed before |
| 2981 | * clear_route_node visits the node (to delete the route of that |
| 2982 | * peer) |
| 2983 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 2984 | * on the process_main queue. Fast-flapping could cause that queue |
| 2985 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2986 | */ |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 2987 | |
| 2988 | /* lock peer in assumption that clear-node-queue will get nodes; if so, |
| 2989 | * the unlock will happen upon work-queue completion; other wise, the |
| 2990 | * unlock happens at the end of this function. |
| 2991 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2992 | if (!peer->clear_node_queue->thread) |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 2993 | peer_lock (peer); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2994 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2995 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2996 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2997 | case BGP_CLEAR_ROUTE_NORMAL: |
| 2998 | if (safi != SAFI_MPLS_VPN) |
| 2999 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 3000 | else |
| 3001 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 3002 | rn = bgp_route_next (rn)) |
| 3003 | if ((table = rn->info) != NULL) |
| 3004 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 3005 | |
| 3006 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 3007 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 3008 | PEER_FLAG_RSERVER_CLIENT)) |
| 3009 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 3010 | break; |
| 3011 | |
| 3012 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
| 3013 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 3014 | break; |
| 3015 | |
| 3016 | default: |
| 3017 | assert (0); |
| 3018 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3019 | } |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3020 | |
| 3021 | /* unlock if no nodes got added to the clear-node-queue. */ |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 3022 | if (!peer->clear_node_queue->thread) |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3023 | peer_unlock (peer); |
| 3024 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3025 | } |
| 3026 | |
| 3027 | void |
| 3028 | bgp_clear_route_all (struct peer *peer) |
| 3029 | { |
| 3030 | afi_t afi; |
| 3031 | safi_t safi; |
| 3032 | |
| 3033 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3034 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3035 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3036 | } |
| 3037 | |
| 3038 | void |
| 3039 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 3040 | { |
| 3041 | struct bgp_table *table; |
| 3042 | struct bgp_node *rn; |
| 3043 | struct bgp_adj_in *ain; |
| 3044 | |
| 3045 | table = peer->bgp->rib[afi][safi]; |
| 3046 | |
| 3047 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3048 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 3049 | if (ain->peer == peer) |
| 3050 | { |
| 3051 | bgp_adj_in_remove (rn, ain); |
| 3052 | bgp_unlock_node (rn); |
| 3053 | break; |
| 3054 | } |
| 3055 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 3056 | |
| 3057 | void |
| 3058 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 3059 | { |
| 3060 | struct bgp_node *rn; |
| 3061 | struct bgp_info *ri; |
| 3062 | struct bgp_table *table; |
| 3063 | |
| 3064 | table = peer->bgp->rib[afi][safi]; |
| 3065 | |
| 3066 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3067 | { |
| 3068 | for (ri = rn->info; ri; ri = ri->next) |
| 3069 | if (ri->peer == peer) |
| 3070 | { |
| 3071 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 3072 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3073 | break; |
| 3074 | } |
| 3075 | } |
| 3076 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3077 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3078 | /* Delete all kernel routes. */ |
| 3079 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3080 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3081 | { |
| 3082 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3083 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3084 | struct bgp_node *rn; |
| 3085 | struct bgp_table *table; |
| 3086 | struct bgp_info *ri; |
| 3087 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3088 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3089 | { |
| 3090 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 3091 | |
| 3092 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3093 | for (ri = rn->info; ri; ri = ri->next) |
| 3094 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3095 | && ri->type == ZEBRA_ROUTE_BGP |
| 3096 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3097 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3098 | |
| 3099 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 3100 | |
| 3101 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3102 | for (ri = rn->info; ri; ri = ri->next) |
| 3103 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3104 | && ri->type == ZEBRA_ROUTE_BGP |
| 3105 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3106 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3107 | } |
| 3108 | } |
| 3109 | |
| 3110 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3111 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3112 | { |
| 3113 | vty_reset (); |
| 3114 | bgp_zclient_reset (); |
| 3115 | access_list_reset (); |
| 3116 | prefix_list_reset (); |
| 3117 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3118 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3119 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3120 | value. */ |
| 3121 | int |
| 3122 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 3123 | { |
| 3124 | u_char *pnt; |
| 3125 | u_char *lim; |
| 3126 | struct prefix p; |
| 3127 | int psize; |
| 3128 | int ret; |
| 3129 | |
| 3130 | /* Check peer status. */ |
| 3131 | if (peer->status != Established) |
| 3132 | return 0; |
| 3133 | |
| 3134 | pnt = packet->nlri; |
| 3135 | lim = pnt + packet->length; |
| 3136 | |
| 3137 | for (; pnt < lim; pnt += psize) |
| 3138 | { |
| 3139 | /* Clear prefix structure. */ |
| 3140 | memset (&p, 0, sizeof (struct prefix)); |
| 3141 | |
| 3142 | /* Fetch prefix length. */ |
| 3143 | p.prefixlen = *pnt++; |
| 3144 | p.family = afi2family (packet->afi); |
| 3145 | |
| 3146 | /* Already checked in nlri_sanity_check(). We do double check |
| 3147 | here. */ |
| 3148 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 3149 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 3150 | return -1; |
| 3151 | |
| 3152 | /* Packet size overflow check. */ |
| 3153 | psize = PSIZE (p.prefixlen); |
| 3154 | |
| 3155 | /* When packet overflow occur return immediately. */ |
| 3156 | if (pnt + psize > lim) |
| 3157 | return -1; |
| 3158 | |
| 3159 | /* Fetch prefix from NLRI packet. */ |
| 3160 | memcpy (&p.u.prefix, pnt, psize); |
| 3161 | |
| 3162 | /* Check address. */ |
| 3163 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3164 | { |
| 3165 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3166 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3167 | /* |
| 3168 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 3169 | * If a BGP router receives an UPDATE message with a |
| 3170 | * semantically incorrect NLRI field, in which a prefix is |
| 3171 | * semantically incorrect (eg. an unexpected multicast IP |
| 3172 | * address), it should ignore the prefix. |
| 3173 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3174 | zlog (peer->log, LOG_ERR, |
| 3175 | "IPv4 unicast NLRI is multicast address %s", |
| 3176 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3177 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3178 | return -1; |
| 3179 | } |
| 3180 | } |
| 3181 | |
| 3182 | #ifdef HAVE_IPV6 |
| 3183 | /* Check address. */ |
| 3184 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3185 | { |
| 3186 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3187 | { |
| 3188 | char buf[BUFSIZ]; |
| 3189 | |
| 3190 | zlog (peer->log, LOG_WARNING, |
| 3191 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 3192 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3193 | |
| 3194 | continue; |
| 3195 | } |
| 3196 | } |
| 3197 | #endif /* HAVE_IPV6 */ |
| 3198 | |
| 3199 | /* Normal process. */ |
| 3200 | if (attr) |
| 3201 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3202 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3203 | else |
| 3204 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3205 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3206 | |
| 3207 | /* Address family configuration mismatch or maximum-prefix count |
| 3208 | overflow. */ |
| 3209 | if (ret < 0) |
| 3210 | return -1; |
| 3211 | } |
| 3212 | |
| 3213 | /* Packet length consistency check. */ |
| 3214 | if (pnt != lim) |
| 3215 | return -1; |
| 3216 | |
| 3217 | return 0; |
| 3218 | } |
| 3219 | |
| 3220 | /* NLRI encode syntax check routine. */ |
| 3221 | int |
| 3222 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 3223 | bgp_size_t length) |
| 3224 | { |
| 3225 | u_char *end; |
| 3226 | u_char prefixlen; |
| 3227 | int psize; |
| 3228 | |
| 3229 | end = pnt + length; |
| 3230 | |
| 3231 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 3232 | syntactic validity. If the field is syntactically incorrect, |
| 3233 | then the Error Subcode is set to Invalid Network Field. */ |
| 3234 | |
| 3235 | while (pnt < end) |
| 3236 | { |
| 3237 | prefixlen = *pnt++; |
| 3238 | |
| 3239 | /* Prefix length check. */ |
| 3240 | if ((afi == AFI_IP && prefixlen > 32) |
| 3241 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 3242 | { |
| 3243 | plog_err (peer->log, |
| 3244 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 3245 | peer->host, prefixlen); |
| 3246 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3247 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3248 | return -1; |
| 3249 | } |
| 3250 | |
| 3251 | /* Packet size overflow check. */ |
| 3252 | psize = PSIZE (prefixlen); |
| 3253 | |
| 3254 | if (pnt + psize > end) |
| 3255 | { |
| 3256 | plog_err (peer->log, |
| 3257 | "%s [Error] Update packet error" |
| 3258 | " (prefix data overflow prefix size is %d)", |
| 3259 | peer->host, psize); |
| 3260 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3261 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3262 | return -1; |
| 3263 | } |
| 3264 | |
| 3265 | pnt += psize; |
| 3266 | } |
| 3267 | |
| 3268 | /* Packet length consistency check. */ |
| 3269 | if (pnt != end) |
| 3270 | { |
| 3271 | plog_err (peer->log, |
| 3272 | "%s [Error] Update packet error" |
| 3273 | " (prefix length mismatch with total length)", |
| 3274 | peer->host); |
| 3275 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3276 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3277 | return -1; |
| 3278 | } |
| 3279 | return 0; |
| 3280 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3281 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3282 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3283 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3284 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3285 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3286 | } |
| 3287 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3288 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3289 | bgp_static_free (struct bgp_static *bgp_static) |
| 3290 | { |
| 3291 | if (bgp_static->rmap.name) |
| 3292 | free (bgp_static->rmap.name); |
| 3293 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3294 | } |
| 3295 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3296 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3297 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3298 | struct prefix *p, afi_t afi, safi_t safi) |
| 3299 | { |
| 3300 | struct bgp_node *rn; |
| 3301 | struct bgp_info *ri; |
| 3302 | |
| 3303 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3304 | |
| 3305 | /* Check selected route and self inserted route. */ |
| 3306 | for (ri = rn->info; ri; ri = ri->next) |
| 3307 | if (ri->peer == bgp->peer_self |
| 3308 | && ri->type == ZEBRA_ROUTE_BGP |
| 3309 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3310 | break; |
| 3311 | |
| 3312 | /* Withdraw static BGP route from routing table. */ |
| 3313 | if (ri) |
| 3314 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3315 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3316 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3317 | } |
| 3318 | |
| 3319 | /* Unlock bgp_node_lookup. */ |
| 3320 | bgp_unlock_node (rn); |
| 3321 | } |
| 3322 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3323 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3324 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3325 | struct bgp_static *bgp_static, |
| 3326 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3327 | { |
| 3328 | struct bgp_node *rn; |
| 3329 | struct bgp_info *ri; |
| 3330 | struct bgp_info *new; |
| 3331 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3332 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3333 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3334 | struct attr new_attr; |
| 3335 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3336 | struct bgp *bgp; |
| 3337 | int ret; |
| 3338 | char buf[SU_ADDRSTRLEN]; |
| 3339 | |
| 3340 | bgp = rsclient->bgp; |
| 3341 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3342 | assert (bgp_static); |
| 3343 | if (!bgp_static) |
| 3344 | return; |
| 3345 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3346 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3347 | |
| 3348 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3349 | |
| 3350 | attr.nexthop = bgp_static->igpnexthop; |
| 3351 | attr.med = bgp_static->igpmetric; |
| 3352 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3353 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3354 | if (bgp_static->atomic) |
| 3355 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3356 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3357 | /* Apply network route-map for export to this rsclient. */ |
| 3358 | if (bgp_static->rmap.name) |
| 3359 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3360 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3361 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3362 | info.attr = &attr_tmp; |
| 3363 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3364 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3365 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3366 | |
| 3367 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3368 | |
| 3369 | rsclient->rmap_type = 0; |
| 3370 | |
| 3371 | if (ret == RMAP_DENYMATCH) |
| 3372 | { |
| 3373 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3374 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3375 | |
| 3376 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3377 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3378 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3379 | bgp_attr_extra_free (&attr); |
| 3380 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3381 | return; |
| 3382 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3383 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3384 | } |
| 3385 | else |
| 3386 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3387 | |
| 3388 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3389 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3390 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3391 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3392 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3393 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3394 | == RMAP_DENY) |
| 3395 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3396 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3397 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3398 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3399 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3400 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3401 | p->prefixlen, rsclient->host); |
| 3402 | |
| 3403 | bgp->peer_self->rmap_type = 0; |
| 3404 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3405 | bgp_attr_unintern (&attr_new); |
| 3406 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3407 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3408 | |
| 3409 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3410 | |
| 3411 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3412 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3413 | |
| 3414 | bgp->peer_self->rmap_type = 0; |
| 3415 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3416 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3417 | attr_new = bgp_attr_intern (&new_attr); |
| 3418 | |
| 3419 | for (ri = rn->info; ri; ri = ri->next) |
| 3420 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3421 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3422 | break; |
| 3423 | |
| 3424 | if (ri) |
| 3425 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3426 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3427 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3428 | { |
| 3429 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3430 | bgp_attr_unintern (&attr_new); |
| 3431 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3432 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3433 | return; |
| 3434 | } |
| 3435 | else |
| 3436 | { |
| 3437 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3438 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3439 | |
| 3440 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3441 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3442 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3443 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3444 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3445 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3446 | |
| 3447 | /* Process change. */ |
| 3448 | bgp_process (bgp, rn, afi, safi); |
| 3449 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3450 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3451 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3452 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3453 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3454 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3455 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3456 | /* Make new BGP info. */ |
| 3457 | new = bgp_info_new (); |
| 3458 | new->type = ZEBRA_ROUTE_BGP; |
| 3459 | new->sub_type = BGP_ROUTE_STATIC; |
| 3460 | new->peer = bgp->peer_self; |
| 3461 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3462 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3463 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3464 | |
| 3465 | /* Register new BGP information. */ |
| 3466 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3467 | |
| 3468 | /* route_node_get lock */ |
| 3469 | bgp_unlock_node (rn); |
| 3470 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3471 | /* Process change. */ |
| 3472 | bgp_process (bgp, rn, afi, safi); |
| 3473 | |
| 3474 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3475 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3476 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3477 | } |
| 3478 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3479 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3480 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3481 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3482 | { |
| 3483 | struct bgp_node *rn; |
| 3484 | struct bgp_info *ri; |
| 3485 | struct bgp_info *new; |
| 3486 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3487 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3488 | struct attr *attr_new; |
| 3489 | int ret; |
| 3490 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3491 | assert (bgp_static); |
| 3492 | if (!bgp_static) |
| 3493 | return; |
| 3494 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3495 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3496 | |
| 3497 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3498 | |
| 3499 | attr.nexthop = bgp_static->igpnexthop; |
| 3500 | attr.med = bgp_static->igpmetric; |
| 3501 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3502 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3503 | if (bgp_static->atomic) |
| 3504 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3505 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3506 | /* Apply route-map. */ |
| 3507 | if (bgp_static->rmap.name) |
| 3508 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3509 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3510 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3511 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3512 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3513 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3514 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3515 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3516 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3517 | bgp->peer_self->rmap_type = 0; |
| 3518 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3519 | if (ret == RMAP_DENYMATCH) |
| 3520 | { |
| 3521 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3522 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3528 | return; |
| 3529 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3530 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3531 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3532 | else |
| 3533 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3534 | |
| 3535 | for (ri = rn->info; ri; ri = ri->next) |
| 3536 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3537 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3538 | break; |
| 3539 | |
| 3540 | if (ri) |
| 3541 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3542 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3543 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3544 | { |
| 3545 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3546 | bgp_attr_unintern (&attr_new); |
| 3547 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3548 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3549 | return; |
| 3550 | } |
| 3551 | else |
| 3552 | { |
| 3553 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3554 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3555 | |
| 3556 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3557 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3558 | bgp_info_restore(rn, ri); |
| 3559 | else |
| 3560 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3561 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3562 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3563 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3564 | |
| 3565 | /* Process change. */ |
| 3566 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3567 | bgp_process (bgp, rn, afi, safi); |
| 3568 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3569 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3570 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3571 | return; |
| 3572 | } |
| 3573 | } |
| 3574 | |
| 3575 | /* Make new BGP info. */ |
| 3576 | new = bgp_info_new (); |
| 3577 | new->type = ZEBRA_ROUTE_BGP; |
| 3578 | new->sub_type = BGP_ROUTE_STATIC; |
| 3579 | new->peer = bgp->peer_self; |
| 3580 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3581 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3582 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3583 | |
| 3584 | /* Aggregate address increment. */ |
| 3585 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3586 | |
| 3587 | /* Register new BGP information. */ |
| 3588 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3589 | |
| 3590 | /* route_node_get lock */ |
| 3591 | bgp_unlock_node (rn); |
| 3592 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3593 | /* Process change. */ |
| 3594 | bgp_process (bgp, rn, afi, safi); |
| 3595 | |
| 3596 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3597 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3598 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3599 | } |
| 3600 | |
| 3601 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3602 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3603 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3604 | { |
| 3605 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3606 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3607 | |
| 3608 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3609 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3610 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3611 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3612 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3613 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3614 | } |
| 3615 | } |
| 3616 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3617 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3618 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3619 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3620 | { |
| 3621 | struct bgp_node *rn; |
| 3622 | struct bgp_info *new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3623 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3624 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3625 | |
| 3626 | /* Make new BGP info. */ |
| 3627 | new = bgp_info_new (); |
| 3628 | new->type = ZEBRA_ROUTE_BGP; |
| 3629 | new->sub_type = BGP_ROUTE_STATIC; |
| 3630 | new->peer = bgp->peer_self; |
| 3631 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 3632 | SET_FLAG (new->flags, BGP_INFO_VALID); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3633 | new->uptime = bgp_clock (); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3634 | new->extra = bgp_info_extra_new(); |
| 3635 | memcpy (new->extra->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3636 | |
| 3637 | /* Aggregate address increment. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3638 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3639 | |
| 3640 | /* Register new BGP information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3641 | bgp_info_add (rn, new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3642 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3643 | /* route_node_get lock */ |
| 3644 | bgp_unlock_node (rn); |
| 3645 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3646 | /* Process change. */ |
| 3647 | bgp_process (bgp, rn, afi, safi); |
| 3648 | } |
| 3649 | |
| 3650 | void |
| 3651 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3652 | safi_t safi) |
| 3653 | { |
| 3654 | struct bgp_node *rn; |
| 3655 | struct bgp_info *ri; |
| 3656 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3657 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3658 | |
| 3659 | /* Check selected route and self inserted route. */ |
| 3660 | for (ri = rn->info; ri; ri = ri->next) |
| 3661 | if (ri->peer == bgp->peer_self |
| 3662 | && ri->type == ZEBRA_ROUTE_BGP |
| 3663 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3664 | break; |
| 3665 | |
| 3666 | /* Withdraw static BGP route from routing table. */ |
| 3667 | if (ri) |
| 3668 | { |
| 3669 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3670 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3671 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3672 | } |
| 3673 | |
| 3674 | /* Unlock bgp_node_lookup. */ |
| 3675 | bgp_unlock_node (rn); |
| 3676 | } |
| 3677 | |
| 3678 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3679 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3680 | { |
| 3681 | struct bgp_static *bgp_static; |
| 3682 | struct bgp *bgp; |
| 3683 | struct bgp_node *rn; |
| 3684 | struct prefix *p; |
| 3685 | |
| 3686 | bgp = rsclient->bgp; |
| 3687 | |
| 3688 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3689 | if ((bgp_static = rn->info) != NULL) |
| 3690 | { |
| 3691 | p = &rn->p; |
| 3692 | |
| 3693 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3694 | afi, safi); |
| 3695 | } |
| 3696 | } |
| 3697 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3698 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3699 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3700 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3701 | { |
| 3702 | struct bgp_node *rn; |
| 3703 | struct bgp_info *ri; |
| 3704 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3705 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3706 | |
| 3707 | /* Check selected route and self inserted route. */ |
| 3708 | for (ri = rn->info; ri; ri = ri->next) |
| 3709 | if (ri->peer == bgp->peer_self |
| 3710 | && ri->type == ZEBRA_ROUTE_BGP |
| 3711 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3712 | break; |
| 3713 | |
| 3714 | /* Withdraw static BGP route from routing table. */ |
| 3715 | if (ri) |
| 3716 | { |
| 3717 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3718 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3719 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3720 | } |
| 3721 | |
| 3722 | /* Unlock bgp_node_lookup. */ |
| 3723 | bgp_unlock_node (rn); |
| 3724 | } |
| 3725 | |
| 3726 | /* Configure static BGP network. When user don't run zebra, static |
| 3727 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3728 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3729 | 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] | 3730 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3731 | { |
| 3732 | int ret; |
| 3733 | struct prefix p; |
| 3734 | struct bgp_static *bgp_static; |
| 3735 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3736 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3737 | |
| 3738 | /* Convert IP prefix string to struct prefix. */ |
| 3739 | ret = str2prefix (ip_str, &p); |
| 3740 | if (! ret) |
| 3741 | { |
| 3742 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3743 | return CMD_WARNING; |
| 3744 | } |
| 3745 | #ifdef HAVE_IPV6 |
| 3746 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3747 | { |
| 3748 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3749 | VTY_NEWLINE); |
| 3750 | return CMD_WARNING; |
| 3751 | } |
| 3752 | #endif /* HAVE_IPV6 */ |
| 3753 | |
| 3754 | apply_mask (&p); |
| 3755 | |
| 3756 | /* Set BGP static route configuration. */ |
| 3757 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3758 | |
| 3759 | if (rn->info) |
| 3760 | { |
| 3761 | /* Configuration change. */ |
| 3762 | bgp_static = rn->info; |
| 3763 | |
| 3764 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3765 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 3766 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3767 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3768 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3769 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3770 | if (rmap) |
| 3771 | { |
| 3772 | if (bgp_static->rmap.name) |
| 3773 | free (bgp_static->rmap.name); |
| 3774 | bgp_static->rmap.name = strdup (rmap); |
| 3775 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3776 | } |
| 3777 | else |
| 3778 | { |
| 3779 | if (bgp_static->rmap.name) |
| 3780 | free (bgp_static->rmap.name); |
| 3781 | bgp_static->rmap.name = NULL; |
| 3782 | bgp_static->rmap.map = NULL; |
| 3783 | bgp_static->valid = 0; |
| 3784 | } |
| 3785 | bgp_unlock_node (rn); |
| 3786 | } |
| 3787 | else |
| 3788 | { |
| 3789 | /* New configuration. */ |
| 3790 | bgp_static = bgp_static_new (); |
| 3791 | bgp_static->backdoor = backdoor; |
| 3792 | bgp_static->valid = 0; |
| 3793 | bgp_static->igpmetric = 0; |
| 3794 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3795 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3796 | if (rmap) |
| 3797 | { |
| 3798 | if (bgp_static->rmap.name) |
| 3799 | free (bgp_static->rmap.name); |
| 3800 | bgp_static->rmap.name = strdup (rmap); |
| 3801 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3802 | } |
| 3803 | rn->info = bgp_static; |
| 3804 | } |
| 3805 | |
| 3806 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3807 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3808 | { |
| 3809 | bgp_static->valid = 1; |
| 3810 | |
| 3811 | if (need_update) |
| 3812 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3813 | |
| 3814 | if (! bgp_static->backdoor) |
| 3815 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3816 | } |
| 3817 | |
| 3818 | return CMD_SUCCESS; |
| 3819 | } |
| 3820 | |
| 3821 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3822 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3823 | 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] | 3824 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3825 | { |
| 3826 | int ret; |
| 3827 | struct prefix p; |
| 3828 | struct bgp_static *bgp_static; |
| 3829 | struct bgp_node *rn; |
| 3830 | |
| 3831 | /* Convert IP prefix string to struct prefix. */ |
| 3832 | ret = str2prefix (ip_str, &p); |
| 3833 | if (! ret) |
| 3834 | { |
| 3835 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3836 | return CMD_WARNING; |
| 3837 | } |
| 3838 | #ifdef HAVE_IPV6 |
| 3839 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3840 | { |
| 3841 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3842 | VTY_NEWLINE); |
| 3843 | return CMD_WARNING; |
| 3844 | } |
| 3845 | #endif /* HAVE_IPV6 */ |
| 3846 | |
| 3847 | apply_mask (&p); |
| 3848 | |
| 3849 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3850 | if (! rn) |
| 3851 | { |
| 3852 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3853 | VTY_NEWLINE); |
| 3854 | return CMD_WARNING; |
| 3855 | } |
| 3856 | |
| 3857 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3858 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3859 | /* Update BGP RIB. */ |
| 3860 | if (! bgp_static->backdoor) |
| 3861 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3862 | |
| 3863 | /* Clear configuration. */ |
| 3864 | bgp_static_free (bgp_static); |
| 3865 | rn->info = NULL; |
| 3866 | bgp_unlock_node (rn); |
| 3867 | bgp_unlock_node (rn); |
| 3868 | |
| 3869 | return CMD_SUCCESS; |
| 3870 | } |
| 3871 | |
| 3872 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3873 | instance. */ |
| 3874 | void |
| 3875 | bgp_static_delete (struct bgp *bgp) |
| 3876 | { |
| 3877 | afi_t afi; |
| 3878 | safi_t safi; |
| 3879 | struct bgp_node *rn; |
| 3880 | struct bgp_node *rm; |
| 3881 | struct bgp_table *table; |
| 3882 | struct bgp_static *bgp_static; |
| 3883 | |
| 3884 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3885 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3886 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3887 | if (rn->info != NULL) |
| 3888 | { |
| 3889 | if (safi == SAFI_MPLS_VPN) |
| 3890 | { |
| 3891 | table = rn->info; |
| 3892 | |
| 3893 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3894 | { |
| 3895 | bgp_static = rn->info; |
| 3896 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3897 | AFI_IP, SAFI_MPLS_VPN, |
| 3898 | (struct prefix_rd *)&rn->p, |
| 3899 | bgp_static->tag); |
| 3900 | bgp_static_free (bgp_static); |
| 3901 | rn->info = NULL; |
| 3902 | bgp_unlock_node (rn); |
| 3903 | } |
| 3904 | } |
| 3905 | else |
| 3906 | { |
| 3907 | bgp_static = rn->info; |
| 3908 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3909 | bgp_static_free (bgp_static); |
| 3910 | rn->info = NULL; |
| 3911 | bgp_unlock_node (rn); |
| 3912 | } |
| 3913 | } |
| 3914 | } |
| 3915 | |
| 3916 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3917 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3918 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3919 | { |
| 3920 | int ret; |
| 3921 | struct prefix p; |
| 3922 | struct prefix_rd prd; |
| 3923 | struct bgp *bgp; |
| 3924 | struct bgp_node *prn; |
| 3925 | struct bgp_node *rn; |
| 3926 | struct bgp_table *table; |
| 3927 | struct bgp_static *bgp_static; |
| 3928 | u_char tag[3]; |
| 3929 | |
| 3930 | bgp = vty->index; |
| 3931 | |
| 3932 | ret = str2prefix (ip_str, &p); |
| 3933 | if (! ret) |
| 3934 | { |
| 3935 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3936 | return CMD_WARNING; |
| 3937 | } |
| 3938 | apply_mask (&p); |
| 3939 | |
| 3940 | ret = str2prefix_rd (rd_str, &prd); |
| 3941 | if (! ret) |
| 3942 | { |
| 3943 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3944 | return CMD_WARNING; |
| 3945 | } |
| 3946 | |
| 3947 | ret = str2tag (tag_str, tag); |
| 3948 | if (! ret) |
| 3949 | { |
| 3950 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3951 | return CMD_WARNING; |
| 3952 | } |
| 3953 | |
| 3954 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3955 | (struct prefix *)&prd); |
| 3956 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3957 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3958 | else |
| 3959 | bgp_unlock_node (prn); |
| 3960 | table = prn->info; |
| 3961 | |
| 3962 | rn = bgp_node_get (table, &p); |
| 3963 | |
| 3964 | if (rn->info) |
| 3965 | { |
| 3966 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3967 | bgp_unlock_node (rn); |
| 3968 | } |
| 3969 | else |
| 3970 | { |
| 3971 | /* New configuration. */ |
| 3972 | bgp_static = bgp_static_new (); |
| 3973 | bgp_static->valid = 1; |
| 3974 | memcpy (bgp_static->tag, tag, 3); |
| 3975 | rn->info = bgp_static; |
| 3976 | |
| 3977 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3978 | } |
| 3979 | |
| 3980 | return CMD_SUCCESS; |
| 3981 | } |
| 3982 | |
| 3983 | /* Configure static BGP network. */ |
| 3984 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3985 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3986 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3987 | { |
| 3988 | int ret; |
| 3989 | struct bgp *bgp; |
| 3990 | struct prefix p; |
| 3991 | struct prefix_rd prd; |
| 3992 | struct bgp_node *prn; |
| 3993 | struct bgp_node *rn; |
| 3994 | struct bgp_table *table; |
| 3995 | struct bgp_static *bgp_static; |
| 3996 | u_char tag[3]; |
| 3997 | |
| 3998 | bgp = vty->index; |
| 3999 | |
| 4000 | /* Convert IP prefix string to struct prefix. */ |
| 4001 | ret = str2prefix (ip_str, &p); |
| 4002 | if (! ret) |
| 4003 | { |
| 4004 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4005 | return CMD_WARNING; |
| 4006 | } |
| 4007 | apply_mask (&p); |
| 4008 | |
| 4009 | ret = str2prefix_rd (rd_str, &prd); |
| 4010 | if (! ret) |
| 4011 | { |
| 4012 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4013 | return CMD_WARNING; |
| 4014 | } |
| 4015 | |
| 4016 | ret = str2tag (tag_str, tag); |
| 4017 | if (! ret) |
| 4018 | { |
| 4019 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4020 | return CMD_WARNING; |
| 4021 | } |
| 4022 | |
| 4023 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 4024 | (struct prefix *)&prd); |
| 4025 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 4026 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4027 | else |
| 4028 | bgp_unlock_node (prn); |
| 4029 | table = prn->info; |
| 4030 | |
| 4031 | rn = bgp_node_lookup (table, &p); |
| 4032 | |
| 4033 | if (rn) |
| 4034 | { |
| 4035 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 4036 | |
| 4037 | bgp_static = rn->info; |
| 4038 | bgp_static_free (bgp_static); |
| 4039 | rn->info = NULL; |
| 4040 | bgp_unlock_node (rn); |
| 4041 | bgp_unlock_node (rn); |
| 4042 | } |
| 4043 | else |
| 4044 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 4045 | |
| 4046 | return CMD_SUCCESS; |
| 4047 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4048 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4049 | DEFUN (bgp_network, |
| 4050 | bgp_network_cmd, |
| 4051 | "network A.B.C.D/M", |
| 4052 | "Specify a network to announce via BGP\n" |
| 4053 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4054 | { |
| 4055 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4056 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4057 | } |
| 4058 | |
| 4059 | DEFUN (bgp_network_route_map, |
| 4060 | bgp_network_route_map_cmd, |
| 4061 | "network A.B.C.D/M route-map WORD", |
| 4062 | "Specify a network to announce via BGP\n" |
| 4063 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4064 | "Route-map to modify the attributes\n" |
| 4065 | "Name of the route map\n") |
| 4066 | { |
| 4067 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4068 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4069 | } |
| 4070 | |
| 4071 | DEFUN (bgp_network_backdoor, |
| 4072 | bgp_network_backdoor_cmd, |
| 4073 | "network A.B.C.D/M backdoor", |
| 4074 | "Specify a network to announce via BGP\n" |
| 4075 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4076 | "Specify a BGP backdoor route\n") |
| 4077 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4078 | 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] | 4079 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4080 | } |
| 4081 | |
| 4082 | DEFUN (bgp_network_mask, |
| 4083 | bgp_network_mask_cmd, |
| 4084 | "network A.B.C.D mask A.B.C.D", |
| 4085 | "Specify a network to announce via BGP\n" |
| 4086 | "Network number\n" |
| 4087 | "Network mask\n" |
| 4088 | "Network mask\n") |
| 4089 | { |
| 4090 | int ret; |
| 4091 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4092 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4093 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4094 | if (! ret) |
| 4095 | { |
| 4096 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4097 | return CMD_WARNING; |
| 4098 | } |
| 4099 | |
| 4100 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4101 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4102 | } |
| 4103 | |
| 4104 | DEFUN (bgp_network_mask_route_map, |
| 4105 | bgp_network_mask_route_map_cmd, |
| 4106 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4107 | "Specify a network to announce via BGP\n" |
| 4108 | "Network number\n" |
| 4109 | "Network mask\n" |
| 4110 | "Network mask\n" |
| 4111 | "Route-map to modify the attributes\n" |
| 4112 | "Name of the route map\n") |
| 4113 | { |
| 4114 | int ret; |
| 4115 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4116 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4117 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4118 | if (! ret) |
| 4119 | { |
| 4120 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4121 | return CMD_WARNING; |
| 4122 | } |
| 4123 | |
| 4124 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4125 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4126 | } |
| 4127 | |
| 4128 | DEFUN (bgp_network_mask_backdoor, |
| 4129 | bgp_network_mask_backdoor_cmd, |
| 4130 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4131 | "Specify a network to announce via BGP\n" |
| 4132 | "Network number\n" |
| 4133 | "Network mask\n" |
| 4134 | "Network mask\n" |
| 4135 | "Specify a BGP backdoor route\n") |
| 4136 | { |
| 4137 | int ret; |
| 4138 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4139 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4140 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4141 | if (! ret) |
| 4142 | { |
| 4143 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4144 | return CMD_WARNING; |
| 4145 | } |
| 4146 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4147 | 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] | 4148 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4149 | } |
| 4150 | |
| 4151 | DEFUN (bgp_network_mask_natural, |
| 4152 | bgp_network_mask_natural_cmd, |
| 4153 | "network A.B.C.D", |
| 4154 | "Specify a network to announce via BGP\n" |
| 4155 | "Network number\n") |
| 4156 | { |
| 4157 | int ret; |
| 4158 | char prefix_str[BUFSIZ]; |
| 4159 | |
| 4160 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4161 | if (! ret) |
| 4162 | { |
| 4163 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4164 | return CMD_WARNING; |
| 4165 | } |
| 4166 | |
| 4167 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4168 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4169 | } |
| 4170 | |
| 4171 | DEFUN (bgp_network_mask_natural_route_map, |
| 4172 | bgp_network_mask_natural_route_map_cmd, |
| 4173 | "network A.B.C.D route-map WORD", |
| 4174 | "Specify a network to announce via BGP\n" |
| 4175 | "Network number\n" |
| 4176 | "Route-map to modify the attributes\n" |
| 4177 | "Name of the route map\n") |
| 4178 | { |
| 4179 | int ret; |
| 4180 | char prefix_str[BUFSIZ]; |
| 4181 | |
| 4182 | ret = netmask_str2prefix_str (argv[0], NULL, 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_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4190 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4191 | } |
| 4192 | |
| 4193 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4194 | bgp_network_mask_natural_backdoor_cmd, |
| 4195 | "network A.B.C.D backdoor", |
| 4196 | "Specify a network to announce via BGP\n" |
| 4197 | "Network number\n" |
| 4198 | "Specify a BGP backdoor route\n") |
| 4199 | { |
| 4200 | int ret; |
| 4201 | char prefix_str[BUFSIZ]; |
| 4202 | |
| 4203 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4204 | if (! ret) |
| 4205 | { |
| 4206 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4207 | return CMD_WARNING; |
| 4208 | } |
| 4209 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4210 | 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] | 4211 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4212 | } |
| 4213 | |
| 4214 | DEFUN (no_bgp_network, |
| 4215 | no_bgp_network_cmd, |
| 4216 | "no network A.B.C.D/M", |
| 4217 | NO_STR |
| 4218 | "Specify a network to announce via BGP\n" |
| 4219 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4220 | { |
| 4221 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4222 | bgp_node_safi (vty)); |
| 4223 | } |
| 4224 | |
| 4225 | ALIAS (no_bgp_network, |
| 4226 | no_bgp_network_route_map_cmd, |
| 4227 | "no network A.B.C.D/M route-map WORD", |
| 4228 | NO_STR |
| 4229 | "Specify a network to announce via BGP\n" |
| 4230 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4231 | "Route-map to modify the attributes\n" |
| 4232 | "Name of the route map\n") |
| 4233 | |
| 4234 | ALIAS (no_bgp_network, |
| 4235 | no_bgp_network_backdoor_cmd, |
| 4236 | "no network A.B.C.D/M backdoor", |
| 4237 | NO_STR |
| 4238 | "Specify a network to announce via BGP\n" |
| 4239 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4240 | "Specify a BGP backdoor route\n") |
| 4241 | |
| 4242 | DEFUN (no_bgp_network_mask, |
| 4243 | no_bgp_network_mask_cmd, |
| 4244 | "no network A.B.C.D mask A.B.C.D", |
| 4245 | NO_STR |
| 4246 | "Specify a network to announce via BGP\n" |
| 4247 | "Network number\n" |
| 4248 | "Network mask\n" |
| 4249 | "Network mask\n") |
| 4250 | { |
| 4251 | int ret; |
| 4252 | char prefix_str[BUFSIZ]; |
| 4253 | |
| 4254 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4255 | if (! ret) |
| 4256 | { |
| 4257 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4258 | return CMD_WARNING; |
| 4259 | } |
| 4260 | |
| 4261 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4262 | bgp_node_safi (vty)); |
| 4263 | } |
| 4264 | |
| 4265 | ALIAS (no_bgp_network_mask, |
| 4266 | no_bgp_network_mask_route_map_cmd, |
| 4267 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4268 | NO_STR |
| 4269 | "Specify a network to announce via BGP\n" |
| 4270 | "Network number\n" |
| 4271 | "Network mask\n" |
| 4272 | "Network mask\n" |
| 4273 | "Route-map to modify the attributes\n" |
| 4274 | "Name of the route map\n") |
| 4275 | |
| 4276 | ALIAS (no_bgp_network_mask, |
| 4277 | no_bgp_network_mask_backdoor_cmd, |
| 4278 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4279 | NO_STR |
| 4280 | "Specify a network to announce via BGP\n" |
| 4281 | "Network number\n" |
| 4282 | "Network mask\n" |
| 4283 | "Network mask\n" |
| 4284 | "Specify a BGP backdoor route\n") |
| 4285 | |
| 4286 | DEFUN (no_bgp_network_mask_natural, |
| 4287 | no_bgp_network_mask_natural_cmd, |
| 4288 | "no network A.B.C.D", |
| 4289 | NO_STR |
| 4290 | "Specify a network to announce via BGP\n" |
| 4291 | "Network number\n") |
| 4292 | { |
| 4293 | int ret; |
| 4294 | char prefix_str[BUFSIZ]; |
| 4295 | |
| 4296 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4297 | if (! ret) |
| 4298 | { |
| 4299 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4300 | return CMD_WARNING; |
| 4301 | } |
| 4302 | |
| 4303 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4304 | bgp_node_safi (vty)); |
| 4305 | } |
| 4306 | |
| 4307 | ALIAS (no_bgp_network_mask_natural, |
| 4308 | no_bgp_network_mask_natural_route_map_cmd, |
| 4309 | "no network A.B.C.D route-map WORD", |
| 4310 | NO_STR |
| 4311 | "Specify a network to announce via BGP\n" |
| 4312 | "Network number\n" |
| 4313 | "Route-map to modify the attributes\n" |
| 4314 | "Name of the route map\n") |
| 4315 | |
| 4316 | ALIAS (no_bgp_network_mask_natural, |
| 4317 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4318 | "no network A.B.C.D backdoor", |
| 4319 | NO_STR |
| 4320 | "Specify a network to announce via BGP\n" |
| 4321 | "Network number\n" |
| 4322 | "Specify a BGP backdoor route\n") |
| 4323 | |
| 4324 | #ifdef HAVE_IPV6 |
| 4325 | DEFUN (ipv6_bgp_network, |
| 4326 | ipv6_bgp_network_cmd, |
| 4327 | "network X:X::X:X/M", |
| 4328 | "Specify a network to announce via BGP\n" |
| 4329 | "IPv6 prefix <network>/<length>\n") |
| 4330 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4331 | 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] | 4332 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4333 | } |
| 4334 | |
| 4335 | DEFUN (ipv6_bgp_network_route_map, |
| 4336 | ipv6_bgp_network_route_map_cmd, |
| 4337 | "network X:X::X:X/M route-map WORD", |
| 4338 | "Specify a network to announce via BGP\n" |
| 4339 | "IPv6 prefix <network>/<length>\n" |
| 4340 | "Route-map to modify the attributes\n" |
| 4341 | "Name of the route map\n") |
| 4342 | { |
| 4343 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4344 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4345 | } |
| 4346 | |
| 4347 | DEFUN (no_ipv6_bgp_network, |
| 4348 | no_ipv6_bgp_network_cmd, |
| 4349 | "no network X:X::X:X/M", |
| 4350 | NO_STR |
| 4351 | "Specify a network to announce via BGP\n" |
| 4352 | "IPv6 prefix <network>/<length>\n") |
| 4353 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4354 | 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] | 4355 | } |
| 4356 | |
| 4357 | ALIAS (no_ipv6_bgp_network, |
| 4358 | no_ipv6_bgp_network_route_map_cmd, |
| 4359 | "no network X:X::X:X/M route-map WORD", |
| 4360 | NO_STR |
| 4361 | "Specify a network to announce via BGP\n" |
| 4362 | "IPv6 prefix <network>/<length>\n" |
| 4363 | "Route-map to modify the attributes\n" |
| 4364 | "Name of the route map\n") |
| 4365 | |
| 4366 | ALIAS (ipv6_bgp_network, |
| 4367 | old_ipv6_bgp_network_cmd, |
| 4368 | "ipv6 bgp network X:X::X:X/M", |
| 4369 | IPV6_STR |
| 4370 | BGP_STR |
| 4371 | "Specify a network to announce via BGP\n" |
| 4372 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4373 | |
| 4374 | ALIAS (no_ipv6_bgp_network, |
| 4375 | old_no_ipv6_bgp_network_cmd, |
| 4376 | "no ipv6 bgp network X:X::X:X/M", |
| 4377 | NO_STR |
| 4378 | IPV6_STR |
| 4379 | BGP_STR |
| 4380 | "Specify a network to announce via BGP\n" |
| 4381 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4382 | #endif /* HAVE_IPV6 */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4383 | |
| 4384 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4385 | ALIAS_DEPRECATED (bgp_network, |
| 4386 | bgp_network_ttl_cmd, |
| 4387 | "network A.B.C.D/M pathlimit <0-255>", |
| 4388 | "Specify a network to announce via BGP\n" |
| 4389 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4390 | "AS-Path hopcount limit attribute\n" |
| 4391 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4392 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4393 | bgp_network_backdoor_ttl_cmd, |
| 4394 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4395 | "Specify a network to announce via BGP\n" |
| 4396 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\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 (bgp_network_mask, |
| 4401 | bgp_network_mask_ttl_cmd, |
| 4402 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4403 | "Specify a network to announce via BGP\n" |
| 4404 | "Network number\n" |
| 4405 | "Network mask\n" |
| 4406 | "Network mask\n" |
| 4407 | "AS-Path hopcount limit attribute\n" |
| 4408 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4409 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4410 | bgp_network_mask_backdoor_ttl_cmd, |
| 4411 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4412 | "Specify a network to announce via BGP\n" |
| 4413 | "Network number\n" |
| 4414 | "Network mask\n" |
| 4415 | "Network mask\n" |
| 4416 | "Specify a BGP backdoor route\n" |
| 4417 | "AS-Path hopcount limit attribute\n" |
| 4418 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4419 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4420 | bgp_network_mask_natural_ttl_cmd, |
| 4421 | "network A.B.C.D pathlimit <0-255>", |
| 4422 | "Specify a network to announce via BGP\n" |
| 4423 | "Network number\n" |
| 4424 | "AS-Path hopcount limit attribute\n" |
| 4425 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4426 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4427 | bgp_network_mask_natural_backdoor_ttl_cmd, |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 4428 | "network A.B.C.D backdoor pathlimit <1-255>", |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4429 | "Specify a network to announce via BGP\n" |
| 4430 | "Network number\n" |
| 4431 | "Specify a BGP backdoor route\n" |
| 4432 | "AS-Path hopcount limit attribute\n" |
| 4433 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4434 | ALIAS_DEPRECATED (no_bgp_network, |
| 4435 | no_bgp_network_ttl_cmd, |
| 4436 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4437 | NO_STR |
| 4438 | "Specify a network to announce via BGP\n" |
| 4439 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4440 | "AS-Path hopcount limit attribute\n" |
| 4441 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4442 | ALIAS_DEPRECATED (no_bgp_network, |
| 4443 | no_bgp_network_backdoor_ttl_cmd, |
| 4444 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4445 | NO_STR |
| 4446 | "Specify a network to announce via BGP\n" |
| 4447 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4448 | "Specify a BGP backdoor route\n" |
| 4449 | "AS-Path hopcount limit attribute\n" |
| 4450 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4451 | ALIAS_DEPRECATED (no_bgp_network, |
| 4452 | no_bgp_network_mask_ttl_cmd, |
| 4453 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4454 | NO_STR |
| 4455 | "Specify a network to announce via BGP\n" |
| 4456 | "Network number\n" |
| 4457 | "Network mask\n" |
| 4458 | "Network mask\n" |
| 4459 | "AS-Path hopcount limit attribute\n" |
| 4460 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4461 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4462 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4463 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4464 | NO_STR |
| 4465 | "Specify a network to announce via BGP\n" |
| 4466 | "Network number\n" |
| 4467 | "Network mask\n" |
| 4468 | "Network mask\n" |
| 4469 | "Specify a BGP backdoor route\n" |
| 4470 | "AS-Path hopcount limit attribute\n" |
| 4471 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4472 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4473 | no_bgp_network_mask_natural_ttl_cmd, |
| 4474 | "no network A.B.C.D pathlimit <0-255>", |
| 4475 | NO_STR |
| 4476 | "Specify a network to announce via BGP\n" |
| 4477 | "Network number\n" |
| 4478 | "AS-Path hopcount limit attribute\n" |
| 4479 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4480 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4481 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4482 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4483 | NO_STR |
| 4484 | "Specify a network to announce via BGP\n" |
| 4485 | "Network number\n" |
| 4486 | "Specify a BGP backdoor route\n" |
| 4487 | "AS-Path hopcount limit attribute\n" |
| 4488 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4489 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4490 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4491 | ipv6_bgp_network_ttl_cmd, |
| 4492 | "network X:X::X:X/M pathlimit <0-255>", |
| 4493 | "Specify a network to announce via BGP\n" |
| 4494 | "IPv6 prefix <network>/<length>\n" |
| 4495 | "AS-Path hopcount limit attribute\n" |
| 4496 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4497 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4498 | no_ipv6_bgp_network_ttl_cmd, |
| 4499 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4500 | NO_STR |
| 4501 | "Specify a network to announce via BGP\n" |
| 4502 | "IPv6 prefix <network>/<length>\n" |
| 4503 | "AS-Path hopcount limit attribute\n" |
| 4504 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4505 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4506 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4507 | /* Aggreagete address: |
| 4508 | |
| 4509 | advertise-map Set condition to advertise attribute |
| 4510 | as-set Generate AS set path information |
| 4511 | attribute-map Set attributes of aggregate |
| 4512 | route-map Set parameters of aggregate |
| 4513 | summary-only Filter more specific routes from updates |
| 4514 | suppress-map Conditionally filter more specific routes from updates |
| 4515 | <cr> |
| 4516 | */ |
| 4517 | struct bgp_aggregate |
| 4518 | { |
| 4519 | /* Summary-only flag. */ |
| 4520 | u_char summary_only; |
| 4521 | |
| 4522 | /* AS set generation. */ |
| 4523 | u_char as_set; |
| 4524 | |
| 4525 | /* Route-map for aggregated route. */ |
| 4526 | struct route_map *map; |
| 4527 | |
| 4528 | /* Suppress-count. */ |
| 4529 | unsigned long count; |
| 4530 | |
| 4531 | /* SAFI configuration. */ |
| 4532 | safi_t safi; |
| 4533 | }; |
| 4534 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4535 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4536 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4537 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4538 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4539 | } |
| 4540 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4541 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4542 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4543 | { |
| 4544 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4545 | } |
| 4546 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4547 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4548 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4549 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4550 | struct bgp_aggregate *aggregate) |
| 4551 | { |
| 4552 | struct bgp_table *table; |
| 4553 | struct bgp_node *top; |
| 4554 | struct bgp_node *rn; |
| 4555 | u_char origin; |
| 4556 | struct aspath *aspath = NULL; |
| 4557 | struct aspath *asmerge = NULL; |
| 4558 | struct community *community = NULL; |
| 4559 | struct community *commerge = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4560 | struct bgp_info *ri; |
| 4561 | struct bgp_info *new; |
| 4562 | int first = 1; |
| 4563 | unsigned long match = 0; |
| 4564 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4565 | /* ORIGIN attribute: If at least one route among routes that are |
| 4566 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4567 | aggregated route must have the ORIGIN attribute with the value |
| 4568 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4569 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4570 | route must have the origin attribute with the value EGP. In all |
| 4571 | other case the value of the ORIGIN attribute of the aggregated |
| 4572 | route is INTERNAL. */ |
| 4573 | origin = BGP_ORIGIN_IGP; |
| 4574 | |
| 4575 | table = bgp->rib[afi][safi]; |
| 4576 | |
| 4577 | top = bgp_node_get (table, p); |
| 4578 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4579 | if (rn->p.prefixlen > p->prefixlen) |
| 4580 | { |
| 4581 | match = 0; |
| 4582 | |
| 4583 | for (ri = rn->info; ri; ri = ri->next) |
| 4584 | { |
| 4585 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4586 | continue; |
| 4587 | |
| 4588 | if (del && ri == del) |
| 4589 | continue; |
| 4590 | |
| 4591 | if (! rinew && first) |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 4592 | first = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4593 | |
| 4594 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4595 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4596 | || ri->attr->med != med) |
| 4597 | { |
| 4598 | if (aspath) |
| 4599 | aspath_free (aspath); |
| 4600 | if (community) |
| 4601 | community_free (community); |
| 4602 | bgp_unlock_node (rn); |
| 4603 | bgp_unlock_node (top); |
| 4604 | return; |
| 4605 | } |
| 4606 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4607 | |
| 4608 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4609 | { |
| 4610 | if (aggregate->summary_only) |
| 4611 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4612 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4613 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4614 | match++; |
| 4615 | } |
| 4616 | |
| 4617 | aggregate->count++; |
| 4618 | |
| 4619 | if (aggregate->as_set) |
| 4620 | { |
| 4621 | if (origin < ri->attr->origin) |
| 4622 | origin = ri->attr->origin; |
| 4623 | |
| 4624 | if (aspath) |
| 4625 | { |
| 4626 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4627 | aspath_free (aspath); |
| 4628 | aspath = asmerge; |
| 4629 | } |
| 4630 | else |
| 4631 | aspath = aspath_dup (ri->attr->aspath); |
| 4632 | |
| 4633 | if (ri->attr->community) |
| 4634 | { |
| 4635 | if (community) |
| 4636 | { |
| 4637 | commerge = community_merge (community, |
| 4638 | ri->attr->community); |
| 4639 | community = community_uniq_sort (commerge); |
| 4640 | community_free (commerge); |
| 4641 | } |
| 4642 | else |
| 4643 | community = community_dup (ri->attr->community); |
| 4644 | } |
| 4645 | } |
| 4646 | } |
| 4647 | } |
| 4648 | if (match) |
| 4649 | bgp_process (bgp, rn, afi, safi); |
| 4650 | } |
| 4651 | bgp_unlock_node (top); |
| 4652 | |
| 4653 | if (rinew) |
| 4654 | { |
| 4655 | aggregate->count++; |
| 4656 | |
| 4657 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4658 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4659 | |
| 4660 | if (aggregate->as_set) |
| 4661 | { |
| 4662 | if (origin < rinew->attr->origin) |
| 4663 | origin = rinew->attr->origin; |
| 4664 | |
| 4665 | if (aspath) |
| 4666 | { |
| 4667 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4668 | aspath_free (aspath); |
| 4669 | aspath = asmerge; |
| 4670 | } |
| 4671 | else |
| 4672 | aspath = aspath_dup (rinew->attr->aspath); |
| 4673 | |
| 4674 | if (rinew->attr->community) |
| 4675 | { |
| 4676 | if (community) |
| 4677 | { |
| 4678 | commerge = community_merge (community, |
| 4679 | rinew->attr->community); |
| 4680 | community = community_uniq_sort (commerge); |
| 4681 | community_free (commerge); |
| 4682 | } |
| 4683 | else |
| 4684 | community = community_dup (rinew->attr->community); |
| 4685 | } |
| 4686 | } |
| 4687 | } |
| 4688 | |
| 4689 | if (aggregate->count > 0) |
| 4690 | { |
| 4691 | rn = bgp_node_get (table, p); |
| 4692 | new = bgp_info_new (); |
| 4693 | new->type = ZEBRA_ROUTE_BGP; |
| 4694 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4695 | new->peer = bgp->peer_self; |
| 4696 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4697 | 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] | 4698 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4699 | |
| 4700 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4701 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4702 | bgp_process (bgp, rn, afi, safi); |
| 4703 | } |
| 4704 | else |
| 4705 | { |
| 4706 | if (aspath) |
| 4707 | aspath_free (aspath); |
| 4708 | if (community) |
| 4709 | community_free (community); |
| 4710 | } |
| 4711 | } |
| 4712 | |
| 4713 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4714 | struct bgp_aggregate *); |
| 4715 | |
| 4716 | void |
| 4717 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4718 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4719 | { |
| 4720 | struct bgp_node *child; |
| 4721 | struct bgp_node *rn; |
| 4722 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4723 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4724 | |
| 4725 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4726 | if (safi == SAFI_MPLS_VPN) |
| 4727 | return; |
| 4728 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4729 | table = bgp->aggregate[afi][safi]; |
| 4730 | |
| 4731 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4732 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4733 | return; |
| 4734 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4735 | if (p->prefixlen == 0) |
| 4736 | return; |
| 4737 | |
| 4738 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4739 | return; |
| 4740 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4741 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4742 | |
| 4743 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4744 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4745 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4746 | { |
| 4747 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4748 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4749 | } |
| 4750 | bgp_unlock_node (child); |
| 4751 | } |
| 4752 | |
| 4753 | void |
| 4754 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4755 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4756 | { |
| 4757 | struct bgp_node *child; |
| 4758 | struct bgp_node *rn; |
| 4759 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4760 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4761 | |
| 4762 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4763 | if (safi == SAFI_MPLS_VPN) |
| 4764 | return; |
| 4765 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4766 | table = bgp->aggregate[afi][safi]; |
| 4767 | |
| 4768 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4769 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4770 | return; |
| 4771 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4772 | if (p->prefixlen == 0) |
| 4773 | return; |
| 4774 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4775 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4776 | |
| 4777 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4778 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4779 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4780 | { |
| 4781 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4782 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4783 | } |
| 4784 | bgp_unlock_node (child); |
| 4785 | } |
| 4786 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4787 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4788 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4789 | struct bgp_aggregate *aggregate) |
| 4790 | { |
| 4791 | struct bgp_table *table; |
| 4792 | struct bgp_node *top; |
| 4793 | struct bgp_node *rn; |
| 4794 | struct bgp_info *new; |
| 4795 | struct bgp_info *ri; |
| 4796 | unsigned long match; |
| 4797 | u_char origin = BGP_ORIGIN_IGP; |
| 4798 | struct aspath *aspath = NULL; |
| 4799 | struct aspath *asmerge = NULL; |
| 4800 | struct community *community = NULL; |
| 4801 | struct community *commerge = NULL; |
| 4802 | |
| 4803 | table = bgp->rib[afi][safi]; |
| 4804 | |
| 4805 | /* Sanity check. */ |
| 4806 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4807 | return; |
| 4808 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4809 | return; |
| 4810 | |
| 4811 | /* If routes exists below this node, generate aggregate routes. */ |
| 4812 | top = bgp_node_get (table, p); |
| 4813 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4814 | if (rn->p.prefixlen > p->prefixlen) |
| 4815 | { |
| 4816 | match = 0; |
| 4817 | |
| 4818 | for (ri = rn->info; ri; ri = ri->next) |
| 4819 | { |
| 4820 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4821 | continue; |
| 4822 | |
| 4823 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4824 | { |
| 4825 | /* summary-only aggregate route suppress aggregated |
| 4826 | route announcement. */ |
| 4827 | if (aggregate->summary_only) |
| 4828 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4829 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4830 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4831 | match++; |
| 4832 | } |
| 4833 | /* as-set aggregate route generate origin, as path, |
| 4834 | community aggregation. */ |
| 4835 | if (aggregate->as_set) |
| 4836 | { |
| 4837 | if (origin < ri->attr->origin) |
| 4838 | origin = ri->attr->origin; |
| 4839 | |
| 4840 | if (aspath) |
| 4841 | { |
| 4842 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4843 | aspath_free (aspath); |
| 4844 | aspath = asmerge; |
| 4845 | } |
| 4846 | else |
| 4847 | aspath = aspath_dup (ri->attr->aspath); |
| 4848 | |
| 4849 | if (ri->attr->community) |
| 4850 | { |
| 4851 | if (community) |
| 4852 | { |
| 4853 | commerge = community_merge (community, |
| 4854 | ri->attr->community); |
| 4855 | community = community_uniq_sort (commerge); |
| 4856 | community_free (commerge); |
| 4857 | } |
| 4858 | else |
| 4859 | community = community_dup (ri->attr->community); |
| 4860 | } |
| 4861 | } |
| 4862 | aggregate->count++; |
| 4863 | } |
| 4864 | } |
| 4865 | |
| 4866 | /* If this node is suppressed, process the change. */ |
| 4867 | if (match) |
| 4868 | bgp_process (bgp, rn, afi, safi); |
| 4869 | } |
| 4870 | bgp_unlock_node (top); |
| 4871 | |
| 4872 | /* Add aggregate route to BGP table. */ |
| 4873 | if (aggregate->count) |
| 4874 | { |
| 4875 | rn = bgp_node_get (table, p); |
| 4876 | |
| 4877 | new = bgp_info_new (); |
| 4878 | new->type = ZEBRA_ROUTE_BGP; |
| 4879 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4880 | new->peer = bgp->peer_self; |
| 4881 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4882 | 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] | 4883 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4884 | |
| 4885 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4886 | bgp_unlock_node (rn); |
| 4887 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4888 | /* Process change. */ |
| 4889 | bgp_process (bgp, rn, afi, safi); |
| 4890 | } |
| 4891 | } |
| 4892 | |
| 4893 | void |
| 4894 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4895 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4896 | { |
| 4897 | struct bgp_table *table; |
| 4898 | struct bgp_node *top; |
| 4899 | struct bgp_node *rn; |
| 4900 | struct bgp_info *ri; |
| 4901 | unsigned long match; |
| 4902 | |
| 4903 | table = bgp->rib[afi][safi]; |
| 4904 | |
| 4905 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4906 | return; |
| 4907 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4908 | return; |
| 4909 | |
| 4910 | /* If routes exists below this node, generate aggregate routes. */ |
| 4911 | top = bgp_node_get (table, p); |
| 4912 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4913 | if (rn->p.prefixlen > p->prefixlen) |
| 4914 | { |
| 4915 | match = 0; |
| 4916 | |
| 4917 | for (ri = rn->info; ri; ri = ri->next) |
| 4918 | { |
| 4919 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4920 | continue; |
| 4921 | |
| 4922 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4923 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4924 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4925 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4926 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4927 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4928 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4929 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4930 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4931 | match++; |
| 4932 | } |
| 4933 | } |
| 4934 | aggregate->count--; |
| 4935 | } |
| 4936 | } |
| 4937 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4938 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4939 | if (match) |
| 4940 | bgp_process (bgp, rn, afi, safi); |
| 4941 | } |
| 4942 | bgp_unlock_node (top); |
| 4943 | |
| 4944 | /* Delete aggregate route from BGP table. */ |
| 4945 | rn = bgp_node_get (table, p); |
| 4946 | |
| 4947 | for (ri = rn->info; ri; ri = ri->next) |
| 4948 | if (ri->peer == bgp->peer_self |
| 4949 | && ri->type == ZEBRA_ROUTE_BGP |
| 4950 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4951 | break; |
| 4952 | |
| 4953 | /* Withdraw static BGP route from routing table. */ |
| 4954 | if (ri) |
| 4955 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4956 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4957 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4958 | } |
| 4959 | |
| 4960 | /* Unlock bgp_node_lookup. */ |
| 4961 | bgp_unlock_node (rn); |
| 4962 | } |
| 4963 | |
| 4964 | /* Aggregate route attribute. */ |
| 4965 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4966 | #define AGGREGATE_AS_SET 1 |
| 4967 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4968 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4969 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4970 | afi_t afi, safi_t safi) |
| 4971 | { |
| 4972 | int ret; |
| 4973 | struct prefix p; |
| 4974 | struct bgp_node *rn; |
| 4975 | struct bgp *bgp; |
| 4976 | struct bgp_aggregate *aggregate; |
| 4977 | |
| 4978 | /* Convert string to prefix structure. */ |
| 4979 | ret = str2prefix (prefix_str, &p); |
| 4980 | if (!ret) |
| 4981 | { |
| 4982 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4983 | return CMD_WARNING; |
| 4984 | } |
| 4985 | apply_mask (&p); |
| 4986 | |
| 4987 | /* Get BGP structure. */ |
| 4988 | bgp = vty->index; |
| 4989 | |
| 4990 | /* Old configuration check. */ |
| 4991 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4992 | if (! rn) |
| 4993 | { |
| 4994 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4995 | VTY_NEWLINE); |
| 4996 | return CMD_WARNING; |
| 4997 | } |
| 4998 | |
| 4999 | aggregate = rn->info; |
| 5000 | if (aggregate->safi & SAFI_UNICAST) |
| 5001 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5002 | if (aggregate->safi & SAFI_MULTICAST) |
| 5003 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5004 | |
| 5005 | /* Unlock aggregate address configuration. */ |
| 5006 | rn->info = NULL; |
| 5007 | bgp_aggregate_free (aggregate); |
| 5008 | bgp_unlock_node (rn); |
| 5009 | bgp_unlock_node (rn); |
| 5010 | |
| 5011 | return CMD_SUCCESS; |
| 5012 | } |
| 5013 | |
| 5014 | static int |
| 5015 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5016 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5017 | u_char summary_only, u_char as_set) |
| 5018 | { |
| 5019 | int ret; |
| 5020 | struct prefix p; |
| 5021 | struct bgp_node *rn; |
| 5022 | struct bgp *bgp; |
| 5023 | struct bgp_aggregate *aggregate; |
| 5024 | |
| 5025 | /* Convert string to prefix structure. */ |
| 5026 | ret = str2prefix (prefix_str, &p); |
| 5027 | if (!ret) |
| 5028 | { |
| 5029 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5030 | return CMD_WARNING; |
| 5031 | } |
| 5032 | apply_mask (&p); |
| 5033 | |
| 5034 | /* Get BGP structure. */ |
| 5035 | bgp = vty->index; |
| 5036 | |
| 5037 | /* Old configuration check. */ |
| 5038 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 5039 | |
| 5040 | if (rn->info) |
| 5041 | { |
| 5042 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5043 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5044 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 5045 | if (ret) |
| 5046 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5047 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 5048 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5049 | return CMD_WARNING; |
| 5050 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5051 | } |
| 5052 | |
| 5053 | /* Make aggregate address structure. */ |
| 5054 | aggregate = bgp_aggregate_new (); |
| 5055 | aggregate->summary_only = summary_only; |
| 5056 | aggregate->as_set = as_set; |
| 5057 | aggregate->safi = safi; |
| 5058 | rn->info = aggregate; |
| 5059 | |
| 5060 | /* Aggregate address insert into BGP routing table. */ |
| 5061 | if (safi & SAFI_UNICAST) |
| 5062 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5063 | if (safi & SAFI_MULTICAST) |
| 5064 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5065 | |
| 5066 | return CMD_SUCCESS; |
| 5067 | } |
| 5068 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5069 | DEFUN (aggregate_address, |
| 5070 | aggregate_address_cmd, |
| 5071 | "aggregate-address A.B.C.D/M", |
| 5072 | "Configure BGP aggregate entries\n" |
| 5073 | "Aggregate prefix\n") |
| 5074 | { |
| 5075 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5076 | } |
| 5077 | |
| 5078 | DEFUN (aggregate_address_mask, |
| 5079 | aggregate_address_mask_cmd, |
| 5080 | "aggregate-address A.B.C.D A.B.C.D", |
| 5081 | "Configure BGP aggregate entries\n" |
| 5082 | "Aggregate address\n" |
| 5083 | "Aggregate mask\n") |
| 5084 | { |
| 5085 | int ret; |
| 5086 | char prefix_str[BUFSIZ]; |
| 5087 | |
| 5088 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5089 | |
| 5090 | if (! ret) |
| 5091 | { |
| 5092 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5093 | return CMD_WARNING; |
| 5094 | } |
| 5095 | |
| 5096 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5097 | 0, 0); |
| 5098 | } |
| 5099 | |
| 5100 | DEFUN (aggregate_address_summary_only, |
| 5101 | aggregate_address_summary_only_cmd, |
| 5102 | "aggregate-address A.B.C.D/M summary-only", |
| 5103 | "Configure BGP aggregate entries\n" |
| 5104 | "Aggregate prefix\n" |
| 5105 | "Filter more specific routes from updates\n") |
| 5106 | { |
| 5107 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5108 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5109 | } |
| 5110 | |
| 5111 | DEFUN (aggregate_address_mask_summary_only, |
| 5112 | aggregate_address_mask_summary_only_cmd, |
| 5113 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5114 | "Configure BGP aggregate entries\n" |
| 5115 | "Aggregate address\n" |
| 5116 | "Aggregate mask\n" |
| 5117 | "Filter more specific routes from updates\n") |
| 5118 | { |
| 5119 | int ret; |
| 5120 | char prefix_str[BUFSIZ]; |
| 5121 | |
| 5122 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5123 | |
| 5124 | if (! ret) |
| 5125 | { |
| 5126 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5127 | return CMD_WARNING; |
| 5128 | } |
| 5129 | |
| 5130 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5131 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5132 | } |
| 5133 | |
| 5134 | DEFUN (aggregate_address_as_set, |
| 5135 | aggregate_address_as_set_cmd, |
| 5136 | "aggregate-address A.B.C.D/M as-set", |
| 5137 | "Configure BGP aggregate entries\n" |
| 5138 | "Aggregate prefix\n" |
| 5139 | "Generate AS set path information\n") |
| 5140 | { |
| 5141 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5142 | 0, AGGREGATE_AS_SET); |
| 5143 | } |
| 5144 | |
| 5145 | DEFUN (aggregate_address_mask_as_set, |
| 5146 | aggregate_address_mask_as_set_cmd, |
| 5147 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5148 | "Configure BGP aggregate entries\n" |
| 5149 | "Aggregate address\n" |
| 5150 | "Aggregate mask\n" |
| 5151 | "Generate AS set path information\n") |
| 5152 | { |
| 5153 | int ret; |
| 5154 | char prefix_str[BUFSIZ]; |
| 5155 | |
| 5156 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5157 | |
| 5158 | if (! ret) |
| 5159 | { |
| 5160 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5161 | return CMD_WARNING; |
| 5162 | } |
| 5163 | |
| 5164 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5165 | 0, AGGREGATE_AS_SET); |
| 5166 | } |
| 5167 | |
| 5168 | |
| 5169 | DEFUN (aggregate_address_as_set_summary, |
| 5170 | aggregate_address_as_set_summary_cmd, |
| 5171 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5172 | "Configure BGP aggregate entries\n" |
| 5173 | "Aggregate prefix\n" |
| 5174 | "Generate AS set path information\n" |
| 5175 | "Filter more specific routes from updates\n") |
| 5176 | { |
| 5177 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5178 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5179 | } |
| 5180 | |
| 5181 | ALIAS (aggregate_address_as_set_summary, |
| 5182 | aggregate_address_summary_as_set_cmd, |
| 5183 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5184 | "Configure BGP aggregate entries\n" |
| 5185 | "Aggregate prefix\n" |
| 5186 | "Filter more specific routes from updates\n" |
| 5187 | "Generate AS set path information\n") |
| 5188 | |
| 5189 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5190 | aggregate_address_mask_as_set_summary_cmd, |
| 5191 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5192 | "Configure BGP aggregate entries\n" |
| 5193 | "Aggregate address\n" |
| 5194 | "Aggregate mask\n" |
| 5195 | "Generate AS set path information\n" |
| 5196 | "Filter more specific routes from updates\n") |
| 5197 | { |
| 5198 | int ret; |
| 5199 | char prefix_str[BUFSIZ]; |
| 5200 | |
| 5201 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5202 | |
| 5203 | if (! ret) |
| 5204 | { |
| 5205 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5206 | return CMD_WARNING; |
| 5207 | } |
| 5208 | |
| 5209 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5210 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5211 | } |
| 5212 | |
| 5213 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5214 | aggregate_address_mask_summary_as_set_cmd, |
| 5215 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5216 | "Configure BGP aggregate entries\n" |
| 5217 | "Aggregate address\n" |
| 5218 | "Aggregate mask\n" |
| 5219 | "Filter more specific routes from updates\n" |
| 5220 | "Generate AS set path information\n") |
| 5221 | |
| 5222 | DEFUN (no_aggregate_address, |
| 5223 | no_aggregate_address_cmd, |
| 5224 | "no aggregate-address A.B.C.D/M", |
| 5225 | NO_STR |
| 5226 | "Configure BGP aggregate entries\n" |
| 5227 | "Aggregate prefix\n") |
| 5228 | { |
| 5229 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5230 | } |
| 5231 | |
| 5232 | ALIAS (no_aggregate_address, |
| 5233 | no_aggregate_address_summary_only_cmd, |
| 5234 | "no aggregate-address A.B.C.D/M summary-only", |
| 5235 | NO_STR |
| 5236 | "Configure BGP aggregate entries\n" |
| 5237 | "Aggregate prefix\n" |
| 5238 | "Filter more specific routes from updates\n") |
| 5239 | |
| 5240 | ALIAS (no_aggregate_address, |
| 5241 | no_aggregate_address_as_set_cmd, |
| 5242 | "no aggregate-address A.B.C.D/M as-set", |
| 5243 | NO_STR |
| 5244 | "Configure BGP aggregate entries\n" |
| 5245 | "Aggregate prefix\n" |
| 5246 | "Generate AS set path information\n") |
| 5247 | |
| 5248 | ALIAS (no_aggregate_address, |
| 5249 | no_aggregate_address_as_set_summary_cmd, |
| 5250 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5251 | NO_STR |
| 5252 | "Configure BGP aggregate entries\n" |
| 5253 | "Aggregate prefix\n" |
| 5254 | "Generate AS set path information\n" |
| 5255 | "Filter more specific routes from updates\n") |
| 5256 | |
| 5257 | ALIAS (no_aggregate_address, |
| 5258 | no_aggregate_address_summary_as_set_cmd, |
| 5259 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5260 | NO_STR |
| 5261 | "Configure BGP aggregate entries\n" |
| 5262 | "Aggregate prefix\n" |
| 5263 | "Filter more specific routes from updates\n" |
| 5264 | "Generate AS set path information\n") |
| 5265 | |
| 5266 | DEFUN (no_aggregate_address_mask, |
| 5267 | no_aggregate_address_mask_cmd, |
| 5268 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5269 | NO_STR |
| 5270 | "Configure BGP aggregate entries\n" |
| 5271 | "Aggregate address\n" |
| 5272 | "Aggregate mask\n") |
| 5273 | { |
| 5274 | int ret; |
| 5275 | char prefix_str[BUFSIZ]; |
| 5276 | |
| 5277 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5278 | |
| 5279 | if (! ret) |
| 5280 | { |
| 5281 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5282 | return CMD_WARNING; |
| 5283 | } |
| 5284 | |
| 5285 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5286 | } |
| 5287 | |
| 5288 | ALIAS (no_aggregate_address_mask, |
| 5289 | no_aggregate_address_mask_summary_only_cmd, |
| 5290 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5291 | NO_STR |
| 5292 | "Configure BGP aggregate entries\n" |
| 5293 | "Aggregate address\n" |
| 5294 | "Aggregate mask\n" |
| 5295 | "Filter more specific routes from updates\n") |
| 5296 | |
| 5297 | ALIAS (no_aggregate_address_mask, |
| 5298 | no_aggregate_address_mask_as_set_cmd, |
| 5299 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5300 | NO_STR |
| 5301 | "Configure BGP aggregate entries\n" |
| 5302 | "Aggregate address\n" |
| 5303 | "Aggregate mask\n" |
| 5304 | "Generate AS set path information\n") |
| 5305 | |
| 5306 | ALIAS (no_aggregate_address_mask, |
| 5307 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5308 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5309 | NO_STR |
| 5310 | "Configure BGP aggregate entries\n" |
| 5311 | "Aggregate address\n" |
| 5312 | "Aggregate mask\n" |
| 5313 | "Generate AS set path information\n" |
| 5314 | "Filter more specific routes from updates\n") |
| 5315 | |
| 5316 | ALIAS (no_aggregate_address_mask, |
| 5317 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5318 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5319 | NO_STR |
| 5320 | "Configure BGP aggregate entries\n" |
| 5321 | "Aggregate address\n" |
| 5322 | "Aggregate mask\n" |
| 5323 | "Filter more specific routes from updates\n" |
| 5324 | "Generate AS set path information\n") |
| 5325 | |
| 5326 | #ifdef HAVE_IPV6 |
| 5327 | DEFUN (ipv6_aggregate_address, |
| 5328 | ipv6_aggregate_address_cmd, |
| 5329 | "aggregate-address X:X::X:X/M", |
| 5330 | "Configure BGP aggregate entries\n" |
| 5331 | "Aggregate prefix\n") |
| 5332 | { |
| 5333 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5334 | } |
| 5335 | |
| 5336 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5337 | ipv6_aggregate_address_summary_only_cmd, |
| 5338 | "aggregate-address X:X::X:X/M summary-only", |
| 5339 | "Configure BGP aggregate entries\n" |
| 5340 | "Aggregate prefix\n" |
| 5341 | "Filter more specific routes from updates\n") |
| 5342 | { |
| 5343 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5344 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5345 | } |
| 5346 | |
| 5347 | DEFUN (no_ipv6_aggregate_address, |
| 5348 | no_ipv6_aggregate_address_cmd, |
| 5349 | "no aggregate-address X:X::X:X/M", |
| 5350 | NO_STR |
| 5351 | "Configure BGP aggregate entries\n" |
| 5352 | "Aggregate prefix\n") |
| 5353 | { |
| 5354 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5355 | } |
| 5356 | |
| 5357 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5358 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5359 | "no aggregate-address X:X::X:X/M summary-only", |
| 5360 | NO_STR |
| 5361 | "Configure BGP aggregate entries\n" |
| 5362 | "Aggregate prefix\n" |
| 5363 | "Filter more specific routes from updates\n") |
| 5364 | { |
| 5365 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5366 | } |
| 5367 | |
| 5368 | ALIAS (ipv6_aggregate_address, |
| 5369 | old_ipv6_aggregate_address_cmd, |
| 5370 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5371 | IPV6_STR |
| 5372 | BGP_STR |
| 5373 | "Configure BGP aggregate entries\n" |
| 5374 | "Aggregate prefix\n") |
| 5375 | |
| 5376 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5377 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5378 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5379 | IPV6_STR |
| 5380 | BGP_STR |
| 5381 | "Configure BGP aggregate entries\n" |
| 5382 | "Aggregate prefix\n" |
| 5383 | "Filter more specific routes from updates\n") |
| 5384 | |
| 5385 | ALIAS (no_ipv6_aggregate_address, |
| 5386 | old_no_ipv6_aggregate_address_cmd, |
| 5387 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5388 | NO_STR |
| 5389 | IPV6_STR |
| 5390 | BGP_STR |
| 5391 | "Configure BGP aggregate entries\n" |
| 5392 | "Aggregate prefix\n") |
| 5393 | |
| 5394 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5395 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5396 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5397 | NO_STR |
| 5398 | IPV6_STR |
| 5399 | BGP_STR |
| 5400 | "Configure BGP aggregate entries\n" |
| 5401 | "Aggregate prefix\n" |
| 5402 | "Filter more specific routes from updates\n") |
| 5403 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5404 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5405 | /* Redistribute route treatment. */ |
| 5406 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5407 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5408 | const struct in6_addr *nexthop6, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5409 | u_int32_t metric, u_char type) |
| 5410 | { |
| 5411 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5412 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5413 | struct bgp_info *new; |
| 5414 | struct bgp_info *bi; |
| 5415 | struct bgp_info info; |
| 5416 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5417 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5418 | struct attr *new_attr; |
| 5419 | afi_t afi; |
| 5420 | int ret; |
| 5421 | |
| 5422 | /* Make default attribute. */ |
| 5423 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5424 | if (nexthop) |
| 5425 | attr.nexthop = *nexthop; |
| 5426 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5427 | #ifdef HAVE_IPV6 |
| 5428 | if (nexthop6) |
| 5429 | { |
| 5430 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5431 | extra->mp_nexthop_global = *nexthop6; |
| 5432 | extra->mp_nexthop_len = 16; |
| 5433 | } |
| 5434 | #endif |
| 5435 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5436 | attr.med = metric; |
| 5437 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5438 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5439 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5440 | { |
| 5441 | afi = family2afi (p->family); |
| 5442 | |
| 5443 | if (bgp->redist[afi][type]) |
| 5444 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5445 | struct attr attr_new; |
| 5446 | struct attr_extra extra_new; |
| 5447 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5448 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5449 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5450 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5451 | |
| 5452 | if (bgp->redist_metric_flag[afi][type]) |
| 5453 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5454 | |
| 5455 | /* Apply route-map. */ |
| 5456 | if (bgp->rmap[afi][type].map) |
| 5457 | { |
| 5458 | info.peer = bgp->peer_self; |
| 5459 | info.attr = &attr_new; |
| 5460 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5461 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5462 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5463 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5464 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5465 | |
| 5466 | bgp->peer_self->rmap_type = 0; |
| 5467 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5468 | if (ret == RMAP_DENYMATCH) |
| 5469 | { |
| 5470 | /* Free uninterned attribute. */ |
| 5471 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5472 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5473 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5474 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5475 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5476 | bgp_redistribute_delete (p, type); |
| 5477 | return; |
| 5478 | } |
| 5479 | } |
| 5480 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5481 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5482 | afi, SAFI_UNICAST, p, NULL); |
| 5483 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5484 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5485 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5486 | for (bi = bn->info; bi; bi = bi->next) |
| 5487 | if (bi->peer == bgp->peer_self |
| 5488 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5489 | break; |
| 5490 | |
| 5491 | if (bi) |
| 5492 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5493 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5494 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5495 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5496 | bgp_attr_unintern (&new_attr); |
| 5497 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5498 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5499 | bgp_unlock_node (bn); |
| 5500 | return; |
| 5501 | } |
| 5502 | else |
| 5503 | { |
| 5504 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5505 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5506 | |
| 5507 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5508 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5509 | bgp_info_restore(bn, bi); |
| 5510 | else |
| 5511 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5512 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5513 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5514 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5515 | |
| 5516 | /* Process change. */ |
| 5517 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5518 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5519 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5520 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5521 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5522 | return; |
| 5523 | } |
| 5524 | } |
| 5525 | |
| 5526 | new = bgp_info_new (); |
| 5527 | new->type = type; |
| 5528 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 5529 | new->peer = bgp->peer_self; |
| 5530 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5531 | new->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5532 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5533 | |
| 5534 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5535 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5536 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5537 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5538 | } |
| 5539 | } |
| 5540 | |
| 5541 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5542 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5543 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5544 | } |
| 5545 | |
| 5546 | void |
| 5547 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5548 | { |
| 5549 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5550 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5551 | afi_t afi; |
| 5552 | struct bgp_node *rn; |
| 5553 | struct bgp_info *ri; |
| 5554 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5555 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5556 | { |
| 5557 | afi = family2afi (p->family); |
| 5558 | |
| 5559 | if (bgp->redist[afi][type]) |
| 5560 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5561 | 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] | 5562 | |
| 5563 | for (ri = rn->info; ri; ri = ri->next) |
| 5564 | if (ri->peer == bgp->peer_self |
| 5565 | && ri->type == type) |
| 5566 | break; |
| 5567 | |
| 5568 | if (ri) |
| 5569 | { |
| 5570 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5571 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5572 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5573 | } |
| 5574 | bgp_unlock_node (rn); |
| 5575 | } |
| 5576 | } |
| 5577 | } |
| 5578 | |
| 5579 | /* Withdraw specified route type's route. */ |
| 5580 | void |
| 5581 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5582 | { |
| 5583 | struct bgp_node *rn; |
| 5584 | struct bgp_info *ri; |
| 5585 | struct bgp_table *table; |
| 5586 | |
| 5587 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5588 | |
| 5589 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5590 | { |
| 5591 | for (ri = rn->info; ri; ri = ri->next) |
| 5592 | if (ri->peer == bgp->peer_self |
| 5593 | && ri->type == type) |
| 5594 | break; |
| 5595 | |
| 5596 | if (ri) |
| 5597 | { |
| 5598 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5599 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5600 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5601 | } |
| 5602 | } |
| 5603 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5604 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5605 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5606 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5607 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5608 | { |
| 5609 | int len; |
| 5610 | u_int32_t destination; |
| 5611 | char buf[BUFSIZ]; |
| 5612 | |
| 5613 | if (p->family == AF_INET) |
| 5614 | { |
| 5615 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5616 | destination = ntohl (p->u.prefix4.s_addr); |
| 5617 | |
| 5618 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5619 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5620 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5621 | || p->u.prefix4.s_addr == 0) |
| 5622 | { |
| 5623 | /* When mask is natural, mask is not displayed. */ |
| 5624 | } |
| 5625 | else |
| 5626 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5627 | } |
| 5628 | else |
| 5629 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5630 | p->prefixlen); |
| 5631 | |
| 5632 | len = 17 - len; |
| 5633 | if (len < 1) |
| 5634 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5635 | else |
| 5636 | vty_out (vty, "%*s", len, " "); |
| 5637 | } |
| 5638 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5639 | enum bgp_display_type |
| 5640 | { |
| 5641 | normal_list, |
| 5642 | }; |
| 5643 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5644 | /* Print the short form route status for a bgp_info */ |
| 5645 | static void |
| 5646 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5647 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5648 | /* Route status display. */ |
| 5649 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5650 | vty_out (vty, "R"); |
| 5651 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5652 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5653 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5654 | vty_out (vty, "s"); |
| 5655 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5656 | vty_out (vty, "*"); |
| 5657 | else |
| 5658 | vty_out (vty, " "); |
| 5659 | |
| 5660 | /* Selected */ |
| 5661 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5662 | vty_out (vty, "h"); |
| 5663 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5664 | vty_out (vty, "d"); |
| 5665 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5666 | vty_out (vty, ">"); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 5667 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
| 5668 | vty_out (vty, "="); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5669 | else |
| 5670 | vty_out (vty, " "); |
| 5671 | |
| 5672 | /* Internal route. */ |
| 5673 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5674 | vty_out (vty, "i"); |
| 5675 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5676 | vty_out (vty, " "); |
| 5677 | } |
| 5678 | |
| 5679 | /* called from terminal list command */ |
| 5680 | void |
| 5681 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5682 | struct bgp_info *binfo, int display, safi_t safi) |
| 5683 | { |
| 5684 | struct attr *attr; |
| 5685 | |
| 5686 | /* short status lead text */ |
| 5687 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5688 | |
| 5689 | /* print prefix and mask */ |
| 5690 | if (! display) |
| 5691 | route_vty_out_route (p, vty); |
| 5692 | else |
| 5693 | vty_out (vty, "%*s", 17, " "); |
| 5694 | |
| 5695 | /* Print attribute */ |
| 5696 | attr = binfo->attr; |
| 5697 | if (attr) |
| 5698 | { |
| 5699 | if (p->family == AF_INET) |
| 5700 | { |
| 5701 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5702 | vty_out (vty, "%-16s", |
| 5703 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5704 | else |
| 5705 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5706 | } |
| 5707 | #ifdef HAVE_IPV6 |
| 5708 | else if (p->family == AF_INET6) |
| 5709 | { |
| 5710 | int len; |
| 5711 | char buf[BUFSIZ]; |
| 5712 | |
| 5713 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5714 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5715 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5716 | len = 16 - len; |
| 5717 | if (len < 1) |
| 5718 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5719 | else |
| 5720 | vty_out (vty, "%*s", len, " "); |
| 5721 | } |
| 5722 | #endif /* HAVE_IPV6 */ |
| 5723 | |
| 5724 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5725 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5726 | else |
| 5727 | vty_out (vty, " "); |
| 5728 | |
| 5729 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5730 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5731 | else |
| 5732 | vty_out (vty, " "); |
| 5733 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5734 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5735 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5736 | /* Print aspath */ |
| 5737 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5738 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5739 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5740 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5741 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5742 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5743 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5744 | } |
| 5745 | |
| 5746 | /* called from terminal list command */ |
| 5747 | void |
| 5748 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5749 | struct attr *attr, safi_t safi) |
| 5750 | { |
| 5751 | /* Route status display. */ |
| 5752 | vty_out (vty, "*"); |
| 5753 | vty_out (vty, ">"); |
| 5754 | vty_out (vty, " "); |
| 5755 | |
| 5756 | /* print prefix and mask */ |
| 5757 | route_vty_out_route (p, vty); |
| 5758 | |
| 5759 | /* Print attribute */ |
| 5760 | if (attr) |
| 5761 | { |
| 5762 | if (p->family == AF_INET) |
| 5763 | { |
| 5764 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5765 | vty_out (vty, "%-16s", |
| 5766 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5767 | else |
| 5768 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5769 | } |
| 5770 | #ifdef HAVE_IPV6 |
| 5771 | else if (p->family == AF_INET6) |
| 5772 | { |
| 5773 | int len; |
| 5774 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5775 | |
| 5776 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5777 | |
| 5778 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5779 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5780 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5781 | len = 16 - len; |
| 5782 | if (len < 1) |
| 5783 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5784 | else |
| 5785 | vty_out (vty, "%*s", len, " "); |
| 5786 | } |
| 5787 | #endif /* HAVE_IPV6 */ |
| 5788 | |
| 5789 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5790 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5791 | else |
| 5792 | vty_out (vty, " "); |
| 5793 | |
| 5794 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5795 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5796 | else |
| 5797 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5798 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5799 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5800 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5801 | /* Print aspath */ |
| 5802 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5803 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5804 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5805 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5806 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5807 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5808 | |
| 5809 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5810 | } |
| 5811 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5812 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5813 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 5814 | struct bgp_info *binfo, int display, safi_t safi) |
| 5815 | { |
| 5816 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5817 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5818 | |
| 5819 | if (!binfo->extra) |
| 5820 | return; |
| 5821 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5822 | /* short status lead text */ |
| 5823 | route_vty_short_status_out (vty, binfo); |
| 5824 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5825 | /* print prefix and mask */ |
| 5826 | if (! display) |
| 5827 | route_vty_out_route (p, vty); |
| 5828 | else |
| 5829 | vty_out (vty, "%*s", 17, " "); |
| 5830 | |
| 5831 | /* Print attribute */ |
| 5832 | attr = binfo->attr; |
| 5833 | if (attr) |
| 5834 | { |
| 5835 | if (p->family == AF_INET) |
| 5836 | { |
| 5837 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5838 | vty_out (vty, "%-16s", |
| 5839 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5840 | else |
| 5841 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5842 | } |
| 5843 | #ifdef HAVE_IPV6 |
| 5844 | else if (p->family == AF_INET6) |
| 5845 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5846 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5847 | char buf[BUFSIZ]; |
| 5848 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5849 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5850 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5851 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5852 | buf, BUFSIZ)); |
| 5853 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5854 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5855 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5856 | buf, BUFSIZ), |
| 5857 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 5858 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5859 | |
| 5860 | } |
| 5861 | #endif /* HAVE_IPV6 */ |
| 5862 | } |
| 5863 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5864 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5865 | |
| 5866 | vty_out (vty, "notag/%d", label); |
| 5867 | |
| 5868 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5869 | } |
| 5870 | |
| 5871 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5872 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5873 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5874 | struct bgp_info *binfo, int display, safi_t safi) |
| 5875 | { |
| 5876 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5877 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5878 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5879 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5880 | /* short status lead text */ |
| 5881 | route_vty_short_status_out (vty, binfo); |
| 5882 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5883 | /* print prefix and mask */ |
| 5884 | if (! display) |
| 5885 | route_vty_out_route (p, vty); |
| 5886 | else |
| 5887 | vty_out (vty, "%*s", 17, " "); |
| 5888 | |
| 5889 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5890 | len = 17 - len; |
| 5891 | if (len < 1) |
| 5892 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5893 | else |
| 5894 | vty_out (vty, "%*s", len, " "); |
| 5895 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5896 | 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] | 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 | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5912 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5913 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5914 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5915 | struct bgp_info *binfo, int display, safi_t safi) |
| 5916 | { |
| 5917 | struct attr *attr; |
| 5918 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5919 | char timebuf[BGP_UPTIME_LEN]; |
| 5920 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5921 | |
| 5922 | if (!binfo->extra) |
| 5923 | return; |
| 5924 | |
| 5925 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5926 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5927 | /* short status lead text */ |
| 5928 | route_vty_short_status_out (vty, binfo); |
| 5929 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5930 | /* print prefix and mask */ |
| 5931 | if (! display) |
| 5932 | route_vty_out_route (p, vty); |
| 5933 | else |
| 5934 | vty_out (vty, "%*s", 17, " "); |
| 5935 | |
| 5936 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5937 | len = 16 - len; |
| 5938 | if (len < 1) |
| 5939 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5940 | else |
| 5941 | vty_out (vty, "%*s", len, " "); |
| 5942 | |
| 5943 | len = vty_out (vty, "%d", bdi->flap); |
| 5944 | len = 5 - len; |
| 5945 | if (len < 1) |
| 5946 | vty_out (vty, " "); |
| 5947 | else |
| 5948 | vty_out (vty, "%*s ", len, " "); |
| 5949 | |
| 5950 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5951 | timebuf, BGP_UPTIME_LEN)); |
| 5952 | |
| 5953 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5954 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5955 | 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] | 5956 | else |
| 5957 | vty_out (vty, "%*s ", 8, " "); |
| 5958 | |
| 5959 | /* Print attribute */ |
| 5960 | attr = binfo->attr; |
| 5961 | if (attr) |
| 5962 | { |
| 5963 | /* Print aspath */ |
| 5964 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5965 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5966 | |
| 5967 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5968 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5969 | } |
| 5970 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5971 | } |
| 5972 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5973 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5974 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5975 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5976 | { |
| 5977 | char buf[INET6_ADDRSTRLEN]; |
| 5978 | char buf1[BUFSIZ]; |
| 5979 | struct attr *attr; |
| 5980 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 5981 | #ifdef HAVE_CLOCK_MONOTONIC |
| 5982 | time_t tbuf; |
| 5983 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5984 | |
| 5985 | attr = binfo->attr; |
| 5986 | |
| 5987 | if (attr) |
| 5988 | { |
| 5989 | /* Line1 display AS-path, Aggregator */ |
| 5990 | if (attr->aspath) |
| 5991 | { |
| 5992 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 5993 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5994 | vty_out (vty, "Local"); |
| 5995 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5996 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5997 | } |
| 5998 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5999 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 6000 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6001 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 6002 | vty_out (vty, ", (stale)"); |
| 6003 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 6004 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6005 | attr->extra->aggregator_as, |
| 6006 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6007 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 6008 | vty_out (vty, ", (Received from a RR-client)"); |
| 6009 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 6010 | vty_out (vty, ", (Received from a RS-client)"); |
| 6011 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6012 | vty_out (vty, ", (history entry)"); |
| 6013 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 6014 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6015 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6016 | |
| 6017 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 6018 | if (p->family == AF_INET) |
| 6019 | { |
| 6020 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6021 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6022 | inet_ntoa (attr->nexthop)); |
| 6023 | } |
| 6024 | #ifdef HAVE_IPV6 |
| 6025 | else |
| 6026 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6027 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6028 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6029 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6030 | buf, INET6_ADDRSTRLEN)); |
| 6031 | } |
| 6032 | #endif /* HAVE_IPV6 */ |
| 6033 | |
| 6034 | if (binfo->peer == bgp->peer_self) |
| 6035 | { |
| 6036 | vty_out (vty, " from %s ", |
| 6037 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 6038 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 6039 | } |
| 6040 | else |
| 6041 | { |
| 6042 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6043 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6044 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 6045 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 6046 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6047 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6048 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6049 | else |
| 6050 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 6051 | } |
| 6052 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6053 | |
| 6054 | #ifdef HAVE_IPV6 |
| 6055 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6056 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6057 | { |
| 6058 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6059 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6060 | buf, INET6_ADDRSTRLEN), |
| 6061 | VTY_NEWLINE); |
| 6062 | } |
| 6063 | #endif /* HAVE_IPV6 */ |
| 6064 | |
| 6065 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 6066 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 6067 | |
| 6068 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6069 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6070 | |
| 6071 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6072 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6073 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6074 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6075 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6076 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6077 | vty_out (vty, ", weight %u", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6078 | |
| 6079 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6080 | vty_out (vty, ", valid"); |
| 6081 | |
| 6082 | if (binfo->peer != bgp->peer_self) |
| 6083 | { |
| 6084 | if (binfo->peer->as == binfo->peer->local_as) |
| 6085 | vty_out (vty, ", internal"); |
| 6086 | else |
| 6087 | vty_out (vty, ", %s", |
| 6088 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6089 | } |
| 6090 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6091 | vty_out (vty, ", aggregated, local"); |
| 6092 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6093 | vty_out (vty, ", sourced"); |
| 6094 | else |
| 6095 | vty_out (vty, ", sourced, local"); |
| 6096 | |
| 6097 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6098 | vty_out (vty, ", atomic-aggregate"); |
| 6099 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6100 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6101 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6102 | bgp_info_mpath_count (binfo))) |
| 6103 | vty_out (vty, ", multipath"); |
| 6104 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6105 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6106 | vty_out (vty, ", best"); |
| 6107 | |
| 6108 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6109 | |
| 6110 | /* Line 4 display Community */ |
| 6111 | if (attr->community) |
| 6112 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6113 | VTY_NEWLINE); |
| 6114 | |
| 6115 | /* Line 5 display Extended-community */ |
| 6116 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6117 | vty_out (vty, " Extended Community: %s%s", |
| 6118 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6119 | |
| 6120 | /* Line 6 display Originator, Cluster-id */ |
| 6121 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6122 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6123 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6124 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6125 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6126 | vty_out (vty, " Originator: %s", |
| 6127 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6128 | |
| 6129 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6130 | { |
| 6131 | int i; |
| 6132 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6133 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6134 | vty_out (vty, "%s ", |
| 6135 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6136 | } |
| 6137 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6138 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6139 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6140 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6141 | bgp_damp_info_vty (vty, binfo); |
| 6142 | |
| 6143 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6144 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6145 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6146 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6147 | #else |
| 6148 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6149 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6150 | } |
| 6151 | vty_out (vty, "%s", VTY_NEWLINE); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 6152 | } |
| 6153 | |
| 6154 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\ |
| 6155 | "h history, * valid, > best, = multipath,%s"\ |
| 6156 | " i internal, r RIB-failure, S Stale, R Removed%s" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6157 | #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] | 6158 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6159 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6160 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6161 | |
| 6162 | enum bgp_show_type |
| 6163 | { |
| 6164 | bgp_show_type_normal, |
| 6165 | bgp_show_type_regexp, |
| 6166 | bgp_show_type_prefix_list, |
| 6167 | bgp_show_type_filter_list, |
| 6168 | bgp_show_type_route_map, |
| 6169 | bgp_show_type_neighbor, |
| 6170 | bgp_show_type_cidr_only, |
| 6171 | bgp_show_type_prefix_longer, |
| 6172 | bgp_show_type_community_all, |
| 6173 | bgp_show_type_community, |
| 6174 | bgp_show_type_community_exact, |
| 6175 | bgp_show_type_community_list, |
| 6176 | bgp_show_type_community_list_exact, |
| 6177 | bgp_show_type_flap_statistics, |
| 6178 | bgp_show_type_flap_address, |
| 6179 | bgp_show_type_flap_prefix, |
| 6180 | bgp_show_type_flap_cidr_only, |
| 6181 | bgp_show_type_flap_regexp, |
| 6182 | bgp_show_type_flap_filter_list, |
| 6183 | bgp_show_type_flap_prefix_list, |
| 6184 | bgp_show_type_flap_prefix_longer, |
| 6185 | bgp_show_type_flap_route_map, |
| 6186 | bgp_show_type_flap_neighbor, |
| 6187 | bgp_show_type_dampend_paths, |
| 6188 | bgp_show_type_damp_neighbor |
| 6189 | }; |
| 6190 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6191 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6192 | 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] | 6193 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6194 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6195 | struct bgp_info *ri; |
| 6196 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6197 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6198 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6199 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6200 | |
| 6201 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6202 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6203 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6204 | /* Start processing of routes. */ |
| 6205 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6206 | if (rn->info != NULL) |
| 6207 | { |
| 6208 | display = 0; |
| 6209 | |
| 6210 | for (ri = rn->info; ri; ri = ri->next) |
| 6211 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6212 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6213 | || type == bgp_show_type_flap_address |
| 6214 | || type == bgp_show_type_flap_prefix |
| 6215 | || type == bgp_show_type_flap_cidr_only |
| 6216 | || type == bgp_show_type_flap_regexp |
| 6217 | || type == bgp_show_type_flap_filter_list |
| 6218 | || type == bgp_show_type_flap_prefix_list |
| 6219 | || type == bgp_show_type_flap_prefix_longer |
| 6220 | || type == bgp_show_type_flap_route_map |
| 6221 | || type == bgp_show_type_flap_neighbor |
| 6222 | || type == bgp_show_type_dampend_paths |
| 6223 | || type == bgp_show_type_damp_neighbor) |
| 6224 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6225 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6226 | continue; |
| 6227 | } |
| 6228 | if (type == bgp_show_type_regexp |
| 6229 | || type == bgp_show_type_flap_regexp) |
| 6230 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6231 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6232 | |
| 6233 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6234 | continue; |
| 6235 | } |
| 6236 | if (type == bgp_show_type_prefix_list |
| 6237 | || type == bgp_show_type_flap_prefix_list) |
| 6238 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6239 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6240 | |
| 6241 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6242 | continue; |
| 6243 | } |
| 6244 | if (type == bgp_show_type_filter_list |
| 6245 | || type == bgp_show_type_flap_filter_list) |
| 6246 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6247 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6248 | |
| 6249 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6250 | continue; |
| 6251 | } |
| 6252 | if (type == bgp_show_type_route_map |
| 6253 | || type == bgp_show_type_flap_route_map) |
| 6254 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6255 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6256 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6257 | struct attr dummy_attr; |
| 6258 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6259 | int ret; |
| 6260 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6261 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6262 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6263 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6264 | binfo.peer = ri->peer; |
| 6265 | binfo.attr = &dummy_attr; |
| 6266 | |
| 6267 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6268 | if (ret == RMAP_DENYMATCH) |
| 6269 | continue; |
| 6270 | } |
| 6271 | if (type == bgp_show_type_neighbor |
| 6272 | || type == bgp_show_type_flap_neighbor |
| 6273 | || type == bgp_show_type_damp_neighbor) |
| 6274 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6275 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6276 | |
| 6277 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6278 | continue; |
| 6279 | } |
| 6280 | if (type == bgp_show_type_cidr_only |
| 6281 | || type == bgp_show_type_flap_cidr_only) |
| 6282 | { |
| 6283 | u_int32_t destination; |
| 6284 | |
| 6285 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6286 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6287 | continue; |
| 6288 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6289 | continue; |
| 6290 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6291 | continue; |
| 6292 | } |
| 6293 | if (type == bgp_show_type_prefix_longer |
| 6294 | || type == bgp_show_type_flap_prefix_longer) |
| 6295 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6296 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6297 | |
| 6298 | if (! prefix_match (p, &rn->p)) |
| 6299 | continue; |
| 6300 | } |
| 6301 | if (type == bgp_show_type_community_all) |
| 6302 | { |
| 6303 | if (! ri->attr->community) |
| 6304 | continue; |
| 6305 | } |
| 6306 | if (type == bgp_show_type_community) |
| 6307 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6308 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6309 | |
| 6310 | if (! ri->attr->community || |
| 6311 | ! community_match (ri->attr->community, com)) |
| 6312 | continue; |
| 6313 | } |
| 6314 | if (type == bgp_show_type_community_exact) |
| 6315 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6316 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6317 | |
| 6318 | if (! ri->attr->community || |
| 6319 | ! community_cmp (ri->attr->community, com)) |
| 6320 | continue; |
| 6321 | } |
| 6322 | if (type == bgp_show_type_community_list) |
| 6323 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6324 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6325 | |
| 6326 | if (! community_list_match (ri->attr->community, list)) |
| 6327 | continue; |
| 6328 | } |
| 6329 | if (type == bgp_show_type_community_list_exact) |
| 6330 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6331 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6332 | |
| 6333 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6334 | continue; |
| 6335 | } |
| 6336 | if (type == bgp_show_type_flap_address |
| 6337 | || type == bgp_show_type_flap_prefix) |
| 6338 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6339 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6340 | |
| 6341 | if (! prefix_match (&rn->p, p)) |
| 6342 | continue; |
| 6343 | |
| 6344 | if (type == bgp_show_type_flap_prefix) |
| 6345 | if (p->prefixlen != rn->p.prefixlen) |
| 6346 | continue; |
| 6347 | } |
| 6348 | if (type == bgp_show_type_dampend_paths |
| 6349 | || type == bgp_show_type_damp_neighbor) |
| 6350 | { |
| 6351 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6352 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6353 | continue; |
| 6354 | } |
| 6355 | |
| 6356 | if (header) |
| 6357 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6358 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6359 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6360 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6361 | if (type == bgp_show_type_dampend_paths |
| 6362 | || type == bgp_show_type_damp_neighbor) |
| 6363 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6364 | else if (type == bgp_show_type_flap_statistics |
| 6365 | || type == bgp_show_type_flap_address |
| 6366 | || type == bgp_show_type_flap_prefix |
| 6367 | || type == bgp_show_type_flap_cidr_only |
| 6368 | || type == bgp_show_type_flap_regexp |
| 6369 | || type == bgp_show_type_flap_filter_list |
| 6370 | || type == bgp_show_type_flap_prefix_list |
| 6371 | || type == bgp_show_type_flap_prefix_longer |
| 6372 | || type == bgp_show_type_flap_route_map |
| 6373 | || type == bgp_show_type_flap_neighbor) |
| 6374 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6375 | else |
| 6376 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6377 | header = 0; |
| 6378 | } |
| 6379 | |
| 6380 | if (type == bgp_show_type_dampend_paths |
| 6381 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6382 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6383 | else if (type == bgp_show_type_flap_statistics |
| 6384 | || type == bgp_show_type_flap_address |
| 6385 | || type == bgp_show_type_flap_prefix |
| 6386 | || type == bgp_show_type_flap_cidr_only |
| 6387 | || type == bgp_show_type_flap_regexp |
| 6388 | || type == bgp_show_type_flap_filter_list |
| 6389 | || type == bgp_show_type_flap_prefix_list |
| 6390 | || type == bgp_show_type_flap_prefix_longer |
| 6391 | || type == bgp_show_type_flap_route_map |
| 6392 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6393 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6394 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6395 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6396 | display++; |
| 6397 | } |
| 6398 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6399 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6400 | } |
| 6401 | |
| 6402 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6403 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6404 | { |
| 6405 | if (type == bgp_show_type_normal) |
| 6406 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 6407 | } |
| 6408 | else |
| 6409 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6410 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6411 | |
| 6412 | return CMD_SUCCESS; |
| 6413 | } |
| 6414 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6415 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6416 | 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] | 6417 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6418 | { |
| 6419 | struct bgp_table *table; |
| 6420 | |
| 6421 | if (bgp == NULL) { |
| 6422 | bgp = bgp_get_default (); |
| 6423 | } |
| 6424 | |
| 6425 | if (bgp == NULL) |
| 6426 | { |
| 6427 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6428 | return CMD_WARNING; |
| 6429 | } |
| 6430 | |
| 6431 | |
| 6432 | table = bgp->rib[afi][safi]; |
| 6433 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6434 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6435 | } |
| 6436 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6437 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6438 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6439 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6440 | struct bgp_node *rn, |
| 6441 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6442 | { |
| 6443 | struct bgp_info *ri; |
| 6444 | struct prefix *p; |
| 6445 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6446 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6447 | char buf1[INET6_ADDRSTRLEN]; |
| 6448 | char buf2[INET6_ADDRSTRLEN]; |
| 6449 | int count = 0; |
| 6450 | int best = 0; |
| 6451 | int suppress = 0; |
| 6452 | int no_export = 0; |
| 6453 | int no_advertise = 0; |
| 6454 | int local_as = 0; |
| 6455 | int first = 0; |
| 6456 | |
| 6457 | p = &rn->p; |
| 6458 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 6459 | (safi == SAFI_MPLS_VPN ? |
| 6460 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6461 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 6462 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6463 | p->prefixlen, VTY_NEWLINE); |
| 6464 | |
| 6465 | for (ri = rn->info; ri; ri = ri->next) |
| 6466 | { |
| 6467 | count++; |
| 6468 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6469 | { |
| 6470 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6471 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6472 | suppress = 1; |
| 6473 | if (ri->attr->community != NULL) |
| 6474 | { |
| 6475 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6476 | no_advertise = 1; |
| 6477 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6478 | no_export = 1; |
| 6479 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6480 | local_as = 1; |
| 6481 | } |
| 6482 | } |
| 6483 | } |
| 6484 | |
| 6485 | vty_out (vty, "Paths: (%d available", count); |
| 6486 | if (best) |
| 6487 | { |
| 6488 | vty_out (vty, ", best #%d", best); |
| 6489 | if (safi == SAFI_UNICAST) |
| 6490 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6491 | } |
| 6492 | else |
| 6493 | vty_out (vty, ", no best path"); |
| 6494 | if (no_advertise) |
| 6495 | vty_out (vty, ", not advertised to any peer"); |
| 6496 | else if (no_export) |
| 6497 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6498 | else if (local_as) |
| 6499 | vty_out (vty, ", not advertised outside local AS"); |
| 6500 | if (suppress) |
| 6501 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6502 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6503 | |
| 6504 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6505 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6506 | { |
| 6507 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6508 | { |
| 6509 | if (! first) |
| 6510 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6511 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6512 | first = 1; |
| 6513 | } |
| 6514 | } |
| 6515 | if (! first) |
| 6516 | vty_out (vty, " Not advertised to any peer"); |
| 6517 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6518 | } |
| 6519 | |
| 6520 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6521 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6522 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6523 | struct bgp_table *rib, const char *ip_str, |
| 6524 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6525 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6526 | { |
| 6527 | int ret; |
| 6528 | int header; |
| 6529 | int display = 0; |
| 6530 | struct prefix match; |
| 6531 | struct bgp_node *rn; |
| 6532 | struct bgp_node *rm; |
| 6533 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6534 | struct bgp_table *table; |
| 6535 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6536 | /* Check IP address argument. */ |
| 6537 | ret = str2prefix (ip_str, &match); |
| 6538 | if (! ret) |
| 6539 | { |
| 6540 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6541 | return CMD_WARNING; |
| 6542 | } |
| 6543 | |
| 6544 | match.family = afi2family (afi); |
| 6545 | |
| 6546 | if (safi == SAFI_MPLS_VPN) |
| 6547 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6548 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6549 | { |
| 6550 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6551 | continue; |
| 6552 | |
| 6553 | if ((table = rn->info) != NULL) |
| 6554 | { |
| 6555 | header = 1; |
| 6556 | |
| 6557 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6558 | { |
| 6559 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6560 | { |
| 6561 | bgp_unlock_node (rm); |
| 6562 | continue; |
| 6563 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6564 | |
| 6565 | for (ri = rm->info; ri; ri = ri->next) |
| 6566 | { |
| 6567 | if (header) |
| 6568 | { |
| 6569 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 6570 | AFI_IP, SAFI_MPLS_VPN); |
| 6571 | |
| 6572 | header = 0; |
| 6573 | } |
| 6574 | display++; |
| 6575 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 6576 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6577 | |
| 6578 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6579 | } |
| 6580 | } |
| 6581 | } |
| 6582 | } |
| 6583 | else |
| 6584 | { |
| 6585 | header = 1; |
| 6586 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6587 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6588 | { |
| 6589 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6590 | { |
| 6591 | for (ri = rn->info; ri; ri = ri->next) |
| 6592 | { |
| 6593 | if (header) |
| 6594 | { |
| 6595 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6596 | header = 0; |
| 6597 | } |
| 6598 | display++; |
| 6599 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6600 | } |
| 6601 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6602 | |
| 6603 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6604 | } |
| 6605 | } |
| 6606 | |
| 6607 | if (! display) |
| 6608 | { |
| 6609 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6610 | return CMD_WARNING; |
| 6611 | } |
| 6612 | |
| 6613 | return CMD_SUCCESS; |
| 6614 | } |
| 6615 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6616 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6617 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6618 | 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] | 6619 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6620 | int prefix_check) |
| 6621 | { |
| 6622 | struct bgp *bgp; |
| 6623 | |
| 6624 | /* BGP structure lookup. */ |
| 6625 | if (view_name) |
| 6626 | { |
| 6627 | bgp = bgp_lookup_by_name (view_name); |
| 6628 | if (bgp == NULL) |
| 6629 | { |
| 6630 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6631 | return CMD_WARNING; |
| 6632 | } |
| 6633 | } |
| 6634 | else |
| 6635 | { |
| 6636 | bgp = bgp_get_default (); |
| 6637 | if (bgp == NULL) |
| 6638 | { |
| 6639 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6640 | return CMD_WARNING; |
| 6641 | } |
| 6642 | } |
| 6643 | |
| 6644 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6645 | afi, safi, prd, prefix_check); |
| 6646 | } |
| 6647 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6648 | /* BGP route print out function. */ |
| 6649 | DEFUN (show_ip_bgp, |
| 6650 | show_ip_bgp_cmd, |
| 6651 | "show ip bgp", |
| 6652 | SHOW_STR |
| 6653 | IP_STR |
| 6654 | BGP_STR) |
| 6655 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6656 | 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] | 6657 | } |
| 6658 | |
| 6659 | DEFUN (show_ip_bgp_ipv4, |
| 6660 | show_ip_bgp_ipv4_cmd, |
| 6661 | "show ip bgp ipv4 (unicast|multicast)", |
| 6662 | SHOW_STR |
| 6663 | IP_STR |
| 6664 | BGP_STR |
| 6665 | "Address family\n" |
| 6666 | "Address Family modifier\n" |
| 6667 | "Address Family modifier\n") |
| 6668 | { |
| 6669 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6670 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6671 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6672 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6673 | 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] | 6674 | } |
| 6675 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6676 | ALIAS (show_ip_bgp_ipv4, |
| 6677 | show_bgp_ipv4_safi_cmd, |
| 6678 | "show bgp ipv4 (unicast|multicast)", |
| 6679 | SHOW_STR |
| 6680 | BGP_STR |
| 6681 | "Address family\n" |
| 6682 | "Address Family modifier\n" |
| 6683 | "Address Family modifier\n") |
| 6684 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6685 | DEFUN (show_ip_bgp_route, |
| 6686 | show_ip_bgp_route_cmd, |
| 6687 | "show ip bgp A.B.C.D", |
| 6688 | SHOW_STR |
| 6689 | IP_STR |
| 6690 | BGP_STR |
| 6691 | "Network in the BGP routing table to display\n") |
| 6692 | { |
| 6693 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6694 | } |
| 6695 | |
| 6696 | DEFUN (show_ip_bgp_ipv4_route, |
| 6697 | show_ip_bgp_ipv4_route_cmd, |
| 6698 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6699 | SHOW_STR |
| 6700 | IP_STR |
| 6701 | BGP_STR |
| 6702 | "Address family\n" |
| 6703 | "Address Family modifier\n" |
| 6704 | "Address Family modifier\n" |
| 6705 | "Network in the BGP routing table to display\n") |
| 6706 | { |
| 6707 | if (strncmp (argv[0], "m", 1) == 0) |
| 6708 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6709 | |
| 6710 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6711 | } |
| 6712 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6713 | ALIAS (show_ip_bgp_ipv4_route, |
| 6714 | show_bgp_ipv4_safi_route_cmd, |
| 6715 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6716 | SHOW_STR |
| 6717 | BGP_STR |
| 6718 | "Address family\n" |
| 6719 | "Address Family modifier\n" |
| 6720 | "Address Family modifier\n" |
| 6721 | "Network in the BGP routing table to display\n") |
| 6722 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6723 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6724 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6725 | "show ip bgp vpnv4 all A.B.C.D", |
| 6726 | SHOW_STR |
| 6727 | IP_STR |
| 6728 | BGP_STR |
| 6729 | "Display VPNv4 NLRI specific information\n" |
| 6730 | "Display information about all VPNv4 NLRIs\n" |
| 6731 | "Network in the BGP routing table to display\n") |
| 6732 | { |
| 6733 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6734 | } |
| 6735 | |
| 6736 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6737 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6738 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6739 | SHOW_STR |
| 6740 | IP_STR |
| 6741 | BGP_STR |
| 6742 | "Display VPNv4 NLRI specific information\n" |
| 6743 | "Display information for a route distinguisher\n" |
| 6744 | "VPN Route Distinguisher\n" |
| 6745 | "Network in the BGP routing table to display\n") |
| 6746 | { |
| 6747 | int ret; |
| 6748 | struct prefix_rd prd; |
| 6749 | |
| 6750 | ret = str2prefix_rd (argv[0], &prd); |
| 6751 | if (! ret) |
| 6752 | { |
| 6753 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6754 | return CMD_WARNING; |
| 6755 | } |
| 6756 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6757 | } |
| 6758 | |
| 6759 | DEFUN (show_ip_bgp_prefix, |
| 6760 | show_ip_bgp_prefix_cmd, |
| 6761 | "show ip bgp A.B.C.D/M", |
| 6762 | SHOW_STR |
| 6763 | IP_STR |
| 6764 | BGP_STR |
| 6765 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6766 | { |
| 6767 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6768 | } |
| 6769 | |
| 6770 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6771 | show_ip_bgp_ipv4_prefix_cmd, |
| 6772 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6773 | SHOW_STR |
| 6774 | IP_STR |
| 6775 | BGP_STR |
| 6776 | "Address family\n" |
| 6777 | "Address Family modifier\n" |
| 6778 | "Address Family modifier\n" |
| 6779 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6780 | { |
| 6781 | if (strncmp (argv[0], "m", 1) == 0) |
| 6782 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6783 | |
| 6784 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6785 | } |
| 6786 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6787 | ALIAS (show_ip_bgp_ipv4_prefix, |
| 6788 | show_bgp_ipv4_safi_prefix_cmd, |
| 6789 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6790 | SHOW_STR |
| 6791 | BGP_STR |
| 6792 | "Address family\n" |
| 6793 | "Address Family modifier\n" |
| 6794 | "Address Family modifier\n" |
| 6795 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6796 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6797 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 6798 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 6799 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 6800 | SHOW_STR |
| 6801 | IP_STR |
| 6802 | BGP_STR |
| 6803 | "Display VPNv4 NLRI specific information\n" |
| 6804 | "Display information about all VPNv4 NLRIs\n" |
| 6805 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6806 | { |
| 6807 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 6808 | } |
| 6809 | |
| 6810 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 6811 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 6812 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 6813 | SHOW_STR |
| 6814 | IP_STR |
| 6815 | BGP_STR |
| 6816 | "Display VPNv4 NLRI specific information\n" |
| 6817 | "Display information for a route distinguisher\n" |
| 6818 | "VPN Route Distinguisher\n" |
| 6819 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6820 | { |
| 6821 | int ret; |
| 6822 | struct prefix_rd prd; |
| 6823 | |
| 6824 | ret = str2prefix_rd (argv[0], &prd); |
| 6825 | if (! ret) |
| 6826 | { |
| 6827 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6828 | return CMD_WARNING; |
| 6829 | } |
| 6830 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 6831 | } |
| 6832 | |
| 6833 | DEFUN (show_ip_bgp_view, |
| 6834 | show_ip_bgp_view_cmd, |
| 6835 | "show ip bgp view WORD", |
| 6836 | SHOW_STR |
| 6837 | IP_STR |
| 6838 | BGP_STR |
| 6839 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6840 | "View name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6841 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6842 | struct bgp *bgp; |
| 6843 | |
| 6844 | /* BGP structure lookup. */ |
| 6845 | bgp = bgp_lookup_by_name (argv[0]); |
| 6846 | if (bgp == NULL) |
| 6847 | { |
| 6848 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6849 | return CMD_WARNING; |
| 6850 | } |
| 6851 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6852 | 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] | 6853 | } |
| 6854 | |
| 6855 | DEFUN (show_ip_bgp_view_route, |
| 6856 | show_ip_bgp_view_route_cmd, |
| 6857 | "show ip bgp view WORD A.B.C.D", |
| 6858 | SHOW_STR |
| 6859 | IP_STR |
| 6860 | BGP_STR |
| 6861 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6862 | "View name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6863 | "Network in the BGP routing table to display\n") |
| 6864 | { |
| 6865 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6866 | } |
| 6867 | |
| 6868 | DEFUN (show_ip_bgp_view_prefix, |
| 6869 | show_ip_bgp_view_prefix_cmd, |
| 6870 | "show ip bgp view WORD A.B.C.D/M", |
| 6871 | SHOW_STR |
| 6872 | IP_STR |
| 6873 | BGP_STR |
| 6874 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6875 | "View name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6876 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6877 | { |
| 6878 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6879 | } |
| 6880 | |
| 6881 | #ifdef HAVE_IPV6 |
| 6882 | DEFUN (show_bgp, |
| 6883 | show_bgp_cmd, |
| 6884 | "show bgp", |
| 6885 | SHOW_STR |
| 6886 | BGP_STR) |
| 6887 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6888 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6889 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6890 | } |
| 6891 | |
| 6892 | ALIAS (show_bgp, |
| 6893 | show_bgp_ipv6_cmd, |
| 6894 | "show bgp ipv6", |
| 6895 | SHOW_STR |
| 6896 | BGP_STR |
| 6897 | "Address family\n") |
| 6898 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6899 | DEFUN (show_bgp_ipv6_safi, |
| 6900 | show_bgp_ipv6_safi_cmd, |
| 6901 | "show bgp ipv6 (unicast|multicast)", |
| 6902 | SHOW_STR |
| 6903 | BGP_STR |
| 6904 | "Address family\n" |
| 6905 | "Address Family modifier\n" |
| 6906 | "Address Family modifier\n") |
| 6907 | { |
| 6908 | if (strncmp (argv[0], "m", 1) == 0) |
| 6909 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6910 | NULL); |
| 6911 | |
| 6912 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6913 | } |
| 6914 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6915 | /* old command */ |
| 6916 | DEFUN (show_ipv6_bgp, |
| 6917 | show_ipv6_bgp_cmd, |
| 6918 | "show ipv6 bgp", |
| 6919 | SHOW_STR |
| 6920 | IP_STR |
| 6921 | BGP_STR) |
| 6922 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6923 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6924 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6925 | } |
| 6926 | |
| 6927 | DEFUN (show_bgp_route, |
| 6928 | show_bgp_route_cmd, |
| 6929 | "show bgp X:X::X:X", |
| 6930 | SHOW_STR |
| 6931 | BGP_STR |
| 6932 | "Network in the BGP routing table to display\n") |
| 6933 | { |
| 6934 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6935 | } |
| 6936 | |
| 6937 | ALIAS (show_bgp_route, |
| 6938 | show_bgp_ipv6_route_cmd, |
| 6939 | "show bgp ipv6 X:X::X:X", |
| 6940 | SHOW_STR |
| 6941 | BGP_STR |
| 6942 | "Address family\n" |
| 6943 | "Network in the BGP routing table to display\n") |
| 6944 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6945 | DEFUN (show_bgp_ipv6_safi_route, |
| 6946 | show_bgp_ipv6_safi_route_cmd, |
| 6947 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
| 6948 | SHOW_STR |
| 6949 | BGP_STR |
| 6950 | "Address family\n" |
| 6951 | "Address Family modifier\n" |
| 6952 | "Address Family modifier\n" |
| 6953 | "Network in the BGP routing table to display\n") |
| 6954 | { |
| 6955 | if (strncmp (argv[0], "m", 1) == 0) |
| 6956 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6957 | |
| 6958 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6959 | } |
| 6960 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6961 | /* old command */ |
| 6962 | DEFUN (show_ipv6_bgp_route, |
| 6963 | show_ipv6_bgp_route_cmd, |
| 6964 | "show ipv6 bgp X:X::X:X", |
| 6965 | SHOW_STR |
| 6966 | IP_STR |
| 6967 | BGP_STR |
| 6968 | "Network in the BGP routing table to display\n") |
| 6969 | { |
| 6970 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6971 | } |
| 6972 | |
| 6973 | DEFUN (show_bgp_prefix, |
| 6974 | show_bgp_prefix_cmd, |
| 6975 | "show bgp X:X::X:X/M", |
| 6976 | SHOW_STR |
| 6977 | BGP_STR |
| 6978 | "IPv6 prefix <network>/<length>\n") |
| 6979 | { |
| 6980 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6981 | } |
| 6982 | |
| 6983 | ALIAS (show_bgp_prefix, |
| 6984 | show_bgp_ipv6_prefix_cmd, |
| 6985 | "show bgp ipv6 X:X::X:X/M", |
| 6986 | SHOW_STR |
| 6987 | BGP_STR |
| 6988 | "Address family\n" |
| 6989 | "IPv6 prefix <network>/<length>\n") |
| 6990 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6991 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 6992 | show_bgp_ipv6_safi_prefix_cmd, |
| 6993 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 6994 | SHOW_STR |
| 6995 | BGP_STR |
| 6996 | "Address family\n" |
| 6997 | "Address Family modifier\n" |
| 6998 | "Address Family modifier\n" |
| 6999 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7000 | { |
| 7001 | if (strncmp (argv[0], "m", 1) == 0) |
| 7002 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7003 | |
| 7004 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7005 | } |
| 7006 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7007 | /* old command */ |
| 7008 | DEFUN (show_ipv6_bgp_prefix, |
| 7009 | show_ipv6_bgp_prefix_cmd, |
| 7010 | "show ipv6 bgp X:X::X:X/M", |
| 7011 | SHOW_STR |
| 7012 | IP_STR |
| 7013 | BGP_STR |
| 7014 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7015 | { |
| 7016 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7017 | } |
| 7018 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7019 | DEFUN (show_bgp_view, |
| 7020 | show_bgp_view_cmd, |
| 7021 | "show bgp view WORD", |
| 7022 | SHOW_STR |
| 7023 | BGP_STR |
| 7024 | "BGP view\n" |
| 7025 | "View name\n") |
| 7026 | { |
| 7027 | struct bgp *bgp; |
| 7028 | |
| 7029 | /* BGP structure lookup. */ |
| 7030 | bgp = bgp_lookup_by_name (argv[0]); |
| 7031 | if (bgp == NULL) |
| 7032 | { |
| 7033 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7034 | return CMD_WARNING; |
| 7035 | } |
| 7036 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7037 | 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] | 7038 | } |
| 7039 | |
| 7040 | ALIAS (show_bgp_view, |
| 7041 | show_bgp_view_ipv6_cmd, |
| 7042 | "show bgp view WORD ipv6", |
| 7043 | SHOW_STR |
| 7044 | BGP_STR |
| 7045 | "BGP view\n" |
| 7046 | "View name\n" |
| 7047 | "Address family\n") |
| 7048 | |
| 7049 | DEFUN (show_bgp_view_route, |
| 7050 | show_bgp_view_route_cmd, |
| 7051 | "show bgp view WORD X:X::X:X", |
| 7052 | SHOW_STR |
| 7053 | BGP_STR |
| 7054 | "BGP view\n" |
| 7055 | "View name\n" |
| 7056 | "Network in the BGP routing table to display\n") |
| 7057 | { |
| 7058 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7059 | } |
| 7060 | |
| 7061 | ALIAS (show_bgp_view_route, |
| 7062 | show_bgp_view_ipv6_route_cmd, |
| 7063 | "show bgp view WORD ipv6 X:X::X:X", |
| 7064 | SHOW_STR |
| 7065 | BGP_STR |
| 7066 | "BGP view\n" |
| 7067 | "View name\n" |
| 7068 | "Address family\n" |
| 7069 | "Network in the BGP routing table to display\n") |
| 7070 | |
| 7071 | DEFUN (show_bgp_view_prefix, |
| 7072 | show_bgp_view_prefix_cmd, |
| 7073 | "show bgp view WORD X:X::X:X/M", |
| 7074 | SHOW_STR |
| 7075 | BGP_STR |
| 7076 | "BGP view\n" |
| 7077 | "View name\n" |
| 7078 | "IPv6 prefix <network>/<length>\n") |
| 7079 | { |
| 7080 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7081 | } |
| 7082 | |
| 7083 | ALIAS (show_bgp_view_prefix, |
| 7084 | show_bgp_view_ipv6_prefix_cmd, |
| 7085 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 7086 | SHOW_STR |
| 7087 | BGP_STR |
| 7088 | "BGP view\n" |
| 7089 | "View name\n" |
| 7090 | "Address family\n" |
| 7091 | "IPv6 prefix <network>/<length>\n") |
| 7092 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7093 | /* old command */ |
| 7094 | DEFUN (show_ipv6_mbgp, |
| 7095 | show_ipv6_mbgp_cmd, |
| 7096 | "show ipv6 mbgp", |
| 7097 | SHOW_STR |
| 7098 | IP_STR |
| 7099 | MBGP_STR) |
| 7100 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7101 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7102 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7103 | } |
| 7104 | |
| 7105 | /* old command */ |
| 7106 | DEFUN (show_ipv6_mbgp_route, |
| 7107 | show_ipv6_mbgp_route_cmd, |
| 7108 | "show ipv6 mbgp X:X::X:X", |
| 7109 | SHOW_STR |
| 7110 | IP_STR |
| 7111 | MBGP_STR |
| 7112 | "Network in the MBGP routing table to display\n") |
| 7113 | { |
| 7114 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7115 | } |
| 7116 | |
| 7117 | /* old command */ |
| 7118 | DEFUN (show_ipv6_mbgp_prefix, |
| 7119 | show_ipv6_mbgp_prefix_cmd, |
| 7120 | "show ipv6 mbgp X:X::X:X/M", |
| 7121 | SHOW_STR |
| 7122 | IP_STR |
| 7123 | MBGP_STR |
| 7124 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7125 | { |
| 7126 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7127 | } |
| 7128 | #endif |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7129 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7130 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7131 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7132 | 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] | 7133 | safi_t safi, enum bgp_show_type type) |
| 7134 | { |
| 7135 | int i; |
| 7136 | struct buffer *b; |
| 7137 | char *regstr; |
| 7138 | int first; |
| 7139 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7140 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7141 | |
| 7142 | first = 0; |
| 7143 | b = buffer_new (1024); |
| 7144 | for (i = 0; i < argc; i++) |
| 7145 | { |
| 7146 | if (first) |
| 7147 | buffer_putc (b, ' '); |
| 7148 | else |
| 7149 | { |
| 7150 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7151 | continue; |
| 7152 | first = 1; |
| 7153 | } |
| 7154 | |
| 7155 | buffer_putstr (b, argv[i]); |
| 7156 | } |
| 7157 | buffer_putc (b, '\0'); |
| 7158 | |
| 7159 | regstr = buffer_getstr (b); |
| 7160 | buffer_free (b); |
| 7161 | |
| 7162 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7163 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7164 | if (! regex) |
| 7165 | { |
| 7166 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 7167 | VTY_NEWLINE); |
| 7168 | return CMD_WARNING; |
| 7169 | } |
| 7170 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7171 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 7172 | bgp_regex_free (regex); |
| 7173 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7174 | } |
| 7175 | |
| 7176 | DEFUN (show_ip_bgp_regexp, |
| 7177 | show_ip_bgp_regexp_cmd, |
| 7178 | "show ip bgp regexp .LINE", |
| 7179 | SHOW_STR |
| 7180 | IP_STR |
| 7181 | BGP_STR |
| 7182 | "Display routes matching the AS path regular expression\n" |
| 7183 | "A regular-expression to match the BGP AS paths\n") |
| 7184 | { |
| 7185 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7186 | bgp_show_type_regexp); |
| 7187 | } |
| 7188 | |
| 7189 | DEFUN (show_ip_bgp_flap_regexp, |
| 7190 | show_ip_bgp_flap_regexp_cmd, |
| 7191 | "show ip bgp flap-statistics regexp .LINE", |
| 7192 | SHOW_STR |
| 7193 | IP_STR |
| 7194 | BGP_STR |
| 7195 | "Display flap statistics of routes\n" |
| 7196 | "Display routes matching the AS path regular expression\n" |
| 7197 | "A regular-expression to match the BGP AS paths\n") |
| 7198 | { |
| 7199 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7200 | bgp_show_type_flap_regexp); |
| 7201 | } |
| 7202 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 7203 | ALIAS (show_ip_bgp_flap_regexp, |
| 7204 | show_ip_bgp_damp_flap_regexp_cmd, |
| 7205 | "show ip bgp dampening flap-statistics regexp .LINE", |
| 7206 | SHOW_STR |
| 7207 | IP_STR |
| 7208 | BGP_STR |
| 7209 | "Display detailed information about dampening\n" |
| 7210 | "Display flap statistics of routes\n" |
| 7211 | "Display routes matching the AS path regular expression\n" |
| 7212 | "A regular-expression to match the BGP AS paths\n") |
| 7213 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7214 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 7215 | show_ip_bgp_ipv4_regexp_cmd, |
| 7216 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 7217 | SHOW_STR |
| 7218 | IP_STR |
| 7219 | BGP_STR |
| 7220 | "Address family\n" |
| 7221 | "Address Family modifier\n" |
| 7222 | "Address Family modifier\n" |
| 7223 | "Display routes matching the AS path regular expression\n" |
| 7224 | "A regular-expression to match the BGP AS paths\n") |
| 7225 | { |
| 7226 | if (strncmp (argv[0], "m", 1) == 0) |
| 7227 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 7228 | bgp_show_type_regexp); |
| 7229 | |
| 7230 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7231 | bgp_show_type_regexp); |
| 7232 | } |
| 7233 | |
| 7234 | #ifdef HAVE_IPV6 |
| 7235 | DEFUN (show_bgp_regexp, |
| 7236 | show_bgp_regexp_cmd, |
| 7237 | "show bgp regexp .LINE", |
| 7238 | SHOW_STR |
| 7239 | BGP_STR |
| 7240 | "Display routes matching the AS path regular expression\n" |
| 7241 | "A regular-expression to match the BGP AS paths\n") |
| 7242 | { |
| 7243 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7244 | bgp_show_type_regexp); |
| 7245 | } |
| 7246 | |
| 7247 | ALIAS (show_bgp_regexp, |
| 7248 | show_bgp_ipv6_regexp_cmd, |
| 7249 | "show bgp ipv6 regexp .LINE", |
| 7250 | SHOW_STR |
| 7251 | BGP_STR |
| 7252 | "Address family\n" |
| 7253 | "Display routes matching the AS path regular expression\n" |
| 7254 | "A regular-expression to match the BGP AS paths\n") |
| 7255 | |
| 7256 | /* old command */ |
| 7257 | DEFUN (show_ipv6_bgp_regexp, |
| 7258 | show_ipv6_bgp_regexp_cmd, |
| 7259 | "show ipv6 bgp regexp .LINE", |
| 7260 | SHOW_STR |
| 7261 | IP_STR |
| 7262 | BGP_STR |
| 7263 | "Display routes matching the AS path regular expression\n" |
| 7264 | "A regular-expression to match the BGP AS paths\n") |
| 7265 | { |
| 7266 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7267 | bgp_show_type_regexp); |
| 7268 | } |
| 7269 | |
| 7270 | /* old command */ |
| 7271 | DEFUN (show_ipv6_mbgp_regexp, |
| 7272 | show_ipv6_mbgp_regexp_cmd, |
| 7273 | "show ipv6 mbgp regexp .LINE", |
| 7274 | SHOW_STR |
| 7275 | IP_STR |
| 7276 | BGP_STR |
| 7277 | "Display routes matching the AS path regular expression\n" |
| 7278 | "A regular-expression to match the MBGP AS paths\n") |
| 7279 | { |
| 7280 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 7281 | bgp_show_type_regexp); |
| 7282 | } |
| 7283 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7284 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7285 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7286 | 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] | 7287 | safi_t safi, enum bgp_show_type type) |
| 7288 | { |
| 7289 | struct prefix_list *plist; |
| 7290 | |
| 7291 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 7292 | if (plist == NULL) |
| 7293 | { |
| 7294 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 7295 | prefix_list_str, VTY_NEWLINE); |
| 7296 | return CMD_WARNING; |
| 7297 | } |
| 7298 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7299 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7300 | } |
| 7301 | |
| 7302 | DEFUN (show_ip_bgp_prefix_list, |
| 7303 | show_ip_bgp_prefix_list_cmd, |
| 7304 | "show ip bgp prefix-list WORD", |
| 7305 | SHOW_STR |
| 7306 | IP_STR |
| 7307 | BGP_STR |
| 7308 | "Display routes conforming to the prefix-list\n" |
| 7309 | "IP prefix-list name\n") |
| 7310 | { |
| 7311 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7312 | bgp_show_type_prefix_list); |
| 7313 | } |
| 7314 | |
| 7315 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 7316 | show_ip_bgp_flap_prefix_list_cmd, |
| 7317 | "show ip bgp flap-statistics prefix-list WORD", |
| 7318 | SHOW_STR |
| 7319 | IP_STR |
| 7320 | BGP_STR |
| 7321 | "Display flap statistics of routes\n" |
| 7322 | "Display routes conforming to the prefix-list\n" |
| 7323 | "IP prefix-list name\n") |
| 7324 | { |
| 7325 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7326 | bgp_show_type_flap_prefix_list); |
| 7327 | } |
| 7328 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 7329 | ALIAS (show_ip_bgp_flap_prefix_list, |
| 7330 | show_ip_bgp_damp_flap_prefix_list_cmd, |
| 7331 | "show ip bgp dampening flap-statistics prefix-list WORD", |
| 7332 | SHOW_STR |
| 7333 | IP_STR |
| 7334 | BGP_STR |
| 7335 | "Display detailed information about dampening\n" |
| 7336 | "Display flap statistics of routes\n" |
| 7337 | "Display routes conforming to the prefix-list\n" |
| 7338 | "IP prefix-list name\n") |
| 7339 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7340 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 7341 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 7342 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 7343 | SHOW_STR |
| 7344 | IP_STR |
| 7345 | BGP_STR |
| 7346 | "Address family\n" |
| 7347 | "Address Family modifier\n" |
| 7348 | "Address Family modifier\n" |
| 7349 | "Display routes conforming to the prefix-list\n" |
| 7350 | "IP prefix-list name\n") |
| 7351 | { |
| 7352 | if (strncmp (argv[0], "m", 1) == 0) |
| 7353 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7354 | bgp_show_type_prefix_list); |
| 7355 | |
| 7356 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7357 | bgp_show_type_prefix_list); |
| 7358 | } |
| 7359 | |
| 7360 | #ifdef HAVE_IPV6 |
| 7361 | DEFUN (show_bgp_prefix_list, |
| 7362 | show_bgp_prefix_list_cmd, |
| 7363 | "show bgp prefix-list WORD", |
| 7364 | SHOW_STR |
| 7365 | BGP_STR |
| 7366 | "Display routes conforming to the prefix-list\n" |
| 7367 | "IPv6 prefix-list name\n") |
| 7368 | { |
| 7369 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7370 | bgp_show_type_prefix_list); |
| 7371 | } |
| 7372 | |
| 7373 | ALIAS (show_bgp_prefix_list, |
| 7374 | show_bgp_ipv6_prefix_list_cmd, |
| 7375 | "show bgp ipv6 prefix-list WORD", |
| 7376 | SHOW_STR |
| 7377 | BGP_STR |
| 7378 | "Address family\n" |
| 7379 | "Display routes conforming to the prefix-list\n" |
| 7380 | "IPv6 prefix-list name\n") |
| 7381 | |
| 7382 | /* old command */ |
| 7383 | DEFUN (show_ipv6_bgp_prefix_list, |
| 7384 | show_ipv6_bgp_prefix_list_cmd, |
| 7385 | "show ipv6 bgp prefix-list WORD", |
| 7386 | SHOW_STR |
| 7387 | IPV6_STR |
| 7388 | BGP_STR |
| 7389 | "Display routes matching the prefix-list\n" |
| 7390 | "IPv6 prefix-list name\n") |
| 7391 | { |
| 7392 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7393 | bgp_show_type_prefix_list); |
| 7394 | } |
| 7395 | |
| 7396 | /* old command */ |
| 7397 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 7398 | show_ipv6_mbgp_prefix_list_cmd, |
| 7399 | "show ipv6 mbgp prefix-list WORD", |
| 7400 | SHOW_STR |
| 7401 | IPV6_STR |
| 7402 | MBGP_STR |
| 7403 | "Display routes matching the prefix-list\n" |
| 7404 | "IPv6 prefix-list name\n") |
| 7405 | { |
| 7406 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7407 | bgp_show_type_prefix_list); |
| 7408 | } |
| 7409 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7410 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7411 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7412 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7413 | safi_t safi, enum bgp_show_type type) |
| 7414 | { |
| 7415 | struct as_list *as_list; |
| 7416 | |
| 7417 | as_list = as_list_lookup (filter); |
| 7418 | if (as_list == NULL) |
| 7419 | { |
| 7420 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 7421 | return CMD_WARNING; |
| 7422 | } |
| 7423 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7424 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7425 | } |
| 7426 | |
| 7427 | DEFUN (show_ip_bgp_filter_list, |
| 7428 | show_ip_bgp_filter_list_cmd, |
| 7429 | "show ip bgp filter-list WORD", |
| 7430 | SHOW_STR |
| 7431 | IP_STR |
| 7432 | BGP_STR |
| 7433 | "Display routes conforming to the filter-list\n" |
| 7434 | "Regular expression access list name\n") |
| 7435 | { |
| 7436 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7437 | bgp_show_type_filter_list); |
| 7438 | } |
| 7439 | |
| 7440 | DEFUN (show_ip_bgp_flap_filter_list, |
| 7441 | show_ip_bgp_flap_filter_list_cmd, |
| 7442 | "show ip bgp flap-statistics filter-list WORD", |
| 7443 | SHOW_STR |
| 7444 | IP_STR |
| 7445 | BGP_STR |
| 7446 | "Display flap statistics of routes\n" |
| 7447 | "Display routes conforming to the filter-list\n" |
| 7448 | "Regular expression access list name\n") |
| 7449 | { |
| 7450 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7451 | bgp_show_type_flap_filter_list); |
| 7452 | } |
| 7453 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 7454 | ALIAS (show_ip_bgp_flap_filter_list, |
| 7455 | show_ip_bgp_damp_flap_filter_list_cmd, |
| 7456 | "show ip bgp dampening flap-statistics filter-list WORD", |
| 7457 | SHOW_STR |
| 7458 | IP_STR |
| 7459 | BGP_STR |
| 7460 | "Display detailed information about dampening\n" |
| 7461 | "Display flap statistics of routes\n" |
| 7462 | "Display routes conforming to the filter-list\n" |
| 7463 | "Regular expression access list name\n") |
| 7464 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7465 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 7466 | show_ip_bgp_ipv4_filter_list_cmd, |
| 7467 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 7468 | SHOW_STR |
| 7469 | IP_STR |
| 7470 | BGP_STR |
| 7471 | "Address family\n" |
| 7472 | "Address Family modifier\n" |
| 7473 | "Address Family modifier\n" |
| 7474 | "Display routes conforming to the filter-list\n" |
| 7475 | "Regular expression access list name\n") |
| 7476 | { |
| 7477 | if (strncmp (argv[0], "m", 1) == 0) |
| 7478 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7479 | bgp_show_type_filter_list); |
| 7480 | |
| 7481 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7482 | bgp_show_type_filter_list); |
| 7483 | } |
| 7484 | |
| 7485 | #ifdef HAVE_IPV6 |
| 7486 | DEFUN (show_bgp_filter_list, |
| 7487 | show_bgp_filter_list_cmd, |
| 7488 | "show bgp filter-list WORD", |
| 7489 | SHOW_STR |
| 7490 | BGP_STR |
| 7491 | "Display routes conforming to the filter-list\n" |
| 7492 | "Regular expression access list name\n") |
| 7493 | { |
| 7494 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7495 | bgp_show_type_filter_list); |
| 7496 | } |
| 7497 | |
| 7498 | ALIAS (show_bgp_filter_list, |
| 7499 | show_bgp_ipv6_filter_list_cmd, |
| 7500 | "show bgp ipv6 filter-list WORD", |
| 7501 | SHOW_STR |
| 7502 | BGP_STR |
| 7503 | "Address family\n" |
| 7504 | "Display routes conforming to the filter-list\n" |
| 7505 | "Regular expression access list name\n") |
| 7506 | |
| 7507 | /* old command */ |
| 7508 | DEFUN (show_ipv6_bgp_filter_list, |
| 7509 | show_ipv6_bgp_filter_list_cmd, |
| 7510 | "show ipv6 bgp filter-list WORD", |
| 7511 | SHOW_STR |
| 7512 | IPV6_STR |
| 7513 | BGP_STR |
| 7514 | "Display routes conforming to the filter-list\n" |
| 7515 | "Regular expression access list name\n") |
| 7516 | { |
| 7517 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7518 | bgp_show_type_filter_list); |
| 7519 | } |
| 7520 | |
| 7521 | /* old command */ |
| 7522 | DEFUN (show_ipv6_mbgp_filter_list, |
| 7523 | show_ipv6_mbgp_filter_list_cmd, |
| 7524 | "show ipv6 mbgp filter-list WORD", |
| 7525 | SHOW_STR |
| 7526 | IPV6_STR |
| 7527 | MBGP_STR |
| 7528 | "Display routes conforming to the filter-list\n" |
| 7529 | "Regular expression access list name\n") |
| 7530 | { |
| 7531 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7532 | bgp_show_type_filter_list); |
| 7533 | } |
| 7534 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7535 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 7536 | DEFUN (show_ip_bgp_dampening_info, |
| 7537 | show_ip_bgp_dampening_params_cmd, |
| 7538 | "show ip bgp dampening parameters", |
| 7539 | SHOW_STR |
| 7540 | IP_STR |
| 7541 | BGP_STR |
| 7542 | "Display detailed information about dampening\n" |
| 7543 | "Display detail of configured dampening parameters\n") |
| 7544 | { |
| 7545 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); |
| 7546 | } |
| 7547 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7548 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7549 | 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] | 7550 | safi_t safi, enum bgp_show_type type) |
| 7551 | { |
| 7552 | struct route_map *rmap; |
| 7553 | |
| 7554 | rmap = route_map_lookup_by_name (rmap_str); |
| 7555 | if (! rmap) |
| 7556 | { |
| 7557 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 7558 | rmap_str, VTY_NEWLINE); |
| 7559 | return CMD_WARNING; |
| 7560 | } |
| 7561 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7562 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7563 | } |
| 7564 | |
| 7565 | DEFUN (show_ip_bgp_route_map, |
| 7566 | show_ip_bgp_route_map_cmd, |
| 7567 | "show ip bgp route-map WORD", |
| 7568 | SHOW_STR |
| 7569 | IP_STR |
| 7570 | BGP_STR |
| 7571 | "Display routes matching the route-map\n" |
| 7572 | "A route-map to match on\n") |
| 7573 | { |
| 7574 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7575 | bgp_show_type_route_map); |
| 7576 | } |
| 7577 | |
| 7578 | DEFUN (show_ip_bgp_flap_route_map, |
| 7579 | show_ip_bgp_flap_route_map_cmd, |
| 7580 | "show ip bgp flap-statistics route-map WORD", |
| 7581 | SHOW_STR |
| 7582 | IP_STR |
| 7583 | BGP_STR |
| 7584 | "Display flap statistics of routes\n" |
| 7585 | "Display routes matching the route-map\n" |
| 7586 | "A route-map to match on\n") |
| 7587 | { |
| 7588 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7589 | bgp_show_type_flap_route_map); |
| 7590 | } |
| 7591 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 7592 | ALIAS (show_ip_bgp_flap_route_map, |
| 7593 | show_ip_bgp_damp_flap_route_map_cmd, |
| 7594 | "show ip bgp dampening flap-statistics route-map WORD", |
| 7595 | SHOW_STR |
| 7596 | IP_STR |
| 7597 | BGP_STR |
| 7598 | "Display detailed information about dampening\n" |
| 7599 | "Display flap statistics of routes\n" |
| 7600 | "Display routes matching the route-map\n" |
| 7601 | "A route-map to match on\n") |
| 7602 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7603 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 7604 | show_ip_bgp_ipv4_route_map_cmd, |
| 7605 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 7606 | SHOW_STR |
| 7607 | IP_STR |
| 7608 | BGP_STR |
| 7609 | "Address family\n" |
| 7610 | "Address Family modifier\n" |
| 7611 | "Address Family modifier\n" |
| 7612 | "Display routes matching the route-map\n" |
| 7613 | "A route-map to match on\n") |
| 7614 | { |
| 7615 | if (strncmp (argv[0], "m", 1) == 0) |
| 7616 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7617 | bgp_show_type_route_map); |
| 7618 | |
| 7619 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7620 | bgp_show_type_route_map); |
| 7621 | } |
| 7622 | |
| 7623 | DEFUN (show_bgp_route_map, |
| 7624 | show_bgp_route_map_cmd, |
| 7625 | "show bgp route-map WORD", |
| 7626 | SHOW_STR |
| 7627 | BGP_STR |
| 7628 | "Display routes matching the route-map\n" |
| 7629 | "A route-map to match on\n") |
| 7630 | { |
| 7631 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7632 | bgp_show_type_route_map); |
| 7633 | } |
| 7634 | |
| 7635 | ALIAS (show_bgp_route_map, |
| 7636 | show_bgp_ipv6_route_map_cmd, |
| 7637 | "show bgp ipv6 route-map WORD", |
| 7638 | SHOW_STR |
| 7639 | BGP_STR |
| 7640 | "Address family\n" |
| 7641 | "Display routes matching the route-map\n" |
| 7642 | "A route-map to match on\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7643 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7644 | DEFUN (show_ip_bgp_cidr_only, |
| 7645 | show_ip_bgp_cidr_only_cmd, |
| 7646 | "show ip bgp cidr-only", |
| 7647 | SHOW_STR |
| 7648 | IP_STR |
| 7649 | BGP_STR |
| 7650 | "Display only routes with non-natural netmasks\n") |
| 7651 | { |
| 7652 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7653 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7654 | } |
| 7655 | |
| 7656 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 7657 | show_ip_bgp_flap_cidr_only_cmd, |
| 7658 | "show ip bgp flap-statistics cidr-only", |
| 7659 | SHOW_STR |
| 7660 | IP_STR |
| 7661 | BGP_STR |
| 7662 | "Display flap statistics of routes\n" |
| 7663 | "Display only routes with non-natural netmasks\n") |
| 7664 | { |
| 7665 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7666 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7667 | } |
| 7668 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 7669 | ALIAS (show_ip_bgp_flap_cidr_only, |
| 7670 | show_ip_bgp_damp_flap_cidr_only_cmd, |
| 7671 | "show ip bgp dampening flap-statistics cidr-only", |
| 7672 | SHOW_STR |
| 7673 | IP_STR |
| 7674 | BGP_STR |
| 7675 | "Display detailed information about dampening\n" |
| 7676 | "Display flap statistics of routes\n" |
| 7677 | "Display only routes with non-natural netmasks\n") |
| 7678 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7679 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 7680 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 7681 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 7682 | SHOW_STR |
| 7683 | IP_STR |
| 7684 | BGP_STR |
| 7685 | "Address family\n" |
| 7686 | "Address Family modifier\n" |
| 7687 | "Address Family modifier\n" |
| 7688 | "Display only routes with non-natural netmasks\n") |
| 7689 | { |
| 7690 | if (strncmp (argv[0], "m", 1) == 0) |
| 7691 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7692 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7693 | |
| 7694 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7695 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7696 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7697 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7698 | DEFUN (show_ip_bgp_community_all, |
| 7699 | show_ip_bgp_community_all_cmd, |
| 7700 | "show ip bgp community", |
| 7701 | SHOW_STR |
| 7702 | IP_STR |
| 7703 | BGP_STR |
| 7704 | "Display routes matching the communities\n") |
| 7705 | { |
| 7706 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7707 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7708 | } |
| 7709 | |
| 7710 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 7711 | show_ip_bgp_ipv4_community_all_cmd, |
| 7712 | "show ip bgp ipv4 (unicast|multicast) community", |
| 7713 | SHOW_STR |
| 7714 | IP_STR |
| 7715 | BGP_STR |
| 7716 | "Address family\n" |
| 7717 | "Address Family modifier\n" |
| 7718 | "Address Family modifier\n" |
| 7719 | "Display routes matching the communities\n") |
| 7720 | { |
| 7721 | if (strncmp (argv[0], "m", 1) == 0) |
| 7722 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7723 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7724 | |
| 7725 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7726 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7727 | } |
| 7728 | |
| 7729 | #ifdef HAVE_IPV6 |
| 7730 | DEFUN (show_bgp_community_all, |
| 7731 | show_bgp_community_all_cmd, |
| 7732 | "show bgp community", |
| 7733 | SHOW_STR |
| 7734 | BGP_STR |
| 7735 | "Display routes matching the communities\n") |
| 7736 | { |
| 7737 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7738 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7739 | } |
| 7740 | |
| 7741 | ALIAS (show_bgp_community_all, |
| 7742 | show_bgp_ipv6_community_all_cmd, |
| 7743 | "show bgp ipv6 community", |
| 7744 | SHOW_STR |
| 7745 | BGP_STR |
| 7746 | "Address family\n" |
| 7747 | "Display routes matching the communities\n") |
| 7748 | |
| 7749 | /* old command */ |
| 7750 | DEFUN (show_ipv6_bgp_community_all, |
| 7751 | show_ipv6_bgp_community_all_cmd, |
| 7752 | "show ipv6 bgp community", |
| 7753 | SHOW_STR |
| 7754 | IPV6_STR |
| 7755 | BGP_STR |
| 7756 | "Display routes matching the communities\n") |
| 7757 | { |
| 7758 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7759 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7760 | } |
| 7761 | |
| 7762 | /* old command */ |
| 7763 | DEFUN (show_ipv6_mbgp_community_all, |
| 7764 | show_ipv6_mbgp_community_all_cmd, |
| 7765 | "show ipv6 mbgp community", |
| 7766 | SHOW_STR |
| 7767 | IPV6_STR |
| 7768 | MBGP_STR |
| 7769 | "Display routes matching the communities\n") |
| 7770 | { |
| 7771 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7772 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7773 | } |
| 7774 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7775 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7776 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7777 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 7778 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7779 | { |
| 7780 | struct community *com; |
| 7781 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7782 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7783 | int i; |
| 7784 | char *str; |
| 7785 | int first = 0; |
| 7786 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7787 | /* BGP structure lookup */ |
| 7788 | if (view_name) |
| 7789 | { |
| 7790 | bgp = bgp_lookup_by_name (view_name); |
| 7791 | if (bgp == NULL) |
| 7792 | { |
| 7793 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 7794 | return CMD_WARNING; |
| 7795 | } |
| 7796 | } |
| 7797 | else |
| 7798 | { |
| 7799 | bgp = bgp_get_default (); |
| 7800 | if (bgp == NULL) |
| 7801 | { |
| 7802 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 7803 | return CMD_WARNING; |
| 7804 | } |
| 7805 | } |
| 7806 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7807 | b = buffer_new (1024); |
| 7808 | for (i = 0; i < argc; i++) |
| 7809 | { |
| 7810 | if (first) |
| 7811 | buffer_putc (b, ' '); |
| 7812 | else |
| 7813 | { |
| 7814 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7815 | continue; |
| 7816 | first = 1; |
| 7817 | } |
| 7818 | |
| 7819 | buffer_putstr (b, argv[i]); |
| 7820 | } |
| 7821 | buffer_putc (b, '\0'); |
| 7822 | |
| 7823 | str = buffer_getstr (b); |
| 7824 | buffer_free (b); |
| 7825 | |
| 7826 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7827 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7828 | if (! com) |
| 7829 | { |
| 7830 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 7831 | return CMD_WARNING; |
| 7832 | } |
| 7833 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7834 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7835 | (exact ? bgp_show_type_community_exact : |
| 7836 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7837 | } |
| 7838 | |
| 7839 | DEFUN (show_ip_bgp_community, |
| 7840 | show_ip_bgp_community_cmd, |
| 7841 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7842 | SHOW_STR |
| 7843 | IP_STR |
| 7844 | BGP_STR |
| 7845 | "Display routes matching the communities\n" |
| 7846 | "community number\n" |
| 7847 | "Do not send outside local AS (well-known community)\n" |
| 7848 | "Do not advertise to any peer (well-known community)\n" |
| 7849 | "Do not export to next AS (well-known community)\n") |
| 7850 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7851 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7852 | } |
| 7853 | |
| 7854 | ALIAS (show_ip_bgp_community, |
| 7855 | show_ip_bgp_community2_cmd, |
| 7856 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7857 | SHOW_STR |
| 7858 | IP_STR |
| 7859 | BGP_STR |
| 7860 | "Display routes matching the communities\n" |
| 7861 | "community number\n" |
| 7862 | "Do not send outside local AS (well-known community)\n" |
| 7863 | "Do not advertise to any peer (well-known community)\n" |
| 7864 | "Do not export to next AS (well-known community)\n" |
| 7865 | "community number\n" |
| 7866 | "Do not send outside local AS (well-known community)\n" |
| 7867 | "Do not advertise to any peer (well-known community)\n" |
| 7868 | "Do not export to next AS (well-known community)\n") |
| 7869 | |
| 7870 | ALIAS (show_ip_bgp_community, |
| 7871 | show_ip_bgp_community3_cmd, |
| 7872 | "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)", |
| 7873 | SHOW_STR |
| 7874 | IP_STR |
| 7875 | BGP_STR |
| 7876 | "Display routes matching the communities\n" |
| 7877 | "community number\n" |
| 7878 | "Do not send outside local AS (well-known community)\n" |
| 7879 | "Do not advertise to any peer (well-known community)\n" |
| 7880 | "Do not export to next AS (well-known community)\n" |
| 7881 | "community number\n" |
| 7882 | "Do not send outside local AS (well-known community)\n" |
| 7883 | "Do not advertise to any peer (well-known community)\n" |
| 7884 | "Do not export to next AS (well-known community)\n" |
| 7885 | "community number\n" |
| 7886 | "Do not send outside local AS (well-known community)\n" |
| 7887 | "Do not advertise to any peer (well-known community)\n" |
| 7888 | "Do not export to next AS (well-known community)\n") |
| 7889 | |
| 7890 | ALIAS (show_ip_bgp_community, |
| 7891 | show_ip_bgp_community4_cmd, |
| 7892 | "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)", |
| 7893 | SHOW_STR |
| 7894 | IP_STR |
| 7895 | BGP_STR |
| 7896 | "Display routes matching the communities\n" |
| 7897 | "community number\n" |
| 7898 | "Do not send outside local AS (well-known community)\n" |
| 7899 | "Do not advertise to any peer (well-known community)\n" |
| 7900 | "Do not export to next AS (well-known community)\n" |
| 7901 | "community number\n" |
| 7902 | "Do not send outside local AS (well-known community)\n" |
| 7903 | "Do not advertise to any peer (well-known community)\n" |
| 7904 | "Do not export to next AS (well-known community)\n" |
| 7905 | "community number\n" |
| 7906 | "Do not send outside local AS (well-known community)\n" |
| 7907 | "Do not advertise to any peer (well-known community)\n" |
| 7908 | "Do not export to next AS (well-known community)\n" |
| 7909 | "community number\n" |
| 7910 | "Do not send outside local AS (well-known community)\n" |
| 7911 | "Do not advertise to any peer (well-known community)\n" |
| 7912 | "Do not export to next AS (well-known community)\n") |
| 7913 | |
| 7914 | DEFUN (show_ip_bgp_ipv4_community, |
| 7915 | show_ip_bgp_ipv4_community_cmd, |
| 7916 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7917 | SHOW_STR |
| 7918 | IP_STR |
| 7919 | BGP_STR |
| 7920 | "Address family\n" |
| 7921 | "Address Family modifier\n" |
| 7922 | "Address Family modifier\n" |
| 7923 | "Display routes matching the communities\n" |
| 7924 | "community number\n" |
| 7925 | "Do not send outside local AS (well-known community)\n" |
| 7926 | "Do not advertise to any peer (well-known community)\n" |
| 7927 | "Do not export to next AS (well-known community)\n") |
| 7928 | { |
| 7929 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7930 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7931 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7932 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7933 | } |
| 7934 | |
| 7935 | ALIAS (show_ip_bgp_ipv4_community, |
| 7936 | show_ip_bgp_ipv4_community2_cmd, |
| 7937 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7938 | SHOW_STR |
| 7939 | IP_STR |
| 7940 | BGP_STR |
| 7941 | "Address family\n" |
| 7942 | "Address Family modifier\n" |
| 7943 | "Address Family modifier\n" |
| 7944 | "Display routes matching the communities\n" |
| 7945 | "community number\n" |
| 7946 | "Do not send outside local AS (well-known community)\n" |
| 7947 | "Do not advertise to any peer (well-known community)\n" |
| 7948 | "Do not export to next AS (well-known community)\n" |
| 7949 | "community number\n" |
| 7950 | "Do not send outside local AS (well-known community)\n" |
| 7951 | "Do not advertise to any peer (well-known community)\n" |
| 7952 | "Do not export to next AS (well-known community)\n") |
| 7953 | |
| 7954 | ALIAS (show_ip_bgp_ipv4_community, |
| 7955 | show_ip_bgp_ipv4_community3_cmd, |
| 7956 | "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)", |
| 7957 | SHOW_STR |
| 7958 | IP_STR |
| 7959 | BGP_STR |
| 7960 | "Address family\n" |
| 7961 | "Address Family modifier\n" |
| 7962 | "Address Family modifier\n" |
| 7963 | "Display routes matching the communities\n" |
| 7964 | "community number\n" |
| 7965 | "Do not send outside local AS (well-known community)\n" |
| 7966 | "Do not advertise to any peer (well-known community)\n" |
| 7967 | "Do not export to next AS (well-known community)\n" |
| 7968 | "community number\n" |
| 7969 | "Do not send outside local AS (well-known community)\n" |
| 7970 | "Do not advertise to any peer (well-known community)\n" |
| 7971 | "Do not export to next AS (well-known community)\n" |
| 7972 | "community number\n" |
| 7973 | "Do not send outside local AS (well-known community)\n" |
| 7974 | "Do not advertise to any peer (well-known community)\n" |
| 7975 | "Do not export to next AS (well-known community)\n") |
| 7976 | |
| 7977 | ALIAS (show_ip_bgp_ipv4_community, |
| 7978 | show_ip_bgp_ipv4_community4_cmd, |
| 7979 | "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)", |
| 7980 | SHOW_STR |
| 7981 | IP_STR |
| 7982 | BGP_STR |
| 7983 | "Address family\n" |
| 7984 | "Address Family modifier\n" |
| 7985 | "Address Family modifier\n" |
| 7986 | "Display routes matching the communities\n" |
| 7987 | "community number\n" |
| 7988 | "Do not send outside local AS (well-known community)\n" |
| 7989 | "Do not advertise to any peer (well-known community)\n" |
| 7990 | "Do not export to next AS (well-known community)\n" |
| 7991 | "community number\n" |
| 7992 | "Do not send outside local AS (well-known community)\n" |
| 7993 | "Do not advertise to any peer (well-known community)\n" |
| 7994 | "Do not export to next AS (well-known community)\n" |
| 7995 | "community number\n" |
| 7996 | "Do not send outside local AS (well-known community)\n" |
| 7997 | "Do not advertise to any peer (well-known community)\n" |
| 7998 | "Do not export to next AS (well-known community)\n" |
| 7999 | "community number\n" |
| 8000 | "Do not send outside local AS (well-known community)\n" |
| 8001 | "Do not advertise to any peer (well-known community)\n" |
| 8002 | "Do not export to next AS (well-known community)\n") |
| 8003 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8004 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 8005 | show_bgp_view_afi_safi_community_all_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8006 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8007 | SHOW_STR |
| 8008 | BGP_STR |
| 8009 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8010 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8011 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8012 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8013 | "Address Family modifier\n" |
| 8014 | "Address Family modifier\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8015 | "Display routes matching the communities\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8016 | { |
| 8017 | int afi; |
| 8018 | int safi; |
| 8019 | struct bgp *bgp; |
| 8020 | |
| 8021 | /* BGP structure lookup. */ |
| 8022 | bgp = bgp_lookup_by_name (argv[0]); |
| 8023 | if (bgp == NULL) |
| 8024 | { |
| 8025 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 8026 | return CMD_WARNING; |
| 8027 | } |
| 8028 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8029 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 8030 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8031 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 8032 | } |
| 8033 | |
| 8034 | DEFUN (show_bgp_view_afi_safi_community, |
| 8035 | show_bgp_view_afi_safi_community_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8036 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8037 | SHOW_STR |
| 8038 | BGP_STR |
| 8039 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8040 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8041 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8042 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8043 | "Address family modifier\n" |
| 8044 | "Address family modifier\n" |
| 8045 | "Display routes matching the communities\n" |
| 8046 | "community number\n" |
| 8047 | "Do not send outside local AS (well-known community)\n" |
| 8048 | "Do not advertise to any peer (well-known community)\n" |
| 8049 | "Do not export to next AS (well-known community)\n") |
| 8050 | { |
| 8051 | int afi; |
| 8052 | int safi; |
| 8053 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8054 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 8055 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 8056 | return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8057 | } |
| 8058 | |
| 8059 | ALIAS (show_bgp_view_afi_safi_community, |
| 8060 | show_bgp_view_afi_safi_community2_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8061 | "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)", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8062 | SHOW_STR |
| 8063 | BGP_STR |
| 8064 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8065 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8066 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8067 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8068 | "Address family modifier\n" |
| 8069 | "Address family modifier\n" |
| 8070 | "Display routes matching the communities\n" |
| 8071 | "community number\n" |
| 8072 | "Do not send outside local AS (well-known community)\n" |
| 8073 | "Do not advertise to any peer (well-known community)\n" |
| 8074 | "Do not export to next AS (well-known community)\n" |
| 8075 | "community number\n" |
| 8076 | "Do not send outside local AS (well-known community)\n" |
| 8077 | "Do not advertise to any peer (well-known community)\n" |
| 8078 | "Do not export to next AS (well-known community)\n") |
| 8079 | |
| 8080 | ALIAS (show_bgp_view_afi_safi_community, |
| 8081 | show_bgp_view_afi_safi_community3_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8082 | "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)", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8083 | SHOW_STR |
| 8084 | BGP_STR |
| 8085 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8086 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8087 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8088 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8089 | "Address family modifier\n" |
| 8090 | "Address family modifier\n" |
| 8091 | "Display routes matching the communities\n" |
| 8092 | "community number\n" |
| 8093 | "Do not send outside local AS (well-known community)\n" |
| 8094 | "Do not advertise to any peer (well-known community)\n" |
| 8095 | "Do not export to next AS (well-known community)\n" |
| 8096 | "community number\n" |
| 8097 | "Do not send outside local AS (well-known community)\n" |
| 8098 | "Do not advertise to any peer (well-known community)\n" |
| 8099 | "Do not export to next AS (well-known community)\n" |
| 8100 | "community number\n" |
| 8101 | "Do not send outside local AS (well-known community)\n" |
| 8102 | "Do not advertise to any peer (well-known community)\n" |
| 8103 | "Do not export to next AS (well-known community)\n") |
| 8104 | |
| 8105 | ALIAS (show_bgp_view_afi_safi_community, |
| 8106 | show_bgp_view_afi_safi_community4_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8107 | "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)", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8108 | SHOW_STR |
| 8109 | BGP_STR |
| 8110 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8111 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8112 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8113 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8114 | "Address family modifier\n" |
| 8115 | "Address family modifier\n" |
| 8116 | "Display routes matching the communities\n" |
| 8117 | "community number\n" |
| 8118 | "Do not send outside local AS (well-known community)\n" |
| 8119 | "Do not advertise to any peer (well-known community)\n" |
| 8120 | "Do not export to next AS (well-known community)\n" |
| 8121 | "community number\n" |
| 8122 | "Do not send outside local AS (well-known community)\n" |
| 8123 | "Do not advertise to any peer (well-known community)\n" |
| 8124 | "Do not export to next AS (well-known community)\n" |
| 8125 | "community number\n" |
| 8126 | "Do not send outside local AS (well-known community)\n" |
| 8127 | "Do not advertise to any peer (well-known community)\n" |
| 8128 | "Do not export to next AS (well-known community)\n" |
| 8129 | "community number\n" |
| 8130 | "Do not send outside local AS (well-known community)\n" |
| 8131 | "Do not advertise to any peer (well-known community)\n" |
| 8132 | "Do not export to next AS (well-known community)\n") |
| 8133 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8134 | DEFUN (show_ip_bgp_community_exact, |
| 8135 | show_ip_bgp_community_exact_cmd, |
| 8136 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8137 | SHOW_STR |
| 8138 | IP_STR |
| 8139 | BGP_STR |
| 8140 | "Display routes matching the communities\n" |
| 8141 | "community number\n" |
| 8142 | "Do not send outside local AS (well-known community)\n" |
| 8143 | "Do not advertise to any peer (well-known community)\n" |
| 8144 | "Do not export to next AS (well-known community)\n" |
| 8145 | "Exact match of the communities") |
| 8146 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8147 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8148 | } |
| 8149 | |
| 8150 | ALIAS (show_ip_bgp_community_exact, |
| 8151 | show_ip_bgp_community2_exact_cmd, |
| 8152 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8153 | SHOW_STR |
| 8154 | IP_STR |
| 8155 | BGP_STR |
| 8156 | "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_community_exact, |
| 8168 | show_ip_bgp_community3_exact_cmd, |
| 8169 | "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", |
| 8170 | SHOW_STR |
| 8171 | IP_STR |
| 8172 | BGP_STR |
| 8173 | "Display routes matching the communities\n" |
| 8174 | "community number\n" |
| 8175 | "Do not send outside local AS (well-known community)\n" |
| 8176 | "Do not advertise to any peer (well-known community)\n" |
| 8177 | "Do not export to next AS (well-known community)\n" |
| 8178 | "community number\n" |
| 8179 | "Do not send outside local AS (well-known community)\n" |
| 8180 | "Do not advertise to any peer (well-known community)\n" |
| 8181 | "Do not export to next AS (well-known community)\n" |
| 8182 | "community number\n" |
| 8183 | "Do not send outside local AS (well-known community)\n" |
| 8184 | "Do not advertise to any peer (well-known community)\n" |
| 8185 | "Do not export to next AS (well-known community)\n" |
| 8186 | "Exact match of the communities") |
| 8187 | |
| 8188 | ALIAS (show_ip_bgp_community_exact, |
| 8189 | show_ip_bgp_community4_exact_cmd, |
| 8190 | "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", |
| 8191 | SHOW_STR |
| 8192 | IP_STR |
| 8193 | BGP_STR |
| 8194 | "Display routes matching the communities\n" |
| 8195 | "community number\n" |
| 8196 | "Do not send outside local AS (well-known community)\n" |
| 8197 | "Do not advertise to any peer (well-known community)\n" |
| 8198 | "Do not export to next AS (well-known community)\n" |
| 8199 | "community number\n" |
| 8200 | "Do not send outside local AS (well-known community)\n" |
| 8201 | "Do not advertise to any peer (well-known community)\n" |
| 8202 | "Do not export to next AS (well-known community)\n" |
| 8203 | "community number\n" |
| 8204 | "Do not send outside local AS (well-known community)\n" |
| 8205 | "Do not advertise to any peer (well-known community)\n" |
| 8206 | "Do not export to next AS (well-known community)\n" |
| 8207 | "community number\n" |
| 8208 | "Do not send outside local AS (well-known community)\n" |
| 8209 | "Do not advertise to any peer (well-known community)\n" |
| 8210 | "Do not export to next AS (well-known community)\n" |
| 8211 | "Exact match of the communities") |
| 8212 | |
| 8213 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 8214 | show_ip_bgp_ipv4_community_exact_cmd, |
| 8215 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8216 | SHOW_STR |
| 8217 | IP_STR |
| 8218 | BGP_STR |
| 8219 | "Address family\n" |
| 8220 | "Address Family modifier\n" |
| 8221 | "Address Family modifier\n" |
| 8222 | "Display routes matching the communities\n" |
| 8223 | "community number\n" |
| 8224 | "Do not send outside local AS (well-known community)\n" |
| 8225 | "Do not advertise to any peer (well-known community)\n" |
| 8226 | "Do not export to next AS (well-known community)\n" |
| 8227 | "Exact match of the communities") |
| 8228 | { |
| 8229 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8230 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8231 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8232 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8233 | } |
| 8234 | |
| 8235 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8236 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 8237 | "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", |
| 8238 | SHOW_STR |
| 8239 | IP_STR |
| 8240 | BGP_STR |
| 8241 | "Address family\n" |
| 8242 | "Address Family modifier\n" |
| 8243 | "Address Family modifier\n" |
| 8244 | "Display routes matching the communities\n" |
| 8245 | "community number\n" |
| 8246 | "Do not send outside local AS (well-known community)\n" |
| 8247 | "Do not advertise to any peer (well-known community)\n" |
| 8248 | "Do not export to next AS (well-known community)\n" |
| 8249 | "community number\n" |
| 8250 | "Do not send outside local AS (well-known community)\n" |
| 8251 | "Do not advertise to any peer (well-known community)\n" |
| 8252 | "Do not export to next AS (well-known community)\n" |
| 8253 | "Exact match of the communities") |
| 8254 | |
| 8255 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8256 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 8257 | "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", |
| 8258 | SHOW_STR |
| 8259 | IP_STR |
| 8260 | BGP_STR |
| 8261 | "Address family\n" |
| 8262 | "Address Family modifier\n" |
| 8263 | "Address Family modifier\n" |
| 8264 | "Display routes matching the communities\n" |
| 8265 | "community number\n" |
| 8266 | "Do not send outside local AS (well-known community)\n" |
| 8267 | "Do not advertise to any peer (well-known community)\n" |
| 8268 | "Do not export to next AS (well-known community)\n" |
| 8269 | "community number\n" |
| 8270 | "Do not send outside local AS (well-known community)\n" |
| 8271 | "Do not advertise to any peer (well-known community)\n" |
| 8272 | "Do not export to next AS (well-known community)\n" |
| 8273 | "community number\n" |
| 8274 | "Do not send outside local AS (well-known community)\n" |
| 8275 | "Do not advertise to any peer (well-known community)\n" |
| 8276 | "Do not export to next AS (well-known community)\n" |
| 8277 | "Exact match of the communities") |
| 8278 | |
| 8279 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8280 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 8281 | "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", |
| 8282 | SHOW_STR |
| 8283 | IP_STR |
| 8284 | BGP_STR |
| 8285 | "Address family\n" |
| 8286 | "Address Family modifier\n" |
| 8287 | "Address Family modifier\n" |
| 8288 | "Display routes matching the communities\n" |
| 8289 | "community number\n" |
| 8290 | "Do not send outside local AS (well-known community)\n" |
| 8291 | "Do not advertise to any peer (well-known community)\n" |
| 8292 | "Do not export to next AS (well-known community)\n" |
| 8293 | "community number\n" |
| 8294 | "Do not send outside local AS (well-known community)\n" |
| 8295 | "Do not advertise to any peer (well-known community)\n" |
| 8296 | "Do not export to next AS (well-known community)\n" |
| 8297 | "community number\n" |
| 8298 | "Do not send outside local AS (well-known community)\n" |
| 8299 | "Do not advertise to any peer (well-known community)\n" |
| 8300 | "Do not export to next AS (well-known community)\n" |
| 8301 | "community number\n" |
| 8302 | "Do not send outside local AS (well-known community)\n" |
| 8303 | "Do not advertise to any peer (well-known community)\n" |
| 8304 | "Do not export to next AS (well-known community)\n" |
| 8305 | "Exact match of the communities") |
| 8306 | |
| 8307 | #ifdef HAVE_IPV6 |
| 8308 | DEFUN (show_bgp_community, |
| 8309 | show_bgp_community_cmd, |
| 8310 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8311 | SHOW_STR |
| 8312 | BGP_STR |
| 8313 | "Display routes matching the communities\n" |
| 8314 | "community number\n" |
| 8315 | "Do not send outside local AS (well-known community)\n" |
| 8316 | "Do not advertise to any peer (well-known community)\n" |
| 8317 | "Do not export to next AS (well-known community)\n") |
| 8318 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8319 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8320 | } |
| 8321 | |
| 8322 | ALIAS (show_bgp_community, |
| 8323 | show_bgp_ipv6_community_cmd, |
| 8324 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 8325 | SHOW_STR |
| 8326 | BGP_STR |
| 8327 | "Address family\n" |
| 8328 | "Display routes matching the communities\n" |
| 8329 | "community number\n" |
| 8330 | "Do not send outside local AS (well-known community)\n" |
| 8331 | "Do not advertise to any peer (well-known community)\n" |
| 8332 | "Do not export to next AS (well-known community)\n") |
| 8333 | |
| 8334 | ALIAS (show_bgp_community, |
| 8335 | show_bgp_community2_cmd, |
| 8336 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8337 | SHOW_STR |
| 8338 | BGP_STR |
| 8339 | "Display routes matching the communities\n" |
| 8340 | "community number\n" |
| 8341 | "Do not send outside local AS (well-known community)\n" |
| 8342 | "Do not advertise to any peer (well-known community)\n" |
| 8343 | "Do not export to next AS (well-known community)\n" |
| 8344 | "community number\n" |
| 8345 | "Do not send outside local AS (well-known community)\n" |
| 8346 | "Do not advertise to any peer (well-known community)\n" |
| 8347 | "Do not export to next AS (well-known community)\n") |
| 8348 | |
| 8349 | ALIAS (show_bgp_community, |
| 8350 | show_bgp_ipv6_community2_cmd, |
| 8351 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8352 | SHOW_STR |
| 8353 | BGP_STR |
| 8354 | "Address family\n" |
| 8355 | "Display routes matching the communities\n" |
| 8356 | "community number\n" |
| 8357 | "Do not send outside local AS (well-known community)\n" |
| 8358 | "Do not advertise to any peer (well-known community)\n" |
| 8359 | "Do not export to next AS (well-known community)\n" |
| 8360 | "community number\n" |
| 8361 | "Do not send outside local AS (well-known community)\n" |
| 8362 | "Do not advertise to any peer (well-known community)\n" |
| 8363 | "Do not export to next AS (well-known community)\n") |
| 8364 | |
| 8365 | ALIAS (show_bgp_community, |
| 8366 | show_bgp_community3_cmd, |
| 8367 | "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)", |
| 8368 | SHOW_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 | "community number\n" |
| 8376 | "Do not send outside local AS (well-known community)\n" |
| 8377 | "Do not advertise to any peer (well-known community)\n" |
| 8378 | "Do not export to next AS (well-known community)\n" |
| 8379 | "community number\n" |
| 8380 | "Do not send outside local AS (well-known community)\n" |
| 8381 | "Do not advertise to any peer (well-known community)\n" |
| 8382 | "Do not export to next AS (well-known community)\n") |
| 8383 | |
| 8384 | ALIAS (show_bgp_community, |
| 8385 | show_bgp_ipv6_community3_cmd, |
| 8386 | "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)", |
| 8387 | SHOW_STR |
| 8388 | BGP_STR |
| 8389 | "Address family\n" |
| 8390 | "Display routes matching the communities\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 | "community number\n" |
| 8396 | "Do not send outside local AS (well-known community)\n" |
| 8397 | "Do not advertise to any peer (well-known community)\n" |
| 8398 | "Do not export to next AS (well-known community)\n" |
| 8399 | "community number\n" |
| 8400 | "Do not send outside local AS (well-known community)\n" |
| 8401 | "Do not advertise to any peer (well-known community)\n" |
| 8402 | "Do not export to next AS (well-known community)\n") |
| 8403 | |
| 8404 | ALIAS (show_bgp_community, |
| 8405 | show_bgp_community4_cmd, |
| 8406 | "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)", |
| 8407 | SHOW_STR |
| 8408 | BGP_STR |
| 8409 | "Display routes matching the communities\n" |
| 8410 | "community number\n" |
| 8411 | "Do not send outside local AS (well-known community)\n" |
| 8412 | "Do not advertise to any peer (well-known community)\n" |
| 8413 | "Do not export to next AS (well-known community)\n" |
| 8414 | "community number\n" |
| 8415 | "Do not send outside local AS (well-known community)\n" |
| 8416 | "Do not advertise to any peer (well-known community)\n" |
| 8417 | "Do not export to next AS (well-known community)\n" |
| 8418 | "community number\n" |
| 8419 | "Do not send outside local AS (well-known community)\n" |
| 8420 | "Do not advertise to any peer (well-known community)\n" |
| 8421 | "Do not export to next AS (well-known community)\n" |
| 8422 | "community number\n" |
| 8423 | "Do not send outside local AS (well-known community)\n" |
| 8424 | "Do not advertise to any peer (well-known community)\n" |
| 8425 | "Do not export to next AS (well-known community)\n") |
| 8426 | |
| 8427 | ALIAS (show_bgp_community, |
| 8428 | show_bgp_ipv6_community4_cmd, |
| 8429 | "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)", |
| 8430 | SHOW_STR |
| 8431 | BGP_STR |
| 8432 | "Address family\n" |
| 8433 | "Display routes matching the communities\n" |
| 8434 | "community number\n" |
| 8435 | "Do not send outside local AS (well-known community)\n" |
| 8436 | "Do not advertise to any peer (well-known community)\n" |
| 8437 | "Do not export to next AS (well-known community)\n" |
| 8438 | "community number\n" |
| 8439 | "Do not send outside local AS (well-known community)\n" |
| 8440 | "Do not advertise to any peer (well-known community)\n" |
| 8441 | "Do not export to next AS (well-known community)\n" |
| 8442 | "community number\n" |
| 8443 | "Do not send outside local AS (well-known community)\n" |
| 8444 | "Do not advertise to any peer (well-known community)\n" |
| 8445 | "Do not export to next AS (well-known community)\n" |
| 8446 | "community number\n" |
| 8447 | "Do not send outside local AS (well-known community)\n" |
| 8448 | "Do not advertise to any peer (well-known community)\n" |
| 8449 | "Do not export to next AS (well-known community)\n") |
| 8450 | |
| 8451 | /* old command */ |
| 8452 | DEFUN (show_ipv6_bgp_community, |
| 8453 | show_ipv6_bgp_community_cmd, |
| 8454 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8455 | SHOW_STR |
| 8456 | IPV6_STR |
| 8457 | BGP_STR |
| 8458 | "Display routes matching the communities\n" |
| 8459 | "community number\n" |
| 8460 | "Do not send outside local AS (well-known community)\n" |
| 8461 | "Do not advertise to any peer (well-known community)\n" |
| 8462 | "Do not export to next AS (well-known community)\n") |
| 8463 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8464 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8465 | } |
| 8466 | |
| 8467 | /* old command */ |
| 8468 | ALIAS (show_ipv6_bgp_community, |
| 8469 | show_ipv6_bgp_community2_cmd, |
| 8470 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8471 | SHOW_STR |
| 8472 | IPV6_STR |
| 8473 | BGP_STR |
| 8474 | "Display routes matching the communities\n" |
| 8475 | "community number\n" |
| 8476 | "Do not send outside local AS (well-known community)\n" |
| 8477 | "Do not advertise to any peer (well-known community)\n" |
| 8478 | "Do not export to next AS (well-known community)\n" |
| 8479 | "community number\n" |
| 8480 | "Do not send outside local AS (well-known community)\n" |
| 8481 | "Do not advertise to any peer (well-known community)\n" |
| 8482 | "Do not export to next AS (well-known community)\n") |
| 8483 | |
| 8484 | /* old command */ |
| 8485 | ALIAS (show_ipv6_bgp_community, |
| 8486 | show_ipv6_bgp_community3_cmd, |
| 8487 | "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)", |
| 8488 | SHOW_STR |
| 8489 | IPV6_STR |
| 8490 | BGP_STR |
| 8491 | "Display routes matching the communities\n" |
| 8492 | "community number\n" |
| 8493 | "Do not send outside local AS (well-known community)\n" |
| 8494 | "Do not advertise to any peer (well-known community)\n" |
| 8495 | "Do not export to next AS (well-known community)\n" |
| 8496 | "community number\n" |
| 8497 | "Do not send outside local AS (well-known community)\n" |
| 8498 | "Do not advertise to any peer (well-known community)\n" |
| 8499 | "Do not export to next AS (well-known community)\n" |
| 8500 | "community number\n" |
| 8501 | "Do not send outside local AS (well-known community)\n" |
| 8502 | "Do not advertise to any peer (well-known community)\n" |
| 8503 | "Do not export to next AS (well-known community)\n") |
| 8504 | |
| 8505 | /* old command */ |
| 8506 | ALIAS (show_ipv6_bgp_community, |
| 8507 | show_ipv6_bgp_community4_cmd, |
| 8508 | "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)", |
| 8509 | SHOW_STR |
| 8510 | IPV6_STR |
| 8511 | BGP_STR |
| 8512 | "Display routes matching the communities\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 | "community number\n" |
| 8522 | "Do not send outside local AS (well-known community)\n" |
| 8523 | "Do not advertise to any peer (well-known community)\n" |
| 8524 | "Do not export to next AS (well-known community)\n" |
| 8525 | "community number\n" |
| 8526 | "Do not send outside local AS (well-known community)\n" |
| 8527 | "Do not advertise to any peer (well-known community)\n" |
| 8528 | "Do not export to next AS (well-known community)\n") |
| 8529 | |
| 8530 | DEFUN (show_bgp_community_exact, |
| 8531 | show_bgp_community_exact_cmd, |
| 8532 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8533 | SHOW_STR |
| 8534 | BGP_STR |
| 8535 | "Display routes matching the communities\n" |
| 8536 | "community number\n" |
| 8537 | "Do not send outside local AS (well-known community)\n" |
| 8538 | "Do not advertise to any peer (well-known community)\n" |
| 8539 | "Do not export to next AS (well-known community)\n" |
| 8540 | "Exact match of the communities") |
| 8541 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8542 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8543 | } |
| 8544 | |
| 8545 | ALIAS (show_bgp_community_exact, |
| 8546 | show_bgp_ipv6_community_exact_cmd, |
| 8547 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8548 | SHOW_STR |
| 8549 | BGP_STR |
| 8550 | "Address family\n" |
| 8551 | "Display routes matching the communities\n" |
| 8552 | "community number\n" |
| 8553 | "Do not send outside local AS (well-known community)\n" |
| 8554 | "Do not advertise to any peer (well-known community)\n" |
| 8555 | "Do not export to next AS (well-known community)\n" |
| 8556 | "Exact match of the communities") |
| 8557 | |
| 8558 | ALIAS (show_bgp_community_exact, |
| 8559 | show_bgp_community2_exact_cmd, |
| 8560 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8561 | SHOW_STR |
| 8562 | BGP_STR |
| 8563 | "Display routes matching the communities\n" |
| 8564 | "community number\n" |
| 8565 | "Do not send outside local AS (well-known community)\n" |
| 8566 | "Do not advertise to any peer (well-known community)\n" |
| 8567 | "Do not export to next AS (well-known community)\n" |
| 8568 | "community number\n" |
| 8569 | "Do not send outside local AS (well-known community)\n" |
| 8570 | "Do not advertise to any peer (well-known community)\n" |
| 8571 | "Do not export to next AS (well-known community)\n" |
| 8572 | "Exact match of the communities") |
| 8573 | |
| 8574 | ALIAS (show_bgp_community_exact, |
| 8575 | show_bgp_ipv6_community2_exact_cmd, |
| 8576 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8577 | SHOW_STR |
| 8578 | BGP_STR |
| 8579 | "Address family\n" |
| 8580 | "Display routes matching the communities\n" |
| 8581 | "community number\n" |
| 8582 | "Do not send outside local AS (well-known community)\n" |
| 8583 | "Do not advertise to any peer (well-known community)\n" |
| 8584 | "Do not export to next AS (well-known community)\n" |
| 8585 | "community number\n" |
| 8586 | "Do not send outside local AS (well-known community)\n" |
| 8587 | "Do not advertise to any peer (well-known community)\n" |
| 8588 | "Do not export to next AS (well-known community)\n" |
| 8589 | "Exact match of the communities") |
| 8590 | |
| 8591 | ALIAS (show_bgp_community_exact, |
| 8592 | show_bgp_community3_exact_cmd, |
| 8593 | "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", |
| 8594 | SHOW_STR |
| 8595 | BGP_STR |
| 8596 | "Display routes matching the communities\n" |
| 8597 | "community number\n" |
| 8598 | "Do not send outside local AS (well-known community)\n" |
| 8599 | "Do not advertise to any peer (well-known community)\n" |
| 8600 | "Do not export to next AS (well-known community)\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 | "community number\n" |
| 8606 | "Do not send outside local AS (well-known community)\n" |
| 8607 | "Do not advertise to any peer (well-known community)\n" |
| 8608 | "Do not export to next AS (well-known community)\n" |
| 8609 | "Exact match of the communities") |
| 8610 | |
| 8611 | ALIAS (show_bgp_community_exact, |
| 8612 | show_bgp_ipv6_community3_exact_cmd, |
| 8613 | "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", |
| 8614 | SHOW_STR |
| 8615 | BGP_STR |
| 8616 | "Address family\n" |
| 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 | "community number\n" |
| 8627 | "Do not send outside local AS (well-known community)\n" |
| 8628 | "Do not advertise to any peer (well-known community)\n" |
| 8629 | "Do not export to next AS (well-known community)\n" |
| 8630 | "Exact match of the communities") |
| 8631 | |
| 8632 | ALIAS (show_bgp_community_exact, |
| 8633 | show_bgp_community4_exact_cmd, |
| 8634 | "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", |
| 8635 | SHOW_STR |
| 8636 | BGP_STR |
| 8637 | "Display routes matching the communities\n" |
| 8638 | "community number\n" |
| 8639 | "Do not send outside local AS (well-known community)\n" |
| 8640 | "Do not advertise to any peer (well-known community)\n" |
| 8641 | "Do not export to next AS (well-known community)\n" |
| 8642 | "community number\n" |
| 8643 | "Do not send outside local AS (well-known community)\n" |
| 8644 | "Do not advertise to any peer (well-known community)\n" |
| 8645 | "Do not export to next AS (well-known community)\n" |
| 8646 | "community number\n" |
| 8647 | "Do not send outside local AS (well-known community)\n" |
| 8648 | "Do not advertise to any peer (well-known community)\n" |
| 8649 | "Do not export to next AS (well-known community)\n" |
| 8650 | "community number\n" |
| 8651 | "Do not send outside local AS (well-known community)\n" |
| 8652 | "Do not advertise to any peer (well-known community)\n" |
| 8653 | "Do not export to next AS (well-known community)\n" |
| 8654 | "Exact match of the communities") |
| 8655 | |
| 8656 | ALIAS (show_bgp_community_exact, |
| 8657 | show_bgp_ipv6_community4_exact_cmd, |
| 8658 | "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", |
| 8659 | SHOW_STR |
| 8660 | BGP_STR |
| 8661 | "Address family\n" |
| 8662 | "Display routes matching the communities\n" |
| 8663 | "community number\n" |
| 8664 | "Do not send outside local AS (well-known community)\n" |
| 8665 | "Do not advertise to any peer (well-known community)\n" |
| 8666 | "Do not export to next AS (well-known community)\n" |
| 8667 | "community number\n" |
| 8668 | "Do not send outside local AS (well-known community)\n" |
| 8669 | "Do not advertise to any peer (well-known community)\n" |
| 8670 | "Do not export to next AS (well-known community)\n" |
| 8671 | "community number\n" |
| 8672 | "Do not send outside local AS (well-known community)\n" |
| 8673 | "Do not advertise to any peer (well-known community)\n" |
| 8674 | "Do not export to next AS (well-known community)\n" |
| 8675 | "community number\n" |
| 8676 | "Do not send outside local AS (well-known community)\n" |
| 8677 | "Do not advertise to any peer (well-known community)\n" |
| 8678 | "Do not export to next AS (well-known community)\n" |
| 8679 | "Exact match of the communities") |
| 8680 | |
| 8681 | /* old command */ |
| 8682 | DEFUN (show_ipv6_bgp_community_exact, |
| 8683 | show_ipv6_bgp_community_exact_cmd, |
| 8684 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8685 | SHOW_STR |
| 8686 | IPV6_STR |
| 8687 | BGP_STR |
| 8688 | "Display routes matching the communities\n" |
| 8689 | "community number\n" |
| 8690 | "Do not send outside local AS (well-known community)\n" |
| 8691 | "Do not advertise to any peer (well-known community)\n" |
| 8692 | "Do not export to next AS (well-known community)\n" |
| 8693 | "Exact match of the communities") |
| 8694 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8695 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8696 | } |
| 8697 | |
| 8698 | /* old command */ |
| 8699 | ALIAS (show_ipv6_bgp_community_exact, |
| 8700 | show_ipv6_bgp_community2_exact_cmd, |
| 8701 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8702 | SHOW_STR |
| 8703 | IPV6_STR |
| 8704 | BGP_STR |
| 8705 | "Display routes matching the communities\n" |
| 8706 | "community number\n" |
| 8707 | "Do not send outside local AS (well-known community)\n" |
| 8708 | "Do not advertise to any peer (well-known community)\n" |
| 8709 | "Do not export to next AS (well-known community)\n" |
| 8710 | "community number\n" |
| 8711 | "Do not send outside local AS (well-known community)\n" |
| 8712 | "Do not advertise to any peer (well-known community)\n" |
| 8713 | "Do not export to next AS (well-known community)\n" |
| 8714 | "Exact match of the communities") |
| 8715 | |
| 8716 | /* old command */ |
| 8717 | ALIAS (show_ipv6_bgp_community_exact, |
| 8718 | show_ipv6_bgp_community3_exact_cmd, |
| 8719 | "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", |
| 8720 | SHOW_STR |
| 8721 | IPV6_STR |
| 8722 | BGP_STR |
| 8723 | "Display routes matching the communities\n" |
| 8724 | "community number\n" |
| 8725 | "Do not send outside local AS (well-known community)\n" |
| 8726 | "Do not advertise to any peer (well-known community)\n" |
| 8727 | "Do not export to next AS (well-known community)\n" |
| 8728 | "community number\n" |
| 8729 | "Do not send outside local AS (well-known community)\n" |
| 8730 | "Do not advertise to any peer (well-known community)\n" |
| 8731 | "Do not export to next AS (well-known community)\n" |
| 8732 | "community number\n" |
| 8733 | "Do not send outside local AS (well-known community)\n" |
| 8734 | "Do not advertise to any peer (well-known community)\n" |
| 8735 | "Do not export to next AS (well-known community)\n" |
| 8736 | "Exact match of the communities") |
| 8737 | |
| 8738 | /* old command */ |
| 8739 | ALIAS (show_ipv6_bgp_community_exact, |
| 8740 | show_ipv6_bgp_community4_exact_cmd, |
| 8741 | "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", |
| 8742 | SHOW_STR |
| 8743 | IPV6_STR |
| 8744 | BGP_STR |
| 8745 | "Display routes matching the communities\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 | "community number\n" |
| 8755 | "Do not send outside local AS (well-known community)\n" |
| 8756 | "Do not advertise to any peer (well-known community)\n" |
| 8757 | "Do not export to next AS (well-known community)\n" |
| 8758 | "community number\n" |
| 8759 | "Do not send outside local AS (well-known community)\n" |
| 8760 | "Do not advertise to any peer (well-known community)\n" |
| 8761 | "Do not export to next AS (well-known community)\n" |
| 8762 | "Exact match of the communities") |
| 8763 | |
| 8764 | /* old command */ |
| 8765 | DEFUN (show_ipv6_mbgp_community, |
| 8766 | show_ipv6_mbgp_community_cmd, |
| 8767 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8768 | SHOW_STR |
| 8769 | IPV6_STR |
| 8770 | MBGP_STR |
| 8771 | "Display routes matching the communities\n" |
| 8772 | "community number\n" |
| 8773 | "Do not send outside local AS (well-known community)\n" |
| 8774 | "Do not advertise to any peer (well-known community)\n" |
| 8775 | "Do not export to next AS (well-known community)\n") |
| 8776 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8777 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8778 | } |
| 8779 | |
| 8780 | /* old command */ |
| 8781 | ALIAS (show_ipv6_mbgp_community, |
| 8782 | show_ipv6_mbgp_community2_cmd, |
| 8783 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8784 | SHOW_STR |
| 8785 | IPV6_STR |
| 8786 | MBGP_STR |
| 8787 | "Display routes matching the communities\n" |
| 8788 | "community number\n" |
| 8789 | "Do not send outside local AS (well-known community)\n" |
| 8790 | "Do not advertise to any peer (well-known community)\n" |
| 8791 | "Do not export to next AS (well-known community)\n" |
| 8792 | "community number\n" |
| 8793 | "Do not send outside local AS (well-known community)\n" |
| 8794 | "Do not advertise to any peer (well-known community)\n" |
| 8795 | "Do not export to next AS (well-known community)\n") |
| 8796 | |
| 8797 | /* old command */ |
| 8798 | ALIAS (show_ipv6_mbgp_community, |
| 8799 | show_ipv6_mbgp_community3_cmd, |
| 8800 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8801 | SHOW_STR |
| 8802 | IPV6_STR |
| 8803 | MBGP_STR |
| 8804 | "Display routes matching the communities\n" |
| 8805 | "community number\n" |
| 8806 | "Do not send outside local AS (well-known community)\n" |
| 8807 | "Do not advertise to any peer (well-known community)\n" |
| 8808 | "Do not export to next AS (well-known community)\n" |
| 8809 | "community number\n" |
| 8810 | "Do not send outside local AS (well-known community)\n" |
| 8811 | "Do not advertise to any peer (well-known community)\n" |
| 8812 | "Do not export to next AS (well-known community)\n" |
| 8813 | "community number\n" |
| 8814 | "Do not send outside local AS (well-known community)\n" |
| 8815 | "Do not advertise to any peer (well-known community)\n" |
| 8816 | "Do not export to next AS (well-known community)\n") |
| 8817 | |
| 8818 | /* old command */ |
| 8819 | ALIAS (show_ipv6_mbgp_community, |
| 8820 | show_ipv6_mbgp_community4_cmd, |
| 8821 | "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)", |
| 8822 | SHOW_STR |
| 8823 | IPV6_STR |
| 8824 | MBGP_STR |
| 8825 | "Display routes matching the communities\n" |
| 8826 | "community number\n" |
| 8827 | "Do not send outside local AS (well-known community)\n" |
| 8828 | "Do not advertise to any peer (well-known community)\n" |
| 8829 | "Do not export to next AS (well-known community)\n" |
| 8830 | "community number\n" |
| 8831 | "Do not send outside local AS (well-known community)\n" |
| 8832 | "Do not advertise to any peer (well-known community)\n" |
| 8833 | "Do not export to next AS (well-known community)\n" |
| 8834 | "community number\n" |
| 8835 | "Do not send outside local AS (well-known community)\n" |
| 8836 | "Do not advertise to any peer (well-known community)\n" |
| 8837 | "Do not export to next AS (well-known community)\n" |
| 8838 | "community number\n" |
| 8839 | "Do not send outside local AS (well-known community)\n" |
| 8840 | "Do not advertise to any peer (well-known community)\n" |
| 8841 | "Do not export to next AS (well-known community)\n") |
| 8842 | |
| 8843 | /* old command */ |
| 8844 | DEFUN (show_ipv6_mbgp_community_exact, |
| 8845 | show_ipv6_mbgp_community_exact_cmd, |
| 8846 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8847 | SHOW_STR |
| 8848 | IPV6_STR |
| 8849 | MBGP_STR |
| 8850 | "Display routes matching the communities\n" |
| 8851 | "community number\n" |
| 8852 | "Do not send outside local AS (well-known community)\n" |
| 8853 | "Do not advertise to any peer (well-known community)\n" |
| 8854 | "Do not export to next AS (well-known community)\n" |
| 8855 | "Exact match of the communities") |
| 8856 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8857 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8858 | } |
| 8859 | |
| 8860 | /* old command */ |
| 8861 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8862 | show_ipv6_mbgp_community2_exact_cmd, |
| 8863 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8864 | SHOW_STR |
| 8865 | IPV6_STR |
| 8866 | MBGP_STR |
| 8867 | "Display routes matching the communities\n" |
| 8868 | "community number\n" |
| 8869 | "Do not send outside local AS (well-known community)\n" |
| 8870 | "Do not advertise to any peer (well-known community)\n" |
| 8871 | "Do not export to next AS (well-known community)\n" |
| 8872 | "community number\n" |
| 8873 | "Do not send outside local AS (well-known community)\n" |
| 8874 | "Do not advertise to any peer (well-known community)\n" |
| 8875 | "Do not export to next AS (well-known community)\n" |
| 8876 | "Exact match of the communities") |
| 8877 | |
| 8878 | /* old command */ |
| 8879 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8880 | show_ipv6_mbgp_community3_exact_cmd, |
| 8881 | "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", |
| 8882 | SHOW_STR |
| 8883 | IPV6_STR |
| 8884 | MBGP_STR |
| 8885 | "Display routes matching the communities\n" |
| 8886 | "community number\n" |
| 8887 | "Do not send outside local AS (well-known community)\n" |
| 8888 | "Do not advertise to any peer (well-known community)\n" |
| 8889 | "Do not export to next AS (well-known community)\n" |
| 8890 | "community number\n" |
| 8891 | "Do not send outside local AS (well-known community)\n" |
| 8892 | "Do not advertise to any peer (well-known community)\n" |
| 8893 | "Do not export to next AS (well-known community)\n" |
| 8894 | "community number\n" |
| 8895 | "Do not send outside local AS (well-known community)\n" |
| 8896 | "Do not advertise to any peer (well-known community)\n" |
| 8897 | "Do not export to next AS (well-known community)\n" |
| 8898 | "Exact match of the communities") |
| 8899 | |
| 8900 | /* old command */ |
| 8901 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8902 | show_ipv6_mbgp_community4_exact_cmd, |
| 8903 | "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", |
| 8904 | SHOW_STR |
| 8905 | IPV6_STR |
| 8906 | MBGP_STR |
| 8907 | "Display routes matching the communities\n" |
| 8908 | "community number\n" |
| 8909 | "Do not send outside local AS (well-known community)\n" |
| 8910 | "Do not advertise to any peer (well-known community)\n" |
| 8911 | "Do not export to next AS (well-known community)\n" |
| 8912 | "community number\n" |
| 8913 | "Do not send outside local AS (well-known community)\n" |
| 8914 | "Do not advertise to any peer (well-known community)\n" |
| 8915 | "Do not export to next AS (well-known community)\n" |
| 8916 | "community number\n" |
| 8917 | "Do not send outside local AS (well-known community)\n" |
| 8918 | "Do not advertise to any peer (well-known community)\n" |
| 8919 | "Do not export to next AS (well-known community)\n" |
| 8920 | "community number\n" |
| 8921 | "Do not send outside local AS (well-known community)\n" |
| 8922 | "Do not advertise to any peer (well-known community)\n" |
| 8923 | "Do not export to next AS (well-known community)\n" |
| 8924 | "Exact match of the communities") |
| 8925 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 8926 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8927 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8928 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 8929 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8930 | { |
| 8931 | struct community_list *list; |
| 8932 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8933 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8934 | if (list == NULL) |
| 8935 | { |
| 8936 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 8937 | VTY_NEWLINE); |
| 8938 | return CMD_WARNING; |
| 8939 | } |
| 8940 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8941 | return bgp_show (vty, NULL, afi, safi, |
| 8942 | (exact ? bgp_show_type_community_list_exact : |
| 8943 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8944 | } |
| 8945 | |
| 8946 | DEFUN (show_ip_bgp_community_list, |
| 8947 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8948 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8949 | SHOW_STR |
| 8950 | IP_STR |
| 8951 | BGP_STR |
| 8952 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8953 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8954 | "community-list name\n") |
| 8955 | { |
| 8956 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 8957 | } |
| 8958 | |
| 8959 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 8960 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8961 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8962 | SHOW_STR |
| 8963 | IP_STR |
| 8964 | BGP_STR |
| 8965 | "Address family\n" |
| 8966 | "Address Family modifier\n" |
| 8967 | "Address Family modifier\n" |
| 8968 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8969 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8970 | "community-list name\n") |
| 8971 | { |
| 8972 | if (strncmp (argv[0], "m", 1) == 0) |
| 8973 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 8974 | |
| 8975 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 8976 | } |
| 8977 | |
| 8978 | DEFUN (show_ip_bgp_community_list_exact, |
| 8979 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8980 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8981 | SHOW_STR |
| 8982 | IP_STR |
| 8983 | BGP_STR |
| 8984 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8985 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8986 | "community-list name\n" |
| 8987 | "Exact match of the communities\n") |
| 8988 | { |
| 8989 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 8990 | } |
| 8991 | |
| 8992 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 8993 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8994 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8995 | SHOW_STR |
| 8996 | IP_STR |
| 8997 | BGP_STR |
| 8998 | "Address family\n" |
| 8999 | "Address Family modifier\n" |
| 9000 | "Address Family modifier\n" |
| 9001 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9002 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9003 | "community-list name\n" |
| 9004 | "Exact match of the communities\n") |
| 9005 | { |
| 9006 | if (strncmp (argv[0], "m", 1) == 0) |
| 9007 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 9008 | |
| 9009 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 9010 | } |
| 9011 | |
| 9012 | #ifdef HAVE_IPV6 |
| 9013 | DEFUN (show_bgp_community_list, |
| 9014 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9015 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9016 | SHOW_STR |
| 9017 | BGP_STR |
| 9018 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9019 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9020 | "community-list name\n") |
| 9021 | { |
| 9022 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 9023 | } |
| 9024 | |
| 9025 | ALIAS (show_bgp_community_list, |
| 9026 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9027 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9028 | SHOW_STR |
| 9029 | BGP_STR |
| 9030 | "Address family\n" |
| 9031 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9032 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 9033 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9034 | |
| 9035 | /* old command */ |
| 9036 | DEFUN (show_ipv6_bgp_community_list, |
| 9037 | show_ipv6_bgp_community_list_cmd, |
| 9038 | "show ipv6 bgp community-list WORD", |
| 9039 | SHOW_STR |
| 9040 | IPV6_STR |
| 9041 | BGP_STR |
| 9042 | "Display routes matching the community-list\n" |
| 9043 | "community-list name\n") |
| 9044 | { |
| 9045 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 9046 | } |
| 9047 | |
| 9048 | /* old command */ |
| 9049 | DEFUN (show_ipv6_mbgp_community_list, |
| 9050 | show_ipv6_mbgp_community_list_cmd, |
| 9051 | "show ipv6 mbgp community-list WORD", |
| 9052 | SHOW_STR |
| 9053 | IPV6_STR |
| 9054 | MBGP_STR |
| 9055 | "Display routes matching the community-list\n" |
| 9056 | "community-list name\n") |
| 9057 | { |
| 9058 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 9059 | } |
| 9060 | |
| 9061 | DEFUN (show_bgp_community_list_exact, |
| 9062 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9063 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9064 | SHOW_STR |
| 9065 | BGP_STR |
| 9066 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9067 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9068 | "community-list name\n" |
| 9069 | "Exact match of the communities\n") |
| 9070 | { |
| 9071 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9072 | } |
| 9073 | |
| 9074 | ALIAS (show_bgp_community_list_exact, |
| 9075 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9076 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9077 | SHOW_STR |
| 9078 | BGP_STR |
| 9079 | "Address family\n" |
| 9080 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9081 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9082 | "community-list name\n" |
| 9083 | "Exact match of the communities\n") |
| 9084 | |
| 9085 | /* old command */ |
| 9086 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 9087 | show_ipv6_bgp_community_list_exact_cmd, |
| 9088 | "show ipv6 bgp community-list WORD exact-match", |
| 9089 | SHOW_STR |
| 9090 | IPV6_STR |
| 9091 | BGP_STR |
| 9092 | "Display routes matching the community-list\n" |
| 9093 | "community-list name\n" |
| 9094 | "Exact match of the communities\n") |
| 9095 | { |
| 9096 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9097 | } |
| 9098 | |
| 9099 | /* old command */ |
| 9100 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 9101 | show_ipv6_mbgp_community_list_exact_cmd, |
| 9102 | "show ipv6 mbgp community-list WORD exact-match", |
| 9103 | SHOW_STR |
| 9104 | IPV6_STR |
| 9105 | MBGP_STR |
| 9106 | "Display routes matching the community-list\n" |
| 9107 | "community-list name\n" |
| 9108 | "Exact match of the communities\n") |
| 9109 | { |
| 9110 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 9111 | } |
| 9112 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9113 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9114 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9115 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9116 | safi_t safi, enum bgp_show_type type) |
| 9117 | { |
| 9118 | int ret; |
| 9119 | struct prefix *p; |
| 9120 | |
| 9121 | p = prefix_new(); |
| 9122 | |
| 9123 | ret = str2prefix (prefix, p); |
| 9124 | if (! ret) |
| 9125 | { |
| 9126 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 9127 | return CMD_WARNING; |
| 9128 | } |
| 9129 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9130 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 9131 | prefix_free(p); |
| 9132 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9133 | } |
| 9134 | |
| 9135 | DEFUN (show_ip_bgp_prefix_longer, |
| 9136 | show_ip_bgp_prefix_longer_cmd, |
| 9137 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 9138 | SHOW_STR |
| 9139 | IP_STR |
| 9140 | BGP_STR |
| 9141 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9142 | "Display route and more specific routes\n") |
| 9143 | { |
| 9144 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9145 | bgp_show_type_prefix_longer); |
| 9146 | } |
| 9147 | |
| 9148 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 9149 | show_ip_bgp_flap_prefix_longer_cmd, |
| 9150 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 9151 | SHOW_STR |
| 9152 | IP_STR |
| 9153 | BGP_STR |
| 9154 | "Display flap statistics of routes\n" |
| 9155 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9156 | "Display route and more specific routes\n") |
| 9157 | { |
| 9158 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9159 | bgp_show_type_flap_prefix_longer); |
| 9160 | } |
| 9161 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 9162 | ALIAS (show_ip_bgp_flap_prefix_longer, |
| 9163 | show_ip_bgp_damp_flap_prefix_longer_cmd, |
| 9164 | "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes", |
| 9165 | SHOW_STR |
| 9166 | IP_STR |
| 9167 | BGP_STR |
| 9168 | "Display detailed information about dampening\n" |
| 9169 | "Display flap statistics of routes\n" |
| 9170 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9171 | "Display route and more specific routes\n") |
| 9172 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9173 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 9174 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 9175 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 9176 | SHOW_STR |
| 9177 | IP_STR |
| 9178 | BGP_STR |
| 9179 | "Address family\n" |
| 9180 | "Address Family modifier\n" |
| 9181 | "Address Family modifier\n" |
| 9182 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9183 | "Display route and more specific routes\n") |
| 9184 | { |
| 9185 | if (strncmp (argv[0], "m", 1) == 0) |
| 9186 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 9187 | bgp_show_type_prefix_longer); |
| 9188 | |
| 9189 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 9190 | bgp_show_type_prefix_longer); |
| 9191 | } |
| 9192 | |
| 9193 | DEFUN (show_ip_bgp_flap_address, |
| 9194 | show_ip_bgp_flap_address_cmd, |
| 9195 | "show ip bgp flap-statistics A.B.C.D", |
| 9196 | SHOW_STR |
| 9197 | IP_STR |
| 9198 | BGP_STR |
| 9199 | "Display flap statistics of routes\n" |
| 9200 | "Network in the BGP routing table to display\n") |
| 9201 | { |
| 9202 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9203 | bgp_show_type_flap_address); |
| 9204 | } |
| 9205 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 9206 | ALIAS (show_ip_bgp_flap_address, |
| 9207 | show_ip_bgp_damp_flap_address_cmd, |
| 9208 | "show ip bgp dampening flap-statistics A.B.C.D", |
| 9209 | SHOW_STR |
| 9210 | IP_STR |
| 9211 | BGP_STR |
| 9212 | "Display detailed information about dampening\n" |
| 9213 | "Display flap statistics of routes\n" |
| 9214 | "Network in the BGP routing table to display\n") |
| 9215 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9216 | DEFUN (show_ip_bgp_flap_prefix, |
| 9217 | show_ip_bgp_flap_prefix_cmd, |
| 9218 | "show ip bgp flap-statistics A.B.C.D/M", |
| 9219 | SHOW_STR |
| 9220 | IP_STR |
| 9221 | BGP_STR |
| 9222 | "Display flap statistics of routes\n" |
| 9223 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9224 | { |
| 9225 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9226 | bgp_show_type_flap_prefix); |
| 9227 | } |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 9228 | |
| 9229 | ALIAS (show_ip_bgp_flap_prefix, |
| 9230 | show_ip_bgp_damp_flap_prefix_cmd, |
| 9231 | "show ip bgp dampening flap-statistics A.B.C.D/M", |
| 9232 | SHOW_STR |
| 9233 | IP_STR |
| 9234 | BGP_STR |
| 9235 | "Display detailed information about dampening\n" |
| 9236 | "Display flap statistics of routes\n" |
| 9237 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9238 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9239 | #ifdef HAVE_IPV6 |
| 9240 | DEFUN (show_bgp_prefix_longer, |
| 9241 | show_bgp_prefix_longer_cmd, |
| 9242 | "show bgp X:X::X:X/M longer-prefixes", |
| 9243 | SHOW_STR |
| 9244 | BGP_STR |
| 9245 | "IPv6 prefix <network>/<length>\n" |
| 9246 | "Display route and more specific routes\n") |
| 9247 | { |
| 9248 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9249 | bgp_show_type_prefix_longer); |
| 9250 | } |
| 9251 | |
| 9252 | ALIAS (show_bgp_prefix_longer, |
| 9253 | show_bgp_ipv6_prefix_longer_cmd, |
| 9254 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 9255 | SHOW_STR |
| 9256 | BGP_STR |
| 9257 | "Address family\n" |
| 9258 | "IPv6 prefix <network>/<length>\n" |
| 9259 | "Display route and more specific routes\n") |
| 9260 | |
| 9261 | /* old command */ |
| 9262 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 9263 | show_ipv6_bgp_prefix_longer_cmd, |
| 9264 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 9265 | SHOW_STR |
| 9266 | IPV6_STR |
| 9267 | BGP_STR |
| 9268 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9269 | "Display route and more specific routes\n") |
| 9270 | { |
| 9271 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9272 | bgp_show_type_prefix_longer); |
| 9273 | } |
| 9274 | |
| 9275 | /* old command */ |
| 9276 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 9277 | show_ipv6_mbgp_prefix_longer_cmd, |
| 9278 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 9279 | SHOW_STR |
| 9280 | IPV6_STR |
| 9281 | MBGP_STR |
| 9282 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9283 | "Display route and more specific routes\n") |
| 9284 | { |
| 9285 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 9286 | bgp_show_type_prefix_longer); |
| 9287 | } |
| 9288 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9289 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9290 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9291 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 9292 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9293 | { |
| 9294 | int ret; |
| 9295 | struct bgp *bgp; |
| 9296 | struct peer *peer; |
| 9297 | union sockunion su; |
| 9298 | |
| 9299 | /* BGP structure lookup. */ |
| 9300 | if (view_name) |
| 9301 | { |
| 9302 | bgp = bgp_lookup_by_name (view_name); |
| 9303 | if (! bgp) |
| 9304 | { |
| 9305 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9306 | return NULL; |
| 9307 | } |
| 9308 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 9309 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9310 | { |
| 9311 | bgp = bgp_get_default (); |
| 9312 | if (! bgp) |
| 9313 | { |
| 9314 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9315 | return NULL; |
| 9316 | } |
| 9317 | } |
| 9318 | |
| 9319 | /* Get peer sockunion. */ |
| 9320 | ret = str2sockunion (ip_str, &su); |
| 9321 | if (ret < 0) |
| 9322 | { |
| 9323 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 9324 | return NULL; |
| 9325 | } |
| 9326 | |
| 9327 | /* Peer structure lookup. */ |
| 9328 | peer = peer_lookup (bgp, &su); |
| 9329 | if (! peer) |
| 9330 | { |
| 9331 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 9332 | return NULL; |
| 9333 | } |
| 9334 | |
| 9335 | return peer; |
| 9336 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9337 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9338 | enum bgp_stats |
| 9339 | { |
| 9340 | BGP_STATS_MAXBITLEN = 0, |
| 9341 | BGP_STATS_RIB, |
| 9342 | BGP_STATS_PREFIXES, |
| 9343 | BGP_STATS_TOTPLEN, |
| 9344 | BGP_STATS_UNAGGREGATEABLE, |
| 9345 | BGP_STATS_MAX_AGGREGATEABLE, |
| 9346 | BGP_STATS_AGGREGATES, |
| 9347 | BGP_STATS_SPACE, |
| 9348 | BGP_STATS_ASPATH_COUNT, |
| 9349 | BGP_STATS_ASPATH_MAXHOPS, |
| 9350 | BGP_STATS_ASPATH_TOTHOPS, |
| 9351 | BGP_STATS_ASPATH_MAXSIZE, |
| 9352 | BGP_STATS_ASPATH_TOTSIZE, |
| 9353 | BGP_STATS_ASN_HIGHEST, |
| 9354 | BGP_STATS_MAX, |
| 9355 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9356 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9357 | static const char *table_stats_strs[] = |
| 9358 | { |
| 9359 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 9360 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 9361 | [BGP_STATS_RIB] = "Total Advertisements", |
| 9362 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 9363 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 9364 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 9365 | [BGP_STATS_SPACE] = "Address space advertised", |
| 9366 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 9367 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 9368 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 9369 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 9370 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 9371 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 9372 | [BGP_STATS_MAX] = NULL, |
| 9373 | }; |
| 9374 | |
| 9375 | struct bgp_table_stats |
| 9376 | { |
| 9377 | struct bgp_table *table; |
| 9378 | unsigned long long counts[BGP_STATS_MAX]; |
| 9379 | }; |
| 9380 | |
| 9381 | #if 0 |
| 9382 | #define TALLY_SIGFIG 100000 |
| 9383 | static unsigned long |
| 9384 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 9385 | { |
| 9386 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 9387 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 9388 | unsigned long ret = newtot / count; |
| 9389 | |
| 9390 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 9391 | return ret + 1; |
| 9392 | else |
| 9393 | return ret; |
| 9394 | } |
| 9395 | #endif |
| 9396 | |
| 9397 | static int |
| 9398 | bgp_table_stats_walker (struct thread *t) |
| 9399 | { |
| 9400 | struct bgp_node *rn; |
| 9401 | struct bgp_node *top; |
| 9402 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 9403 | unsigned int space = 0; |
| 9404 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 9405 | if (!(top = bgp_table_top (ts->table))) |
| 9406 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9407 | |
| 9408 | switch (top->p.family) |
| 9409 | { |
| 9410 | case AF_INET: |
| 9411 | space = IPV4_MAX_BITLEN; |
| 9412 | break; |
| 9413 | case AF_INET6: |
| 9414 | space = IPV6_MAX_BITLEN; |
| 9415 | break; |
| 9416 | } |
| 9417 | |
| 9418 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 9419 | |
| 9420 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 9421 | { |
| 9422 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9423 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9424 | unsigned int rinum = 0; |
| 9425 | |
| 9426 | if (rn == top) |
| 9427 | continue; |
| 9428 | |
| 9429 | if (!rn->info) |
| 9430 | continue; |
| 9431 | |
| 9432 | ts->counts[BGP_STATS_PREFIXES]++; |
| 9433 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 9434 | |
| 9435 | #if 0 |
| 9436 | ts->counts[BGP_STATS_AVGPLEN] |
| 9437 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 9438 | ts->counts[BGP_STATS_AVGPLEN], |
| 9439 | rn->p.prefixlen); |
| 9440 | #endif |
| 9441 | |
| 9442 | /* check if the prefix is included by any other announcements */ |
| 9443 | while (prn && !prn->info) |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9444 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9445 | |
| 9446 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 9447 | { |
| 9448 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 9449 | /* announced address space */ |
| 9450 | if (space) |
| 9451 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 9452 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9453 | else if (prn->info) |
| 9454 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 9455 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9456 | for (ri = rn->info; ri; ri = ri->next) |
| 9457 | { |
| 9458 | rinum++; |
| 9459 | ts->counts[BGP_STATS_RIB]++; |
| 9460 | |
| 9461 | if (ri->attr && |
| 9462 | (CHECK_FLAG (ri->attr->flag, |
| 9463 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 9464 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 9465 | |
| 9466 | /* as-path stats */ |
| 9467 | if (ri->attr && ri->attr->aspath) |
| 9468 | { |
| 9469 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 9470 | unsigned int size = aspath_size (ri->attr->aspath); |
| 9471 | as_t highest = aspath_highest (ri->attr->aspath); |
| 9472 | |
| 9473 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 9474 | |
| 9475 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 9476 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 9477 | |
| 9478 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 9479 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 9480 | |
| 9481 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 9482 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 9483 | #if 0 |
| 9484 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 9485 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9486 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 9487 | hops); |
| 9488 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 9489 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9490 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 9491 | size); |
| 9492 | #endif |
| 9493 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 9494 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 9495 | } |
| 9496 | } |
| 9497 | } |
| 9498 | return 0; |
| 9499 | } |
| 9500 | |
| 9501 | static int |
| 9502 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 9503 | { |
| 9504 | struct bgp_table_stats ts; |
| 9505 | unsigned int i; |
| 9506 | |
| 9507 | if (!bgp->rib[afi][safi]) |
| 9508 | { |
| 9509 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); |
| 9510 | return CMD_WARNING; |
| 9511 | } |
| 9512 | |
| 9513 | memset (&ts, 0, sizeof (ts)); |
| 9514 | ts.table = bgp->rib[afi][safi]; |
| 9515 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 9516 | |
| 9517 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 9518 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 9519 | |
| 9520 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 9521 | { |
| 9522 | if (!table_stats_strs[i]) |
| 9523 | continue; |
| 9524 | |
| 9525 | switch (i) |
| 9526 | { |
| 9527 | #if 0 |
| 9528 | case BGP_STATS_ASPATH_AVGHOPS: |
| 9529 | case BGP_STATS_ASPATH_AVGSIZE: |
| 9530 | case BGP_STATS_AVGPLEN: |
| 9531 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9532 | vty_out (vty, "%12.2f", |
| 9533 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 9534 | break; |
| 9535 | #endif |
| 9536 | case BGP_STATS_ASPATH_TOTHOPS: |
| 9537 | case BGP_STATS_ASPATH_TOTSIZE: |
| 9538 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9539 | vty_out (vty, "%12.2f", |
| 9540 | ts.counts[i] ? |
| 9541 | (float)ts.counts[i] / |
| 9542 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 9543 | : 0); |
| 9544 | break; |
| 9545 | case BGP_STATS_TOTPLEN: |
| 9546 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9547 | vty_out (vty, "%12.2f", |
| 9548 | ts.counts[i] ? |
| 9549 | (float)ts.counts[i] / |
| 9550 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 9551 | : 0); |
| 9552 | break; |
| 9553 | case BGP_STATS_SPACE: |
| 9554 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9555 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 9556 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 9557 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 9558 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9559 | vty_out (vty, "%12.2f%s", |
| 9560 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 9561 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9562 | VTY_NEWLINE); |
| 9563 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 9564 | vty_out (vty, "%12.2f%s", |
| 9565 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9566 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 9567 | VTY_NEWLINE); |
| 9568 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 9569 | break; |
| 9570 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 9571 | vty_out (vty, "%12.2f", |
| 9572 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9573 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 9574 | break; |
| 9575 | default: |
| 9576 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9577 | vty_out (vty, "%12llu", ts.counts[i]); |
| 9578 | } |
| 9579 | |
| 9580 | vty_out (vty, "%s", VTY_NEWLINE); |
| 9581 | } |
| 9582 | return CMD_SUCCESS; |
| 9583 | } |
| 9584 | |
| 9585 | static int |
| 9586 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 9587 | const char *afi_str, const char *safi_str) |
| 9588 | { |
| 9589 | struct bgp *bgp; |
| 9590 | afi_t afi; |
| 9591 | safi_t safi; |
| 9592 | |
| 9593 | if (name) |
| 9594 | bgp = bgp_lookup_by_name (name); |
| 9595 | else |
| 9596 | bgp = bgp_get_default (); |
| 9597 | |
| 9598 | if (!bgp) |
| 9599 | { |
| 9600 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); |
| 9601 | return CMD_WARNING; |
| 9602 | } |
| 9603 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 9604 | { |
| 9605 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 9606 | afi = AFI_IP; |
| 9607 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 9608 | afi = AFI_IP6; |
| 9609 | else |
| 9610 | { |
| 9611 | vty_out (vty, "%% Invalid address family %s%s", |
| 9612 | afi_str, VTY_NEWLINE); |
| 9613 | return CMD_WARNING; |
| 9614 | } |
| 9615 | if (strncmp (safi_str, "m", 1) == 0) |
| 9616 | safi = SAFI_MULTICAST; |
| 9617 | else if (strncmp (safi_str, "u", 1) == 0) |
| 9618 | safi = SAFI_UNICAST; |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 9619 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
| 9620 | safi = SAFI_MPLS_LABELED_VPN; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9621 | else |
| 9622 | { |
| 9623 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
| 9624 | safi_str, VTY_NEWLINE); |
| 9625 | return CMD_WARNING; |
| 9626 | } |
| 9627 | } |
| 9628 | else |
| 9629 | { |
| 9630 | vty_out (vty, "%% Invalid address family %s%s", |
| 9631 | afi_str, VTY_NEWLINE); |
| 9632 | return CMD_WARNING; |
| 9633 | } |
| 9634 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9635 | return bgp_table_stats (vty, bgp, afi, safi); |
| 9636 | } |
| 9637 | |
| 9638 | DEFUN (show_bgp_statistics, |
| 9639 | show_bgp_statistics_cmd, |
| 9640 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", |
| 9641 | SHOW_STR |
| 9642 | BGP_STR |
| 9643 | "Address family\n" |
| 9644 | "Address family\n" |
| 9645 | "Address Family modifier\n" |
| 9646 | "Address Family modifier\n" |
| 9647 | "BGP RIB advertisement statistics\n") |
| 9648 | { |
| 9649 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9650 | } |
| 9651 | |
| 9652 | ALIAS (show_bgp_statistics, |
| 9653 | show_bgp_statistics_vpnv4_cmd, |
| 9654 | "show bgp (ipv4) (vpnv4) statistics", |
| 9655 | SHOW_STR |
| 9656 | BGP_STR |
| 9657 | "Address family\n" |
| 9658 | "Address Family modifier\n" |
| 9659 | "BGP RIB advertisement statistics\n") |
| 9660 | |
| 9661 | DEFUN (show_bgp_statistics_view, |
| 9662 | show_bgp_statistics_view_cmd, |
| 9663 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", |
| 9664 | SHOW_STR |
| 9665 | BGP_STR |
| 9666 | "BGP view\n" |
| 9667 | "Address family\n" |
| 9668 | "Address family\n" |
| 9669 | "Address Family modifier\n" |
| 9670 | "Address Family modifier\n" |
| 9671 | "BGP RIB advertisement statistics\n") |
| 9672 | { |
| 9673 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9674 | } |
| 9675 | |
| 9676 | ALIAS (show_bgp_statistics_view, |
| 9677 | show_bgp_statistics_view_vpnv4_cmd, |
| 9678 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
| 9679 | SHOW_STR |
| 9680 | BGP_STR |
| 9681 | "BGP view\n" |
| 9682 | "Address family\n" |
| 9683 | "Address Family modifier\n" |
| 9684 | "BGP RIB advertisement statistics\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9685 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9686 | enum bgp_pcounts |
| 9687 | { |
| 9688 | PCOUNT_ADJ_IN = 0, |
| 9689 | PCOUNT_DAMPED, |
| 9690 | PCOUNT_REMOVED, |
| 9691 | PCOUNT_HISTORY, |
| 9692 | PCOUNT_STALE, |
| 9693 | PCOUNT_VALID, |
| 9694 | PCOUNT_ALL, |
| 9695 | PCOUNT_COUNTED, |
| 9696 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 9697 | PCOUNT_MAX, |
| 9698 | }; |
| 9699 | |
| 9700 | static const char *pcount_strs[] = |
| 9701 | { |
| 9702 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 9703 | [PCOUNT_DAMPED] = "Damped", |
| 9704 | [PCOUNT_REMOVED] = "Removed", |
| 9705 | [PCOUNT_HISTORY] = "History", |
| 9706 | [PCOUNT_STALE] = "Stale", |
| 9707 | [PCOUNT_VALID] = "Valid", |
| 9708 | [PCOUNT_ALL] = "All RIB", |
| 9709 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 9710 | [PCOUNT_PFCNT] = "Useable", |
| 9711 | [PCOUNT_MAX] = NULL, |
| 9712 | }; |
| 9713 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9714 | struct peer_pcounts |
| 9715 | { |
| 9716 | unsigned int count[PCOUNT_MAX]; |
| 9717 | const struct peer *peer; |
| 9718 | const struct bgp_table *table; |
| 9719 | }; |
| 9720 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9721 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9722 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9723 | { |
| 9724 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9725 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 9726 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9727 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9728 | 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] | 9729 | { |
| 9730 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9731 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9732 | |
| 9733 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9734 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9735 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9736 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9737 | for (ri = rn->info; ri; ri = ri->next) |
| 9738 | { |
| 9739 | char buf[SU_ADDRSTRLEN]; |
| 9740 | |
| 9741 | if (ri->peer != peer) |
| 9742 | continue; |
| 9743 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9744 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9745 | |
| 9746 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9747 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9748 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9749 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9750 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9751 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9752 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9753 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9754 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9755 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9756 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9757 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9758 | |
| 9759 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 9760 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9761 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9762 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9763 | plog_warn (peer->log, |
| 9764 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 9765 | peer->host, |
| 9766 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9767 | buf, SU_ADDRSTRLEN), |
| 9768 | rn->p.prefixlen, |
| 9769 | ri->flags); |
| 9770 | } |
| 9771 | else |
| 9772 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9773 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9774 | plog_warn (peer->log, |
| 9775 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 9776 | peer->host, |
| 9777 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9778 | buf, SU_ADDRSTRLEN), |
| 9779 | rn->p.prefixlen, |
| 9780 | ri->flags); |
| 9781 | } |
| 9782 | } |
| 9783 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9784 | return 0; |
| 9785 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9786 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9787 | static int |
| 9788 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 9789 | { |
| 9790 | struct peer_pcounts pcounts = { .peer = peer }; |
| 9791 | unsigned int i; |
| 9792 | |
| 9793 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 9794 | || !peer->bgp->rib[afi][safi]) |
| 9795 | { |
| 9796 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9797 | return CMD_WARNING; |
| 9798 | } |
| 9799 | |
| 9800 | memset (&pcounts, 0, sizeof(pcounts)); |
| 9801 | pcounts.peer = peer; |
| 9802 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 9803 | |
| 9804 | /* in-place call via thread subsystem so as to record execution time |
| 9805 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 9806 | * on just vty_read()). |
| 9807 | */ |
| 9808 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 9809 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9810 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 9811 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 9812 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 9813 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 9814 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 9815 | |
| 9816 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9817 | vty_out (vty, "%20s: %-10d%s", |
| 9818 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9819 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9820 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9821 | { |
| 9822 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 9823 | peer->host, VTY_NEWLINE); |
| 9824 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 9825 | VTY_NEWLINE); |
| 9826 | } |
| 9827 | |
| 9828 | return CMD_SUCCESS; |
| 9829 | } |
| 9830 | |
| 9831 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 9832 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 9833 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9834 | SHOW_STR |
| 9835 | IP_STR |
| 9836 | BGP_STR |
| 9837 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9838 | "Neighbor to display information about\n" |
| 9839 | "Neighbor to display information about\n" |
| 9840 | "Display detailed prefix count information\n") |
| 9841 | { |
| 9842 | struct peer *peer; |
| 9843 | |
| 9844 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9845 | if (! peer) |
| 9846 | return CMD_WARNING; |
| 9847 | |
| 9848 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9849 | } |
| 9850 | |
| 9851 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 9852 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 9853 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9854 | SHOW_STR |
| 9855 | BGP_STR |
| 9856 | "Address family\n" |
| 9857 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9858 | "Neighbor to display information about\n" |
| 9859 | "Neighbor to display information about\n" |
| 9860 | "Display detailed prefix count information\n") |
| 9861 | { |
| 9862 | struct peer *peer; |
| 9863 | |
| 9864 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9865 | if (! peer) |
| 9866 | return CMD_WARNING; |
| 9867 | |
| 9868 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 9869 | } |
| 9870 | |
| 9871 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 9872 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 9873 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9874 | SHOW_STR |
| 9875 | IP_STR |
| 9876 | BGP_STR |
| 9877 | "Address family\n" |
| 9878 | "Address Family modifier\n" |
| 9879 | "Address Family modifier\n" |
| 9880 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9881 | "Neighbor to display information about\n" |
| 9882 | "Neighbor to display information about\n" |
| 9883 | "Display detailed prefix count information\n") |
| 9884 | { |
| 9885 | struct peer *peer; |
| 9886 | |
| 9887 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9888 | if (! peer) |
| 9889 | return CMD_WARNING; |
| 9890 | |
| 9891 | if (strncmp (argv[0], "m", 1) == 0) |
| 9892 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 9893 | |
| 9894 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9895 | } |
| 9896 | |
| 9897 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 9898 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 9899 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9900 | SHOW_STR |
| 9901 | IP_STR |
| 9902 | BGP_STR |
| 9903 | "Address family\n" |
| 9904 | "Address Family modifier\n" |
| 9905 | "Address Family modifier\n" |
| 9906 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9907 | "Neighbor to display information about\n" |
| 9908 | "Neighbor to display information about\n" |
| 9909 | "Display detailed prefix count information\n") |
| 9910 | { |
| 9911 | struct peer *peer; |
| 9912 | |
| 9913 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9914 | if (! peer) |
| 9915 | return CMD_WARNING; |
| 9916 | |
| 9917 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 9918 | } |
| 9919 | |
| 9920 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9921 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9922 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 9923 | int in) |
| 9924 | { |
| 9925 | struct bgp_table *table; |
| 9926 | struct bgp_adj_in *ain; |
| 9927 | struct bgp_adj_out *adj; |
| 9928 | unsigned long output_count; |
| 9929 | struct bgp_node *rn; |
| 9930 | int header1 = 1; |
| 9931 | struct bgp *bgp; |
| 9932 | int header2 = 1; |
| 9933 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9934 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9935 | |
| 9936 | if (! bgp) |
| 9937 | return; |
| 9938 | |
| 9939 | table = bgp->rib[afi][safi]; |
| 9940 | |
| 9941 | output_count = 0; |
| 9942 | |
| 9943 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 9944 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 9945 | { |
| 9946 | 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] | 9947 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9948 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9949 | |
| 9950 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 9951 | VTY_NEWLINE, VTY_NEWLINE); |
| 9952 | header1 = 0; |
| 9953 | } |
| 9954 | |
| 9955 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 9956 | if (in) |
| 9957 | { |
| 9958 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9959 | if (ain->peer == peer) |
| 9960 | { |
| 9961 | if (header1) |
| 9962 | { |
| 9963 | 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] | 9964 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9965 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9966 | header1 = 0; |
| 9967 | } |
| 9968 | if (header2) |
| 9969 | { |
| 9970 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9971 | header2 = 0; |
| 9972 | } |
| 9973 | if (ain->attr) |
| 9974 | { |
| 9975 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 9976 | output_count++; |
| 9977 | } |
| 9978 | } |
| 9979 | } |
| 9980 | else |
| 9981 | { |
| 9982 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 9983 | if (adj->peer == peer) |
| 9984 | { |
| 9985 | if (header1) |
| 9986 | { |
| 9987 | 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] | 9988 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9989 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9990 | header1 = 0; |
| 9991 | } |
| 9992 | if (header2) |
| 9993 | { |
| 9994 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9995 | header2 = 0; |
| 9996 | } |
| 9997 | if (adj->attr) |
| 9998 | { |
| 9999 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 10000 | output_count++; |
| 10001 | } |
| 10002 | } |
| 10003 | } |
| 10004 | |
| 10005 | if (output_count != 0) |
| 10006 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 10007 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 10008 | } |
| 10009 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10010 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10011 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 10012 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10013 | if (! peer || ! peer->afc[afi][safi]) |
| 10014 | { |
| 10015 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 10016 | return CMD_WARNING; |
| 10017 | } |
| 10018 | |
| 10019 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 10020 | { |
| 10021 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 10022 | VTY_NEWLINE); |
| 10023 | return CMD_WARNING; |
| 10024 | } |
| 10025 | |
| 10026 | show_adj_route (vty, peer, afi, safi, in); |
| 10027 | |
| 10028 | return CMD_SUCCESS; |
| 10029 | } |
| 10030 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10031 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 10032 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 10033 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10034 | SHOW_STR |
| 10035 | IP_STR |
| 10036 | BGP_STR |
| 10037 | "BGP view\n" |
| 10038 | "View name\n" |
| 10039 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10040 | "Neighbor to display information about\n" |
| 10041 | "Neighbor to display information about\n" |
| 10042 | "Display the routes advertised to a BGP neighbor\n") |
| 10043 | { |
| 10044 | struct peer *peer; |
| 10045 | |
| 10046 | if (argc == 2) |
| 10047 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10048 | else |
| 10049 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10050 | |
| 10051 | if (! peer) |
| 10052 | return CMD_WARNING; |
| 10053 | |
| 10054 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 10055 | } |
| 10056 | |
| 10057 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10058 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 10059 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10060 | SHOW_STR |
| 10061 | IP_STR |
| 10062 | BGP_STR |
| 10063 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10064 | "Neighbor to display information about\n" |
| 10065 | "Neighbor to display information about\n" |
| 10066 | "Display the routes advertised to a BGP neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10067 | |
| 10068 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 10069 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 10070 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10071 | SHOW_STR |
| 10072 | IP_STR |
| 10073 | BGP_STR |
| 10074 | "Address family\n" |
| 10075 | "Address Family modifier\n" |
| 10076 | "Address Family modifier\n" |
| 10077 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10078 | "Neighbor to display information about\n" |
| 10079 | "Neighbor to display information about\n" |
| 10080 | "Display the routes advertised to a BGP neighbor\n") |
| 10081 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10082 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10083 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10084 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10085 | if (! peer) |
| 10086 | return CMD_WARNING; |
| 10087 | |
| 10088 | if (strncmp (argv[0], "m", 1) == 0) |
| 10089 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 10090 | |
| 10091 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10092 | } |
| 10093 | |
| 10094 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10095 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 10096 | show_bgp_view_neighbor_advertised_route_cmd, |
| 10097 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10098 | SHOW_STR |
| 10099 | BGP_STR |
| 10100 | "BGP view\n" |
| 10101 | "View name\n" |
| 10102 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10103 | "Neighbor to display information about\n" |
| 10104 | "Neighbor to display information about\n" |
| 10105 | "Display the routes advertised to a BGP neighbor\n") |
| 10106 | { |
| 10107 | struct peer *peer; |
| 10108 | |
| 10109 | if (argc == 2) |
| 10110 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10111 | else |
| 10112 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10113 | |
| 10114 | if (! peer) |
| 10115 | return CMD_WARNING; |
| 10116 | |
| 10117 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 10118 | } |
| 10119 | |
| 10120 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 10121 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 10122 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10123 | SHOW_STR |
| 10124 | BGP_STR |
| 10125 | "BGP view\n" |
| 10126 | "View name\n" |
| 10127 | "Address family\n" |
| 10128 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10129 | "Neighbor to display information about\n" |
| 10130 | "Neighbor to display information about\n" |
| 10131 | "Display the routes advertised to a BGP neighbor\n") |
| 10132 | |
| 10133 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 10134 | show_bgp_view_neighbor_received_routes_cmd, |
| 10135 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10136 | SHOW_STR |
| 10137 | BGP_STR |
| 10138 | "BGP view\n" |
| 10139 | "View name\n" |
| 10140 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10141 | "Neighbor to display information about\n" |
| 10142 | "Neighbor to display information about\n" |
| 10143 | "Display the received routes from neighbor\n") |
| 10144 | { |
| 10145 | struct peer *peer; |
| 10146 | |
| 10147 | if (argc == 2) |
| 10148 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10149 | else |
| 10150 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10151 | |
| 10152 | if (! peer) |
| 10153 | return CMD_WARNING; |
| 10154 | |
| 10155 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 10156 | } |
| 10157 | |
| 10158 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 10159 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 10160 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10161 | SHOW_STR |
| 10162 | BGP_STR |
| 10163 | "BGP view\n" |
| 10164 | "View name\n" |
| 10165 | "Address family\n" |
| 10166 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10167 | "Neighbor to display information about\n" |
| 10168 | "Neighbor to display information about\n" |
| 10169 | "Display the received routes from neighbor\n") |
| 10170 | |
| 10171 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10172 | show_bgp_neighbor_advertised_route_cmd, |
| 10173 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10174 | SHOW_STR |
| 10175 | BGP_STR |
| 10176 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10177 | "Neighbor to display information about\n" |
| 10178 | "Neighbor to display information about\n" |
| 10179 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10180 | |
| 10181 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10182 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 10183 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10184 | SHOW_STR |
| 10185 | BGP_STR |
| 10186 | "Address family\n" |
| 10187 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10188 | "Neighbor to display information about\n" |
| 10189 | "Neighbor to display information about\n" |
| 10190 | "Display the routes advertised to a BGP neighbor\n") |
| 10191 | |
| 10192 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10193 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10194 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 10195 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10196 | SHOW_STR |
| 10197 | IPV6_STR |
| 10198 | BGP_STR |
| 10199 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10200 | "Neighbor to display information about\n" |
| 10201 | "Neighbor to display information about\n" |
| 10202 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10203 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10204 | /* old command */ |
| 10205 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 10206 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 10207 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10208 | SHOW_STR |
| 10209 | IPV6_STR |
| 10210 | MBGP_STR |
| 10211 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10212 | "Neighbor to display information about\n" |
| 10213 | "Neighbor to display information about\n" |
| 10214 | "Display the routes advertised to a BGP neighbor\n") |
| 10215 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10216 | struct peer *peer; |
| 10217 | |
| 10218 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10219 | if (! peer) |
| 10220 | return CMD_WARNING; |
| 10221 | |
| 10222 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10223 | } |
| 10224 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 10225 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10226 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 10227 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 10228 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10229 | SHOW_STR |
| 10230 | IP_STR |
| 10231 | BGP_STR |
| 10232 | "BGP view\n" |
| 10233 | "View name\n" |
| 10234 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10235 | "Neighbor to display information about\n" |
| 10236 | "Neighbor to display information about\n" |
| 10237 | "Display the received routes from neighbor\n") |
| 10238 | { |
| 10239 | struct peer *peer; |
| 10240 | |
| 10241 | if (argc == 2) |
| 10242 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10243 | else |
| 10244 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10245 | |
| 10246 | if (! peer) |
| 10247 | return CMD_WARNING; |
| 10248 | |
| 10249 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 10250 | } |
| 10251 | |
| 10252 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10253 | show_ip_bgp_neighbor_received_routes_cmd, |
| 10254 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10255 | SHOW_STR |
| 10256 | IP_STR |
| 10257 | BGP_STR |
| 10258 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10259 | "Neighbor to display information about\n" |
| 10260 | "Neighbor to display information about\n" |
| 10261 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10262 | |
| 10263 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 10264 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 10265 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10266 | SHOW_STR |
| 10267 | IP_STR |
| 10268 | BGP_STR |
| 10269 | "Address family\n" |
| 10270 | "Address Family modifier\n" |
| 10271 | "Address Family modifier\n" |
| 10272 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10273 | "Neighbor to display information about\n" |
| 10274 | "Neighbor to display information about\n" |
| 10275 | "Display the received routes from neighbor\n") |
| 10276 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10277 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10278 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10279 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10280 | if (! peer) |
| 10281 | return CMD_WARNING; |
| 10282 | |
| 10283 | if (strncmp (argv[0], "m", 1) == 0) |
| 10284 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 10285 | |
| 10286 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10287 | } |
| 10288 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10289 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 10290 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10291 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10292 | SHOW_STR |
| 10293 | BGP_STR |
| 10294 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10295 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10296 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10297 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10298 | "Address family modifier\n" |
| 10299 | "Address family modifier\n" |
| 10300 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10301 | "Neighbor to display information about\n" |
| 10302 | "Neighbor to display information about\n" |
| 10303 | "Display the advertised routes to neighbor\n" |
| 10304 | "Display the received routes from neighbor\n") |
| 10305 | { |
| 10306 | int afi; |
| 10307 | int safi; |
| 10308 | int in; |
| 10309 | struct peer *peer; |
| 10310 | |
David Lamparter | 94bad67 | 2015-03-03 08:52:22 +0100 | [diff] [blame] | 10311 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10312 | |
| 10313 | if (! peer) |
| 10314 | return CMD_WARNING; |
| 10315 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10316 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10317 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10318 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10319 | |
| 10320 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 10321 | } |
| 10322 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10323 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 10324 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 10325 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10326 | SHOW_STR |
| 10327 | IP_STR |
| 10328 | BGP_STR |
| 10329 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10330 | "Neighbor to display information about\n" |
| 10331 | "Neighbor to display information about\n" |
| 10332 | "Display information received from a BGP neighbor\n" |
| 10333 | "Display the prefixlist filter\n") |
| 10334 | { |
| 10335 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10336 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10337 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10338 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10339 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10340 | ret = str2sockunion (argv[0], &su); |
| 10341 | if (ret < 0) |
| 10342 | { |
| 10343 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10344 | return CMD_WARNING; |
| 10345 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10346 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10347 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10348 | if (! peer) |
| 10349 | return CMD_WARNING; |
| 10350 | |
| 10351 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10352 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10353 | if (count) |
| 10354 | { |
| 10355 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10356 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10357 | } |
| 10358 | |
| 10359 | return CMD_SUCCESS; |
| 10360 | } |
| 10361 | |
| 10362 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 10363 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 10364 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10365 | SHOW_STR |
| 10366 | IP_STR |
| 10367 | BGP_STR |
| 10368 | "Address family\n" |
| 10369 | "Address Family modifier\n" |
| 10370 | "Address Family modifier\n" |
| 10371 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10372 | "Neighbor to display information about\n" |
| 10373 | "Neighbor to display information about\n" |
| 10374 | "Display information received from a BGP neighbor\n" |
| 10375 | "Display the prefixlist filter\n") |
| 10376 | { |
| 10377 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10378 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10379 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10380 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10381 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10382 | ret = str2sockunion (argv[1], &su); |
| 10383 | if (ret < 0) |
| 10384 | { |
| 10385 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10386 | return CMD_WARNING; |
| 10387 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10388 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10389 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10390 | if (! peer) |
| 10391 | return CMD_WARNING; |
| 10392 | |
| 10393 | if (strncmp (argv[0], "m", 1) == 0) |
| 10394 | { |
| 10395 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 10396 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10397 | if (count) |
| 10398 | { |
| 10399 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 10400 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10401 | } |
| 10402 | } |
| 10403 | else |
| 10404 | { |
| 10405 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10406 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10407 | if (count) |
| 10408 | { |
| 10409 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10410 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10411 | } |
| 10412 | } |
| 10413 | |
| 10414 | return CMD_SUCCESS; |
| 10415 | } |
| 10416 | |
| 10417 | |
| 10418 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10419 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10420 | show_bgp_neighbor_received_routes_cmd, |
| 10421 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10422 | SHOW_STR |
| 10423 | BGP_STR |
| 10424 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10425 | "Neighbor to display information about\n" |
| 10426 | "Neighbor to display information about\n" |
| 10427 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10428 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10429 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10430 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 10431 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10432 | SHOW_STR |
| 10433 | BGP_STR |
| 10434 | "Address family\n" |
| 10435 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10436 | "Neighbor to display information about\n" |
| 10437 | "Neighbor to display information about\n" |
| 10438 | "Display the received routes from neighbor\n") |
| 10439 | |
| 10440 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 10441 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 10442 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10443 | SHOW_STR |
| 10444 | BGP_STR |
| 10445 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10446 | "Neighbor to display information about\n" |
| 10447 | "Neighbor to display information about\n" |
| 10448 | "Display information received from a BGP neighbor\n" |
| 10449 | "Display the prefixlist filter\n") |
| 10450 | { |
| 10451 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10452 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10453 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10454 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10455 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10456 | ret = str2sockunion (argv[0], &su); |
| 10457 | if (ret < 0) |
| 10458 | { |
| 10459 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10460 | return CMD_WARNING; |
| 10461 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10462 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10463 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10464 | if (! peer) |
| 10465 | return CMD_WARNING; |
| 10466 | |
| 10467 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10468 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10469 | if (count) |
| 10470 | { |
| 10471 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10472 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10473 | } |
| 10474 | |
| 10475 | return CMD_SUCCESS; |
| 10476 | } |
| 10477 | |
| 10478 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 10479 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 10480 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10481 | SHOW_STR |
| 10482 | BGP_STR |
| 10483 | "Address family\n" |
| 10484 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10485 | "Neighbor to display information about\n" |
| 10486 | "Neighbor to display information about\n" |
| 10487 | "Display information received from a BGP neighbor\n" |
| 10488 | "Display the prefixlist filter\n") |
| 10489 | |
| 10490 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10491 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10492 | ipv6_bgp_neighbor_received_routes_cmd, |
| 10493 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10494 | SHOW_STR |
| 10495 | IPV6_STR |
| 10496 | BGP_STR |
| 10497 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10498 | "Neighbor to display information about\n" |
| 10499 | "Neighbor to display information about\n" |
| 10500 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10501 | |
| 10502 | /* old command */ |
| 10503 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 10504 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 10505 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10506 | SHOW_STR |
| 10507 | IPV6_STR |
| 10508 | MBGP_STR |
| 10509 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10510 | "Neighbor to display information about\n" |
| 10511 | "Neighbor to display information about\n" |
| 10512 | "Display the received routes from neighbor\n") |
| 10513 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10514 | struct peer *peer; |
| 10515 | |
| 10516 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10517 | if (! peer) |
| 10518 | return CMD_WARNING; |
| 10519 | |
| 10520 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10521 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10522 | |
| 10523 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 10524 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 10525 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10526 | SHOW_STR |
| 10527 | BGP_STR |
| 10528 | "BGP view\n" |
| 10529 | "View name\n" |
| 10530 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10531 | "Neighbor to display information about\n" |
| 10532 | "Neighbor to display information about\n" |
| 10533 | "Display information received from a BGP neighbor\n" |
| 10534 | "Display the prefixlist filter\n") |
| 10535 | { |
| 10536 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10537 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10538 | struct peer *peer; |
| 10539 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10540 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10541 | |
| 10542 | /* BGP structure lookup. */ |
| 10543 | bgp = bgp_lookup_by_name (argv[0]); |
| 10544 | if (bgp == NULL) |
| 10545 | { |
| 10546 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10547 | return CMD_WARNING; |
| 10548 | } |
| 10549 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10550 | ret = str2sockunion (argv[1], &su); |
| 10551 | if (ret < 0) |
| 10552 | { |
| 10553 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10554 | return CMD_WARNING; |
| 10555 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10556 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10557 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10558 | if (! peer) |
| 10559 | return CMD_WARNING; |
| 10560 | |
| 10561 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10562 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10563 | if (count) |
| 10564 | { |
| 10565 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10566 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10567 | } |
| 10568 | |
| 10569 | return CMD_SUCCESS; |
| 10570 | } |
| 10571 | |
| 10572 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 10573 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 10574 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10575 | SHOW_STR |
| 10576 | BGP_STR |
| 10577 | "BGP view\n" |
| 10578 | "View name\n" |
| 10579 | "Address family\n" |
| 10580 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10581 | "Neighbor to display information about\n" |
| 10582 | "Neighbor to display information about\n" |
| 10583 | "Display information received from a BGP neighbor\n" |
| 10584 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10585 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 10586 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10587 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10588 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10589 | safi_t safi, enum bgp_show_type type) |
| 10590 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10591 | if (! peer || ! peer->afc[afi][safi]) |
| 10592 | { |
| 10593 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10594 | return CMD_WARNING; |
| 10595 | } |
| 10596 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10597 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10598 | } |
| 10599 | |
| 10600 | DEFUN (show_ip_bgp_neighbor_routes, |
| 10601 | show_ip_bgp_neighbor_routes_cmd, |
| 10602 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10603 | SHOW_STR |
| 10604 | IP_STR |
| 10605 | BGP_STR |
| 10606 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10607 | "Neighbor to display information about\n" |
| 10608 | "Neighbor to display information about\n" |
| 10609 | "Display routes learned from neighbor\n") |
| 10610 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10611 | struct peer *peer; |
| 10612 | |
| 10613 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10614 | if (! peer) |
| 10615 | return CMD_WARNING; |
| 10616 | |
| 10617 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10618 | bgp_show_type_neighbor); |
| 10619 | } |
| 10620 | |
| 10621 | DEFUN (show_ip_bgp_neighbor_flap, |
| 10622 | show_ip_bgp_neighbor_flap_cmd, |
| 10623 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10624 | SHOW_STR |
| 10625 | IP_STR |
| 10626 | BGP_STR |
| 10627 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10628 | "Neighbor to display information about\n" |
| 10629 | "Neighbor to display information about\n" |
| 10630 | "Display flap statistics of the routes learned from neighbor\n") |
| 10631 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10632 | struct peer *peer; |
| 10633 | |
| 10634 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10635 | if (! peer) |
| 10636 | return CMD_WARNING; |
| 10637 | |
| 10638 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10639 | bgp_show_type_flap_neighbor); |
| 10640 | } |
| 10641 | |
| 10642 | DEFUN (show_ip_bgp_neighbor_damp, |
| 10643 | show_ip_bgp_neighbor_damp_cmd, |
| 10644 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10645 | SHOW_STR |
| 10646 | IP_STR |
| 10647 | BGP_STR |
| 10648 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10649 | "Neighbor to display information about\n" |
| 10650 | "Neighbor to display information about\n" |
| 10651 | "Display the dampened routes received from neighbor\n") |
| 10652 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10653 | struct peer *peer; |
| 10654 | |
| 10655 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10656 | if (! peer) |
| 10657 | return CMD_WARNING; |
| 10658 | |
| 10659 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10660 | bgp_show_type_damp_neighbor); |
| 10661 | } |
| 10662 | |
| 10663 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 10664 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 10665 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 10666 | SHOW_STR |
| 10667 | IP_STR |
| 10668 | BGP_STR |
| 10669 | "Address family\n" |
| 10670 | "Address Family modifier\n" |
| 10671 | "Address Family modifier\n" |
| 10672 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10673 | "Neighbor to display information about\n" |
| 10674 | "Neighbor to display information about\n" |
| 10675 | "Display routes learned from neighbor\n") |
| 10676 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10677 | struct peer *peer; |
| 10678 | |
| 10679 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10680 | if (! peer) |
| 10681 | return CMD_WARNING; |
| 10682 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10683 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10684 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10685 | bgp_show_type_neighbor); |
| 10686 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10687 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10688 | bgp_show_type_neighbor); |
| 10689 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10690 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10691 | DEFUN (show_ip_bgp_view_rsclient, |
| 10692 | show_ip_bgp_view_rsclient_cmd, |
| 10693 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 10694 | SHOW_STR |
| 10695 | IP_STR |
| 10696 | BGP_STR |
| 10697 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10698 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10699 | "Information about Route Server Client\n" |
| 10700 | NEIGHBOR_ADDR_STR) |
| 10701 | { |
| 10702 | struct bgp_table *table; |
| 10703 | struct peer *peer; |
| 10704 | |
| 10705 | if (argc == 2) |
| 10706 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10707 | else |
| 10708 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10709 | |
| 10710 | if (! peer) |
| 10711 | return CMD_WARNING; |
| 10712 | |
| 10713 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10714 | { |
| 10715 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10716 | VTY_NEWLINE); |
| 10717 | return CMD_WARNING; |
| 10718 | } |
| 10719 | |
| 10720 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10721 | PEER_FLAG_RSERVER_CLIENT)) |
| 10722 | { |
| 10723 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10724 | VTY_NEWLINE); |
| 10725 | return CMD_WARNING; |
| 10726 | } |
| 10727 | |
| 10728 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 10729 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10730 | 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] | 10731 | } |
| 10732 | |
| 10733 | ALIAS (show_ip_bgp_view_rsclient, |
| 10734 | show_ip_bgp_rsclient_cmd, |
| 10735 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 10736 | SHOW_STR |
| 10737 | IP_STR |
| 10738 | BGP_STR |
| 10739 | "Information about Route Server Client\n" |
| 10740 | NEIGHBOR_ADDR_STR) |
| 10741 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10742 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 10743 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 10744 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10745 | SHOW_STR |
| 10746 | BGP_STR |
| 10747 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10748 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10749 | "Address family\n" |
| 10750 | "Address Family modifier\n" |
| 10751 | "Address Family modifier\n" |
| 10752 | "Information about Route Server Client\n" |
| 10753 | NEIGHBOR_ADDR_STR) |
| 10754 | { |
| 10755 | struct bgp_table *table; |
| 10756 | struct peer *peer; |
| 10757 | safi_t safi; |
| 10758 | |
| 10759 | if (argc == 3) { |
| 10760 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10761 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10762 | } else { |
| 10763 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10764 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10765 | } |
| 10766 | |
| 10767 | if (! peer) |
| 10768 | return CMD_WARNING; |
| 10769 | |
| 10770 | if (! peer->afc[AFI_IP][safi]) |
| 10771 | { |
| 10772 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10773 | VTY_NEWLINE); |
| 10774 | return CMD_WARNING; |
| 10775 | } |
| 10776 | |
| 10777 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10778 | PEER_FLAG_RSERVER_CLIENT)) |
| 10779 | { |
| 10780 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10781 | VTY_NEWLINE); |
| 10782 | return CMD_WARNING; |
| 10783 | } |
| 10784 | |
| 10785 | table = peer->rib[AFI_IP][safi]; |
| 10786 | |
| 10787 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 10788 | } |
| 10789 | |
| 10790 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 10791 | show_bgp_ipv4_safi_rsclient_cmd, |
| 10792 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10793 | SHOW_STR |
| 10794 | BGP_STR |
| 10795 | "Address family\n" |
| 10796 | "Address Family modifier\n" |
| 10797 | "Address Family modifier\n" |
| 10798 | "Information about Route Server Client\n" |
| 10799 | NEIGHBOR_ADDR_STR) |
| 10800 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10801 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 10802 | show_ip_bgp_view_rsclient_route_cmd, |
Michael Lambert | a8bf6f5 | 2008-09-24 17:23:11 +0100 | [diff] [blame] | 10803 | "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] | 10804 | SHOW_STR |
| 10805 | IP_STR |
| 10806 | BGP_STR |
| 10807 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10808 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10809 | "Information about Route Server Client\n" |
| 10810 | NEIGHBOR_ADDR_STR |
| 10811 | "Network in the BGP routing table to display\n") |
| 10812 | { |
| 10813 | struct bgp *bgp; |
| 10814 | struct peer *peer; |
| 10815 | |
| 10816 | /* BGP structure lookup. */ |
| 10817 | if (argc == 3) |
| 10818 | { |
| 10819 | bgp = bgp_lookup_by_name (argv[0]); |
| 10820 | if (bgp == NULL) |
| 10821 | { |
| 10822 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10823 | return CMD_WARNING; |
| 10824 | } |
| 10825 | } |
| 10826 | else |
| 10827 | { |
| 10828 | bgp = bgp_get_default (); |
| 10829 | if (bgp == NULL) |
| 10830 | { |
| 10831 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10832 | return CMD_WARNING; |
| 10833 | } |
| 10834 | } |
| 10835 | |
| 10836 | if (argc == 3) |
| 10837 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10838 | else |
| 10839 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10840 | |
| 10841 | if (! peer) |
| 10842 | return CMD_WARNING; |
| 10843 | |
| 10844 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10845 | { |
| 10846 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10847 | VTY_NEWLINE); |
| 10848 | return CMD_WARNING; |
| 10849 | } |
| 10850 | |
| 10851 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10852 | PEER_FLAG_RSERVER_CLIENT)) |
| 10853 | { |
| 10854 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10855 | VTY_NEWLINE); |
| 10856 | return CMD_WARNING; |
| 10857 | } |
| 10858 | |
| 10859 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10860 | (argc == 3) ? argv[2] : argv[1], |
| 10861 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 10862 | } |
| 10863 | |
| 10864 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 10865 | show_ip_bgp_rsclient_route_cmd, |
| 10866 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10867 | SHOW_STR |
| 10868 | IP_STR |
| 10869 | BGP_STR |
| 10870 | "Information about Route Server Client\n" |
| 10871 | NEIGHBOR_ADDR_STR |
| 10872 | "Network in the BGP routing table to display\n") |
| 10873 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10874 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 10875 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 10876 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10877 | SHOW_STR |
| 10878 | BGP_STR |
| 10879 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10880 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10881 | "Address family\n" |
| 10882 | "Address Family modifier\n" |
| 10883 | "Address Family modifier\n" |
| 10884 | "Information about Route Server Client\n" |
| 10885 | NEIGHBOR_ADDR_STR |
| 10886 | "Network in the BGP routing table to display\n") |
| 10887 | { |
| 10888 | struct bgp *bgp; |
| 10889 | struct peer *peer; |
| 10890 | safi_t safi; |
| 10891 | |
| 10892 | /* BGP structure lookup. */ |
| 10893 | if (argc == 4) |
| 10894 | { |
| 10895 | bgp = bgp_lookup_by_name (argv[0]); |
| 10896 | if (bgp == NULL) |
| 10897 | { |
| 10898 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10899 | return CMD_WARNING; |
| 10900 | } |
| 10901 | } |
| 10902 | else |
| 10903 | { |
| 10904 | bgp = bgp_get_default (); |
| 10905 | if (bgp == NULL) |
| 10906 | { |
| 10907 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10908 | return CMD_WARNING; |
| 10909 | } |
| 10910 | } |
| 10911 | |
| 10912 | if (argc == 4) { |
| 10913 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10914 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10915 | } else { |
| 10916 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10917 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10918 | } |
| 10919 | |
| 10920 | if (! peer) |
| 10921 | return CMD_WARNING; |
| 10922 | |
| 10923 | if (! peer->afc[AFI_IP][safi]) |
| 10924 | { |
| 10925 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10926 | VTY_NEWLINE); |
| 10927 | return CMD_WARNING; |
| 10928 | } |
| 10929 | |
| 10930 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10931 | PEER_FLAG_RSERVER_CLIENT)) |
| 10932 | { |
| 10933 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10934 | VTY_NEWLINE); |
| 10935 | return CMD_WARNING; |
| 10936 | } |
| 10937 | |
| 10938 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10939 | (argc == 4) ? argv[3] : argv[2], |
| 10940 | AFI_IP, safi, NULL, 0); |
| 10941 | } |
| 10942 | |
| 10943 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 10944 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 10945 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10946 | SHOW_STR |
| 10947 | BGP_STR |
| 10948 | "Address family\n" |
| 10949 | "Address Family modifier\n" |
| 10950 | "Address Family modifier\n" |
| 10951 | "Information about Route Server Client\n" |
| 10952 | NEIGHBOR_ADDR_STR |
| 10953 | "Network in the BGP routing table to display\n") |
| 10954 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10955 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 10956 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 10957 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10958 | SHOW_STR |
| 10959 | IP_STR |
| 10960 | BGP_STR |
| 10961 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10962 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10963 | "Information about Route Server Client\n" |
| 10964 | NEIGHBOR_ADDR_STR |
| 10965 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10966 | { |
| 10967 | struct bgp *bgp; |
| 10968 | struct peer *peer; |
| 10969 | |
| 10970 | /* BGP structure lookup. */ |
| 10971 | if (argc == 3) |
| 10972 | { |
| 10973 | bgp = bgp_lookup_by_name (argv[0]); |
| 10974 | if (bgp == NULL) |
| 10975 | { |
| 10976 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10977 | return CMD_WARNING; |
| 10978 | } |
| 10979 | } |
| 10980 | else |
| 10981 | { |
| 10982 | bgp = bgp_get_default (); |
| 10983 | if (bgp == NULL) |
| 10984 | { |
| 10985 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10986 | return CMD_WARNING; |
| 10987 | } |
| 10988 | } |
| 10989 | |
| 10990 | if (argc == 3) |
| 10991 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10992 | else |
| 10993 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10994 | |
| 10995 | if (! peer) |
| 10996 | return CMD_WARNING; |
| 10997 | |
| 10998 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10999 | { |
| 11000 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11001 | VTY_NEWLINE); |
| 11002 | return CMD_WARNING; |
| 11003 | } |
| 11004 | |
| 11005 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 11006 | PEER_FLAG_RSERVER_CLIENT)) |
| 11007 | { |
| 11008 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11009 | VTY_NEWLINE); |
| 11010 | return CMD_WARNING; |
| 11011 | } |
| 11012 | |
| 11013 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 11014 | (argc == 3) ? argv[2] : argv[1], |
| 11015 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 11016 | } |
| 11017 | |
| 11018 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 11019 | show_ip_bgp_rsclient_prefix_cmd, |
| 11020 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11021 | SHOW_STR |
| 11022 | IP_STR |
| 11023 | BGP_STR |
| 11024 | "Information about Route Server Client\n" |
| 11025 | NEIGHBOR_ADDR_STR |
| 11026 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11027 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11028 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 11029 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 11030 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11031 | SHOW_STR |
| 11032 | BGP_STR |
| 11033 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11034 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11035 | "Address family\n" |
| 11036 | "Address Family modifier\n" |
| 11037 | "Address Family modifier\n" |
| 11038 | "Information about Route Server Client\n" |
| 11039 | NEIGHBOR_ADDR_STR |
| 11040 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11041 | { |
| 11042 | struct bgp *bgp; |
| 11043 | struct peer *peer; |
| 11044 | safi_t safi; |
| 11045 | |
| 11046 | /* BGP structure lookup. */ |
| 11047 | if (argc == 4) |
| 11048 | { |
| 11049 | bgp = bgp_lookup_by_name (argv[0]); |
| 11050 | if (bgp == NULL) |
| 11051 | { |
| 11052 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11053 | return CMD_WARNING; |
| 11054 | } |
| 11055 | } |
| 11056 | else |
| 11057 | { |
| 11058 | bgp = bgp_get_default (); |
| 11059 | if (bgp == NULL) |
| 11060 | { |
| 11061 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11062 | return CMD_WARNING; |
| 11063 | } |
| 11064 | } |
| 11065 | |
| 11066 | if (argc == 4) { |
| 11067 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11068 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11069 | } else { |
| 11070 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11071 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11072 | } |
| 11073 | |
| 11074 | if (! peer) |
| 11075 | return CMD_WARNING; |
| 11076 | |
| 11077 | if (! peer->afc[AFI_IP][safi]) |
| 11078 | { |
| 11079 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11080 | VTY_NEWLINE); |
| 11081 | return CMD_WARNING; |
| 11082 | } |
| 11083 | |
| 11084 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 11085 | PEER_FLAG_RSERVER_CLIENT)) |
| 11086 | { |
| 11087 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11088 | VTY_NEWLINE); |
| 11089 | return CMD_WARNING; |
| 11090 | } |
| 11091 | |
| 11092 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 11093 | (argc == 4) ? argv[3] : argv[2], |
| 11094 | AFI_IP, safi, NULL, 1); |
| 11095 | } |
| 11096 | |
| 11097 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 11098 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 11099 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11100 | SHOW_STR |
| 11101 | BGP_STR |
| 11102 | "Address family\n" |
| 11103 | "Address Family modifier\n" |
| 11104 | "Address Family modifier\n" |
| 11105 | "Information about Route Server Client\n" |
| 11106 | NEIGHBOR_ADDR_STR |
| 11107 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11108 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11109 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11110 | DEFUN (show_bgp_view_neighbor_routes, |
| 11111 | show_bgp_view_neighbor_routes_cmd, |
| 11112 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 11113 | SHOW_STR |
| 11114 | BGP_STR |
| 11115 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11116 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11117 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11118 | "Neighbor to display information about\n" |
| 11119 | "Neighbor to display information about\n" |
| 11120 | "Display routes learned from neighbor\n") |
| 11121 | { |
| 11122 | struct peer *peer; |
| 11123 | |
| 11124 | if (argc == 2) |
| 11125 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11126 | else |
| 11127 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11128 | |
| 11129 | if (! peer) |
| 11130 | return CMD_WARNING; |
| 11131 | |
| 11132 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11133 | bgp_show_type_neighbor); |
| 11134 | } |
| 11135 | |
| 11136 | ALIAS (show_bgp_view_neighbor_routes, |
| 11137 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 11138 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11139 | SHOW_STR |
| 11140 | BGP_STR |
| 11141 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11142 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11143 | "Address family\n" |
| 11144 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11145 | "Neighbor to display information about\n" |
| 11146 | "Neighbor to display information about\n" |
| 11147 | "Display routes learned from neighbor\n") |
| 11148 | |
| 11149 | DEFUN (show_bgp_view_neighbor_damp, |
| 11150 | show_bgp_view_neighbor_damp_cmd, |
| 11151 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11152 | SHOW_STR |
| 11153 | BGP_STR |
| 11154 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11155 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11156 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11157 | "Neighbor to display information about\n" |
| 11158 | "Neighbor to display information about\n" |
| 11159 | "Display the dampened routes received from neighbor\n") |
| 11160 | { |
| 11161 | struct peer *peer; |
| 11162 | |
| 11163 | if (argc == 2) |
| 11164 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11165 | else |
| 11166 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11167 | |
| 11168 | if (! peer) |
| 11169 | return CMD_WARNING; |
| 11170 | |
| 11171 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11172 | bgp_show_type_damp_neighbor); |
| 11173 | } |
| 11174 | |
| 11175 | ALIAS (show_bgp_view_neighbor_damp, |
| 11176 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 11177 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11178 | SHOW_STR |
| 11179 | BGP_STR |
| 11180 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11181 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11182 | "Address family\n" |
| 11183 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11184 | "Neighbor to display information about\n" |
| 11185 | "Neighbor to display information about\n" |
| 11186 | "Display the dampened routes received from neighbor\n") |
| 11187 | |
| 11188 | DEFUN (show_bgp_view_neighbor_flap, |
| 11189 | show_bgp_view_neighbor_flap_cmd, |
| 11190 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11191 | SHOW_STR |
| 11192 | BGP_STR |
| 11193 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11194 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 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 | struct peer *peer; |
| 11201 | |
| 11202 | if (argc == 2) |
| 11203 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11204 | else |
| 11205 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11206 | |
| 11207 | if (! peer) |
| 11208 | return CMD_WARNING; |
| 11209 | |
| 11210 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11211 | bgp_show_type_flap_neighbor); |
| 11212 | } |
| 11213 | |
| 11214 | ALIAS (show_bgp_view_neighbor_flap, |
| 11215 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 11216 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11217 | SHOW_STR |
| 11218 | BGP_STR |
| 11219 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11220 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11221 | "Address family\n" |
| 11222 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11223 | "Neighbor to display information about\n" |
| 11224 | "Neighbor to display information about\n" |
| 11225 | "Display flap statistics of the routes learned from neighbor\n") |
| 11226 | |
| 11227 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11228 | show_bgp_neighbor_routes_cmd, |
| 11229 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11230 | SHOW_STR |
| 11231 | BGP_STR |
| 11232 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11233 | "Neighbor to display information about\n" |
| 11234 | "Neighbor to display information about\n" |
| 11235 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11236 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11237 | |
| 11238 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11239 | show_bgp_ipv6_neighbor_routes_cmd, |
| 11240 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11241 | SHOW_STR |
| 11242 | BGP_STR |
| 11243 | "Address family\n" |
| 11244 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11245 | "Neighbor to display information about\n" |
| 11246 | "Neighbor to display information about\n" |
| 11247 | "Display routes learned from neighbor\n") |
| 11248 | |
| 11249 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11250 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11251 | ipv6_bgp_neighbor_routes_cmd, |
| 11252 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11253 | SHOW_STR |
| 11254 | IPV6_STR |
| 11255 | BGP_STR |
| 11256 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11257 | "Neighbor to display information about\n" |
| 11258 | "Neighbor to display information about\n" |
| 11259 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11260 | |
| 11261 | /* old command */ |
| 11262 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 11263 | ipv6_mbgp_neighbor_routes_cmd, |
| 11264 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11265 | SHOW_STR |
| 11266 | IPV6_STR |
| 11267 | MBGP_STR |
| 11268 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11269 | "Neighbor to display information about\n" |
| 11270 | "Neighbor to display information about\n" |
| 11271 | "Display routes learned from neighbor\n") |
| 11272 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11273 | struct peer *peer; |
| 11274 | |
| 11275 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11276 | if (! peer) |
| 11277 | return CMD_WARNING; |
| 11278 | |
| 11279 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11280 | bgp_show_type_neighbor); |
| 11281 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11282 | |
| 11283 | ALIAS (show_bgp_view_neighbor_flap, |
| 11284 | show_bgp_neighbor_flap_cmd, |
| 11285 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11286 | SHOW_STR |
| 11287 | BGP_STR |
| 11288 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11289 | "Neighbor to display information about\n" |
| 11290 | "Neighbor to display information about\n" |
| 11291 | "Display flap statistics of the routes learned from neighbor\n") |
| 11292 | |
| 11293 | ALIAS (show_bgp_view_neighbor_flap, |
| 11294 | show_bgp_ipv6_neighbor_flap_cmd, |
| 11295 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11296 | SHOW_STR |
| 11297 | BGP_STR |
| 11298 | "Address family\n" |
| 11299 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11300 | "Neighbor to display information about\n" |
| 11301 | "Neighbor to display information about\n" |
| 11302 | "Display flap statistics of the routes learned from neighbor\n") |
| 11303 | |
| 11304 | ALIAS (show_bgp_view_neighbor_damp, |
| 11305 | show_bgp_neighbor_damp_cmd, |
| 11306 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11307 | SHOW_STR |
| 11308 | BGP_STR |
| 11309 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11310 | "Neighbor to display information about\n" |
| 11311 | "Neighbor to display information about\n" |
| 11312 | "Display the dampened routes received from neighbor\n") |
| 11313 | |
| 11314 | ALIAS (show_bgp_view_neighbor_damp, |
| 11315 | show_bgp_ipv6_neighbor_damp_cmd, |
| 11316 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11317 | SHOW_STR |
| 11318 | BGP_STR |
| 11319 | "Address family\n" |
| 11320 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11321 | "Neighbor to display information about\n" |
| 11322 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 11323 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11324 | |
| 11325 | DEFUN (show_bgp_view_rsclient, |
| 11326 | show_bgp_view_rsclient_cmd, |
| 11327 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 11328 | SHOW_STR |
| 11329 | BGP_STR |
| 11330 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11331 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11332 | "Information about Route Server Client\n" |
| 11333 | NEIGHBOR_ADDR_STR) |
| 11334 | { |
| 11335 | struct bgp_table *table; |
| 11336 | struct peer *peer; |
| 11337 | |
| 11338 | if (argc == 2) |
| 11339 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11340 | else |
| 11341 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11342 | |
| 11343 | if (! peer) |
| 11344 | return CMD_WARNING; |
| 11345 | |
| 11346 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11347 | { |
| 11348 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11349 | VTY_NEWLINE); |
| 11350 | return CMD_WARNING; |
| 11351 | } |
| 11352 | |
| 11353 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11354 | PEER_FLAG_RSERVER_CLIENT)) |
| 11355 | { |
| 11356 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11357 | VTY_NEWLINE); |
| 11358 | return CMD_WARNING; |
| 11359 | } |
| 11360 | |
| 11361 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 11362 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11363 | 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] | 11364 | } |
| 11365 | |
| 11366 | ALIAS (show_bgp_view_rsclient, |
| 11367 | show_bgp_rsclient_cmd, |
| 11368 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 11369 | SHOW_STR |
| 11370 | BGP_STR |
| 11371 | "Information about Route Server Client\n" |
| 11372 | NEIGHBOR_ADDR_STR) |
| 11373 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11374 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 11375 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 11376 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11377 | SHOW_STR |
| 11378 | BGP_STR |
| 11379 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11380 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11381 | "Address family\n" |
| 11382 | "Address Family modifier\n" |
| 11383 | "Address Family modifier\n" |
| 11384 | "Information about Route Server Client\n" |
| 11385 | NEIGHBOR_ADDR_STR) |
| 11386 | { |
| 11387 | struct bgp_table *table; |
| 11388 | struct peer *peer; |
| 11389 | safi_t safi; |
| 11390 | |
| 11391 | if (argc == 3) { |
| 11392 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11393 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11394 | } else { |
| 11395 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11396 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11397 | } |
| 11398 | |
| 11399 | if (! peer) |
| 11400 | return CMD_WARNING; |
| 11401 | |
| 11402 | if (! peer->afc[AFI_IP6][safi]) |
| 11403 | { |
| 11404 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11405 | VTY_NEWLINE); |
| 11406 | return CMD_WARNING; |
| 11407 | } |
| 11408 | |
| 11409 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11410 | PEER_FLAG_RSERVER_CLIENT)) |
| 11411 | { |
| 11412 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11413 | VTY_NEWLINE); |
| 11414 | return CMD_WARNING; |
| 11415 | } |
| 11416 | |
| 11417 | table = peer->rib[AFI_IP6][safi]; |
| 11418 | |
| 11419 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 11420 | } |
| 11421 | |
| 11422 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 11423 | show_bgp_ipv6_safi_rsclient_cmd, |
| 11424 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11425 | SHOW_STR |
| 11426 | BGP_STR |
| 11427 | "Address family\n" |
| 11428 | "Address Family modifier\n" |
| 11429 | "Address Family modifier\n" |
| 11430 | "Information about Route Server Client\n" |
| 11431 | NEIGHBOR_ADDR_STR) |
| 11432 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11433 | DEFUN (show_bgp_view_rsclient_route, |
| 11434 | show_bgp_view_rsclient_route_cmd, |
| 11435 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11436 | SHOW_STR |
| 11437 | BGP_STR |
| 11438 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11439 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11440 | "Information about Route Server Client\n" |
| 11441 | NEIGHBOR_ADDR_STR |
| 11442 | "Network in the BGP routing table to display\n") |
| 11443 | { |
| 11444 | struct bgp *bgp; |
| 11445 | struct peer *peer; |
| 11446 | |
| 11447 | /* BGP structure lookup. */ |
| 11448 | if (argc == 3) |
| 11449 | { |
| 11450 | bgp = bgp_lookup_by_name (argv[0]); |
| 11451 | if (bgp == NULL) |
| 11452 | { |
| 11453 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11454 | return CMD_WARNING; |
| 11455 | } |
| 11456 | } |
| 11457 | else |
| 11458 | { |
| 11459 | bgp = bgp_get_default (); |
| 11460 | if (bgp == NULL) |
| 11461 | { |
| 11462 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11463 | return CMD_WARNING; |
| 11464 | } |
| 11465 | } |
| 11466 | |
| 11467 | if (argc == 3) |
| 11468 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11469 | else |
| 11470 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11471 | |
| 11472 | if (! peer) |
| 11473 | return CMD_WARNING; |
| 11474 | |
| 11475 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11476 | { |
| 11477 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11478 | VTY_NEWLINE); |
| 11479 | return CMD_WARNING; |
| 11480 | } |
| 11481 | |
| 11482 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11483 | PEER_FLAG_RSERVER_CLIENT)) |
| 11484 | { |
| 11485 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11486 | VTY_NEWLINE); |
| 11487 | return CMD_WARNING; |
| 11488 | } |
| 11489 | |
| 11490 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11491 | (argc == 3) ? argv[2] : argv[1], |
| 11492 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 11493 | } |
| 11494 | |
| 11495 | ALIAS (show_bgp_view_rsclient_route, |
| 11496 | show_bgp_rsclient_route_cmd, |
| 11497 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11498 | SHOW_STR |
| 11499 | BGP_STR |
| 11500 | "Information about Route Server Client\n" |
| 11501 | NEIGHBOR_ADDR_STR |
| 11502 | "Network in the BGP routing table to display\n") |
| 11503 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11504 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 11505 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 11506 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11507 | SHOW_STR |
| 11508 | BGP_STR |
| 11509 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11510 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11511 | "Address family\n" |
| 11512 | "Address Family modifier\n" |
| 11513 | "Address Family modifier\n" |
| 11514 | "Information about Route Server Client\n" |
| 11515 | NEIGHBOR_ADDR_STR |
| 11516 | "Network in the BGP routing table to display\n") |
| 11517 | { |
| 11518 | struct bgp *bgp; |
| 11519 | struct peer *peer; |
| 11520 | safi_t safi; |
| 11521 | |
| 11522 | /* BGP structure lookup. */ |
| 11523 | if (argc == 4) |
| 11524 | { |
| 11525 | bgp = bgp_lookup_by_name (argv[0]); |
| 11526 | if (bgp == NULL) |
| 11527 | { |
| 11528 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11529 | return CMD_WARNING; |
| 11530 | } |
| 11531 | } |
| 11532 | else |
| 11533 | { |
| 11534 | bgp = bgp_get_default (); |
| 11535 | if (bgp == NULL) |
| 11536 | { |
| 11537 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11538 | return CMD_WARNING; |
| 11539 | } |
| 11540 | } |
| 11541 | |
| 11542 | if (argc == 4) { |
| 11543 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11544 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11545 | } else { |
| 11546 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11547 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11548 | } |
| 11549 | |
| 11550 | if (! peer) |
| 11551 | return CMD_WARNING; |
| 11552 | |
| 11553 | if (! peer->afc[AFI_IP6][safi]) |
| 11554 | { |
| 11555 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11556 | VTY_NEWLINE); |
| 11557 | return CMD_WARNING; |
| 11558 | } |
| 11559 | |
| 11560 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11561 | PEER_FLAG_RSERVER_CLIENT)) |
| 11562 | { |
| 11563 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11564 | VTY_NEWLINE); |
| 11565 | return CMD_WARNING; |
| 11566 | } |
| 11567 | |
| 11568 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11569 | (argc == 4) ? argv[3] : argv[2], |
| 11570 | AFI_IP6, safi, NULL, 0); |
| 11571 | } |
| 11572 | |
| 11573 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 11574 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 11575 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11576 | SHOW_STR |
| 11577 | BGP_STR |
| 11578 | "Address family\n" |
| 11579 | "Address Family modifier\n" |
| 11580 | "Address Family modifier\n" |
| 11581 | "Information about Route Server Client\n" |
| 11582 | NEIGHBOR_ADDR_STR |
| 11583 | "Network in the BGP routing table to display\n") |
| 11584 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11585 | DEFUN (show_bgp_view_rsclient_prefix, |
| 11586 | show_bgp_view_rsclient_prefix_cmd, |
| 11587 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11588 | SHOW_STR |
| 11589 | BGP_STR |
| 11590 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11591 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11592 | "Information about Route Server Client\n" |
| 11593 | NEIGHBOR_ADDR_STR |
| 11594 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11595 | { |
| 11596 | struct bgp *bgp; |
| 11597 | struct peer *peer; |
| 11598 | |
| 11599 | /* BGP structure lookup. */ |
| 11600 | if (argc == 3) |
| 11601 | { |
| 11602 | bgp = bgp_lookup_by_name (argv[0]); |
| 11603 | if (bgp == NULL) |
| 11604 | { |
| 11605 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11606 | return CMD_WARNING; |
| 11607 | } |
| 11608 | } |
| 11609 | else |
| 11610 | { |
| 11611 | bgp = bgp_get_default (); |
| 11612 | if (bgp == NULL) |
| 11613 | { |
| 11614 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11615 | return CMD_WARNING; |
| 11616 | } |
| 11617 | } |
| 11618 | |
| 11619 | if (argc == 3) |
| 11620 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11621 | else |
| 11622 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11623 | |
| 11624 | if (! peer) |
| 11625 | return CMD_WARNING; |
| 11626 | |
| 11627 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11628 | { |
| 11629 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11630 | VTY_NEWLINE); |
| 11631 | return CMD_WARNING; |
| 11632 | } |
| 11633 | |
| 11634 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11635 | PEER_FLAG_RSERVER_CLIENT)) |
| 11636 | { |
| 11637 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11638 | VTY_NEWLINE); |
| 11639 | return CMD_WARNING; |
| 11640 | } |
| 11641 | |
| 11642 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11643 | (argc == 3) ? argv[2] : argv[1], |
| 11644 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 11645 | } |
| 11646 | |
| 11647 | ALIAS (show_bgp_view_rsclient_prefix, |
| 11648 | show_bgp_rsclient_prefix_cmd, |
| 11649 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11650 | SHOW_STR |
| 11651 | BGP_STR |
| 11652 | "Information about Route Server Client\n" |
| 11653 | NEIGHBOR_ADDR_STR |
| 11654 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11655 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11656 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11657 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 11658 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11659 | SHOW_STR |
| 11660 | BGP_STR |
| 11661 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11662 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11663 | "Address family\n" |
| 11664 | "Address Family modifier\n" |
| 11665 | "Address Family modifier\n" |
| 11666 | "Information about Route Server Client\n" |
| 11667 | NEIGHBOR_ADDR_STR |
| 11668 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11669 | { |
| 11670 | struct bgp *bgp; |
| 11671 | struct peer *peer; |
| 11672 | safi_t safi; |
| 11673 | |
| 11674 | /* BGP structure lookup. */ |
| 11675 | if (argc == 4) |
| 11676 | { |
| 11677 | bgp = bgp_lookup_by_name (argv[0]); |
| 11678 | if (bgp == NULL) |
| 11679 | { |
| 11680 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11681 | return CMD_WARNING; |
| 11682 | } |
| 11683 | } |
| 11684 | else |
| 11685 | { |
| 11686 | bgp = bgp_get_default (); |
| 11687 | if (bgp == NULL) |
| 11688 | { |
| 11689 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11690 | return CMD_WARNING; |
| 11691 | } |
| 11692 | } |
| 11693 | |
| 11694 | if (argc == 4) { |
| 11695 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11696 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11697 | } else { |
| 11698 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11699 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11700 | } |
| 11701 | |
| 11702 | if (! peer) |
| 11703 | return CMD_WARNING; |
| 11704 | |
| 11705 | if (! peer->afc[AFI_IP6][safi]) |
| 11706 | { |
| 11707 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11708 | VTY_NEWLINE); |
| 11709 | return CMD_WARNING; |
| 11710 | } |
| 11711 | |
| 11712 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11713 | PEER_FLAG_RSERVER_CLIENT)) |
| 11714 | { |
| 11715 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11716 | VTY_NEWLINE); |
| 11717 | return CMD_WARNING; |
| 11718 | } |
| 11719 | |
| 11720 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11721 | (argc == 4) ? argv[3] : argv[2], |
| 11722 | AFI_IP6, safi, NULL, 1); |
| 11723 | } |
| 11724 | |
| 11725 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11726 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 11727 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11728 | SHOW_STR |
| 11729 | BGP_STR |
| 11730 | "Address family\n" |
| 11731 | "Address Family modifier\n" |
| 11732 | "Address Family modifier\n" |
| 11733 | "Information about Route Server Client\n" |
| 11734 | NEIGHBOR_ADDR_STR |
| 11735 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11736 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11737 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11738 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11739 | struct bgp_table *bgp_distance_table; |
| 11740 | |
| 11741 | struct bgp_distance |
| 11742 | { |
| 11743 | /* Distance value for the IP source prefix. */ |
| 11744 | u_char distance; |
| 11745 | |
| 11746 | /* Name of the access-list to be matched. */ |
| 11747 | char *access_list; |
| 11748 | }; |
| 11749 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11750 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 11751 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11752 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 11753 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11754 | } |
| 11755 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11756 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11757 | bgp_distance_free (struct bgp_distance *bdistance) |
| 11758 | { |
| 11759 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 11760 | } |
| 11761 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11762 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11763 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 11764 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11765 | { |
| 11766 | int ret; |
| 11767 | struct prefix_ipv4 p; |
| 11768 | u_char distance; |
| 11769 | struct bgp_node *rn; |
| 11770 | struct bgp_distance *bdistance; |
| 11771 | |
| 11772 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11773 | if (ret == 0) |
| 11774 | { |
| 11775 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11776 | return CMD_WARNING; |
| 11777 | } |
| 11778 | |
| 11779 | distance = atoi (distance_str); |
| 11780 | |
| 11781 | /* Get BGP distance node. */ |
| 11782 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 11783 | if (rn->info) |
| 11784 | { |
| 11785 | bdistance = rn->info; |
| 11786 | bgp_unlock_node (rn); |
| 11787 | } |
| 11788 | else |
| 11789 | { |
| 11790 | bdistance = bgp_distance_new (); |
| 11791 | rn->info = bdistance; |
| 11792 | } |
| 11793 | |
| 11794 | /* Set distance value. */ |
| 11795 | bdistance->distance = distance; |
| 11796 | |
| 11797 | /* Reset access-list configuration. */ |
| 11798 | if (bdistance->access_list) |
| 11799 | { |
| 11800 | free (bdistance->access_list); |
| 11801 | bdistance->access_list = NULL; |
| 11802 | } |
| 11803 | if (access_list_str) |
| 11804 | bdistance->access_list = strdup (access_list_str); |
| 11805 | |
| 11806 | return CMD_SUCCESS; |
| 11807 | } |
| 11808 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11809 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11810 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 11811 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11812 | { |
| 11813 | int ret; |
| 11814 | struct prefix_ipv4 p; |
| 11815 | u_char distance; |
| 11816 | struct bgp_node *rn; |
| 11817 | struct bgp_distance *bdistance; |
| 11818 | |
| 11819 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11820 | if (ret == 0) |
| 11821 | { |
| 11822 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11823 | return CMD_WARNING; |
| 11824 | } |
| 11825 | |
| 11826 | distance = atoi (distance_str); |
| 11827 | |
| 11828 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 11829 | if (! rn) |
| 11830 | { |
| 11831 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 11832 | return CMD_WARNING; |
| 11833 | } |
| 11834 | |
| 11835 | bdistance = rn->info; |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 11836 | |
| 11837 | if (bdistance->distance != distance) |
| 11838 | { |
| 11839 | vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); |
| 11840 | return CMD_WARNING; |
| 11841 | } |
| 11842 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11843 | if (bdistance->access_list) |
| 11844 | free (bdistance->access_list); |
| 11845 | bgp_distance_free (bdistance); |
| 11846 | |
| 11847 | rn->info = NULL; |
| 11848 | bgp_unlock_node (rn); |
| 11849 | bgp_unlock_node (rn); |
| 11850 | |
| 11851 | return CMD_SUCCESS; |
| 11852 | } |
| 11853 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11854 | /* Apply BGP information to distance method. */ |
| 11855 | u_char |
| 11856 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 11857 | { |
| 11858 | struct bgp_node *rn; |
| 11859 | struct prefix_ipv4 q; |
| 11860 | struct peer *peer; |
| 11861 | struct bgp_distance *bdistance; |
| 11862 | struct access_list *alist; |
| 11863 | struct bgp_static *bgp_static; |
| 11864 | |
| 11865 | if (! bgp) |
| 11866 | return 0; |
| 11867 | |
| 11868 | if (p->family != AF_INET) |
| 11869 | return 0; |
| 11870 | |
| 11871 | peer = rinfo->peer; |
| 11872 | |
| 11873 | if (peer->su.sa.sa_family != AF_INET) |
| 11874 | return 0; |
| 11875 | |
| 11876 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 11877 | q.family = AF_INET; |
| 11878 | q.prefix = peer->su.sin.sin_addr; |
| 11879 | q.prefixlen = IPV4_MAX_BITLEN; |
| 11880 | |
| 11881 | /* Check source address. */ |
| 11882 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 11883 | if (rn) |
| 11884 | { |
| 11885 | bdistance = rn->info; |
| 11886 | bgp_unlock_node (rn); |
| 11887 | |
| 11888 | if (bdistance->access_list) |
| 11889 | { |
| 11890 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 11891 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 11892 | return bdistance->distance; |
| 11893 | } |
| 11894 | else |
| 11895 | return bdistance->distance; |
| 11896 | } |
| 11897 | |
| 11898 | /* Backdoor check. */ |
| 11899 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 11900 | if (rn) |
| 11901 | { |
| 11902 | bgp_static = rn->info; |
| 11903 | bgp_unlock_node (rn); |
| 11904 | |
| 11905 | if (bgp_static->backdoor) |
| 11906 | { |
| 11907 | if (bgp->distance_local) |
| 11908 | return bgp->distance_local; |
| 11909 | else |
| 11910 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11911 | } |
| 11912 | } |
| 11913 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 11914 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11915 | { |
| 11916 | if (bgp->distance_ebgp) |
| 11917 | return bgp->distance_ebgp; |
| 11918 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 11919 | } |
| 11920 | else |
| 11921 | { |
| 11922 | if (bgp->distance_ibgp) |
| 11923 | return bgp->distance_ibgp; |
| 11924 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11925 | } |
| 11926 | } |
| 11927 | |
| 11928 | DEFUN (bgp_distance, |
| 11929 | bgp_distance_cmd, |
| 11930 | "distance bgp <1-255> <1-255> <1-255>", |
| 11931 | "Define an administrative distance\n" |
| 11932 | "BGP distance\n" |
| 11933 | "Distance for routes external to the AS\n" |
| 11934 | "Distance for routes internal to the AS\n" |
| 11935 | "Distance for local routes\n") |
| 11936 | { |
| 11937 | struct bgp *bgp; |
| 11938 | |
| 11939 | bgp = vty->index; |
| 11940 | |
| 11941 | bgp->distance_ebgp = atoi (argv[0]); |
| 11942 | bgp->distance_ibgp = atoi (argv[1]); |
| 11943 | bgp->distance_local = atoi (argv[2]); |
| 11944 | return CMD_SUCCESS; |
| 11945 | } |
| 11946 | |
| 11947 | DEFUN (no_bgp_distance, |
| 11948 | no_bgp_distance_cmd, |
| 11949 | "no distance bgp <1-255> <1-255> <1-255>", |
| 11950 | NO_STR |
| 11951 | "Define an administrative distance\n" |
| 11952 | "BGP distance\n" |
| 11953 | "Distance for routes external to the AS\n" |
| 11954 | "Distance for routes internal to the AS\n" |
| 11955 | "Distance for local routes\n") |
| 11956 | { |
| 11957 | struct bgp *bgp; |
| 11958 | |
| 11959 | bgp = vty->index; |
| 11960 | |
| 11961 | bgp->distance_ebgp= 0; |
| 11962 | bgp->distance_ibgp = 0; |
| 11963 | bgp->distance_local = 0; |
| 11964 | return CMD_SUCCESS; |
| 11965 | } |
| 11966 | |
| 11967 | ALIAS (no_bgp_distance, |
| 11968 | no_bgp_distance2_cmd, |
| 11969 | "no distance bgp", |
| 11970 | NO_STR |
| 11971 | "Define an administrative distance\n" |
| 11972 | "BGP distance\n") |
| 11973 | |
| 11974 | DEFUN (bgp_distance_source, |
| 11975 | bgp_distance_source_cmd, |
| 11976 | "distance <1-255> A.B.C.D/M", |
| 11977 | "Define an administrative distance\n" |
| 11978 | "Administrative distance\n" |
| 11979 | "IP source prefix\n") |
| 11980 | { |
| 11981 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 11982 | return CMD_SUCCESS; |
| 11983 | } |
| 11984 | |
| 11985 | DEFUN (no_bgp_distance_source, |
| 11986 | no_bgp_distance_source_cmd, |
| 11987 | "no distance <1-255> A.B.C.D/M", |
| 11988 | NO_STR |
| 11989 | "Define an administrative distance\n" |
| 11990 | "Administrative distance\n" |
| 11991 | "IP source prefix\n") |
| 11992 | { |
| 11993 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 11994 | return CMD_SUCCESS; |
| 11995 | } |
| 11996 | |
| 11997 | DEFUN (bgp_distance_source_access_list, |
| 11998 | bgp_distance_source_access_list_cmd, |
| 11999 | "distance <1-255> A.B.C.D/M WORD", |
| 12000 | "Define an administrative distance\n" |
| 12001 | "Administrative distance\n" |
| 12002 | "IP source prefix\n" |
| 12003 | "Access list name\n") |
| 12004 | { |
| 12005 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 12006 | return CMD_SUCCESS; |
| 12007 | } |
| 12008 | |
| 12009 | DEFUN (no_bgp_distance_source_access_list, |
| 12010 | no_bgp_distance_source_access_list_cmd, |
| 12011 | "no distance <1-255> A.B.C.D/M WORD", |
| 12012 | NO_STR |
| 12013 | "Define an administrative distance\n" |
| 12014 | "Administrative distance\n" |
| 12015 | "IP source prefix\n" |
| 12016 | "Access list name\n") |
| 12017 | { |
| 12018 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 12019 | return CMD_SUCCESS; |
| 12020 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12021 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12022 | DEFUN (bgp_damp_set, |
| 12023 | bgp_damp_set_cmd, |
| 12024 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 12025 | "BGP Specific commands\n" |
| 12026 | "Enable route-flap dampening\n" |
| 12027 | "Half-life time for the penalty\n" |
| 12028 | "Value to start reusing a route\n" |
| 12029 | "Value to start suppressing a route\n" |
| 12030 | "Maximum duration to suppress a stable route\n") |
| 12031 | { |
| 12032 | struct bgp *bgp; |
| 12033 | int half = DEFAULT_HALF_LIFE * 60; |
| 12034 | int reuse = DEFAULT_REUSE; |
| 12035 | int suppress = DEFAULT_SUPPRESS; |
| 12036 | int max = 4 * half; |
| 12037 | |
| 12038 | if (argc == 4) |
| 12039 | { |
| 12040 | half = atoi (argv[0]) * 60; |
| 12041 | reuse = atoi (argv[1]); |
| 12042 | suppress = atoi (argv[2]); |
| 12043 | max = atoi (argv[3]) * 60; |
| 12044 | } |
| 12045 | else if (argc == 1) |
| 12046 | { |
| 12047 | half = atoi (argv[0]) * 60; |
| 12048 | max = 4 * half; |
| 12049 | } |
| 12050 | |
| 12051 | bgp = vty->index; |
Balaji | aa7dbb1 | 2015-03-16 16:55:26 +0000 | [diff] [blame] | 12052 | |
| 12053 | if (suppress < reuse) |
| 12054 | { |
| 12055 | vty_out (vty, "Suppress value cannot be less than reuse value %s", |
| 12056 | VTY_NEWLINE); |
| 12057 | return 0; |
| 12058 | } |
| 12059 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12060 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 12061 | half, reuse, suppress, max); |
| 12062 | } |
| 12063 | |
| 12064 | ALIAS (bgp_damp_set, |
| 12065 | bgp_damp_set2_cmd, |
| 12066 | "bgp dampening <1-45>", |
| 12067 | "BGP Specific commands\n" |
| 12068 | "Enable route-flap dampening\n" |
| 12069 | "Half-life time for the penalty\n") |
| 12070 | |
| 12071 | ALIAS (bgp_damp_set, |
| 12072 | bgp_damp_set3_cmd, |
| 12073 | "bgp dampening", |
| 12074 | "BGP Specific commands\n" |
| 12075 | "Enable route-flap dampening\n") |
| 12076 | |
| 12077 | DEFUN (bgp_damp_unset, |
| 12078 | bgp_damp_unset_cmd, |
| 12079 | "no bgp dampening", |
| 12080 | NO_STR |
| 12081 | "BGP Specific commands\n" |
| 12082 | "Enable route-flap dampening\n") |
| 12083 | { |
| 12084 | struct bgp *bgp; |
| 12085 | |
| 12086 | bgp = vty->index; |
| 12087 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 12088 | } |
| 12089 | |
| 12090 | ALIAS (bgp_damp_unset, |
| 12091 | bgp_damp_unset2_cmd, |
| 12092 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 12093 | NO_STR |
| 12094 | "BGP Specific commands\n" |
| 12095 | "Enable route-flap dampening\n" |
| 12096 | "Half-life time for the penalty\n" |
| 12097 | "Value to start reusing a route\n" |
| 12098 | "Value to start suppressing a route\n" |
| 12099 | "Maximum duration to suppress a stable route\n") |
| 12100 | |
| 12101 | DEFUN (show_ip_bgp_dampened_paths, |
| 12102 | show_ip_bgp_dampened_paths_cmd, |
| 12103 | "show ip bgp dampened-paths", |
| 12104 | SHOW_STR |
| 12105 | IP_STR |
| 12106 | BGP_STR |
| 12107 | "Display paths suppressed due to dampening\n") |
| 12108 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12109 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 12110 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12111 | } |
| 12112 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12113 | ALIAS (show_ip_bgp_dampened_paths, |
| 12114 | show_ip_bgp_damp_dampened_paths_cmd, |
| 12115 | "show ip bgp dampening dampened-paths", |
| 12116 | SHOW_STR |
| 12117 | IP_STR |
| 12118 | BGP_STR |
| 12119 | "Display detailed information about dampening\n" |
| 12120 | "Display paths suppressed due to dampening\n") |
| 12121 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12122 | DEFUN (show_ip_bgp_flap_statistics, |
| 12123 | show_ip_bgp_flap_statistics_cmd, |
| 12124 | "show ip bgp flap-statistics", |
| 12125 | SHOW_STR |
| 12126 | IP_STR |
| 12127 | BGP_STR |
| 12128 | "Display flap statistics of routes\n") |
| 12129 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12130 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 12131 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12132 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12133 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12134 | ALIAS (show_ip_bgp_flap_statistics, |
| 12135 | show_ip_bgp_damp_flap_statistics_cmd, |
| 12136 | "show ip bgp dampening flap-statistics", |
| 12137 | SHOW_STR |
| 12138 | IP_STR |
| 12139 | BGP_STR |
| 12140 | "Display detailed information about dampening\n" |
| 12141 | "Display flap statistics of routes\n") |
| 12142 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12143 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12144 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 12145 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 12146 | const char *ip_str, afi_t afi, safi_t safi, |
| 12147 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12148 | { |
| 12149 | int ret; |
| 12150 | struct prefix match; |
| 12151 | struct bgp_node *rn; |
| 12152 | struct bgp_node *rm; |
| 12153 | struct bgp_info *ri; |
| 12154 | struct bgp_info *ri_temp; |
| 12155 | struct bgp *bgp; |
| 12156 | struct bgp_table *table; |
| 12157 | |
| 12158 | /* BGP structure lookup. */ |
| 12159 | if (view_name) |
| 12160 | { |
| 12161 | bgp = bgp_lookup_by_name (view_name); |
| 12162 | if (bgp == NULL) |
| 12163 | { |
| 12164 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 12165 | return CMD_WARNING; |
| 12166 | } |
| 12167 | } |
| 12168 | else |
| 12169 | { |
| 12170 | bgp = bgp_get_default (); |
| 12171 | if (bgp == NULL) |
| 12172 | { |
| 12173 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 12174 | return CMD_WARNING; |
| 12175 | } |
| 12176 | } |
| 12177 | |
| 12178 | /* Check IP address argument. */ |
| 12179 | ret = str2prefix (ip_str, &match); |
| 12180 | if (! ret) |
| 12181 | { |
| 12182 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 12183 | return CMD_WARNING; |
| 12184 | } |
| 12185 | |
| 12186 | match.family = afi2family (afi); |
| 12187 | |
| 12188 | if (safi == SAFI_MPLS_VPN) |
| 12189 | { |
| 12190 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 12191 | { |
| 12192 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 12193 | continue; |
| 12194 | |
| 12195 | if ((table = rn->info) != NULL) |
| 12196 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12197 | { |
| 12198 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 12199 | { |
| 12200 | ri = rm->info; |
| 12201 | while (ri) |
| 12202 | { |
| 12203 | if (ri->extra && ri->extra->damp_info) |
| 12204 | { |
| 12205 | ri_temp = ri->next; |
| 12206 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12207 | ri = ri_temp; |
| 12208 | } |
| 12209 | else |
| 12210 | ri = ri->next; |
| 12211 | } |
| 12212 | } |
| 12213 | |
| 12214 | bgp_unlock_node (rm); |
| 12215 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12216 | } |
| 12217 | } |
| 12218 | else |
| 12219 | { |
| 12220 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12221 | { |
| 12222 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 12223 | { |
| 12224 | ri = rn->info; |
| 12225 | while (ri) |
| 12226 | { |
| 12227 | if (ri->extra && ri->extra->damp_info) |
| 12228 | { |
| 12229 | ri_temp = ri->next; |
| 12230 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12231 | ri = ri_temp; |
| 12232 | } |
| 12233 | else |
| 12234 | ri = ri->next; |
| 12235 | } |
| 12236 | } |
| 12237 | |
| 12238 | bgp_unlock_node (rn); |
| 12239 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12240 | } |
| 12241 | |
| 12242 | return CMD_SUCCESS; |
| 12243 | } |
| 12244 | |
| 12245 | DEFUN (clear_ip_bgp_dampening, |
| 12246 | clear_ip_bgp_dampening_cmd, |
| 12247 | "clear ip bgp dampening", |
| 12248 | CLEAR_STR |
| 12249 | IP_STR |
| 12250 | BGP_STR |
| 12251 | "Clear route flap dampening information\n") |
| 12252 | { |
| 12253 | bgp_damp_info_clean (); |
| 12254 | return CMD_SUCCESS; |
| 12255 | } |
| 12256 | |
| 12257 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 12258 | clear_ip_bgp_dampening_prefix_cmd, |
| 12259 | "clear ip bgp dampening A.B.C.D/M", |
| 12260 | CLEAR_STR |
| 12261 | IP_STR |
| 12262 | BGP_STR |
| 12263 | "Clear route flap dampening information\n" |
| 12264 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 12265 | { |
| 12266 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12267 | SAFI_UNICAST, NULL, 1); |
| 12268 | } |
| 12269 | |
| 12270 | DEFUN (clear_ip_bgp_dampening_address, |
| 12271 | clear_ip_bgp_dampening_address_cmd, |
| 12272 | "clear ip bgp dampening A.B.C.D", |
| 12273 | CLEAR_STR |
| 12274 | IP_STR |
| 12275 | BGP_STR |
| 12276 | "Clear route flap dampening information\n" |
| 12277 | "Network to clear damping information\n") |
| 12278 | { |
| 12279 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12280 | SAFI_UNICAST, NULL, 0); |
| 12281 | } |
| 12282 | |
| 12283 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 12284 | clear_ip_bgp_dampening_address_mask_cmd, |
| 12285 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 12286 | CLEAR_STR |
| 12287 | IP_STR |
| 12288 | BGP_STR |
| 12289 | "Clear route flap dampening information\n" |
| 12290 | "Network to clear damping information\n" |
| 12291 | "Network mask\n") |
| 12292 | { |
| 12293 | int ret; |
| 12294 | char prefix_str[BUFSIZ]; |
| 12295 | |
| 12296 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 12297 | if (! ret) |
| 12298 | { |
| 12299 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 12300 | return CMD_WARNING; |
| 12301 | } |
| 12302 | |
| 12303 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 12304 | SAFI_UNICAST, NULL, 0); |
| 12305 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12306 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12307 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12308 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 12309 | afi_t afi, safi_t safi, int *write) |
| 12310 | { |
| 12311 | struct bgp_node *prn; |
| 12312 | struct bgp_node *rn; |
| 12313 | struct bgp_table *table; |
| 12314 | struct prefix *p; |
| 12315 | struct prefix_rd *prd; |
| 12316 | struct bgp_static *bgp_static; |
| 12317 | u_int32_t label; |
| 12318 | char buf[SU_ADDRSTRLEN]; |
| 12319 | char rdbuf[RD_ADDRSTRLEN]; |
| 12320 | |
| 12321 | /* Network configuration. */ |
| 12322 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 12323 | if ((table = prn->info) != NULL) |
| 12324 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12325 | if ((bgp_static = rn->info) != NULL) |
| 12326 | { |
| 12327 | p = &rn->p; |
| 12328 | prd = (struct prefix_rd *) &prn->p; |
| 12329 | |
| 12330 | /* "address-family" display. */ |
| 12331 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12332 | |
| 12333 | /* "network" configuration display. */ |
| 12334 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 12335 | label = decode_label (bgp_static->tag); |
| 12336 | |
| 12337 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 12338 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12339 | p->prefixlen, |
| 12340 | rdbuf, label); |
| 12341 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12342 | } |
| 12343 | return 0; |
| 12344 | } |
| 12345 | |
| 12346 | /* Configuration of static route announcement and aggregate |
| 12347 | information. */ |
| 12348 | int |
| 12349 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 12350 | afi_t afi, safi_t safi, int *write) |
| 12351 | { |
| 12352 | struct bgp_node *rn; |
| 12353 | struct prefix *p; |
| 12354 | struct bgp_static *bgp_static; |
| 12355 | struct bgp_aggregate *bgp_aggregate; |
| 12356 | char buf[SU_ADDRSTRLEN]; |
| 12357 | |
| 12358 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 12359 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 12360 | |
| 12361 | /* Network configuration. */ |
| 12362 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12363 | if ((bgp_static = rn->info) != NULL) |
| 12364 | { |
| 12365 | p = &rn->p; |
| 12366 | |
| 12367 | /* "address-family" display. */ |
| 12368 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12369 | |
| 12370 | /* "network" configuration display. */ |
| 12371 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12372 | { |
| 12373 | u_int32_t destination; |
| 12374 | struct in_addr netmask; |
| 12375 | |
| 12376 | destination = ntohl (p->u.prefix4.s_addr); |
| 12377 | masklen2ip (p->prefixlen, &netmask); |
| 12378 | vty_out (vty, " network %s", |
| 12379 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 12380 | |
| 12381 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 12382 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 12383 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 12384 | || p->u.prefix4.s_addr == 0) |
| 12385 | { |
| 12386 | /* Natural mask is not display. */ |
| 12387 | } |
| 12388 | else |
| 12389 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 12390 | } |
| 12391 | else |
| 12392 | { |
| 12393 | vty_out (vty, " network %s/%d", |
| 12394 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12395 | p->prefixlen); |
| 12396 | } |
| 12397 | |
| 12398 | if (bgp_static->rmap.name) |
| 12399 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12400 | else |
| 12401 | { |
| 12402 | if (bgp_static->backdoor) |
| 12403 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12404 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12405 | |
| 12406 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12407 | } |
| 12408 | |
| 12409 | /* Aggregate-address configuration. */ |
| 12410 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12411 | if ((bgp_aggregate = rn->info) != NULL) |
| 12412 | { |
| 12413 | p = &rn->p; |
| 12414 | |
| 12415 | /* "address-family" display. */ |
| 12416 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12417 | |
| 12418 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12419 | { |
| 12420 | struct in_addr netmask; |
| 12421 | |
| 12422 | masklen2ip (p->prefixlen, &netmask); |
| 12423 | vty_out (vty, " aggregate-address %s %s", |
| 12424 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12425 | inet_ntoa (netmask)); |
| 12426 | } |
| 12427 | else |
| 12428 | { |
| 12429 | vty_out (vty, " aggregate-address %s/%d", |
| 12430 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12431 | p->prefixlen); |
| 12432 | } |
| 12433 | |
| 12434 | if (bgp_aggregate->as_set) |
| 12435 | vty_out (vty, " as-set"); |
| 12436 | |
| 12437 | if (bgp_aggregate->summary_only) |
| 12438 | vty_out (vty, " summary-only"); |
| 12439 | |
| 12440 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12441 | } |
| 12442 | |
| 12443 | return 0; |
| 12444 | } |
| 12445 | |
| 12446 | int |
| 12447 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 12448 | { |
| 12449 | struct bgp_node *rn; |
| 12450 | struct bgp_distance *bdistance; |
| 12451 | |
| 12452 | /* Distance configuration. */ |
| 12453 | if (bgp->distance_ebgp |
| 12454 | && bgp->distance_ibgp |
| 12455 | && bgp->distance_local |
| 12456 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 12457 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 12458 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 12459 | vty_out (vty, " distance bgp %d %d %d%s", |
| 12460 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 12461 | VTY_NEWLINE); |
| 12462 | |
| 12463 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 12464 | if ((bdistance = rn->info) != NULL) |
| 12465 | { |
| 12466 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 12467 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 12468 | bdistance->access_list ? bdistance->access_list : "", |
| 12469 | VTY_NEWLINE); |
| 12470 | } |
| 12471 | |
| 12472 | return 0; |
| 12473 | } |
| 12474 | |
| 12475 | /* Allocate routing table structure and install commands. */ |
| 12476 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 12477 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12478 | { |
| 12479 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 12480 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12481 | |
| 12482 | /* IPv4 BGP commands. */ |
| 12483 | install_element (BGP_NODE, &bgp_network_cmd); |
| 12484 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 12485 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 12486 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 12487 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 12488 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12489 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 12490 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 12491 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 12492 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 12493 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 12494 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 12495 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 12496 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12497 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12498 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 12499 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 12500 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 12501 | |
| 12502 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 12503 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 12504 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 12505 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12506 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 12507 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 12508 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 12509 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12510 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 12511 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12512 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 12513 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 12514 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 12515 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12516 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12517 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 12518 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12519 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12520 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12521 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12522 | |
| 12523 | /* IPv4 unicast configuration. */ |
| 12524 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 12525 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 12526 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 12527 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 12528 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 12529 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 12530 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12531 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 12532 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 12533 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 12534 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12535 | 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] | 12536 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12537 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 12538 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 12539 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 12540 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12541 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 12542 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 12543 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 12544 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12545 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 12546 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12547 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 12548 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 12549 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 12550 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12551 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12552 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 12553 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12554 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12555 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12556 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12557 | |
| 12558 | /* IPv4 multicast configuration. */ |
| 12559 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 12560 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 12561 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 12562 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 12563 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 12564 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12565 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 12566 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 12567 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 12568 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 12569 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12570 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12571 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 12572 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 12573 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 12574 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12575 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 12576 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 12577 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 12578 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12579 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 12580 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12581 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 12582 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 12583 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 12584 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12585 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12586 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 12587 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12588 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12589 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12590 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12591 | |
| 12592 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 12593 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12594 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12595 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 12596 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12597 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12598 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12599 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12600 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 12601 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12602 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12603 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12604 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12605 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 12606 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 12607 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12608 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 12609 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12610 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12611 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12612 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 12613 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12614 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 12615 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12616 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12617 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12618 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 12619 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12620 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 12621 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 12622 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 12623 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 12624 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12625 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12626 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12627 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12628 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12629 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12630 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12631 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12632 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12633 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 12634 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12635 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12636 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12637 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12638 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12639 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12640 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12641 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 12642 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12643 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12644 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12645 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12646 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12647 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12648 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12649 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12650 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12651 | 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] | 12652 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12653 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12654 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12655 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12656 | install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12657 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12658 | install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12659 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12660 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12661 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12662 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12663 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12664 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12665 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12666 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12667 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12668 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12669 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12670 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12671 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12672 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12673 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12674 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12675 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12676 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12677 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12678 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12679 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12680 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12681 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12682 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12683 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12684 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12685 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12686 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12687 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12688 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12689 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12690 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12691 | |
| 12692 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
| 12693 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
| 12694 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12695 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12696 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12697 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 12698 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12699 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12700 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12701 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12702 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 12703 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12704 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 12705 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 12706 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 12707 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 12708 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12709 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12710 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12711 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12712 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12713 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12714 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12715 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12716 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12717 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 12718 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12719 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12720 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12721 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12722 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12723 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12724 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12725 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12726 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12727 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12728 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12729 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12730 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12731 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12732 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12733 | |
| 12734 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 12735 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12736 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12737 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 12738 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12739 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12740 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12741 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12742 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 12743 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12744 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12745 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12746 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12747 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 12748 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 12749 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12750 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 12751 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12752 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12753 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12754 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 12755 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12756 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 12757 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12758 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12759 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12760 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 12761 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12762 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 12763 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 12764 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 12765 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 12766 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12767 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12768 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12769 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12770 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12771 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12772 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12773 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12774 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12775 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 12776 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12777 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12778 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12779 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12780 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12781 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12782 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12783 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 12784 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12785 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12786 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12787 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12788 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12789 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12790 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12791 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12792 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12793 | 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] | 12794 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12795 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12796 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12797 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12798 | install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12799 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12800 | install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12801 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12802 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12803 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12804 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12805 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12806 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12807 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12808 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12809 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12810 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12811 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12812 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12813 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
| 12814 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12815 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12816 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12817 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame^] | 12818 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12819 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12820 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12821 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12822 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12823 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12824 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12825 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12826 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12827 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12828 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12829 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12830 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12831 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12832 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12833 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12834 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12835 | |
| 12836 | /* BGP dampening clear commands */ |
| 12837 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 12838 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 12839 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 12840 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 12841 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12842 | /* prefix count */ |
| 12843 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 12844 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 12845 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12846 | #ifdef HAVE_IPV6 |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12847 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 12848 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12849 | /* New config IPv6 BGP commands. */ |
| 12850 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 12851 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 12852 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 12853 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 12854 | |
| 12855 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 12856 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 12857 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 12858 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 12859 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 12860 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 12861 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 12862 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12863 | /* Old config IPv6 BGP commands. */ |
| 12864 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 12865 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 12866 | |
| 12867 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 12868 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 12869 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 12870 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 12871 | |
| 12872 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 12873 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12874 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12875 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 12876 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12877 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12878 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 12879 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12880 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12881 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 12882 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12883 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 12884 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12885 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 12886 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12887 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 12888 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12889 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 12890 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12891 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 12892 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 12893 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 12894 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 12895 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 12896 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 12897 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 12898 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 12899 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 12900 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12901 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 12902 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12903 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 12904 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12905 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 12906 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12907 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 12908 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12909 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 12910 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12911 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 12912 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12913 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12914 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12915 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12916 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12917 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 12918 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12919 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12920 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12921 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 12922 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12923 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 12924 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12925 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12926 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12927 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12928 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12929 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12930 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12931 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 12932 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 12933 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 12934 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12935 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 12936 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12937 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12938 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12939 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12940 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12941 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12942 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12943 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12944 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12945 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12946 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12947 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12948 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12949 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12950 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12951 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12952 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12953 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12954 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12955 | |
| 12956 | /* Restricted: |
| 12957 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 12958 | */ |
| 12959 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 12960 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12961 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12962 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
| 12963 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12964 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12965 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 12966 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 12967 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 12968 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 12969 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 12970 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 12971 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 12972 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 12973 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 12974 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12975 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 12976 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12977 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 12978 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12979 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 12980 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12981 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12982 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12983 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12984 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12985 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 12986 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12987 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 12988 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12989 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12990 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12991 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12992 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12993 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12994 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12995 | |
| 12996 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 12997 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12998 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12999 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 13000 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13001 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13002 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 13003 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13004 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13005 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 13006 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 13007 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 13008 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 13009 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 13010 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 13011 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 13012 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 13013 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 13014 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 13015 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 13016 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 13017 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 13018 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 13019 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 13020 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 13021 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 13022 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 13023 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 13024 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 13025 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 13026 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 13027 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 13028 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 13029 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 13030 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 13031 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 13032 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 13033 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 13034 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 13035 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 13036 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 13037 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 13038 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 13039 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 13040 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 13041 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 13042 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 13043 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 13044 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13045 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 13046 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 13047 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 13048 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13049 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13050 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13051 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13052 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13053 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13054 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13055 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 13056 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 13057 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 13058 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 13059 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 13060 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 13061 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 13062 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 13063 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 13064 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 13065 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 13066 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 13067 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 13068 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 13069 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 13070 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 13071 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 13072 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13073 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13074 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13075 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13076 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13077 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13078 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13079 | |
| 13080 | /* Statistics */ |
| 13081 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
| 13082 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 13083 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
| 13084 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
| 13085 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13086 | /* old command */ |
| 13087 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 13088 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 13089 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 13090 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 13091 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 13092 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 13093 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 13094 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 13095 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 13096 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 13097 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 13098 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 13099 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 13100 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 13101 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 13102 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 13103 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 13104 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 13105 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 13106 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 13107 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 13108 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 13109 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 13110 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 13111 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 13112 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 13113 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 13114 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 13115 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 13116 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 13117 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 13118 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 13119 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 13120 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 13121 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 13122 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13123 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13124 | /* old command */ |
| 13125 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 13126 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 13127 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 13128 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 13129 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 13130 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 13131 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 13132 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 13133 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 13134 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 13135 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 13136 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 13137 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 13138 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 13139 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 13140 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 13141 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 13142 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 13143 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 13144 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 13145 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 13146 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 13147 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 13148 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 13149 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 13150 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 13151 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 13152 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 13153 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 13154 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 13155 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 13156 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 13157 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 13158 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 13159 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 13160 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 13161 | |
| 13162 | /* old command */ |
| 13163 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13164 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13165 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13166 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13167 | |
| 13168 | /* old command */ |
| 13169 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13170 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13171 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13172 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13173 | |
| 13174 | /* old command */ |
| 13175 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13176 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13177 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13178 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13179 | #endif /* HAVE_IPV6 */ |
| 13180 | |
| 13181 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 13182 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 13183 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 13184 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 13185 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 13186 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 13187 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 13188 | |
| 13189 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 13190 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 13191 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 13192 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 13193 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 13194 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 13195 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 13196 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 13197 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 13198 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13199 | |
| 13200 | /* Deprecated AS-Pathlimit commands */ |
| 13201 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 13202 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 13203 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13204 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13205 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13206 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13207 | |
| 13208 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 13209 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13210 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13211 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13212 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13213 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13214 | |
| 13215 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 13216 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 13217 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13218 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13219 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13220 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13221 | |
| 13222 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 13223 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13224 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13225 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13226 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13227 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13228 | |
| 13229 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 13230 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 13231 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13232 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13233 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13234 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13235 | |
| 13236 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 13237 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13238 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13239 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13240 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13241 | 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] | 13242 | |
| 13243 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13244 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 13245 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 13246 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13247 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 13248 | |
| 13249 | void |
| 13250 | bgp_route_finish (void) |
| 13251 | { |
| 13252 | bgp_table_unlock (bgp_distance_table); |
| 13253 | bgp_distance_table = NULL; |
| 13254 | } |