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 | |
| 527 | /* 11. Rourter-ID comparision. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 528 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 529 | new_id.s_addr = newattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 530 | else |
| 531 | new_id.s_addr = new->peer->remote_id.s_addr; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 532 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 533 | exist_id.s_addr = existattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 534 | else |
| 535 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 536 | |
| 537 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 538 | return 1; |
| 539 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 540 | return 0; |
| 541 | |
| 542 | /* 12. Cluster length comparision. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 543 | new_cluster = exist_cluster = 0; |
| 544 | |
| 545 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 546 | new_cluster = newattre->cluster->length; |
| 547 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 548 | exist_cluster = existattre->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 549 | |
| 550 | if (new_cluster < exist_cluster) |
| 551 | return 1; |
| 552 | if (new_cluster > exist_cluster) |
| 553 | return 0; |
| 554 | |
| 555 | /* 13. Neighbor address comparision. */ |
| 556 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 557 | |
| 558 | if (ret == 1) |
| 559 | return 0; |
| 560 | if (ret == -1) |
| 561 | return 1; |
| 562 | |
| 563 | return 1; |
| 564 | } |
| 565 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 566 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 567 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 568 | afi_t afi, safi_t safi) |
| 569 | { |
| 570 | struct bgp_filter *filter; |
| 571 | |
| 572 | filter = &peer->filter[afi][safi]; |
| 573 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 574 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 575 | if (BGP_DEBUG (update, UPDATE_IN) \ |
| 576 | && !(F ## _IN (filter))) \ |
| 577 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ |
| 578 | peer->host, #f, F ## _IN_NAME(filter)); |
| 579 | |
| 580 | if (DISTRIBUTE_IN_NAME (filter)) { |
| 581 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 582 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 583 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 584 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 585 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 586 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 587 | if (PREFIX_LIST_IN_NAME (filter)) { |
| 588 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 589 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 590 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 591 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 592 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 593 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 594 | if (FILTER_LIST_IN_NAME (filter)) { |
| 595 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 596 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 597 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 598 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 599 | } |
| 600 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 601 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 602 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 603 | } |
| 604 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 605 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 606 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 607 | afi_t afi, safi_t safi) |
| 608 | { |
| 609 | struct bgp_filter *filter; |
| 610 | |
| 611 | filter = &peer->filter[afi][safi]; |
| 612 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 613 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 614 | if (BGP_DEBUG (update, UPDATE_OUT) \ |
| 615 | && !(F ## _OUT (filter))) \ |
| 616 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ |
| 617 | peer->host, #f, F ## _OUT_NAME(filter)); |
| 618 | |
| 619 | if (DISTRIBUTE_OUT_NAME (filter)) { |
| 620 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 621 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 622 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 623 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 624 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 625 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 626 | if (PREFIX_LIST_OUT_NAME (filter)) { |
| 627 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 628 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 629 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 630 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 631 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 632 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 633 | if (FILTER_LIST_OUT_NAME (filter)) { |
| 634 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 635 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 636 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 637 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 638 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 639 | |
| 640 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 641 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 645 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 646 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 647 | { |
| 648 | if (attr->community) |
| 649 | { |
| 650 | /* NO_ADVERTISE check. */ |
| 651 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 652 | return 1; |
| 653 | |
| 654 | /* NO_EXPORT check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 655 | if (peer->sort == BGP_PEER_EBGP && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 656 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 657 | return 1; |
| 658 | |
| 659 | /* NO_EXPORT_SUBCONFED check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 660 | if (peer->sort == BGP_PEER_EBGP |
| 661 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 662 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 663 | return 1; |
| 664 | } |
| 665 | return 0; |
| 666 | } |
| 667 | |
| 668 | /* Route reflection loop check. */ |
| 669 | static int |
| 670 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 671 | { |
| 672 | struct in_addr cluster_id; |
| 673 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 674 | if (attr->extra && attr->extra->cluster) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 675 | { |
| 676 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 677 | cluster_id = peer->bgp->cluster_id; |
| 678 | else |
| 679 | cluster_id = peer->bgp->router_id; |
| 680 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 681 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 682 | return 1; |
| 683 | } |
| 684 | return 0; |
| 685 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 686 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 687 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 688 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 689 | afi_t afi, safi_t safi) |
| 690 | { |
| 691 | struct bgp_filter *filter; |
| 692 | struct bgp_info info; |
| 693 | route_map_result_t ret; |
| 694 | |
| 695 | filter = &peer->filter[afi][safi]; |
| 696 | |
| 697 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 698 | if (peer->weight) |
| 699 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 700 | |
| 701 | /* Route map apply. */ |
| 702 | if (ROUTE_MAP_IN_NAME (filter)) |
| 703 | { |
| 704 | /* Duplicate current value to new strucutre for modification. */ |
| 705 | info.peer = peer; |
| 706 | info.attr = attr; |
| 707 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 708 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 709 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 710 | /* Apply BGP route map to the attribute. */ |
| 711 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 712 | |
| 713 | peer->rmap_type = 0; |
| 714 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 715 | if (ret == RMAP_DENYMATCH) |
| 716 | { |
| 717 | /* Free newly generated AS path and community by route-map. */ |
| 718 | bgp_attr_flush (attr); |
| 719 | return RMAP_DENY; |
| 720 | } |
| 721 | } |
| 722 | return RMAP_PERMIT; |
| 723 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 724 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 725 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 726 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 727 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 728 | { |
| 729 | struct bgp_filter *filter; |
| 730 | struct bgp_info info; |
| 731 | route_map_result_t ret; |
| 732 | |
| 733 | filter = &peer->filter[afi][safi]; |
| 734 | |
| 735 | /* Route map apply. */ |
| 736 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 737 | { |
| 738 | /* Duplicate current value to new strucutre for modification. */ |
| 739 | info.peer = rsclient; |
| 740 | info.attr = attr; |
| 741 | |
| 742 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 743 | |
| 744 | /* Apply BGP route map to the attribute. */ |
| 745 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 746 | |
| 747 | rsclient->rmap_type = 0; |
| 748 | |
| 749 | if (ret == RMAP_DENYMATCH) |
| 750 | { |
| 751 | /* Free newly generated AS path and community by route-map. */ |
| 752 | bgp_attr_flush (attr); |
| 753 | return RMAP_DENY; |
| 754 | } |
| 755 | } |
| 756 | return RMAP_PERMIT; |
| 757 | } |
| 758 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 759 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 760 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 761 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 762 | { |
| 763 | struct bgp_filter *filter; |
| 764 | struct bgp_info info; |
| 765 | route_map_result_t ret; |
| 766 | |
| 767 | filter = &rsclient->filter[afi][safi]; |
| 768 | |
| 769 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 770 | if (peer->weight) |
| 771 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 772 | |
| 773 | /* Route map apply. */ |
| 774 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 775 | { |
| 776 | /* Duplicate current value to new strucutre for modification. */ |
| 777 | info.peer = peer; |
| 778 | info.attr = attr; |
| 779 | |
| 780 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 781 | |
| 782 | /* Apply BGP route map to the attribute. */ |
| 783 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 784 | |
| 785 | peer->rmap_type = 0; |
| 786 | |
| 787 | if (ret == RMAP_DENYMATCH) |
| 788 | { |
| 789 | /* Free newly generated AS path and community by route-map. */ |
| 790 | bgp_attr_flush (attr); |
| 791 | return RMAP_DENY; |
| 792 | } |
| 793 | } |
| 794 | return RMAP_PERMIT; |
| 795 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 796 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 797 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 798 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 799 | struct attr *attr, afi_t afi, safi_t safi) |
| 800 | { |
| 801 | int ret; |
| 802 | char buf[SU_ADDRSTRLEN]; |
| 803 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 804 | struct peer *from; |
| 805 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 806 | int transparent; |
| 807 | int reflect; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 808 | struct attr *riattr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 809 | |
| 810 | from = ri->peer; |
| 811 | filter = &peer->filter[afi][safi]; |
| 812 | bgp = peer->bgp; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 813 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 814 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 815 | if (DISABLE_BGP_ANNOUNCE) |
| 816 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 817 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 818 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 819 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 820 | return 0; |
| 821 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 822 | /* Do not send back route to sender. */ |
| 823 | if (from == peer) |
| 824 | return 0; |
| 825 | |
| 826 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 827 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 828 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 829 | return 0; |
| 830 | |
| 831 | /* Default route check. */ |
| 832 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 833 | { |
| 834 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 835 | return 0; |
| 836 | #ifdef HAVE_IPV6 |
| 837 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 838 | return 0; |
| 839 | #endif /* HAVE_IPV6 */ |
| 840 | } |
| 841 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 842 | /* Transparency check. */ |
| 843 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 844 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 845 | transparent = 1; |
| 846 | else |
| 847 | transparent = 0; |
| 848 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 849 | /* If community is not disabled check the no-export and local. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 850 | if (! transparent && bgp_community_filter (peer, riattr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 851 | return 0; |
| 852 | |
| 853 | /* If the attribute has originator-id and it is same as remote |
| 854 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 855 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 856 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 857 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 858 | { |
| 859 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 860 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 861 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 862 | peer->host, |
| 863 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 864 | p->prefixlen); |
| 865 | return 0; |
| 866 | } |
| 867 | } |
| 868 | |
| 869 | /* ORF prefix-list filter check */ |
| 870 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 871 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 872 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 873 | if (peer->orf_plist[afi][safi]) |
| 874 | { |
| 875 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 876 | return 0; |
| 877 | } |
| 878 | |
| 879 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 880 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 881 | { |
| 882 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 883 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 884 | "%s [Update:SEND] %s/%d is filtered", |
| 885 | peer->host, |
| 886 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 887 | p->prefixlen); |
| 888 | return 0; |
| 889 | } |
| 890 | |
| 891 | #ifdef BGP_SEND_ASPATH_CHECK |
| 892 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 893 | if (aspath_loop_check (riattr->aspath, peer->as)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 894 | { |
| 895 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 896 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 897 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 898 | peer->host, peer->as); |
| 899 | return 0; |
| 900 | } |
| 901 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 902 | |
| 903 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 904 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 905 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 906 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 907 | { |
| 908 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 909 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 910 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 911 | peer->host, |
| 912 | bgp->confed_id); |
| 913 | return 0; |
| 914 | } |
| 915 | } |
| 916 | |
| 917 | /* Route-Reflect check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 918 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 919 | reflect = 1; |
| 920 | else |
| 921 | reflect = 0; |
| 922 | |
| 923 | /* IBGP reflection check. */ |
| 924 | if (reflect) |
| 925 | { |
| 926 | /* A route from a Client peer. */ |
| 927 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 928 | { |
| 929 | /* Reflect to all the Non-Client peers and also to the |
| 930 | Client peers other than the originator. Originator check |
| 931 | is already done. So there is noting to do. */ |
| 932 | /* no bgp client-to-client reflection check. */ |
| 933 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 934 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 935 | return 0; |
| 936 | } |
| 937 | else |
| 938 | { |
| 939 | /* A route from a Non-client peer. Reflect to all other |
| 940 | clients. */ |
| 941 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 942 | return 0; |
| 943 | } |
| 944 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 945 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 946 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 947 | bgp_attr_dup (attr, riattr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 948 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 949 | /* If local-preference is not set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 950 | if ((peer->sort == BGP_PEER_IBGP |
| 951 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 952 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 953 | { |
| 954 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 955 | attr->local_pref = bgp->default_local_pref; |
| 956 | } |
| 957 | |
Pradosh Mohapatra | 689bb66 | 2013-09-07 07:13:37 +0000 | [diff] [blame] | 958 | /* If originator-id is not set and the route is to be reflected, |
| 959 | set the originator id */ |
| 960 | if (peer && from && peer->sort == BGP_PEER_IBGP && |
| 961 | from->sort == BGP_PEER_IBGP && |
| 962 | (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) |
| 963 | { |
| 964 | attr->extra = bgp_attr_extra_get(attr); |
| 965 | IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id)); |
| 966 | SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID); |
| 967 | } |
| 968 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 969 | /* 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] | 970 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 971 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 972 | { |
| 973 | if (ri->peer != bgp->peer_self && ! transparent |
| 974 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 975 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 976 | } |
| 977 | |
| 978 | /* next-hop-set */ |
| 979 | if (transparent || reflect |
| 980 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 981 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 982 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 983 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 984 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 985 | #endif /* HAVE_IPV6 */ |
| 986 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 987 | { |
| 988 | /* NEXT-HOP Unchanged. */ |
| 989 | } |
| 990 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 991 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 992 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 993 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 994 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 995 | #endif /* HAVE_IPV6 */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 996 | || (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 997 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 998 | { |
| 999 | /* Set IPv4 nexthop. */ |
| 1000 | if (p->family == AF_INET) |
| 1001 | { |
| 1002 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1003 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 1004 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1005 | else |
| 1006 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1007 | } |
| 1008 | #ifdef HAVE_IPV6 |
| 1009 | /* Set IPv6 nexthop. */ |
| 1010 | if (p->family == AF_INET6) |
| 1011 | { |
| 1012 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1013 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1014 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1015 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1016 | } |
| 1017 | #endif /* HAVE_IPV6 */ |
| 1018 | } |
| 1019 | |
| 1020 | #ifdef HAVE_IPV6 |
| 1021 | if (p->family == AF_INET6) |
| 1022 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1023 | /* Left nexthop_local unchanged if so configured. */ |
| 1024 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 1025 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1026 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1027 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 1028 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1029 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1030 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1031 | } |
| 1032 | |
| 1033 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 1034 | else |
| 1035 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1036 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1037 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1038 | |
| 1039 | /* Set link-local address for shared network peer. */ |
| 1040 | if (peer->shared_network |
| 1041 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 1042 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1043 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1044 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1045 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1046 | } |
| 1047 | |
| 1048 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 1049 | address.*/ |
| 1050 | if (reflect) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1051 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1052 | |
| 1053 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 1054 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1055 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1056 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1057 | |
| 1058 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1059 | #endif /* HAVE_IPV6 */ |
| 1060 | |
| 1061 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1062 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1063 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1064 | && aspath_private_as_check (attr->aspath)) |
| 1065 | attr->aspath = aspath_empty_get (); |
| 1066 | |
| 1067 | /* Route map & unsuppress-map apply. */ |
| 1068 | if (ROUTE_MAP_OUT_NAME (filter) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1069 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1070 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1071 | struct bgp_info info; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1072 | struct attr dummy_attr; |
| 1073 | struct attr_extra dummy_extra; |
| 1074 | |
| 1075 | dummy_attr.extra = &dummy_extra; |
| 1076 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1077 | info.peer = peer; |
| 1078 | info.attr = attr; |
| 1079 | |
| 1080 | /* The route reflector is not allowed to modify the attributes |
| 1081 | of the reflected IBGP routes. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1082 | if (from->sort == BGP_PEER_IBGP |
| 1083 | && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1084 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1085 | bgp_attr_dup (&dummy_attr, attr); |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1086 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1087 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1088 | |
| 1089 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1090 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1091 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1092 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1093 | else |
| 1094 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1095 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1096 | peer->rmap_type = 0; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1097 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1098 | if (ret == RMAP_DENYMATCH) |
| 1099 | { |
| 1100 | bgp_attr_flush (attr); |
| 1101 | return 0; |
| 1102 | } |
| 1103 | } |
| 1104 | return 1; |
| 1105 | } |
| 1106 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1107 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1108 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1109 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1110 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1111 | int ret; |
| 1112 | char buf[SU_ADDRSTRLEN]; |
| 1113 | struct bgp_filter *filter; |
| 1114 | struct bgp_info info; |
| 1115 | struct peer *from; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1116 | struct attr *riattr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1117 | |
| 1118 | from = ri->peer; |
| 1119 | filter = &rsclient->filter[afi][safi]; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1120 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1121 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 1122 | if (DISABLE_BGP_ANNOUNCE) |
| 1123 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1124 | |
| 1125 | /* Do not send back route to sender. */ |
| 1126 | if (from == rsclient) |
| 1127 | return 0; |
| 1128 | |
| 1129 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1130 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1131 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 1132 | return 0; |
| 1133 | |
| 1134 | /* Default route check. */ |
| 1135 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1136 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1137 | { |
| 1138 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1139 | return 0; |
| 1140 | #ifdef HAVE_IPV6 |
| 1141 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1142 | return 0; |
| 1143 | #endif /* HAVE_IPV6 */ |
| 1144 | } |
| 1145 | |
| 1146 | /* If the attribute has originator-id and it is same as remote |
| 1147 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1148 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1149 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1150 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1151 | &riattr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1152 | { |
| 1153 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1154 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1155 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1156 | rsclient->host, |
| 1157 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1158 | p->prefixlen); |
| 1159 | return 0; |
| 1160 | } |
| 1161 | } |
| 1162 | |
| 1163 | /* ORF prefix-list filter check */ |
| 1164 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1165 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1166 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1167 | if (rsclient->orf_plist[afi][safi]) |
| 1168 | { |
| 1169 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1170 | return 0; |
| 1171 | } |
| 1172 | |
| 1173 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1174 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1175 | { |
| 1176 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1177 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1178 | "%s [Update:SEND] %s/%d is filtered", |
| 1179 | rsclient->host, |
| 1180 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1181 | p->prefixlen); |
| 1182 | return 0; |
| 1183 | } |
| 1184 | |
| 1185 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1186 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1187 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1188 | { |
| 1189 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1190 | zlog (rsclient->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 1191 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1192 | rsclient->host, rsclient->as); |
| 1193 | return 0; |
| 1194 | } |
| 1195 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1196 | |
| 1197 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1198 | bgp_attr_dup (attr, riattr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1199 | |
| 1200 | /* next-hop-set */ |
| 1201 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1202 | #ifdef HAVE_IPV6 |
| 1203 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1204 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1205 | #endif /* HAVE_IPV6 */ |
| 1206 | ) |
| 1207 | { |
| 1208 | /* Set IPv4 nexthop. */ |
| 1209 | if (p->family == AF_INET) |
| 1210 | { |
| 1211 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1212 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1213 | IPV4_MAX_BYTELEN); |
| 1214 | else |
| 1215 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1216 | } |
| 1217 | #ifdef HAVE_IPV6 |
| 1218 | /* Set IPv6 nexthop. */ |
| 1219 | if (p->family == AF_INET6) |
| 1220 | { |
| 1221 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1222 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1223 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1224 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1225 | } |
| 1226 | #endif /* HAVE_IPV6 */ |
| 1227 | } |
| 1228 | |
| 1229 | #ifdef HAVE_IPV6 |
| 1230 | if (p->family == AF_INET6) |
| 1231 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1232 | struct attr_extra *attre = attr->extra; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1233 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1234 | /* Left nexthop_local unchanged if so configured. */ |
| 1235 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1236 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1237 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1238 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1239 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1240 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1241 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1242 | } |
| 1243 | |
| 1244 | /* Default nexthop_local treatment for RS-Clients */ |
| 1245 | else |
| 1246 | { |
| 1247 | /* Announcer and RS-Client are both in the same network */ |
| 1248 | if (rsclient->shared_network && from->shared_network && |
| 1249 | (rsclient->ifindex == from->ifindex)) |
| 1250 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1251 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1252 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1253 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1254 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1255 | } |
| 1256 | |
| 1257 | /* Set link-local address for shared network peer. */ |
| 1258 | else if (rsclient->shared_network |
| 1259 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1260 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1261 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1262 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1263 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1264 | } |
| 1265 | |
| 1266 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1267 | attre->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1268 | } |
| 1269 | |
| 1270 | } |
| 1271 | #endif /* HAVE_IPV6 */ |
| 1272 | |
| 1273 | |
| 1274 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1275 | if (rsclient->sort == BGP_PEER_EBGP |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1276 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1277 | && aspath_private_as_check (attr->aspath)) |
| 1278 | attr->aspath = aspath_empty_get (); |
| 1279 | |
| 1280 | /* Route map & unsuppress-map apply. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1281 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1282 | { |
| 1283 | info.peer = rsclient; |
| 1284 | info.attr = attr; |
| 1285 | |
| 1286 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1287 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1288 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1289 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1290 | else |
| 1291 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1292 | |
| 1293 | rsclient->rmap_type = 0; |
| 1294 | |
| 1295 | if (ret == RMAP_DENYMATCH) |
| 1296 | { |
| 1297 | bgp_attr_flush (attr); |
| 1298 | return 0; |
| 1299 | } |
| 1300 | } |
| 1301 | |
| 1302 | return 1; |
| 1303 | } |
| 1304 | |
| 1305 | struct bgp_info_pair |
| 1306 | { |
| 1307 | struct bgp_info *old; |
| 1308 | struct bgp_info *new; |
| 1309 | }; |
| 1310 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1311 | static void |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1312 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
| 1313 | struct bgp_maxpaths_cfg *mpath_cfg, |
| 1314 | struct bgp_info_pair *result) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1315 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1316 | struct bgp_info *new_select; |
| 1317 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1318 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1319 | struct bgp_info *ri1; |
| 1320 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1321 | struct bgp_info *nextri = NULL; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1322 | int paths_eq, do_mpath; |
| 1323 | struct list mp_list; |
| 1324 | |
| 1325 | bgp_mp_list_init (&mp_list); |
| 1326 | do_mpath = (mpath_cfg->maxpaths_ebgp != BGP_DEFAULT_MAXPATHS || |
| 1327 | mpath_cfg->maxpaths_ibgp != BGP_DEFAULT_MAXPATHS); |
| 1328 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1329 | /* bgp deterministic-med */ |
| 1330 | new_select = NULL; |
| 1331 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1332 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1333 | { |
| 1334 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1335 | continue; |
| 1336 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1337 | continue; |
| 1338 | |
| 1339 | new_select = ri1; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1340 | if (do_mpath) |
| 1341 | bgp_mp_list_add (&mp_list, ri1); |
| 1342 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1343 | if (ri1->next) |
| 1344 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1345 | { |
| 1346 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1347 | continue; |
| 1348 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1349 | continue; |
| 1350 | |
| 1351 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1352 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1353 | ri2->attr->aspath)) |
| 1354 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1355 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
| 1356 | old_select = ri2; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1357 | if (bgp_info_cmp (bgp, ri2, new_select, &paths_eq)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1358 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1359 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1360 | new_select = ri2; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1361 | if (do_mpath && !paths_eq) |
| 1362 | { |
| 1363 | bgp_mp_list_clear (&mp_list); |
| 1364 | bgp_mp_list_add (&mp_list, ri2); |
| 1365 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1366 | } |
| 1367 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1368 | if (do_mpath && paths_eq) |
| 1369 | bgp_mp_list_add (&mp_list, ri2); |
| 1370 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1371 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1372 | } |
| 1373 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1374 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1375 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1376 | |
| 1377 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); |
| 1378 | bgp_mp_list_clear (&mp_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1379 | } |
| 1380 | |
| 1381 | /* Check old selected route and new selected route. */ |
| 1382 | old_select = NULL; |
| 1383 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1384 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1385 | { |
| 1386 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1387 | old_select = ri; |
| 1388 | |
| 1389 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1390 | { |
| 1391 | /* reap REMOVED routes, if needs be |
| 1392 | * selected route must stay for a while longer though |
| 1393 | */ |
| 1394 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1395 | && (ri != old_select)) |
| 1396 | bgp_info_reap (rn, ri); |
| 1397 | |
| 1398 | continue; |
| 1399 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1400 | |
| 1401 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1402 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1403 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1404 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1405 | continue; |
| 1406 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1407 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1408 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1409 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1410 | if (bgp_info_cmp (bgp, ri, new_select, &paths_eq)) |
| 1411 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1412 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1413 | bgp_mp_dmed_deselect (new_select); |
| 1414 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1415 | new_select = ri; |
| 1416 | |
| 1417 | if (do_mpath && !paths_eq) |
| 1418 | { |
| 1419 | bgp_mp_list_clear (&mp_list); |
| 1420 | bgp_mp_list_add (&mp_list, ri); |
| 1421 | } |
| 1422 | } |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1423 | else if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1424 | bgp_mp_dmed_deselect (ri); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1425 | |
| 1426 | if (do_mpath && paths_eq) |
| 1427 | bgp_mp_list_add (&mp_list, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1428 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1429 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1430 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1431 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1432 | 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] | 1433 | |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1434 | bgp_info_mpath_aggregate_update (new_select, old_select); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1435 | bgp_mp_list_clear (&mp_list); |
| 1436 | |
| 1437 | result->old = old_select; |
| 1438 | result->new = new_select; |
| 1439 | |
| 1440 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1441 | } |
| 1442 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1443 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1444 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1445 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1446 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1447 | struct prefix *p; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1448 | struct attr attr; |
| 1449 | struct attr_extra extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1450 | |
| 1451 | p = &rn->p; |
| 1452 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1453 | /* Announce route to Established peer. */ |
| 1454 | if (peer->status != Established) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1455 | return 0; |
| 1456 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1457 | /* Address family configuration check. */ |
| 1458 | if (! peer->afc_nego[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1459 | return 0; |
| 1460 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1461 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1462 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1463 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1464 | return 0; |
| 1465 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1466 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 1467 | attr.extra = &extra; |
| 1468 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1469 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1470 | { |
| 1471 | case BGP_TABLE_MAIN: |
| 1472 | /* Announcement to peer->conf. If the route is filtered, |
| 1473 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1474 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
| 1475 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1476 | else |
| 1477 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1478 | break; |
| 1479 | case BGP_TABLE_RSCLIENT: |
| 1480 | /* Announcement to peer->conf. If the route is filtered, |
| 1481 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1482 | if (selected && |
| 1483 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) |
| 1484 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
| 1485 | else |
| 1486 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1487 | break; |
| 1488 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1489 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1490 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1491 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1492 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1493 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1494 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1495 | struct bgp *bgp; |
| 1496 | struct bgp_node *rn; |
| 1497 | afi_t afi; |
| 1498 | safi_t safi; |
| 1499 | }; |
| 1500 | |
| 1501 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1502 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1503 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1504 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1505 | struct bgp *bgp = pq->bgp; |
| 1506 | struct bgp_node *rn = pq->rn; |
| 1507 | afi_t afi = pq->afi; |
| 1508 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1509 | struct bgp_info *new_select; |
| 1510 | struct bgp_info *old_select; |
| 1511 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1512 | struct listnode *node, *nnode; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1513 | struct peer *rsclient = bgp_node_table (rn)->owner; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1514 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1515 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1516 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1517 | new_select = old_and_new.new; |
| 1518 | old_select = old_and_new.old; |
| 1519 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1520 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1521 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1522 | if (rsclient->group) |
| 1523 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1524 | { |
| 1525 | /* Nothing to do. */ |
| 1526 | if (old_select && old_select == new_select) |
| 1527 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1528 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1529 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1530 | if (old_select) |
| 1531 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
| 1532 | if (new_select) |
| 1533 | { |
| 1534 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1535 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1536 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
| 1537 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1538 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1539 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1540 | afi, safi); |
| 1541 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1542 | } |
| 1543 | else |
| 1544 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1545 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1546 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1547 | if (new_select) |
| 1548 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1549 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1550 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1551 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1552 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1553 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1554 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1555 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1556 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1557 | bgp_info_reap (rn, old_select); |
| 1558 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1559 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1560 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1561 | } |
| 1562 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1563 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1564 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1565 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1566 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1567 | struct bgp *bgp = pq->bgp; |
| 1568 | struct bgp_node *rn = pq->rn; |
| 1569 | afi_t afi = pq->afi; |
| 1570 | safi_t safi = pq->safi; |
| 1571 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1572 | struct bgp_info *new_select; |
| 1573 | struct bgp_info *old_select; |
| 1574 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1575 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1576 | struct peer *peer; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1577 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1578 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1579 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1580 | old_select = old_and_new.old; |
| 1581 | new_select = old_and_new.new; |
| 1582 | |
| 1583 | /* Nothing to do. */ |
| 1584 | if (old_select && old_select == new_select) |
| 1585 | { |
| 1586 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1587 | { |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1588 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
| 1589 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1590 | bgp_zebra_announce (p, old_select, bgp, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1591 | |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1592 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1593 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1594 | return WQ_SUCCESS; |
| 1595 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1596 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1597 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1598 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1599 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1600 | if (new_select) |
| 1601 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1602 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1603 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1604 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1605 | } |
| 1606 | |
| 1607 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1608 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1609 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1610 | { |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1611 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1612 | } |
| 1613 | |
| 1614 | /* FIB update. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1615 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
| 1616 | ! bgp_option_check (BGP_OPT_NO_FIB))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1617 | { |
| 1618 | if (new_select |
| 1619 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1620 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1621 | bgp_zebra_announce (p, new_select, bgp, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1622 | else |
| 1623 | { |
| 1624 | /* Withdraw the route from the kernel. */ |
| 1625 | if (old_select |
| 1626 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1627 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1628 | bgp_zebra_withdraw (p, old_select, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1629 | } |
| 1630 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1631 | |
| 1632 | /* Reap old select bgp_info, it it has been removed */ |
| 1633 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1634 | bgp_info_reap (rn, old_select); |
| 1635 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1636 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1637 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1638 | } |
| 1639 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1640 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1641 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1642 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1643 | struct bgp_process_queue *pq = data; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1644 | struct bgp_table *table = bgp_node_table (pq->rn); |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1645 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1646 | bgp_unlock (pq->bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1647 | bgp_unlock_node (pq->rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1648 | bgp_table_unlock (table); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1649 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1650 | } |
| 1651 | |
| 1652 | static void |
| 1653 | bgp_process_queue_init (void) |
| 1654 | { |
| 1655 | bm->process_main_queue |
| 1656 | = work_queue_new (bm->master, "process_main_queue"); |
| 1657 | bm->process_rsclient_queue |
| 1658 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1659 | |
| 1660 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1661 | { |
| 1662 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1663 | exit (1); |
| 1664 | } |
| 1665 | |
| 1666 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1667 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1668 | bm->process_main_queue->spec.max_retries = 0; |
| 1669 | bm->process_main_queue->spec.hold = 50; |
| 1670 | |
| 1671 | memcpy (bm->process_rsclient_queue, bm->process_main_queue, |
| 1672 | sizeof (struct work_queue *)); |
| 1673 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1674 | } |
| 1675 | |
| 1676 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1677 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1678 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1679 | struct bgp_process_queue *pqnode; |
| 1680 | |
| 1681 | /* already scheduled for processing? */ |
| 1682 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1683 | return; |
| 1684 | |
| 1685 | if ( (bm->process_main_queue == NULL) || |
| 1686 | (bm->process_rsclient_queue == NULL) ) |
| 1687 | bgp_process_queue_init (); |
| 1688 | |
| 1689 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1690 | sizeof (struct bgp_process_queue)); |
| 1691 | if (!pqnode) |
| 1692 | return; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1693 | |
| 1694 | /* all unlocked in bgp_processq_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1695 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1696 | pqnode->rn = bgp_lock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1697 | pqnode->bgp = bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1698 | bgp_lock (bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1699 | pqnode->afi = afi; |
| 1700 | pqnode->safi = safi; |
| 1701 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1702 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1703 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1704 | case BGP_TABLE_MAIN: |
| 1705 | work_queue_add (bm->process_main_queue, pqnode); |
| 1706 | break; |
| 1707 | case BGP_TABLE_RSCLIENT: |
| 1708 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1709 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1710 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1711 | |
Stephen Hemminger | 07ff4dc | 2013-01-04 22:29:20 +0000 | [diff] [blame] | 1712 | SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1713 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1714 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1715 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1716 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1717 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1718 | { |
| 1719 | struct peer *peer; |
| 1720 | |
| 1721 | peer = THREAD_ARG (thread); |
| 1722 | peer->t_pmax_restart = NULL; |
| 1723 | |
| 1724 | if (BGP_DEBUG (events, EVENTS)) |
| 1725 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1726 | peer->host); |
| 1727 | |
| 1728 | peer_clear (peer); |
| 1729 | |
| 1730 | return 0; |
| 1731 | } |
| 1732 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1733 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1734 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1735 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1736 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1737 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1738 | return 0; |
| 1739 | |
| 1740 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1741 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1742 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1743 | && ! always) |
| 1744 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1745 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1746 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1747 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1748 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1749 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1750 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1751 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1752 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1753 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1754 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1755 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1756 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1757 | |
| 1758 | if (safi == SAFI_MPLS_VPN) |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 1759 | safi = SAFI_MPLS_LABELED_VPN; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1760 | |
| 1761 | ndata[0] = (afi >> 8); |
| 1762 | ndata[1] = afi; |
| 1763 | ndata[2] = safi; |
| 1764 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1765 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1766 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1767 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1768 | |
| 1769 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1770 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1771 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1772 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1773 | |
| 1774 | /* restart timer start */ |
| 1775 | if (peer->pmax_restart[afi][safi]) |
| 1776 | { |
| 1777 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1778 | |
| 1779 | if (BGP_DEBUG (events, EVENTS)) |
| 1780 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1781 | peer->host, peer->v_pmax_restart); |
| 1782 | |
| 1783 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1784 | peer->v_pmax_restart); |
| 1785 | } |
| 1786 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1787 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1788 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1789 | else |
| 1790 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1791 | |
| 1792 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1793 | { |
| 1794 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1795 | && ! always) |
| 1796 | return 0; |
| 1797 | |
| 1798 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1799 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1800 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1801 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1802 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1803 | } |
| 1804 | else |
| 1805 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1806 | return 0; |
| 1807 | } |
| 1808 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1809 | /* Unconditionally remove the route from the RIB, without taking |
| 1810 | * damping into consideration (eg, because the session went down) |
| 1811 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1812 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1813 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1814 | afi_t afi, safi_t safi) |
| 1815 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1816 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1817 | |
| 1818 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1819 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1820 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1821 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1822 | } |
| 1823 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1824 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1825 | 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] | 1826 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1827 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1828 | int status = BGP_DAMP_NONE; |
| 1829 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1830 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1831 | * the bgp_info in the RIB for historical reference. |
| 1832 | */ |
| 1833 | 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] | 1834 | && peer->sort == BGP_PEER_EBGP) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1835 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1836 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1837 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1838 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1839 | return; |
| 1840 | } |
| 1841 | |
| 1842 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1843 | } |
| 1844 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1845 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1846 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1847 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1848 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1849 | { |
| 1850 | struct bgp_node *rn; |
| 1851 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1852 | struct attr new_attr; |
| 1853 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1854 | struct attr *attr_new; |
| 1855 | struct attr *attr_new2; |
| 1856 | struct bgp_info *ri; |
| 1857 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1858 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1859 | char buf[SU_ADDRSTRLEN]; |
| 1860 | |
| 1861 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1862 | if (peer == rsclient) |
| 1863 | return; |
| 1864 | |
| 1865 | bgp = peer->bgp; |
| 1866 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1867 | |
| 1868 | /* Check previously received route. */ |
| 1869 | for (ri = rn->info; ri; ri = ri->next) |
| 1870 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1871 | break; |
| 1872 | |
| 1873 | /* AS path loop check. */ |
Milan Kocian | 000e157 | 2013-10-18 07:59:38 +0000 | [diff] [blame] | 1874 | if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1875 | { |
| 1876 | reason = "as-path contains our own AS;"; |
| 1877 | goto filtered; |
| 1878 | } |
| 1879 | |
| 1880 | /* Route reflector originator ID check. */ |
| 1881 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1882 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1883 | { |
| 1884 | reason = "originator is us;"; |
| 1885 | goto filtered; |
| 1886 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1887 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1888 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1889 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1890 | |
| 1891 | /* Apply export policy. */ |
| 1892 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1893 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1894 | { |
| 1895 | reason = "export-policy;"; |
| 1896 | goto filtered; |
| 1897 | } |
| 1898 | |
| 1899 | attr_new2 = bgp_attr_intern (&new_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1900 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1901 | /* Apply import policy. */ |
| 1902 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1903 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1904 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1905 | |
| 1906 | reason = "import-policy;"; |
| 1907 | goto filtered; |
| 1908 | } |
| 1909 | |
| 1910 | attr_new = bgp_attr_intern (&new_attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1911 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1912 | |
| 1913 | /* IPv4 unicast next hop check. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1914 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1915 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1916 | /* 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] | 1917 | if (new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1918 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1919 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1920 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1921 | |
| 1922 | reason = "martian next-hop;"; |
| 1923 | goto filtered; |
| 1924 | } |
| 1925 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1926 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1927 | /* If the update is implicit withdraw. */ |
| 1928 | if (ri) |
| 1929 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1930 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1931 | |
| 1932 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1933 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1934 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1935 | { |
| 1936 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1937 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1938 | |
| 1939 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1940 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1941 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1942 | peer->host, |
| 1943 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1944 | p->prefixlen, rsclient->host); |
| 1945 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1946 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1947 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1948 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1949 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1950 | } |
| 1951 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1952 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 1953 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 1954 | bgp_info_restore (rn, ri); |
| 1955 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1956 | /* Received Logging. */ |
| 1957 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1958 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1959 | peer->host, |
| 1960 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1961 | p->prefixlen, rsclient->host); |
| 1962 | |
| 1963 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1964 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1965 | |
| 1966 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1967 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1968 | ri->attr = attr_new; |
| 1969 | |
| 1970 | /* Update MPLS tag. */ |
| 1971 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1972 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1973 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1974 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1975 | |
| 1976 | /* Process change. */ |
| 1977 | bgp_process (bgp, rn, afi, safi); |
| 1978 | bgp_unlock_node (rn); |
| 1979 | |
| 1980 | return; |
| 1981 | } |
| 1982 | |
| 1983 | /* Received Logging. */ |
| 1984 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1985 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1986 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1987 | peer->host, |
| 1988 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1989 | p->prefixlen, rsclient->host); |
| 1990 | } |
| 1991 | |
| 1992 | /* Make new BGP info. */ |
| 1993 | new = bgp_info_new (); |
| 1994 | new->type = type; |
| 1995 | new->sub_type = sub_type; |
| 1996 | new->peer = peer; |
| 1997 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1998 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 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 (new))->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, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2005 | |
| 2006 | /* Register new BGP information. */ |
| 2007 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2008 | |
| 2009 | /* route_node_get lock */ |
| 2010 | bgp_unlock_node (rn); |
| 2011 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2012 | /* Process change. */ |
| 2013 | bgp_process (bgp, rn, afi, safi); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2014 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2015 | return; |
| 2016 | |
| 2017 | filtered: |
| 2018 | |
| 2019 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2020 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2021 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2022 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 2023 | peer->host, |
| 2024 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2025 | p->prefixlen, rsclient->host, reason); |
| 2026 | |
| 2027 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2028 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2029 | |
| 2030 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2031 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2032 | return; |
| 2033 | } |
| 2034 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2035 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2036 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 2037 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 2038 | struct prefix_rd *prd, u_char *tag) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2039 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2040 | struct bgp_node *rn; |
| 2041 | struct bgp_info *ri; |
| 2042 | char buf[SU_ADDRSTRLEN]; |
| 2043 | |
| 2044 | if (rsclient == peer) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2045 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2046 | |
| 2047 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 2048 | |
| 2049 | /* Lookup withdrawn route. */ |
| 2050 | for (ri = rn->info; ri; ri = ri->next) |
| 2051 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2052 | break; |
| 2053 | |
| 2054 | /* Withdraw specified route from routing table. */ |
| 2055 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2056 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2057 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2058 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2059 | "%s Can't find the route %s/%d", peer->host, |
| 2060 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2061 | p->prefixlen); |
| 2062 | |
| 2063 | /* Unlock bgp_node_get() lock. */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2064 | bgp_unlock_node (rn); |
| 2065 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2066 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2067 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2068 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2069 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2070 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2071 | { |
| 2072 | int ret; |
| 2073 | int aspath_loop_count = 0; |
| 2074 | struct bgp_node *rn; |
| 2075 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2076 | struct attr new_attr; |
| 2077 | struct attr_extra new_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2078 | struct attr *attr_new; |
| 2079 | struct bgp_info *ri; |
| 2080 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2081 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2082 | char buf[SU_ADDRSTRLEN]; |
| 2083 | |
| 2084 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2085 | 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] | 2086 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2087 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2088 | Adj-RIBs-In. */ |
Jorge Boncompte [DTI2] | 343aa82 | 2012-05-07 16:53:08 +0000 | [diff] [blame] | 2089 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2090 | && peer != bgp->peer_self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2091 | bgp_adj_in_set (rn, peer, attr); |
| 2092 | |
| 2093 | /* Check previously received route. */ |
| 2094 | for (ri = rn->info; ri; ri = ri->next) |
| 2095 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2096 | break; |
| 2097 | |
| 2098 | /* AS path local-as loop check. */ |
| 2099 | if (peer->change_local_as) |
| 2100 | { |
| 2101 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 2102 | aspath_loop_count = 1; |
| 2103 | |
| 2104 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 2105 | { |
| 2106 | reason = "as-path contains our own AS;"; |
| 2107 | goto filtered; |
| 2108 | } |
| 2109 | } |
| 2110 | |
| 2111 | /* AS path loop check. */ |
| 2112 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 2113 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2114 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2115 | > peer->allowas_in[afi][safi])) |
| 2116 | { |
| 2117 | reason = "as-path contains our own AS;"; |
| 2118 | goto filtered; |
| 2119 | } |
| 2120 | |
| 2121 | /* Route reflector originator ID check. */ |
| 2122 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2123 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2124 | { |
| 2125 | reason = "originator is us;"; |
| 2126 | goto filtered; |
| 2127 | } |
| 2128 | |
| 2129 | /* Route reflector cluster ID check. */ |
| 2130 | if (bgp_cluster_filter (peer, attr)) |
| 2131 | { |
| 2132 | reason = "reflected from the same cluster;"; |
| 2133 | goto filtered; |
| 2134 | } |
| 2135 | |
| 2136 | /* Apply incoming filter. */ |
| 2137 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2138 | { |
| 2139 | reason = "filter;"; |
| 2140 | goto filtered; |
| 2141 | } |
| 2142 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2143 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2144 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2145 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2146 | /* Apply incoming route-map. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2147 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2148 | { |
| 2149 | reason = "route-map;"; |
| 2150 | goto filtered; |
| 2151 | } |
| 2152 | |
| 2153 | /* IPv4 unicast next hop check. */ |
| 2154 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2155 | { |
| 2156 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2157 | discard it. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2158 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 |
Denis Ovsienko | 8e80bdf | 2011-08-05 18:52:52 +0400 | [diff] [blame] | 2159 | && ! bgp_nexthop_onlink (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2160 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2161 | { |
| 2162 | reason = "non-connected next-hop;"; |
| 2163 | goto filtered; |
| 2164 | } |
| 2165 | |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2166 | /* 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] | 2167 | must not be my own address. */ |
Jorge Boncompte [DTI2] | 10f9bf3 | 2012-05-07 16:52:52 +0000 | [diff] [blame] | 2168 | if (new_attr.nexthop.s_addr == 0 |
| 2169 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) |
| 2170 | || bgp_nexthop_self (&new_attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2171 | { |
| 2172 | reason = "martian next-hop;"; |
| 2173 | goto filtered; |
| 2174 | } |
| 2175 | } |
| 2176 | |
| 2177 | attr_new = bgp_attr_intern (&new_attr); |
| 2178 | |
| 2179 | /* If the update is implicit withdraw. */ |
| 2180 | if (ri) |
| 2181 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2182 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2183 | |
| 2184 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2185 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2186 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2187 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2188 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2189 | |
| 2190 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2191 | && peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2192 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2193 | { |
| 2194 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2195 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2196 | peer->host, |
| 2197 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2198 | p->prefixlen); |
| 2199 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2200 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2201 | { |
| 2202 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2203 | bgp_process (bgp, rn, afi, safi); |
| 2204 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2205 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2206 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2207 | { |
| 2208 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2209 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2210 | "%s rcvd %s/%d...duplicate ignored", |
| 2211 | peer->host, |
| 2212 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2213 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2214 | |
| 2215 | /* graceful restart STALE flag unset. */ |
| 2216 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2217 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2218 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2219 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2220 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2221 | } |
| 2222 | |
| 2223 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2224 | bgp_attr_unintern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2225 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2226 | return 0; |
| 2227 | } |
| 2228 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2229 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2230 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2231 | { |
| 2232 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2233 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2234 | peer->host, |
| 2235 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2236 | p->prefixlen); |
| 2237 | bgp_info_restore (rn, ri); |
| 2238 | } |
| 2239 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2240 | /* Received Logging. */ |
| 2241 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2242 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2243 | peer->host, |
| 2244 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2245 | p->prefixlen); |
| 2246 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2247 | /* graceful restart STALE flag unset. */ |
| 2248 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2249 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2250 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2251 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2252 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2253 | |
| 2254 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2255 | * only if update is accepted, they'll increment below. |
| 2256 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2257 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2258 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2259 | /* Update bgp route dampening information. */ |
| 2260 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2261 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2262 | { |
| 2263 | /* This is implicit withdraw so we should update dampening |
| 2264 | information. */ |
| 2265 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2266 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2267 | } |
| 2268 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2269 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2270 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2271 | ri->attr = attr_new; |
| 2272 | |
| 2273 | /* Update MPLS tag. */ |
| 2274 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2275 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2276 | |
| 2277 | /* Update bgp route dampening information. */ |
| 2278 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2279 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2280 | { |
| 2281 | /* Now we do normal update dampening. */ |
| 2282 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2283 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2284 | { |
| 2285 | bgp_unlock_node (rn); |
| 2286 | return 0; |
| 2287 | } |
| 2288 | } |
| 2289 | |
| 2290 | /* Nexthop reachability check. */ |
| 2291 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2292 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2293 | && (peer->sort == BGP_PEER_IBGP |
| 2294 | || peer->sort == BGP_PEER_CONFED |
| 2295 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2296 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2297 | { |
| 2298 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2299 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2300 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2301 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2302 | } |
| 2303 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2304 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2305 | |
| 2306 | /* Process change. */ |
| 2307 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2308 | |
| 2309 | bgp_process (bgp, rn, afi, safi); |
| 2310 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2311 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2312 | return 0; |
| 2313 | } |
| 2314 | |
| 2315 | /* Received Logging. */ |
| 2316 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2317 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2318 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2319 | peer->host, |
| 2320 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2321 | p->prefixlen); |
| 2322 | } |
| 2323 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2324 | /* Make new BGP info. */ |
| 2325 | new = bgp_info_new (); |
| 2326 | new->type = type; |
| 2327 | new->sub_type = sub_type; |
| 2328 | new->peer = peer; |
| 2329 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2330 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2331 | |
| 2332 | /* Update MPLS tag. */ |
| 2333 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2334 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2335 | |
| 2336 | /* Nexthop reachability check. */ |
| 2337 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2338 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2339 | && (peer->sort == BGP_PEER_IBGP |
| 2340 | || peer->sort == BGP_PEER_CONFED |
| 2341 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2342 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2343 | { |
| 2344 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2345 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2346 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2347 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2348 | } |
| 2349 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2350 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2351 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2352 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2353 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2354 | |
| 2355 | /* Register new BGP information. */ |
| 2356 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2357 | |
| 2358 | /* route_node_get lock */ |
| 2359 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2360 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2361 | /* If maximum prefix count is configured and current prefix |
| 2362 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2363 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2364 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2365 | |
| 2366 | /* Process change. */ |
| 2367 | bgp_process (bgp, rn, afi, safi); |
| 2368 | |
| 2369 | return 0; |
| 2370 | |
| 2371 | /* This BGP update is filtered. Log the reason then update BGP |
| 2372 | entry. */ |
| 2373 | filtered: |
| 2374 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2375 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2376 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2377 | peer->host, |
| 2378 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2379 | p->prefixlen, reason); |
| 2380 | |
| 2381 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2382 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2383 | |
| 2384 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2385 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2386 | return 0; |
| 2387 | } |
| 2388 | |
| 2389 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2390 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2391 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2392 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2393 | { |
| 2394 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2395 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2396 | struct bgp *bgp; |
| 2397 | int ret; |
| 2398 | |
| 2399 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2400 | soft_reconfig); |
| 2401 | |
| 2402 | bgp = peer->bgp; |
| 2403 | |
| 2404 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2405 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2406 | { |
| 2407 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2408 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2409 | sub_type, prd, tag); |
| 2410 | } |
| 2411 | |
| 2412 | return ret; |
| 2413 | } |
| 2414 | |
| 2415 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2416 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2417 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2418 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2419 | { |
| 2420 | struct bgp *bgp; |
| 2421 | char buf[SU_ADDRSTRLEN]; |
| 2422 | struct bgp_node *rn; |
| 2423 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2424 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2425 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2426 | |
| 2427 | bgp = peer->bgp; |
| 2428 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2429 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2430 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2431 | { |
| 2432 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2433 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2434 | } |
| 2435 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2436 | /* Logging. */ |
| 2437 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2438 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2439 | peer->host, |
| 2440 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2441 | p->prefixlen); |
| 2442 | |
| 2443 | /* Lookup node. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2444 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2445 | |
| 2446 | /* If peer is soft reconfiguration enabled. Record input packet for |
| 2447 | further calculation. */ |
| 2448 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2449 | && peer != bgp->peer_self) |
| 2450 | bgp_adj_in_unset (rn, peer); |
| 2451 | |
| 2452 | /* Lookup withdrawn route. */ |
| 2453 | for (ri = rn->info; ri; ri = ri->next) |
| 2454 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2455 | break; |
| 2456 | |
| 2457 | /* Withdraw specified route from routing table. */ |
| 2458 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2459 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2460 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2461 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2462 | "%s Can't find the route %s/%d", peer->host, |
| 2463 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2464 | p->prefixlen); |
| 2465 | |
| 2466 | /* Unlock bgp_node_get() lock. */ |
| 2467 | bgp_unlock_node (rn); |
| 2468 | |
| 2469 | return 0; |
| 2470 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2471 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2472 | void |
| 2473 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2474 | { |
| 2475 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 2476 | struct attr attr; |
Jorge Boncompte [DTI2] | 577ac57 | 2012-05-07 16:53:06 +0000 | [diff] [blame] | 2477 | struct aspath *aspath; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2478 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2479 | struct peer *from; |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2480 | struct bgp_node *rn; |
| 2481 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2482 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2483 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2484 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2485 | return; |
| 2486 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2487 | bgp = peer->bgp; |
| 2488 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2489 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2490 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2491 | aspath = attr.aspath; |
| 2492 | attr.local_pref = bgp->default_local_pref; |
| 2493 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2494 | |
| 2495 | if (afi == AFI_IP) |
| 2496 | str2prefix ("0.0.0.0/0", &p); |
| 2497 | #ifdef HAVE_IPV6 |
| 2498 | else if (afi == AFI_IP6) |
| 2499 | { |
Jorge Boncompte [DTI2] | 6182d65 | 2012-05-07 16:53:02 +0000 | [diff] [blame] | 2500 | struct attr_extra *ae = attr.extra; |
| 2501 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2502 | str2prefix ("::/0", &p); |
| 2503 | |
| 2504 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2505 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2506 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2507 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2508 | |
| 2509 | /* If the peer is on shared nextwork and we have link-local |
| 2510 | nexthop set it. */ |
| 2511 | if (peer->shared_network |
| 2512 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2513 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2514 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2515 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2516 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2517 | } |
| 2518 | } |
| 2519 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2520 | |
| 2521 | if (peer->default_rmap[afi][safi].name) |
| 2522 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2523 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2524 | for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn)) |
| 2525 | { |
| 2526 | for (ri = rn->info; ri; ri = ri->next) |
| 2527 | { |
| 2528 | struct attr dummy_attr; |
| 2529 | struct attr_extra dummy_extra; |
| 2530 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2531 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2532 | /* Provide dummy so the route-map can't modify the attributes */ |
| 2533 | dummy_attr.extra = &dummy_extra; |
| 2534 | bgp_attr_dup(&dummy_attr, ri->attr); |
| 2535 | info.peer = ri->peer; |
| 2536 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2537 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2538 | ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p, |
| 2539 | RMAP_BGP, &info); |
| 2540 | |
| 2541 | /* The route map might have set attributes. If we don't flush them |
| 2542 | * here, they will be leaked. */ |
| 2543 | bgp_attr_flush(&dummy_attr); |
| 2544 | if (ret != RMAP_DENYMATCH) |
| 2545 | break; |
| 2546 | } |
| 2547 | if (ret != RMAP_DENYMATCH) |
| 2548 | break; |
| 2549 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2550 | bgp->peer_self->rmap_type = 0; |
| 2551 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2552 | if (ret == RMAP_DENYMATCH) |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2553 | withdraw = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2554 | } |
| 2555 | |
| 2556 | if (withdraw) |
| 2557 | { |
| 2558 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2559 | bgp_default_withdraw_send (peer, afi, safi); |
| 2560 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2561 | } |
| 2562 | else |
| 2563 | { |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2564 | if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2565 | { |
| 2566 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2567 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2568 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2569 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2570 | |
| 2571 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2572 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2573 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2574 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2575 | static void |
| 2576 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2577 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2578 | { |
| 2579 | struct bgp_node *rn; |
| 2580 | struct bgp_info *ri; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2581 | struct attr attr; |
| 2582 | struct attr_extra extra; |
| 2583 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2584 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2585 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2586 | |
| 2587 | if (safi != SAFI_MPLS_VPN |
| 2588 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2589 | bgp_default_originate (peer, afi, safi, 0); |
| 2590 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2591 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 2592 | attr.extra = &extra; |
| 2593 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2594 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2595 | for (ri = rn->info; ri; ri = ri->next) |
| 2596 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2597 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2598 | if ( (rsclient) ? |
| 2599 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2600 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2601 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2602 | else |
| 2603 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2604 | } |
| 2605 | } |
| 2606 | |
| 2607 | void |
| 2608 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2609 | { |
| 2610 | struct bgp_node *rn; |
| 2611 | struct bgp_table *table; |
| 2612 | |
| 2613 | if (peer->status != Established) |
| 2614 | return; |
| 2615 | |
| 2616 | if (! peer->afc_nego[afi][safi]) |
| 2617 | return; |
| 2618 | |
| 2619 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2620 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2621 | return; |
| 2622 | |
| 2623 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2624 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2625 | else |
| 2626 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2627 | rn = bgp_route_next(rn)) |
| 2628 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2629 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2630 | |
| 2631 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2632 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2633 | } |
| 2634 | |
| 2635 | void |
| 2636 | bgp_announce_route_all (struct peer *peer) |
| 2637 | { |
| 2638 | afi_t afi; |
| 2639 | safi_t safi; |
| 2640 | |
| 2641 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2642 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2643 | bgp_announce_route (peer, afi, safi); |
| 2644 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2645 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2646 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2647 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2648 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2649 | { |
| 2650 | struct bgp_node *rn; |
| 2651 | struct bgp_adj_in *ain; |
| 2652 | |
| 2653 | if (! table) |
| 2654 | table = rsclient->bgp->rib[afi][safi]; |
| 2655 | |
| 2656 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2657 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2658 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2659 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2660 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2661 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2662 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2663 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2664 | } |
| 2665 | } |
| 2666 | |
| 2667 | void |
| 2668 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2669 | { |
| 2670 | struct bgp_table *table; |
| 2671 | struct bgp_node *rn; |
| 2672 | |
| 2673 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2674 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2675 | |
| 2676 | else |
| 2677 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2678 | rn = bgp_route_next (rn)) |
| 2679 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2680 | { |
| 2681 | struct prefix_rd prd; |
| 2682 | prd.family = AF_UNSPEC; |
| 2683 | prd.prefixlen = 64; |
| 2684 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2685 | |
| 2686 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); |
| 2687 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2688 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2689 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2690 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2691 | 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] | 2692 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2693 | { |
| 2694 | int ret; |
| 2695 | struct bgp_node *rn; |
| 2696 | struct bgp_adj_in *ain; |
| 2697 | |
| 2698 | if (! table) |
| 2699 | table = peer->bgp->rib[afi][safi]; |
| 2700 | |
| 2701 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2702 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2703 | { |
| 2704 | if (ain->peer == peer) |
| 2705 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2706 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2707 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2708 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2709 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2710 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2711 | prd, tag, 1); |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2712 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2713 | if (ret < 0) |
| 2714 | { |
| 2715 | bgp_unlock_node (rn); |
| 2716 | return; |
| 2717 | } |
| 2718 | continue; |
| 2719 | } |
| 2720 | } |
| 2721 | } |
| 2722 | |
| 2723 | void |
| 2724 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2725 | { |
| 2726 | struct bgp_node *rn; |
| 2727 | struct bgp_table *table; |
| 2728 | |
| 2729 | if (peer->status != Established) |
| 2730 | return; |
| 2731 | |
| 2732 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2733 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2734 | else |
| 2735 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2736 | rn = bgp_route_next (rn)) |
| 2737 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2738 | { |
| 2739 | struct prefix_rd prd; |
| 2740 | prd.family = AF_UNSPEC; |
| 2741 | prd.prefixlen = 64; |
| 2742 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2743 | |
| 2744 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); |
| 2745 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2746 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2747 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2748 | |
| 2749 | struct bgp_clear_node_queue |
| 2750 | { |
| 2751 | struct bgp_node *rn; |
| 2752 | enum bgp_clear_route_type purpose; |
| 2753 | }; |
| 2754 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2755 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2756 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2757 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2758 | struct bgp_clear_node_queue *cnq = data; |
| 2759 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2760 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2761 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2762 | afi_t afi = bgp_node_table (rn)->afi; |
| 2763 | safi_t safi = bgp_node_table (rn)->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2764 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2765 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2766 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2767 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2768 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2769 | { |
| 2770 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2771 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2772 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2773 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2774 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2775 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2776 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2777 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2778 | break; |
| 2779 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2780 | return WQ_SUCCESS; |
| 2781 | } |
| 2782 | |
| 2783 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2784 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2785 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2786 | struct bgp_clear_node_queue *cnq = data; |
| 2787 | struct bgp_node *rn = cnq->rn; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2788 | struct bgp_table *table = bgp_node_table (rn); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2789 | |
| 2790 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2791 | bgp_table_unlock (table); |
| 2792 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2793 | } |
| 2794 | |
| 2795 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2796 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2797 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2798 | struct peer *peer = wq->spec.data; |
| 2799 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2800 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2801 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2802 | |
| 2803 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2804 | } |
| 2805 | |
| 2806 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2807 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2808 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2809 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2810 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2811 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2812 | #undef CLEAR_QUEUE_NAME_LEN |
| 2813 | |
| 2814 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2815 | { |
| 2816 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2817 | exit (1); |
| 2818 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2819 | peer->clear_node_queue->spec.hold = 10; |
| 2820 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2821 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2822 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2823 | peer->clear_node_queue->spec.max_retries = 0; |
| 2824 | |
| 2825 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2826 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2827 | } |
| 2828 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2829 | static void |
| 2830 | 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] | 2831 | struct bgp_table *table, struct peer *rsclient, |
| 2832 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2833 | { |
| 2834 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2835 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2836 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2837 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2838 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2839 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2840 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2841 | if (! table) |
| 2842 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2843 | |
| 2844 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2845 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2846 | struct bgp_info *ri; |
| 2847 | struct bgp_adj_in *ain; |
| 2848 | struct bgp_adj_out *aout; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2849 | |
| 2850 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2851 | * queued for every clearing peer, regardless of whether it is |
| 2852 | * relevant to the peer at hand. |
| 2853 | * |
| 2854 | * Overview: There are 3 different indices which need to be |
| 2855 | * scrubbed, potentially, when a peer is removed: |
| 2856 | * |
| 2857 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2858 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2859 | * 3 other routes visible by the peer's adj-out index |
| 2860 | * |
| 2861 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2862 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2863 | * adj-outs at our leisure. |
| 2864 | * |
| 2865 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2866 | * invisible via RIB index before peer session is allowed to be |
| 2867 | * brought back up. So one needs to know when such a 'search' is |
| 2868 | * complete. |
| 2869 | * |
| 2870 | * Ideally: |
| 2871 | * |
| 2872 | * - there'd be a single global queue or a single RIB walker |
| 2873 | * - rather than tracking which route_nodes still need to be |
| 2874 | * examined on a peer basis, we'd track which peers still |
| 2875 | * aren't cleared |
| 2876 | * |
| 2877 | * Given that our per-peer prefix-counts now should be reliable, |
| 2878 | * this may actually be achievable. It doesn't seem to be a huge |
| 2879 | * problem at this time, |
| 2880 | */ |
Jorge Boncompte [DTI2] | 24e50f2 | 2012-05-07 15:17:33 +0000 | [diff] [blame] | 2881 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2882 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2883 | { |
| 2884 | bgp_adj_in_remove (rn, ain); |
| 2885 | bgp_unlock_node (rn); |
| 2886 | break; |
| 2887 | } |
| 2888 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2889 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2890 | { |
| 2891 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2892 | bgp_unlock_node (rn); |
| 2893 | break; |
| 2894 | } |
| 2895 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2896 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2897 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2898 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2899 | struct bgp_clear_node_queue *cnq; |
| 2900 | |
| 2901 | /* both unlocked in bgp_clear_node_queue_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2902 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2903 | bgp_lock_node (rn); |
| 2904 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2905 | sizeof (struct bgp_clear_node_queue)); |
| 2906 | cnq->rn = rn; |
| 2907 | cnq->purpose = purpose; |
| 2908 | work_queue_add (peer->clear_node_queue, cnq); |
| 2909 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2910 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2911 | } |
| 2912 | return; |
| 2913 | } |
| 2914 | |
| 2915 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2916 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2917 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2918 | { |
| 2919 | struct bgp_node *rn; |
| 2920 | struct bgp_table *table; |
| 2921 | struct peer *rsclient; |
| 2922 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2923 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2924 | if (peer->clear_node_queue == NULL) |
| 2925 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2926 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2927 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 2928 | * Idle until it receives a Clearing_Completed event. This protects |
| 2929 | * against peers which flap faster than we can we clear, which could |
| 2930 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2931 | * |
| 2932 | * a) race with routes from the new session being installed before |
| 2933 | * clear_route_node visits the node (to delete the route of that |
| 2934 | * peer) |
| 2935 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 2936 | * on the process_main queue. Fast-flapping could cause that queue |
| 2937 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2938 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2939 | if (!peer->clear_node_queue->thread) |
| 2940 | peer_lock (peer); /* bgp_clear_node_complete */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2941 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2942 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2943 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2944 | case BGP_CLEAR_ROUTE_NORMAL: |
| 2945 | if (safi != SAFI_MPLS_VPN) |
| 2946 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 2947 | else |
| 2948 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2949 | rn = bgp_route_next (rn)) |
| 2950 | if ((table = rn->info) != NULL) |
| 2951 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 2952 | |
| 2953 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 2954 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 2955 | PEER_FLAG_RSERVER_CLIENT)) |
| 2956 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 2957 | break; |
| 2958 | |
| 2959 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
| 2960 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 2961 | break; |
| 2962 | |
| 2963 | default: |
| 2964 | assert (0); |
| 2965 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2966 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2967 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2968 | /* If no routes were cleared, nothing was added to workqueue, the |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2969 | * completion function won't be run by workqueue code - call it here. |
| 2970 | * XXX: Actually, this assumption doesn't hold, see |
| 2971 | * bgp_clear_route_table(), we queue all non-empty nodes. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2972 | * |
| 2973 | * Additionally, there is a presumption in FSM that clearing is only |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2974 | * really needed if peer state is Established - peers in |
| 2975 | * pre-Established states shouldn't have any route-update state |
| 2976 | * associated with them (in or out). |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2977 | * |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2978 | * We still can get here in pre-Established though, through |
| 2979 | * peer_delete -> bgp_fsm_change_status, so this is a useful sanity |
| 2980 | * check to ensure the assumption above holds. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2981 | * |
| 2982 | * At some future point, this check could be move to the top of the |
| 2983 | * function, and do a quick early-return when state is |
| 2984 | * pre-Established, avoiding above list and table scans. Once we're |
| 2985 | * sure it is safe.. |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2986 | */ |
| 2987 | if (!peer->clear_node_queue->thread) |
| 2988 | bgp_clear_node_complete (peer->clear_node_queue); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2989 | } |
| 2990 | |
| 2991 | void |
| 2992 | bgp_clear_route_all (struct peer *peer) |
| 2993 | { |
| 2994 | afi_t afi; |
| 2995 | safi_t safi; |
| 2996 | |
| 2997 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2998 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2999 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3000 | } |
| 3001 | |
| 3002 | void |
| 3003 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 3004 | { |
| 3005 | struct bgp_table *table; |
| 3006 | struct bgp_node *rn; |
| 3007 | struct bgp_adj_in *ain; |
| 3008 | |
| 3009 | table = peer->bgp->rib[afi][safi]; |
| 3010 | |
| 3011 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3012 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 3013 | if (ain->peer == peer) |
| 3014 | { |
| 3015 | bgp_adj_in_remove (rn, ain); |
| 3016 | bgp_unlock_node (rn); |
| 3017 | break; |
| 3018 | } |
| 3019 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 3020 | |
| 3021 | void |
| 3022 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 3023 | { |
| 3024 | struct bgp_node *rn; |
| 3025 | struct bgp_info *ri; |
| 3026 | struct bgp_table *table; |
| 3027 | |
| 3028 | table = peer->bgp->rib[afi][safi]; |
| 3029 | |
| 3030 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3031 | { |
| 3032 | for (ri = rn->info; ri; ri = ri->next) |
| 3033 | if (ri->peer == peer) |
| 3034 | { |
| 3035 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 3036 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3037 | break; |
| 3038 | } |
| 3039 | } |
| 3040 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3041 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3042 | /* Delete all kernel routes. */ |
| 3043 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3044 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3045 | { |
| 3046 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3047 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3048 | struct bgp_node *rn; |
| 3049 | struct bgp_table *table; |
| 3050 | struct bgp_info *ri; |
| 3051 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3052 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3053 | { |
| 3054 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 3055 | |
| 3056 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3057 | for (ri = rn->info; ri; ri = ri->next) |
| 3058 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3059 | && ri->type == ZEBRA_ROUTE_BGP |
| 3060 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3061 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3062 | |
| 3063 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 3064 | |
| 3065 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3066 | for (ri = rn->info; ri; ri = ri->next) |
| 3067 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3068 | && ri->type == ZEBRA_ROUTE_BGP |
| 3069 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3070 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3071 | } |
| 3072 | } |
| 3073 | |
| 3074 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3075 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3076 | { |
| 3077 | vty_reset (); |
| 3078 | bgp_zclient_reset (); |
| 3079 | access_list_reset (); |
| 3080 | prefix_list_reset (); |
| 3081 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3082 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3083 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3084 | value. */ |
| 3085 | int |
| 3086 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 3087 | { |
| 3088 | u_char *pnt; |
| 3089 | u_char *lim; |
| 3090 | struct prefix p; |
| 3091 | int psize; |
| 3092 | int ret; |
| 3093 | |
| 3094 | /* Check peer status. */ |
| 3095 | if (peer->status != Established) |
| 3096 | return 0; |
| 3097 | |
| 3098 | pnt = packet->nlri; |
| 3099 | lim = pnt + packet->length; |
| 3100 | |
| 3101 | for (; pnt < lim; pnt += psize) |
| 3102 | { |
| 3103 | /* Clear prefix structure. */ |
| 3104 | memset (&p, 0, sizeof (struct prefix)); |
| 3105 | |
| 3106 | /* Fetch prefix length. */ |
| 3107 | p.prefixlen = *pnt++; |
| 3108 | p.family = afi2family (packet->afi); |
| 3109 | |
| 3110 | /* Already checked in nlri_sanity_check(). We do double check |
| 3111 | here. */ |
| 3112 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 3113 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 3114 | return -1; |
| 3115 | |
| 3116 | /* Packet size overflow check. */ |
| 3117 | psize = PSIZE (p.prefixlen); |
| 3118 | |
| 3119 | /* When packet overflow occur return immediately. */ |
| 3120 | if (pnt + psize > lim) |
| 3121 | return -1; |
| 3122 | |
| 3123 | /* Fetch prefix from NLRI packet. */ |
| 3124 | memcpy (&p.u.prefix, pnt, psize); |
| 3125 | |
| 3126 | /* Check address. */ |
| 3127 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3128 | { |
| 3129 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3130 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3131 | /* |
| 3132 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 3133 | * If a BGP router receives an UPDATE message with a |
| 3134 | * semantically incorrect NLRI field, in which a prefix is |
| 3135 | * semantically incorrect (eg. an unexpected multicast IP |
| 3136 | * address), it should ignore the prefix. |
| 3137 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3138 | zlog (peer->log, LOG_ERR, |
| 3139 | "IPv4 unicast NLRI is multicast address %s", |
| 3140 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3141 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3142 | return -1; |
| 3143 | } |
| 3144 | } |
| 3145 | |
| 3146 | #ifdef HAVE_IPV6 |
| 3147 | /* Check address. */ |
| 3148 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3149 | { |
| 3150 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3151 | { |
| 3152 | char buf[BUFSIZ]; |
| 3153 | |
| 3154 | zlog (peer->log, LOG_WARNING, |
| 3155 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 3156 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3157 | |
| 3158 | continue; |
| 3159 | } |
| 3160 | } |
| 3161 | #endif /* HAVE_IPV6 */ |
| 3162 | |
| 3163 | /* Normal process. */ |
| 3164 | if (attr) |
| 3165 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3166 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3167 | else |
| 3168 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3169 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3170 | |
| 3171 | /* Address family configuration mismatch or maximum-prefix count |
| 3172 | overflow. */ |
| 3173 | if (ret < 0) |
| 3174 | return -1; |
| 3175 | } |
| 3176 | |
| 3177 | /* Packet length consistency check. */ |
| 3178 | if (pnt != lim) |
| 3179 | return -1; |
| 3180 | |
| 3181 | return 0; |
| 3182 | } |
| 3183 | |
| 3184 | /* NLRI encode syntax check routine. */ |
| 3185 | int |
| 3186 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 3187 | bgp_size_t length) |
| 3188 | { |
| 3189 | u_char *end; |
| 3190 | u_char prefixlen; |
| 3191 | int psize; |
| 3192 | |
| 3193 | end = pnt + length; |
| 3194 | |
| 3195 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 3196 | syntactic validity. If the field is syntactically incorrect, |
| 3197 | then the Error Subcode is set to Invalid Network Field. */ |
| 3198 | |
| 3199 | while (pnt < end) |
| 3200 | { |
| 3201 | prefixlen = *pnt++; |
| 3202 | |
| 3203 | /* Prefix length check. */ |
| 3204 | if ((afi == AFI_IP && prefixlen > 32) |
| 3205 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 3206 | { |
| 3207 | plog_err (peer->log, |
| 3208 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 3209 | peer->host, prefixlen); |
| 3210 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3211 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3212 | return -1; |
| 3213 | } |
| 3214 | |
| 3215 | /* Packet size overflow check. */ |
| 3216 | psize = PSIZE (prefixlen); |
| 3217 | |
| 3218 | if (pnt + psize > end) |
| 3219 | { |
| 3220 | plog_err (peer->log, |
| 3221 | "%s [Error] Update packet error" |
| 3222 | " (prefix data overflow prefix size is %d)", |
| 3223 | peer->host, psize); |
| 3224 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3225 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3226 | return -1; |
| 3227 | } |
| 3228 | |
| 3229 | pnt += psize; |
| 3230 | } |
| 3231 | |
| 3232 | /* Packet length consistency check. */ |
| 3233 | if (pnt != end) |
| 3234 | { |
| 3235 | plog_err (peer->log, |
| 3236 | "%s [Error] Update packet error" |
| 3237 | " (prefix length mismatch with total length)", |
| 3238 | peer->host); |
| 3239 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3240 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3241 | return -1; |
| 3242 | } |
| 3243 | return 0; |
| 3244 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3245 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3246 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3247 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3248 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3249 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3250 | } |
| 3251 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3252 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3253 | bgp_static_free (struct bgp_static *bgp_static) |
| 3254 | { |
| 3255 | if (bgp_static->rmap.name) |
| 3256 | free (bgp_static->rmap.name); |
| 3257 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3258 | } |
| 3259 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3260 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3261 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3262 | struct prefix *p, afi_t afi, safi_t safi) |
| 3263 | { |
| 3264 | struct bgp_node *rn; |
| 3265 | struct bgp_info *ri; |
| 3266 | |
| 3267 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3268 | |
| 3269 | /* Check selected route and self inserted route. */ |
| 3270 | for (ri = rn->info; ri; ri = ri->next) |
| 3271 | if (ri->peer == bgp->peer_self |
| 3272 | && ri->type == ZEBRA_ROUTE_BGP |
| 3273 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3274 | break; |
| 3275 | |
| 3276 | /* Withdraw static BGP route from routing table. */ |
| 3277 | if (ri) |
| 3278 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3279 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3280 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3281 | } |
| 3282 | |
| 3283 | /* Unlock bgp_node_lookup. */ |
| 3284 | bgp_unlock_node (rn); |
| 3285 | } |
| 3286 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3287 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3288 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3289 | struct bgp_static *bgp_static, |
| 3290 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3291 | { |
| 3292 | struct bgp_node *rn; |
| 3293 | struct bgp_info *ri; |
| 3294 | struct bgp_info *new; |
| 3295 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3296 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3297 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3298 | struct attr new_attr; |
| 3299 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3300 | struct bgp *bgp; |
| 3301 | int ret; |
| 3302 | char buf[SU_ADDRSTRLEN]; |
| 3303 | |
| 3304 | bgp = rsclient->bgp; |
| 3305 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3306 | assert (bgp_static); |
| 3307 | if (!bgp_static) |
| 3308 | return; |
| 3309 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3310 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3311 | |
| 3312 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3313 | |
| 3314 | attr.nexthop = bgp_static->igpnexthop; |
| 3315 | attr.med = bgp_static->igpmetric; |
| 3316 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3317 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3318 | if (bgp_static->atomic) |
| 3319 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3320 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3321 | /* Apply network route-map for export to this rsclient. */ |
| 3322 | if (bgp_static->rmap.name) |
| 3323 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3324 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3325 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3326 | info.attr = &attr_tmp; |
| 3327 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3328 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3329 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3330 | |
| 3331 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3332 | |
| 3333 | rsclient->rmap_type = 0; |
| 3334 | |
| 3335 | if (ret == RMAP_DENYMATCH) |
| 3336 | { |
| 3337 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3338 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3339 | |
| 3340 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3341 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3342 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3343 | bgp_attr_extra_free (&attr); |
| 3344 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3345 | return; |
| 3346 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3347 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3348 | } |
| 3349 | else |
| 3350 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3351 | |
| 3352 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3353 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3354 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3355 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3356 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3357 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3358 | == RMAP_DENY) |
| 3359 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3360 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3361 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3362 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3363 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3364 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3365 | p->prefixlen, rsclient->host); |
| 3366 | |
| 3367 | bgp->peer_self->rmap_type = 0; |
| 3368 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3369 | bgp_attr_unintern (&attr_new); |
| 3370 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3371 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3372 | |
| 3373 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3374 | |
| 3375 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3376 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3377 | |
| 3378 | bgp->peer_self->rmap_type = 0; |
| 3379 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3380 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3381 | attr_new = bgp_attr_intern (&new_attr); |
| 3382 | |
| 3383 | for (ri = rn->info; ri; ri = ri->next) |
| 3384 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3385 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3386 | break; |
| 3387 | |
| 3388 | if (ri) |
| 3389 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3390 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3391 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3392 | { |
| 3393 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3394 | bgp_attr_unintern (&attr_new); |
| 3395 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3396 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3397 | return; |
| 3398 | } |
| 3399 | else |
| 3400 | { |
| 3401 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3402 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3403 | |
| 3404 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3405 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3406 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3407 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3408 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3409 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3410 | |
| 3411 | /* Process change. */ |
| 3412 | bgp_process (bgp, rn, afi, safi); |
| 3413 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3414 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3415 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3416 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3417 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3418 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3419 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3420 | /* Make new BGP info. */ |
| 3421 | new = bgp_info_new (); |
| 3422 | new->type = ZEBRA_ROUTE_BGP; |
| 3423 | new->sub_type = BGP_ROUTE_STATIC; |
| 3424 | new->peer = bgp->peer_self; |
| 3425 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3426 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3427 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3428 | |
| 3429 | /* Register new BGP information. */ |
| 3430 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3431 | |
| 3432 | /* route_node_get lock */ |
| 3433 | bgp_unlock_node (rn); |
| 3434 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3435 | /* Process change. */ |
| 3436 | bgp_process (bgp, rn, afi, safi); |
| 3437 | |
| 3438 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3439 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3440 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3441 | } |
| 3442 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3443 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3444 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3445 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3446 | { |
| 3447 | struct bgp_node *rn; |
| 3448 | struct bgp_info *ri; |
| 3449 | struct bgp_info *new; |
| 3450 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3451 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3452 | struct attr *attr_new; |
| 3453 | int ret; |
| 3454 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3455 | assert (bgp_static); |
| 3456 | if (!bgp_static) |
| 3457 | return; |
| 3458 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3459 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3460 | |
| 3461 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3462 | |
| 3463 | attr.nexthop = bgp_static->igpnexthop; |
| 3464 | attr.med = bgp_static->igpmetric; |
| 3465 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3466 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3467 | if (bgp_static->atomic) |
| 3468 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3469 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3470 | /* Apply route-map. */ |
| 3471 | if (bgp_static->rmap.name) |
| 3472 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3473 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3474 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3475 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3476 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3477 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3478 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3479 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3480 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3481 | bgp->peer_self->rmap_type = 0; |
| 3482 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3483 | if (ret == RMAP_DENYMATCH) |
| 3484 | { |
| 3485 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3486 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3487 | |
| 3488 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3489 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3490 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3491 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3492 | return; |
| 3493 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3494 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3495 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3496 | else |
| 3497 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3498 | |
| 3499 | for (ri = rn->info; ri; ri = ri->next) |
| 3500 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3501 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3502 | break; |
| 3503 | |
| 3504 | if (ri) |
| 3505 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3506 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3507 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3508 | { |
| 3509 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3510 | bgp_attr_unintern (&attr_new); |
| 3511 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3512 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3513 | return; |
| 3514 | } |
| 3515 | else |
| 3516 | { |
| 3517 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3518 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3519 | |
| 3520 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3521 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3522 | bgp_info_restore(rn, ri); |
| 3523 | else |
| 3524 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3525 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3526 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3527 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3528 | |
| 3529 | /* Process change. */ |
| 3530 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3531 | bgp_process (bgp, rn, afi, safi); |
| 3532 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3533 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3534 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3535 | return; |
| 3536 | } |
| 3537 | } |
| 3538 | |
| 3539 | /* Make new BGP info. */ |
| 3540 | new = bgp_info_new (); |
| 3541 | new->type = ZEBRA_ROUTE_BGP; |
| 3542 | new->sub_type = BGP_ROUTE_STATIC; |
| 3543 | new->peer = bgp->peer_self; |
| 3544 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3545 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3546 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3547 | |
| 3548 | /* Aggregate address increment. */ |
| 3549 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3550 | |
| 3551 | /* Register new BGP information. */ |
| 3552 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3553 | |
| 3554 | /* route_node_get lock */ |
| 3555 | bgp_unlock_node (rn); |
| 3556 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3557 | /* Process change. */ |
| 3558 | bgp_process (bgp, rn, afi, safi); |
| 3559 | |
| 3560 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3561 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3562 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3563 | } |
| 3564 | |
| 3565 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3566 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3567 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3568 | { |
| 3569 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3570 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3571 | |
| 3572 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3573 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3574 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3575 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3576 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3577 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3578 | } |
| 3579 | } |
| 3580 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3581 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3582 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3583 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3584 | { |
| 3585 | struct bgp_node *rn; |
| 3586 | struct bgp_info *new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3587 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3588 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3589 | |
| 3590 | /* Make new BGP info. */ |
| 3591 | new = bgp_info_new (); |
| 3592 | new->type = ZEBRA_ROUTE_BGP; |
| 3593 | new->sub_type = BGP_ROUTE_STATIC; |
| 3594 | new->peer = bgp->peer_self; |
| 3595 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 3596 | SET_FLAG (new->flags, BGP_INFO_VALID); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3597 | new->uptime = bgp_clock (); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3598 | new->extra = bgp_info_extra_new(); |
| 3599 | memcpy (new->extra->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3600 | |
| 3601 | /* Aggregate address increment. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3602 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3603 | |
| 3604 | /* Register new BGP information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3605 | bgp_info_add (rn, new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3606 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3607 | /* route_node_get lock */ |
| 3608 | bgp_unlock_node (rn); |
| 3609 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3610 | /* Process change. */ |
| 3611 | bgp_process (bgp, rn, afi, safi); |
| 3612 | } |
| 3613 | |
| 3614 | void |
| 3615 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3616 | safi_t safi) |
| 3617 | { |
| 3618 | struct bgp_node *rn; |
| 3619 | struct bgp_info *ri; |
| 3620 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3621 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3622 | |
| 3623 | /* Check selected route and self inserted route. */ |
| 3624 | for (ri = rn->info; ri; ri = ri->next) |
| 3625 | if (ri->peer == bgp->peer_self |
| 3626 | && ri->type == ZEBRA_ROUTE_BGP |
| 3627 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3628 | break; |
| 3629 | |
| 3630 | /* Withdraw static BGP route from routing table. */ |
| 3631 | if (ri) |
| 3632 | { |
| 3633 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3634 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3635 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3636 | } |
| 3637 | |
| 3638 | /* Unlock bgp_node_lookup. */ |
| 3639 | bgp_unlock_node (rn); |
| 3640 | } |
| 3641 | |
| 3642 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3643 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3644 | { |
| 3645 | struct bgp_static *bgp_static; |
| 3646 | struct bgp *bgp; |
| 3647 | struct bgp_node *rn; |
| 3648 | struct prefix *p; |
| 3649 | |
| 3650 | bgp = rsclient->bgp; |
| 3651 | |
| 3652 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3653 | if ((bgp_static = rn->info) != NULL) |
| 3654 | { |
| 3655 | p = &rn->p; |
| 3656 | |
| 3657 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3658 | afi, safi); |
| 3659 | } |
| 3660 | } |
| 3661 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3662 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3663 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3664 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3665 | { |
| 3666 | struct bgp_node *rn; |
| 3667 | struct bgp_info *ri; |
| 3668 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3669 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3670 | |
| 3671 | /* Check selected route and self inserted route. */ |
| 3672 | for (ri = rn->info; ri; ri = ri->next) |
| 3673 | if (ri->peer == bgp->peer_self |
| 3674 | && ri->type == ZEBRA_ROUTE_BGP |
| 3675 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3676 | break; |
| 3677 | |
| 3678 | /* Withdraw static BGP route from routing table. */ |
| 3679 | if (ri) |
| 3680 | { |
| 3681 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3682 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3683 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3684 | } |
| 3685 | |
| 3686 | /* Unlock bgp_node_lookup. */ |
| 3687 | bgp_unlock_node (rn); |
| 3688 | } |
| 3689 | |
| 3690 | /* Configure static BGP network. When user don't run zebra, static |
| 3691 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3692 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3693 | 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] | 3694 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3695 | { |
| 3696 | int ret; |
| 3697 | struct prefix p; |
| 3698 | struct bgp_static *bgp_static; |
| 3699 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3700 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3701 | |
| 3702 | /* Convert IP prefix string to struct prefix. */ |
| 3703 | ret = str2prefix (ip_str, &p); |
| 3704 | if (! ret) |
| 3705 | { |
| 3706 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3707 | return CMD_WARNING; |
| 3708 | } |
| 3709 | #ifdef HAVE_IPV6 |
| 3710 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3711 | { |
| 3712 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3713 | VTY_NEWLINE); |
| 3714 | return CMD_WARNING; |
| 3715 | } |
| 3716 | #endif /* HAVE_IPV6 */ |
| 3717 | |
| 3718 | apply_mask (&p); |
| 3719 | |
| 3720 | /* Set BGP static route configuration. */ |
| 3721 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3722 | |
| 3723 | if (rn->info) |
| 3724 | { |
| 3725 | /* Configuration change. */ |
| 3726 | bgp_static = rn->info; |
| 3727 | |
| 3728 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3729 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 3730 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3731 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3732 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3733 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3734 | if (rmap) |
| 3735 | { |
| 3736 | if (bgp_static->rmap.name) |
| 3737 | free (bgp_static->rmap.name); |
| 3738 | bgp_static->rmap.name = strdup (rmap); |
| 3739 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3740 | } |
| 3741 | else |
| 3742 | { |
| 3743 | if (bgp_static->rmap.name) |
| 3744 | free (bgp_static->rmap.name); |
| 3745 | bgp_static->rmap.name = NULL; |
| 3746 | bgp_static->rmap.map = NULL; |
| 3747 | bgp_static->valid = 0; |
| 3748 | } |
| 3749 | bgp_unlock_node (rn); |
| 3750 | } |
| 3751 | else |
| 3752 | { |
| 3753 | /* New configuration. */ |
| 3754 | bgp_static = bgp_static_new (); |
| 3755 | bgp_static->backdoor = backdoor; |
| 3756 | bgp_static->valid = 0; |
| 3757 | bgp_static->igpmetric = 0; |
| 3758 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3759 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3760 | if (rmap) |
| 3761 | { |
| 3762 | if (bgp_static->rmap.name) |
| 3763 | free (bgp_static->rmap.name); |
| 3764 | bgp_static->rmap.name = strdup (rmap); |
| 3765 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3766 | } |
| 3767 | rn->info = bgp_static; |
| 3768 | } |
| 3769 | |
| 3770 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3771 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3772 | { |
| 3773 | bgp_static->valid = 1; |
| 3774 | |
| 3775 | if (need_update) |
| 3776 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3777 | |
| 3778 | if (! bgp_static->backdoor) |
| 3779 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3780 | } |
| 3781 | |
| 3782 | return CMD_SUCCESS; |
| 3783 | } |
| 3784 | |
| 3785 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3786 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3787 | 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] | 3788 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3789 | { |
| 3790 | int ret; |
| 3791 | struct prefix p; |
| 3792 | struct bgp_static *bgp_static; |
| 3793 | struct bgp_node *rn; |
| 3794 | |
| 3795 | /* Convert IP prefix string to struct prefix. */ |
| 3796 | ret = str2prefix (ip_str, &p); |
| 3797 | if (! ret) |
| 3798 | { |
| 3799 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3800 | return CMD_WARNING; |
| 3801 | } |
| 3802 | #ifdef HAVE_IPV6 |
| 3803 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3804 | { |
| 3805 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3806 | VTY_NEWLINE); |
| 3807 | return CMD_WARNING; |
| 3808 | } |
| 3809 | #endif /* HAVE_IPV6 */ |
| 3810 | |
| 3811 | apply_mask (&p); |
| 3812 | |
| 3813 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3814 | if (! rn) |
| 3815 | { |
| 3816 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3817 | VTY_NEWLINE); |
| 3818 | return CMD_WARNING; |
| 3819 | } |
| 3820 | |
| 3821 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3822 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3823 | /* Update BGP RIB. */ |
| 3824 | if (! bgp_static->backdoor) |
| 3825 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3826 | |
| 3827 | /* Clear configuration. */ |
| 3828 | bgp_static_free (bgp_static); |
| 3829 | rn->info = NULL; |
| 3830 | bgp_unlock_node (rn); |
| 3831 | bgp_unlock_node (rn); |
| 3832 | |
| 3833 | return CMD_SUCCESS; |
| 3834 | } |
| 3835 | |
| 3836 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3837 | instance. */ |
| 3838 | void |
| 3839 | bgp_static_delete (struct bgp *bgp) |
| 3840 | { |
| 3841 | afi_t afi; |
| 3842 | safi_t safi; |
| 3843 | struct bgp_node *rn; |
| 3844 | struct bgp_node *rm; |
| 3845 | struct bgp_table *table; |
| 3846 | struct bgp_static *bgp_static; |
| 3847 | |
| 3848 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3849 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3850 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3851 | if (rn->info != NULL) |
| 3852 | { |
| 3853 | if (safi == SAFI_MPLS_VPN) |
| 3854 | { |
| 3855 | table = rn->info; |
| 3856 | |
| 3857 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3858 | { |
| 3859 | bgp_static = rn->info; |
| 3860 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3861 | AFI_IP, SAFI_MPLS_VPN, |
| 3862 | (struct prefix_rd *)&rn->p, |
| 3863 | bgp_static->tag); |
| 3864 | bgp_static_free (bgp_static); |
| 3865 | rn->info = NULL; |
| 3866 | bgp_unlock_node (rn); |
| 3867 | } |
| 3868 | } |
| 3869 | else |
| 3870 | { |
| 3871 | bgp_static = rn->info; |
| 3872 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3873 | bgp_static_free (bgp_static); |
| 3874 | rn->info = NULL; |
| 3875 | bgp_unlock_node (rn); |
| 3876 | } |
| 3877 | } |
| 3878 | } |
| 3879 | |
| 3880 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3881 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3882 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3883 | { |
| 3884 | int ret; |
| 3885 | struct prefix p; |
| 3886 | struct prefix_rd prd; |
| 3887 | struct bgp *bgp; |
| 3888 | struct bgp_node *prn; |
| 3889 | struct bgp_node *rn; |
| 3890 | struct bgp_table *table; |
| 3891 | struct bgp_static *bgp_static; |
| 3892 | u_char tag[3]; |
| 3893 | |
| 3894 | bgp = vty->index; |
| 3895 | |
| 3896 | ret = str2prefix (ip_str, &p); |
| 3897 | if (! ret) |
| 3898 | { |
| 3899 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3900 | return CMD_WARNING; |
| 3901 | } |
| 3902 | apply_mask (&p); |
| 3903 | |
| 3904 | ret = str2prefix_rd (rd_str, &prd); |
| 3905 | if (! ret) |
| 3906 | { |
| 3907 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3908 | return CMD_WARNING; |
| 3909 | } |
| 3910 | |
| 3911 | ret = str2tag (tag_str, tag); |
| 3912 | if (! ret) |
| 3913 | { |
| 3914 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3915 | return CMD_WARNING; |
| 3916 | } |
| 3917 | |
| 3918 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3919 | (struct prefix *)&prd); |
| 3920 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3921 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3922 | else |
| 3923 | bgp_unlock_node (prn); |
| 3924 | table = prn->info; |
| 3925 | |
| 3926 | rn = bgp_node_get (table, &p); |
| 3927 | |
| 3928 | if (rn->info) |
| 3929 | { |
| 3930 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3931 | bgp_unlock_node (rn); |
| 3932 | } |
| 3933 | else |
| 3934 | { |
| 3935 | /* New configuration. */ |
| 3936 | bgp_static = bgp_static_new (); |
| 3937 | bgp_static->valid = 1; |
| 3938 | memcpy (bgp_static->tag, tag, 3); |
| 3939 | rn->info = bgp_static; |
| 3940 | |
| 3941 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3942 | } |
| 3943 | |
| 3944 | return CMD_SUCCESS; |
| 3945 | } |
| 3946 | |
| 3947 | /* Configure static BGP network. */ |
| 3948 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3949 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3950 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3951 | { |
| 3952 | int ret; |
| 3953 | struct bgp *bgp; |
| 3954 | struct prefix p; |
| 3955 | struct prefix_rd prd; |
| 3956 | struct bgp_node *prn; |
| 3957 | struct bgp_node *rn; |
| 3958 | struct bgp_table *table; |
| 3959 | struct bgp_static *bgp_static; |
| 3960 | u_char tag[3]; |
| 3961 | |
| 3962 | bgp = vty->index; |
| 3963 | |
| 3964 | /* Convert IP prefix string to struct prefix. */ |
| 3965 | ret = str2prefix (ip_str, &p); |
| 3966 | if (! ret) |
| 3967 | { |
| 3968 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3969 | return CMD_WARNING; |
| 3970 | } |
| 3971 | apply_mask (&p); |
| 3972 | |
| 3973 | ret = str2prefix_rd (rd_str, &prd); |
| 3974 | if (! ret) |
| 3975 | { |
| 3976 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3977 | return CMD_WARNING; |
| 3978 | } |
| 3979 | |
| 3980 | ret = str2tag (tag_str, tag); |
| 3981 | if (! ret) |
| 3982 | { |
| 3983 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3984 | return CMD_WARNING; |
| 3985 | } |
| 3986 | |
| 3987 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3988 | (struct prefix *)&prd); |
| 3989 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3990 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3991 | else |
| 3992 | bgp_unlock_node (prn); |
| 3993 | table = prn->info; |
| 3994 | |
| 3995 | rn = bgp_node_lookup (table, &p); |
| 3996 | |
| 3997 | if (rn) |
| 3998 | { |
| 3999 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 4000 | |
| 4001 | bgp_static = rn->info; |
| 4002 | bgp_static_free (bgp_static); |
| 4003 | rn->info = NULL; |
| 4004 | bgp_unlock_node (rn); |
| 4005 | bgp_unlock_node (rn); |
| 4006 | } |
| 4007 | else |
| 4008 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 4009 | |
| 4010 | return CMD_SUCCESS; |
| 4011 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4012 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4013 | DEFUN (bgp_network, |
| 4014 | bgp_network_cmd, |
| 4015 | "network A.B.C.D/M", |
| 4016 | "Specify a network to announce via BGP\n" |
| 4017 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4018 | { |
| 4019 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4020 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4021 | } |
| 4022 | |
| 4023 | DEFUN (bgp_network_route_map, |
| 4024 | bgp_network_route_map_cmd, |
| 4025 | "network A.B.C.D/M route-map WORD", |
| 4026 | "Specify a network to announce via BGP\n" |
| 4027 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4028 | "Route-map to modify the attributes\n" |
| 4029 | "Name of the route map\n") |
| 4030 | { |
| 4031 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4032 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4033 | } |
| 4034 | |
| 4035 | DEFUN (bgp_network_backdoor, |
| 4036 | bgp_network_backdoor_cmd, |
| 4037 | "network A.B.C.D/M backdoor", |
| 4038 | "Specify a network to announce via BGP\n" |
| 4039 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4040 | "Specify a BGP backdoor route\n") |
| 4041 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4042 | 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] | 4043 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4044 | } |
| 4045 | |
| 4046 | DEFUN (bgp_network_mask, |
| 4047 | bgp_network_mask_cmd, |
| 4048 | "network A.B.C.D mask A.B.C.D", |
| 4049 | "Specify a network to announce via BGP\n" |
| 4050 | "Network number\n" |
| 4051 | "Network mask\n" |
| 4052 | "Network mask\n") |
| 4053 | { |
| 4054 | int ret; |
| 4055 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4056 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4057 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4058 | if (! ret) |
| 4059 | { |
| 4060 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4061 | return CMD_WARNING; |
| 4062 | } |
| 4063 | |
| 4064 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4065 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4066 | } |
| 4067 | |
| 4068 | DEFUN (bgp_network_mask_route_map, |
| 4069 | bgp_network_mask_route_map_cmd, |
| 4070 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4071 | "Specify a network to announce via BGP\n" |
| 4072 | "Network number\n" |
| 4073 | "Network mask\n" |
| 4074 | "Network mask\n" |
| 4075 | "Route-map to modify the attributes\n" |
| 4076 | "Name of the route map\n") |
| 4077 | { |
| 4078 | int ret; |
| 4079 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4080 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4081 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4082 | if (! ret) |
| 4083 | { |
| 4084 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4085 | return CMD_WARNING; |
| 4086 | } |
| 4087 | |
| 4088 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4089 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4090 | } |
| 4091 | |
| 4092 | DEFUN (bgp_network_mask_backdoor, |
| 4093 | bgp_network_mask_backdoor_cmd, |
| 4094 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4095 | "Specify a network to announce via BGP\n" |
| 4096 | "Network number\n" |
| 4097 | "Network mask\n" |
| 4098 | "Network mask\n" |
| 4099 | "Specify a BGP backdoor route\n") |
| 4100 | { |
| 4101 | int ret; |
| 4102 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4103 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4104 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4105 | if (! ret) |
| 4106 | { |
| 4107 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4108 | return CMD_WARNING; |
| 4109 | } |
| 4110 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4111 | 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] | 4112 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4113 | } |
| 4114 | |
| 4115 | DEFUN (bgp_network_mask_natural, |
| 4116 | bgp_network_mask_natural_cmd, |
| 4117 | "network A.B.C.D", |
| 4118 | "Specify a network to announce via BGP\n" |
| 4119 | "Network number\n") |
| 4120 | { |
| 4121 | int ret; |
| 4122 | char prefix_str[BUFSIZ]; |
| 4123 | |
| 4124 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4125 | if (! ret) |
| 4126 | { |
| 4127 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4128 | return CMD_WARNING; |
| 4129 | } |
| 4130 | |
| 4131 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4132 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4133 | } |
| 4134 | |
| 4135 | DEFUN (bgp_network_mask_natural_route_map, |
| 4136 | bgp_network_mask_natural_route_map_cmd, |
| 4137 | "network A.B.C.D route-map WORD", |
| 4138 | "Specify a network to announce via BGP\n" |
| 4139 | "Network number\n" |
| 4140 | "Route-map to modify the attributes\n" |
| 4141 | "Name of the route map\n") |
| 4142 | { |
| 4143 | int ret; |
| 4144 | char prefix_str[BUFSIZ]; |
| 4145 | |
| 4146 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4147 | if (! ret) |
| 4148 | { |
| 4149 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4150 | return CMD_WARNING; |
| 4151 | } |
| 4152 | |
| 4153 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4154 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4155 | } |
| 4156 | |
| 4157 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4158 | bgp_network_mask_natural_backdoor_cmd, |
| 4159 | "network A.B.C.D backdoor", |
| 4160 | "Specify a network to announce via BGP\n" |
| 4161 | "Network number\n" |
| 4162 | "Specify a BGP backdoor route\n") |
| 4163 | { |
| 4164 | int ret; |
| 4165 | char prefix_str[BUFSIZ]; |
| 4166 | |
| 4167 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4168 | if (! ret) |
| 4169 | { |
| 4170 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4171 | return CMD_WARNING; |
| 4172 | } |
| 4173 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4174 | 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] | 4175 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4176 | } |
| 4177 | |
| 4178 | DEFUN (no_bgp_network, |
| 4179 | no_bgp_network_cmd, |
| 4180 | "no network A.B.C.D/M", |
| 4181 | NO_STR |
| 4182 | "Specify a network to announce via BGP\n" |
| 4183 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4184 | { |
| 4185 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4186 | bgp_node_safi (vty)); |
| 4187 | } |
| 4188 | |
| 4189 | ALIAS (no_bgp_network, |
| 4190 | no_bgp_network_route_map_cmd, |
| 4191 | "no network A.B.C.D/M route-map WORD", |
| 4192 | NO_STR |
| 4193 | "Specify a network to announce via BGP\n" |
| 4194 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4195 | "Route-map to modify the attributes\n" |
| 4196 | "Name of the route map\n") |
| 4197 | |
| 4198 | ALIAS (no_bgp_network, |
| 4199 | no_bgp_network_backdoor_cmd, |
| 4200 | "no network A.B.C.D/M backdoor", |
| 4201 | NO_STR |
| 4202 | "Specify a network to announce via BGP\n" |
| 4203 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4204 | "Specify a BGP backdoor route\n") |
| 4205 | |
| 4206 | DEFUN (no_bgp_network_mask, |
| 4207 | no_bgp_network_mask_cmd, |
| 4208 | "no network A.B.C.D mask A.B.C.D", |
| 4209 | NO_STR |
| 4210 | "Specify a network to announce via BGP\n" |
| 4211 | "Network number\n" |
| 4212 | "Network mask\n" |
| 4213 | "Network mask\n") |
| 4214 | { |
| 4215 | int ret; |
| 4216 | char prefix_str[BUFSIZ]; |
| 4217 | |
| 4218 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4219 | if (! ret) |
| 4220 | { |
| 4221 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4222 | return CMD_WARNING; |
| 4223 | } |
| 4224 | |
| 4225 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4226 | bgp_node_safi (vty)); |
| 4227 | } |
| 4228 | |
| 4229 | ALIAS (no_bgp_network_mask, |
| 4230 | no_bgp_network_mask_route_map_cmd, |
| 4231 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4232 | NO_STR |
| 4233 | "Specify a network to announce via BGP\n" |
| 4234 | "Network number\n" |
| 4235 | "Network mask\n" |
| 4236 | "Network mask\n" |
| 4237 | "Route-map to modify the attributes\n" |
| 4238 | "Name of the route map\n") |
| 4239 | |
| 4240 | ALIAS (no_bgp_network_mask, |
| 4241 | no_bgp_network_mask_backdoor_cmd, |
| 4242 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4243 | NO_STR |
| 4244 | "Specify a network to announce via BGP\n" |
| 4245 | "Network number\n" |
| 4246 | "Network mask\n" |
| 4247 | "Network mask\n" |
| 4248 | "Specify a BGP backdoor route\n") |
| 4249 | |
| 4250 | DEFUN (no_bgp_network_mask_natural, |
| 4251 | no_bgp_network_mask_natural_cmd, |
| 4252 | "no network A.B.C.D", |
| 4253 | NO_STR |
| 4254 | "Specify a network to announce via BGP\n" |
| 4255 | "Network number\n") |
| 4256 | { |
| 4257 | int ret; |
| 4258 | char prefix_str[BUFSIZ]; |
| 4259 | |
| 4260 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4261 | if (! ret) |
| 4262 | { |
| 4263 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4264 | return CMD_WARNING; |
| 4265 | } |
| 4266 | |
| 4267 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4268 | bgp_node_safi (vty)); |
| 4269 | } |
| 4270 | |
| 4271 | ALIAS (no_bgp_network_mask_natural, |
| 4272 | no_bgp_network_mask_natural_route_map_cmd, |
| 4273 | "no network A.B.C.D route-map WORD", |
| 4274 | NO_STR |
| 4275 | "Specify a network to announce via BGP\n" |
| 4276 | "Network number\n" |
| 4277 | "Route-map to modify the attributes\n" |
| 4278 | "Name of the route map\n") |
| 4279 | |
| 4280 | ALIAS (no_bgp_network_mask_natural, |
| 4281 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4282 | "no network A.B.C.D backdoor", |
| 4283 | NO_STR |
| 4284 | "Specify a network to announce via BGP\n" |
| 4285 | "Network number\n" |
| 4286 | "Specify a BGP backdoor route\n") |
| 4287 | |
| 4288 | #ifdef HAVE_IPV6 |
| 4289 | DEFUN (ipv6_bgp_network, |
| 4290 | ipv6_bgp_network_cmd, |
| 4291 | "network X:X::X:X/M", |
| 4292 | "Specify a network to announce via BGP\n" |
| 4293 | "IPv6 prefix <network>/<length>\n") |
| 4294 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4295 | 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] | 4296 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4297 | } |
| 4298 | |
| 4299 | DEFUN (ipv6_bgp_network_route_map, |
| 4300 | ipv6_bgp_network_route_map_cmd, |
| 4301 | "network X:X::X:X/M route-map WORD", |
| 4302 | "Specify a network to announce via BGP\n" |
| 4303 | "IPv6 prefix <network>/<length>\n" |
| 4304 | "Route-map to modify the attributes\n" |
| 4305 | "Name of the route map\n") |
| 4306 | { |
| 4307 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4308 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4309 | } |
| 4310 | |
| 4311 | DEFUN (no_ipv6_bgp_network, |
| 4312 | no_ipv6_bgp_network_cmd, |
| 4313 | "no network X:X::X:X/M", |
| 4314 | NO_STR |
| 4315 | "Specify a network to announce via BGP\n" |
| 4316 | "IPv6 prefix <network>/<length>\n") |
| 4317 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4318 | 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] | 4319 | } |
| 4320 | |
| 4321 | ALIAS (no_ipv6_bgp_network, |
| 4322 | no_ipv6_bgp_network_route_map_cmd, |
| 4323 | "no network X:X::X:X/M route-map WORD", |
| 4324 | NO_STR |
| 4325 | "Specify a network to announce via BGP\n" |
| 4326 | "IPv6 prefix <network>/<length>\n" |
| 4327 | "Route-map to modify the attributes\n" |
| 4328 | "Name of the route map\n") |
| 4329 | |
| 4330 | ALIAS (ipv6_bgp_network, |
| 4331 | old_ipv6_bgp_network_cmd, |
| 4332 | "ipv6 bgp network X:X::X:X/M", |
| 4333 | IPV6_STR |
| 4334 | BGP_STR |
| 4335 | "Specify a network to announce via BGP\n" |
| 4336 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4337 | |
| 4338 | ALIAS (no_ipv6_bgp_network, |
| 4339 | old_no_ipv6_bgp_network_cmd, |
| 4340 | "no ipv6 bgp network X:X::X:X/M", |
| 4341 | NO_STR |
| 4342 | IPV6_STR |
| 4343 | BGP_STR |
| 4344 | "Specify a network to announce via BGP\n" |
| 4345 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4346 | #endif /* HAVE_IPV6 */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4347 | |
| 4348 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4349 | ALIAS_DEPRECATED (bgp_network, |
| 4350 | bgp_network_ttl_cmd, |
| 4351 | "network A.B.C.D/M pathlimit <0-255>", |
| 4352 | "Specify a network to announce via BGP\n" |
| 4353 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4354 | "AS-Path hopcount limit attribute\n" |
| 4355 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4356 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4357 | bgp_network_backdoor_ttl_cmd, |
| 4358 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4359 | "Specify a network to announce via BGP\n" |
| 4360 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4361 | "Specify a BGP backdoor route\n" |
| 4362 | "AS-Path hopcount limit attribute\n" |
| 4363 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4364 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4365 | bgp_network_mask_ttl_cmd, |
| 4366 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4367 | "Specify a network to announce via BGP\n" |
| 4368 | "Network number\n" |
| 4369 | "Network mask\n" |
| 4370 | "Network mask\n" |
| 4371 | "AS-Path hopcount limit attribute\n" |
| 4372 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4373 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4374 | bgp_network_mask_backdoor_ttl_cmd, |
| 4375 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4376 | "Specify a network to announce via BGP\n" |
| 4377 | "Network number\n" |
| 4378 | "Network mask\n" |
| 4379 | "Network mask\n" |
| 4380 | "Specify a BGP backdoor route\n" |
| 4381 | "AS-Path hopcount limit attribute\n" |
| 4382 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4383 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4384 | bgp_network_mask_natural_ttl_cmd, |
| 4385 | "network A.B.C.D pathlimit <0-255>", |
| 4386 | "Specify a network to announce via BGP\n" |
| 4387 | "Network number\n" |
| 4388 | "AS-Path hopcount limit attribute\n" |
| 4389 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4390 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4391 | bgp_network_mask_natural_backdoor_ttl_cmd, |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 4392 | "network A.B.C.D backdoor pathlimit <1-255>", |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4393 | "Specify a network to announce via BGP\n" |
| 4394 | "Network number\n" |
| 4395 | "Specify a BGP backdoor route\n" |
| 4396 | "AS-Path hopcount limit attribute\n" |
| 4397 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4398 | ALIAS_DEPRECATED (no_bgp_network, |
| 4399 | no_bgp_network_ttl_cmd, |
| 4400 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4401 | NO_STR |
| 4402 | "Specify a network to announce via BGP\n" |
| 4403 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4404 | "AS-Path hopcount limit attribute\n" |
| 4405 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4406 | ALIAS_DEPRECATED (no_bgp_network, |
| 4407 | no_bgp_network_backdoor_ttl_cmd, |
| 4408 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4409 | NO_STR |
| 4410 | "Specify a network to announce via BGP\n" |
| 4411 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4412 | "Specify a BGP backdoor route\n" |
| 4413 | "AS-Path hopcount limit attribute\n" |
| 4414 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4415 | ALIAS_DEPRECATED (no_bgp_network, |
| 4416 | no_bgp_network_mask_ttl_cmd, |
| 4417 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4418 | NO_STR |
| 4419 | "Specify a network to announce via BGP\n" |
| 4420 | "Network number\n" |
| 4421 | "Network mask\n" |
| 4422 | "Network mask\n" |
| 4423 | "AS-Path hopcount limit attribute\n" |
| 4424 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4425 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4426 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4427 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4428 | NO_STR |
| 4429 | "Specify a network to announce via BGP\n" |
| 4430 | "Network number\n" |
| 4431 | "Network mask\n" |
| 4432 | "Network mask\n" |
| 4433 | "Specify a BGP backdoor route\n" |
| 4434 | "AS-Path hopcount limit attribute\n" |
| 4435 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4436 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4437 | no_bgp_network_mask_natural_ttl_cmd, |
| 4438 | "no network A.B.C.D pathlimit <0-255>", |
| 4439 | NO_STR |
| 4440 | "Specify a network to announce via BGP\n" |
| 4441 | "Network number\n" |
| 4442 | "AS-Path hopcount limit attribute\n" |
| 4443 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4444 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4445 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4446 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4447 | NO_STR |
| 4448 | "Specify a network to announce via BGP\n" |
| 4449 | "Network number\n" |
| 4450 | "Specify a BGP backdoor route\n" |
| 4451 | "AS-Path hopcount limit attribute\n" |
| 4452 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4453 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4454 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4455 | ipv6_bgp_network_ttl_cmd, |
| 4456 | "network X:X::X:X/M pathlimit <0-255>", |
| 4457 | "Specify a network to announce via BGP\n" |
| 4458 | "IPv6 prefix <network>/<length>\n" |
| 4459 | "AS-Path hopcount limit attribute\n" |
| 4460 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4461 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4462 | no_ipv6_bgp_network_ttl_cmd, |
| 4463 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4464 | NO_STR |
| 4465 | "Specify a network to announce via BGP\n" |
| 4466 | "IPv6 prefix <network>/<length>\n" |
| 4467 | "AS-Path hopcount limit attribute\n" |
| 4468 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4469 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4470 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4471 | /* Aggreagete address: |
| 4472 | |
| 4473 | advertise-map Set condition to advertise attribute |
| 4474 | as-set Generate AS set path information |
| 4475 | attribute-map Set attributes of aggregate |
| 4476 | route-map Set parameters of aggregate |
| 4477 | summary-only Filter more specific routes from updates |
| 4478 | suppress-map Conditionally filter more specific routes from updates |
| 4479 | <cr> |
| 4480 | */ |
| 4481 | struct bgp_aggregate |
| 4482 | { |
| 4483 | /* Summary-only flag. */ |
| 4484 | u_char summary_only; |
| 4485 | |
| 4486 | /* AS set generation. */ |
| 4487 | u_char as_set; |
| 4488 | |
| 4489 | /* Route-map for aggregated route. */ |
| 4490 | struct route_map *map; |
| 4491 | |
| 4492 | /* Suppress-count. */ |
| 4493 | unsigned long count; |
| 4494 | |
| 4495 | /* SAFI configuration. */ |
| 4496 | safi_t safi; |
| 4497 | }; |
| 4498 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4499 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4500 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4501 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4502 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4503 | } |
| 4504 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4505 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4506 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4507 | { |
| 4508 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4509 | } |
| 4510 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4511 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4512 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4513 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4514 | struct bgp_aggregate *aggregate) |
| 4515 | { |
| 4516 | struct bgp_table *table; |
| 4517 | struct bgp_node *top; |
| 4518 | struct bgp_node *rn; |
| 4519 | u_char origin; |
| 4520 | struct aspath *aspath = NULL; |
| 4521 | struct aspath *asmerge = NULL; |
| 4522 | struct community *community = NULL; |
| 4523 | struct community *commerge = NULL; |
| 4524 | struct in_addr nexthop; |
| 4525 | u_int32_t med = 0; |
| 4526 | struct bgp_info *ri; |
| 4527 | struct bgp_info *new; |
| 4528 | int first = 1; |
| 4529 | unsigned long match = 0; |
| 4530 | |
| 4531 | /* Record adding route's nexthop and med. */ |
| 4532 | if (rinew) |
| 4533 | { |
| 4534 | nexthop = rinew->attr->nexthop; |
| 4535 | med = rinew->attr->med; |
| 4536 | } |
| 4537 | |
| 4538 | /* ORIGIN attribute: If at least one route among routes that are |
| 4539 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4540 | aggregated route must have the ORIGIN attribute with the value |
| 4541 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4542 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4543 | route must have the origin attribute with the value EGP. In all |
| 4544 | other case the value of the ORIGIN attribute of the aggregated |
| 4545 | route is INTERNAL. */ |
| 4546 | origin = BGP_ORIGIN_IGP; |
| 4547 | |
| 4548 | table = bgp->rib[afi][safi]; |
| 4549 | |
| 4550 | top = bgp_node_get (table, p); |
| 4551 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4552 | if (rn->p.prefixlen > p->prefixlen) |
| 4553 | { |
| 4554 | match = 0; |
| 4555 | |
| 4556 | for (ri = rn->info; ri; ri = ri->next) |
| 4557 | { |
| 4558 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4559 | continue; |
| 4560 | |
| 4561 | if (del && ri == del) |
| 4562 | continue; |
| 4563 | |
| 4564 | if (! rinew && first) |
| 4565 | { |
| 4566 | nexthop = ri->attr->nexthop; |
| 4567 | med = ri->attr->med; |
| 4568 | first = 0; |
| 4569 | } |
| 4570 | |
| 4571 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4572 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4573 | || ri->attr->med != med) |
| 4574 | { |
| 4575 | if (aspath) |
| 4576 | aspath_free (aspath); |
| 4577 | if (community) |
| 4578 | community_free (community); |
| 4579 | bgp_unlock_node (rn); |
| 4580 | bgp_unlock_node (top); |
| 4581 | return; |
| 4582 | } |
| 4583 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4584 | |
| 4585 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4586 | { |
| 4587 | if (aggregate->summary_only) |
| 4588 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4589 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4590 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4591 | match++; |
| 4592 | } |
| 4593 | |
| 4594 | aggregate->count++; |
| 4595 | |
| 4596 | if (aggregate->as_set) |
| 4597 | { |
| 4598 | if (origin < ri->attr->origin) |
| 4599 | origin = ri->attr->origin; |
| 4600 | |
| 4601 | if (aspath) |
| 4602 | { |
| 4603 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4604 | aspath_free (aspath); |
| 4605 | aspath = asmerge; |
| 4606 | } |
| 4607 | else |
| 4608 | aspath = aspath_dup (ri->attr->aspath); |
| 4609 | |
| 4610 | if (ri->attr->community) |
| 4611 | { |
| 4612 | if (community) |
| 4613 | { |
| 4614 | commerge = community_merge (community, |
| 4615 | ri->attr->community); |
| 4616 | community = community_uniq_sort (commerge); |
| 4617 | community_free (commerge); |
| 4618 | } |
| 4619 | else |
| 4620 | community = community_dup (ri->attr->community); |
| 4621 | } |
| 4622 | } |
| 4623 | } |
| 4624 | } |
| 4625 | if (match) |
| 4626 | bgp_process (bgp, rn, afi, safi); |
| 4627 | } |
| 4628 | bgp_unlock_node (top); |
| 4629 | |
| 4630 | if (rinew) |
| 4631 | { |
| 4632 | aggregate->count++; |
| 4633 | |
| 4634 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4635 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4636 | |
| 4637 | if (aggregate->as_set) |
| 4638 | { |
| 4639 | if (origin < rinew->attr->origin) |
| 4640 | origin = rinew->attr->origin; |
| 4641 | |
| 4642 | if (aspath) |
| 4643 | { |
| 4644 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4645 | aspath_free (aspath); |
| 4646 | aspath = asmerge; |
| 4647 | } |
| 4648 | else |
| 4649 | aspath = aspath_dup (rinew->attr->aspath); |
| 4650 | |
| 4651 | if (rinew->attr->community) |
| 4652 | { |
| 4653 | if (community) |
| 4654 | { |
| 4655 | commerge = community_merge (community, |
| 4656 | rinew->attr->community); |
| 4657 | community = community_uniq_sort (commerge); |
| 4658 | community_free (commerge); |
| 4659 | } |
| 4660 | else |
| 4661 | community = community_dup (rinew->attr->community); |
| 4662 | } |
| 4663 | } |
| 4664 | } |
| 4665 | |
| 4666 | if (aggregate->count > 0) |
| 4667 | { |
| 4668 | rn = bgp_node_get (table, p); |
| 4669 | new = bgp_info_new (); |
| 4670 | new->type = ZEBRA_ROUTE_BGP; |
| 4671 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4672 | new->peer = bgp->peer_self; |
| 4673 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4674 | 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] | 4675 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4676 | |
| 4677 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4678 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4679 | bgp_process (bgp, rn, afi, safi); |
| 4680 | } |
| 4681 | else |
| 4682 | { |
| 4683 | if (aspath) |
| 4684 | aspath_free (aspath); |
| 4685 | if (community) |
| 4686 | community_free (community); |
| 4687 | } |
| 4688 | } |
| 4689 | |
| 4690 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4691 | struct bgp_aggregate *); |
| 4692 | |
| 4693 | void |
| 4694 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4695 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4696 | { |
| 4697 | struct bgp_node *child; |
| 4698 | struct bgp_node *rn; |
| 4699 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4700 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4701 | |
| 4702 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4703 | if (safi == SAFI_MPLS_VPN) |
| 4704 | return; |
| 4705 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4706 | table = bgp->aggregate[afi][safi]; |
| 4707 | |
| 4708 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4709 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4710 | return; |
| 4711 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4712 | if (p->prefixlen == 0) |
| 4713 | return; |
| 4714 | |
| 4715 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4716 | return; |
| 4717 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4718 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4719 | |
| 4720 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4721 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4722 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4723 | { |
| 4724 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4725 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4726 | } |
| 4727 | bgp_unlock_node (child); |
| 4728 | } |
| 4729 | |
| 4730 | void |
| 4731 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4732 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4733 | { |
| 4734 | struct bgp_node *child; |
| 4735 | struct bgp_node *rn; |
| 4736 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4737 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4738 | |
| 4739 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4740 | if (safi == SAFI_MPLS_VPN) |
| 4741 | return; |
| 4742 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4743 | table = bgp->aggregate[afi][safi]; |
| 4744 | |
| 4745 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4746 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4747 | return; |
| 4748 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4749 | if (p->prefixlen == 0) |
| 4750 | return; |
| 4751 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4752 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4753 | |
| 4754 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4755 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4756 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4757 | { |
| 4758 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4759 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4760 | } |
| 4761 | bgp_unlock_node (child); |
| 4762 | } |
| 4763 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4764 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4765 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4766 | struct bgp_aggregate *aggregate) |
| 4767 | { |
| 4768 | struct bgp_table *table; |
| 4769 | struct bgp_node *top; |
| 4770 | struct bgp_node *rn; |
| 4771 | struct bgp_info *new; |
| 4772 | struct bgp_info *ri; |
| 4773 | unsigned long match; |
| 4774 | u_char origin = BGP_ORIGIN_IGP; |
| 4775 | struct aspath *aspath = NULL; |
| 4776 | struct aspath *asmerge = NULL; |
| 4777 | struct community *community = NULL; |
| 4778 | struct community *commerge = NULL; |
| 4779 | |
| 4780 | table = bgp->rib[afi][safi]; |
| 4781 | |
| 4782 | /* Sanity check. */ |
| 4783 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4784 | return; |
| 4785 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4786 | return; |
| 4787 | |
| 4788 | /* If routes exists below this node, generate aggregate routes. */ |
| 4789 | top = bgp_node_get (table, p); |
| 4790 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4791 | if (rn->p.prefixlen > p->prefixlen) |
| 4792 | { |
| 4793 | match = 0; |
| 4794 | |
| 4795 | for (ri = rn->info; ri; ri = ri->next) |
| 4796 | { |
| 4797 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4798 | continue; |
| 4799 | |
| 4800 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4801 | { |
| 4802 | /* summary-only aggregate route suppress aggregated |
| 4803 | route announcement. */ |
| 4804 | if (aggregate->summary_only) |
| 4805 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4806 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4807 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4808 | match++; |
| 4809 | } |
| 4810 | /* as-set aggregate route generate origin, as path, |
| 4811 | community aggregation. */ |
| 4812 | if (aggregate->as_set) |
| 4813 | { |
| 4814 | if (origin < ri->attr->origin) |
| 4815 | origin = ri->attr->origin; |
| 4816 | |
| 4817 | if (aspath) |
| 4818 | { |
| 4819 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4820 | aspath_free (aspath); |
| 4821 | aspath = asmerge; |
| 4822 | } |
| 4823 | else |
| 4824 | aspath = aspath_dup (ri->attr->aspath); |
| 4825 | |
| 4826 | if (ri->attr->community) |
| 4827 | { |
| 4828 | if (community) |
| 4829 | { |
| 4830 | commerge = community_merge (community, |
| 4831 | ri->attr->community); |
| 4832 | community = community_uniq_sort (commerge); |
| 4833 | community_free (commerge); |
| 4834 | } |
| 4835 | else |
| 4836 | community = community_dup (ri->attr->community); |
| 4837 | } |
| 4838 | } |
| 4839 | aggregate->count++; |
| 4840 | } |
| 4841 | } |
| 4842 | |
| 4843 | /* If this node is suppressed, process the change. */ |
| 4844 | if (match) |
| 4845 | bgp_process (bgp, rn, afi, safi); |
| 4846 | } |
| 4847 | bgp_unlock_node (top); |
| 4848 | |
| 4849 | /* Add aggregate route to BGP table. */ |
| 4850 | if (aggregate->count) |
| 4851 | { |
| 4852 | rn = bgp_node_get (table, p); |
| 4853 | |
| 4854 | new = bgp_info_new (); |
| 4855 | new->type = ZEBRA_ROUTE_BGP; |
| 4856 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4857 | new->peer = bgp->peer_self; |
| 4858 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4859 | 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] | 4860 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4861 | |
| 4862 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4863 | bgp_unlock_node (rn); |
| 4864 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4865 | /* Process change. */ |
| 4866 | bgp_process (bgp, rn, afi, safi); |
| 4867 | } |
| 4868 | } |
| 4869 | |
| 4870 | void |
| 4871 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4872 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4873 | { |
| 4874 | struct bgp_table *table; |
| 4875 | struct bgp_node *top; |
| 4876 | struct bgp_node *rn; |
| 4877 | struct bgp_info *ri; |
| 4878 | unsigned long match; |
| 4879 | |
| 4880 | table = bgp->rib[afi][safi]; |
| 4881 | |
| 4882 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4883 | return; |
| 4884 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4885 | return; |
| 4886 | |
| 4887 | /* If routes exists below this node, generate aggregate routes. */ |
| 4888 | top = bgp_node_get (table, p); |
| 4889 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4890 | if (rn->p.prefixlen > p->prefixlen) |
| 4891 | { |
| 4892 | match = 0; |
| 4893 | |
| 4894 | for (ri = rn->info; ri; ri = ri->next) |
| 4895 | { |
| 4896 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4897 | continue; |
| 4898 | |
| 4899 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4900 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4901 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4902 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4903 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4904 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4905 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4906 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4907 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4908 | match++; |
| 4909 | } |
| 4910 | } |
| 4911 | aggregate->count--; |
| 4912 | } |
| 4913 | } |
| 4914 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4915 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4916 | if (match) |
| 4917 | bgp_process (bgp, rn, afi, safi); |
| 4918 | } |
| 4919 | bgp_unlock_node (top); |
| 4920 | |
| 4921 | /* Delete aggregate route from BGP table. */ |
| 4922 | rn = bgp_node_get (table, p); |
| 4923 | |
| 4924 | for (ri = rn->info; ri; ri = ri->next) |
| 4925 | if (ri->peer == bgp->peer_self |
| 4926 | && ri->type == ZEBRA_ROUTE_BGP |
| 4927 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4928 | break; |
| 4929 | |
| 4930 | /* Withdraw static BGP route from routing table. */ |
| 4931 | if (ri) |
| 4932 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4933 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4934 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4935 | } |
| 4936 | |
| 4937 | /* Unlock bgp_node_lookup. */ |
| 4938 | bgp_unlock_node (rn); |
| 4939 | } |
| 4940 | |
| 4941 | /* Aggregate route attribute. */ |
| 4942 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4943 | #define AGGREGATE_AS_SET 1 |
| 4944 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4945 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4946 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4947 | afi_t afi, safi_t safi) |
| 4948 | { |
| 4949 | int ret; |
| 4950 | struct prefix p; |
| 4951 | struct bgp_node *rn; |
| 4952 | struct bgp *bgp; |
| 4953 | struct bgp_aggregate *aggregate; |
| 4954 | |
| 4955 | /* Convert string to prefix structure. */ |
| 4956 | ret = str2prefix (prefix_str, &p); |
| 4957 | if (!ret) |
| 4958 | { |
| 4959 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4960 | return CMD_WARNING; |
| 4961 | } |
| 4962 | apply_mask (&p); |
| 4963 | |
| 4964 | /* Get BGP structure. */ |
| 4965 | bgp = vty->index; |
| 4966 | |
| 4967 | /* Old configuration check. */ |
| 4968 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4969 | if (! rn) |
| 4970 | { |
| 4971 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4972 | VTY_NEWLINE); |
| 4973 | return CMD_WARNING; |
| 4974 | } |
| 4975 | |
| 4976 | aggregate = rn->info; |
| 4977 | if (aggregate->safi & SAFI_UNICAST) |
| 4978 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4979 | if (aggregate->safi & SAFI_MULTICAST) |
| 4980 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4981 | |
| 4982 | /* Unlock aggregate address configuration. */ |
| 4983 | rn->info = NULL; |
| 4984 | bgp_aggregate_free (aggregate); |
| 4985 | bgp_unlock_node (rn); |
| 4986 | bgp_unlock_node (rn); |
| 4987 | |
| 4988 | return CMD_SUCCESS; |
| 4989 | } |
| 4990 | |
| 4991 | static int |
| 4992 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4993 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4994 | u_char summary_only, u_char as_set) |
| 4995 | { |
| 4996 | int ret; |
| 4997 | struct prefix p; |
| 4998 | struct bgp_node *rn; |
| 4999 | struct bgp *bgp; |
| 5000 | struct bgp_aggregate *aggregate; |
| 5001 | |
| 5002 | /* Convert string to prefix structure. */ |
| 5003 | ret = str2prefix (prefix_str, &p); |
| 5004 | if (!ret) |
| 5005 | { |
| 5006 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5007 | return CMD_WARNING; |
| 5008 | } |
| 5009 | apply_mask (&p); |
| 5010 | |
| 5011 | /* Get BGP structure. */ |
| 5012 | bgp = vty->index; |
| 5013 | |
| 5014 | /* Old configuration check. */ |
| 5015 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 5016 | |
| 5017 | if (rn->info) |
| 5018 | { |
| 5019 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5020 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5021 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 5022 | if (ret) |
| 5023 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5024 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 5025 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5026 | return CMD_WARNING; |
| 5027 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5028 | } |
| 5029 | |
| 5030 | /* Make aggregate address structure. */ |
| 5031 | aggregate = bgp_aggregate_new (); |
| 5032 | aggregate->summary_only = summary_only; |
| 5033 | aggregate->as_set = as_set; |
| 5034 | aggregate->safi = safi; |
| 5035 | rn->info = aggregate; |
| 5036 | |
| 5037 | /* Aggregate address insert into BGP routing table. */ |
| 5038 | if (safi & SAFI_UNICAST) |
| 5039 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5040 | if (safi & SAFI_MULTICAST) |
| 5041 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5042 | |
| 5043 | return CMD_SUCCESS; |
| 5044 | } |
| 5045 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5046 | DEFUN (aggregate_address, |
| 5047 | aggregate_address_cmd, |
| 5048 | "aggregate-address A.B.C.D/M", |
| 5049 | "Configure BGP aggregate entries\n" |
| 5050 | "Aggregate prefix\n") |
| 5051 | { |
| 5052 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5053 | } |
| 5054 | |
| 5055 | DEFUN (aggregate_address_mask, |
| 5056 | aggregate_address_mask_cmd, |
| 5057 | "aggregate-address A.B.C.D A.B.C.D", |
| 5058 | "Configure BGP aggregate entries\n" |
| 5059 | "Aggregate address\n" |
| 5060 | "Aggregate mask\n") |
| 5061 | { |
| 5062 | int ret; |
| 5063 | char prefix_str[BUFSIZ]; |
| 5064 | |
| 5065 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5066 | |
| 5067 | if (! ret) |
| 5068 | { |
| 5069 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5070 | return CMD_WARNING; |
| 5071 | } |
| 5072 | |
| 5073 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5074 | 0, 0); |
| 5075 | } |
| 5076 | |
| 5077 | DEFUN (aggregate_address_summary_only, |
| 5078 | aggregate_address_summary_only_cmd, |
| 5079 | "aggregate-address A.B.C.D/M summary-only", |
| 5080 | "Configure BGP aggregate entries\n" |
| 5081 | "Aggregate prefix\n" |
| 5082 | "Filter more specific routes from updates\n") |
| 5083 | { |
| 5084 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5085 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5086 | } |
| 5087 | |
| 5088 | DEFUN (aggregate_address_mask_summary_only, |
| 5089 | aggregate_address_mask_summary_only_cmd, |
| 5090 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5091 | "Configure BGP aggregate entries\n" |
| 5092 | "Aggregate address\n" |
| 5093 | "Aggregate mask\n" |
| 5094 | "Filter more specific routes from updates\n") |
| 5095 | { |
| 5096 | int ret; |
| 5097 | char prefix_str[BUFSIZ]; |
| 5098 | |
| 5099 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5100 | |
| 5101 | if (! ret) |
| 5102 | { |
| 5103 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5104 | return CMD_WARNING; |
| 5105 | } |
| 5106 | |
| 5107 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5108 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5109 | } |
| 5110 | |
| 5111 | DEFUN (aggregate_address_as_set, |
| 5112 | aggregate_address_as_set_cmd, |
| 5113 | "aggregate-address A.B.C.D/M as-set", |
| 5114 | "Configure BGP aggregate entries\n" |
| 5115 | "Aggregate prefix\n" |
| 5116 | "Generate AS set path information\n") |
| 5117 | { |
| 5118 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5119 | 0, AGGREGATE_AS_SET); |
| 5120 | } |
| 5121 | |
| 5122 | DEFUN (aggregate_address_mask_as_set, |
| 5123 | aggregate_address_mask_as_set_cmd, |
| 5124 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5125 | "Configure BGP aggregate entries\n" |
| 5126 | "Aggregate address\n" |
| 5127 | "Aggregate mask\n" |
| 5128 | "Generate AS set path information\n") |
| 5129 | { |
| 5130 | int ret; |
| 5131 | char prefix_str[BUFSIZ]; |
| 5132 | |
| 5133 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5134 | |
| 5135 | if (! ret) |
| 5136 | { |
| 5137 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5138 | return CMD_WARNING; |
| 5139 | } |
| 5140 | |
| 5141 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5142 | 0, AGGREGATE_AS_SET); |
| 5143 | } |
| 5144 | |
| 5145 | |
| 5146 | DEFUN (aggregate_address_as_set_summary, |
| 5147 | aggregate_address_as_set_summary_cmd, |
| 5148 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5149 | "Configure BGP aggregate entries\n" |
| 5150 | "Aggregate prefix\n" |
| 5151 | "Generate AS set path information\n" |
| 5152 | "Filter more specific routes from updates\n") |
| 5153 | { |
| 5154 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5155 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5156 | } |
| 5157 | |
| 5158 | ALIAS (aggregate_address_as_set_summary, |
| 5159 | aggregate_address_summary_as_set_cmd, |
| 5160 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5161 | "Configure BGP aggregate entries\n" |
| 5162 | "Aggregate prefix\n" |
| 5163 | "Filter more specific routes from updates\n" |
| 5164 | "Generate AS set path information\n") |
| 5165 | |
| 5166 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5167 | aggregate_address_mask_as_set_summary_cmd, |
| 5168 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5169 | "Configure BGP aggregate entries\n" |
| 5170 | "Aggregate address\n" |
| 5171 | "Aggregate mask\n" |
| 5172 | "Generate AS set path information\n" |
| 5173 | "Filter more specific routes from updates\n") |
| 5174 | { |
| 5175 | int ret; |
| 5176 | char prefix_str[BUFSIZ]; |
| 5177 | |
| 5178 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5179 | |
| 5180 | if (! ret) |
| 5181 | { |
| 5182 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5183 | return CMD_WARNING; |
| 5184 | } |
| 5185 | |
| 5186 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5187 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5188 | } |
| 5189 | |
| 5190 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5191 | aggregate_address_mask_summary_as_set_cmd, |
| 5192 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5193 | "Configure BGP aggregate entries\n" |
| 5194 | "Aggregate address\n" |
| 5195 | "Aggregate mask\n" |
| 5196 | "Filter more specific routes from updates\n" |
| 5197 | "Generate AS set path information\n") |
| 5198 | |
| 5199 | DEFUN (no_aggregate_address, |
| 5200 | no_aggregate_address_cmd, |
| 5201 | "no aggregate-address A.B.C.D/M", |
| 5202 | NO_STR |
| 5203 | "Configure BGP aggregate entries\n" |
| 5204 | "Aggregate prefix\n") |
| 5205 | { |
| 5206 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5207 | } |
| 5208 | |
| 5209 | ALIAS (no_aggregate_address, |
| 5210 | no_aggregate_address_summary_only_cmd, |
| 5211 | "no aggregate-address A.B.C.D/M summary-only", |
| 5212 | NO_STR |
| 5213 | "Configure BGP aggregate entries\n" |
| 5214 | "Aggregate prefix\n" |
| 5215 | "Filter more specific routes from updates\n") |
| 5216 | |
| 5217 | ALIAS (no_aggregate_address, |
| 5218 | no_aggregate_address_as_set_cmd, |
| 5219 | "no aggregate-address A.B.C.D/M as-set", |
| 5220 | NO_STR |
| 5221 | "Configure BGP aggregate entries\n" |
| 5222 | "Aggregate prefix\n" |
| 5223 | "Generate AS set path information\n") |
| 5224 | |
| 5225 | ALIAS (no_aggregate_address, |
| 5226 | no_aggregate_address_as_set_summary_cmd, |
| 5227 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5228 | NO_STR |
| 5229 | "Configure BGP aggregate entries\n" |
| 5230 | "Aggregate prefix\n" |
| 5231 | "Generate AS set path information\n" |
| 5232 | "Filter more specific routes from updates\n") |
| 5233 | |
| 5234 | ALIAS (no_aggregate_address, |
| 5235 | no_aggregate_address_summary_as_set_cmd, |
| 5236 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5237 | NO_STR |
| 5238 | "Configure BGP aggregate entries\n" |
| 5239 | "Aggregate prefix\n" |
| 5240 | "Filter more specific routes from updates\n" |
| 5241 | "Generate AS set path information\n") |
| 5242 | |
| 5243 | DEFUN (no_aggregate_address_mask, |
| 5244 | no_aggregate_address_mask_cmd, |
| 5245 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5246 | NO_STR |
| 5247 | "Configure BGP aggregate entries\n" |
| 5248 | "Aggregate address\n" |
| 5249 | "Aggregate mask\n") |
| 5250 | { |
| 5251 | int ret; |
| 5252 | char prefix_str[BUFSIZ]; |
| 5253 | |
| 5254 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5255 | |
| 5256 | if (! ret) |
| 5257 | { |
| 5258 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5259 | return CMD_WARNING; |
| 5260 | } |
| 5261 | |
| 5262 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5263 | } |
| 5264 | |
| 5265 | ALIAS (no_aggregate_address_mask, |
| 5266 | no_aggregate_address_mask_summary_only_cmd, |
| 5267 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5268 | NO_STR |
| 5269 | "Configure BGP aggregate entries\n" |
| 5270 | "Aggregate address\n" |
| 5271 | "Aggregate mask\n" |
| 5272 | "Filter more specific routes from updates\n") |
| 5273 | |
| 5274 | ALIAS (no_aggregate_address_mask, |
| 5275 | no_aggregate_address_mask_as_set_cmd, |
| 5276 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5277 | NO_STR |
| 5278 | "Configure BGP aggregate entries\n" |
| 5279 | "Aggregate address\n" |
| 5280 | "Aggregate mask\n" |
| 5281 | "Generate AS set path information\n") |
| 5282 | |
| 5283 | ALIAS (no_aggregate_address_mask, |
| 5284 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5285 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5286 | NO_STR |
| 5287 | "Configure BGP aggregate entries\n" |
| 5288 | "Aggregate address\n" |
| 5289 | "Aggregate mask\n" |
| 5290 | "Generate AS set path information\n" |
| 5291 | "Filter more specific routes from updates\n") |
| 5292 | |
| 5293 | ALIAS (no_aggregate_address_mask, |
| 5294 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5295 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5296 | NO_STR |
| 5297 | "Configure BGP aggregate entries\n" |
| 5298 | "Aggregate address\n" |
| 5299 | "Aggregate mask\n" |
| 5300 | "Filter more specific routes from updates\n" |
| 5301 | "Generate AS set path information\n") |
| 5302 | |
| 5303 | #ifdef HAVE_IPV6 |
| 5304 | DEFUN (ipv6_aggregate_address, |
| 5305 | ipv6_aggregate_address_cmd, |
| 5306 | "aggregate-address X:X::X:X/M", |
| 5307 | "Configure BGP aggregate entries\n" |
| 5308 | "Aggregate prefix\n") |
| 5309 | { |
| 5310 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5311 | } |
| 5312 | |
| 5313 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5314 | ipv6_aggregate_address_summary_only_cmd, |
| 5315 | "aggregate-address X:X::X:X/M summary-only", |
| 5316 | "Configure BGP aggregate entries\n" |
| 5317 | "Aggregate prefix\n" |
| 5318 | "Filter more specific routes from updates\n") |
| 5319 | { |
| 5320 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5321 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5322 | } |
| 5323 | |
| 5324 | DEFUN (no_ipv6_aggregate_address, |
| 5325 | no_ipv6_aggregate_address_cmd, |
| 5326 | "no aggregate-address X:X::X:X/M", |
| 5327 | NO_STR |
| 5328 | "Configure BGP aggregate entries\n" |
| 5329 | "Aggregate prefix\n") |
| 5330 | { |
| 5331 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5332 | } |
| 5333 | |
| 5334 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5335 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5336 | "no aggregate-address X:X::X:X/M summary-only", |
| 5337 | NO_STR |
| 5338 | "Configure BGP aggregate entries\n" |
| 5339 | "Aggregate prefix\n" |
| 5340 | "Filter more specific routes from updates\n") |
| 5341 | { |
| 5342 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5343 | } |
| 5344 | |
| 5345 | ALIAS (ipv6_aggregate_address, |
| 5346 | old_ipv6_aggregate_address_cmd, |
| 5347 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5348 | IPV6_STR |
| 5349 | BGP_STR |
| 5350 | "Configure BGP aggregate entries\n" |
| 5351 | "Aggregate prefix\n") |
| 5352 | |
| 5353 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5354 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5355 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5356 | IPV6_STR |
| 5357 | BGP_STR |
| 5358 | "Configure BGP aggregate entries\n" |
| 5359 | "Aggregate prefix\n" |
| 5360 | "Filter more specific routes from updates\n") |
| 5361 | |
| 5362 | ALIAS (no_ipv6_aggregate_address, |
| 5363 | old_no_ipv6_aggregate_address_cmd, |
| 5364 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5365 | NO_STR |
| 5366 | IPV6_STR |
| 5367 | BGP_STR |
| 5368 | "Configure BGP aggregate entries\n" |
| 5369 | "Aggregate prefix\n") |
| 5370 | |
| 5371 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5372 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5373 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5374 | NO_STR |
| 5375 | IPV6_STR |
| 5376 | BGP_STR |
| 5377 | "Configure BGP aggregate entries\n" |
| 5378 | "Aggregate prefix\n" |
| 5379 | "Filter more specific routes from updates\n") |
| 5380 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5381 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5382 | /* Redistribute route treatment. */ |
| 5383 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5384 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5385 | const struct in6_addr *nexthop6, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5386 | u_int32_t metric, u_char type) |
| 5387 | { |
| 5388 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5389 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5390 | struct bgp_info *new; |
| 5391 | struct bgp_info *bi; |
| 5392 | struct bgp_info info; |
| 5393 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5394 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5395 | struct attr *new_attr; |
| 5396 | afi_t afi; |
| 5397 | int ret; |
| 5398 | |
| 5399 | /* Make default attribute. */ |
| 5400 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5401 | if (nexthop) |
| 5402 | attr.nexthop = *nexthop; |
| 5403 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5404 | #ifdef HAVE_IPV6 |
| 5405 | if (nexthop6) |
| 5406 | { |
| 5407 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5408 | extra->mp_nexthop_global = *nexthop6; |
| 5409 | extra->mp_nexthop_len = 16; |
| 5410 | } |
| 5411 | #endif |
| 5412 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5413 | attr.med = metric; |
| 5414 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5415 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5416 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5417 | { |
| 5418 | afi = family2afi (p->family); |
| 5419 | |
| 5420 | if (bgp->redist[afi][type]) |
| 5421 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5422 | struct attr attr_new; |
| 5423 | struct attr_extra extra_new; |
| 5424 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5425 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5426 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5427 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5428 | |
| 5429 | if (bgp->redist_metric_flag[afi][type]) |
| 5430 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5431 | |
| 5432 | /* Apply route-map. */ |
| 5433 | if (bgp->rmap[afi][type].map) |
| 5434 | { |
| 5435 | info.peer = bgp->peer_self; |
| 5436 | info.attr = &attr_new; |
| 5437 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5438 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5439 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5440 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5441 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5442 | |
| 5443 | bgp->peer_self->rmap_type = 0; |
| 5444 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5445 | if (ret == RMAP_DENYMATCH) |
| 5446 | { |
| 5447 | /* Free uninterned attribute. */ |
| 5448 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5449 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5450 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5451 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5452 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5453 | bgp_redistribute_delete (p, type); |
| 5454 | return; |
| 5455 | } |
| 5456 | } |
| 5457 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5458 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5459 | afi, SAFI_UNICAST, p, NULL); |
| 5460 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5461 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5462 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5463 | for (bi = bn->info; bi; bi = bi->next) |
| 5464 | if (bi->peer == bgp->peer_self |
| 5465 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5466 | break; |
| 5467 | |
| 5468 | if (bi) |
| 5469 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5470 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5471 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5472 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5473 | bgp_attr_unintern (&new_attr); |
| 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_unlock_node (bn); |
| 5477 | return; |
| 5478 | } |
| 5479 | else |
| 5480 | { |
| 5481 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5482 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5483 | |
| 5484 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5485 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5486 | bgp_info_restore(bn, bi); |
| 5487 | else |
| 5488 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5489 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5490 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5491 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5492 | |
| 5493 | /* Process change. */ |
| 5494 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5495 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5496 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 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 | return; |
| 5500 | } |
| 5501 | } |
| 5502 | |
| 5503 | new = bgp_info_new (); |
| 5504 | new->type = type; |
| 5505 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 5506 | new->peer = bgp->peer_self; |
| 5507 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5508 | new->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5509 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5510 | |
| 5511 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5512 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5513 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5514 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5515 | } |
| 5516 | } |
| 5517 | |
| 5518 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5519 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5520 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5521 | } |
| 5522 | |
| 5523 | void |
| 5524 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5525 | { |
| 5526 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5527 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5528 | afi_t afi; |
| 5529 | struct bgp_node *rn; |
| 5530 | struct bgp_info *ri; |
| 5531 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5532 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5533 | { |
| 5534 | afi = family2afi (p->family); |
| 5535 | |
| 5536 | if (bgp->redist[afi][type]) |
| 5537 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5538 | 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] | 5539 | |
| 5540 | for (ri = rn->info; ri; ri = ri->next) |
| 5541 | if (ri->peer == bgp->peer_self |
| 5542 | && ri->type == type) |
| 5543 | break; |
| 5544 | |
| 5545 | if (ri) |
| 5546 | { |
| 5547 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5548 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5549 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5550 | } |
| 5551 | bgp_unlock_node (rn); |
| 5552 | } |
| 5553 | } |
| 5554 | } |
| 5555 | |
| 5556 | /* Withdraw specified route type's route. */ |
| 5557 | void |
| 5558 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5559 | { |
| 5560 | struct bgp_node *rn; |
| 5561 | struct bgp_info *ri; |
| 5562 | struct bgp_table *table; |
| 5563 | |
| 5564 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5565 | |
| 5566 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5567 | { |
| 5568 | for (ri = rn->info; ri; ri = ri->next) |
| 5569 | if (ri->peer == bgp->peer_self |
| 5570 | && ri->type == type) |
| 5571 | break; |
| 5572 | |
| 5573 | if (ri) |
| 5574 | { |
| 5575 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5576 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5577 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5578 | } |
| 5579 | } |
| 5580 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5581 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5582 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5583 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5584 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5585 | { |
| 5586 | int len; |
| 5587 | u_int32_t destination; |
| 5588 | char buf[BUFSIZ]; |
| 5589 | |
| 5590 | if (p->family == AF_INET) |
| 5591 | { |
| 5592 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5593 | destination = ntohl (p->u.prefix4.s_addr); |
| 5594 | |
| 5595 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5596 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5597 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5598 | || p->u.prefix4.s_addr == 0) |
| 5599 | { |
| 5600 | /* When mask is natural, mask is not displayed. */ |
| 5601 | } |
| 5602 | else |
| 5603 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5604 | } |
| 5605 | else |
| 5606 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5607 | p->prefixlen); |
| 5608 | |
| 5609 | len = 17 - len; |
| 5610 | if (len < 1) |
| 5611 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5612 | else |
| 5613 | vty_out (vty, "%*s", len, " "); |
| 5614 | } |
| 5615 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5616 | enum bgp_display_type |
| 5617 | { |
| 5618 | normal_list, |
| 5619 | }; |
| 5620 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5621 | /* Print the short form route status for a bgp_info */ |
| 5622 | static void |
| 5623 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5624 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5625 | /* Route status display. */ |
| 5626 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5627 | vty_out (vty, "R"); |
| 5628 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5629 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5630 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5631 | vty_out (vty, "s"); |
| 5632 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5633 | vty_out (vty, "*"); |
| 5634 | else |
| 5635 | vty_out (vty, " "); |
| 5636 | |
| 5637 | /* Selected */ |
| 5638 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5639 | vty_out (vty, "h"); |
| 5640 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5641 | vty_out (vty, "d"); |
| 5642 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5643 | vty_out (vty, ">"); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 5644 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
| 5645 | vty_out (vty, "="); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5646 | else |
| 5647 | vty_out (vty, " "); |
| 5648 | |
| 5649 | /* Internal route. */ |
| 5650 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5651 | vty_out (vty, "i"); |
| 5652 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5653 | vty_out (vty, " "); |
| 5654 | } |
| 5655 | |
| 5656 | /* called from terminal list command */ |
| 5657 | void |
| 5658 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5659 | struct bgp_info *binfo, int display, safi_t safi) |
| 5660 | { |
| 5661 | struct attr *attr; |
| 5662 | |
| 5663 | /* short status lead text */ |
| 5664 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5665 | |
| 5666 | /* print prefix and mask */ |
| 5667 | if (! display) |
| 5668 | route_vty_out_route (p, vty); |
| 5669 | else |
| 5670 | vty_out (vty, "%*s", 17, " "); |
| 5671 | |
| 5672 | /* Print attribute */ |
| 5673 | attr = binfo->attr; |
| 5674 | if (attr) |
| 5675 | { |
| 5676 | if (p->family == AF_INET) |
| 5677 | { |
| 5678 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5679 | vty_out (vty, "%-16s", |
| 5680 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5681 | else |
| 5682 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5683 | } |
| 5684 | #ifdef HAVE_IPV6 |
| 5685 | else if (p->family == AF_INET6) |
| 5686 | { |
| 5687 | int len; |
| 5688 | char buf[BUFSIZ]; |
| 5689 | |
| 5690 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5691 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5692 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5693 | len = 16 - len; |
| 5694 | if (len < 1) |
| 5695 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5696 | else |
| 5697 | vty_out (vty, "%*s", len, " "); |
| 5698 | } |
| 5699 | #endif /* HAVE_IPV6 */ |
| 5700 | |
| 5701 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5702 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5703 | else |
| 5704 | vty_out (vty, " "); |
| 5705 | |
| 5706 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5707 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5708 | else |
| 5709 | vty_out (vty, " "); |
| 5710 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5711 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5712 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5713 | /* Print aspath */ |
| 5714 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5715 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5716 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5717 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5718 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5719 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5720 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5721 | } |
| 5722 | |
| 5723 | /* called from terminal list command */ |
| 5724 | void |
| 5725 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5726 | struct attr *attr, safi_t safi) |
| 5727 | { |
| 5728 | /* Route status display. */ |
| 5729 | vty_out (vty, "*"); |
| 5730 | vty_out (vty, ">"); |
| 5731 | vty_out (vty, " "); |
| 5732 | |
| 5733 | /* print prefix and mask */ |
| 5734 | route_vty_out_route (p, vty); |
| 5735 | |
| 5736 | /* Print attribute */ |
| 5737 | if (attr) |
| 5738 | { |
| 5739 | if (p->family == AF_INET) |
| 5740 | { |
| 5741 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5742 | vty_out (vty, "%-16s", |
| 5743 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5744 | else |
| 5745 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5746 | } |
| 5747 | #ifdef HAVE_IPV6 |
| 5748 | else if (p->family == AF_INET6) |
| 5749 | { |
| 5750 | int len; |
| 5751 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5752 | |
| 5753 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5754 | |
| 5755 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5756 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5757 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5758 | len = 16 - len; |
| 5759 | if (len < 1) |
| 5760 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5761 | else |
| 5762 | vty_out (vty, "%*s", len, " "); |
| 5763 | } |
| 5764 | #endif /* HAVE_IPV6 */ |
| 5765 | |
| 5766 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5767 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5768 | else |
| 5769 | vty_out (vty, " "); |
| 5770 | |
| 5771 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5772 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5773 | else |
| 5774 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5775 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5776 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5777 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5778 | /* Print aspath */ |
| 5779 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5780 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5781 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5782 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5783 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5784 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5785 | |
| 5786 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5787 | } |
| 5788 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5789 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5790 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 5791 | struct bgp_info *binfo, int display, safi_t safi) |
| 5792 | { |
| 5793 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5794 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5795 | |
| 5796 | if (!binfo->extra) |
| 5797 | return; |
| 5798 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5799 | /* short status lead text */ |
| 5800 | route_vty_short_status_out (vty, binfo); |
| 5801 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5802 | /* print prefix and mask */ |
| 5803 | if (! display) |
| 5804 | route_vty_out_route (p, vty); |
| 5805 | else |
| 5806 | vty_out (vty, "%*s", 17, " "); |
| 5807 | |
| 5808 | /* Print attribute */ |
| 5809 | attr = binfo->attr; |
| 5810 | if (attr) |
| 5811 | { |
| 5812 | if (p->family == AF_INET) |
| 5813 | { |
| 5814 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5815 | vty_out (vty, "%-16s", |
| 5816 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5817 | else |
| 5818 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5819 | } |
| 5820 | #ifdef HAVE_IPV6 |
| 5821 | else if (p->family == AF_INET6) |
| 5822 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5823 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5824 | char buf[BUFSIZ]; |
| 5825 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5826 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5827 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5828 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5829 | buf, BUFSIZ)); |
| 5830 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5831 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5832 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5833 | buf, BUFSIZ), |
| 5834 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 5835 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5836 | |
| 5837 | } |
| 5838 | #endif /* HAVE_IPV6 */ |
| 5839 | } |
| 5840 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5841 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5842 | |
| 5843 | vty_out (vty, "notag/%d", label); |
| 5844 | |
| 5845 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5846 | } |
| 5847 | |
| 5848 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5849 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5850 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5851 | struct bgp_info *binfo, int display, safi_t safi) |
| 5852 | { |
| 5853 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5854 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5855 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5856 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5857 | /* short status lead text */ |
| 5858 | route_vty_short_status_out (vty, binfo); |
| 5859 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5860 | /* print prefix and mask */ |
| 5861 | if (! display) |
| 5862 | route_vty_out_route (p, vty); |
| 5863 | else |
| 5864 | vty_out (vty, "%*s", 17, " "); |
| 5865 | |
| 5866 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5867 | len = 17 - len; |
| 5868 | if (len < 1) |
| 5869 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5870 | else |
| 5871 | vty_out (vty, "%*s", len, " "); |
| 5872 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5873 | 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] | 5874 | |
| 5875 | /* Print attribute */ |
| 5876 | attr = binfo->attr; |
| 5877 | if (attr) |
| 5878 | { |
| 5879 | /* Print aspath */ |
| 5880 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5881 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5882 | |
| 5883 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5884 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5885 | } |
| 5886 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5887 | } |
| 5888 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5889 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5890 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5891 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5892 | struct bgp_info *binfo, int display, safi_t safi) |
| 5893 | { |
| 5894 | struct attr *attr; |
| 5895 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5896 | char timebuf[BGP_UPTIME_LEN]; |
| 5897 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5898 | |
| 5899 | if (!binfo->extra) |
| 5900 | return; |
| 5901 | |
| 5902 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5903 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5904 | /* short status lead text */ |
| 5905 | route_vty_short_status_out (vty, binfo); |
| 5906 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5907 | /* print prefix and mask */ |
| 5908 | if (! display) |
| 5909 | route_vty_out_route (p, vty); |
| 5910 | else |
| 5911 | vty_out (vty, "%*s", 17, " "); |
| 5912 | |
| 5913 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5914 | len = 16 - len; |
| 5915 | if (len < 1) |
| 5916 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5917 | else |
| 5918 | vty_out (vty, "%*s", len, " "); |
| 5919 | |
| 5920 | len = vty_out (vty, "%d", bdi->flap); |
| 5921 | len = 5 - len; |
| 5922 | if (len < 1) |
| 5923 | vty_out (vty, " "); |
| 5924 | else |
| 5925 | vty_out (vty, "%*s ", len, " "); |
| 5926 | |
| 5927 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5928 | timebuf, BGP_UPTIME_LEN)); |
| 5929 | |
| 5930 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5931 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5932 | 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] | 5933 | else |
| 5934 | vty_out (vty, "%*s ", 8, " "); |
| 5935 | |
| 5936 | /* Print attribute */ |
| 5937 | attr = binfo->attr; |
| 5938 | if (attr) |
| 5939 | { |
| 5940 | /* Print aspath */ |
| 5941 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5942 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5943 | |
| 5944 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5945 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5946 | } |
| 5947 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5948 | } |
| 5949 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5950 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5951 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5952 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5953 | { |
| 5954 | char buf[INET6_ADDRSTRLEN]; |
| 5955 | char buf1[BUFSIZ]; |
| 5956 | struct attr *attr; |
| 5957 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 5958 | #ifdef HAVE_CLOCK_MONOTONIC |
| 5959 | time_t tbuf; |
| 5960 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5961 | |
| 5962 | attr = binfo->attr; |
| 5963 | |
| 5964 | if (attr) |
| 5965 | { |
| 5966 | /* Line1 display AS-path, Aggregator */ |
| 5967 | if (attr->aspath) |
| 5968 | { |
| 5969 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 5970 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5971 | vty_out (vty, "Local"); |
| 5972 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5973 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5974 | } |
| 5975 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5976 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5977 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5978 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 5979 | vty_out (vty, ", (stale)"); |
| 5980 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 5981 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5982 | attr->extra->aggregator_as, |
| 5983 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5984 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 5985 | vty_out (vty, ", (Received from a RR-client)"); |
| 5986 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 5987 | vty_out (vty, ", (Received from a RS-client)"); |
| 5988 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5989 | vty_out (vty, ", (history entry)"); |
| 5990 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5991 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5992 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5993 | |
| 5994 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 5995 | if (p->family == AF_INET) |
| 5996 | { |
| 5997 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5998 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5999 | inet_ntoa (attr->nexthop)); |
| 6000 | } |
| 6001 | #ifdef HAVE_IPV6 |
| 6002 | else |
| 6003 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6004 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6005 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6006 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6007 | buf, INET6_ADDRSTRLEN)); |
| 6008 | } |
| 6009 | #endif /* HAVE_IPV6 */ |
| 6010 | |
| 6011 | if (binfo->peer == bgp->peer_self) |
| 6012 | { |
| 6013 | vty_out (vty, " from %s ", |
| 6014 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 6015 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 6016 | } |
| 6017 | else |
| 6018 | { |
| 6019 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6020 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6021 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 6022 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 6023 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6024 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6025 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6026 | else |
| 6027 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 6028 | } |
| 6029 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6030 | |
| 6031 | #ifdef HAVE_IPV6 |
| 6032 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6033 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6034 | { |
| 6035 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6036 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6037 | buf, INET6_ADDRSTRLEN), |
| 6038 | VTY_NEWLINE); |
| 6039 | } |
| 6040 | #endif /* HAVE_IPV6 */ |
| 6041 | |
| 6042 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 6043 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 6044 | |
| 6045 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6046 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6047 | |
| 6048 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6049 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6050 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6051 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6052 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6053 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6054 | vty_out (vty, ", weight %u", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6055 | |
| 6056 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6057 | vty_out (vty, ", valid"); |
| 6058 | |
| 6059 | if (binfo->peer != bgp->peer_self) |
| 6060 | { |
| 6061 | if (binfo->peer->as == binfo->peer->local_as) |
| 6062 | vty_out (vty, ", internal"); |
| 6063 | else |
| 6064 | vty_out (vty, ", %s", |
| 6065 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6066 | } |
| 6067 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6068 | vty_out (vty, ", aggregated, local"); |
| 6069 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6070 | vty_out (vty, ", sourced"); |
| 6071 | else |
| 6072 | vty_out (vty, ", sourced, local"); |
| 6073 | |
| 6074 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6075 | vty_out (vty, ", atomic-aggregate"); |
| 6076 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6077 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6078 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6079 | bgp_info_mpath_count (binfo))) |
| 6080 | vty_out (vty, ", multipath"); |
| 6081 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6082 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6083 | vty_out (vty, ", best"); |
| 6084 | |
| 6085 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6086 | |
| 6087 | /* Line 4 display Community */ |
| 6088 | if (attr->community) |
| 6089 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6090 | VTY_NEWLINE); |
| 6091 | |
| 6092 | /* Line 5 display Extended-community */ |
| 6093 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6094 | vty_out (vty, " Extended Community: %s%s", |
| 6095 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6096 | |
| 6097 | /* Line 6 display Originator, Cluster-id */ |
| 6098 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6099 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6100 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6101 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6102 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6103 | vty_out (vty, " Originator: %s", |
| 6104 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6105 | |
| 6106 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6107 | { |
| 6108 | int i; |
| 6109 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6110 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6111 | vty_out (vty, "%s ", |
| 6112 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6113 | } |
| 6114 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6115 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6116 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6117 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6118 | bgp_damp_info_vty (vty, binfo); |
| 6119 | |
| 6120 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6121 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6122 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6123 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6124 | #else |
| 6125 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6126 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6127 | } |
| 6128 | vty_out (vty, "%s", VTY_NEWLINE); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 6129 | } |
| 6130 | |
| 6131 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\ |
| 6132 | "h history, * valid, > best, = multipath,%s"\ |
| 6133 | " i internal, r RIB-failure, S Stale, R Removed%s" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6134 | #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] | 6135 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6136 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6137 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6138 | |
| 6139 | enum bgp_show_type |
| 6140 | { |
| 6141 | bgp_show_type_normal, |
| 6142 | bgp_show_type_regexp, |
| 6143 | bgp_show_type_prefix_list, |
| 6144 | bgp_show_type_filter_list, |
| 6145 | bgp_show_type_route_map, |
| 6146 | bgp_show_type_neighbor, |
| 6147 | bgp_show_type_cidr_only, |
| 6148 | bgp_show_type_prefix_longer, |
| 6149 | bgp_show_type_community_all, |
| 6150 | bgp_show_type_community, |
| 6151 | bgp_show_type_community_exact, |
| 6152 | bgp_show_type_community_list, |
| 6153 | bgp_show_type_community_list_exact, |
| 6154 | bgp_show_type_flap_statistics, |
| 6155 | bgp_show_type_flap_address, |
| 6156 | bgp_show_type_flap_prefix, |
| 6157 | bgp_show_type_flap_cidr_only, |
| 6158 | bgp_show_type_flap_regexp, |
| 6159 | bgp_show_type_flap_filter_list, |
| 6160 | bgp_show_type_flap_prefix_list, |
| 6161 | bgp_show_type_flap_prefix_longer, |
| 6162 | bgp_show_type_flap_route_map, |
| 6163 | bgp_show_type_flap_neighbor, |
| 6164 | bgp_show_type_dampend_paths, |
| 6165 | bgp_show_type_damp_neighbor |
| 6166 | }; |
| 6167 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6168 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6169 | 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] | 6170 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6171 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6172 | struct bgp_info *ri; |
| 6173 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6174 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6175 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6176 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6177 | |
| 6178 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6179 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6180 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6181 | /* Start processing of routes. */ |
| 6182 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6183 | if (rn->info != NULL) |
| 6184 | { |
| 6185 | display = 0; |
| 6186 | |
| 6187 | for (ri = rn->info; ri; ri = ri->next) |
| 6188 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6189 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6190 | || type == bgp_show_type_flap_address |
| 6191 | || type == bgp_show_type_flap_prefix |
| 6192 | || type == bgp_show_type_flap_cidr_only |
| 6193 | || type == bgp_show_type_flap_regexp |
| 6194 | || type == bgp_show_type_flap_filter_list |
| 6195 | || type == bgp_show_type_flap_prefix_list |
| 6196 | || type == bgp_show_type_flap_prefix_longer |
| 6197 | || type == bgp_show_type_flap_route_map |
| 6198 | || type == bgp_show_type_flap_neighbor |
| 6199 | || type == bgp_show_type_dampend_paths |
| 6200 | || type == bgp_show_type_damp_neighbor) |
| 6201 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6202 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6203 | continue; |
| 6204 | } |
| 6205 | if (type == bgp_show_type_regexp |
| 6206 | || type == bgp_show_type_flap_regexp) |
| 6207 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6208 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6209 | |
| 6210 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6211 | continue; |
| 6212 | } |
| 6213 | if (type == bgp_show_type_prefix_list |
| 6214 | || type == bgp_show_type_flap_prefix_list) |
| 6215 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6216 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6217 | |
| 6218 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6219 | continue; |
| 6220 | } |
| 6221 | if (type == bgp_show_type_filter_list |
| 6222 | || type == bgp_show_type_flap_filter_list) |
| 6223 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6224 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6225 | |
| 6226 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6227 | continue; |
| 6228 | } |
| 6229 | if (type == bgp_show_type_route_map |
| 6230 | || type == bgp_show_type_flap_route_map) |
| 6231 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6232 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6233 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6234 | struct attr dummy_attr; |
| 6235 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6236 | int ret; |
| 6237 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6238 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6239 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6240 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6241 | binfo.peer = ri->peer; |
| 6242 | binfo.attr = &dummy_attr; |
| 6243 | |
| 6244 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6245 | if (ret == RMAP_DENYMATCH) |
| 6246 | continue; |
| 6247 | } |
| 6248 | if (type == bgp_show_type_neighbor |
| 6249 | || type == bgp_show_type_flap_neighbor |
| 6250 | || type == bgp_show_type_damp_neighbor) |
| 6251 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6252 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6253 | |
| 6254 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6255 | continue; |
| 6256 | } |
| 6257 | if (type == bgp_show_type_cidr_only |
| 6258 | || type == bgp_show_type_flap_cidr_only) |
| 6259 | { |
| 6260 | u_int32_t destination; |
| 6261 | |
| 6262 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6263 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6264 | continue; |
| 6265 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6266 | continue; |
| 6267 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6268 | continue; |
| 6269 | } |
| 6270 | if (type == bgp_show_type_prefix_longer |
| 6271 | || type == bgp_show_type_flap_prefix_longer) |
| 6272 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6273 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6274 | |
| 6275 | if (! prefix_match (p, &rn->p)) |
| 6276 | continue; |
| 6277 | } |
| 6278 | if (type == bgp_show_type_community_all) |
| 6279 | { |
| 6280 | if (! ri->attr->community) |
| 6281 | continue; |
| 6282 | } |
| 6283 | if (type == bgp_show_type_community) |
| 6284 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6285 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6286 | |
| 6287 | if (! ri->attr->community || |
| 6288 | ! community_match (ri->attr->community, com)) |
| 6289 | continue; |
| 6290 | } |
| 6291 | if (type == bgp_show_type_community_exact) |
| 6292 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6293 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6294 | |
| 6295 | if (! ri->attr->community || |
| 6296 | ! community_cmp (ri->attr->community, com)) |
| 6297 | continue; |
| 6298 | } |
| 6299 | if (type == bgp_show_type_community_list) |
| 6300 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6301 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6302 | |
| 6303 | if (! community_list_match (ri->attr->community, list)) |
| 6304 | continue; |
| 6305 | } |
| 6306 | if (type == bgp_show_type_community_list_exact) |
| 6307 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6308 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6309 | |
| 6310 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6311 | continue; |
| 6312 | } |
| 6313 | if (type == bgp_show_type_flap_address |
| 6314 | || type == bgp_show_type_flap_prefix) |
| 6315 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6316 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6317 | |
| 6318 | if (! prefix_match (&rn->p, p)) |
| 6319 | continue; |
| 6320 | |
| 6321 | if (type == bgp_show_type_flap_prefix) |
| 6322 | if (p->prefixlen != rn->p.prefixlen) |
| 6323 | continue; |
| 6324 | } |
| 6325 | if (type == bgp_show_type_dampend_paths |
| 6326 | || type == bgp_show_type_damp_neighbor) |
| 6327 | { |
| 6328 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6329 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6330 | continue; |
| 6331 | } |
| 6332 | |
| 6333 | if (header) |
| 6334 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6335 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6336 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6337 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6338 | if (type == bgp_show_type_dampend_paths |
| 6339 | || type == bgp_show_type_damp_neighbor) |
| 6340 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6341 | else if (type == bgp_show_type_flap_statistics |
| 6342 | || type == bgp_show_type_flap_address |
| 6343 | || type == bgp_show_type_flap_prefix |
| 6344 | || type == bgp_show_type_flap_cidr_only |
| 6345 | || type == bgp_show_type_flap_regexp |
| 6346 | || type == bgp_show_type_flap_filter_list |
| 6347 | || type == bgp_show_type_flap_prefix_list |
| 6348 | || type == bgp_show_type_flap_prefix_longer |
| 6349 | || type == bgp_show_type_flap_route_map |
| 6350 | || type == bgp_show_type_flap_neighbor) |
| 6351 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6352 | else |
| 6353 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6354 | header = 0; |
| 6355 | } |
| 6356 | |
| 6357 | if (type == bgp_show_type_dampend_paths |
| 6358 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6359 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6360 | else if (type == bgp_show_type_flap_statistics |
| 6361 | || type == bgp_show_type_flap_address |
| 6362 | || type == bgp_show_type_flap_prefix |
| 6363 | || type == bgp_show_type_flap_cidr_only |
| 6364 | || type == bgp_show_type_flap_regexp |
| 6365 | || type == bgp_show_type_flap_filter_list |
| 6366 | || type == bgp_show_type_flap_prefix_list |
| 6367 | || type == bgp_show_type_flap_prefix_longer |
| 6368 | || type == bgp_show_type_flap_route_map |
| 6369 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6370 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6371 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6372 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6373 | display++; |
| 6374 | } |
| 6375 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6376 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6377 | } |
| 6378 | |
| 6379 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6380 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6381 | { |
| 6382 | if (type == bgp_show_type_normal) |
| 6383 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 6384 | } |
| 6385 | else |
| 6386 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6387 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6388 | |
| 6389 | return CMD_SUCCESS; |
| 6390 | } |
| 6391 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6392 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6393 | 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] | 6394 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6395 | { |
| 6396 | struct bgp_table *table; |
| 6397 | |
| 6398 | if (bgp == NULL) { |
| 6399 | bgp = bgp_get_default (); |
| 6400 | } |
| 6401 | |
| 6402 | if (bgp == NULL) |
| 6403 | { |
| 6404 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6405 | return CMD_WARNING; |
| 6406 | } |
| 6407 | |
| 6408 | |
| 6409 | table = bgp->rib[afi][safi]; |
| 6410 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6411 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6412 | } |
| 6413 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6414 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6415 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6416 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6417 | struct bgp_node *rn, |
| 6418 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6419 | { |
| 6420 | struct bgp_info *ri; |
| 6421 | struct prefix *p; |
| 6422 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6423 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6424 | char buf1[INET6_ADDRSTRLEN]; |
| 6425 | char buf2[INET6_ADDRSTRLEN]; |
| 6426 | int count = 0; |
| 6427 | int best = 0; |
| 6428 | int suppress = 0; |
| 6429 | int no_export = 0; |
| 6430 | int no_advertise = 0; |
| 6431 | int local_as = 0; |
| 6432 | int first = 0; |
| 6433 | |
| 6434 | p = &rn->p; |
| 6435 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 6436 | (safi == SAFI_MPLS_VPN ? |
| 6437 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6438 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 6439 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6440 | p->prefixlen, VTY_NEWLINE); |
| 6441 | |
| 6442 | for (ri = rn->info; ri; ri = ri->next) |
| 6443 | { |
| 6444 | count++; |
| 6445 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6446 | { |
| 6447 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6448 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6449 | suppress = 1; |
| 6450 | if (ri->attr->community != NULL) |
| 6451 | { |
| 6452 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6453 | no_advertise = 1; |
| 6454 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6455 | no_export = 1; |
| 6456 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6457 | local_as = 1; |
| 6458 | } |
| 6459 | } |
| 6460 | } |
| 6461 | |
| 6462 | vty_out (vty, "Paths: (%d available", count); |
| 6463 | if (best) |
| 6464 | { |
| 6465 | vty_out (vty, ", best #%d", best); |
| 6466 | if (safi == SAFI_UNICAST) |
| 6467 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6468 | } |
| 6469 | else |
| 6470 | vty_out (vty, ", no best path"); |
| 6471 | if (no_advertise) |
| 6472 | vty_out (vty, ", not advertised to any peer"); |
| 6473 | else if (no_export) |
| 6474 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6475 | else if (local_as) |
| 6476 | vty_out (vty, ", not advertised outside local AS"); |
| 6477 | if (suppress) |
| 6478 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6479 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6480 | |
| 6481 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6482 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6483 | { |
| 6484 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6485 | { |
| 6486 | if (! first) |
| 6487 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6488 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6489 | first = 1; |
| 6490 | } |
| 6491 | } |
| 6492 | if (! first) |
| 6493 | vty_out (vty, " Not advertised to any peer"); |
| 6494 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6495 | } |
| 6496 | |
| 6497 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6498 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6499 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6500 | struct bgp_table *rib, const char *ip_str, |
| 6501 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6502 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6503 | { |
| 6504 | int ret; |
| 6505 | int header; |
| 6506 | int display = 0; |
| 6507 | struct prefix match; |
| 6508 | struct bgp_node *rn; |
| 6509 | struct bgp_node *rm; |
| 6510 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6511 | struct bgp_table *table; |
| 6512 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6513 | /* Check IP address argument. */ |
| 6514 | ret = str2prefix (ip_str, &match); |
| 6515 | if (! ret) |
| 6516 | { |
| 6517 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6518 | return CMD_WARNING; |
| 6519 | } |
| 6520 | |
| 6521 | match.family = afi2family (afi); |
| 6522 | |
| 6523 | if (safi == SAFI_MPLS_VPN) |
| 6524 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6525 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6526 | { |
| 6527 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6528 | continue; |
| 6529 | |
| 6530 | if ((table = rn->info) != NULL) |
| 6531 | { |
| 6532 | header = 1; |
| 6533 | |
| 6534 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6535 | { |
| 6536 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6537 | { |
| 6538 | bgp_unlock_node (rm); |
| 6539 | continue; |
| 6540 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6541 | |
| 6542 | for (ri = rm->info; ri; ri = ri->next) |
| 6543 | { |
| 6544 | if (header) |
| 6545 | { |
| 6546 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 6547 | AFI_IP, SAFI_MPLS_VPN); |
| 6548 | |
| 6549 | header = 0; |
| 6550 | } |
| 6551 | display++; |
| 6552 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 6553 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6554 | |
| 6555 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6556 | } |
| 6557 | } |
| 6558 | } |
| 6559 | } |
| 6560 | else |
| 6561 | { |
| 6562 | header = 1; |
| 6563 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6564 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6565 | { |
| 6566 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6567 | { |
| 6568 | for (ri = rn->info; ri; ri = ri->next) |
| 6569 | { |
| 6570 | if (header) |
| 6571 | { |
| 6572 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6573 | header = 0; |
| 6574 | } |
| 6575 | display++; |
| 6576 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6577 | } |
| 6578 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6579 | |
| 6580 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6581 | } |
| 6582 | } |
| 6583 | |
| 6584 | if (! display) |
| 6585 | { |
| 6586 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6587 | return CMD_WARNING; |
| 6588 | } |
| 6589 | |
| 6590 | return CMD_SUCCESS; |
| 6591 | } |
| 6592 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6593 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6594 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6595 | 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] | 6596 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6597 | int prefix_check) |
| 6598 | { |
| 6599 | struct bgp *bgp; |
| 6600 | |
| 6601 | /* BGP structure lookup. */ |
| 6602 | if (view_name) |
| 6603 | { |
| 6604 | bgp = bgp_lookup_by_name (view_name); |
| 6605 | if (bgp == NULL) |
| 6606 | { |
| 6607 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6608 | return CMD_WARNING; |
| 6609 | } |
| 6610 | } |
| 6611 | else |
| 6612 | { |
| 6613 | bgp = bgp_get_default (); |
| 6614 | if (bgp == NULL) |
| 6615 | { |
| 6616 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6617 | return CMD_WARNING; |
| 6618 | } |
| 6619 | } |
| 6620 | |
| 6621 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6622 | afi, safi, prd, prefix_check); |
| 6623 | } |
| 6624 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6625 | /* BGP route print out function. */ |
| 6626 | DEFUN (show_ip_bgp, |
| 6627 | show_ip_bgp_cmd, |
| 6628 | "show ip bgp", |
| 6629 | SHOW_STR |
| 6630 | IP_STR |
| 6631 | BGP_STR) |
| 6632 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6633 | 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] | 6634 | } |
| 6635 | |
| 6636 | DEFUN (show_ip_bgp_ipv4, |
| 6637 | show_ip_bgp_ipv4_cmd, |
| 6638 | "show ip bgp ipv4 (unicast|multicast)", |
| 6639 | SHOW_STR |
| 6640 | IP_STR |
| 6641 | BGP_STR |
| 6642 | "Address family\n" |
| 6643 | "Address Family modifier\n" |
| 6644 | "Address Family modifier\n") |
| 6645 | { |
| 6646 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6647 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6648 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6649 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6650 | 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] | 6651 | } |
| 6652 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6653 | ALIAS (show_ip_bgp_ipv4, |
| 6654 | show_bgp_ipv4_safi_cmd, |
| 6655 | "show bgp ipv4 (unicast|multicast)", |
| 6656 | SHOW_STR |
| 6657 | BGP_STR |
| 6658 | "Address family\n" |
| 6659 | "Address Family modifier\n" |
| 6660 | "Address Family modifier\n") |
| 6661 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6662 | DEFUN (show_ip_bgp_route, |
| 6663 | show_ip_bgp_route_cmd, |
| 6664 | "show ip bgp A.B.C.D", |
| 6665 | SHOW_STR |
| 6666 | IP_STR |
| 6667 | BGP_STR |
| 6668 | "Network in the BGP routing table to display\n") |
| 6669 | { |
| 6670 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6671 | } |
| 6672 | |
| 6673 | DEFUN (show_ip_bgp_ipv4_route, |
| 6674 | show_ip_bgp_ipv4_route_cmd, |
| 6675 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6676 | SHOW_STR |
| 6677 | IP_STR |
| 6678 | BGP_STR |
| 6679 | "Address family\n" |
| 6680 | "Address Family modifier\n" |
| 6681 | "Address Family modifier\n" |
| 6682 | "Network in the BGP routing table to display\n") |
| 6683 | { |
| 6684 | if (strncmp (argv[0], "m", 1) == 0) |
| 6685 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6686 | |
| 6687 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6688 | } |
| 6689 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6690 | ALIAS (show_ip_bgp_ipv4_route, |
| 6691 | show_bgp_ipv4_safi_route_cmd, |
| 6692 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6693 | SHOW_STR |
| 6694 | BGP_STR |
| 6695 | "Address family\n" |
| 6696 | "Address Family modifier\n" |
| 6697 | "Address Family modifier\n" |
| 6698 | "Network in the BGP routing table to display\n") |
| 6699 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6700 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6701 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6702 | "show ip bgp vpnv4 all A.B.C.D", |
| 6703 | SHOW_STR |
| 6704 | IP_STR |
| 6705 | BGP_STR |
| 6706 | "Display VPNv4 NLRI specific information\n" |
| 6707 | "Display information about all VPNv4 NLRIs\n" |
| 6708 | "Network in the BGP routing table to display\n") |
| 6709 | { |
| 6710 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6711 | } |
| 6712 | |
| 6713 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6714 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6715 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6716 | SHOW_STR |
| 6717 | IP_STR |
| 6718 | BGP_STR |
| 6719 | "Display VPNv4 NLRI specific information\n" |
| 6720 | "Display information for a route distinguisher\n" |
| 6721 | "VPN Route Distinguisher\n" |
| 6722 | "Network in the BGP routing table to display\n") |
| 6723 | { |
| 6724 | int ret; |
| 6725 | struct prefix_rd prd; |
| 6726 | |
| 6727 | ret = str2prefix_rd (argv[0], &prd); |
| 6728 | if (! ret) |
| 6729 | { |
| 6730 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6731 | return CMD_WARNING; |
| 6732 | } |
| 6733 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6734 | } |
| 6735 | |
| 6736 | DEFUN (show_ip_bgp_prefix, |
| 6737 | show_ip_bgp_prefix_cmd, |
| 6738 | "show ip bgp A.B.C.D/M", |
| 6739 | SHOW_STR |
| 6740 | IP_STR |
| 6741 | BGP_STR |
| 6742 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6743 | { |
| 6744 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6745 | } |
| 6746 | |
| 6747 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6748 | show_ip_bgp_ipv4_prefix_cmd, |
| 6749 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6750 | SHOW_STR |
| 6751 | IP_STR |
| 6752 | BGP_STR |
| 6753 | "Address family\n" |
| 6754 | "Address Family modifier\n" |
| 6755 | "Address Family modifier\n" |
| 6756 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6757 | { |
| 6758 | if (strncmp (argv[0], "m", 1) == 0) |
| 6759 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6760 | |
| 6761 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6762 | } |
| 6763 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6764 | ALIAS (show_ip_bgp_ipv4_prefix, |
| 6765 | show_bgp_ipv4_safi_prefix_cmd, |
| 6766 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6767 | SHOW_STR |
| 6768 | BGP_STR |
| 6769 | "Address family\n" |
| 6770 | "Address Family modifier\n" |
| 6771 | "Address Family modifier\n" |
| 6772 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6773 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6774 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 6775 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 6776 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 6777 | SHOW_STR |
| 6778 | IP_STR |
| 6779 | BGP_STR |
| 6780 | "Display VPNv4 NLRI specific information\n" |
| 6781 | "Display information about all VPNv4 NLRIs\n" |
| 6782 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6783 | { |
| 6784 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 6785 | } |
| 6786 | |
| 6787 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 6788 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 6789 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 6790 | SHOW_STR |
| 6791 | IP_STR |
| 6792 | BGP_STR |
| 6793 | "Display VPNv4 NLRI specific information\n" |
| 6794 | "Display information for a route distinguisher\n" |
| 6795 | "VPN Route Distinguisher\n" |
| 6796 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6797 | { |
| 6798 | int ret; |
| 6799 | struct prefix_rd prd; |
| 6800 | |
| 6801 | ret = str2prefix_rd (argv[0], &prd); |
| 6802 | if (! ret) |
| 6803 | { |
| 6804 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6805 | return CMD_WARNING; |
| 6806 | } |
| 6807 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 6808 | } |
| 6809 | |
| 6810 | DEFUN (show_ip_bgp_view, |
| 6811 | show_ip_bgp_view_cmd, |
| 6812 | "show ip bgp view WORD", |
| 6813 | SHOW_STR |
| 6814 | IP_STR |
| 6815 | BGP_STR |
| 6816 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6817 | "View name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6818 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6819 | struct bgp *bgp; |
| 6820 | |
| 6821 | /* BGP structure lookup. */ |
| 6822 | bgp = bgp_lookup_by_name (argv[0]); |
| 6823 | if (bgp == NULL) |
| 6824 | { |
| 6825 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6826 | return CMD_WARNING; |
| 6827 | } |
| 6828 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6829 | 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] | 6830 | } |
| 6831 | |
| 6832 | DEFUN (show_ip_bgp_view_route, |
| 6833 | show_ip_bgp_view_route_cmd, |
| 6834 | "show ip bgp view WORD A.B.C.D", |
| 6835 | SHOW_STR |
| 6836 | IP_STR |
| 6837 | BGP_STR |
| 6838 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6839 | "View name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6840 | "Network in the BGP routing table to display\n") |
| 6841 | { |
| 6842 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6843 | } |
| 6844 | |
| 6845 | DEFUN (show_ip_bgp_view_prefix, |
| 6846 | show_ip_bgp_view_prefix_cmd, |
| 6847 | "show ip bgp view WORD A.B.C.D/M", |
| 6848 | SHOW_STR |
| 6849 | IP_STR |
| 6850 | BGP_STR |
| 6851 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6852 | "View name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6853 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6854 | { |
| 6855 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6856 | } |
| 6857 | |
| 6858 | #ifdef HAVE_IPV6 |
| 6859 | DEFUN (show_bgp, |
| 6860 | show_bgp_cmd, |
| 6861 | "show bgp", |
| 6862 | SHOW_STR |
| 6863 | BGP_STR) |
| 6864 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6865 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6866 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6867 | } |
| 6868 | |
| 6869 | ALIAS (show_bgp, |
| 6870 | show_bgp_ipv6_cmd, |
| 6871 | "show bgp ipv6", |
| 6872 | SHOW_STR |
| 6873 | BGP_STR |
| 6874 | "Address family\n") |
| 6875 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6876 | DEFUN (show_bgp_ipv6_safi, |
| 6877 | show_bgp_ipv6_safi_cmd, |
| 6878 | "show bgp ipv6 (unicast|multicast)", |
| 6879 | SHOW_STR |
| 6880 | BGP_STR |
| 6881 | "Address family\n" |
| 6882 | "Address Family modifier\n" |
| 6883 | "Address Family modifier\n") |
| 6884 | { |
| 6885 | if (strncmp (argv[0], "m", 1) == 0) |
| 6886 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6887 | NULL); |
| 6888 | |
| 6889 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6890 | } |
| 6891 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6892 | /* old command */ |
| 6893 | DEFUN (show_ipv6_bgp, |
| 6894 | show_ipv6_bgp_cmd, |
| 6895 | "show ipv6 bgp", |
| 6896 | SHOW_STR |
| 6897 | IP_STR |
| 6898 | BGP_STR) |
| 6899 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6900 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6901 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6902 | } |
| 6903 | |
| 6904 | DEFUN (show_bgp_route, |
| 6905 | show_bgp_route_cmd, |
| 6906 | "show bgp X:X::X:X", |
| 6907 | SHOW_STR |
| 6908 | BGP_STR |
| 6909 | "Network in the BGP routing table to display\n") |
| 6910 | { |
| 6911 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6912 | } |
| 6913 | |
| 6914 | ALIAS (show_bgp_route, |
| 6915 | show_bgp_ipv6_route_cmd, |
| 6916 | "show bgp ipv6 X:X::X:X", |
| 6917 | SHOW_STR |
| 6918 | BGP_STR |
| 6919 | "Address family\n" |
| 6920 | "Network in the BGP routing table to display\n") |
| 6921 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6922 | DEFUN (show_bgp_ipv6_safi_route, |
| 6923 | show_bgp_ipv6_safi_route_cmd, |
| 6924 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
| 6925 | SHOW_STR |
| 6926 | BGP_STR |
| 6927 | "Address family\n" |
| 6928 | "Address Family modifier\n" |
| 6929 | "Address Family modifier\n" |
| 6930 | "Network in the BGP routing table to display\n") |
| 6931 | { |
| 6932 | if (strncmp (argv[0], "m", 1) == 0) |
| 6933 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6934 | |
| 6935 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6936 | } |
| 6937 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6938 | /* old command */ |
| 6939 | DEFUN (show_ipv6_bgp_route, |
| 6940 | show_ipv6_bgp_route_cmd, |
| 6941 | "show ipv6 bgp X:X::X:X", |
| 6942 | SHOW_STR |
| 6943 | IP_STR |
| 6944 | BGP_STR |
| 6945 | "Network in the BGP routing table to display\n") |
| 6946 | { |
| 6947 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6948 | } |
| 6949 | |
| 6950 | DEFUN (show_bgp_prefix, |
| 6951 | show_bgp_prefix_cmd, |
| 6952 | "show bgp X:X::X:X/M", |
| 6953 | SHOW_STR |
| 6954 | BGP_STR |
| 6955 | "IPv6 prefix <network>/<length>\n") |
| 6956 | { |
| 6957 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6958 | } |
| 6959 | |
| 6960 | ALIAS (show_bgp_prefix, |
| 6961 | show_bgp_ipv6_prefix_cmd, |
| 6962 | "show bgp ipv6 X:X::X:X/M", |
| 6963 | SHOW_STR |
| 6964 | BGP_STR |
| 6965 | "Address family\n" |
| 6966 | "IPv6 prefix <network>/<length>\n") |
| 6967 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6968 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 6969 | show_bgp_ipv6_safi_prefix_cmd, |
| 6970 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 6971 | SHOW_STR |
| 6972 | BGP_STR |
| 6973 | "Address family\n" |
| 6974 | "Address Family modifier\n" |
| 6975 | "Address Family modifier\n" |
| 6976 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6977 | { |
| 6978 | if (strncmp (argv[0], "m", 1) == 0) |
| 6979 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 6980 | |
| 6981 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6982 | } |
| 6983 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6984 | /* old command */ |
| 6985 | DEFUN (show_ipv6_bgp_prefix, |
| 6986 | show_ipv6_bgp_prefix_cmd, |
| 6987 | "show ipv6 bgp X:X::X:X/M", |
| 6988 | SHOW_STR |
| 6989 | IP_STR |
| 6990 | BGP_STR |
| 6991 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6992 | { |
| 6993 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6994 | } |
| 6995 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6996 | DEFUN (show_bgp_view, |
| 6997 | show_bgp_view_cmd, |
| 6998 | "show bgp view WORD", |
| 6999 | SHOW_STR |
| 7000 | BGP_STR |
| 7001 | "BGP view\n" |
| 7002 | "View name\n") |
| 7003 | { |
| 7004 | struct bgp *bgp; |
| 7005 | |
| 7006 | /* BGP structure lookup. */ |
| 7007 | bgp = bgp_lookup_by_name (argv[0]); |
| 7008 | if (bgp == NULL) |
| 7009 | { |
| 7010 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7011 | return CMD_WARNING; |
| 7012 | } |
| 7013 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7014 | 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] | 7015 | } |
| 7016 | |
| 7017 | ALIAS (show_bgp_view, |
| 7018 | show_bgp_view_ipv6_cmd, |
| 7019 | "show bgp view WORD ipv6", |
| 7020 | SHOW_STR |
| 7021 | BGP_STR |
| 7022 | "BGP view\n" |
| 7023 | "View name\n" |
| 7024 | "Address family\n") |
| 7025 | |
| 7026 | DEFUN (show_bgp_view_route, |
| 7027 | show_bgp_view_route_cmd, |
| 7028 | "show bgp view WORD X:X::X:X", |
| 7029 | SHOW_STR |
| 7030 | BGP_STR |
| 7031 | "BGP view\n" |
| 7032 | "View name\n" |
| 7033 | "Network in the BGP routing table to display\n") |
| 7034 | { |
| 7035 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7036 | } |
| 7037 | |
| 7038 | ALIAS (show_bgp_view_route, |
| 7039 | show_bgp_view_ipv6_route_cmd, |
| 7040 | "show bgp view WORD ipv6 X:X::X:X", |
| 7041 | SHOW_STR |
| 7042 | BGP_STR |
| 7043 | "BGP view\n" |
| 7044 | "View name\n" |
| 7045 | "Address family\n" |
| 7046 | "Network in the BGP routing table to display\n") |
| 7047 | |
| 7048 | DEFUN (show_bgp_view_prefix, |
| 7049 | show_bgp_view_prefix_cmd, |
| 7050 | "show bgp view WORD X:X::X:X/M", |
| 7051 | SHOW_STR |
| 7052 | BGP_STR |
| 7053 | "BGP view\n" |
| 7054 | "View name\n" |
| 7055 | "IPv6 prefix <network>/<length>\n") |
| 7056 | { |
| 7057 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7058 | } |
| 7059 | |
| 7060 | ALIAS (show_bgp_view_prefix, |
| 7061 | show_bgp_view_ipv6_prefix_cmd, |
| 7062 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 7063 | SHOW_STR |
| 7064 | BGP_STR |
| 7065 | "BGP view\n" |
| 7066 | "View name\n" |
| 7067 | "Address family\n" |
| 7068 | "IPv6 prefix <network>/<length>\n") |
| 7069 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7070 | /* old command */ |
| 7071 | DEFUN (show_ipv6_mbgp, |
| 7072 | show_ipv6_mbgp_cmd, |
| 7073 | "show ipv6 mbgp", |
| 7074 | SHOW_STR |
| 7075 | IP_STR |
| 7076 | MBGP_STR) |
| 7077 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7078 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7079 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7080 | } |
| 7081 | |
| 7082 | /* old command */ |
| 7083 | DEFUN (show_ipv6_mbgp_route, |
| 7084 | show_ipv6_mbgp_route_cmd, |
| 7085 | "show ipv6 mbgp X:X::X:X", |
| 7086 | SHOW_STR |
| 7087 | IP_STR |
| 7088 | MBGP_STR |
| 7089 | "Network in the MBGP routing table to display\n") |
| 7090 | { |
| 7091 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7092 | } |
| 7093 | |
| 7094 | /* old command */ |
| 7095 | DEFUN (show_ipv6_mbgp_prefix, |
| 7096 | show_ipv6_mbgp_prefix_cmd, |
| 7097 | "show ipv6 mbgp X:X::X:X/M", |
| 7098 | SHOW_STR |
| 7099 | IP_STR |
| 7100 | MBGP_STR |
| 7101 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7102 | { |
| 7103 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7104 | } |
| 7105 | #endif |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7106 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7107 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7108 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7109 | 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] | 7110 | safi_t safi, enum bgp_show_type type) |
| 7111 | { |
| 7112 | int i; |
| 7113 | struct buffer *b; |
| 7114 | char *regstr; |
| 7115 | int first; |
| 7116 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7117 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7118 | |
| 7119 | first = 0; |
| 7120 | b = buffer_new (1024); |
| 7121 | for (i = 0; i < argc; i++) |
| 7122 | { |
| 7123 | if (first) |
| 7124 | buffer_putc (b, ' '); |
| 7125 | else |
| 7126 | { |
| 7127 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7128 | continue; |
| 7129 | first = 1; |
| 7130 | } |
| 7131 | |
| 7132 | buffer_putstr (b, argv[i]); |
| 7133 | } |
| 7134 | buffer_putc (b, '\0'); |
| 7135 | |
| 7136 | regstr = buffer_getstr (b); |
| 7137 | buffer_free (b); |
| 7138 | |
| 7139 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7140 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7141 | if (! regex) |
| 7142 | { |
| 7143 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 7144 | VTY_NEWLINE); |
| 7145 | return CMD_WARNING; |
| 7146 | } |
| 7147 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7148 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 7149 | bgp_regex_free (regex); |
| 7150 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7151 | } |
| 7152 | |
| 7153 | DEFUN (show_ip_bgp_regexp, |
| 7154 | show_ip_bgp_regexp_cmd, |
| 7155 | "show ip bgp regexp .LINE", |
| 7156 | SHOW_STR |
| 7157 | IP_STR |
| 7158 | BGP_STR |
| 7159 | "Display routes matching the AS path regular expression\n" |
| 7160 | "A regular-expression to match the BGP AS paths\n") |
| 7161 | { |
| 7162 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7163 | bgp_show_type_regexp); |
| 7164 | } |
| 7165 | |
| 7166 | DEFUN (show_ip_bgp_flap_regexp, |
| 7167 | show_ip_bgp_flap_regexp_cmd, |
| 7168 | "show ip bgp flap-statistics regexp .LINE", |
| 7169 | SHOW_STR |
| 7170 | IP_STR |
| 7171 | BGP_STR |
| 7172 | "Display flap statistics of routes\n" |
| 7173 | "Display routes matching the AS path regular expression\n" |
| 7174 | "A regular-expression to match the BGP AS paths\n") |
| 7175 | { |
| 7176 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7177 | bgp_show_type_flap_regexp); |
| 7178 | } |
| 7179 | |
| 7180 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 7181 | show_ip_bgp_ipv4_regexp_cmd, |
| 7182 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 7183 | SHOW_STR |
| 7184 | IP_STR |
| 7185 | BGP_STR |
| 7186 | "Address family\n" |
| 7187 | "Address Family modifier\n" |
| 7188 | "Address Family modifier\n" |
| 7189 | "Display routes matching the AS path regular expression\n" |
| 7190 | "A regular-expression to match the BGP AS paths\n") |
| 7191 | { |
| 7192 | if (strncmp (argv[0], "m", 1) == 0) |
| 7193 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 7194 | bgp_show_type_regexp); |
| 7195 | |
| 7196 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7197 | bgp_show_type_regexp); |
| 7198 | } |
| 7199 | |
| 7200 | #ifdef HAVE_IPV6 |
| 7201 | DEFUN (show_bgp_regexp, |
| 7202 | show_bgp_regexp_cmd, |
| 7203 | "show bgp regexp .LINE", |
| 7204 | SHOW_STR |
| 7205 | BGP_STR |
| 7206 | "Display routes matching the AS path regular expression\n" |
| 7207 | "A regular-expression to match the BGP AS paths\n") |
| 7208 | { |
| 7209 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7210 | bgp_show_type_regexp); |
| 7211 | } |
| 7212 | |
| 7213 | ALIAS (show_bgp_regexp, |
| 7214 | show_bgp_ipv6_regexp_cmd, |
| 7215 | "show bgp ipv6 regexp .LINE", |
| 7216 | SHOW_STR |
| 7217 | BGP_STR |
| 7218 | "Address family\n" |
| 7219 | "Display routes matching the AS path regular expression\n" |
| 7220 | "A regular-expression to match the BGP AS paths\n") |
| 7221 | |
| 7222 | /* old command */ |
| 7223 | DEFUN (show_ipv6_bgp_regexp, |
| 7224 | show_ipv6_bgp_regexp_cmd, |
| 7225 | "show ipv6 bgp regexp .LINE", |
| 7226 | SHOW_STR |
| 7227 | IP_STR |
| 7228 | BGP_STR |
| 7229 | "Display routes matching the AS path regular expression\n" |
| 7230 | "A regular-expression to match the BGP AS paths\n") |
| 7231 | { |
| 7232 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7233 | bgp_show_type_regexp); |
| 7234 | } |
| 7235 | |
| 7236 | /* old command */ |
| 7237 | DEFUN (show_ipv6_mbgp_regexp, |
| 7238 | show_ipv6_mbgp_regexp_cmd, |
| 7239 | "show ipv6 mbgp regexp .LINE", |
| 7240 | SHOW_STR |
| 7241 | IP_STR |
| 7242 | BGP_STR |
| 7243 | "Display routes matching the AS path regular expression\n" |
| 7244 | "A regular-expression to match the MBGP AS paths\n") |
| 7245 | { |
| 7246 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 7247 | bgp_show_type_regexp); |
| 7248 | } |
| 7249 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7250 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7251 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7252 | 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] | 7253 | safi_t safi, enum bgp_show_type type) |
| 7254 | { |
| 7255 | struct prefix_list *plist; |
| 7256 | |
| 7257 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 7258 | if (plist == NULL) |
| 7259 | { |
| 7260 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 7261 | prefix_list_str, VTY_NEWLINE); |
| 7262 | return CMD_WARNING; |
| 7263 | } |
| 7264 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7265 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7266 | } |
| 7267 | |
| 7268 | DEFUN (show_ip_bgp_prefix_list, |
| 7269 | show_ip_bgp_prefix_list_cmd, |
| 7270 | "show ip bgp prefix-list WORD", |
| 7271 | SHOW_STR |
| 7272 | IP_STR |
| 7273 | BGP_STR |
| 7274 | "Display routes conforming to the prefix-list\n" |
| 7275 | "IP prefix-list name\n") |
| 7276 | { |
| 7277 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7278 | bgp_show_type_prefix_list); |
| 7279 | } |
| 7280 | |
| 7281 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 7282 | show_ip_bgp_flap_prefix_list_cmd, |
| 7283 | "show ip bgp flap-statistics prefix-list WORD", |
| 7284 | SHOW_STR |
| 7285 | IP_STR |
| 7286 | BGP_STR |
| 7287 | "Display flap statistics of routes\n" |
| 7288 | "Display routes conforming to the prefix-list\n" |
| 7289 | "IP prefix-list name\n") |
| 7290 | { |
| 7291 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7292 | bgp_show_type_flap_prefix_list); |
| 7293 | } |
| 7294 | |
| 7295 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 7296 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 7297 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 7298 | SHOW_STR |
| 7299 | IP_STR |
| 7300 | BGP_STR |
| 7301 | "Address family\n" |
| 7302 | "Address Family modifier\n" |
| 7303 | "Address Family modifier\n" |
| 7304 | "Display routes conforming to the prefix-list\n" |
| 7305 | "IP prefix-list name\n") |
| 7306 | { |
| 7307 | if (strncmp (argv[0], "m", 1) == 0) |
| 7308 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7309 | bgp_show_type_prefix_list); |
| 7310 | |
| 7311 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7312 | bgp_show_type_prefix_list); |
| 7313 | } |
| 7314 | |
| 7315 | #ifdef HAVE_IPV6 |
| 7316 | DEFUN (show_bgp_prefix_list, |
| 7317 | show_bgp_prefix_list_cmd, |
| 7318 | "show bgp prefix-list WORD", |
| 7319 | SHOW_STR |
| 7320 | BGP_STR |
| 7321 | "Display routes conforming to the prefix-list\n" |
| 7322 | "IPv6 prefix-list name\n") |
| 7323 | { |
| 7324 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7325 | bgp_show_type_prefix_list); |
| 7326 | } |
| 7327 | |
| 7328 | ALIAS (show_bgp_prefix_list, |
| 7329 | show_bgp_ipv6_prefix_list_cmd, |
| 7330 | "show bgp ipv6 prefix-list WORD", |
| 7331 | SHOW_STR |
| 7332 | BGP_STR |
| 7333 | "Address family\n" |
| 7334 | "Display routes conforming to the prefix-list\n" |
| 7335 | "IPv6 prefix-list name\n") |
| 7336 | |
| 7337 | /* old command */ |
| 7338 | DEFUN (show_ipv6_bgp_prefix_list, |
| 7339 | show_ipv6_bgp_prefix_list_cmd, |
| 7340 | "show ipv6 bgp prefix-list WORD", |
| 7341 | SHOW_STR |
| 7342 | IPV6_STR |
| 7343 | BGP_STR |
| 7344 | "Display routes matching the prefix-list\n" |
| 7345 | "IPv6 prefix-list name\n") |
| 7346 | { |
| 7347 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7348 | bgp_show_type_prefix_list); |
| 7349 | } |
| 7350 | |
| 7351 | /* old command */ |
| 7352 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 7353 | show_ipv6_mbgp_prefix_list_cmd, |
| 7354 | "show ipv6 mbgp prefix-list WORD", |
| 7355 | SHOW_STR |
| 7356 | IPV6_STR |
| 7357 | MBGP_STR |
| 7358 | "Display routes matching the prefix-list\n" |
| 7359 | "IPv6 prefix-list name\n") |
| 7360 | { |
| 7361 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7362 | bgp_show_type_prefix_list); |
| 7363 | } |
| 7364 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7365 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7366 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7367 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7368 | safi_t safi, enum bgp_show_type type) |
| 7369 | { |
| 7370 | struct as_list *as_list; |
| 7371 | |
| 7372 | as_list = as_list_lookup (filter); |
| 7373 | if (as_list == NULL) |
| 7374 | { |
| 7375 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 7376 | return CMD_WARNING; |
| 7377 | } |
| 7378 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7379 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7380 | } |
| 7381 | |
| 7382 | DEFUN (show_ip_bgp_filter_list, |
| 7383 | show_ip_bgp_filter_list_cmd, |
| 7384 | "show ip bgp filter-list WORD", |
| 7385 | SHOW_STR |
| 7386 | IP_STR |
| 7387 | BGP_STR |
| 7388 | "Display routes conforming to the filter-list\n" |
| 7389 | "Regular expression access list name\n") |
| 7390 | { |
| 7391 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7392 | bgp_show_type_filter_list); |
| 7393 | } |
| 7394 | |
| 7395 | DEFUN (show_ip_bgp_flap_filter_list, |
| 7396 | show_ip_bgp_flap_filter_list_cmd, |
| 7397 | "show ip bgp flap-statistics filter-list WORD", |
| 7398 | SHOW_STR |
| 7399 | IP_STR |
| 7400 | BGP_STR |
| 7401 | "Display flap statistics of routes\n" |
| 7402 | "Display routes conforming to the filter-list\n" |
| 7403 | "Regular expression access list name\n") |
| 7404 | { |
| 7405 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7406 | bgp_show_type_flap_filter_list); |
| 7407 | } |
| 7408 | |
| 7409 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 7410 | show_ip_bgp_ipv4_filter_list_cmd, |
| 7411 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 7412 | SHOW_STR |
| 7413 | IP_STR |
| 7414 | BGP_STR |
| 7415 | "Address family\n" |
| 7416 | "Address Family modifier\n" |
| 7417 | "Address Family modifier\n" |
| 7418 | "Display routes conforming to the filter-list\n" |
| 7419 | "Regular expression access list name\n") |
| 7420 | { |
| 7421 | if (strncmp (argv[0], "m", 1) == 0) |
| 7422 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7423 | bgp_show_type_filter_list); |
| 7424 | |
| 7425 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7426 | bgp_show_type_filter_list); |
| 7427 | } |
| 7428 | |
| 7429 | #ifdef HAVE_IPV6 |
| 7430 | DEFUN (show_bgp_filter_list, |
| 7431 | show_bgp_filter_list_cmd, |
| 7432 | "show bgp filter-list WORD", |
| 7433 | SHOW_STR |
| 7434 | BGP_STR |
| 7435 | "Display routes conforming to the filter-list\n" |
| 7436 | "Regular expression access list name\n") |
| 7437 | { |
| 7438 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7439 | bgp_show_type_filter_list); |
| 7440 | } |
| 7441 | |
| 7442 | ALIAS (show_bgp_filter_list, |
| 7443 | show_bgp_ipv6_filter_list_cmd, |
| 7444 | "show bgp ipv6 filter-list WORD", |
| 7445 | SHOW_STR |
| 7446 | BGP_STR |
| 7447 | "Address family\n" |
| 7448 | "Display routes conforming to the filter-list\n" |
| 7449 | "Regular expression access list name\n") |
| 7450 | |
| 7451 | /* old command */ |
| 7452 | DEFUN (show_ipv6_bgp_filter_list, |
| 7453 | show_ipv6_bgp_filter_list_cmd, |
| 7454 | "show ipv6 bgp filter-list WORD", |
| 7455 | SHOW_STR |
| 7456 | IPV6_STR |
| 7457 | BGP_STR |
| 7458 | "Display routes conforming to the filter-list\n" |
| 7459 | "Regular expression access list name\n") |
| 7460 | { |
| 7461 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7462 | bgp_show_type_filter_list); |
| 7463 | } |
| 7464 | |
| 7465 | /* old command */ |
| 7466 | DEFUN (show_ipv6_mbgp_filter_list, |
| 7467 | show_ipv6_mbgp_filter_list_cmd, |
| 7468 | "show ipv6 mbgp filter-list WORD", |
| 7469 | SHOW_STR |
| 7470 | IPV6_STR |
| 7471 | MBGP_STR |
| 7472 | "Display routes conforming to the filter-list\n" |
| 7473 | "Regular expression access list name\n") |
| 7474 | { |
| 7475 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7476 | bgp_show_type_filter_list); |
| 7477 | } |
| 7478 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7479 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7480 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7481 | 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] | 7482 | safi_t safi, enum bgp_show_type type) |
| 7483 | { |
| 7484 | struct route_map *rmap; |
| 7485 | |
| 7486 | rmap = route_map_lookup_by_name (rmap_str); |
| 7487 | if (! rmap) |
| 7488 | { |
| 7489 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 7490 | rmap_str, VTY_NEWLINE); |
| 7491 | return CMD_WARNING; |
| 7492 | } |
| 7493 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7494 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7495 | } |
| 7496 | |
| 7497 | DEFUN (show_ip_bgp_route_map, |
| 7498 | show_ip_bgp_route_map_cmd, |
| 7499 | "show ip bgp route-map WORD", |
| 7500 | SHOW_STR |
| 7501 | IP_STR |
| 7502 | BGP_STR |
| 7503 | "Display routes matching the route-map\n" |
| 7504 | "A route-map to match on\n") |
| 7505 | { |
| 7506 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7507 | bgp_show_type_route_map); |
| 7508 | } |
| 7509 | |
| 7510 | DEFUN (show_ip_bgp_flap_route_map, |
| 7511 | show_ip_bgp_flap_route_map_cmd, |
| 7512 | "show ip bgp flap-statistics route-map WORD", |
| 7513 | SHOW_STR |
| 7514 | IP_STR |
| 7515 | BGP_STR |
| 7516 | "Display flap statistics of routes\n" |
| 7517 | "Display routes matching the route-map\n" |
| 7518 | "A route-map to match on\n") |
| 7519 | { |
| 7520 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7521 | bgp_show_type_flap_route_map); |
| 7522 | } |
| 7523 | |
| 7524 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 7525 | show_ip_bgp_ipv4_route_map_cmd, |
| 7526 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 7527 | SHOW_STR |
| 7528 | IP_STR |
| 7529 | BGP_STR |
| 7530 | "Address family\n" |
| 7531 | "Address Family modifier\n" |
| 7532 | "Address Family modifier\n" |
| 7533 | "Display routes matching the route-map\n" |
| 7534 | "A route-map to match on\n") |
| 7535 | { |
| 7536 | if (strncmp (argv[0], "m", 1) == 0) |
| 7537 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7538 | bgp_show_type_route_map); |
| 7539 | |
| 7540 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7541 | bgp_show_type_route_map); |
| 7542 | } |
| 7543 | |
| 7544 | DEFUN (show_bgp_route_map, |
| 7545 | show_bgp_route_map_cmd, |
| 7546 | "show bgp route-map WORD", |
| 7547 | SHOW_STR |
| 7548 | BGP_STR |
| 7549 | "Display routes matching the route-map\n" |
| 7550 | "A route-map to match on\n") |
| 7551 | { |
| 7552 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7553 | bgp_show_type_route_map); |
| 7554 | } |
| 7555 | |
| 7556 | ALIAS (show_bgp_route_map, |
| 7557 | show_bgp_ipv6_route_map_cmd, |
| 7558 | "show bgp ipv6 route-map WORD", |
| 7559 | SHOW_STR |
| 7560 | BGP_STR |
| 7561 | "Address family\n" |
| 7562 | "Display routes matching the route-map\n" |
| 7563 | "A route-map to match on\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7564 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7565 | DEFUN (show_ip_bgp_cidr_only, |
| 7566 | show_ip_bgp_cidr_only_cmd, |
| 7567 | "show ip bgp cidr-only", |
| 7568 | SHOW_STR |
| 7569 | IP_STR |
| 7570 | BGP_STR |
| 7571 | "Display only routes with non-natural netmasks\n") |
| 7572 | { |
| 7573 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7574 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7575 | } |
| 7576 | |
| 7577 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 7578 | show_ip_bgp_flap_cidr_only_cmd, |
| 7579 | "show ip bgp flap-statistics cidr-only", |
| 7580 | SHOW_STR |
| 7581 | IP_STR |
| 7582 | BGP_STR |
| 7583 | "Display flap statistics of routes\n" |
| 7584 | "Display only routes with non-natural netmasks\n") |
| 7585 | { |
| 7586 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7587 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7588 | } |
| 7589 | |
| 7590 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 7591 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 7592 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 7593 | SHOW_STR |
| 7594 | IP_STR |
| 7595 | BGP_STR |
| 7596 | "Address family\n" |
| 7597 | "Address Family modifier\n" |
| 7598 | "Address Family modifier\n" |
| 7599 | "Display only routes with non-natural netmasks\n") |
| 7600 | { |
| 7601 | if (strncmp (argv[0], "m", 1) == 0) |
| 7602 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7603 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7604 | |
| 7605 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7606 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7607 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7608 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7609 | DEFUN (show_ip_bgp_community_all, |
| 7610 | show_ip_bgp_community_all_cmd, |
| 7611 | "show ip bgp community", |
| 7612 | SHOW_STR |
| 7613 | IP_STR |
| 7614 | BGP_STR |
| 7615 | "Display routes matching the communities\n") |
| 7616 | { |
| 7617 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7618 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7619 | } |
| 7620 | |
| 7621 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 7622 | show_ip_bgp_ipv4_community_all_cmd, |
| 7623 | "show ip bgp ipv4 (unicast|multicast) community", |
| 7624 | SHOW_STR |
| 7625 | IP_STR |
| 7626 | BGP_STR |
| 7627 | "Address family\n" |
| 7628 | "Address Family modifier\n" |
| 7629 | "Address Family modifier\n" |
| 7630 | "Display routes matching the communities\n") |
| 7631 | { |
| 7632 | if (strncmp (argv[0], "m", 1) == 0) |
| 7633 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7634 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7635 | |
| 7636 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7637 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7638 | } |
| 7639 | |
| 7640 | #ifdef HAVE_IPV6 |
| 7641 | DEFUN (show_bgp_community_all, |
| 7642 | show_bgp_community_all_cmd, |
| 7643 | "show bgp community", |
| 7644 | SHOW_STR |
| 7645 | BGP_STR |
| 7646 | "Display routes matching the communities\n") |
| 7647 | { |
| 7648 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7649 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7650 | } |
| 7651 | |
| 7652 | ALIAS (show_bgp_community_all, |
| 7653 | show_bgp_ipv6_community_all_cmd, |
| 7654 | "show bgp ipv6 community", |
| 7655 | SHOW_STR |
| 7656 | BGP_STR |
| 7657 | "Address family\n" |
| 7658 | "Display routes matching the communities\n") |
| 7659 | |
| 7660 | /* old command */ |
| 7661 | DEFUN (show_ipv6_bgp_community_all, |
| 7662 | show_ipv6_bgp_community_all_cmd, |
| 7663 | "show ipv6 bgp community", |
| 7664 | SHOW_STR |
| 7665 | IPV6_STR |
| 7666 | BGP_STR |
| 7667 | "Display routes matching the communities\n") |
| 7668 | { |
| 7669 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7670 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7671 | } |
| 7672 | |
| 7673 | /* old command */ |
| 7674 | DEFUN (show_ipv6_mbgp_community_all, |
| 7675 | show_ipv6_mbgp_community_all_cmd, |
| 7676 | "show ipv6 mbgp community", |
| 7677 | SHOW_STR |
| 7678 | IPV6_STR |
| 7679 | MBGP_STR |
| 7680 | "Display routes matching the communities\n") |
| 7681 | { |
| 7682 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7683 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7684 | } |
| 7685 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7686 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7687 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7688 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 7689 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7690 | { |
| 7691 | struct community *com; |
| 7692 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7693 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7694 | int i; |
| 7695 | char *str; |
| 7696 | int first = 0; |
| 7697 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7698 | /* BGP structure lookup */ |
| 7699 | if (view_name) |
| 7700 | { |
| 7701 | bgp = bgp_lookup_by_name (view_name); |
| 7702 | if (bgp == NULL) |
| 7703 | { |
| 7704 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 7705 | return CMD_WARNING; |
| 7706 | } |
| 7707 | } |
| 7708 | else |
| 7709 | { |
| 7710 | bgp = bgp_get_default (); |
| 7711 | if (bgp == NULL) |
| 7712 | { |
| 7713 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 7714 | return CMD_WARNING; |
| 7715 | } |
| 7716 | } |
| 7717 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7718 | b = buffer_new (1024); |
| 7719 | for (i = 0; i < argc; i++) |
| 7720 | { |
| 7721 | if (first) |
| 7722 | buffer_putc (b, ' '); |
| 7723 | else |
| 7724 | { |
| 7725 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7726 | continue; |
| 7727 | first = 1; |
| 7728 | } |
| 7729 | |
| 7730 | buffer_putstr (b, argv[i]); |
| 7731 | } |
| 7732 | buffer_putc (b, '\0'); |
| 7733 | |
| 7734 | str = buffer_getstr (b); |
| 7735 | buffer_free (b); |
| 7736 | |
| 7737 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7738 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7739 | if (! com) |
| 7740 | { |
| 7741 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 7742 | return CMD_WARNING; |
| 7743 | } |
| 7744 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7745 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7746 | (exact ? bgp_show_type_community_exact : |
| 7747 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7748 | } |
| 7749 | |
| 7750 | DEFUN (show_ip_bgp_community, |
| 7751 | show_ip_bgp_community_cmd, |
| 7752 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7753 | SHOW_STR |
| 7754 | IP_STR |
| 7755 | BGP_STR |
| 7756 | "Display routes matching the communities\n" |
| 7757 | "community number\n" |
| 7758 | "Do not send outside local AS (well-known community)\n" |
| 7759 | "Do not advertise to any peer (well-known community)\n" |
| 7760 | "Do not export to next AS (well-known community)\n") |
| 7761 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7762 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7763 | } |
| 7764 | |
| 7765 | ALIAS (show_ip_bgp_community, |
| 7766 | show_ip_bgp_community2_cmd, |
| 7767 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7768 | SHOW_STR |
| 7769 | IP_STR |
| 7770 | BGP_STR |
| 7771 | "Display routes matching the communities\n" |
| 7772 | "community number\n" |
| 7773 | "Do not send outside local AS (well-known community)\n" |
| 7774 | "Do not advertise to any peer (well-known community)\n" |
| 7775 | "Do not export to next AS (well-known community)\n" |
| 7776 | "community number\n" |
| 7777 | "Do not send outside local AS (well-known community)\n" |
| 7778 | "Do not advertise to any peer (well-known community)\n" |
| 7779 | "Do not export to next AS (well-known community)\n") |
| 7780 | |
| 7781 | ALIAS (show_ip_bgp_community, |
| 7782 | show_ip_bgp_community3_cmd, |
| 7783 | "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)", |
| 7784 | SHOW_STR |
| 7785 | IP_STR |
| 7786 | BGP_STR |
| 7787 | "Display routes matching the communities\n" |
| 7788 | "community number\n" |
| 7789 | "Do not send outside local AS (well-known community)\n" |
| 7790 | "Do not advertise to any peer (well-known community)\n" |
| 7791 | "Do not export to next AS (well-known community)\n" |
| 7792 | "community number\n" |
| 7793 | "Do not send outside local AS (well-known community)\n" |
| 7794 | "Do not advertise to any peer (well-known community)\n" |
| 7795 | "Do not export to next AS (well-known community)\n" |
| 7796 | "community number\n" |
| 7797 | "Do not send outside local AS (well-known community)\n" |
| 7798 | "Do not advertise to any peer (well-known community)\n" |
| 7799 | "Do not export to next AS (well-known community)\n") |
| 7800 | |
| 7801 | ALIAS (show_ip_bgp_community, |
| 7802 | show_ip_bgp_community4_cmd, |
| 7803 | "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)", |
| 7804 | SHOW_STR |
| 7805 | IP_STR |
| 7806 | BGP_STR |
| 7807 | "Display routes matching the communities\n" |
| 7808 | "community number\n" |
| 7809 | "Do not send outside local AS (well-known community)\n" |
| 7810 | "Do not advertise to any peer (well-known community)\n" |
| 7811 | "Do not export to next AS (well-known community)\n" |
| 7812 | "community number\n" |
| 7813 | "Do not send outside local AS (well-known community)\n" |
| 7814 | "Do not advertise to any peer (well-known community)\n" |
| 7815 | "Do not export to next AS (well-known community)\n" |
| 7816 | "community number\n" |
| 7817 | "Do not send outside local AS (well-known community)\n" |
| 7818 | "Do not advertise to any peer (well-known community)\n" |
| 7819 | "Do not export to next AS (well-known community)\n" |
| 7820 | "community number\n" |
| 7821 | "Do not send outside local AS (well-known community)\n" |
| 7822 | "Do not advertise to any peer (well-known community)\n" |
| 7823 | "Do not export to next AS (well-known community)\n") |
| 7824 | |
| 7825 | DEFUN (show_ip_bgp_ipv4_community, |
| 7826 | show_ip_bgp_ipv4_community_cmd, |
| 7827 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7828 | SHOW_STR |
| 7829 | IP_STR |
| 7830 | BGP_STR |
| 7831 | "Address family\n" |
| 7832 | "Address Family modifier\n" |
| 7833 | "Address Family modifier\n" |
| 7834 | "Display routes matching the communities\n" |
| 7835 | "community number\n" |
| 7836 | "Do not send outside local AS (well-known community)\n" |
| 7837 | "Do not advertise to any peer (well-known community)\n" |
| 7838 | "Do not export to next AS (well-known community)\n") |
| 7839 | { |
| 7840 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7841 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7842 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7843 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7844 | } |
| 7845 | |
| 7846 | ALIAS (show_ip_bgp_ipv4_community, |
| 7847 | show_ip_bgp_ipv4_community2_cmd, |
| 7848 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7849 | SHOW_STR |
| 7850 | IP_STR |
| 7851 | BGP_STR |
| 7852 | "Address family\n" |
| 7853 | "Address Family modifier\n" |
| 7854 | "Address Family modifier\n" |
| 7855 | "Display routes matching the communities\n" |
| 7856 | "community number\n" |
| 7857 | "Do not send outside local AS (well-known community)\n" |
| 7858 | "Do not advertise to any peer (well-known community)\n" |
| 7859 | "Do not export to next AS (well-known community)\n" |
| 7860 | "community number\n" |
| 7861 | "Do not send outside local AS (well-known community)\n" |
| 7862 | "Do not advertise to any peer (well-known community)\n" |
| 7863 | "Do not export to next AS (well-known community)\n") |
| 7864 | |
| 7865 | ALIAS (show_ip_bgp_ipv4_community, |
| 7866 | show_ip_bgp_ipv4_community3_cmd, |
| 7867 | "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)", |
| 7868 | SHOW_STR |
| 7869 | IP_STR |
| 7870 | BGP_STR |
| 7871 | "Address family\n" |
| 7872 | "Address Family modifier\n" |
| 7873 | "Address Family modifier\n" |
| 7874 | "Display routes matching the communities\n" |
| 7875 | "community number\n" |
| 7876 | "Do not send outside local AS (well-known community)\n" |
| 7877 | "Do not advertise to any peer (well-known community)\n" |
| 7878 | "Do not export to next AS (well-known community)\n" |
| 7879 | "community number\n" |
| 7880 | "Do not send outside local AS (well-known community)\n" |
| 7881 | "Do not advertise to any peer (well-known community)\n" |
| 7882 | "Do not export to next AS (well-known community)\n" |
| 7883 | "community number\n" |
| 7884 | "Do not send outside local AS (well-known community)\n" |
| 7885 | "Do not advertise to any peer (well-known community)\n" |
| 7886 | "Do not export to next AS (well-known community)\n") |
| 7887 | |
| 7888 | ALIAS (show_ip_bgp_ipv4_community, |
| 7889 | show_ip_bgp_ipv4_community4_cmd, |
| 7890 | "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)", |
| 7891 | SHOW_STR |
| 7892 | IP_STR |
| 7893 | BGP_STR |
| 7894 | "Address family\n" |
| 7895 | "Address Family modifier\n" |
| 7896 | "Address Family modifier\n" |
| 7897 | "Display routes matching the communities\n" |
| 7898 | "community number\n" |
| 7899 | "Do not send outside local AS (well-known community)\n" |
| 7900 | "Do not advertise to any peer (well-known community)\n" |
| 7901 | "Do not export to next AS (well-known community)\n" |
| 7902 | "community number\n" |
| 7903 | "Do not send outside local AS (well-known community)\n" |
| 7904 | "Do not advertise to any peer (well-known community)\n" |
| 7905 | "Do not export to next AS (well-known community)\n" |
| 7906 | "community number\n" |
| 7907 | "Do not send outside local AS (well-known community)\n" |
| 7908 | "Do not advertise to any peer (well-known community)\n" |
| 7909 | "Do not export to next AS (well-known community)\n" |
| 7910 | "community number\n" |
| 7911 | "Do not send outside local AS (well-known community)\n" |
| 7912 | "Do not advertise to any peer (well-known community)\n" |
| 7913 | "Do not export to next AS (well-known community)\n") |
| 7914 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7915 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 7916 | show_bgp_view_afi_safi_community_all_cmd, |
| 7917 | #ifdef HAVE_IPV6 |
| 7918 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
| 7919 | #else |
| 7920 | "show bgp view WORD ipv4 (unicast|multicast) community", |
| 7921 | #endif |
| 7922 | SHOW_STR |
| 7923 | BGP_STR |
| 7924 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 7925 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7926 | "Address family\n" |
| 7927 | #ifdef HAVE_IPV6 |
| 7928 | "Address family\n" |
| 7929 | #endif |
| 7930 | "Address Family modifier\n" |
| 7931 | "Address Family modifier\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 7932 | "Display routes matching the communities\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7933 | { |
| 7934 | int afi; |
| 7935 | int safi; |
| 7936 | struct bgp *bgp; |
| 7937 | |
| 7938 | /* BGP structure lookup. */ |
| 7939 | bgp = bgp_lookup_by_name (argv[0]); |
| 7940 | if (bgp == NULL) |
| 7941 | { |
| 7942 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7943 | return CMD_WARNING; |
| 7944 | } |
| 7945 | |
| 7946 | #ifdef HAVE_IPV6 |
| 7947 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 7948 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7949 | #else |
| 7950 | afi = AFI_IP; |
| 7951 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7952 | #endif |
| 7953 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 7954 | } |
| 7955 | |
| 7956 | DEFUN (show_bgp_view_afi_safi_community, |
| 7957 | show_bgp_view_afi_safi_community_cmd, |
| 7958 | #ifdef HAVE_IPV6 |
| 7959 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7960 | #else |
| 7961 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7962 | #endif |
| 7963 | SHOW_STR |
| 7964 | BGP_STR |
| 7965 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 7966 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7967 | "Address family\n" |
| 7968 | #ifdef HAVE_IPV6 |
| 7969 | "Address family\n" |
| 7970 | #endif |
| 7971 | "Address family modifier\n" |
| 7972 | "Address family modifier\n" |
| 7973 | "Display routes matching the communities\n" |
| 7974 | "community number\n" |
| 7975 | "Do not send outside local AS (well-known community)\n" |
| 7976 | "Do not advertise to any peer (well-known community)\n" |
| 7977 | "Do not export to next AS (well-known community)\n") |
| 7978 | { |
| 7979 | int afi; |
| 7980 | int safi; |
| 7981 | |
| 7982 | #ifdef HAVE_IPV6 |
| 7983 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 7984 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7985 | return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi); |
| 7986 | #else |
| 7987 | afi = AFI_IP; |
| 7988 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7989 | return bgp_show_community (vty, argv[0], argc-2, &argv[2], 0, afi, safi); |
| 7990 | #endif |
| 7991 | } |
| 7992 | |
| 7993 | ALIAS (show_bgp_view_afi_safi_community, |
| 7994 | show_bgp_view_afi_safi_community2_cmd, |
| 7995 | #ifdef HAVE_IPV6 |
| 7996 | "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)", |
| 7997 | #else |
| 7998 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7999 | #endif |
| 8000 | SHOW_STR |
| 8001 | BGP_STR |
| 8002 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8003 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8004 | "Address family\n" |
| 8005 | #ifdef HAVE_IPV6 |
| 8006 | "Address family\n" |
| 8007 | #endif |
| 8008 | "Address family modifier\n" |
| 8009 | "Address family modifier\n" |
| 8010 | "Display routes matching the communities\n" |
| 8011 | "community number\n" |
| 8012 | "Do not send outside local AS (well-known community)\n" |
| 8013 | "Do not advertise to any peer (well-known community)\n" |
| 8014 | "Do not export to next AS (well-known community)\n" |
| 8015 | "community number\n" |
| 8016 | "Do not send outside local AS (well-known community)\n" |
| 8017 | "Do not advertise to any peer (well-known community)\n" |
| 8018 | "Do not export to next AS (well-known community)\n") |
| 8019 | |
| 8020 | ALIAS (show_bgp_view_afi_safi_community, |
| 8021 | show_bgp_view_afi_safi_community3_cmd, |
| 8022 | #ifdef HAVE_IPV6 |
| 8023 | "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)", |
| 8024 | #else |
| 8025 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8026 | #endif |
| 8027 | SHOW_STR |
| 8028 | BGP_STR |
| 8029 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8030 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8031 | "Address family\n" |
| 8032 | #ifdef HAVE_IPV6 |
| 8033 | "Address family\n" |
| 8034 | #endif |
| 8035 | "Address family modifier\n" |
| 8036 | "Address family modifier\n" |
| 8037 | "Display routes matching the communities\n" |
| 8038 | "community number\n" |
| 8039 | "Do not send outside local AS (well-known community)\n" |
| 8040 | "Do not advertise to any peer (well-known community)\n" |
| 8041 | "Do not export to next AS (well-known community)\n" |
| 8042 | "community number\n" |
| 8043 | "Do not send outside local AS (well-known community)\n" |
| 8044 | "Do not advertise to any peer (well-known community)\n" |
| 8045 | "Do not export to next AS (well-known community)\n" |
| 8046 | "community number\n" |
| 8047 | "Do not send outside local AS (well-known community)\n" |
| 8048 | "Do not advertise to any peer (well-known community)\n" |
| 8049 | "Do not export to next AS (well-known community)\n") |
| 8050 | |
| 8051 | ALIAS (show_bgp_view_afi_safi_community, |
| 8052 | show_bgp_view_afi_safi_community4_cmd, |
| 8053 | #ifdef HAVE_IPV6 |
| 8054 | "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)", |
| 8055 | #else |
| 8056 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8057 | #endif |
| 8058 | SHOW_STR |
| 8059 | BGP_STR |
| 8060 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8061 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8062 | "Address family\n" |
| 8063 | #ifdef HAVE_IPV6 |
| 8064 | "Address family\n" |
| 8065 | #endif |
| 8066 | "Address family modifier\n" |
| 8067 | "Address family modifier\n" |
| 8068 | "Display routes matching the communities\n" |
| 8069 | "community number\n" |
| 8070 | "Do not send outside local AS (well-known community)\n" |
| 8071 | "Do not advertise to any peer (well-known community)\n" |
| 8072 | "Do not export to next AS (well-known community)\n" |
| 8073 | "community number\n" |
| 8074 | "Do not send outside local AS (well-known community)\n" |
| 8075 | "Do not advertise to any peer (well-known community)\n" |
| 8076 | "Do not export to next AS (well-known community)\n" |
| 8077 | "community number\n" |
| 8078 | "Do not send outside local AS (well-known community)\n" |
| 8079 | "Do not advertise to any peer (well-known community)\n" |
| 8080 | "Do not export to next AS (well-known community)\n" |
| 8081 | "community number\n" |
| 8082 | "Do not send outside local AS (well-known community)\n" |
| 8083 | "Do not advertise to any peer (well-known community)\n" |
| 8084 | "Do not export to next AS (well-known community)\n") |
| 8085 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8086 | DEFUN (show_ip_bgp_community_exact, |
| 8087 | show_ip_bgp_community_exact_cmd, |
| 8088 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8089 | SHOW_STR |
| 8090 | IP_STR |
| 8091 | BGP_STR |
| 8092 | "Display routes matching the communities\n" |
| 8093 | "community number\n" |
| 8094 | "Do not send outside local AS (well-known community)\n" |
| 8095 | "Do not advertise to any peer (well-known community)\n" |
| 8096 | "Do not export to next AS (well-known community)\n" |
| 8097 | "Exact match of the communities") |
| 8098 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8099 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8100 | } |
| 8101 | |
| 8102 | ALIAS (show_ip_bgp_community_exact, |
| 8103 | show_ip_bgp_community2_exact_cmd, |
| 8104 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8105 | SHOW_STR |
| 8106 | IP_STR |
| 8107 | BGP_STR |
| 8108 | "Display routes matching the communities\n" |
| 8109 | "community number\n" |
| 8110 | "Do not send outside local AS (well-known community)\n" |
| 8111 | "Do not advertise to any peer (well-known community)\n" |
| 8112 | "Do not export to next AS (well-known community)\n" |
| 8113 | "community number\n" |
| 8114 | "Do not send outside local AS (well-known community)\n" |
| 8115 | "Do not advertise to any peer (well-known community)\n" |
| 8116 | "Do not export to next AS (well-known community)\n" |
| 8117 | "Exact match of the communities") |
| 8118 | |
| 8119 | ALIAS (show_ip_bgp_community_exact, |
| 8120 | show_ip_bgp_community3_exact_cmd, |
| 8121 | "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", |
| 8122 | SHOW_STR |
| 8123 | IP_STR |
| 8124 | BGP_STR |
| 8125 | "Display routes matching the communities\n" |
| 8126 | "community number\n" |
| 8127 | "Do not send outside local AS (well-known community)\n" |
| 8128 | "Do not advertise to any peer (well-known community)\n" |
| 8129 | "Do not export to next AS (well-known community)\n" |
| 8130 | "community number\n" |
| 8131 | "Do not send outside local AS (well-known community)\n" |
| 8132 | "Do not advertise to any peer (well-known community)\n" |
| 8133 | "Do not export to next AS (well-known community)\n" |
| 8134 | "community number\n" |
| 8135 | "Do not send outside local AS (well-known community)\n" |
| 8136 | "Do not advertise to any peer (well-known community)\n" |
| 8137 | "Do not export to next AS (well-known community)\n" |
| 8138 | "Exact match of the communities") |
| 8139 | |
| 8140 | ALIAS (show_ip_bgp_community_exact, |
| 8141 | show_ip_bgp_community4_exact_cmd, |
| 8142 | "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", |
| 8143 | SHOW_STR |
| 8144 | IP_STR |
| 8145 | BGP_STR |
| 8146 | "Display routes matching the communities\n" |
| 8147 | "community number\n" |
| 8148 | "Do not send outside local AS (well-known community)\n" |
| 8149 | "Do not advertise to any peer (well-known community)\n" |
| 8150 | "Do not export to next AS (well-known community)\n" |
| 8151 | "community number\n" |
| 8152 | "Do not send outside local AS (well-known community)\n" |
| 8153 | "Do not advertise to any peer (well-known community)\n" |
| 8154 | "Do not export to next AS (well-known community)\n" |
| 8155 | "community number\n" |
| 8156 | "Do not send outside local AS (well-known community)\n" |
| 8157 | "Do not advertise to any peer (well-known community)\n" |
| 8158 | "Do not export to next AS (well-known community)\n" |
| 8159 | "community number\n" |
| 8160 | "Do not send outside local AS (well-known community)\n" |
| 8161 | "Do not advertise to any peer (well-known community)\n" |
| 8162 | "Do not export to next AS (well-known community)\n" |
| 8163 | "Exact match of the communities") |
| 8164 | |
| 8165 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 8166 | show_ip_bgp_ipv4_community_exact_cmd, |
| 8167 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8168 | SHOW_STR |
| 8169 | IP_STR |
| 8170 | BGP_STR |
| 8171 | "Address family\n" |
| 8172 | "Address Family modifier\n" |
| 8173 | "Address Family modifier\n" |
| 8174 | "Display routes matching the communities\n" |
| 8175 | "community number\n" |
| 8176 | "Do not send outside local AS (well-known community)\n" |
| 8177 | "Do not advertise to any peer (well-known community)\n" |
| 8178 | "Do not export to next AS (well-known community)\n" |
| 8179 | "Exact match of the communities") |
| 8180 | { |
| 8181 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8182 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8183 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8184 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8185 | } |
| 8186 | |
| 8187 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8188 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 8189 | "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", |
| 8190 | SHOW_STR |
| 8191 | IP_STR |
| 8192 | BGP_STR |
| 8193 | "Address family\n" |
| 8194 | "Address Family modifier\n" |
| 8195 | "Address Family modifier\n" |
| 8196 | "Display routes matching the communities\n" |
| 8197 | "community number\n" |
| 8198 | "Do not send outside local AS (well-known community)\n" |
| 8199 | "Do not advertise to any peer (well-known community)\n" |
| 8200 | "Do not export to next AS (well-known community)\n" |
| 8201 | "community number\n" |
| 8202 | "Do not send outside local AS (well-known community)\n" |
| 8203 | "Do not advertise to any peer (well-known community)\n" |
| 8204 | "Do not export to next AS (well-known community)\n" |
| 8205 | "Exact match of the communities") |
| 8206 | |
| 8207 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8208 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 8209 | "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", |
| 8210 | SHOW_STR |
| 8211 | IP_STR |
| 8212 | BGP_STR |
| 8213 | "Address family\n" |
| 8214 | "Address Family modifier\n" |
| 8215 | "Address Family modifier\n" |
| 8216 | "Display routes matching the communities\n" |
| 8217 | "community number\n" |
| 8218 | "Do not send outside local AS (well-known community)\n" |
| 8219 | "Do not advertise to any peer (well-known community)\n" |
| 8220 | "Do not export to next AS (well-known community)\n" |
| 8221 | "community number\n" |
| 8222 | "Do not send outside local AS (well-known community)\n" |
| 8223 | "Do not advertise to any peer (well-known community)\n" |
| 8224 | "Do not export to next AS (well-known community)\n" |
| 8225 | "community number\n" |
| 8226 | "Do not send outside local AS (well-known community)\n" |
| 8227 | "Do not advertise to any peer (well-known community)\n" |
| 8228 | "Do not export to next AS (well-known community)\n" |
| 8229 | "Exact match of the communities") |
| 8230 | |
| 8231 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8232 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 8233 | "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", |
| 8234 | SHOW_STR |
| 8235 | IP_STR |
| 8236 | BGP_STR |
| 8237 | "Address family\n" |
| 8238 | "Address Family modifier\n" |
| 8239 | "Address Family modifier\n" |
| 8240 | "Display routes matching the communities\n" |
| 8241 | "community number\n" |
| 8242 | "Do not send outside local AS (well-known community)\n" |
| 8243 | "Do not advertise to any peer (well-known community)\n" |
| 8244 | "Do not export to next AS (well-known community)\n" |
| 8245 | "community number\n" |
| 8246 | "Do not send outside local AS (well-known community)\n" |
| 8247 | "Do not advertise to any peer (well-known community)\n" |
| 8248 | "Do not export to next AS (well-known community)\n" |
| 8249 | "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 | "community number\n" |
| 8254 | "Do not send outside local AS (well-known community)\n" |
| 8255 | "Do not advertise to any peer (well-known community)\n" |
| 8256 | "Do not export to next AS (well-known community)\n" |
| 8257 | "Exact match of the communities") |
| 8258 | |
| 8259 | #ifdef HAVE_IPV6 |
| 8260 | DEFUN (show_bgp_community, |
| 8261 | show_bgp_community_cmd, |
| 8262 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8263 | SHOW_STR |
| 8264 | BGP_STR |
| 8265 | "Display routes matching the communities\n" |
| 8266 | "community number\n" |
| 8267 | "Do not send outside local AS (well-known community)\n" |
| 8268 | "Do not advertise to any peer (well-known community)\n" |
| 8269 | "Do not export to next AS (well-known community)\n") |
| 8270 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8271 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8272 | } |
| 8273 | |
| 8274 | ALIAS (show_bgp_community, |
| 8275 | show_bgp_ipv6_community_cmd, |
| 8276 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 8277 | SHOW_STR |
| 8278 | BGP_STR |
| 8279 | "Address family\n" |
| 8280 | "Display routes matching the communities\n" |
| 8281 | "community number\n" |
| 8282 | "Do not send outside local AS (well-known community)\n" |
| 8283 | "Do not advertise to any peer (well-known community)\n" |
| 8284 | "Do not export to next AS (well-known community)\n") |
| 8285 | |
| 8286 | ALIAS (show_bgp_community, |
| 8287 | show_bgp_community2_cmd, |
| 8288 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8289 | SHOW_STR |
| 8290 | BGP_STR |
| 8291 | "Display routes matching the communities\n" |
| 8292 | "community number\n" |
| 8293 | "Do not send outside local AS (well-known community)\n" |
| 8294 | "Do not advertise to any peer (well-known community)\n" |
| 8295 | "Do not export to next AS (well-known community)\n" |
| 8296 | "community number\n" |
| 8297 | "Do not send outside local AS (well-known community)\n" |
| 8298 | "Do not advertise to any peer (well-known community)\n" |
| 8299 | "Do not export to next AS (well-known community)\n") |
| 8300 | |
| 8301 | ALIAS (show_bgp_community, |
| 8302 | show_bgp_ipv6_community2_cmd, |
| 8303 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8304 | SHOW_STR |
| 8305 | BGP_STR |
| 8306 | "Address family\n" |
| 8307 | "Display routes matching the communities\n" |
| 8308 | "community number\n" |
| 8309 | "Do not send outside local AS (well-known community)\n" |
| 8310 | "Do not advertise to any peer (well-known community)\n" |
| 8311 | "Do not export to next AS (well-known community)\n" |
| 8312 | "community number\n" |
| 8313 | "Do not send outside local AS (well-known community)\n" |
| 8314 | "Do not advertise to any peer (well-known community)\n" |
| 8315 | "Do not export to next AS (well-known community)\n") |
| 8316 | |
| 8317 | ALIAS (show_bgp_community, |
| 8318 | show_bgp_community3_cmd, |
| 8319 | "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)", |
| 8320 | SHOW_STR |
| 8321 | BGP_STR |
| 8322 | "Display routes matching the communities\n" |
| 8323 | "community number\n" |
| 8324 | "Do not send outside local AS (well-known community)\n" |
| 8325 | "Do not advertise to any peer (well-known community)\n" |
| 8326 | "Do not export to next AS (well-known community)\n" |
| 8327 | "community number\n" |
| 8328 | "Do not send outside local AS (well-known community)\n" |
| 8329 | "Do not advertise to any peer (well-known community)\n" |
| 8330 | "Do not export to next AS (well-known community)\n" |
| 8331 | "community number\n" |
| 8332 | "Do not send outside local AS (well-known community)\n" |
| 8333 | "Do not advertise to any peer (well-known community)\n" |
| 8334 | "Do not export to next AS (well-known community)\n") |
| 8335 | |
| 8336 | ALIAS (show_bgp_community, |
| 8337 | show_bgp_ipv6_community3_cmd, |
| 8338 | "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)", |
| 8339 | SHOW_STR |
| 8340 | BGP_STR |
| 8341 | "Address family\n" |
| 8342 | "Display routes matching the communities\n" |
| 8343 | "community number\n" |
| 8344 | "Do not send outside local AS (well-known community)\n" |
| 8345 | "Do not advertise to any peer (well-known community)\n" |
| 8346 | "Do not export to next AS (well-known community)\n" |
| 8347 | "community number\n" |
| 8348 | "Do not send outside local AS (well-known community)\n" |
| 8349 | "Do not advertise to any peer (well-known community)\n" |
| 8350 | "Do not export to next AS (well-known community)\n" |
| 8351 | "community number\n" |
| 8352 | "Do not send outside local AS (well-known community)\n" |
| 8353 | "Do not advertise to any peer (well-known community)\n" |
| 8354 | "Do not export to next AS (well-known community)\n") |
| 8355 | |
| 8356 | ALIAS (show_bgp_community, |
| 8357 | show_bgp_community4_cmd, |
| 8358 | "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)", |
| 8359 | SHOW_STR |
| 8360 | BGP_STR |
| 8361 | "Display routes matching the communities\n" |
| 8362 | "community number\n" |
| 8363 | "Do not send outside local AS (well-known community)\n" |
| 8364 | "Do not advertise to any peer (well-known community)\n" |
| 8365 | "Do not export to next AS (well-known community)\n" |
| 8366 | "community number\n" |
| 8367 | "Do not send outside local AS (well-known community)\n" |
| 8368 | "Do not advertise to any peer (well-known community)\n" |
| 8369 | "Do not export to next AS (well-known community)\n" |
| 8370 | "community number\n" |
| 8371 | "Do not send outside local AS (well-known community)\n" |
| 8372 | "Do not advertise to any peer (well-known community)\n" |
| 8373 | "Do not export to next AS (well-known community)\n" |
| 8374 | "community number\n" |
| 8375 | "Do not send outside local AS (well-known community)\n" |
| 8376 | "Do not advertise to any peer (well-known community)\n" |
| 8377 | "Do not export to next AS (well-known community)\n") |
| 8378 | |
| 8379 | ALIAS (show_bgp_community, |
| 8380 | show_bgp_ipv6_community4_cmd, |
| 8381 | "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)", |
| 8382 | SHOW_STR |
| 8383 | BGP_STR |
| 8384 | "Address family\n" |
| 8385 | "Display routes matching the communities\n" |
| 8386 | "community number\n" |
| 8387 | "Do not send outside local AS (well-known community)\n" |
| 8388 | "Do not advertise to any peer (well-known community)\n" |
| 8389 | "Do not export to next AS (well-known community)\n" |
| 8390 | "community number\n" |
| 8391 | "Do not send outside local AS (well-known community)\n" |
| 8392 | "Do not advertise to any peer (well-known community)\n" |
| 8393 | "Do not export to next AS (well-known community)\n" |
| 8394 | "community number\n" |
| 8395 | "Do not send outside local AS (well-known community)\n" |
| 8396 | "Do not advertise to any peer (well-known community)\n" |
| 8397 | "Do not export to next AS (well-known community)\n" |
| 8398 | "community number\n" |
| 8399 | "Do not send outside local AS (well-known community)\n" |
| 8400 | "Do not advertise to any peer (well-known community)\n" |
| 8401 | "Do not export to next AS (well-known community)\n") |
| 8402 | |
| 8403 | /* old command */ |
| 8404 | DEFUN (show_ipv6_bgp_community, |
| 8405 | show_ipv6_bgp_community_cmd, |
| 8406 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8407 | SHOW_STR |
| 8408 | IPV6_STR |
| 8409 | BGP_STR |
| 8410 | "Display routes matching the communities\n" |
| 8411 | "community number\n" |
| 8412 | "Do not send outside local AS (well-known community)\n" |
| 8413 | "Do not advertise to any peer (well-known community)\n" |
| 8414 | "Do not export to next AS (well-known community)\n") |
| 8415 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8416 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8417 | } |
| 8418 | |
| 8419 | /* old command */ |
| 8420 | ALIAS (show_ipv6_bgp_community, |
| 8421 | show_ipv6_bgp_community2_cmd, |
| 8422 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8423 | SHOW_STR |
| 8424 | IPV6_STR |
| 8425 | BGP_STR |
| 8426 | "Display routes matching the communities\n" |
| 8427 | "community number\n" |
| 8428 | "Do not send outside local AS (well-known community)\n" |
| 8429 | "Do not advertise to any peer (well-known community)\n" |
| 8430 | "Do not export to next AS (well-known community)\n" |
| 8431 | "community number\n" |
| 8432 | "Do not send outside local AS (well-known community)\n" |
| 8433 | "Do not advertise to any peer (well-known community)\n" |
| 8434 | "Do not export to next AS (well-known community)\n") |
| 8435 | |
| 8436 | /* old command */ |
| 8437 | ALIAS (show_ipv6_bgp_community, |
| 8438 | show_ipv6_bgp_community3_cmd, |
| 8439 | "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)", |
| 8440 | SHOW_STR |
| 8441 | IPV6_STR |
| 8442 | BGP_STR |
| 8443 | "Display routes matching the communities\n" |
| 8444 | "community number\n" |
| 8445 | "Do not send outside local AS (well-known community)\n" |
| 8446 | "Do not advertise to any peer (well-known community)\n" |
| 8447 | "Do not export to next AS (well-known community)\n" |
| 8448 | "community number\n" |
| 8449 | "Do not send outside local AS (well-known community)\n" |
| 8450 | "Do not advertise to any peer (well-known community)\n" |
| 8451 | "Do not export to next AS (well-known community)\n" |
| 8452 | "community number\n" |
| 8453 | "Do not send outside local AS (well-known community)\n" |
| 8454 | "Do not advertise to any peer (well-known community)\n" |
| 8455 | "Do not export to next AS (well-known community)\n") |
| 8456 | |
| 8457 | /* old command */ |
| 8458 | ALIAS (show_ipv6_bgp_community, |
| 8459 | show_ipv6_bgp_community4_cmd, |
| 8460 | "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)", |
| 8461 | SHOW_STR |
| 8462 | IPV6_STR |
| 8463 | BGP_STR |
| 8464 | "Display routes matching the communities\n" |
| 8465 | "community number\n" |
| 8466 | "Do not send outside local AS (well-known community)\n" |
| 8467 | "Do not advertise to any peer (well-known community)\n" |
| 8468 | "Do not export to next AS (well-known community)\n" |
| 8469 | "community number\n" |
| 8470 | "Do not send outside local AS (well-known community)\n" |
| 8471 | "Do not advertise to any peer (well-known community)\n" |
| 8472 | "Do not export to next AS (well-known community)\n" |
| 8473 | "community number\n" |
| 8474 | "Do not send outside local AS (well-known community)\n" |
| 8475 | "Do not advertise to any peer (well-known community)\n" |
| 8476 | "Do not export to next AS (well-known community)\n" |
| 8477 | "community number\n" |
| 8478 | "Do not send outside local AS (well-known community)\n" |
| 8479 | "Do not advertise to any peer (well-known community)\n" |
| 8480 | "Do not export to next AS (well-known community)\n") |
| 8481 | |
| 8482 | DEFUN (show_bgp_community_exact, |
| 8483 | show_bgp_community_exact_cmd, |
| 8484 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8485 | SHOW_STR |
| 8486 | BGP_STR |
| 8487 | "Display routes matching the communities\n" |
| 8488 | "community number\n" |
| 8489 | "Do not send outside local AS (well-known community)\n" |
| 8490 | "Do not advertise to any peer (well-known community)\n" |
| 8491 | "Do not export to next AS (well-known community)\n" |
| 8492 | "Exact match of the communities") |
| 8493 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8494 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8495 | } |
| 8496 | |
| 8497 | ALIAS (show_bgp_community_exact, |
| 8498 | show_bgp_ipv6_community_exact_cmd, |
| 8499 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8500 | SHOW_STR |
| 8501 | BGP_STR |
| 8502 | "Address family\n" |
| 8503 | "Display routes matching the communities\n" |
| 8504 | "community number\n" |
| 8505 | "Do not send outside local AS (well-known community)\n" |
| 8506 | "Do not advertise to any peer (well-known community)\n" |
| 8507 | "Do not export to next AS (well-known community)\n" |
| 8508 | "Exact match of the communities") |
| 8509 | |
| 8510 | ALIAS (show_bgp_community_exact, |
| 8511 | show_bgp_community2_exact_cmd, |
| 8512 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8513 | SHOW_STR |
| 8514 | BGP_STR |
| 8515 | "Display routes matching the communities\n" |
| 8516 | "community number\n" |
| 8517 | "Do not send outside local AS (well-known community)\n" |
| 8518 | "Do not advertise to any peer (well-known community)\n" |
| 8519 | "Do not export to next AS (well-known community)\n" |
| 8520 | "community number\n" |
| 8521 | "Do not send outside local AS (well-known community)\n" |
| 8522 | "Do not advertise to any peer (well-known community)\n" |
| 8523 | "Do not export to next AS (well-known community)\n" |
| 8524 | "Exact match of the communities") |
| 8525 | |
| 8526 | ALIAS (show_bgp_community_exact, |
| 8527 | show_bgp_ipv6_community2_exact_cmd, |
| 8528 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8529 | SHOW_STR |
| 8530 | BGP_STR |
| 8531 | "Address family\n" |
| 8532 | "Display routes matching the communities\n" |
| 8533 | "community number\n" |
| 8534 | "Do not send outside local AS (well-known community)\n" |
| 8535 | "Do not advertise to any peer (well-known community)\n" |
| 8536 | "Do not export to next AS (well-known community)\n" |
| 8537 | "community number\n" |
| 8538 | "Do not send outside local AS (well-known community)\n" |
| 8539 | "Do not advertise to any peer (well-known community)\n" |
| 8540 | "Do not export to next AS (well-known community)\n" |
| 8541 | "Exact match of the communities") |
| 8542 | |
| 8543 | ALIAS (show_bgp_community_exact, |
| 8544 | show_bgp_community3_exact_cmd, |
| 8545 | "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", |
| 8546 | SHOW_STR |
| 8547 | BGP_STR |
| 8548 | "Display routes matching the communities\n" |
| 8549 | "community number\n" |
| 8550 | "Do not send outside local AS (well-known community)\n" |
| 8551 | "Do not advertise to any peer (well-known community)\n" |
| 8552 | "Do not export to next AS (well-known community)\n" |
| 8553 | "community number\n" |
| 8554 | "Do not send outside local AS (well-known community)\n" |
| 8555 | "Do not advertise to any peer (well-known community)\n" |
| 8556 | "Do not export to next AS (well-known community)\n" |
| 8557 | "community number\n" |
| 8558 | "Do not send outside local AS (well-known community)\n" |
| 8559 | "Do not advertise to any peer (well-known community)\n" |
| 8560 | "Do not export to next AS (well-known community)\n" |
| 8561 | "Exact match of the communities") |
| 8562 | |
| 8563 | ALIAS (show_bgp_community_exact, |
| 8564 | show_bgp_ipv6_community3_exact_cmd, |
| 8565 | "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", |
| 8566 | SHOW_STR |
| 8567 | BGP_STR |
| 8568 | "Address family\n" |
| 8569 | "Display routes matching the communities\n" |
| 8570 | "community number\n" |
| 8571 | "Do not send outside local AS (well-known community)\n" |
| 8572 | "Do not advertise to any peer (well-known community)\n" |
| 8573 | "Do not export to next AS (well-known community)\n" |
| 8574 | "community number\n" |
| 8575 | "Do not send outside local AS (well-known community)\n" |
| 8576 | "Do not advertise to any peer (well-known community)\n" |
| 8577 | "Do not export to next AS (well-known community)\n" |
| 8578 | "community number\n" |
| 8579 | "Do not send outside local AS (well-known community)\n" |
| 8580 | "Do not advertise to any peer (well-known community)\n" |
| 8581 | "Do not export to next AS (well-known community)\n" |
| 8582 | "Exact match of the communities") |
| 8583 | |
| 8584 | ALIAS (show_bgp_community_exact, |
| 8585 | show_bgp_community4_exact_cmd, |
| 8586 | "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", |
| 8587 | SHOW_STR |
| 8588 | BGP_STR |
| 8589 | "Display routes matching the communities\n" |
| 8590 | "community number\n" |
| 8591 | "Do not send outside local AS (well-known community)\n" |
| 8592 | "Do not advertise to any peer (well-known community)\n" |
| 8593 | "Do not export to next AS (well-known community)\n" |
| 8594 | "community number\n" |
| 8595 | "Do not send outside local AS (well-known community)\n" |
| 8596 | "Do not advertise to any peer (well-known community)\n" |
| 8597 | "Do not export to next AS (well-known community)\n" |
| 8598 | "community number\n" |
| 8599 | "Do not send outside local AS (well-known community)\n" |
| 8600 | "Do not advertise to any peer (well-known community)\n" |
| 8601 | "Do not export to next AS (well-known community)\n" |
| 8602 | "community number\n" |
| 8603 | "Do not send outside local AS (well-known community)\n" |
| 8604 | "Do not advertise to any peer (well-known community)\n" |
| 8605 | "Do not export to next AS (well-known community)\n" |
| 8606 | "Exact match of the communities") |
| 8607 | |
| 8608 | ALIAS (show_bgp_community_exact, |
| 8609 | show_bgp_ipv6_community4_exact_cmd, |
| 8610 | "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", |
| 8611 | SHOW_STR |
| 8612 | BGP_STR |
| 8613 | "Address family\n" |
| 8614 | "Display routes matching the communities\n" |
| 8615 | "community number\n" |
| 8616 | "Do not send outside local AS (well-known community)\n" |
| 8617 | "Do not advertise to any peer (well-known community)\n" |
| 8618 | "Do not export to next AS (well-known community)\n" |
| 8619 | "community number\n" |
| 8620 | "Do not send outside local AS (well-known community)\n" |
| 8621 | "Do not advertise to any peer (well-known community)\n" |
| 8622 | "Do not export to next AS (well-known community)\n" |
| 8623 | "community number\n" |
| 8624 | "Do not send outside local AS (well-known community)\n" |
| 8625 | "Do not advertise to any peer (well-known community)\n" |
| 8626 | "Do not export to next AS (well-known community)\n" |
| 8627 | "community number\n" |
| 8628 | "Do not send outside local AS (well-known community)\n" |
| 8629 | "Do not advertise to any peer (well-known community)\n" |
| 8630 | "Do not export to next AS (well-known community)\n" |
| 8631 | "Exact match of the communities") |
| 8632 | |
| 8633 | /* old command */ |
| 8634 | DEFUN (show_ipv6_bgp_community_exact, |
| 8635 | show_ipv6_bgp_community_exact_cmd, |
| 8636 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8637 | SHOW_STR |
| 8638 | IPV6_STR |
| 8639 | BGP_STR |
| 8640 | "Display routes matching the communities\n" |
| 8641 | "community number\n" |
| 8642 | "Do not send outside local AS (well-known community)\n" |
| 8643 | "Do not advertise to any peer (well-known community)\n" |
| 8644 | "Do not export to next AS (well-known community)\n" |
| 8645 | "Exact match of the communities") |
| 8646 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8647 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8648 | } |
| 8649 | |
| 8650 | /* old command */ |
| 8651 | ALIAS (show_ipv6_bgp_community_exact, |
| 8652 | show_ipv6_bgp_community2_exact_cmd, |
| 8653 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8654 | SHOW_STR |
| 8655 | IPV6_STR |
| 8656 | BGP_STR |
| 8657 | "Display routes matching the communities\n" |
| 8658 | "community number\n" |
| 8659 | "Do not send outside local AS (well-known community)\n" |
| 8660 | "Do not advertise to any peer (well-known community)\n" |
| 8661 | "Do not export to next AS (well-known community)\n" |
| 8662 | "community number\n" |
| 8663 | "Do not send outside local AS (well-known community)\n" |
| 8664 | "Do not advertise to any peer (well-known community)\n" |
| 8665 | "Do not export to next AS (well-known community)\n" |
| 8666 | "Exact match of the communities") |
| 8667 | |
| 8668 | /* old command */ |
| 8669 | ALIAS (show_ipv6_bgp_community_exact, |
| 8670 | show_ipv6_bgp_community3_exact_cmd, |
| 8671 | "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", |
| 8672 | SHOW_STR |
| 8673 | IPV6_STR |
| 8674 | BGP_STR |
| 8675 | "Display routes matching the communities\n" |
| 8676 | "community number\n" |
| 8677 | "Do not send outside local AS (well-known community)\n" |
| 8678 | "Do not advertise to any peer (well-known community)\n" |
| 8679 | "Do not export to next AS (well-known community)\n" |
| 8680 | "community number\n" |
| 8681 | "Do not send outside local AS (well-known community)\n" |
| 8682 | "Do not advertise to any peer (well-known community)\n" |
| 8683 | "Do not export to next AS (well-known community)\n" |
| 8684 | "community number\n" |
| 8685 | "Do not send outside local AS (well-known community)\n" |
| 8686 | "Do not advertise to any peer (well-known community)\n" |
| 8687 | "Do not export to next AS (well-known community)\n" |
| 8688 | "Exact match of the communities") |
| 8689 | |
| 8690 | /* old command */ |
| 8691 | ALIAS (show_ipv6_bgp_community_exact, |
| 8692 | show_ipv6_bgp_community4_exact_cmd, |
| 8693 | "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", |
| 8694 | SHOW_STR |
| 8695 | IPV6_STR |
| 8696 | BGP_STR |
| 8697 | "Display routes matching the communities\n" |
| 8698 | "community number\n" |
| 8699 | "Do not send outside local AS (well-known community)\n" |
| 8700 | "Do not advertise to any peer (well-known community)\n" |
| 8701 | "Do not export to next AS (well-known community)\n" |
| 8702 | "community number\n" |
| 8703 | "Do not send outside local AS (well-known community)\n" |
| 8704 | "Do not advertise to any peer (well-known community)\n" |
| 8705 | "Do not export to next AS (well-known community)\n" |
| 8706 | "community number\n" |
| 8707 | "Do not send outside local AS (well-known community)\n" |
| 8708 | "Do not advertise to any peer (well-known community)\n" |
| 8709 | "Do not export to next AS (well-known community)\n" |
| 8710 | "community number\n" |
| 8711 | "Do not send outside local AS (well-known community)\n" |
| 8712 | "Do not advertise to any peer (well-known community)\n" |
| 8713 | "Do not export to next AS (well-known community)\n" |
| 8714 | "Exact match of the communities") |
| 8715 | |
| 8716 | /* old command */ |
| 8717 | DEFUN (show_ipv6_mbgp_community, |
| 8718 | show_ipv6_mbgp_community_cmd, |
| 8719 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8720 | SHOW_STR |
| 8721 | IPV6_STR |
| 8722 | MBGP_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 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8729 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8730 | } |
| 8731 | |
| 8732 | /* old command */ |
| 8733 | ALIAS (show_ipv6_mbgp_community, |
| 8734 | show_ipv6_mbgp_community2_cmd, |
| 8735 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8736 | SHOW_STR |
| 8737 | IPV6_STR |
| 8738 | MBGP_STR |
| 8739 | "Display routes matching the communities\n" |
| 8740 | "community number\n" |
| 8741 | "Do not send outside local AS (well-known community)\n" |
| 8742 | "Do not advertise to any peer (well-known community)\n" |
| 8743 | "Do not export to next AS (well-known community)\n" |
| 8744 | "community number\n" |
| 8745 | "Do not send outside local AS (well-known community)\n" |
| 8746 | "Do not advertise to any peer (well-known community)\n" |
| 8747 | "Do not export to next AS (well-known community)\n") |
| 8748 | |
| 8749 | /* old command */ |
| 8750 | ALIAS (show_ipv6_mbgp_community, |
| 8751 | show_ipv6_mbgp_community3_cmd, |
| 8752 | "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)", |
| 8753 | SHOW_STR |
| 8754 | IPV6_STR |
| 8755 | MBGP_STR |
| 8756 | "Display routes matching the communities\n" |
| 8757 | "community number\n" |
| 8758 | "Do not send outside local AS (well-known community)\n" |
| 8759 | "Do not advertise to any peer (well-known community)\n" |
| 8760 | "Do not export to next AS (well-known community)\n" |
| 8761 | "community number\n" |
| 8762 | "Do not send outside local AS (well-known community)\n" |
| 8763 | "Do not advertise to any peer (well-known community)\n" |
| 8764 | "Do not export to next AS (well-known community)\n" |
| 8765 | "community number\n" |
| 8766 | "Do not send outside local AS (well-known community)\n" |
| 8767 | "Do not advertise to any peer (well-known community)\n" |
| 8768 | "Do not export to next AS (well-known community)\n") |
| 8769 | |
| 8770 | /* old command */ |
| 8771 | ALIAS (show_ipv6_mbgp_community, |
| 8772 | show_ipv6_mbgp_community4_cmd, |
| 8773 | "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)", |
| 8774 | SHOW_STR |
| 8775 | IPV6_STR |
| 8776 | MBGP_STR |
| 8777 | "Display routes matching the communities\n" |
| 8778 | "community number\n" |
| 8779 | "Do not send outside local AS (well-known community)\n" |
| 8780 | "Do not advertise to any peer (well-known community)\n" |
| 8781 | "Do not export to next AS (well-known community)\n" |
| 8782 | "community number\n" |
| 8783 | "Do not send outside local AS (well-known community)\n" |
| 8784 | "Do not advertise to any peer (well-known community)\n" |
| 8785 | "Do not export to next AS (well-known community)\n" |
| 8786 | "community number\n" |
| 8787 | "Do not send outside local AS (well-known community)\n" |
| 8788 | "Do not advertise to any peer (well-known community)\n" |
| 8789 | "Do not export to next AS (well-known community)\n" |
| 8790 | "community number\n" |
| 8791 | "Do not send outside local AS (well-known community)\n" |
| 8792 | "Do not advertise to any peer (well-known community)\n" |
| 8793 | "Do not export to next AS (well-known community)\n") |
| 8794 | |
| 8795 | /* old command */ |
| 8796 | DEFUN (show_ipv6_mbgp_community_exact, |
| 8797 | show_ipv6_mbgp_community_exact_cmd, |
| 8798 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8799 | SHOW_STR |
| 8800 | IPV6_STR |
| 8801 | MBGP_STR |
| 8802 | "Display routes matching the communities\n" |
| 8803 | "community number\n" |
| 8804 | "Do not send outside local AS (well-known community)\n" |
| 8805 | "Do not advertise to any peer (well-known community)\n" |
| 8806 | "Do not export to next AS (well-known community)\n" |
| 8807 | "Exact match of the communities") |
| 8808 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8809 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8810 | } |
| 8811 | |
| 8812 | /* old command */ |
| 8813 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8814 | show_ipv6_mbgp_community2_exact_cmd, |
| 8815 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8816 | SHOW_STR |
| 8817 | IPV6_STR |
| 8818 | MBGP_STR |
| 8819 | "Display routes matching the communities\n" |
| 8820 | "community number\n" |
| 8821 | "Do not send outside local AS (well-known community)\n" |
| 8822 | "Do not advertise to any peer (well-known community)\n" |
| 8823 | "Do not export to next AS (well-known community)\n" |
| 8824 | "community number\n" |
| 8825 | "Do not send outside local AS (well-known community)\n" |
| 8826 | "Do not advertise to any peer (well-known community)\n" |
| 8827 | "Do not export to next AS (well-known community)\n" |
| 8828 | "Exact match of the communities") |
| 8829 | |
| 8830 | /* old command */ |
| 8831 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8832 | show_ipv6_mbgp_community3_exact_cmd, |
| 8833 | "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", |
| 8834 | SHOW_STR |
| 8835 | IPV6_STR |
| 8836 | MBGP_STR |
| 8837 | "Display routes matching the communities\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 | "community number\n" |
| 8843 | "Do not send outside local AS (well-known community)\n" |
| 8844 | "Do not advertise to any peer (well-known community)\n" |
| 8845 | "Do not export to next AS (well-known community)\n" |
| 8846 | "community number\n" |
| 8847 | "Do not send outside local AS (well-known community)\n" |
| 8848 | "Do not advertise to any peer (well-known community)\n" |
| 8849 | "Do not export to next AS (well-known community)\n" |
| 8850 | "Exact match of the communities") |
| 8851 | |
| 8852 | /* old command */ |
| 8853 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8854 | show_ipv6_mbgp_community4_exact_cmd, |
| 8855 | "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", |
| 8856 | SHOW_STR |
| 8857 | IPV6_STR |
| 8858 | MBGP_STR |
| 8859 | "Display routes matching the communities\n" |
| 8860 | "community number\n" |
| 8861 | "Do not send outside local AS (well-known community)\n" |
| 8862 | "Do not advertise to any peer (well-known community)\n" |
| 8863 | "Do not export to next AS (well-known community)\n" |
| 8864 | "community number\n" |
| 8865 | "Do not send outside local AS (well-known community)\n" |
| 8866 | "Do not advertise to any peer (well-known community)\n" |
| 8867 | "Do not export to next AS (well-known community)\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 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 8878 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8879 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8880 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 8881 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8882 | { |
| 8883 | struct community_list *list; |
| 8884 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8885 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8886 | if (list == NULL) |
| 8887 | { |
| 8888 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 8889 | VTY_NEWLINE); |
| 8890 | return CMD_WARNING; |
| 8891 | } |
| 8892 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8893 | return bgp_show (vty, NULL, afi, safi, |
| 8894 | (exact ? bgp_show_type_community_list_exact : |
| 8895 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8896 | } |
| 8897 | |
| 8898 | DEFUN (show_ip_bgp_community_list, |
| 8899 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8900 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8901 | SHOW_STR |
| 8902 | IP_STR |
| 8903 | BGP_STR |
| 8904 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8905 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8906 | "community-list name\n") |
| 8907 | { |
| 8908 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 8909 | } |
| 8910 | |
| 8911 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 8912 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8913 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8914 | SHOW_STR |
| 8915 | IP_STR |
| 8916 | BGP_STR |
| 8917 | "Address family\n" |
| 8918 | "Address Family modifier\n" |
| 8919 | "Address Family modifier\n" |
| 8920 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8921 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8922 | "community-list name\n") |
| 8923 | { |
| 8924 | if (strncmp (argv[0], "m", 1) == 0) |
| 8925 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 8926 | |
| 8927 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 8928 | } |
| 8929 | |
| 8930 | DEFUN (show_ip_bgp_community_list_exact, |
| 8931 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8932 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8933 | SHOW_STR |
| 8934 | IP_STR |
| 8935 | BGP_STR |
| 8936 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8937 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8938 | "community-list name\n" |
| 8939 | "Exact match of the communities\n") |
| 8940 | { |
| 8941 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 8942 | } |
| 8943 | |
| 8944 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 8945 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8946 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8947 | SHOW_STR |
| 8948 | IP_STR |
| 8949 | BGP_STR |
| 8950 | "Address family\n" |
| 8951 | "Address Family modifier\n" |
| 8952 | "Address Family modifier\n" |
| 8953 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8954 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8955 | "community-list name\n" |
| 8956 | "Exact match of the communities\n") |
| 8957 | { |
| 8958 | if (strncmp (argv[0], "m", 1) == 0) |
| 8959 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 8960 | |
| 8961 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 8962 | } |
| 8963 | |
| 8964 | #ifdef HAVE_IPV6 |
| 8965 | DEFUN (show_bgp_community_list, |
| 8966 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8967 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8968 | SHOW_STR |
| 8969 | BGP_STR |
| 8970 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8971 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8972 | "community-list name\n") |
| 8973 | { |
| 8974 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8975 | } |
| 8976 | |
| 8977 | ALIAS (show_bgp_community_list, |
| 8978 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8979 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8980 | SHOW_STR |
| 8981 | BGP_STR |
| 8982 | "Address family\n" |
| 8983 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8984 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 8985 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8986 | |
| 8987 | /* old command */ |
| 8988 | DEFUN (show_ipv6_bgp_community_list, |
| 8989 | show_ipv6_bgp_community_list_cmd, |
| 8990 | "show ipv6 bgp community-list WORD", |
| 8991 | SHOW_STR |
| 8992 | IPV6_STR |
| 8993 | BGP_STR |
| 8994 | "Display routes matching the community-list\n" |
| 8995 | "community-list name\n") |
| 8996 | { |
| 8997 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8998 | } |
| 8999 | |
| 9000 | /* old command */ |
| 9001 | DEFUN (show_ipv6_mbgp_community_list, |
| 9002 | show_ipv6_mbgp_community_list_cmd, |
| 9003 | "show ipv6 mbgp community-list WORD", |
| 9004 | SHOW_STR |
| 9005 | IPV6_STR |
| 9006 | MBGP_STR |
| 9007 | "Display routes matching the community-list\n" |
| 9008 | "community-list name\n") |
| 9009 | { |
| 9010 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 9011 | } |
| 9012 | |
| 9013 | DEFUN (show_bgp_community_list_exact, |
| 9014 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9015 | "show bgp community-list (<1-500>|WORD) exact-match", |
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 | "Exact match of the communities\n") |
| 9022 | { |
| 9023 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9024 | } |
| 9025 | |
| 9026 | ALIAS (show_bgp_community_list_exact, |
| 9027 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9028 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9029 | SHOW_STR |
| 9030 | BGP_STR |
| 9031 | "Address family\n" |
| 9032 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9033 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9034 | "community-list name\n" |
| 9035 | "Exact match of the communities\n") |
| 9036 | |
| 9037 | /* old command */ |
| 9038 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 9039 | show_ipv6_bgp_community_list_exact_cmd, |
| 9040 | "show ipv6 bgp community-list WORD exact-match", |
| 9041 | SHOW_STR |
| 9042 | IPV6_STR |
| 9043 | BGP_STR |
| 9044 | "Display routes matching the community-list\n" |
| 9045 | "community-list name\n" |
| 9046 | "Exact match of the communities\n") |
| 9047 | { |
| 9048 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9049 | } |
| 9050 | |
| 9051 | /* old command */ |
| 9052 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 9053 | show_ipv6_mbgp_community_list_exact_cmd, |
| 9054 | "show ipv6 mbgp community-list WORD exact-match", |
| 9055 | SHOW_STR |
| 9056 | IPV6_STR |
| 9057 | MBGP_STR |
| 9058 | "Display routes matching the community-list\n" |
| 9059 | "community-list name\n" |
| 9060 | "Exact match of the communities\n") |
| 9061 | { |
| 9062 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 9063 | } |
| 9064 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9065 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9066 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9067 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9068 | safi_t safi, enum bgp_show_type type) |
| 9069 | { |
| 9070 | int ret; |
| 9071 | struct prefix *p; |
| 9072 | |
| 9073 | p = prefix_new(); |
| 9074 | |
| 9075 | ret = str2prefix (prefix, p); |
| 9076 | if (! ret) |
| 9077 | { |
| 9078 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 9079 | return CMD_WARNING; |
| 9080 | } |
| 9081 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9082 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 9083 | prefix_free(p); |
| 9084 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9085 | } |
| 9086 | |
| 9087 | DEFUN (show_ip_bgp_prefix_longer, |
| 9088 | show_ip_bgp_prefix_longer_cmd, |
| 9089 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 9090 | SHOW_STR |
| 9091 | IP_STR |
| 9092 | BGP_STR |
| 9093 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9094 | "Display route and more specific routes\n") |
| 9095 | { |
| 9096 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9097 | bgp_show_type_prefix_longer); |
| 9098 | } |
| 9099 | |
| 9100 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 9101 | show_ip_bgp_flap_prefix_longer_cmd, |
| 9102 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 9103 | SHOW_STR |
| 9104 | IP_STR |
| 9105 | BGP_STR |
| 9106 | "Display flap statistics of routes\n" |
| 9107 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9108 | "Display route and more specific routes\n") |
| 9109 | { |
| 9110 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9111 | bgp_show_type_flap_prefix_longer); |
| 9112 | } |
| 9113 | |
| 9114 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 9115 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 9116 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 9117 | SHOW_STR |
| 9118 | IP_STR |
| 9119 | BGP_STR |
| 9120 | "Address family\n" |
| 9121 | "Address Family modifier\n" |
| 9122 | "Address Family modifier\n" |
| 9123 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9124 | "Display route and more specific routes\n") |
| 9125 | { |
| 9126 | if (strncmp (argv[0], "m", 1) == 0) |
| 9127 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 9128 | bgp_show_type_prefix_longer); |
| 9129 | |
| 9130 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 9131 | bgp_show_type_prefix_longer); |
| 9132 | } |
| 9133 | |
| 9134 | DEFUN (show_ip_bgp_flap_address, |
| 9135 | show_ip_bgp_flap_address_cmd, |
| 9136 | "show ip bgp flap-statistics A.B.C.D", |
| 9137 | SHOW_STR |
| 9138 | IP_STR |
| 9139 | BGP_STR |
| 9140 | "Display flap statistics of routes\n" |
| 9141 | "Network in the BGP routing table to display\n") |
| 9142 | { |
| 9143 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9144 | bgp_show_type_flap_address); |
| 9145 | } |
| 9146 | |
| 9147 | DEFUN (show_ip_bgp_flap_prefix, |
| 9148 | show_ip_bgp_flap_prefix_cmd, |
| 9149 | "show ip bgp flap-statistics A.B.C.D/M", |
| 9150 | SHOW_STR |
| 9151 | IP_STR |
| 9152 | BGP_STR |
| 9153 | "Display flap statistics of routes\n" |
| 9154 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9155 | { |
| 9156 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9157 | bgp_show_type_flap_prefix); |
| 9158 | } |
| 9159 | #ifdef HAVE_IPV6 |
| 9160 | DEFUN (show_bgp_prefix_longer, |
| 9161 | show_bgp_prefix_longer_cmd, |
| 9162 | "show bgp X:X::X:X/M longer-prefixes", |
| 9163 | SHOW_STR |
| 9164 | BGP_STR |
| 9165 | "IPv6 prefix <network>/<length>\n" |
| 9166 | "Display route and more specific routes\n") |
| 9167 | { |
| 9168 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9169 | bgp_show_type_prefix_longer); |
| 9170 | } |
| 9171 | |
| 9172 | ALIAS (show_bgp_prefix_longer, |
| 9173 | show_bgp_ipv6_prefix_longer_cmd, |
| 9174 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 9175 | SHOW_STR |
| 9176 | BGP_STR |
| 9177 | "Address family\n" |
| 9178 | "IPv6 prefix <network>/<length>\n" |
| 9179 | "Display route and more specific routes\n") |
| 9180 | |
| 9181 | /* old command */ |
| 9182 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 9183 | show_ipv6_bgp_prefix_longer_cmd, |
| 9184 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 9185 | SHOW_STR |
| 9186 | IPV6_STR |
| 9187 | BGP_STR |
| 9188 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9189 | "Display route and more specific routes\n") |
| 9190 | { |
| 9191 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9192 | bgp_show_type_prefix_longer); |
| 9193 | } |
| 9194 | |
| 9195 | /* old command */ |
| 9196 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 9197 | show_ipv6_mbgp_prefix_longer_cmd, |
| 9198 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 9199 | SHOW_STR |
| 9200 | IPV6_STR |
| 9201 | MBGP_STR |
| 9202 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9203 | "Display route and more specific routes\n") |
| 9204 | { |
| 9205 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 9206 | bgp_show_type_prefix_longer); |
| 9207 | } |
| 9208 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9209 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9210 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9211 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 9212 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9213 | { |
| 9214 | int ret; |
| 9215 | struct bgp *bgp; |
| 9216 | struct peer *peer; |
| 9217 | union sockunion su; |
| 9218 | |
| 9219 | /* BGP structure lookup. */ |
| 9220 | if (view_name) |
| 9221 | { |
| 9222 | bgp = bgp_lookup_by_name (view_name); |
| 9223 | if (! bgp) |
| 9224 | { |
| 9225 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9226 | return NULL; |
| 9227 | } |
| 9228 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 9229 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9230 | { |
| 9231 | bgp = bgp_get_default (); |
| 9232 | if (! bgp) |
| 9233 | { |
| 9234 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9235 | return NULL; |
| 9236 | } |
| 9237 | } |
| 9238 | |
| 9239 | /* Get peer sockunion. */ |
| 9240 | ret = str2sockunion (ip_str, &su); |
| 9241 | if (ret < 0) |
| 9242 | { |
| 9243 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 9244 | return NULL; |
| 9245 | } |
| 9246 | |
| 9247 | /* Peer structure lookup. */ |
| 9248 | peer = peer_lookup (bgp, &su); |
| 9249 | if (! peer) |
| 9250 | { |
| 9251 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 9252 | return NULL; |
| 9253 | } |
| 9254 | |
| 9255 | return peer; |
| 9256 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9257 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9258 | enum bgp_stats |
| 9259 | { |
| 9260 | BGP_STATS_MAXBITLEN = 0, |
| 9261 | BGP_STATS_RIB, |
| 9262 | BGP_STATS_PREFIXES, |
| 9263 | BGP_STATS_TOTPLEN, |
| 9264 | BGP_STATS_UNAGGREGATEABLE, |
| 9265 | BGP_STATS_MAX_AGGREGATEABLE, |
| 9266 | BGP_STATS_AGGREGATES, |
| 9267 | BGP_STATS_SPACE, |
| 9268 | BGP_STATS_ASPATH_COUNT, |
| 9269 | BGP_STATS_ASPATH_MAXHOPS, |
| 9270 | BGP_STATS_ASPATH_TOTHOPS, |
| 9271 | BGP_STATS_ASPATH_MAXSIZE, |
| 9272 | BGP_STATS_ASPATH_TOTSIZE, |
| 9273 | BGP_STATS_ASN_HIGHEST, |
| 9274 | BGP_STATS_MAX, |
| 9275 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9276 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9277 | static const char *table_stats_strs[] = |
| 9278 | { |
| 9279 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 9280 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 9281 | [BGP_STATS_RIB] = "Total Advertisements", |
| 9282 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 9283 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 9284 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 9285 | [BGP_STATS_SPACE] = "Address space advertised", |
| 9286 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 9287 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 9288 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 9289 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 9290 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 9291 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 9292 | [BGP_STATS_MAX] = NULL, |
| 9293 | }; |
| 9294 | |
| 9295 | struct bgp_table_stats |
| 9296 | { |
| 9297 | struct bgp_table *table; |
| 9298 | unsigned long long counts[BGP_STATS_MAX]; |
| 9299 | }; |
| 9300 | |
| 9301 | #if 0 |
| 9302 | #define TALLY_SIGFIG 100000 |
| 9303 | static unsigned long |
| 9304 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 9305 | { |
| 9306 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 9307 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 9308 | unsigned long ret = newtot / count; |
| 9309 | |
| 9310 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 9311 | return ret + 1; |
| 9312 | else |
| 9313 | return ret; |
| 9314 | } |
| 9315 | #endif |
| 9316 | |
| 9317 | static int |
| 9318 | bgp_table_stats_walker (struct thread *t) |
| 9319 | { |
| 9320 | struct bgp_node *rn; |
| 9321 | struct bgp_node *top; |
| 9322 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 9323 | unsigned int space = 0; |
| 9324 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 9325 | if (!(top = bgp_table_top (ts->table))) |
| 9326 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9327 | |
| 9328 | switch (top->p.family) |
| 9329 | { |
| 9330 | case AF_INET: |
| 9331 | space = IPV4_MAX_BITLEN; |
| 9332 | break; |
| 9333 | case AF_INET6: |
| 9334 | space = IPV6_MAX_BITLEN; |
| 9335 | break; |
| 9336 | } |
| 9337 | |
| 9338 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 9339 | |
| 9340 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 9341 | { |
| 9342 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9343 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9344 | unsigned int rinum = 0; |
| 9345 | |
| 9346 | if (rn == top) |
| 9347 | continue; |
| 9348 | |
| 9349 | if (!rn->info) |
| 9350 | continue; |
| 9351 | |
| 9352 | ts->counts[BGP_STATS_PREFIXES]++; |
| 9353 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 9354 | |
| 9355 | #if 0 |
| 9356 | ts->counts[BGP_STATS_AVGPLEN] |
| 9357 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 9358 | ts->counts[BGP_STATS_AVGPLEN], |
| 9359 | rn->p.prefixlen); |
| 9360 | #endif |
| 9361 | |
| 9362 | /* check if the prefix is included by any other announcements */ |
| 9363 | while (prn && !prn->info) |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9364 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9365 | |
| 9366 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 9367 | { |
| 9368 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 9369 | /* announced address space */ |
| 9370 | if (space) |
| 9371 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 9372 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9373 | else if (prn->info) |
| 9374 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 9375 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9376 | for (ri = rn->info; ri; ri = ri->next) |
| 9377 | { |
| 9378 | rinum++; |
| 9379 | ts->counts[BGP_STATS_RIB]++; |
| 9380 | |
| 9381 | if (ri->attr && |
| 9382 | (CHECK_FLAG (ri->attr->flag, |
| 9383 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 9384 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 9385 | |
| 9386 | /* as-path stats */ |
| 9387 | if (ri->attr && ri->attr->aspath) |
| 9388 | { |
| 9389 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 9390 | unsigned int size = aspath_size (ri->attr->aspath); |
| 9391 | as_t highest = aspath_highest (ri->attr->aspath); |
| 9392 | |
| 9393 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 9394 | |
| 9395 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 9396 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 9397 | |
| 9398 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 9399 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 9400 | |
| 9401 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 9402 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 9403 | #if 0 |
| 9404 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 9405 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9406 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 9407 | hops); |
| 9408 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 9409 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9410 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 9411 | size); |
| 9412 | #endif |
| 9413 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 9414 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 9415 | } |
| 9416 | } |
| 9417 | } |
| 9418 | return 0; |
| 9419 | } |
| 9420 | |
| 9421 | static int |
| 9422 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 9423 | { |
| 9424 | struct bgp_table_stats ts; |
| 9425 | unsigned int i; |
| 9426 | |
| 9427 | if (!bgp->rib[afi][safi]) |
| 9428 | { |
| 9429 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); |
| 9430 | return CMD_WARNING; |
| 9431 | } |
| 9432 | |
| 9433 | memset (&ts, 0, sizeof (ts)); |
| 9434 | ts.table = bgp->rib[afi][safi]; |
| 9435 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 9436 | |
| 9437 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 9438 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 9439 | |
| 9440 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 9441 | { |
| 9442 | if (!table_stats_strs[i]) |
| 9443 | continue; |
| 9444 | |
| 9445 | switch (i) |
| 9446 | { |
| 9447 | #if 0 |
| 9448 | case BGP_STATS_ASPATH_AVGHOPS: |
| 9449 | case BGP_STATS_ASPATH_AVGSIZE: |
| 9450 | case BGP_STATS_AVGPLEN: |
| 9451 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9452 | vty_out (vty, "%12.2f", |
| 9453 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 9454 | break; |
| 9455 | #endif |
| 9456 | case BGP_STATS_ASPATH_TOTHOPS: |
| 9457 | case BGP_STATS_ASPATH_TOTSIZE: |
| 9458 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9459 | vty_out (vty, "%12.2f", |
| 9460 | ts.counts[i] ? |
| 9461 | (float)ts.counts[i] / |
| 9462 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 9463 | : 0); |
| 9464 | break; |
| 9465 | case BGP_STATS_TOTPLEN: |
| 9466 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9467 | vty_out (vty, "%12.2f", |
| 9468 | ts.counts[i] ? |
| 9469 | (float)ts.counts[i] / |
| 9470 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 9471 | : 0); |
| 9472 | break; |
| 9473 | case BGP_STATS_SPACE: |
| 9474 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9475 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 9476 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 9477 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 9478 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9479 | vty_out (vty, "%12.2f%s", |
| 9480 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 9481 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9482 | VTY_NEWLINE); |
| 9483 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 9484 | vty_out (vty, "%12.2f%s", |
| 9485 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9486 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 9487 | VTY_NEWLINE); |
| 9488 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 9489 | break; |
| 9490 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 9491 | vty_out (vty, "%12.2f", |
| 9492 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9493 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 9494 | break; |
| 9495 | default: |
| 9496 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9497 | vty_out (vty, "%12llu", ts.counts[i]); |
| 9498 | } |
| 9499 | |
| 9500 | vty_out (vty, "%s", VTY_NEWLINE); |
| 9501 | } |
| 9502 | return CMD_SUCCESS; |
| 9503 | } |
| 9504 | |
| 9505 | static int |
| 9506 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 9507 | const char *afi_str, const char *safi_str) |
| 9508 | { |
| 9509 | struct bgp *bgp; |
| 9510 | afi_t afi; |
| 9511 | safi_t safi; |
| 9512 | |
| 9513 | if (name) |
| 9514 | bgp = bgp_lookup_by_name (name); |
| 9515 | else |
| 9516 | bgp = bgp_get_default (); |
| 9517 | |
| 9518 | if (!bgp) |
| 9519 | { |
| 9520 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); |
| 9521 | return CMD_WARNING; |
| 9522 | } |
| 9523 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 9524 | { |
| 9525 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 9526 | afi = AFI_IP; |
| 9527 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 9528 | afi = AFI_IP6; |
| 9529 | else |
| 9530 | { |
| 9531 | vty_out (vty, "%% Invalid address family %s%s", |
| 9532 | afi_str, VTY_NEWLINE); |
| 9533 | return CMD_WARNING; |
| 9534 | } |
| 9535 | if (strncmp (safi_str, "m", 1) == 0) |
| 9536 | safi = SAFI_MULTICAST; |
| 9537 | else if (strncmp (safi_str, "u", 1) == 0) |
| 9538 | safi = SAFI_UNICAST; |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 9539 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
| 9540 | safi = SAFI_MPLS_LABELED_VPN; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9541 | else |
| 9542 | { |
| 9543 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
| 9544 | safi_str, VTY_NEWLINE); |
| 9545 | return CMD_WARNING; |
| 9546 | } |
| 9547 | } |
| 9548 | else |
| 9549 | { |
| 9550 | vty_out (vty, "%% Invalid address family %s%s", |
| 9551 | afi_str, VTY_NEWLINE); |
| 9552 | return CMD_WARNING; |
| 9553 | } |
| 9554 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9555 | return bgp_table_stats (vty, bgp, afi, safi); |
| 9556 | } |
| 9557 | |
| 9558 | DEFUN (show_bgp_statistics, |
| 9559 | show_bgp_statistics_cmd, |
| 9560 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", |
| 9561 | SHOW_STR |
| 9562 | BGP_STR |
| 9563 | "Address family\n" |
| 9564 | "Address family\n" |
| 9565 | "Address Family modifier\n" |
| 9566 | "Address Family modifier\n" |
| 9567 | "BGP RIB advertisement statistics\n") |
| 9568 | { |
| 9569 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9570 | } |
| 9571 | |
| 9572 | ALIAS (show_bgp_statistics, |
| 9573 | show_bgp_statistics_vpnv4_cmd, |
| 9574 | "show bgp (ipv4) (vpnv4) statistics", |
| 9575 | SHOW_STR |
| 9576 | BGP_STR |
| 9577 | "Address family\n" |
| 9578 | "Address Family modifier\n" |
| 9579 | "BGP RIB advertisement statistics\n") |
| 9580 | |
| 9581 | DEFUN (show_bgp_statistics_view, |
| 9582 | show_bgp_statistics_view_cmd, |
| 9583 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", |
| 9584 | SHOW_STR |
| 9585 | BGP_STR |
| 9586 | "BGP view\n" |
| 9587 | "Address family\n" |
| 9588 | "Address family\n" |
| 9589 | "Address Family modifier\n" |
| 9590 | "Address Family modifier\n" |
| 9591 | "BGP RIB advertisement statistics\n") |
| 9592 | { |
| 9593 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9594 | } |
| 9595 | |
| 9596 | ALIAS (show_bgp_statistics_view, |
| 9597 | show_bgp_statistics_view_vpnv4_cmd, |
| 9598 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
| 9599 | SHOW_STR |
| 9600 | BGP_STR |
| 9601 | "BGP view\n" |
| 9602 | "Address family\n" |
| 9603 | "Address Family modifier\n" |
| 9604 | "BGP RIB advertisement statistics\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9605 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9606 | enum bgp_pcounts |
| 9607 | { |
| 9608 | PCOUNT_ADJ_IN = 0, |
| 9609 | PCOUNT_DAMPED, |
| 9610 | PCOUNT_REMOVED, |
| 9611 | PCOUNT_HISTORY, |
| 9612 | PCOUNT_STALE, |
| 9613 | PCOUNT_VALID, |
| 9614 | PCOUNT_ALL, |
| 9615 | PCOUNT_COUNTED, |
| 9616 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 9617 | PCOUNT_MAX, |
| 9618 | }; |
| 9619 | |
| 9620 | static const char *pcount_strs[] = |
| 9621 | { |
| 9622 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 9623 | [PCOUNT_DAMPED] = "Damped", |
| 9624 | [PCOUNT_REMOVED] = "Removed", |
| 9625 | [PCOUNT_HISTORY] = "History", |
| 9626 | [PCOUNT_STALE] = "Stale", |
| 9627 | [PCOUNT_VALID] = "Valid", |
| 9628 | [PCOUNT_ALL] = "All RIB", |
| 9629 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 9630 | [PCOUNT_PFCNT] = "Useable", |
| 9631 | [PCOUNT_MAX] = NULL, |
| 9632 | }; |
| 9633 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9634 | struct peer_pcounts |
| 9635 | { |
| 9636 | unsigned int count[PCOUNT_MAX]; |
| 9637 | const struct peer *peer; |
| 9638 | const struct bgp_table *table; |
| 9639 | }; |
| 9640 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9641 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9642 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9643 | { |
| 9644 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9645 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 9646 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9647 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9648 | 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] | 9649 | { |
| 9650 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9651 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9652 | |
| 9653 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9654 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9655 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9656 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9657 | for (ri = rn->info; ri; ri = ri->next) |
| 9658 | { |
| 9659 | char buf[SU_ADDRSTRLEN]; |
| 9660 | |
| 9661 | if (ri->peer != peer) |
| 9662 | continue; |
| 9663 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9664 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9665 | |
| 9666 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9667 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9668 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9669 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9670 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9671 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9672 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9673 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9674 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9675 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9676 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9677 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9678 | |
| 9679 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 9680 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9681 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9682 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9683 | plog_warn (peer->log, |
| 9684 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 9685 | peer->host, |
| 9686 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9687 | buf, SU_ADDRSTRLEN), |
| 9688 | rn->p.prefixlen, |
| 9689 | ri->flags); |
| 9690 | } |
| 9691 | else |
| 9692 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9693 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9694 | plog_warn (peer->log, |
| 9695 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 9696 | peer->host, |
| 9697 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9698 | buf, SU_ADDRSTRLEN), |
| 9699 | rn->p.prefixlen, |
| 9700 | ri->flags); |
| 9701 | } |
| 9702 | } |
| 9703 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9704 | return 0; |
| 9705 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9706 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9707 | static int |
| 9708 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 9709 | { |
| 9710 | struct peer_pcounts pcounts = { .peer = peer }; |
| 9711 | unsigned int i; |
| 9712 | |
| 9713 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 9714 | || !peer->bgp->rib[afi][safi]) |
| 9715 | { |
| 9716 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9717 | return CMD_WARNING; |
| 9718 | } |
| 9719 | |
| 9720 | memset (&pcounts, 0, sizeof(pcounts)); |
| 9721 | pcounts.peer = peer; |
| 9722 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 9723 | |
| 9724 | /* in-place call via thread subsystem so as to record execution time |
| 9725 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 9726 | * on just vty_read()). |
| 9727 | */ |
| 9728 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 9729 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9730 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 9731 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 9732 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 9733 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 9734 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 9735 | |
| 9736 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9737 | vty_out (vty, "%20s: %-10d%s", |
| 9738 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9739 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9740 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9741 | { |
| 9742 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 9743 | peer->host, VTY_NEWLINE); |
| 9744 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 9745 | VTY_NEWLINE); |
| 9746 | } |
| 9747 | |
| 9748 | return CMD_SUCCESS; |
| 9749 | } |
| 9750 | |
| 9751 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 9752 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 9753 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9754 | SHOW_STR |
| 9755 | IP_STR |
| 9756 | BGP_STR |
| 9757 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9758 | "Neighbor to display information about\n" |
| 9759 | "Neighbor to display information about\n" |
| 9760 | "Display detailed prefix count information\n") |
| 9761 | { |
| 9762 | struct peer *peer; |
| 9763 | |
| 9764 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9765 | if (! peer) |
| 9766 | return CMD_WARNING; |
| 9767 | |
| 9768 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9769 | } |
| 9770 | |
| 9771 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 9772 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 9773 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9774 | SHOW_STR |
| 9775 | BGP_STR |
| 9776 | "Address family\n" |
| 9777 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9778 | "Neighbor to display information about\n" |
| 9779 | "Neighbor to display information about\n" |
| 9780 | "Display detailed prefix count information\n") |
| 9781 | { |
| 9782 | struct peer *peer; |
| 9783 | |
| 9784 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9785 | if (! peer) |
| 9786 | return CMD_WARNING; |
| 9787 | |
| 9788 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 9789 | } |
| 9790 | |
| 9791 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 9792 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 9793 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9794 | SHOW_STR |
| 9795 | IP_STR |
| 9796 | BGP_STR |
| 9797 | "Address family\n" |
| 9798 | "Address Family modifier\n" |
| 9799 | "Address Family modifier\n" |
| 9800 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9801 | "Neighbor to display information about\n" |
| 9802 | "Neighbor to display information about\n" |
| 9803 | "Display detailed prefix count information\n") |
| 9804 | { |
| 9805 | struct peer *peer; |
| 9806 | |
| 9807 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9808 | if (! peer) |
| 9809 | return CMD_WARNING; |
| 9810 | |
| 9811 | if (strncmp (argv[0], "m", 1) == 0) |
| 9812 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 9813 | |
| 9814 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9815 | } |
| 9816 | |
| 9817 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 9818 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 9819 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9820 | SHOW_STR |
| 9821 | IP_STR |
| 9822 | BGP_STR |
| 9823 | "Address family\n" |
| 9824 | "Address Family modifier\n" |
| 9825 | "Address Family modifier\n" |
| 9826 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9827 | "Neighbor to display information about\n" |
| 9828 | "Neighbor to display information about\n" |
| 9829 | "Display detailed prefix count information\n") |
| 9830 | { |
| 9831 | struct peer *peer; |
| 9832 | |
| 9833 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9834 | if (! peer) |
| 9835 | return CMD_WARNING; |
| 9836 | |
| 9837 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 9838 | } |
| 9839 | |
| 9840 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9841 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9842 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 9843 | int in) |
| 9844 | { |
| 9845 | struct bgp_table *table; |
| 9846 | struct bgp_adj_in *ain; |
| 9847 | struct bgp_adj_out *adj; |
| 9848 | unsigned long output_count; |
| 9849 | struct bgp_node *rn; |
| 9850 | int header1 = 1; |
| 9851 | struct bgp *bgp; |
| 9852 | int header2 = 1; |
| 9853 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9854 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9855 | |
| 9856 | if (! bgp) |
| 9857 | return; |
| 9858 | |
| 9859 | table = bgp->rib[afi][safi]; |
| 9860 | |
| 9861 | output_count = 0; |
| 9862 | |
| 9863 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 9864 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 9865 | { |
| 9866 | 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] | 9867 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9868 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9869 | |
| 9870 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 9871 | VTY_NEWLINE, VTY_NEWLINE); |
| 9872 | header1 = 0; |
| 9873 | } |
| 9874 | |
| 9875 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 9876 | if (in) |
| 9877 | { |
| 9878 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9879 | if (ain->peer == peer) |
| 9880 | { |
| 9881 | if (header1) |
| 9882 | { |
| 9883 | 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] | 9884 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9885 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9886 | header1 = 0; |
| 9887 | } |
| 9888 | if (header2) |
| 9889 | { |
| 9890 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9891 | header2 = 0; |
| 9892 | } |
| 9893 | if (ain->attr) |
| 9894 | { |
| 9895 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 9896 | output_count++; |
| 9897 | } |
| 9898 | } |
| 9899 | } |
| 9900 | else |
| 9901 | { |
| 9902 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 9903 | if (adj->peer == peer) |
| 9904 | { |
| 9905 | if (header1) |
| 9906 | { |
| 9907 | 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] | 9908 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9909 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9910 | header1 = 0; |
| 9911 | } |
| 9912 | if (header2) |
| 9913 | { |
| 9914 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9915 | header2 = 0; |
| 9916 | } |
| 9917 | if (adj->attr) |
| 9918 | { |
| 9919 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 9920 | output_count++; |
| 9921 | } |
| 9922 | } |
| 9923 | } |
| 9924 | |
| 9925 | if (output_count != 0) |
| 9926 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 9927 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 9928 | } |
| 9929 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9930 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9931 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 9932 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9933 | if (! peer || ! peer->afc[afi][safi]) |
| 9934 | { |
| 9935 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9936 | return CMD_WARNING; |
| 9937 | } |
| 9938 | |
| 9939 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 9940 | { |
| 9941 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 9942 | VTY_NEWLINE); |
| 9943 | return CMD_WARNING; |
| 9944 | } |
| 9945 | |
| 9946 | show_adj_route (vty, peer, afi, safi, in); |
| 9947 | |
| 9948 | return CMD_SUCCESS; |
| 9949 | } |
| 9950 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 9951 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 9952 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 9953 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9954 | SHOW_STR |
| 9955 | IP_STR |
| 9956 | BGP_STR |
| 9957 | "BGP view\n" |
| 9958 | "View name\n" |
| 9959 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9960 | "Neighbor to display information about\n" |
| 9961 | "Neighbor to display information about\n" |
| 9962 | "Display the routes advertised to a BGP neighbor\n") |
| 9963 | { |
| 9964 | struct peer *peer; |
| 9965 | |
| 9966 | if (argc == 2) |
| 9967 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9968 | else |
| 9969 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9970 | |
| 9971 | if (! peer) |
| 9972 | return CMD_WARNING; |
| 9973 | |
| 9974 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 9975 | } |
| 9976 | |
| 9977 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9978 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 9979 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9980 | SHOW_STR |
| 9981 | IP_STR |
| 9982 | BGP_STR |
| 9983 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9984 | "Neighbor to display information about\n" |
| 9985 | "Neighbor to display information about\n" |
| 9986 | "Display the routes advertised to a BGP neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9987 | |
| 9988 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 9989 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 9990 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9991 | SHOW_STR |
| 9992 | IP_STR |
| 9993 | BGP_STR |
| 9994 | "Address family\n" |
| 9995 | "Address Family modifier\n" |
| 9996 | "Address Family modifier\n" |
| 9997 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9998 | "Neighbor to display information about\n" |
| 9999 | "Neighbor to display information about\n" |
| 10000 | "Display the routes advertised to a BGP neighbor\n") |
| 10001 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10002 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10003 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10004 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10005 | if (! peer) |
| 10006 | return CMD_WARNING; |
| 10007 | |
| 10008 | if (strncmp (argv[0], "m", 1) == 0) |
| 10009 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 10010 | |
| 10011 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10012 | } |
| 10013 | |
| 10014 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10015 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 10016 | show_bgp_view_neighbor_advertised_route_cmd, |
| 10017 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10018 | SHOW_STR |
| 10019 | BGP_STR |
| 10020 | "BGP view\n" |
| 10021 | "View name\n" |
| 10022 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10023 | "Neighbor to display information about\n" |
| 10024 | "Neighbor to display information about\n" |
| 10025 | "Display the routes advertised to a BGP neighbor\n") |
| 10026 | { |
| 10027 | struct peer *peer; |
| 10028 | |
| 10029 | if (argc == 2) |
| 10030 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10031 | else |
| 10032 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10033 | |
| 10034 | if (! peer) |
| 10035 | return CMD_WARNING; |
| 10036 | |
| 10037 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 10038 | } |
| 10039 | |
| 10040 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 10041 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 10042 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10043 | SHOW_STR |
| 10044 | BGP_STR |
| 10045 | "BGP view\n" |
| 10046 | "View name\n" |
| 10047 | "Address family\n" |
| 10048 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10049 | "Neighbor to display information about\n" |
| 10050 | "Neighbor to display information about\n" |
| 10051 | "Display the routes advertised to a BGP neighbor\n") |
| 10052 | |
| 10053 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 10054 | show_bgp_view_neighbor_received_routes_cmd, |
| 10055 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10056 | SHOW_STR |
| 10057 | BGP_STR |
| 10058 | "BGP view\n" |
| 10059 | "View name\n" |
| 10060 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10061 | "Neighbor to display information about\n" |
| 10062 | "Neighbor to display information about\n" |
| 10063 | "Display the received routes from neighbor\n") |
| 10064 | { |
| 10065 | struct peer *peer; |
| 10066 | |
| 10067 | if (argc == 2) |
| 10068 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10069 | else |
| 10070 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10071 | |
| 10072 | if (! peer) |
| 10073 | return CMD_WARNING; |
| 10074 | |
| 10075 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 10076 | } |
| 10077 | |
| 10078 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 10079 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 10080 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10081 | SHOW_STR |
| 10082 | BGP_STR |
| 10083 | "BGP view\n" |
| 10084 | "View name\n" |
| 10085 | "Address family\n" |
| 10086 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10087 | "Neighbor to display information about\n" |
| 10088 | "Neighbor to display information about\n" |
| 10089 | "Display the received routes from neighbor\n") |
| 10090 | |
| 10091 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10092 | show_bgp_neighbor_advertised_route_cmd, |
| 10093 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10094 | SHOW_STR |
| 10095 | BGP_STR |
| 10096 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10097 | "Neighbor to display information about\n" |
| 10098 | "Neighbor to display information about\n" |
| 10099 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10100 | |
| 10101 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10102 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 10103 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10104 | SHOW_STR |
| 10105 | BGP_STR |
| 10106 | "Address family\n" |
| 10107 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10108 | "Neighbor to display information about\n" |
| 10109 | "Neighbor to display information about\n" |
| 10110 | "Display the routes advertised to a BGP neighbor\n") |
| 10111 | |
| 10112 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10113 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10114 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 10115 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10116 | SHOW_STR |
| 10117 | IPV6_STR |
| 10118 | BGP_STR |
| 10119 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10120 | "Neighbor to display information about\n" |
| 10121 | "Neighbor to display information about\n" |
| 10122 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10123 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10124 | /* old command */ |
| 10125 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 10126 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 10127 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10128 | SHOW_STR |
| 10129 | IPV6_STR |
| 10130 | MBGP_STR |
| 10131 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10132 | "Neighbor to display information about\n" |
| 10133 | "Neighbor to display information about\n" |
| 10134 | "Display the routes advertised to a BGP neighbor\n") |
| 10135 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10136 | struct peer *peer; |
| 10137 | |
| 10138 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10139 | if (! peer) |
| 10140 | return CMD_WARNING; |
| 10141 | |
| 10142 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10143 | } |
| 10144 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 10145 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10146 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 10147 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 10148 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10149 | SHOW_STR |
| 10150 | IP_STR |
| 10151 | BGP_STR |
| 10152 | "BGP view\n" |
| 10153 | "View name\n" |
| 10154 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10155 | "Neighbor to display information about\n" |
| 10156 | "Neighbor to display information about\n" |
| 10157 | "Display the received routes from neighbor\n") |
| 10158 | { |
| 10159 | struct peer *peer; |
| 10160 | |
| 10161 | if (argc == 2) |
| 10162 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10163 | else |
| 10164 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10165 | |
| 10166 | if (! peer) |
| 10167 | return CMD_WARNING; |
| 10168 | |
| 10169 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 10170 | } |
| 10171 | |
| 10172 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10173 | show_ip_bgp_neighbor_received_routes_cmd, |
| 10174 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10175 | SHOW_STR |
| 10176 | IP_STR |
| 10177 | BGP_STR |
| 10178 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10179 | "Neighbor to display information about\n" |
| 10180 | "Neighbor to display information about\n" |
| 10181 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10182 | |
| 10183 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 10184 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 10185 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10186 | SHOW_STR |
| 10187 | IP_STR |
| 10188 | BGP_STR |
| 10189 | "Address family\n" |
| 10190 | "Address Family modifier\n" |
| 10191 | "Address Family modifier\n" |
| 10192 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10193 | "Neighbor to display information about\n" |
| 10194 | "Neighbor to display information about\n" |
| 10195 | "Display the received routes from neighbor\n") |
| 10196 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10197 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10198 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10199 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10200 | if (! peer) |
| 10201 | return CMD_WARNING; |
| 10202 | |
| 10203 | if (strncmp (argv[0], "m", 1) == 0) |
| 10204 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 10205 | |
| 10206 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10207 | } |
| 10208 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10209 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 10210 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
| 10211 | #ifdef HAVE_IPV6 |
| 10212 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
| 10213 | #else |
| 10214 | "show bgp view WORD ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
| 10215 | #endif |
| 10216 | SHOW_STR |
| 10217 | BGP_STR |
| 10218 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10219 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10220 | "Address family\n" |
| 10221 | #ifdef HAVE_IPV6 |
| 10222 | "Address family\n" |
| 10223 | #endif |
| 10224 | "Address family modifier\n" |
| 10225 | "Address family modifier\n" |
| 10226 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10227 | "Neighbor to display information about\n" |
| 10228 | "Neighbor to display information about\n" |
| 10229 | "Display the advertised routes to neighbor\n" |
| 10230 | "Display the received routes from neighbor\n") |
| 10231 | { |
| 10232 | int afi; |
| 10233 | int safi; |
| 10234 | int in; |
| 10235 | struct peer *peer; |
| 10236 | |
| 10237 | #ifdef HAVE_IPV6 |
| 10238 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
| 10239 | #else |
| 10240 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10241 | #endif |
| 10242 | |
| 10243 | if (! peer) |
| 10244 | return CMD_WARNING; |
| 10245 | |
| 10246 | #ifdef HAVE_IPV6 |
| 10247 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10248 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10249 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
| 10250 | #else |
| 10251 | afi = AFI_IP; |
| 10252 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10253 | in = (strncmp (argv[3], "r", 1) == 0) ? 1 : 0; |
| 10254 | #endif |
| 10255 | |
| 10256 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 10257 | } |
| 10258 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10259 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 10260 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 10261 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10262 | SHOW_STR |
| 10263 | IP_STR |
| 10264 | BGP_STR |
| 10265 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10266 | "Neighbor to display information about\n" |
| 10267 | "Neighbor to display information about\n" |
| 10268 | "Display information received from a BGP neighbor\n" |
| 10269 | "Display the prefixlist filter\n") |
| 10270 | { |
| 10271 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10272 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10273 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10274 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10275 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10276 | ret = str2sockunion (argv[0], &su); |
| 10277 | if (ret < 0) |
| 10278 | { |
| 10279 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10280 | return CMD_WARNING; |
| 10281 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10282 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10283 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10284 | if (! peer) |
| 10285 | return CMD_WARNING; |
| 10286 | |
| 10287 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10288 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10289 | if (count) |
| 10290 | { |
| 10291 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10292 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10293 | } |
| 10294 | |
| 10295 | return CMD_SUCCESS; |
| 10296 | } |
| 10297 | |
| 10298 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 10299 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 10300 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10301 | SHOW_STR |
| 10302 | IP_STR |
| 10303 | BGP_STR |
| 10304 | "Address family\n" |
| 10305 | "Address Family modifier\n" |
| 10306 | "Address Family modifier\n" |
| 10307 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10308 | "Neighbor to display information about\n" |
| 10309 | "Neighbor to display information about\n" |
| 10310 | "Display information received from a BGP neighbor\n" |
| 10311 | "Display the prefixlist filter\n") |
| 10312 | { |
| 10313 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10314 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10315 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10316 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10317 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10318 | ret = str2sockunion (argv[1], &su); |
| 10319 | if (ret < 0) |
| 10320 | { |
| 10321 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10322 | return CMD_WARNING; |
| 10323 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10324 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10325 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10326 | if (! peer) |
| 10327 | return CMD_WARNING; |
| 10328 | |
| 10329 | if (strncmp (argv[0], "m", 1) == 0) |
| 10330 | { |
| 10331 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 10332 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10333 | if (count) |
| 10334 | { |
| 10335 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 10336 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10337 | } |
| 10338 | } |
| 10339 | else |
| 10340 | { |
| 10341 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10342 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10343 | if (count) |
| 10344 | { |
| 10345 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10346 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10347 | } |
| 10348 | } |
| 10349 | |
| 10350 | return CMD_SUCCESS; |
| 10351 | } |
| 10352 | |
| 10353 | |
| 10354 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10355 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10356 | show_bgp_neighbor_received_routes_cmd, |
| 10357 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10358 | SHOW_STR |
| 10359 | BGP_STR |
| 10360 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10361 | "Neighbor to display information about\n" |
| 10362 | "Neighbor to display information about\n" |
| 10363 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10364 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10365 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10366 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 10367 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10368 | SHOW_STR |
| 10369 | BGP_STR |
| 10370 | "Address family\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 the received routes from neighbor\n") |
| 10375 | |
| 10376 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 10377 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 10378 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10379 | SHOW_STR |
| 10380 | BGP_STR |
| 10381 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10382 | "Neighbor to display information about\n" |
| 10383 | "Neighbor to display information about\n" |
| 10384 | "Display information received from a BGP neighbor\n" |
| 10385 | "Display the prefixlist filter\n") |
| 10386 | { |
| 10387 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10388 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10389 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10390 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10391 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10392 | ret = str2sockunion (argv[0], &su); |
| 10393 | if (ret < 0) |
| 10394 | { |
| 10395 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10396 | return CMD_WARNING; |
| 10397 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10398 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10399 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10400 | if (! peer) |
| 10401 | return CMD_WARNING; |
| 10402 | |
| 10403 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10404 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10405 | if (count) |
| 10406 | { |
| 10407 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10408 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10409 | } |
| 10410 | |
| 10411 | return CMD_SUCCESS; |
| 10412 | } |
| 10413 | |
| 10414 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 10415 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 10416 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10417 | SHOW_STR |
| 10418 | BGP_STR |
| 10419 | "Address family\n" |
| 10420 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10421 | "Neighbor to display information about\n" |
| 10422 | "Neighbor to display information about\n" |
| 10423 | "Display information received from a BGP neighbor\n" |
| 10424 | "Display the prefixlist filter\n") |
| 10425 | |
| 10426 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10427 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10428 | ipv6_bgp_neighbor_received_routes_cmd, |
| 10429 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10430 | SHOW_STR |
| 10431 | IPV6_STR |
| 10432 | BGP_STR |
| 10433 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10434 | "Neighbor to display information about\n" |
| 10435 | "Neighbor to display information about\n" |
| 10436 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10437 | |
| 10438 | /* old command */ |
| 10439 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 10440 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 10441 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10442 | SHOW_STR |
| 10443 | IPV6_STR |
| 10444 | MBGP_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 the received routes from neighbor\n") |
| 10449 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10450 | struct peer *peer; |
| 10451 | |
| 10452 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10453 | if (! peer) |
| 10454 | return CMD_WARNING; |
| 10455 | |
| 10456 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10457 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10458 | |
| 10459 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 10460 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 10461 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10462 | SHOW_STR |
| 10463 | BGP_STR |
| 10464 | "BGP view\n" |
| 10465 | "View name\n" |
| 10466 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10467 | "Neighbor to display information about\n" |
| 10468 | "Neighbor to display information about\n" |
| 10469 | "Display information received from a BGP neighbor\n" |
| 10470 | "Display the prefixlist filter\n") |
| 10471 | { |
| 10472 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10473 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10474 | struct peer *peer; |
| 10475 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10476 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10477 | |
| 10478 | /* BGP structure lookup. */ |
| 10479 | bgp = bgp_lookup_by_name (argv[0]); |
| 10480 | if (bgp == NULL) |
| 10481 | { |
| 10482 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10483 | return CMD_WARNING; |
| 10484 | } |
| 10485 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10486 | ret = str2sockunion (argv[1], &su); |
| 10487 | if (ret < 0) |
| 10488 | { |
| 10489 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10490 | return CMD_WARNING; |
| 10491 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10492 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10493 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10494 | if (! peer) |
| 10495 | return CMD_WARNING; |
| 10496 | |
| 10497 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10498 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10499 | if (count) |
| 10500 | { |
| 10501 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10502 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10503 | } |
| 10504 | |
| 10505 | return CMD_SUCCESS; |
| 10506 | } |
| 10507 | |
| 10508 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 10509 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 10510 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10511 | SHOW_STR |
| 10512 | BGP_STR |
| 10513 | "BGP view\n" |
| 10514 | "View name\n" |
| 10515 | "Address family\n" |
| 10516 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10517 | "Neighbor to display information about\n" |
| 10518 | "Neighbor to display information about\n" |
| 10519 | "Display information received from a BGP neighbor\n" |
| 10520 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10521 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 10522 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10523 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10524 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10525 | safi_t safi, enum bgp_show_type type) |
| 10526 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10527 | if (! peer || ! peer->afc[afi][safi]) |
| 10528 | { |
| 10529 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10530 | return CMD_WARNING; |
| 10531 | } |
| 10532 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10533 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10534 | } |
| 10535 | |
| 10536 | DEFUN (show_ip_bgp_neighbor_routes, |
| 10537 | show_ip_bgp_neighbor_routes_cmd, |
| 10538 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10539 | SHOW_STR |
| 10540 | IP_STR |
| 10541 | BGP_STR |
| 10542 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10543 | "Neighbor to display information about\n" |
| 10544 | "Neighbor to display information about\n" |
| 10545 | "Display routes learned from neighbor\n") |
| 10546 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10547 | struct peer *peer; |
| 10548 | |
| 10549 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10550 | if (! peer) |
| 10551 | return CMD_WARNING; |
| 10552 | |
| 10553 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10554 | bgp_show_type_neighbor); |
| 10555 | } |
| 10556 | |
| 10557 | DEFUN (show_ip_bgp_neighbor_flap, |
| 10558 | show_ip_bgp_neighbor_flap_cmd, |
| 10559 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10560 | SHOW_STR |
| 10561 | IP_STR |
| 10562 | BGP_STR |
| 10563 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10564 | "Neighbor to display information about\n" |
| 10565 | "Neighbor to display information about\n" |
| 10566 | "Display flap statistics of the routes learned from neighbor\n") |
| 10567 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10568 | struct peer *peer; |
| 10569 | |
| 10570 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10571 | if (! peer) |
| 10572 | return CMD_WARNING; |
| 10573 | |
| 10574 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10575 | bgp_show_type_flap_neighbor); |
| 10576 | } |
| 10577 | |
| 10578 | DEFUN (show_ip_bgp_neighbor_damp, |
| 10579 | show_ip_bgp_neighbor_damp_cmd, |
| 10580 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10581 | SHOW_STR |
| 10582 | IP_STR |
| 10583 | BGP_STR |
| 10584 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10585 | "Neighbor to display information about\n" |
| 10586 | "Neighbor to display information about\n" |
| 10587 | "Display the dampened routes received from neighbor\n") |
| 10588 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10589 | struct peer *peer; |
| 10590 | |
| 10591 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10592 | if (! peer) |
| 10593 | return CMD_WARNING; |
| 10594 | |
| 10595 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10596 | bgp_show_type_damp_neighbor); |
| 10597 | } |
| 10598 | |
| 10599 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 10600 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 10601 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 10602 | SHOW_STR |
| 10603 | IP_STR |
| 10604 | BGP_STR |
| 10605 | "Address family\n" |
| 10606 | "Address Family modifier\n" |
| 10607 | "Address Family modifier\n" |
| 10608 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10609 | "Neighbor to display information about\n" |
| 10610 | "Neighbor to display information about\n" |
| 10611 | "Display routes learned from neighbor\n") |
| 10612 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10613 | struct peer *peer; |
| 10614 | |
| 10615 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10616 | if (! peer) |
| 10617 | return CMD_WARNING; |
| 10618 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10619 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10620 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10621 | bgp_show_type_neighbor); |
| 10622 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10623 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10624 | bgp_show_type_neighbor); |
| 10625 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10626 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10627 | DEFUN (show_ip_bgp_view_rsclient, |
| 10628 | show_ip_bgp_view_rsclient_cmd, |
| 10629 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 10630 | SHOW_STR |
| 10631 | IP_STR |
| 10632 | BGP_STR |
| 10633 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10634 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10635 | "Information about Route Server Client\n" |
| 10636 | NEIGHBOR_ADDR_STR) |
| 10637 | { |
| 10638 | struct bgp_table *table; |
| 10639 | struct peer *peer; |
| 10640 | |
| 10641 | if (argc == 2) |
| 10642 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10643 | else |
| 10644 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10645 | |
| 10646 | if (! peer) |
| 10647 | return CMD_WARNING; |
| 10648 | |
| 10649 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10650 | { |
| 10651 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10652 | VTY_NEWLINE); |
| 10653 | return CMD_WARNING; |
| 10654 | } |
| 10655 | |
| 10656 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10657 | PEER_FLAG_RSERVER_CLIENT)) |
| 10658 | { |
| 10659 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10660 | VTY_NEWLINE); |
| 10661 | return CMD_WARNING; |
| 10662 | } |
| 10663 | |
| 10664 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 10665 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10666 | 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] | 10667 | } |
| 10668 | |
| 10669 | ALIAS (show_ip_bgp_view_rsclient, |
| 10670 | show_ip_bgp_rsclient_cmd, |
| 10671 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 10672 | SHOW_STR |
| 10673 | IP_STR |
| 10674 | BGP_STR |
| 10675 | "Information about Route Server Client\n" |
| 10676 | NEIGHBOR_ADDR_STR) |
| 10677 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10678 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 10679 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 10680 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10681 | SHOW_STR |
| 10682 | BGP_STR |
| 10683 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10684 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10685 | "Address family\n" |
| 10686 | "Address Family modifier\n" |
| 10687 | "Address Family modifier\n" |
| 10688 | "Information about Route Server Client\n" |
| 10689 | NEIGHBOR_ADDR_STR) |
| 10690 | { |
| 10691 | struct bgp_table *table; |
| 10692 | struct peer *peer; |
| 10693 | safi_t safi; |
| 10694 | |
| 10695 | if (argc == 3) { |
| 10696 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10697 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10698 | } else { |
| 10699 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10700 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10701 | } |
| 10702 | |
| 10703 | if (! peer) |
| 10704 | return CMD_WARNING; |
| 10705 | |
| 10706 | if (! peer->afc[AFI_IP][safi]) |
| 10707 | { |
| 10708 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10709 | VTY_NEWLINE); |
| 10710 | return CMD_WARNING; |
| 10711 | } |
| 10712 | |
| 10713 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10714 | PEER_FLAG_RSERVER_CLIENT)) |
| 10715 | { |
| 10716 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10717 | VTY_NEWLINE); |
| 10718 | return CMD_WARNING; |
| 10719 | } |
| 10720 | |
| 10721 | table = peer->rib[AFI_IP][safi]; |
| 10722 | |
| 10723 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 10724 | } |
| 10725 | |
| 10726 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 10727 | show_bgp_ipv4_safi_rsclient_cmd, |
| 10728 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10729 | SHOW_STR |
| 10730 | BGP_STR |
| 10731 | "Address family\n" |
| 10732 | "Address Family modifier\n" |
| 10733 | "Address Family modifier\n" |
| 10734 | "Information about Route Server Client\n" |
| 10735 | NEIGHBOR_ADDR_STR) |
| 10736 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10737 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 10738 | show_ip_bgp_view_rsclient_route_cmd, |
Michael Lambert | a8bf6f5 | 2008-09-24 17:23:11 +0100 | [diff] [blame] | 10739 | "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] | 10740 | SHOW_STR |
| 10741 | IP_STR |
| 10742 | BGP_STR |
| 10743 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10744 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10745 | "Information about Route Server Client\n" |
| 10746 | NEIGHBOR_ADDR_STR |
| 10747 | "Network in the BGP routing table to display\n") |
| 10748 | { |
| 10749 | struct bgp *bgp; |
| 10750 | struct peer *peer; |
| 10751 | |
| 10752 | /* BGP structure lookup. */ |
| 10753 | if (argc == 3) |
| 10754 | { |
| 10755 | bgp = bgp_lookup_by_name (argv[0]); |
| 10756 | if (bgp == NULL) |
| 10757 | { |
| 10758 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10759 | return CMD_WARNING; |
| 10760 | } |
| 10761 | } |
| 10762 | else |
| 10763 | { |
| 10764 | bgp = bgp_get_default (); |
| 10765 | if (bgp == NULL) |
| 10766 | { |
| 10767 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10768 | return CMD_WARNING; |
| 10769 | } |
| 10770 | } |
| 10771 | |
| 10772 | if (argc == 3) |
| 10773 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10774 | else |
| 10775 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10776 | |
| 10777 | if (! peer) |
| 10778 | return CMD_WARNING; |
| 10779 | |
| 10780 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10781 | { |
| 10782 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10783 | VTY_NEWLINE); |
| 10784 | return CMD_WARNING; |
| 10785 | } |
| 10786 | |
| 10787 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10788 | PEER_FLAG_RSERVER_CLIENT)) |
| 10789 | { |
| 10790 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10791 | VTY_NEWLINE); |
| 10792 | return CMD_WARNING; |
| 10793 | } |
| 10794 | |
| 10795 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10796 | (argc == 3) ? argv[2] : argv[1], |
| 10797 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 10798 | } |
| 10799 | |
| 10800 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 10801 | show_ip_bgp_rsclient_route_cmd, |
| 10802 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10803 | SHOW_STR |
| 10804 | IP_STR |
| 10805 | BGP_STR |
| 10806 | "Information about Route Server Client\n" |
| 10807 | NEIGHBOR_ADDR_STR |
| 10808 | "Network in the BGP routing table to display\n") |
| 10809 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10810 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 10811 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 10812 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10813 | SHOW_STR |
| 10814 | BGP_STR |
| 10815 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10816 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10817 | "Address family\n" |
| 10818 | "Address Family modifier\n" |
| 10819 | "Address Family modifier\n" |
| 10820 | "Information about Route Server Client\n" |
| 10821 | NEIGHBOR_ADDR_STR |
| 10822 | "Network in the BGP routing table to display\n") |
| 10823 | { |
| 10824 | struct bgp *bgp; |
| 10825 | struct peer *peer; |
| 10826 | safi_t safi; |
| 10827 | |
| 10828 | /* BGP structure lookup. */ |
| 10829 | if (argc == 4) |
| 10830 | { |
| 10831 | bgp = bgp_lookup_by_name (argv[0]); |
| 10832 | if (bgp == NULL) |
| 10833 | { |
| 10834 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10835 | return CMD_WARNING; |
| 10836 | } |
| 10837 | } |
| 10838 | else |
| 10839 | { |
| 10840 | bgp = bgp_get_default (); |
| 10841 | if (bgp == NULL) |
| 10842 | { |
| 10843 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10844 | return CMD_WARNING; |
| 10845 | } |
| 10846 | } |
| 10847 | |
| 10848 | if (argc == 4) { |
| 10849 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10850 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10851 | } else { |
| 10852 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10853 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10854 | } |
| 10855 | |
| 10856 | if (! peer) |
| 10857 | return CMD_WARNING; |
| 10858 | |
| 10859 | if (! peer->afc[AFI_IP][safi]) |
| 10860 | { |
| 10861 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10862 | VTY_NEWLINE); |
| 10863 | return CMD_WARNING; |
| 10864 | } |
| 10865 | |
| 10866 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10867 | PEER_FLAG_RSERVER_CLIENT)) |
| 10868 | { |
| 10869 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10870 | VTY_NEWLINE); |
| 10871 | return CMD_WARNING; |
| 10872 | } |
| 10873 | |
| 10874 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10875 | (argc == 4) ? argv[3] : argv[2], |
| 10876 | AFI_IP, safi, NULL, 0); |
| 10877 | } |
| 10878 | |
| 10879 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 10880 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 10881 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10882 | SHOW_STR |
| 10883 | BGP_STR |
| 10884 | "Address family\n" |
| 10885 | "Address Family modifier\n" |
| 10886 | "Address Family modifier\n" |
| 10887 | "Information about Route Server Client\n" |
| 10888 | NEIGHBOR_ADDR_STR |
| 10889 | "Network in the BGP routing table to display\n") |
| 10890 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10891 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 10892 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 10893 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10894 | SHOW_STR |
| 10895 | IP_STR |
| 10896 | BGP_STR |
| 10897 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10898 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10899 | "Information about Route Server Client\n" |
| 10900 | NEIGHBOR_ADDR_STR |
| 10901 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10902 | { |
| 10903 | struct bgp *bgp; |
| 10904 | struct peer *peer; |
| 10905 | |
| 10906 | /* BGP structure lookup. */ |
| 10907 | if (argc == 3) |
| 10908 | { |
| 10909 | bgp = bgp_lookup_by_name (argv[0]); |
| 10910 | if (bgp == NULL) |
| 10911 | { |
| 10912 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10913 | return CMD_WARNING; |
| 10914 | } |
| 10915 | } |
| 10916 | else |
| 10917 | { |
| 10918 | bgp = bgp_get_default (); |
| 10919 | if (bgp == NULL) |
| 10920 | { |
| 10921 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10922 | return CMD_WARNING; |
| 10923 | } |
| 10924 | } |
| 10925 | |
| 10926 | if (argc == 3) |
| 10927 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10928 | else |
| 10929 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10930 | |
| 10931 | if (! peer) |
| 10932 | return CMD_WARNING; |
| 10933 | |
| 10934 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10935 | { |
| 10936 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10937 | VTY_NEWLINE); |
| 10938 | return CMD_WARNING; |
| 10939 | } |
| 10940 | |
| 10941 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10942 | PEER_FLAG_RSERVER_CLIENT)) |
| 10943 | { |
| 10944 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10945 | VTY_NEWLINE); |
| 10946 | return CMD_WARNING; |
| 10947 | } |
| 10948 | |
| 10949 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10950 | (argc == 3) ? argv[2] : argv[1], |
| 10951 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 10952 | } |
| 10953 | |
| 10954 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 10955 | show_ip_bgp_rsclient_prefix_cmd, |
| 10956 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10957 | SHOW_STR |
| 10958 | IP_STR |
| 10959 | BGP_STR |
| 10960 | "Information about Route Server Client\n" |
| 10961 | NEIGHBOR_ADDR_STR |
| 10962 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10963 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10964 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 10965 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 10966 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10967 | SHOW_STR |
| 10968 | BGP_STR |
| 10969 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10970 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10971 | "Address family\n" |
| 10972 | "Address Family modifier\n" |
| 10973 | "Address Family modifier\n" |
| 10974 | "Information about Route Server Client\n" |
| 10975 | NEIGHBOR_ADDR_STR |
| 10976 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10977 | { |
| 10978 | struct bgp *bgp; |
| 10979 | struct peer *peer; |
| 10980 | safi_t safi; |
| 10981 | |
| 10982 | /* BGP structure lookup. */ |
| 10983 | if (argc == 4) |
| 10984 | { |
| 10985 | bgp = bgp_lookup_by_name (argv[0]); |
| 10986 | if (bgp == NULL) |
| 10987 | { |
| 10988 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10989 | return CMD_WARNING; |
| 10990 | } |
| 10991 | } |
| 10992 | else |
| 10993 | { |
| 10994 | bgp = bgp_get_default (); |
| 10995 | if (bgp == NULL) |
| 10996 | { |
| 10997 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10998 | return CMD_WARNING; |
| 10999 | } |
| 11000 | } |
| 11001 | |
| 11002 | if (argc == 4) { |
| 11003 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11004 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11005 | } else { |
| 11006 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11007 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11008 | } |
| 11009 | |
| 11010 | if (! peer) |
| 11011 | return CMD_WARNING; |
| 11012 | |
| 11013 | if (! peer->afc[AFI_IP][safi]) |
| 11014 | { |
| 11015 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11016 | VTY_NEWLINE); |
| 11017 | return CMD_WARNING; |
| 11018 | } |
| 11019 | |
| 11020 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 11021 | PEER_FLAG_RSERVER_CLIENT)) |
| 11022 | { |
| 11023 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11024 | VTY_NEWLINE); |
| 11025 | return CMD_WARNING; |
| 11026 | } |
| 11027 | |
| 11028 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 11029 | (argc == 4) ? argv[3] : argv[2], |
| 11030 | AFI_IP, safi, NULL, 1); |
| 11031 | } |
| 11032 | |
| 11033 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 11034 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 11035 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11036 | SHOW_STR |
| 11037 | BGP_STR |
| 11038 | "Address family\n" |
| 11039 | "Address Family modifier\n" |
| 11040 | "Address Family modifier\n" |
| 11041 | "Information about Route Server Client\n" |
| 11042 | NEIGHBOR_ADDR_STR |
| 11043 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11044 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11045 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11046 | DEFUN (show_bgp_view_neighbor_routes, |
| 11047 | show_bgp_view_neighbor_routes_cmd, |
| 11048 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 11049 | SHOW_STR |
| 11050 | BGP_STR |
| 11051 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11052 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11053 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11054 | "Neighbor to display information about\n" |
| 11055 | "Neighbor to display information about\n" |
| 11056 | "Display routes learned from neighbor\n") |
| 11057 | { |
| 11058 | struct peer *peer; |
| 11059 | |
| 11060 | if (argc == 2) |
| 11061 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11062 | else |
| 11063 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11064 | |
| 11065 | if (! peer) |
| 11066 | return CMD_WARNING; |
| 11067 | |
| 11068 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11069 | bgp_show_type_neighbor); |
| 11070 | } |
| 11071 | |
| 11072 | ALIAS (show_bgp_view_neighbor_routes, |
| 11073 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 11074 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11075 | SHOW_STR |
| 11076 | BGP_STR |
| 11077 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11078 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11079 | "Address family\n" |
| 11080 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11081 | "Neighbor to display information about\n" |
| 11082 | "Neighbor to display information about\n" |
| 11083 | "Display routes learned from neighbor\n") |
| 11084 | |
| 11085 | DEFUN (show_bgp_view_neighbor_damp, |
| 11086 | show_bgp_view_neighbor_damp_cmd, |
| 11087 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11088 | SHOW_STR |
| 11089 | BGP_STR |
| 11090 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11091 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11092 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11093 | "Neighbor to display information about\n" |
| 11094 | "Neighbor to display information about\n" |
| 11095 | "Display the dampened routes received from neighbor\n") |
| 11096 | { |
| 11097 | struct peer *peer; |
| 11098 | |
| 11099 | if (argc == 2) |
| 11100 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11101 | else |
| 11102 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11103 | |
| 11104 | if (! peer) |
| 11105 | return CMD_WARNING; |
| 11106 | |
| 11107 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11108 | bgp_show_type_damp_neighbor); |
| 11109 | } |
| 11110 | |
| 11111 | ALIAS (show_bgp_view_neighbor_damp, |
| 11112 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 11113 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11114 | SHOW_STR |
| 11115 | BGP_STR |
| 11116 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11117 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11118 | "Address family\n" |
| 11119 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11120 | "Neighbor to display information about\n" |
| 11121 | "Neighbor to display information about\n" |
| 11122 | "Display the dampened routes received from neighbor\n") |
| 11123 | |
| 11124 | DEFUN (show_bgp_view_neighbor_flap, |
| 11125 | show_bgp_view_neighbor_flap_cmd, |
| 11126 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11127 | SHOW_STR |
| 11128 | BGP_STR |
| 11129 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11130 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11131 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11132 | "Neighbor to display information about\n" |
| 11133 | "Neighbor to display information about\n" |
| 11134 | "Display flap statistics of the routes learned from neighbor\n") |
| 11135 | { |
| 11136 | struct peer *peer; |
| 11137 | |
| 11138 | if (argc == 2) |
| 11139 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11140 | else |
| 11141 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11142 | |
| 11143 | if (! peer) |
| 11144 | return CMD_WARNING; |
| 11145 | |
| 11146 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11147 | bgp_show_type_flap_neighbor); |
| 11148 | } |
| 11149 | |
| 11150 | ALIAS (show_bgp_view_neighbor_flap, |
| 11151 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 11152 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11153 | SHOW_STR |
| 11154 | BGP_STR |
| 11155 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11156 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11157 | "Address family\n" |
| 11158 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11159 | "Neighbor to display information about\n" |
| 11160 | "Neighbor to display information about\n" |
| 11161 | "Display flap statistics of the routes learned from neighbor\n") |
| 11162 | |
| 11163 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11164 | show_bgp_neighbor_routes_cmd, |
| 11165 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11166 | SHOW_STR |
| 11167 | BGP_STR |
| 11168 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11169 | "Neighbor to display information about\n" |
| 11170 | "Neighbor to display information about\n" |
| 11171 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11172 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11173 | |
| 11174 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11175 | show_bgp_ipv6_neighbor_routes_cmd, |
| 11176 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11177 | SHOW_STR |
| 11178 | BGP_STR |
| 11179 | "Address family\n" |
| 11180 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11181 | "Neighbor to display information about\n" |
| 11182 | "Neighbor to display information about\n" |
| 11183 | "Display routes learned from neighbor\n") |
| 11184 | |
| 11185 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11186 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11187 | ipv6_bgp_neighbor_routes_cmd, |
| 11188 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11189 | SHOW_STR |
| 11190 | IPV6_STR |
| 11191 | BGP_STR |
| 11192 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11193 | "Neighbor to display information about\n" |
| 11194 | "Neighbor to display information about\n" |
| 11195 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11196 | |
| 11197 | /* old command */ |
| 11198 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 11199 | ipv6_mbgp_neighbor_routes_cmd, |
| 11200 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11201 | SHOW_STR |
| 11202 | IPV6_STR |
| 11203 | MBGP_STR |
| 11204 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11205 | "Neighbor to display information about\n" |
| 11206 | "Neighbor to display information about\n" |
| 11207 | "Display routes learned from neighbor\n") |
| 11208 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11209 | struct peer *peer; |
| 11210 | |
| 11211 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11212 | if (! peer) |
| 11213 | return CMD_WARNING; |
| 11214 | |
| 11215 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11216 | bgp_show_type_neighbor); |
| 11217 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11218 | |
| 11219 | ALIAS (show_bgp_view_neighbor_flap, |
| 11220 | show_bgp_neighbor_flap_cmd, |
| 11221 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11222 | SHOW_STR |
| 11223 | BGP_STR |
| 11224 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11225 | "Neighbor to display information about\n" |
| 11226 | "Neighbor to display information about\n" |
| 11227 | "Display flap statistics of the routes learned from neighbor\n") |
| 11228 | |
| 11229 | ALIAS (show_bgp_view_neighbor_flap, |
| 11230 | show_bgp_ipv6_neighbor_flap_cmd, |
| 11231 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11232 | SHOW_STR |
| 11233 | BGP_STR |
| 11234 | "Address family\n" |
| 11235 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11236 | "Neighbor to display information about\n" |
| 11237 | "Neighbor to display information about\n" |
| 11238 | "Display flap statistics of the routes learned from neighbor\n") |
| 11239 | |
| 11240 | ALIAS (show_bgp_view_neighbor_damp, |
| 11241 | show_bgp_neighbor_damp_cmd, |
| 11242 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11243 | SHOW_STR |
| 11244 | BGP_STR |
| 11245 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11246 | "Neighbor to display information about\n" |
| 11247 | "Neighbor to display information about\n" |
| 11248 | "Display the dampened routes received from neighbor\n") |
| 11249 | |
| 11250 | ALIAS (show_bgp_view_neighbor_damp, |
| 11251 | show_bgp_ipv6_neighbor_damp_cmd, |
| 11252 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11253 | SHOW_STR |
| 11254 | BGP_STR |
| 11255 | "Address family\n" |
| 11256 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11257 | "Neighbor to display information about\n" |
| 11258 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 11259 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11260 | |
| 11261 | DEFUN (show_bgp_view_rsclient, |
| 11262 | show_bgp_view_rsclient_cmd, |
| 11263 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 11264 | SHOW_STR |
| 11265 | BGP_STR |
| 11266 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11267 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11268 | "Information about Route Server Client\n" |
| 11269 | NEIGHBOR_ADDR_STR) |
| 11270 | { |
| 11271 | struct bgp_table *table; |
| 11272 | struct peer *peer; |
| 11273 | |
| 11274 | if (argc == 2) |
| 11275 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11276 | else |
| 11277 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11278 | |
| 11279 | if (! peer) |
| 11280 | return CMD_WARNING; |
| 11281 | |
| 11282 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11283 | { |
| 11284 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11285 | VTY_NEWLINE); |
| 11286 | return CMD_WARNING; |
| 11287 | } |
| 11288 | |
| 11289 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11290 | PEER_FLAG_RSERVER_CLIENT)) |
| 11291 | { |
| 11292 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11293 | VTY_NEWLINE); |
| 11294 | return CMD_WARNING; |
| 11295 | } |
| 11296 | |
| 11297 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 11298 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11299 | 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] | 11300 | } |
| 11301 | |
| 11302 | ALIAS (show_bgp_view_rsclient, |
| 11303 | show_bgp_rsclient_cmd, |
| 11304 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 11305 | SHOW_STR |
| 11306 | BGP_STR |
| 11307 | "Information about Route Server Client\n" |
| 11308 | NEIGHBOR_ADDR_STR) |
| 11309 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11310 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 11311 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 11312 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11313 | SHOW_STR |
| 11314 | BGP_STR |
| 11315 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11316 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11317 | "Address family\n" |
| 11318 | "Address Family modifier\n" |
| 11319 | "Address Family modifier\n" |
| 11320 | "Information about Route Server Client\n" |
| 11321 | NEIGHBOR_ADDR_STR) |
| 11322 | { |
| 11323 | struct bgp_table *table; |
| 11324 | struct peer *peer; |
| 11325 | safi_t safi; |
| 11326 | |
| 11327 | if (argc == 3) { |
| 11328 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11329 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11330 | } else { |
| 11331 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11332 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11333 | } |
| 11334 | |
| 11335 | if (! peer) |
| 11336 | return CMD_WARNING; |
| 11337 | |
| 11338 | if (! peer->afc[AFI_IP6][safi]) |
| 11339 | { |
| 11340 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11341 | VTY_NEWLINE); |
| 11342 | return CMD_WARNING; |
| 11343 | } |
| 11344 | |
| 11345 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11346 | PEER_FLAG_RSERVER_CLIENT)) |
| 11347 | { |
| 11348 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11349 | VTY_NEWLINE); |
| 11350 | return CMD_WARNING; |
| 11351 | } |
| 11352 | |
| 11353 | table = peer->rib[AFI_IP6][safi]; |
| 11354 | |
| 11355 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 11356 | } |
| 11357 | |
| 11358 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 11359 | show_bgp_ipv6_safi_rsclient_cmd, |
| 11360 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11361 | SHOW_STR |
| 11362 | BGP_STR |
| 11363 | "Address family\n" |
| 11364 | "Address Family modifier\n" |
| 11365 | "Address Family modifier\n" |
| 11366 | "Information about Route Server Client\n" |
| 11367 | NEIGHBOR_ADDR_STR) |
| 11368 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11369 | DEFUN (show_bgp_view_rsclient_route, |
| 11370 | show_bgp_view_rsclient_route_cmd, |
| 11371 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11372 | SHOW_STR |
| 11373 | BGP_STR |
| 11374 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11375 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11376 | "Information about Route Server Client\n" |
| 11377 | NEIGHBOR_ADDR_STR |
| 11378 | "Network in the BGP routing table to display\n") |
| 11379 | { |
| 11380 | struct bgp *bgp; |
| 11381 | struct peer *peer; |
| 11382 | |
| 11383 | /* BGP structure lookup. */ |
| 11384 | if (argc == 3) |
| 11385 | { |
| 11386 | bgp = bgp_lookup_by_name (argv[0]); |
| 11387 | if (bgp == NULL) |
| 11388 | { |
| 11389 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11390 | return CMD_WARNING; |
| 11391 | } |
| 11392 | } |
| 11393 | else |
| 11394 | { |
| 11395 | bgp = bgp_get_default (); |
| 11396 | if (bgp == NULL) |
| 11397 | { |
| 11398 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11399 | return CMD_WARNING; |
| 11400 | } |
| 11401 | } |
| 11402 | |
| 11403 | if (argc == 3) |
| 11404 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11405 | else |
| 11406 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11407 | |
| 11408 | if (! peer) |
| 11409 | return CMD_WARNING; |
| 11410 | |
| 11411 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11412 | { |
| 11413 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11414 | VTY_NEWLINE); |
| 11415 | return CMD_WARNING; |
| 11416 | } |
| 11417 | |
| 11418 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11419 | PEER_FLAG_RSERVER_CLIENT)) |
| 11420 | { |
| 11421 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11422 | VTY_NEWLINE); |
| 11423 | return CMD_WARNING; |
| 11424 | } |
| 11425 | |
| 11426 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11427 | (argc == 3) ? argv[2] : argv[1], |
| 11428 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 11429 | } |
| 11430 | |
| 11431 | ALIAS (show_bgp_view_rsclient_route, |
| 11432 | show_bgp_rsclient_route_cmd, |
| 11433 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11434 | SHOW_STR |
| 11435 | BGP_STR |
| 11436 | "Information about Route Server Client\n" |
| 11437 | NEIGHBOR_ADDR_STR |
| 11438 | "Network in the BGP routing table to display\n") |
| 11439 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11440 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 11441 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 11442 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11443 | SHOW_STR |
| 11444 | BGP_STR |
| 11445 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11446 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11447 | "Address family\n" |
| 11448 | "Address Family modifier\n" |
| 11449 | "Address Family modifier\n" |
| 11450 | "Information about Route Server Client\n" |
| 11451 | NEIGHBOR_ADDR_STR |
| 11452 | "Network in the BGP routing table to display\n") |
| 11453 | { |
| 11454 | struct bgp *bgp; |
| 11455 | struct peer *peer; |
| 11456 | safi_t safi; |
| 11457 | |
| 11458 | /* BGP structure lookup. */ |
| 11459 | if (argc == 4) |
| 11460 | { |
| 11461 | bgp = bgp_lookup_by_name (argv[0]); |
| 11462 | if (bgp == NULL) |
| 11463 | { |
| 11464 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11465 | return CMD_WARNING; |
| 11466 | } |
| 11467 | } |
| 11468 | else |
| 11469 | { |
| 11470 | bgp = bgp_get_default (); |
| 11471 | if (bgp == NULL) |
| 11472 | { |
| 11473 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11474 | return CMD_WARNING; |
| 11475 | } |
| 11476 | } |
| 11477 | |
| 11478 | if (argc == 4) { |
| 11479 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11480 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11481 | } else { |
| 11482 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11483 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11484 | } |
| 11485 | |
| 11486 | if (! peer) |
| 11487 | return CMD_WARNING; |
| 11488 | |
| 11489 | if (! peer->afc[AFI_IP6][safi]) |
| 11490 | { |
| 11491 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11492 | VTY_NEWLINE); |
| 11493 | return CMD_WARNING; |
| 11494 | } |
| 11495 | |
| 11496 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11497 | PEER_FLAG_RSERVER_CLIENT)) |
| 11498 | { |
| 11499 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11500 | VTY_NEWLINE); |
| 11501 | return CMD_WARNING; |
| 11502 | } |
| 11503 | |
| 11504 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11505 | (argc == 4) ? argv[3] : argv[2], |
| 11506 | AFI_IP6, safi, NULL, 0); |
| 11507 | } |
| 11508 | |
| 11509 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 11510 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 11511 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11512 | SHOW_STR |
| 11513 | BGP_STR |
| 11514 | "Address family\n" |
| 11515 | "Address Family modifier\n" |
| 11516 | "Address Family modifier\n" |
| 11517 | "Information about Route Server Client\n" |
| 11518 | NEIGHBOR_ADDR_STR |
| 11519 | "Network in the BGP routing table to display\n") |
| 11520 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11521 | DEFUN (show_bgp_view_rsclient_prefix, |
| 11522 | show_bgp_view_rsclient_prefix_cmd, |
| 11523 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11524 | SHOW_STR |
| 11525 | BGP_STR |
| 11526 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11527 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11528 | "Information about Route Server Client\n" |
| 11529 | NEIGHBOR_ADDR_STR |
| 11530 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11531 | { |
| 11532 | struct bgp *bgp; |
| 11533 | struct peer *peer; |
| 11534 | |
| 11535 | /* BGP structure lookup. */ |
| 11536 | if (argc == 3) |
| 11537 | { |
| 11538 | bgp = bgp_lookup_by_name (argv[0]); |
| 11539 | if (bgp == NULL) |
| 11540 | { |
| 11541 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11542 | return CMD_WARNING; |
| 11543 | } |
| 11544 | } |
| 11545 | else |
| 11546 | { |
| 11547 | bgp = bgp_get_default (); |
| 11548 | if (bgp == NULL) |
| 11549 | { |
| 11550 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11551 | return CMD_WARNING; |
| 11552 | } |
| 11553 | } |
| 11554 | |
| 11555 | if (argc == 3) |
| 11556 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11557 | else |
| 11558 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11559 | |
| 11560 | if (! peer) |
| 11561 | return CMD_WARNING; |
| 11562 | |
| 11563 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11564 | { |
| 11565 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11566 | VTY_NEWLINE); |
| 11567 | return CMD_WARNING; |
| 11568 | } |
| 11569 | |
| 11570 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11571 | PEER_FLAG_RSERVER_CLIENT)) |
| 11572 | { |
| 11573 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11574 | VTY_NEWLINE); |
| 11575 | return CMD_WARNING; |
| 11576 | } |
| 11577 | |
| 11578 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11579 | (argc == 3) ? argv[2] : argv[1], |
| 11580 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 11581 | } |
| 11582 | |
| 11583 | ALIAS (show_bgp_view_rsclient_prefix, |
| 11584 | show_bgp_rsclient_prefix_cmd, |
| 11585 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11586 | SHOW_STR |
| 11587 | BGP_STR |
| 11588 | "Information about Route Server Client\n" |
| 11589 | NEIGHBOR_ADDR_STR |
| 11590 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11591 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11592 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11593 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 11594 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11595 | SHOW_STR |
| 11596 | BGP_STR |
| 11597 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11598 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11599 | "Address family\n" |
| 11600 | "Address Family modifier\n" |
| 11601 | "Address Family modifier\n" |
| 11602 | "Information about Route Server Client\n" |
| 11603 | NEIGHBOR_ADDR_STR |
| 11604 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11605 | { |
| 11606 | struct bgp *bgp; |
| 11607 | struct peer *peer; |
| 11608 | safi_t safi; |
| 11609 | |
| 11610 | /* BGP structure lookup. */ |
| 11611 | if (argc == 4) |
| 11612 | { |
| 11613 | bgp = bgp_lookup_by_name (argv[0]); |
| 11614 | if (bgp == NULL) |
| 11615 | { |
| 11616 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11617 | return CMD_WARNING; |
| 11618 | } |
| 11619 | } |
| 11620 | else |
| 11621 | { |
| 11622 | bgp = bgp_get_default (); |
| 11623 | if (bgp == NULL) |
| 11624 | { |
| 11625 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11626 | return CMD_WARNING; |
| 11627 | } |
| 11628 | } |
| 11629 | |
| 11630 | if (argc == 4) { |
| 11631 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11632 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11633 | } else { |
| 11634 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11635 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11636 | } |
| 11637 | |
| 11638 | if (! peer) |
| 11639 | return CMD_WARNING; |
| 11640 | |
| 11641 | if (! peer->afc[AFI_IP6][safi]) |
| 11642 | { |
| 11643 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11644 | VTY_NEWLINE); |
| 11645 | return CMD_WARNING; |
| 11646 | } |
| 11647 | |
| 11648 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11649 | PEER_FLAG_RSERVER_CLIENT)) |
| 11650 | { |
| 11651 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11652 | VTY_NEWLINE); |
| 11653 | return CMD_WARNING; |
| 11654 | } |
| 11655 | |
| 11656 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11657 | (argc == 4) ? argv[3] : argv[2], |
| 11658 | AFI_IP6, safi, NULL, 1); |
| 11659 | } |
| 11660 | |
| 11661 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11662 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 11663 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11664 | SHOW_STR |
| 11665 | BGP_STR |
| 11666 | "Address family\n" |
| 11667 | "Address Family modifier\n" |
| 11668 | "Address Family modifier\n" |
| 11669 | "Information about Route Server Client\n" |
| 11670 | NEIGHBOR_ADDR_STR |
| 11671 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11672 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11673 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11674 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11675 | struct bgp_table *bgp_distance_table; |
| 11676 | |
| 11677 | struct bgp_distance |
| 11678 | { |
| 11679 | /* Distance value for the IP source prefix. */ |
| 11680 | u_char distance; |
| 11681 | |
| 11682 | /* Name of the access-list to be matched. */ |
| 11683 | char *access_list; |
| 11684 | }; |
| 11685 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11686 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 11687 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11688 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 11689 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11690 | } |
| 11691 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11692 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11693 | bgp_distance_free (struct bgp_distance *bdistance) |
| 11694 | { |
| 11695 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 11696 | } |
| 11697 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11698 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11699 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 11700 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11701 | { |
| 11702 | int ret; |
| 11703 | struct prefix_ipv4 p; |
| 11704 | u_char distance; |
| 11705 | struct bgp_node *rn; |
| 11706 | struct bgp_distance *bdistance; |
| 11707 | |
| 11708 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11709 | if (ret == 0) |
| 11710 | { |
| 11711 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11712 | return CMD_WARNING; |
| 11713 | } |
| 11714 | |
| 11715 | distance = atoi (distance_str); |
| 11716 | |
| 11717 | /* Get BGP distance node. */ |
| 11718 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 11719 | if (rn->info) |
| 11720 | { |
| 11721 | bdistance = rn->info; |
| 11722 | bgp_unlock_node (rn); |
| 11723 | } |
| 11724 | else |
| 11725 | { |
| 11726 | bdistance = bgp_distance_new (); |
| 11727 | rn->info = bdistance; |
| 11728 | } |
| 11729 | |
| 11730 | /* Set distance value. */ |
| 11731 | bdistance->distance = distance; |
| 11732 | |
| 11733 | /* Reset access-list configuration. */ |
| 11734 | if (bdistance->access_list) |
| 11735 | { |
| 11736 | free (bdistance->access_list); |
| 11737 | bdistance->access_list = NULL; |
| 11738 | } |
| 11739 | if (access_list_str) |
| 11740 | bdistance->access_list = strdup (access_list_str); |
| 11741 | |
| 11742 | return CMD_SUCCESS; |
| 11743 | } |
| 11744 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11745 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11746 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 11747 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11748 | { |
| 11749 | int ret; |
| 11750 | struct prefix_ipv4 p; |
| 11751 | u_char distance; |
| 11752 | struct bgp_node *rn; |
| 11753 | struct bgp_distance *bdistance; |
| 11754 | |
| 11755 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11756 | if (ret == 0) |
| 11757 | { |
| 11758 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11759 | return CMD_WARNING; |
| 11760 | } |
| 11761 | |
| 11762 | distance = atoi (distance_str); |
| 11763 | |
| 11764 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 11765 | if (! rn) |
| 11766 | { |
| 11767 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 11768 | return CMD_WARNING; |
| 11769 | } |
| 11770 | |
| 11771 | bdistance = rn->info; |
| 11772 | |
| 11773 | if (bdistance->access_list) |
| 11774 | free (bdistance->access_list); |
| 11775 | bgp_distance_free (bdistance); |
| 11776 | |
| 11777 | rn->info = NULL; |
| 11778 | bgp_unlock_node (rn); |
| 11779 | bgp_unlock_node (rn); |
| 11780 | |
| 11781 | return CMD_SUCCESS; |
| 11782 | } |
| 11783 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11784 | /* Apply BGP information to distance method. */ |
| 11785 | u_char |
| 11786 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 11787 | { |
| 11788 | struct bgp_node *rn; |
| 11789 | struct prefix_ipv4 q; |
| 11790 | struct peer *peer; |
| 11791 | struct bgp_distance *bdistance; |
| 11792 | struct access_list *alist; |
| 11793 | struct bgp_static *bgp_static; |
| 11794 | |
| 11795 | if (! bgp) |
| 11796 | return 0; |
| 11797 | |
| 11798 | if (p->family != AF_INET) |
| 11799 | return 0; |
| 11800 | |
| 11801 | peer = rinfo->peer; |
| 11802 | |
| 11803 | if (peer->su.sa.sa_family != AF_INET) |
| 11804 | return 0; |
| 11805 | |
| 11806 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 11807 | q.family = AF_INET; |
| 11808 | q.prefix = peer->su.sin.sin_addr; |
| 11809 | q.prefixlen = IPV4_MAX_BITLEN; |
| 11810 | |
| 11811 | /* Check source address. */ |
| 11812 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 11813 | if (rn) |
| 11814 | { |
| 11815 | bdistance = rn->info; |
| 11816 | bgp_unlock_node (rn); |
| 11817 | |
| 11818 | if (bdistance->access_list) |
| 11819 | { |
| 11820 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 11821 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 11822 | return bdistance->distance; |
| 11823 | } |
| 11824 | else |
| 11825 | return bdistance->distance; |
| 11826 | } |
| 11827 | |
| 11828 | /* Backdoor check. */ |
| 11829 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 11830 | if (rn) |
| 11831 | { |
| 11832 | bgp_static = rn->info; |
| 11833 | bgp_unlock_node (rn); |
| 11834 | |
| 11835 | if (bgp_static->backdoor) |
| 11836 | { |
| 11837 | if (bgp->distance_local) |
| 11838 | return bgp->distance_local; |
| 11839 | else |
| 11840 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11841 | } |
| 11842 | } |
| 11843 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 11844 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11845 | { |
| 11846 | if (bgp->distance_ebgp) |
| 11847 | return bgp->distance_ebgp; |
| 11848 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 11849 | } |
| 11850 | else |
| 11851 | { |
| 11852 | if (bgp->distance_ibgp) |
| 11853 | return bgp->distance_ibgp; |
| 11854 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11855 | } |
| 11856 | } |
| 11857 | |
| 11858 | DEFUN (bgp_distance, |
| 11859 | bgp_distance_cmd, |
| 11860 | "distance bgp <1-255> <1-255> <1-255>", |
| 11861 | "Define an administrative distance\n" |
| 11862 | "BGP distance\n" |
| 11863 | "Distance for routes external to the AS\n" |
| 11864 | "Distance for routes internal to the AS\n" |
| 11865 | "Distance for local routes\n") |
| 11866 | { |
| 11867 | struct bgp *bgp; |
| 11868 | |
| 11869 | bgp = vty->index; |
| 11870 | |
| 11871 | bgp->distance_ebgp = atoi (argv[0]); |
| 11872 | bgp->distance_ibgp = atoi (argv[1]); |
| 11873 | bgp->distance_local = atoi (argv[2]); |
| 11874 | return CMD_SUCCESS; |
| 11875 | } |
| 11876 | |
| 11877 | DEFUN (no_bgp_distance, |
| 11878 | no_bgp_distance_cmd, |
| 11879 | "no distance bgp <1-255> <1-255> <1-255>", |
| 11880 | NO_STR |
| 11881 | "Define an administrative distance\n" |
| 11882 | "BGP distance\n" |
| 11883 | "Distance for routes external to the AS\n" |
| 11884 | "Distance for routes internal to the AS\n" |
| 11885 | "Distance for local routes\n") |
| 11886 | { |
| 11887 | struct bgp *bgp; |
| 11888 | |
| 11889 | bgp = vty->index; |
| 11890 | |
| 11891 | bgp->distance_ebgp= 0; |
| 11892 | bgp->distance_ibgp = 0; |
| 11893 | bgp->distance_local = 0; |
| 11894 | return CMD_SUCCESS; |
| 11895 | } |
| 11896 | |
| 11897 | ALIAS (no_bgp_distance, |
| 11898 | no_bgp_distance2_cmd, |
| 11899 | "no distance bgp", |
| 11900 | NO_STR |
| 11901 | "Define an administrative distance\n" |
| 11902 | "BGP distance\n") |
| 11903 | |
| 11904 | DEFUN (bgp_distance_source, |
| 11905 | bgp_distance_source_cmd, |
| 11906 | "distance <1-255> A.B.C.D/M", |
| 11907 | "Define an administrative distance\n" |
| 11908 | "Administrative distance\n" |
| 11909 | "IP source prefix\n") |
| 11910 | { |
| 11911 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 11912 | return CMD_SUCCESS; |
| 11913 | } |
| 11914 | |
| 11915 | DEFUN (no_bgp_distance_source, |
| 11916 | no_bgp_distance_source_cmd, |
| 11917 | "no distance <1-255> A.B.C.D/M", |
| 11918 | NO_STR |
| 11919 | "Define an administrative distance\n" |
| 11920 | "Administrative distance\n" |
| 11921 | "IP source prefix\n") |
| 11922 | { |
| 11923 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 11924 | return CMD_SUCCESS; |
| 11925 | } |
| 11926 | |
| 11927 | DEFUN (bgp_distance_source_access_list, |
| 11928 | bgp_distance_source_access_list_cmd, |
| 11929 | "distance <1-255> A.B.C.D/M WORD", |
| 11930 | "Define an administrative distance\n" |
| 11931 | "Administrative distance\n" |
| 11932 | "IP source prefix\n" |
| 11933 | "Access list name\n") |
| 11934 | { |
| 11935 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 11936 | return CMD_SUCCESS; |
| 11937 | } |
| 11938 | |
| 11939 | DEFUN (no_bgp_distance_source_access_list, |
| 11940 | no_bgp_distance_source_access_list_cmd, |
| 11941 | "no distance <1-255> A.B.C.D/M WORD", |
| 11942 | NO_STR |
| 11943 | "Define an administrative distance\n" |
| 11944 | "Administrative distance\n" |
| 11945 | "IP source prefix\n" |
| 11946 | "Access list name\n") |
| 11947 | { |
| 11948 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 11949 | return CMD_SUCCESS; |
| 11950 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11951 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11952 | DEFUN (bgp_damp_set, |
| 11953 | bgp_damp_set_cmd, |
| 11954 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 11955 | "BGP Specific commands\n" |
| 11956 | "Enable route-flap dampening\n" |
| 11957 | "Half-life time for the penalty\n" |
| 11958 | "Value to start reusing a route\n" |
| 11959 | "Value to start suppressing a route\n" |
| 11960 | "Maximum duration to suppress a stable route\n") |
| 11961 | { |
| 11962 | struct bgp *bgp; |
| 11963 | int half = DEFAULT_HALF_LIFE * 60; |
| 11964 | int reuse = DEFAULT_REUSE; |
| 11965 | int suppress = DEFAULT_SUPPRESS; |
| 11966 | int max = 4 * half; |
| 11967 | |
| 11968 | if (argc == 4) |
| 11969 | { |
| 11970 | half = atoi (argv[0]) * 60; |
| 11971 | reuse = atoi (argv[1]); |
| 11972 | suppress = atoi (argv[2]); |
| 11973 | max = atoi (argv[3]) * 60; |
| 11974 | } |
| 11975 | else if (argc == 1) |
| 11976 | { |
| 11977 | half = atoi (argv[0]) * 60; |
| 11978 | max = 4 * half; |
| 11979 | } |
| 11980 | |
| 11981 | bgp = vty->index; |
| 11982 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 11983 | half, reuse, suppress, max); |
| 11984 | } |
| 11985 | |
| 11986 | ALIAS (bgp_damp_set, |
| 11987 | bgp_damp_set2_cmd, |
| 11988 | "bgp dampening <1-45>", |
| 11989 | "BGP Specific commands\n" |
| 11990 | "Enable route-flap dampening\n" |
| 11991 | "Half-life time for the penalty\n") |
| 11992 | |
| 11993 | ALIAS (bgp_damp_set, |
| 11994 | bgp_damp_set3_cmd, |
| 11995 | "bgp dampening", |
| 11996 | "BGP Specific commands\n" |
| 11997 | "Enable route-flap dampening\n") |
| 11998 | |
| 11999 | DEFUN (bgp_damp_unset, |
| 12000 | bgp_damp_unset_cmd, |
| 12001 | "no bgp dampening", |
| 12002 | NO_STR |
| 12003 | "BGP Specific commands\n" |
| 12004 | "Enable route-flap dampening\n") |
| 12005 | { |
| 12006 | struct bgp *bgp; |
| 12007 | |
| 12008 | bgp = vty->index; |
| 12009 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 12010 | } |
| 12011 | |
| 12012 | ALIAS (bgp_damp_unset, |
| 12013 | bgp_damp_unset2_cmd, |
| 12014 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 12015 | NO_STR |
| 12016 | "BGP Specific commands\n" |
| 12017 | "Enable route-flap dampening\n" |
| 12018 | "Half-life time for the penalty\n" |
| 12019 | "Value to start reusing a route\n" |
| 12020 | "Value to start suppressing a route\n" |
| 12021 | "Maximum duration to suppress a stable route\n") |
| 12022 | |
| 12023 | DEFUN (show_ip_bgp_dampened_paths, |
| 12024 | show_ip_bgp_dampened_paths_cmd, |
| 12025 | "show ip bgp dampened-paths", |
| 12026 | SHOW_STR |
| 12027 | IP_STR |
| 12028 | BGP_STR |
| 12029 | "Display paths suppressed due to dampening\n") |
| 12030 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12031 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 12032 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12033 | } |
| 12034 | |
| 12035 | DEFUN (show_ip_bgp_flap_statistics, |
| 12036 | show_ip_bgp_flap_statistics_cmd, |
| 12037 | "show ip bgp flap-statistics", |
| 12038 | SHOW_STR |
| 12039 | IP_STR |
| 12040 | BGP_STR |
| 12041 | "Display flap statistics of routes\n") |
| 12042 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12043 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 12044 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12045 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12046 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12047 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12048 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 12049 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 12050 | const char *ip_str, afi_t afi, safi_t safi, |
| 12051 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12052 | { |
| 12053 | int ret; |
| 12054 | struct prefix match; |
| 12055 | struct bgp_node *rn; |
| 12056 | struct bgp_node *rm; |
| 12057 | struct bgp_info *ri; |
| 12058 | struct bgp_info *ri_temp; |
| 12059 | struct bgp *bgp; |
| 12060 | struct bgp_table *table; |
| 12061 | |
| 12062 | /* BGP structure lookup. */ |
| 12063 | if (view_name) |
| 12064 | { |
| 12065 | bgp = bgp_lookup_by_name (view_name); |
| 12066 | if (bgp == NULL) |
| 12067 | { |
| 12068 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 12069 | return CMD_WARNING; |
| 12070 | } |
| 12071 | } |
| 12072 | else |
| 12073 | { |
| 12074 | bgp = bgp_get_default (); |
| 12075 | if (bgp == NULL) |
| 12076 | { |
| 12077 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 12078 | return CMD_WARNING; |
| 12079 | } |
| 12080 | } |
| 12081 | |
| 12082 | /* Check IP address argument. */ |
| 12083 | ret = str2prefix (ip_str, &match); |
| 12084 | if (! ret) |
| 12085 | { |
| 12086 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 12087 | return CMD_WARNING; |
| 12088 | } |
| 12089 | |
| 12090 | match.family = afi2family (afi); |
| 12091 | |
| 12092 | if (safi == SAFI_MPLS_VPN) |
| 12093 | { |
| 12094 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 12095 | { |
| 12096 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 12097 | continue; |
| 12098 | |
| 12099 | if ((table = rn->info) != NULL) |
| 12100 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12101 | { |
| 12102 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 12103 | { |
| 12104 | ri = rm->info; |
| 12105 | while (ri) |
| 12106 | { |
| 12107 | if (ri->extra && ri->extra->damp_info) |
| 12108 | { |
| 12109 | ri_temp = ri->next; |
| 12110 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12111 | ri = ri_temp; |
| 12112 | } |
| 12113 | else |
| 12114 | ri = ri->next; |
| 12115 | } |
| 12116 | } |
| 12117 | |
| 12118 | bgp_unlock_node (rm); |
| 12119 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12120 | } |
| 12121 | } |
| 12122 | else |
| 12123 | { |
| 12124 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12125 | { |
| 12126 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 12127 | { |
| 12128 | ri = rn->info; |
| 12129 | while (ri) |
| 12130 | { |
| 12131 | if (ri->extra && ri->extra->damp_info) |
| 12132 | { |
| 12133 | ri_temp = ri->next; |
| 12134 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12135 | ri = ri_temp; |
| 12136 | } |
| 12137 | else |
| 12138 | ri = ri->next; |
| 12139 | } |
| 12140 | } |
| 12141 | |
| 12142 | bgp_unlock_node (rn); |
| 12143 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12144 | } |
| 12145 | |
| 12146 | return CMD_SUCCESS; |
| 12147 | } |
| 12148 | |
| 12149 | DEFUN (clear_ip_bgp_dampening, |
| 12150 | clear_ip_bgp_dampening_cmd, |
| 12151 | "clear ip bgp dampening", |
| 12152 | CLEAR_STR |
| 12153 | IP_STR |
| 12154 | BGP_STR |
| 12155 | "Clear route flap dampening information\n") |
| 12156 | { |
| 12157 | bgp_damp_info_clean (); |
| 12158 | return CMD_SUCCESS; |
| 12159 | } |
| 12160 | |
| 12161 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 12162 | clear_ip_bgp_dampening_prefix_cmd, |
| 12163 | "clear ip bgp dampening A.B.C.D/M", |
| 12164 | CLEAR_STR |
| 12165 | IP_STR |
| 12166 | BGP_STR |
| 12167 | "Clear route flap dampening information\n" |
| 12168 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 12169 | { |
| 12170 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12171 | SAFI_UNICAST, NULL, 1); |
| 12172 | } |
| 12173 | |
| 12174 | DEFUN (clear_ip_bgp_dampening_address, |
| 12175 | clear_ip_bgp_dampening_address_cmd, |
| 12176 | "clear ip bgp dampening A.B.C.D", |
| 12177 | CLEAR_STR |
| 12178 | IP_STR |
| 12179 | BGP_STR |
| 12180 | "Clear route flap dampening information\n" |
| 12181 | "Network to clear damping information\n") |
| 12182 | { |
| 12183 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12184 | SAFI_UNICAST, NULL, 0); |
| 12185 | } |
| 12186 | |
| 12187 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 12188 | clear_ip_bgp_dampening_address_mask_cmd, |
| 12189 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 12190 | CLEAR_STR |
| 12191 | IP_STR |
| 12192 | BGP_STR |
| 12193 | "Clear route flap dampening information\n" |
| 12194 | "Network to clear damping information\n" |
| 12195 | "Network mask\n") |
| 12196 | { |
| 12197 | int ret; |
| 12198 | char prefix_str[BUFSIZ]; |
| 12199 | |
| 12200 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 12201 | if (! ret) |
| 12202 | { |
| 12203 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 12204 | return CMD_WARNING; |
| 12205 | } |
| 12206 | |
| 12207 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 12208 | SAFI_UNICAST, NULL, 0); |
| 12209 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12210 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12211 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12212 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 12213 | afi_t afi, safi_t safi, int *write) |
| 12214 | { |
| 12215 | struct bgp_node *prn; |
| 12216 | struct bgp_node *rn; |
| 12217 | struct bgp_table *table; |
| 12218 | struct prefix *p; |
| 12219 | struct prefix_rd *prd; |
| 12220 | struct bgp_static *bgp_static; |
| 12221 | u_int32_t label; |
| 12222 | char buf[SU_ADDRSTRLEN]; |
| 12223 | char rdbuf[RD_ADDRSTRLEN]; |
| 12224 | |
| 12225 | /* Network configuration. */ |
| 12226 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 12227 | if ((table = prn->info) != NULL) |
| 12228 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12229 | if ((bgp_static = rn->info) != NULL) |
| 12230 | { |
| 12231 | p = &rn->p; |
| 12232 | prd = (struct prefix_rd *) &prn->p; |
| 12233 | |
| 12234 | /* "address-family" display. */ |
| 12235 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12236 | |
| 12237 | /* "network" configuration display. */ |
| 12238 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 12239 | label = decode_label (bgp_static->tag); |
| 12240 | |
| 12241 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 12242 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12243 | p->prefixlen, |
| 12244 | rdbuf, label); |
| 12245 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12246 | } |
| 12247 | return 0; |
| 12248 | } |
| 12249 | |
| 12250 | /* Configuration of static route announcement and aggregate |
| 12251 | information. */ |
| 12252 | int |
| 12253 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 12254 | afi_t afi, safi_t safi, int *write) |
| 12255 | { |
| 12256 | struct bgp_node *rn; |
| 12257 | struct prefix *p; |
| 12258 | struct bgp_static *bgp_static; |
| 12259 | struct bgp_aggregate *bgp_aggregate; |
| 12260 | char buf[SU_ADDRSTRLEN]; |
| 12261 | |
| 12262 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 12263 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 12264 | |
| 12265 | /* Network configuration. */ |
| 12266 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12267 | if ((bgp_static = rn->info) != NULL) |
| 12268 | { |
| 12269 | p = &rn->p; |
| 12270 | |
| 12271 | /* "address-family" display. */ |
| 12272 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12273 | |
| 12274 | /* "network" configuration display. */ |
| 12275 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12276 | { |
| 12277 | u_int32_t destination; |
| 12278 | struct in_addr netmask; |
| 12279 | |
| 12280 | destination = ntohl (p->u.prefix4.s_addr); |
| 12281 | masklen2ip (p->prefixlen, &netmask); |
| 12282 | vty_out (vty, " network %s", |
| 12283 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 12284 | |
| 12285 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 12286 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 12287 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 12288 | || p->u.prefix4.s_addr == 0) |
| 12289 | { |
| 12290 | /* Natural mask is not display. */ |
| 12291 | } |
| 12292 | else |
| 12293 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 12294 | } |
| 12295 | else |
| 12296 | { |
| 12297 | vty_out (vty, " network %s/%d", |
| 12298 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12299 | p->prefixlen); |
| 12300 | } |
| 12301 | |
| 12302 | if (bgp_static->rmap.name) |
| 12303 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12304 | else |
| 12305 | { |
| 12306 | if (bgp_static->backdoor) |
| 12307 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12308 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12309 | |
| 12310 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12311 | } |
| 12312 | |
| 12313 | /* Aggregate-address configuration. */ |
| 12314 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12315 | if ((bgp_aggregate = rn->info) != NULL) |
| 12316 | { |
| 12317 | p = &rn->p; |
| 12318 | |
| 12319 | /* "address-family" display. */ |
| 12320 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12321 | |
| 12322 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12323 | { |
| 12324 | struct in_addr netmask; |
| 12325 | |
| 12326 | masklen2ip (p->prefixlen, &netmask); |
| 12327 | vty_out (vty, " aggregate-address %s %s", |
| 12328 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12329 | inet_ntoa (netmask)); |
| 12330 | } |
| 12331 | else |
| 12332 | { |
| 12333 | vty_out (vty, " aggregate-address %s/%d", |
| 12334 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12335 | p->prefixlen); |
| 12336 | } |
| 12337 | |
| 12338 | if (bgp_aggregate->as_set) |
| 12339 | vty_out (vty, " as-set"); |
| 12340 | |
| 12341 | if (bgp_aggregate->summary_only) |
| 12342 | vty_out (vty, " summary-only"); |
| 12343 | |
| 12344 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12345 | } |
| 12346 | |
| 12347 | return 0; |
| 12348 | } |
| 12349 | |
| 12350 | int |
| 12351 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 12352 | { |
| 12353 | struct bgp_node *rn; |
| 12354 | struct bgp_distance *bdistance; |
| 12355 | |
| 12356 | /* Distance configuration. */ |
| 12357 | if (bgp->distance_ebgp |
| 12358 | && bgp->distance_ibgp |
| 12359 | && bgp->distance_local |
| 12360 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 12361 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 12362 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 12363 | vty_out (vty, " distance bgp %d %d %d%s", |
| 12364 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 12365 | VTY_NEWLINE); |
| 12366 | |
| 12367 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 12368 | if ((bdistance = rn->info) != NULL) |
| 12369 | { |
| 12370 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 12371 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 12372 | bdistance->access_list ? bdistance->access_list : "", |
| 12373 | VTY_NEWLINE); |
| 12374 | } |
| 12375 | |
| 12376 | return 0; |
| 12377 | } |
| 12378 | |
| 12379 | /* Allocate routing table structure and install commands. */ |
| 12380 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 12381 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12382 | { |
| 12383 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 12384 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12385 | |
| 12386 | /* IPv4 BGP commands. */ |
| 12387 | install_element (BGP_NODE, &bgp_network_cmd); |
| 12388 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 12389 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 12390 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 12391 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 12392 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12393 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 12394 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 12395 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 12396 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 12397 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 12398 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 12399 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 12400 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12401 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12402 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 12403 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 12404 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 12405 | |
| 12406 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 12407 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 12408 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 12409 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12410 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 12411 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 12412 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 12413 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12414 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 12415 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12416 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 12417 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 12418 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 12419 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12420 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12421 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 12422 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12423 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12424 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12425 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12426 | |
| 12427 | /* IPv4 unicast configuration. */ |
| 12428 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 12429 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 12430 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 12431 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 12432 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 12433 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 12434 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12435 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 12436 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 12437 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 12438 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12439 | 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] | 12440 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12441 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 12442 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 12443 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 12444 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12445 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 12446 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 12447 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 12448 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12449 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 12450 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12451 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 12452 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 12453 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 12454 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12455 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12456 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 12457 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12458 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12459 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12460 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12461 | |
| 12462 | /* IPv4 multicast configuration. */ |
| 12463 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 12464 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 12465 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 12466 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 12467 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 12468 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12469 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 12470 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 12471 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 12472 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 12473 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12474 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12475 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 12476 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 12477 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 12478 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12479 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 12480 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 12481 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 12482 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12483 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 12484 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12485 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 12486 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 12487 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 12488 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12489 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12490 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 12491 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12492 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12493 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12494 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12495 | |
| 12496 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 12497 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12498 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12499 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 12500 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12501 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12502 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12503 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12504 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 12505 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12506 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12507 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12508 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12509 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 12510 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 12511 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12512 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 12513 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12514 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12515 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12516 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 12517 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12518 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 12519 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12520 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12521 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12522 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 12523 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12524 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 12525 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 12526 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 12527 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 12528 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12529 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12530 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12531 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12532 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12533 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12534 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12535 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12536 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12537 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 12538 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12539 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12540 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12541 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12542 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12543 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12544 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12545 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 12546 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12547 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12548 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12549 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12550 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12551 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12552 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12553 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12554 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12555 | 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] | 12556 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12557 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12558 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12559 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 12560 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 12561 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 12562 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 12563 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12564 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 12565 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12566 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 12567 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 12568 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 12569 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 12570 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12571 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12572 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12573 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12574 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12575 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12576 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12577 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12578 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12579 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12580 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12581 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12582 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12583 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12584 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12585 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12586 | |
| 12587 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
| 12588 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
| 12589 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12590 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12591 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12592 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 12593 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12594 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12595 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12596 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12597 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 12598 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12599 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 12600 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 12601 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 12602 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 12603 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12604 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12605 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12606 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12607 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12608 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12609 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12610 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12611 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12612 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 12613 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12614 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12615 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12616 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12617 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12618 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12619 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12620 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12621 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12622 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12623 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12624 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12625 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12626 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12627 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12628 | |
| 12629 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 12630 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12631 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12632 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 12633 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12634 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12635 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12636 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12637 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 12638 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12639 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12640 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12641 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12642 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 12643 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 12644 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12645 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 12646 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12647 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12648 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12649 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 12650 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12651 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 12652 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12653 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12654 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12655 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 12656 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12657 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 12658 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 12659 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 12660 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 12661 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12662 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12663 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12664 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12665 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12666 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12667 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12668 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12669 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12670 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 12671 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12672 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12673 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12674 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12675 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12676 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12677 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12678 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 12679 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12680 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12681 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12682 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12683 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12684 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12685 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12686 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12687 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12688 | 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] | 12689 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12690 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12691 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12692 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 12693 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 12694 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 12695 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 12696 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12697 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 12698 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12699 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 12700 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 12701 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 12702 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 12703 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12704 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12705 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12706 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12707 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12708 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12709 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12710 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12711 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12712 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12713 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12714 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12715 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12716 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12717 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12718 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12719 | |
| 12720 | /* BGP dampening clear commands */ |
| 12721 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 12722 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 12723 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 12724 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 12725 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12726 | /* prefix count */ |
| 12727 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 12728 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 12729 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12730 | #ifdef HAVE_IPV6 |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12731 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 12732 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12733 | /* New config IPv6 BGP commands. */ |
| 12734 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 12735 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 12736 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 12737 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 12738 | |
| 12739 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 12740 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 12741 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 12742 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 12743 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 12744 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 12745 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 12746 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12747 | /* Old config IPv6 BGP commands. */ |
| 12748 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 12749 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 12750 | |
| 12751 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 12752 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 12753 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 12754 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 12755 | |
| 12756 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 12757 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12758 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12759 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 12760 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12761 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12762 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 12763 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12764 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12765 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 12766 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12767 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 12768 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12769 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 12770 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12771 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 12772 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12773 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 12774 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12775 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 12776 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 12777 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 12778 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 12779 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 12780 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 12781 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 12782 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 12783 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 12784 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12785 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 12786 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12787 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 12788 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12789 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 12790 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12791 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 12792 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12793 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 12794 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12795 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 12796 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12797 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12798 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12799 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12800 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12801 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 12802 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12803 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12804 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12805 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 12806 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12807 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 12808 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12809 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12810 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12811 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12812 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12813 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12814 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12815 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 12816 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 12817 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 12818 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12819 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 12820 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12821 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12822 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12823 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12824 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12825 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12826 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12827 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12828 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12829 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12830 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12831 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12832 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12833 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12834 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12835 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12836 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12837 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12838 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12839 | |
| 12840 | /* Restricted: |
| 12841 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 12842 | */ |
| 12843 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 12844 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12845 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12846 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
| 12847 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12848 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12849 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 12850 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 12851 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 12852 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 12853 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 12854 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 12855 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 12856 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 12857 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 12858 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12859 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 12860 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12861 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 12862 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12863 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 12864 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12865 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12866 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12867 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12868 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12869 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 12870 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12871 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 12872 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12873 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12874 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12875 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12876 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12877 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12878 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12879 | |
| 12880 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 12881 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12882 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12883 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 12884 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12885 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12886 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 12887 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12888 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12889 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 12890 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12891 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 12892 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12893 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 12894 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12895 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 12896 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12897 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 12898 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12899 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 12900 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 12901 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 12902 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 12903 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 12904 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 12905 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 12906 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 12907 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 12908 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12909 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 12910 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12911 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 12912 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12913 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 12914 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12915 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 12916 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12917 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 12918 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12919 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 12920 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12921 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12922 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12923 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12924 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12925 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 12926 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12927 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12928 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12929 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 12930 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12931 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 12932 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12933 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12934 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12935 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12936 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12937 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12938 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12939 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 12940 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 12941 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 12942 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12943 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 12944 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12945 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12946 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12947 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12948 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12949 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12950 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12951 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12952 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12953 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12954 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12955 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12956 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12957 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12958 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12959 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12960 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12961 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12962 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12963 | |
| 12964 | /* Statistics */ |
| 12965 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
| 12966 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 12967 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
| 12968 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
| 12969 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12970 | /* old command */ |
| 12971 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 12972 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 12973 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 12974 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 12975 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 12976 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 12977 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 12978 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 12979 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 12980 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 12981 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 12982 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 12983 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 12984 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 12985 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 12986 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 12987 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 12988 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 12989 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 12990 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 12991 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 12992 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 12993 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 12994 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 12995 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 12996 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 12997 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 12998 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 12999 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 13000 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 13001 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 13002 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 13003 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 13004 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 13005 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 13006 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13007 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13008 | /* old command */ |
| 13009 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 13010 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 13011 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 13012 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 13013 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 13014 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 13015 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 13016 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 13017 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 13018 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 13019 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 13020 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 13021 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 13022 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 13023 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 13024 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 13025 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 13026 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 13027 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 13028 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 13029 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 13030 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 13031 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 13032 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 13033 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 13034 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 13035 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 13036 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 13037 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 13038 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 13039 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 13040 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 13041 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 13042 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 13043 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 13044 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 13045 | |
| 13046 | /* old command */ |
| 13047 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13048 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13049 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13050 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13051 | |
| 13052 | /* old command */ |
| 13053 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13054 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13055 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13056 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13057 | |
| 13058 | /* old command */ |
| 13059 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13060 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13061 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13062 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13063 | #endif /* HAVE_IPV6 */ |
| 13064 | |
| 13065 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 13066 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 13067 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 13068 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 13069 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 13070 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 13071 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 13072 | |
| 13073 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 13074 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 13075 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 13076 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 13077 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 13078 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 13079 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 13080 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 13081 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 13082 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13083 | |
| 13084 | /* Deprecated AS-Pathlimit commands */ |
| 13085 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 13086 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 13087 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13088 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13089 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13090 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13091 | |
| 13092 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 13093 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13094 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13095 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13096 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13097 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13098 | |
| 13099 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 13100 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 13101 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13102 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13103 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13104 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13105 | |
| 13106 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 13107 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13108 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13109 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13110 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13111 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13112 | |
| 13113 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 13114 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 13115 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13116 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13117 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13118 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13119 | |
| 13120 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 13121 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13122 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13123 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13124 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13125 | 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] | 13126 | |
| 13127 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13128 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 13129 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 13130 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13131 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 13132 | |
| 13133 | void |
| 13134 | bgp_route_finish (void) |
| 13135 | { |
| 13136 | bgp_table_unlock (bgp_distance_table); |
| 13137 | bgp_distance_table = NULL; |
| 13138 | } |