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) |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 716 | /* caller has multiple error paths with bgp_attr_flush() */ |
| 717 | return RMAP_DENY; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 718 | } |
| 719 | return RMAP_PERMIT; |
| 720 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 721 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 722 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 723 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 724 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 725 | { |
| 726 | struct bgp_filter *filter; |
| 727 | struct bgp_info info; |
| 728 | route_map_result_t ret; |
| 729 | |
| 730 | filter = &peer->filter[afi][safi]; |
| 731 | |
| 732 | /* Route map apply. */ |
| 733 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 734 | { |
| 735 | /* Duplicate current value to new strucutre for modification. */ |
| 736 | info.peer = rsclient; |
| 737 | info.attr = attr; |
| 738 | |
| 739 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 740 | |
| 741 | /* Apply BGP route map to the attribute. */ |
| 742 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 743 | |
| 744 | rsclient->rmap_type = 0; |
| 745 | |
| 746 | if (ret == RMAP_DENYMATCH) |
| 747 | { |
| 748 | /* Free newly generated AS path and community by route-map. */ |
| 749 | bgp_attr_flush (attr); |
| 750 | return RMAP_DENY; |
| 751 | } |
| 752 | } |
| 753 | return RMAP_PERMIT; |
| 754 | } |
| 755 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 756 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 757 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 758 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 759 | { |
| 760 | struct bgp_filter *filter; |
| 761 | struct bgp_info info; |
| 762 | route_map_result_t ret; |
| 763 | |
| 764 | filter = &rsclient->filter[afi][safi]; |
| 765 | |
| 766 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 767 | if (peer->weight) |
| 768 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 769 | |
| 770 | /* Route map apply. */ |
| 771 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 772 | { |
| 773 | /* Duplicate current value to new strucutre for modification. */ |
| 774 | info.peer = peer; |
| 775 | info.attr = attr; |
| 776 | |
| 777 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 778 | |
| 779 | /* Apply BGP route map to the attribute. */ |
| 780 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 781 | |
| 782 | peer->rmap_type = 0; |
| 783 | |
| 784 | if (ret == RMAP_DENYMATCH) |
| 785 | { |
| 786 | /* Free newly generated AS path and community by route-map. */ |
| 787 | bgp_attr_flush (attr); |
| 788 | return RMAP_DENY; |
| 789 | } |
| 790 | } |
| 791 | return RMAP_PERMIT; |
| 792 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 793 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 794 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 795 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 796 | struct attr *attr, afi_t afi, safi_t safi) |
| 797 | { |
| 798 | int ret; |
| 799 | char buf[SU_ADDRSTRLEN]; |
| 800 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 801 | struct peer *from; |
| 802 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 803 | int transparent; |
| 804 | int reflect; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 805 | struct attr *riattr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 806 | |
| 807 | from = ri->peer; |
| 808 | filter = &peer->filter[afi][safi]; |
| 809 | bgp = peer->bgp; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 810 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 811 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 812 | if (DISABLE_BGP_ANNOUNCE) |
| 813 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 814 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 815 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 816 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 817 | return 0; |
| 818 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 819 | /* Do not send back route to sender. */ |
| 820 | if (from == peer) |
| 821 | return 0; |
| 822 | |
| 823 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 824 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 825 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 826 | return 0; |
| 827 | |
| 828 | /* Default route check. */ |
| 829 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 830 | { |
| 831 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 832 | return 0; |
| 833 | #ifdef HAVE_IPV6 |
| 834 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 835 | return 0; |
| 836 | #endif /* HAVE_IPV6 */ |
| 837 | } |
| 838 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 839 | /* Transparency check. */ |
| 840 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 841 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 842 | transparent = 1; |
| 843 | else |
| 844 | transparent = 0; |
| 845 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 846 | /* If community is not disabled check the no-export and local. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 847 | if (! transparent && bgp_community_filter (peer, riattr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 848 | return 0; |
| 849 | |
| 850 | /* If the attribute has originator-id and it is same as remote |
| 851 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 852 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 853 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 854 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 855 | { |
| 856 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 857 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 858 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 859 | peer->host, |
| 860 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 861 | p->prefixlen); |
| 862 | return 0; |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | /* ORF prefix-list filter check */ |
| 867 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 868 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 869 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 870 | if (peer->orf_plist[afi][safi]) |
| 871 | { |
| 872 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 873 | return 0; |
| 874 | } |
| 875 | |
| 876 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 877 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 878 | { |
| 879 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 880 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 881 | "%s [Update:SEND] %s/%d is filtered", |
| 882 | peer->host, |
| 883 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 884 | p->prefixlen); |
| 885 | return 0; |
| 886 | } |
| 887 | |
| 888 | #ifdef BGP_SEND_ASPATH_CHECK |
| 889 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 890 | if (aspath_loop_check (riattr->aspath, peer->as)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 891 | { |
| 892 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 893 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 894 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 895 | peer->host, peer->as); |
| 896 | return 0; |
| 897 | } |
| 898 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 899 | |
| 900 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 901 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 902 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 903 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 904 | { |
| 905 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 906 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 907 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 908 | peer->host, |
| 909 | bgp->confed_id); |
| 910 | return 0; |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | /* Route-Reflect check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 915 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 916 | reflect = 1; |
| 917 | else |
| 918 | reflect = 0; |
| 919 | |
| 920 | /* IBGP reflection check. */ |
| 921 | if (reflect) |
| 922 | { |
| 923 | /* A route from a Client peer. */ |
| 924 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 925 | { |
| 926 | /* Reflect to all the Non-Client peers and also to the |
| 927 | Client peers other than the originator. Originator check |
| 928 | is already done. So there is noting to do. */ |
| 929 | /* no bgp client-to-client reflection check. */ |
| 930 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 931 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 932 | return 0; |
| 933 | } |
| 934 | else |
| 935 | { |
| 936 | /* A route from a Non-client peer. Reflect to all other |
| 937 | clients. */ |
| 938 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 939 | return 0; |
| 940 | } |
| 941 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 942 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 943 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 944 | bgp_attr_dup (attr, riattr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 945 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 946 | /* If local-preference is not set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 947 | if ((peer->sort == BGP_PEER_IBGP |
| 948 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 949 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 950 | { |
| 951 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 952 | attr->local_pref = bgp->default_local_pref; |
| 953 | } |
| 954 | |
Pradosh Mohapatra | 689bb66 | 2013-09-07 07:13:37 +0000 | [diff] [blame] | 955 | /* If originator-id is not set and the route is to be reflected, |
| 956 | set the originator id */ |
| 957 | if (peer && from && peer->sort == BGP_PEER_IBGP && |
| 958 | from->sort == BGP_PEER_IBGP && |
| 959 | (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) |
| 960 | { |
| 961 | attr->extra = bgp_attr_extra_get(attr); |
| 962 | IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id)); |
| 963 | SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID); |
| 964 | } |
| 965 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 966 | /* 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] | 967 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 968 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 969 | { |
| 970 | if (ri->peer != bgp->peer_self && ! transparent |
| 971 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 972 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 973 | } |
| 974 | |
| 975 | /* next-hop-set */ |
| 976 | if (transparent || reflect |
| 977 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 978 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 979 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 980 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 981 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 982 | #endif /* HAVE_IPV6 */ |
| 983 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 984 | { |
| 985 | /* NEXT-HOP Unchanged. */ |
| 986 | } |
| 987 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 988 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 989 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 990 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 991 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 992 | #endif /* HAVE_IPV6 */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 993 | || (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 994 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 995 | { |
| 996 | /* Set IPv4 nexthop. */ |
| 997 | if (p->family == AF_INET) |
| 998 | { |
| 999 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1000 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 1001 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1002 | else |
| 1003 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1004 | } |
| 1005 | #ifdef HAVE_IPV6 |
| 1006 | /* Set IPv6 nexthop. */ |
| 1007 | if (p->family == AF_INET6) |
| 1008 | { |
| 1009 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1010 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1011 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1012 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1013 | } |
| 1014 | #endif /* HAVE_IPV6 */ |
| 1015 | } |
| 1016 | |
| 1017 | #ifdef HAVE_IPV6 |
| 1018 | if (p->family == AF_INET6) |
| 1019 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1020 | /* Left nexthop_local unchanged if so configured. */ |
| 1021 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 1022 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1023 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1024 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 1025 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1026 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1027 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1028 | } |
| 1029 | |
| 1030 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 1031 | else |
| 1032 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1033 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1034 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1035 | |
| 1036 | /* Set link-local address for shared network peer. */ |
| 1037 | if (peer->shared_network |
| 1038 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 1039 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1040 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1041 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1042 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1043 | } |
| 1044 | |
| 1045 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 1046 | address.*/ |
| 1047 | if (reflect) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1048 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1049 | |
| 1050 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 1051 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1052 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1053 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1054 | |
| 1055 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1056 | #endif /* HAVE_IPV6 */ |
| 1057 | |
| 1058 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1059 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1060 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1061 | && aspath_private_as_check (attr->aspath)) |
| 1062 | attr->aspath = aspath_empty_get (); |
| 1063 | |
| 1064 | /* Route map & unsuppress-map apply. */ |
| 1065 | if (ROUTE_MAP_OUT_NAME (filter) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1066 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1067 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1068 | struct bgp_info info; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1069 | struct attr dummy_attr; |
| 1070 | struct attr_extra dummy_extra; |
| 1071 | |
| 1072 | dummy_attr.extra = &dummy_extra; |
| 1073 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1074 | info.peer = peer; |
| 1075 | info.attr = attr; |
| 1076 | |
| 1077 | /* The route reflector is not allowed to modify the attributes |
| 1078 | of the reflected IBGP routes. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1079 | if (from->sort == BGP_PEER_IBGP |
| 1080 | && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1081 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1082 | bgp_attr_dup (&dummy_attr, attr); |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1083 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1084 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1085 | |
| 1086 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1087 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1088 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1089 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1090 | else |
| 1091 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1092 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1093 | peer->rmap_type = 0; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1094 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1095 | if (ret == RMAP_DENYMATCH) |
| 1096 | { |
| 1097 | bgp_attr_flush (attr); |
| 1098 | return 0; |
| 1099 | } |
| 1100 | } |
| 1101 | return 1; |
| 1102 | } |
| 1103 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1104 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1105 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1106 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1107 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1108 | int ret; |
| 1109 | char buf[SU_ADDRSTRLEN]; |
| 1110 | struct bgp_filter *filter; |
| 1111 | struct bgp_info info; |
| 1112 | struct peer *from; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1113 | struct attr *riattr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1114 | |
| 1115 | from = ri->peer; |
| 1116 | filter = &rsclient->filter[afi][safi]; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1117 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1118 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 1119 | if (DISABLE_BGP_ANNOUNCE) |
| 1120 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1121 | |
| 1122 | /* Do not send back route to sender. */ |
| 1123 | if (from == rsclient) |
| 1124 | return 0; |
| 1125 | |
| 1126 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1127 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1128 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 1129 | return 0; |
| 1130 | |
| 1131 | /* Default route check. */ |
| 1132 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1133 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1134 | { |
| 1135 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1136 | return 0; |
| 1137 | #ifdef HAVE_IPV6 |
| 1138 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1139 | return 0; |
| 1140 | #endif /* HAVE_IPV6 */ |
| 1141 | } |
| 1142 | |
| 1143 | /* If the attribute has originator-id and it is same as remote |
| 1144 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1145 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1146 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1147 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1148 | &riattr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1149 | { |
| 1150 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1151 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1152 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1153 | rsclient->host, |
| 1154 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1155 | p->prefixlen); |
| 1156 | return 0; |
| 1157 | } |
| 1158 | } |
| 1159 | |
| 1160 | /* ORF prefix-list filter check */ |
| 1161 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1162 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1163 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1164 | if (rsclient->orf_plist[afi][safi]) |
| 1165 | { |
| 1166 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1167 | return 0; |
| 1168 | } |
| 1169 | |
| 1170 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1171 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1172 | { |
| 1173 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1174 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1175 | "%s [Update:SEND] %s/%d is filtered", |
| 1176 | rsclient->host, |
| 1177 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1178 | p->prefixlen); |
| 1179 | return 0; |
| 1180 | } |
| 1181 | |
| 1182 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1183 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1184 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1185 | { |
| 1186 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1187 | zlog (rsclient->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 1188 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1189 | rsclient->host, rsclient->as); |
| 1190 | return 0; |
| 1191 | } |
| 1192 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1193 | |
| 1194 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1195 | bgp_attr_dup (attr, riattr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1196 | |
| 1197 | /* next-hop-set */ |
| 1198 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1199 | #ifdef HAVE_IPV6 |
| 1200 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1201 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1202 | #endif /* HAVE_IPV6 */ |
| 1203 | ) |
| 1204 | { |
| 1205 | /* Set IPv4 nexthop. */ |
| 1206 | if (p->family == AF_INET) |
| 1207 | { |
| 1208 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1209 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1210 | IPV4_MAX_BYTELEN); |
| 1211 | else |
| 1212 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1213 | } |
| 1214 | #ifdef HAVE_IPV6 |
| 1215 | /* Set IPv6 nexthop. */ |
| 1216 | if (p->family == AF_INET6) |
| 1217 | { |
| 1218 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1219 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1220 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1221 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1222 | } |
| 1223 | #endif /* HAVE_IPV6 */ |
| 1224 | } |
| 1225 | |
| 1226 | #ifdef HAVE_IPV6 |
| 1227 | if (p->family == AF_INET6) |
| 1228 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1229 | struct attr_extra *attre = attr->extra; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1230 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1231 | /* Left nexthop_local unchanged if so configured. */ |
| 1232 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1233 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1234 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1235 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1236 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1237 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1238 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1239 | } |
| 1240 | |
| 1241 | /* Default nexthop_local treatment for RS-Clients */ |
| 1242 | else |
| 1243 | { |
| 1244 | /* Announcer and RS-Client are both in the same network */ |
| 1245 | if (rsclient->shared_network && from->shared_network && |
| 1246 | (rsclient->ifindex == from->ifindex)) |
| 1247 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1248 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1249 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1250 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1251 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1252 | } |
| 1253 | |
| 1254 | /* Set link-local address for shared network peer. */ |
| 1255 | else if (rsclient->shared_network |
| 1256 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1257 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1258 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1259 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1260 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1261 | } |
| 1262 | |
| 1263 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1264 | attre->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1265 | } |
| 1266 | |
| 1267 | } |
| 1268 | #endif /* HAVE_IPV6 */ |
| 1269 | |
| 1270 | |
| 1271 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1272 | if (rsclient->sort == BGP_PEER_EBGP |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1273 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1274 | && aspath_private_as_check (attr->aspath)) |
| 1275 | attr->aspath = aspath_empty_get (); |
| 1276 | |
| 1277 | /* Route map & unsuppress-map apply. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1278 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1279 | { |
| 1280 | info.peer = rsclient; |
| 1281 | info.attr = attr; |
| 1282 | |
| 1283 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1284 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1285 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1286 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1287 | else |
| 1288 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1289 | |
| 1290 | rsclient->rmap_type = 0; |
| 1291 | |
| 1292 | if (ret == RMAP_DENYMATCH) |
| 1293 | { |
| 1294 | bgp_attr_flush (attr); |
| 1295 | return 0; |
| 1296 | } |
| 1297 | } |
| 1298 | |
| 1299 | return 1; |
| 1300 | } |
| 1301 | |
| 1302 | struct bgp_info_pair |
| 1303 | { |
| 1304 | struct bgp_info *old; |
| 1305 | struct bgp_info *new; |
| 1306 | }; |
| 1307 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1308 | static void |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1309 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
| 1310 | struct bgp_maxpaths_cfg *mpath_cfg, |
| 1311 | struct bgp_info_pair *result) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1312 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1313 | struct bgp_info *new_select; |
| 1314 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1315 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1316 | struct bgp_info *ri1; |
| 1317 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1318 | struct bgp_info *nextri = NULL; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1319 | int paths_eq, do_mpath; |
| 1320 | struct list mp_list; |
| 1321 | |
| 1322 | bgp_mp_list_init (&mp_list); |
| 1323 | do_mpath = (mpath_cfg->maxpaths_ebgp != BGP_DEFAULT_MAXPATHS || |
| 1324 | mpath_cfg->maxpaths_ibgp != BGP_DEFAULT_MAXPATHS); |
| 1325 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1326 | /* bgp deterministic-med */ |
| 1327 | new_select = NULL; |
| 1328 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1329 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1330 | { |
| 1331 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1332 | continue; |
| 1333 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1334 | continue; |
| 1335 | |
| 1336 | new_select = ri1; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1337 | if (do_mpath) |
| 1338 | bgp_mp_list_add (&mp_list, ri1); |
| 1339 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1340 | if (ri1->next) |
| 1341 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1342 | { |
| 1343 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1344 | continue; |
| 1345 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1346 | continue; |
| 1347 | |
| 1348 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1349 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1350 | ri2->attr->aspath)) |
| 1351 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1352 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
| 1353 | old_select = ri2; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1354 | if (bgp_info_cmp (bgp, ri2, new_select, &paths_eq)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1355 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1356 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1357 | new_select = ri2; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1358 | if (do_mpath && !paths_eq) |
| 1359 | { |
| 1360 | bgp_mp_list_clear (&mp_list); |
| 1361 | bgp_mp_list_add (&mp_list, ri2); |
| 1362 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1363 | } |
| 1364 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1365 | if (do_mpath && paths_eq) |
| 1366 | bgp_mp_list_add (&mp_list, ri2); |
| 1367 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1368 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1369 | } |
| 1370 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1371 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1372 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1373 | |
| 1374 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg); |
| 1375 | bgp_mp_list_clear (&mp_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1376 | } |
| 1377 | |
| 1378 | /* Check old selected route and new selected route. */ |
| 1379 | old_select = NULL; |
| 1380 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1381 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1382 | { |
| 1383 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1384 | old_select = ri; |
| 1385 | |
| 1386 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1387 | { |
| 1388 | /* reap REMOVED routes, if needs be |
| 1389 | * selected route must stay for a while longer though |
| 1390 | */ |
| 1391 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1392 | && (ri != old_select)) |
| 1393 | bgp_info_reap (rn, ri); |
| 1394 | |
| 1395 | continue; |
| 1396 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1397 | |
| 1398 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1399 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1400 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1401 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1402 | continue; |
| 1403 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1404 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1405 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1406 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1407 | if (bgp_info_cmp (bgp, ri, new_select, &paths_eq)) |
| 1408 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1409 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1410 | bgp_mp_dmed_deselect (new_select); |
| 1411 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1412 | new_select = ri; |
| 1413 | |
| 1414 | if (do_mpath && !paths_eq) |
| 1415 | { |
| 1416 | bgp_mp_list_clear (&mp_list); |
| 1417 | bgp_mp_list_add (&mp_list, ri); |
| 1418 | } |
| 1419 | } |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1420 | else if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1421 | bgp_mp_dmed_deselect (ri); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1422 | |
| 1423 | if (do_mpath && paths_eq) |
| 1424 | bgp_mp_list_add (&mp_list, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1425 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1426 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1427 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1428 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1429 | 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] | 1430 | |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1431 | bgp_info_mpath_aggregate_update (new_select, old_select); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1432 | bgp_mp_list_clear (&mp_list); |
| 1433 | |
| 1434 | result->old = old_select; |
| 1435 | result->new = new_select; |
| 1436 | |
| 1437 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1438 | } |
| 1439 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1440 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1441 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1442 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1443 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1444 | struct prefix *p; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1445 | struct attr attr; |
| 1446 | struct attr_extra extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1447 | |
| 1448 | p = &rn->p; |
| 1449 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1450 | /* Announce route to Established peer. */ |
| 1451 | if (peer->status != Established) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1452 | return 0; |
| 1453 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1454 | /* Address family configuration check. */ |
| 1455 | if (! peer->afc_nego[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1456 | return 0; |
| 1457 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1458 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1459 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1460 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1461 | return 0; |
| 1462 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1463 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 1464 | attr.extra = &extra; |
| 1465 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1466 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1467 | { |
| 1468 | case BGP_TABLE_MAIN: |
| 1469 | /* Announcement to peer->conf. If the route is filtered, |
| 1470 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1471 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
| 1472 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1473 | else |
| 1474 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1475 | break; |
| 1476 | case BGP_TABLE_RSCLIENT: |
| 1477 | /* Announcement to peer->conf. If the route is filtered, |
| 1478 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1479 | if (selected && |
| 1480 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) |
| 1481 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
| 1482 | else |
| 1483 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1484 | break; |
| 1485 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1486 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1487 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1488 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1489 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1490 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1491 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1492 | struct bgp *bgp; |
| 1493 | struct bgp_node *rn; |
| 1494 | afi_t afi; |
| 1495 | safi_t safi; |
| 1496 | }; |
| 1497 | |
| 1498 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1499 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1500 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1501 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1502 | struct bgp *bgp = pq->bgp; |
| 1503 | struct bgp_node *rn = pq->rn; |
| 1504 | afi_t afi = pq->afi; |
| 1505 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1506 | struct bgp_info *new_select; |
| 1507 | struct bgp_info *old_select; |
| 1508 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1509 | struct listnode *node, *nnode; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1510 | struct peer *rsclient = bgp_node_table (rn)->owner; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1511 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1512 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1513 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1514 | new_select = old_and_new.new; |
| 1515 | old_select = old_and_new.old; |
| 1516 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1517 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1518 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1519 | if (rsclient->group) |
| 1520 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1521 | { |
| 1522 | /* Nothing to do. */ |
| 1523 | if (old_select && old_select == new_select) |
| 1524 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1525 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1526 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1527 | if (old_select) |
| 1528 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
| 1529 | if (new_select) |
| 1530 | { |
| 1531 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1532 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1533 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
| 1534 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1535 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1536 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1537 | afi, safi); |
| 1538 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1539 | } |
| 1540 | else |
| 1541 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1542 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1543 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1544 | if (new_select) |
| 1545 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1546 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1547 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1548 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1549 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1550 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1551 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1552 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1553 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1554 | bgp_info_reap (rn, old_select); |
| 1555 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1556 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1557 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1558 | } |
| 1559 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1560 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1561 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1562 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1563 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1564 | struct bgp *bgp = pq->bgp; |
| 1565 | struct bgp_node *rn = pq->rn; |
| 1566 | afi_t afi = pq->afi; |
| 1567 | safi_t safi = pq->safi; |
| 1568 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1569 | struct bgp_info *new_select; |
| 1570 | struct bgp_info *old_select; |
| 1571 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1572 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1573 | struct peer *peer; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1574 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1575 | /* Best path selection. */ |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1576 | bgp_best_selection (bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1577 | old_select = old_and_new.old; |
| 1578 | new_select = old_and_new.new; |
| 1579 | |
| 1580 | /* Nothing to do. */ |
| 1581 | if (old_select && old_select == new_select) |
| 1582 | { |
| 1583 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1584 | { |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1585 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
| 1586 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1587 | bgp_zebra_announce (p, old_select, bgp, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1588 | |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1589 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1590 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1591 | return WQ_SUCCESS; |
| 1592 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1593 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1594 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1595 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1596 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1597 | if (new_select) |
| 1598 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1599 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1600 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1601 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1602 | } |
| 1603 | |
| 1604 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1605 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1606 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1607 | { |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1608 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1609 | } |
| 1610 | |
| 1611 | /* FIB update. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1612 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
| 1613 | ! bgp_option_check (BGP_OPT_NO_FIB))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1614 | { |
| 1615 | if (new_select |
| 1616 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1617 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1618 | bgp_zebra_announce (p, new_select, bgp, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1619 | else |
| 1620 | { |
| 1621 | /* Withdraw the route from the kernel. */ |
| 1622 | if (old_select |
| 1623 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1624 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1625 | bgp_zebra_withdraw (p, old_select, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1626 | } |
| 1627 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1628 | |
| 1629 | /* Reap old select bgp_info, it it has been removed */ |
| 1630 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1631 | bgp_info_reap (rn, old_select); |
| 1632 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1633 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1634 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1635 | } |
| 1636 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1637 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1638 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1639 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1640 | struct bgp_process_queue *pq = data; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1641 | struct bgp_table *table = bgp_node_table (pq->rn); |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1642 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1643 | bgp_unlock (pq->bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1644 | bgp_unlock_node (pq->rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1645 | bgp_table_unlock (table); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1646 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1647 | } |
| 1648 | |
| 1649 | static void |
| 1650 | bgp_process_queue_init (void) |
| 1651 | { |
| 1652 | bm->process_main_queue |
| 1653 | = work_queue_new (bm->master, "process_main_queue"); |
| 1654 | bm->process_rsclient_queue |
| 1655 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1656 | |
| 1657 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1658 | { |
| 1659 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1660 | exit (1); |
| 1661 | } |
| 1662 | |
| 1663 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1664 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1665 | bm->process_main_queue->spec.max_retries = 0; |
| 1666 | bm->process_main_queue->spec.hold = 50; |
| 1667 | |
| 1668 | memcpy (bm->process_rsclient_queue, bm->process_main_queue, |
| 1669 | sizeof (struct work_queue *)); |
| 1670 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1671 | } |
| 1672 | |
| 1673 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1674 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1675 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1676 | struct bgp_process_queue *pqnode; |
| 1677 | |
| 1678 | /* already scheduled for processing? */ |
| 1679 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1680 | return; |
| 1681 | |
| 1682 | if ( (bm->process_main_queue == NULL) || |
| 1683 | (bm->process_rsclient_queue == NULL) ) |
| 1684 | bgp_process_queue_init (); |
| 1685 | |
| 1686 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1687 | sizeof (struct bgp_process_queue)); |
| 1688 | if (!pqnode) |
| 1689 | return; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1690 | |
| 1691 | /* all unlocked in bgp_processq_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1692 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1693 | pqnode->rn = bgp_lock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1694 | pqnode->bgp = bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1695 | bgp_lock (bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1696 | pqnode->afi = afi; |
| 1697 | pqnode->safi = safi; |
| 1698 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1699 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1700 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1701 | case BGP_TABLE_MAIN: |
| 1702 | work_queue_add (bm->process_main_queue, pqnode); |
| 1703 | break; |
| 1704 | case BGP_TABLE_RSCLIENT: |
| 1705 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1706 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1707 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1708 | |
Stephen Hemminger | 07ff4dc | 2013-01-04 22:29:20 +0000 | [diff] [blame] | 1709 | SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1710 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1711 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1712 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1713 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1714 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1715 | { |
| 1716 | struct peer *peer; |
| 1717 | |
| 1718 | peer = THREAD_ARG (thread); |
| 1719 | peer->t_pmax_restart = NULL; |
| 1720 | |
| 1721 | if (BGP_DEBUG (events, EVENTS)) |
| 1722 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1723 | peer->host); |
| 1724 | |
| 1725 | peer_clear (peer); |
| 1726 | |
| 1727 | return 0; |
| 1728 | } |
| 1729 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1730 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1731 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1732 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1733 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1734 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1735 | return 0; |
| 1736 | |
| 1737 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1738 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1739 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1740 | && ! always) |
| 1741 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1742 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1743 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1744 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1745 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1746 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1747 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1748 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1749 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1750 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1751 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1752 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1753 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1754 | |
| 1755 | if (safi == SAFI_MPLS_VPN) |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 1756 | safi = SAFI_MPLS_LABELED_VPN; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1757 | |
| 1758 | ndata[0] = (afi >> 8); |
| 1759 | ndata[1] = afi; |
| 1760 | ndata[2] = safi; |
| 1761 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1762 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1763 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1764 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1765 | |
| 1766 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1767 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1768 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1769 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1770 | |
| 1771 | /* restart timer start */ |
| 1772 | if (peer->pmax_restart[afi][safi]) |
| 1773 | { |
| 1774 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1775 | |
| 1776 | if (BGP_DEBUG (events, EVENTS)) |
| 1777 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1778 | peer->host, peer->v_pmax_restart); |
| 1779 | |
| 1780 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1781 | peer->v_pmax_restart); |
| 1782 | } |
| 1783 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1784 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1785 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1786 | else |
| 1787 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1788 | |
| 1789 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1790 | { |
| 1791 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1792 | && ! always) |
| 1793 | return 0; |
| 1794 | |
| 1795 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1796 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1797 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1798 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1799 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1800 | } |
| 1801 | else |
| 1802 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1803 | return 0; |
| 1804 | } |
| 1805 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1806 | /* Unconditionally remove the route from the RIB, without taking |
| 1807 | * damping into consideration (eg, because the session went down) |
| 1808 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1809 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1810 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1811 | afi_t afi, safi_t safi) |
| 1812 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1813 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1814 | |
| 1815 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1816 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1817 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1818 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1819 | } |
| 1820 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1821 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1822 | 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] | 1823 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1824 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1825 | int status = BGP_DAMP_NONE; |
| 1826 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1827 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1828 | * the bgp_info in the RIB for historical reference. |
| 1829 | */ |
| 1830 | 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] | 1831 | && peer->sort == BGP_PEER_EBGP) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1832 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1833 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1834 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1835 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1836 | return; |
| 1837 | } |
| 1838 | |
| 1839 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1840 | } |
| 1841 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1842 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1843 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1844 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1845 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1846 | { |
| 1847 | struct bgp_node *rn; |
| 1848 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1849 | struct attr new_attr; |
| 1850 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1851 | struct attr *attr_new; |
| 1852 | struct attr *attr_new2; |
| 1853 | struct bgp_info *ri; |
| 1854 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1855 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1856 | char buf[SU_ADDRSTRLEN]; |
| 1857 | |
| 1858 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1859 | if (peer == rsclient) |
| 1860 | return; |
| 1861 | |
| 1862 | bgp = peer->bgp; |
| 1863 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1864 | |
| 1865 | /* Check previously received route. */ |
| 1866 | for (ri = rn->info; ri; ri = ri->next) |
| 1867 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1868 | break; |
| 1869 | |
| 1870 | /* AS path loop check. */ |
Milan Kocian | 000e157 | 2013-10-18 07:59:38 +0000 | [diff] [blame] | 1871 | if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1872 | { |
| 1873 | reason = "as-path contains our own AS;"; |
| 1874 | goto filtered; |
| 1875 | } |
| 1876 | |
| 1877 | /* Route reflector originator ID check. */ |
| 1878 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1879 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1880 | { |
| 1881 | reason = "originator is us;"; |
| 1882 | goto filtered; |
| 1883 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1884 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1885 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1886 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1887 | |
| 1888 | /* Apply export policy. */ |
| 1889 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1890 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1891 | { |
| 1892 | reason = "export-policy;"; |
| 1893 | goto filtered; |
| 1894 | } |
| 1895 | |
| 1896 | attr_new2 = bgp_attr_intern (&new_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1897 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1898 | /* Apply import policy. */ |
| 1899 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1900 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1901 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1902 | |
| 1903 | reason = "import-policy;"; |
| 1904 | goto filtered; |
| 1905 | } |
| 1906 | |
| 1907 | attr_new = bgp_attr_intern (&new_attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1908 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1909 | |
| 1910 | /* IPv4 unicast next hop check. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1911 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1912 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1913 | /* 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] | 1914 | if (new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1915 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1916 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1917 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1918 | |
| 1919 | reason = "martian next-hop;"; |
| 1920 | goto filtered; |
| 1921 | } |
| 1922 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1923 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1924 | /* If the update is implicit withdraw. */ |
| 1925 | if (ri) |
| 1926 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1927 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1928 | |
| 1929 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1930 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1931 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1932 | { |
| 1933 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1934 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1935 | |
| 1936 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1937 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1938 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1939 | peer->host, |
| 1940 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1941 | p->prefixlen, rsclient->host); |
| 1942 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1943 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1944 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1945 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1946 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1947 | } |
| 1948 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1949 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 1950 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 1951 | bgp_info_restore (rn, ri); |
| 1952 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1953 | /* Received Logging. */ |
| 1954 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1955 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1956 | peer->host, |
| 1957 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1958 | p->prefixlen, rsclient->host); |
| 1959 | |
| 1960 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1961 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1962 | |
| 1963 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1964 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1965 | ri->attr = attr_new; |
| 1966 | |
| 1967 | /* Update MPLS tag. */ |
| 1968 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1969 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1970 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1971 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1972 | |
| 1973 | /* Process change. */ |
| 1974 | bgp_process (bgp, rn, afi, safi); |
| 1975 | bgp_unlock_node (rn); |
| 1976 | |
| 1977 | return; |
| 1978 | } |
| 1979 | |
| 1980 | /* Received Logging. */ |
| 1981 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1982 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1983 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1984 | peer->host, |
| 1985 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1986 | p->prefixlen, rsclient->host); |
| 1987 | } |
| 1988 | |
| 1989 | /* Make new BGP info. */ |
| 1990 | new = bgp_info_new (); |
| 1991 | new->type = type; |
| 1992 | new->sub_type = sub_type; |
| 1993 | new->peer = peer; |
| 1994 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1995 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1996 | |
| 1997 | /* Update MPLS tag. */ |
| 1998 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1999 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2000 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2001 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2002 | |
| 2003 | /* Register new BGP information. */ |
| 2004 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2005 | |
| 2006 | /* route_node_get lock */ |
| 2007 | bgp_unlock_node (rn); |
| 2008 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2009 | /* Process change. */ |
| 2010 | bgp_process (bgp, rn, afi, safi); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2011 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2012 | return; |
| 2013 | |
| 2014 | filtered: |
| 2015 | |
| 2016 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2017 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2018 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2019 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 2020 | peer->host, |
| 2021 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2022 | p->prefixlen, rsclient->host, reason); |
| 2023 | |
| 2024 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2025 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2026 | |
| 2027 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2028 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2029 | return; |
| 2030 | } |
| 2031 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2032 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2033 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 2034 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 2035 | struct prefix_rd *prd, u_char *tag) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2036 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2037 | struct bgp_node *rn; |
| 2038 | struct bgp_info *ri; |
| 2039 | char buf[SU_ADDRSTRLEN]; |
| 2040 | |
| 2041 | if (rsclient == peer) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2042 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2043 | |
| 2044 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 2045 | |
| 2046 | /* Lookup withdrawn route. */ |
| 2047 | for (ri = rn->info; ri; ri = ri->next) |
| 2048 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2049 | break; |
| 2050 | |
| 2051 | /* Withdraw specified route from routing table. */ |
| 2052 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2053 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2054 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2055 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2056 | "%s Can't find the route %s/%d", peer->host, |
| 2057 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2058 | p->prefixlen); |
| 2059 | |
| 2060 | /* Unlock bgp_node_get() lock. */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2061 | bgp_unlock_node (rn); |
| 2062 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2063 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2064 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2065 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2066 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2067 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2068 | { |
| 2069 | int ret; |
| 2070 | int aspath_loop_count = 0; |
| 2071 | struct bgp_node *rn; |
| 2072 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2073 | struct attr new_attr; |
| 2074 | struct attr_extra new_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2075 | struct attr *attr_new; |
| 2076 | struct bgp_info *ri; |
| 2077 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2078 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2079 | char buf[SU_ADDRSTRLEN]; |
| 2080 | |
| 2081 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2082 | 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] | 2083 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2084 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2085 | Adj-RIBs-In. */ |
Jorge Boncompte [DTI2] | 343aa82 | 2012-05-07 16:53:08 +0000 | [diff] [blame] | 2086 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2087 | && peer != bgp->peer_self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2088 | bgp_adj_in_set (rn, peer, attr); |
| 2089 | |
| 2090 | /* Check previously received route. */ |
| 2091 | for (ri = rn->info; ri; ri = ri->next) |
| 2092 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2093 | break; |
| 2094 | |
| 2095 | /* AS path local-as loop check. */ |
| 2096 | if (peer->change_local_as) |
| 2097 | { |
| 2098 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 2099 | aspath_loop_count = 1; |
| 2100 | |
| 2101 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 2102 | { |
| 2103 | reason = "as-path contains our own AS;"; |
| 2104 | goto filtered; |
| 2105 | } |
| 2106 | } |
| 2107 | |
| 2108 | /* AS path loop check. */ |
| 2109 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 2110 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2111 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2112 | > peer->allowas_in[afi][safi])) |
| 2113 | { |
| 2114 | reason = "as-path contains our own AS;"; |
| 2115 | goto filtered; |
| 2116 | } |
| 2117 | |
| 2118 | /* Route reflector originator ID check. */ |
| 2119 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2120 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2121 | { |
| 2122 | reason = "originator is us;"; |
| 2123 | goto filtered; |
| 2124 | } |
| 2125 | |
| 2126 | /* Route reflector cluster ID check. */ |
| 2127 | if (bgp_cluster_filter (peer, attr)) |
| 2128 | { |
| 2129 | reason = "reflected from the same cluster;"; |
| 2130 | goto filtered; |
| 2131 | } |
| 2132 | |
| 2133 | /* Apply incoming filter. */ |
| 2134 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2135 | { |
| 2136 | reason = "filter;"; |
| 2137 | goto filtered; |
| 2138 | } |
| 2139 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2140 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2141 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2142 | |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2143 | /* Apply incoming route-map. |
| 2144 | * NB: new_attr may now contain newly allocated values from route-map "set" |
| 2145 | * commands, so we need bgp_attr_flush in the error paths, until we intern |
| 2146 | * the attr (which takes over the memory references) */ |
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;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2150 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2151 | goto filtered; |
| 2152 | } |
| 2153 | |
| 2154 | /* IPv4 unicast next hop check. */ |
| 2155 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2156 | { |
| 2157 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2158 | discard it. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2159 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 |
Denis Ovsienko | 8e80bdf | 2011-08-05 18:52:52 +0400 | [diff] [blame] | 2160 | && ! bgp_nexthop_onlink (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2161 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2162 | { |
| 2163 | reason = "non-connected next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2164 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2165 | goto filtered; |
| 2166 | } |
| 2167 | |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2168 | /* 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] | 2169 | must not be my own address. */ |
Jorge Boncompte [DTI2] | 10f9bf3 | 2012-05-07 16:52:52 +0000 | [diff] [blame] | 2170 | if (new_attr.nexthop.s_addr == 0 |
| 2171 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) |
| 2172 | || bgp_nexthop_self (&new_attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2173 | { |
| 2174 | reason = "martian next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2175 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2176 | goto filtered; |
| 2177 | } |
| 2178 | } |
| 2179 | |
| 2180 | attr_new = bgp_attr_intern (&new_attr); |
| 2181 | |
| 2182 | /* If the update is implicit withdraw. */ |
| 2183 | if (ri) |
| 2184 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2185 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2186 | |
| 2187 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2188 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2189 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2190 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2191 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2192 | |
| 2193 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2194 | && peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2195 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2196 | { |
| 2197 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2198 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2199 | peer->host, |
| 2200 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2201 | p->prefixlen); |
| 2202 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2203 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2204 | { |
| 2205 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2206 | bgp_process (bgp, rn, afi, safi); |
| 2207 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2208 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2209 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2210 | { |
| 2211 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2212 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2213 | "%s rcvd %s/%d...duplicate ignored", |
| 2214 | peer->host, |
| 2215 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2216 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2217 | |
| 2218 | /* graceful restart STALE flag unset. */ |
| 2219 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2220 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2221 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2222 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2223 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2224 | } |
| 2225 | |
| 2226 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2227 | bgp_attr_unintern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2228 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2229 | return 0; |
| 2230 | } |
| 2231 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2232 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2233 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2234 | { |
| 2235 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2236 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2237 | peer->host, |
| 2238 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2239 | p->prefixlen); |
| 2240 | bgp_info_restore (rn, ri); |
| 2241 | } |
| 2242 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2243 | /* Received Logging. */ |
| 2244 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2245 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2246 | peer->host, |
| 2247 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2248 | p->prefixlen); |
| 2249 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2250 | /* graceful restart STALE flag unset. */ |
| 2251 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2252 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2253 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2254 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2255 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2256 | |
| 2257 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2258 | * only if update is accepted, they'll increment below. |
| 2259 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2260 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2261 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2262 | /* Update bgp route dampening information. */ |
| 2263 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2264 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2265 | { |
| 2266 | /* This is implicit withdraw so we should update dampening |
| 2267 | information. */ |
| 2268 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2269 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2270 | } |
| 2271 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2272 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2273 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2274 | ri->attr = attr_new; |
| 2275 | |
| 2276 | /* Update MPLS tag. */ |
| 2277 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2278 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2279 | |
| 2280 | /* Update bgp route dampening information. */ |
| 2281 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2282 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2283 | { |
| 2284 | /* Now we do normal update dampening. */ |
| 2285 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2286 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2287 | { |
| 2288 | bgp_unlock_node (rn); |
| 2289 | return 0; |
| 2290 | } |
| 2291 | } |
| 2292 | |
| 2293 | /* Nexthop reachability check. */ |
| 2294 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2295 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2296 | && (peer->sort == BGP_PEER_IBGP |
| 2297 | || peer->sort == BGP_PEER_CONFED |
| 2298 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2299 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2300 | { |
| 2301 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2302 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2303 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2304 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2305 | } |
| 2306 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2307 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2308 | |
| 2309 | /* Process change. */ |
| 2310 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2311 | |
| 2312 | bgp_process (bgp, rn, afi, safi); |
| 2313 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2314 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2315 | return 0; |
| 2316 | } |
| 2317 | |
| 2318 | /* Received Logging. */ |
| 2319 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2320 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2321 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2322 | peer->host, |
| 2323 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2324 | p->prefixlen); |
| 2325 | } |
| 2326 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2327 | /* Make new BGP info. */ |
| 2328 | new = bgp_info_new (); |
| 2329 | new->type = type; |
| 2330 | new->sub_type = sub_type; |
| 2331 | new->peer = peer; |
| 2332 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2333 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2334 | |
| 2335 | /* Update MPLS tag. */ |
| 2336 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2337 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2338 | |
| 2339 | /* Nexthop reachability check. */ |
| 2340 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2341 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2342 | && (peer->sort == BGP_PEER_IBGP |
| 2343 | || peer->sort == BGP_PEER_CONFED |
| 2344 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2345 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2346 | { |
| 2347 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2348 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2349 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2350 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2351 | } |
| 2352 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2353 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2354 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2355 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2356 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2357 | |
| 2358 | /* Register new BGP information. */ |
| 2359 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2360 | |
| 2361 | /* route_node_get lock */ |
| 2362 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2363 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2364 | /* If maximum prefix count is configured and current prefix |
| 2365 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2366 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2367 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2368 | |
| 2369 | /* Process change. */ |
| 2370 | bgp_process (bgp, rn, afi, safi); |
| 2371 | |
| 2372 | return 0; |
| 2373 | |
| 2374 | /* This BGP update is filtered. Log the reason then update BGP |
| 2375 | entry. */ |
| 2376 | filtered: |
| 2377 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2378 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2379 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2380 | peer->host, |
| 2381 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2382 | p->prefixlen, reason); |
| 2383 | |
| 2384 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2385 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2386 | |
| 2387 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2388 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2389 | return 0; |
| 2390 | } |
| 2391 | |
| 2392 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2393 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2394 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2395 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2396 | { |
| 2397 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2398 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2399 | struct bgp *bgp; |
| 2400 | int ret; |
| 2401 | |
| 2402 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2403 | soft_reconfig); |
| 2404 | |
| 2405 | bgp = peer->bgp; |
| 2406 | |
| 2407 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2408 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2409 | { |
| 2410 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2411 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2412 | sub_type, prd, tag); |
| 2413 | } |
| 2414 | |
| 2415 | return ret; |
| 2416 | } |
| 2417 | |
| 2418 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2419 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2420 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2421 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2422 | { |
| 2423 | struct bgp *bgp; |
| 2424 | char buf[SU_ADDRSTRLEN]; |
| 2425 | struct bgp_node *rn; |
| 2426 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2427 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2428 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2429 | |
| 2430 | bgp = peer->bgp; |
| 2431 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2432 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2433 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2434 | { |
| 2435 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2436 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2437 | } |
| 2438 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2439 | /* Logging. */ |
| 2440 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2441 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2442 | peer->host, |
| 2443 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2444 | p->prefixlen); |
| 2445 | |
| 2446 | /* Lookup node. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2447 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2448 | |
| 2449 | /* If peer is soft reconfiguration enabled. Record input packet for |
| 2450 | further calculation. */ |
| 2451 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2452 | && peer != bgp->peer_self) |
| 2453 | bgp_adj_in_unset (rn, peer); |
| 2454 | |
| 2455 | /* Lookup withdrawn route. */ |
| 2456 | for (ri = rn->info; ri; ri = ri->next) |
| 2457 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2458 | break; |
| 2459 | |
| 2460 | /* Withdraw specified route from routing table. */ |
| 2461 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2462 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2463 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2464 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2465 | "%s Can't find the route %s/%d", peer->host, |
| 2466 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2467 | p->prefixlen); |
| 2468 | |
| 2469 | /* Unlock bgp_node_get() lock. */ |
| 2470 | bgp_unlock_node (rn); |
| 2471 | |
| 2472 | return 0; |
| 2473 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2474 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2475 | void |
| 2476 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2477 | { |
| 2478 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 2479 | struct attr attr; |
Jorge Boncompte [DTI2] | 577ac57 | 2012-05-07 16:53:06 +0000 | [diff] [blame] | 2480 | struct aspath *aspath; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2481 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2482 | struct peer *from; |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2483 | struct bgp_node *rn; |
| 2484 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2485 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2486 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2487 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2488 | return; |
| 2489 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2490 | bgp = peer->bgp; |
| 2491 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2492 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2493 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2494 | aspath = attr.aspath; |
| 2495 | attr.local_pref = bgp->default_local_pref; |
| 2496 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2497 | |
| 2498 | if (afi == AFI_IP) |
| 2499 | str2prefix ("0.0.0.0/0", &p); |
| 2500 | #ifdef HAVE_IPV6 |
| 2501 | else if (afi == AFI_IP6) |
| 2502 | { |
Jorge Boncompte [DTI2] | 6182d65 | 2012-05-07 16:53:02 +0000 | [diff] [blame] | 2503 | struct attr_extra *ae = attr.extra; |
| 2504 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2505 | str2prefix ("::/0", &p); |
| 2506 | |
| 2507 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2508 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2509 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2510 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2511 | |
| 2512 | /* If the peer is on shared nextwork and we have link-local |
| 2513 | nexthop set it. */ |
| 2514 | if (peer->shared_network |
| 2515 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2516 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2517 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2518 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2519 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2520 | } |
| 2521 | } |
| 2522 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2523 | |
| 2524 | if (peer->default_rmap[afi][safi].name) |
| 2525 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2526 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2527 | for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn)) |
| 2528 | { |
| 2529 | for (ri = rn->info; ri; ri = ri->next) |
| 2530 | { |
| 2531 | struct attr dummy_attr; |
| 2532 | struct attr_extra dummy_extra; |
| 2533 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2534 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2535 | /* Provide dummy so the route-map can't modify the attributes */ |
| 2536 | dummy_attr.extra = &dummy_extra; |
| 2537 | bgp_attr_dup(&dummy_attr, ri->attr); |
| 2538 | info.peer = ri->peer; |
| 2539 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2540 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2541 | ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p, |
| 2542 | RMAP_BGP, &info); |
| 2543 | |
| 2544 | /* The route map might have set attributes. If we don't flush them |
| 2545 | * here, they will be leaked. */ |
| 2546 | bgp_attr_flush(&dummy_attr); |
| 2547 | if (ret != RMAP_DENYMATCH) |
| 2548 | break; |
| 2549 | } |
| 2550 | if (ret != RMAP_DENYMATCH) |
| 2551 | break; |
| 2552 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2553 | bgp->peer_self->rmap_type = 0; |
| 2554 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2555 | if (ret == RMAP_DENYMATCH) |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2556 | withdraw = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2557 | } |
| 2558 | |
| 2559 | if (withdraw) |
| 2560 | { |
| 2561 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2562 | bgp_default_withdraw_send (peer, afi, safi); |
| 2563 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2564 | } |
| 2565 | else |
| 2566 | { |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2567 | if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2568 | { |
| 2569 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2570 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2571 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2572 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2573 | |
| 2574 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2575 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2576 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2577 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2578 | static void |
| 2579 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2580 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2581 | { |
| 2582 | struct bgp_node *rn; |
| 2583 | struct bgp_info *ri; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2584 | struct attr attr; |
| 2585 | struct attr_extra extra; |
| 2586 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2587 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2588 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2589 | |
| 2590 | if (safi != SAFI_MPLS_VPN |
| 2591 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2592 | bgp_default_originate (peer, afi, safi, 0); |
| 2593 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2594 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 2595 | attr.extra = &extra; |
| 2596 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2597 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2598 | for (ri = rn->info; ri; ri = ri->next) |
| 2599 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2600 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2601 | if ( (rsclient) ? |
| 2602 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2603 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2604 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2605 | else |
| 2606 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2607 | } |
| 2608 | } |
| 2609 | |
| 2610 | void |
| 2611 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2612 | { |
| 2613 | struct bgp_node *rn; |
| 2614 | struct bgp_table *table; |
| 2615 | |
| 2616 | if (peer->status != Established) |
| 2617 | return; |
| 2618 | |
| 2619 | if (! peer->afc_nego[afi][safi]) |
| 2620 | return; |
| 2621 | |
| 2622 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2623 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2624 | return; |
| 2625 | |
| 2626 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2627 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2628 | else |
| 2629 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2630 | rn = bgp_route_next(rn)) |
| 2631 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2632 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2633 | |
| 2634 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2635 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2636 | } |
| 2637 | |
| 2638 | void |
| 2639 | bgp_announce_route_all (struct peer *peer) |
| 2640 | { |
| 2641 | afi_t afi; |
| 2642 | safi_t safi; |
| 2643 | |
| 2644 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2645 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2646 | bgp_announce_route (peer, afi, safi); |
| 2647 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2648 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2649 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2650 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2651 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2652 | { |
| 2653 | struct bgp_node *rn; |
| 2654 | struct bgp_adj_in *ain; |
| 2655 | |
| 2656 | if (! table) |
| 2657 | table = rsclient->bgp->rib[afi][safi]; |
| 2658 | |
| 2659 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2660 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2661 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2662 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2663 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2664 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2665 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2666 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2667 | } |
| 2668 | } |
| 2669 | |
| 2670 | void |
| 2671 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2672 | { |
| 2673 | struct bgp_table *table; |
| 2674 | struct bgp_node *rn; |
| 2675 | |
| 2676 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2677 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2678 | |
| 2679 | else |
| 2680 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2681 | rn = bgp_route_next (rn)) |
| 2682 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2683 | { |
| 2684 | struct prefix_rd prd; |
| 2685 | prd.family = AF_UNSPEC; |
| 2686 | prd.prefixlen = 64; |
| 2687 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2688 | |
| 2689 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); |
| 2690 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2691 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2692 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2693 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2694 | 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] | 2695 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2696 | { |
| 2697 | int ret; |
| 2698 | struct bgp_node *rn; |
| 2699 | struct bgp_adj_in *ain; |
| 2700 | |
| 2701 | if (! table) |
| 2702 | table = peer->bgp->rib[afi][safi]; |
| 2703 | |
| 2704 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2705 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2706 | { |
| 2707 | if (ain->peer == peer) |
| 2708 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2709 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2710 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2711 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2712 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2713 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2714 | prd, tag, 1); |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2715 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2716 | if (ret < 0) |
| 2717 | { |
| 2718 | bgp_unlock_node (rn); |
| 2719 | return; |
| 2720 | } |
| 2721 | continue; |
| 2722 | } |
| 2723 | } |
| 2724 | } |
| 2725 | |
| 2726 | void |
| 2727 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2728 | { |
| 2729 | struct bgp_node *rn; |
| 2730 | struct bgp_table *table; |
| 2731 | |
| 2732 | if (peer->status != Established) |
| 2733 | return; |
| 2734 | |
| 2735 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2736 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2737 | else |
| 2738 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2739 | rn = bgp_route_next (rn)) |
| 2740 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2741 | { |
| 2742 | struct prefix_rd prd; |
| 2743 | prd.family = AF_UNSPEC; |
| 2744 | prd.prefixlen = 64; |
| 2745 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2746 | |
| 2747 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); |
| 2748 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2749 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2750 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2751 | |
| 2752 | struct bgp_clear_node_queue |
| 2753 | { |
| 2754 | struct bgp_node *rn; |
| 2755 | enum bgp_clear_route_type purpose; |
| 2756 | }; |
| 2757 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2758 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2759 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2760 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2761 | struct bgp_clear_node_queue *cnq = data; |
| 2762 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2763 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2764 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2765 | afi_t afi = bgp_node_table (rn)->afi; |
| 2766 | safi_t safi = bgp_node_table (rn)->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2767 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2768 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2769 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2770 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2771 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2772 | { |
| 2773 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2774 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2775 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2776 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2777 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2778 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2779 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2780 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2781 | break; |
| 2782 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2783 | return WQ_SUCCESS; |
| 2784 | } |
| 2785 | |
| 2786 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2787 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2788 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2789 | struct bgp_clear_node_queue *cnq = data; |
| 2790 | struct bgp_node *rn = cnq->rn; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2791 | struct bgp_table *table = bgp_node_table (rn); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2792 | |
| 2793 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2794 | bgp_table_unlock (table); |
| 2795 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2796 | } |
| 2797 | |
| 2798 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2799 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2800 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2801 | struct peer *peer = wq->spec.data; |
| 2802 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2803 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2804 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2805 | |
| 2806 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2807 | } |
| 2808 | |
| 2809 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2810 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2811 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2812 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2813 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2814 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2815 | #undef CLEAR_QUEUE_NAME_LEN |
| 2816 | |
| 2817 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2818 | { |
| 2819 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2820 | exit (1); |
| 2821 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2822 | peer->clear_node_queue->spec.hold = 10; |
| 2823 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2824 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2825 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2826 | peer->clear_node_queue->spec.max_retries = 0; |
| 2827 | |
| 2828 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2829 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2830 | } |
| 2831 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2832 | static void |
| 2833 | 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] | 2834 | struct bgp_table *table, struct peer *rsclient, |
| 2835 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2836 | { |
| 2837 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2838 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2839 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2840 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2841 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2842 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2843 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2844 | if (! table) |
| 2845 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2846 | |
| 2847 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2848 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2849 | struct bgp_info *ri; |
| 2850 | struct bgp_adj_in *ain; |
| 2851 | struct bgp_adj_out *aout; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2852 | |
| 2853 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2854 | * queued for every clearing peer, regardless of whether it is |
| 2855 | * relevant to the peer at hand. |
| 2856 | * |
| 2857 | * Overview: There are 3 different indices which need to be |
| 2858 | * scrubbed, potentially, when a peer is removed: |
| 2859 | * |
| 2860 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2861 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2862 | * 3 other routes visible by the peer's adj-out index |
| 2863 | * |
| 2864 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2865 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2866 | * adj-outs at our leisure. |
| 2867 | * |
| 2868 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2869 | * invisible via RIB index before peer session is allowed to be |
| 2870 | * brought back up. So one needs to know when such a 'search' is |
| 2871 | * complete. |
| 2872 | * |
| 2873 | * Ideally: |
| 2874 | * |
| 2875 | * - there'd be a single global queue or a single RIB walker |
| 2876 | * - rather than tracking which route_nodes still need to be |
| 2877 | * examined on a peer basis, we'd track which peers still |
| 2878 | * aren't cleared |
| 2879 | * |
| 2880 | * Given that our per-peer prefix-counts now should be reliable, |
| 2881 | * this may actually be achievable. It doesn't seem to be a huge |
| 2882 | * problem at this time, |
| 2883 | */ |
Jorge Boncompte [DTI2] | 24e50f2 | 2012-05-07 15:17:33 +0000 | [diff] [blame] | 2884 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2885 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2886 | { |
| 2887 | bgp_adj_in_remove (rn, ain); |
| 2888 | bgp_unlock_node (rn); |
| 2889 | break; |
| 2890 | } |
| 2891 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2892 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2893 | { |
| 2894 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2895 | bgp_unlock_node (rn); |
| 2896 | break; |
| 2897 | } |
| 2898 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2899 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2900 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2901 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2902 | struct bgp_clear_node_queue *cnq; |
| 2903 | |
| 2904 | /* both unlocked in bgp_clear_node_queue_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2905 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2906 | bgp_lock_node (rn); |
| 2907 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2908 | sizeof (struct bgp_clear_node_queue)); |
| 2909 | cnq->rn = rn; |
| 2910 | cnq->purpose = purpose; |
| 2911 | work_queue_add (peer->clear_node_queue, cnq); |
| 2912 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2913 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2914 | } |
| 2915 | return; |
| 2916 | } |
| 2917 | |
| 2918 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2919 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2920 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2921 | { |
| 2922 | struct bgp_node *rn; |
| 2923 | struct bgp_table *table; |
| 2924 | struct peer *rsclient; |
| 2925 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2926 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2927 | if (peer->clear_node_queue == NULL) |
| 2928 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2929 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2930 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 2931 | * Idle until it receives a Clearing_Completed event. This protects |
| 2932 | * against peers which flap faster than we can we clear, which could |
| 2933 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2934 | * |
| 2935 | * a) race with routes from the new session being installed before |
| 2936 | * clear_route_node visits the node (to delete the route of that |
| 2937 | * peer) |
| 2938 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 2939 | * on the process_main queue. Fast-flapping could cause that queue |
| 2940 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2941 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2942 | if (!peer->clear_node_queue->thread) |
| 2943 | peer_lock (peer); /* bgp_clear_node_complete */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2944 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2945 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2946 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2947 | case BGP_CLEAR_ROUTE_NORMAL: |
| 2948 | if (safi != SAFI_MPLS_VPN) |
| 2949 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 2950 | else |
| 2951 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2952 | rn = bgp_route_next (rn)) |
| 2953 | if ((table = rn->info) != NULL) |
| 2954 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 2955 | |
| 2956 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 2957 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 2958 | PEER_FLAG_RSERVER_CLIENT)) |
| 2959 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 2960 | break; |
| 2961 | |
| 2962 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
| 2963 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 2964 | break; |
| 2965 | |
| 2966 | default: |
| 2967 | assert (0); |
| 2968 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2969 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2970 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2971 | /* If no routes were cleared, nothing was added to workqueue, the |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2972 | * completion function won't be run by workqueue code - call it here. |
| 2973 | * XXX: Actually, this assumption doesn't hold, see |
| 2974 | * bgp_clear_route_table(), we queue all non-empty nodes. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2975 | * |
| 2976 | * Additionally, there is a presumption in FSM that clearing is only |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2977 | * really needed if peer state is Established - peers in |
| 2978 | * pre-Established states shouldn't have any route-update state |
| 2979 | * associated with them (in or out). |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2980 | * |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2981 | * We still can get here in pre-Established though, through |
| 2982 | * peer_delete -> bgp_fsm_change_status, so this is a useful sanity |
| 2983 | * check to ensure the assumption above holds. |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2984 | * |
| 2985 | * At some future point, this check could be move to the top of the |
| 2986 | * function, and do a quick early-return when state is |
| 2987 | * pre-Established, avoiding above list and table scans. Once we're |
| 2988 | * sure it is safe.. |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2989 | */ |
| 2990 | if (!peer->clear_node_queue->thread) |
| 2991 | bgp_clear_node_complete (peer->clear_node_queue); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2992 | } |
| 2993 | |
| 2994 | void |
| 2995 | bgp_clear_route_all (struct peer *peer) |
| 2996 | { |
| 2997 | afi_t afi; |
| 2998 | safi_t safi; |
| 2999 | |
| 3000 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3001 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3002 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3003 | } |
| 3004 | |
| 3005 | void |
| 3006 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 3007 | { |
| 3008 | struct bgp_table *table; |
| 3009 | struct bgp_node *rn; |
| 3010 | struct bgp_adj_in *ain; |
| 3011 | |
| 3012 | table = peer->bgp->rib[afi][safi]; |
| 3013 | |
| 3014 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3015 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 3016 | if (ain->peer == peer) |
| 3017 | { |
| 3018 | bgp_adj_in_remove (rn, ain); |
| 3019 | bgp_unlock_node (rn); |
| 3020 | break; |
| 3021 | } |
| 3022 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 3023 | |
| 3024 | void |
| 3025 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 3026 | { |
| 3027 | struct bgp_node *rn; |
| 3028 | struct bgp_info *ri; |
| 3029 | struct bgp_table *table; |
| 3030 | |
| 3031 | table = peer->bgp->rib[afi][safi]; |
| 3032 | |
| 3033 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3034 | { |
| 3035 | for (ri = rn->info; ri; ri = ri->next) |
| 3036 | if (ri->peer == peer) |
| 3037 | { |
| 3038 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 3039 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3040 | break; |
| 3041 | } |
| 3042 | } |
| 3043 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3044 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3045 | /* Delete all kernel routes. */ |
| 3046 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3047 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3048 | { |
| 3049 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3050 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3051 | struct bgp_node *rn; |
| 3052 | struct bgp_table *table; |
| 3053 | struct bgp_info *ri; |
| 3054 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3055 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3056 | { |
| 3057 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 3058 | |
| 3059 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3060 | for (ri = rn->info; ri; ri = ri->next) |
| 3061 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3062 | && ri->type == ZEBRA_ROUTE_BGP |
| 3063 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3064 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3065 | |
| 3066 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 3067 | |
| 3068 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3069 | for (ri = rn->info; ri; ri = ri->next) |
| 3070 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3071 | && ri->type == ZEBRA_ROUTE_BGP |
| 3072 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3073 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3074 | } |
| 3075 | } |
| 3076 | |
| 3077 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3078 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3079 | { |
| 3080 | vty_reset (); |
| 3081 | bgp_zclient_reset (); |
| 3082 | access_list_reset (); |
| 3083 | prefix_list_reset (); |
| 3084 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3085 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3086 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3087 | value. */ |
| 3088 | int |
| 3089 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 3090 | { |
| 3091 | u_char *pnt; |
| 3092 | u_char *lim; |
| 3093 | struct prefix p; |
| 3094 | int psize; |
| 3095 | int ret; |
| 3096 | |
| 3097 | /* Check peer status. */ |
| 3098 | if (peer->status != Established) |
| 3099 | return 0; |
| 3100 | |
| 3101 | pnt = packet->nlri; |
| 3102 | lim = pnt + packet->length; |
| 3103 | |
| 3104 | for (; pnt < lim; pnt += psize) |
| 3105 | { |
| 3106 | /* Clear prefix structure. */ |
| 3107 | memset (&p, 0, sizeof (struct prefix)); |
| 3108 | |
| 3109 | /* Fetch prefix length. */ |
| 3110 | p.prefixlen = *pnt++; |
| 3111 | p.family = afi2family (packet->afi); |
| 3112 | |
| 3113 | /* Already checked in nlri_sanity_check(). We do double check |
| 3114 | here. */ |
| 3115 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 3116 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 3117 | return -1; |
| 3118 | |
| 3119 | /* Packet size overflow check. */ |
| 3120 | psize = PSIZE (p.prefixlen); |
| 3121 | |
| 3122 | /* When packet overflow occur return immediately. */ |
| 3123 | if (pnt + psize > lim) |
| 3124 | return -1; |
| 3125 | |
| 3126 | /* Fetch prefix from NLRI packet. */ |
| 3127 | memcpy (&p.u.prefix, pnt, psize); |
| 3128 | |
| 3129 | /* Check address. */ |
| 3130 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3131 | { |
| 3132 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3133 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3134 | /* |
| 3135 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 3136 | * If a BGP router receives an UPDATE message with a |
| 3137 | * semantically incorrect NLRI field, in which a prefix is |
| 3138 | * semantically incorrect (eg. an unexpected multicast IP |
| 3139 | * address), it should ignore the prefix. |
| 3140 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3141 | zlog (peer->log, LOG_ERR, |
| 3142 | "IPv4 unicast NLRI is multicast address %s", |
| 3143 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3144 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3145 | return -1; |
| 3146 | } |
| 3147 | } |
| 3148 | |
| 3149 | #ifdef HAVE_IPV6 |
| 3150 | /* Check address. */ |
| 3151 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3152 | { |
| 3153 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3154 | { |
| 3155 | char buf[BUFSIZ]; |
| 3156 | |
| 3157 | zlog (peer->log, LOG_WARNING, |
| 3158 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 3159 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3160 | |
| 3161 | continue; |
| 3162 | } |
| 3163 | } |
| 3164 | #endif /* HAVE_IPV6 */ |
| 3165 | |
| 3166 | /* Normal process. */ |
| 3167 | if (attr) |
| 3168 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3169 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3170 | else |
| 3171 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3172 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3173 | |
| 3174 | /* Address family configuration mismatch or maximum-prefix count |
| 3175 | overflow. */ |
| 3176 | if (ret < 0) |
| 3177 | return -1; |
| 3178 | } |
| 3179 | |
| 3180 | /* Packet length consistency check. */ |
| 3181 | if (pnt != lim) |
| 3182 | return -1; |
| 3183 | |
| 3184 | return 0; |
| 3185 | } |
| 3186 | |
| 3187 | /* NLRI encode syntax check routine. */ |
| 3188 | int |
| 3189 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 3190 | bgp_size_t length) |
| 3191 | { |
| 3192 | u_char *end; |
| 3193 | u_char prefixlen; |
| 3194 | int psize; |
| 3195 | |
| 3196 | end = pnt + length; |
| 3197 | |
| 3198 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 3199 | syntactic validity. If the field is syntactically incorrect, |
| 3200 | then the Error Subcode is set to Invalid Network Field. */ |
| 3201 | |
| 3202 | while (pnt < end) |
| 3203 | { |
| 3204 | prefixlen = *pnt++; |
| 3205 | |
| 3206 | /* Prefix length check. */ |
| 3207 | if ((afi == AFI_IP && prefixlen > 32) |
| 3208 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 3209 | { |
| 3210 | plog_err (peer->log, |
| 3211 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 3212 | peer->host, prefixlen); |
| 3213 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3214 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3215 | return -1; |
| 3216 | } |
| 3217 | |
| 3218 | /* Packet size overflow check. */ |
| 3219 | psize = PSIZE (prefixlen); |
| 3220 | |
| 3221 | if (pnt + psize > end) |
| 3222 | { |
| 3223 | plog_err (peer->log, |
| 3224 | "%s [Error] Update packet error" |
| 3225 | " (prefix data overflow prefix size is %d)", |
| 3226 | peer->host, psize); |
| 3227 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3228 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3229 | return -1; |
| 3230 | } |
| 3231 | |
| 3232 | pnt += psize; |
| 3233 | } |
| 3234 | |
| 3235 | /* Packet length consistency check. */ |
| 3236 | if (pnt != end) |
| 3237 | { |
| 3238 | plog_err (peer->log, |
| 3239 | "%s [Error] Update packet error" |
| 3240 | " (prefix length mismatch with total length)", |
| 3241 | peer->host); |
| 3242 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3243 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3244 | return -1; |
| 3245 | } |
| 3246 | return 0; |
| 3247 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3248 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3249 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3250 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3251 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3252 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3253 | } |
| 3254 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3255 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3256 | bgp_static_free (struct bgp_static *bgp_static) |
| 3257 | { |
| 3258 | if (bgp_static->rmap.name) |
| 3259 | free (bgp_static->rmap.name); |
| 3260 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3261 | } |
| 3262 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3263 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3264 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3265 | struct prefix *p, afi_t afi, safi_t safi) |
| 3266 | { |
| 3267 | struct bgp_node *rn; |
| 3268 | struct bgp_info *ri; |
| 3269 | |
| 3270 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3271 | |
| 3272 | /* Check selected route and self inserted route. */ |
| 3273 | for (ri = rn->info; ri; ri = ri->next) |
| 3274 | if (ri->peer == bgp->peer_self |
| 3275 | && ri->type == ZEBRA_ROUTE_BGP |
| 3276 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3277 | break; |
| 3278 | |
| 3279 | /* Withdraw static BGP route from routing table. */ |
| 3280 | if (ri) |
| 3281 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3282 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3283 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3284 | } |
| 3285 | |
| 3286 | /* Unlock bgp_node_lookup. */ |
| 3287 | bgp_unlock_node (rn); |
| 3288 | } |
| 3289 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3290 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3291 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3292 | struct bgp_static *bgp_static, |
| 3293 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3294 | { |
| 3295 | struct bgp_node *rn; |
| 3296 | struct bgp_info *ri; |
| 3297 | struct bgp_info *new; |
| 3298 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3299 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3300 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3301 | struct attr new_attr; |
| 3302 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3303 | struct bgp *bgp; |
| 3304 | int ret; |
| 3305 | char buf[SU_ADDRSTRLEN]; |
| 3306 | |
| 3307 | bgp = rsclient->bgp; |
| 3308 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3309 | assert (bgp_static); |
| 3310 | if (!bgp_static) |
| 3311 | return; |
| 3312 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3313 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3314 | |
| 3315 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3316 | |
| 3317 | attr.nexthop = bgp_static->igpnexthop; |
| 3318 | attr.med = bgp_static->igpmetric; |
| 3319 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3320 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3321 | if (bgp_static->atomic) |
| 3322 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3323 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3324 | /* Apply network route-map for export to this rsclient. */ |
| 3325 | if (bgp_static->rmap.name) |
| 3326 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3327 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3328 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3329 | info.attr = &attr_tmp; |
| 3330 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3331 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3332 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3333 | |
| 3334 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3335 | |
| 3336 | rsclient->rmap_type = 0; |
| 3337 | |
| 3338 | if (ret == RMAP_DENYMATCH) |
| 3339 | { |
| 3340 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3341 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3342 | |
| 3343 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3344 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3345 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3346 | bgp_attr_extra_free (&attr); |
| 3347 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3348 | return; |
| 3349 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3350 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3351 | } |
| 3352 | else |
| 3353 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3354 | |
| 3355 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3356 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3357 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3358 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3359 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3360 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3361 | == RMAP_DENY) |
| 3362 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3363 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3364 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3365 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3366 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3367 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3368 | p->prefixlen, rsclient->host); |
| 3369 | |
| 3370 | bgp->peer_self->rmap_type = 0; |
| 3371 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3372 | bgp_attr_unintern (&attr_new); |
| 3373 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3374 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3375 | |
| 3376 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3377 | |
| 3378 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3379 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3380 | |
| 3381 | bgp->peer_self->rmap_type = 0; |
| 3382 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3383 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3384 | attr_new = bgp_attr_intern (&new_attr); |
| 3385 | |
| 3386 | for (ri = rn->info; ri; ri = ri->next) |
| 3387 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3388 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3389 | break; |
| 3390 | |
| 3391 | if (ri) |
| 3392 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3393 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3394 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3395 | { |
| 3396 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3397 | bgp_attr_unintern (&attr_new); |
| 3398 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3399 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3400 | return; |
| 3401 | } |
| 3402 | else |
| 3403 | { |
| 3404 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3405 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3406 | |
| 3407 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3408 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3409 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3410 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3411 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3412 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3413 | |
| 3414 | /* Process change. */ |
| 3415 | bgp_process (bgp, rn, afi, safi); |
| 3416 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3417 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3418 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3419 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3420 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3421 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3422 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3423 | /* Make new BGP info. */ |
| 3424 | new = bgp_info_new (); |
| 3425 | new->type = ZEBRA_ROUTE_BGP; |
| 3426 | new->sub_type = BGP_ROUTE_STATIC; |
| 3427 | new->peer = bgp->peer_self; |
| 3428 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3429 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3430 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3431 | |
| 3432 | /* Register new BGP information. */ |
| 3433 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3434 | |
| 3435 | /* route_node_get lock */ |
| 3436 | bgp_unlock_node (rn); |
| 3437 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3438 | /* Process change. */ |
| 3439 | bgp_process (bgp, rn, afi, safi); |
| 3440 | |
| 3441 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3442 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3443 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3444 | } |
| 3445 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3446 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3447 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3448 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3449 | { |
| 3450 | struct bgp_node *rn; |
| 3451 | struct bgp_info *ri; |
| 3452 | struct bgp_info *new; |
| 3453 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3454 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3455 | struct attr *attr_new; |
| 3456 | int ret; |
| 3457 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3458 | assert (bgp_static); |
| 3459 | if (!bgp_static) |
| 3460 | return; |
| 3461 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3462 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3463 | |
| 3464 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3465 | |
| 3466 | attr.nexthop = bgp_static->igpnexthop; |
| 3467 | attr.med = bgp_static->igpmetric; |
| 3468 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3469 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3470 | if (bgp_static->atomic) |
| 3471 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3472 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3473 | /* Apply route-map. */ |
| 3474 | if (bgp_static->rmap.name) |
| 3475 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3476 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3477 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3478 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3479 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3480 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3481 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3482 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3483 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3484 | bgp->peer_self->rmap_type = 0; |
| 3485 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3486 | if (ret == RMAP_DENYMATCH) |
| 3487 | { |
| 3488 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3489 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3490 | |
| 3491 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3492 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3493 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3494 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3495 | return; |
| 3496 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3497 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3498 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3499 | else |
| 3500 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3501 | |
| 3502 | for (ri = rn->info; ri; ri = ri->next) |
| 3503 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3504 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3505 | break; |
| 3506 | |
| 3507 | if (ri) |
| 3508 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3509 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3510 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3511 | { |
| 3512 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3513 | bgp_attr_unintern (&attr_new); |
| 3514 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3515 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3516 | return; |
| 3517 | } |
| 3518 | else |
| 3519 | { |
| 3520 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3521 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3522 | |
| 3523 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3524 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3525 | bgp_info_restore(rn, ri); |
| 3526 | else |
| 3527 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3528 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3529 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3530 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3531 | |
| 3532 | /* Process change. */ |
| 3533 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3534 | bgp_process (bgp, rn, afi, safi); |
| 3535 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3536 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3537 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3538 | return; |
| 3539 | } |
| 3540 | } |
| 3541 | |
| 3542 | /* Make new BGP info. */ |
| 3543 | new = bgp_info_new (); |
| 3544 | new->type = ZEBRA_ROUTE_BGP; |
| 3545 | new->sub_type = BGP_ROUTE_STATIC; |
| 3546 | new->peer = bgp->peer_self; |
| 3547 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3548 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3549 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3550 | |
| 3551 | /* Aggregate address increment. */ |
| 3552 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3553 | |
| 3554 | /* Register new BGP information. */ |
| 3555 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3556 | |
| 3557 | /* route_node_get lock */ |
| 3558 | bgp_unlock_node (rn); |
| 3559 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3560 | /* Process change. */ |
| 3561 | bgp_process (bgp, rn, afi, safi); |
| 3562 | |
| 3563 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3564 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3565 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3566 | } |
| 3567 | |
| 3568 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3569 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3570 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3571 | { |
| 3572 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3573 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3574 | |
| 3575 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3576 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3577 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3578 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3579 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3580 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3581 | } |
| 3582 | } |
| 3583 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3584 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3585 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3586 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3587 | { |
| 3588 | struct bgp_node *rn; |
| 3589 | struct bgp_info *new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3590 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3591 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3592 | |
| 3593 | /* Make new BGP info. */ |
| 3594 | new = bgp_info_new (); |
| 3595 | new->type = ZEBRA_ROUTE_BGP; |
| 3596 | new->sub_type = BGP_ROUTE_STATIC; |
| 3597 | new->peer = bgp->peer_self; |
| 3598 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 3599 | SET_FLAG (new->flags, BGP_INFO_VALID); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3600 | new->uptime = bgp_clock (); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3601 | new->extra = bgp_info_extra_new(); |
| 3602 | memcpy (new->extra->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3603 | |
| 3604 | /* Aggregate address increment. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3605 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3606 | |
| 3607 | /* Register new BGP information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3608 | bgp_info_add (rn, new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3609 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3610 | /* route_node_get lock */ |
| 3611 | bgp_unlock_node (rn); |
| 3612 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3613 | /* Process change. */ |
| 3614 | bgp_process (bgp, rn, afi, safi); |
| 3615 | } |
| 3616 | |
| 3617 | void |
| 3618 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3619 | safi_t safi) |
| 3620 | { |
| 3621 | struct bgp_node *rn; |
| 3622 | struct bgp_info *ri; |
| 3623 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3624 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3625 | |
| 3626 | /* Check selected route and self inserted route. */ |
| 3627 | for (ri = rn->info; ri; ri = ri->next) |
| 3628 | if (ri->peer == bgp->peer_self |
| 3629 | && ri->type == ZEBRA_ROUTE_BGP |
| 3630 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3631 | break; |
| 3632 | |
| 3633 | /* Withdraw static BGP route from routing table. */ |
| 3634 | if (ri) |
| 3635 | { |
| 3636 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3637 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3638 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3639 | } |
| 3640 | |
| 3641 | /* Unlock bgp_node_lookup. */ |
| 3642 | bgp_unlock_node (rn); |
| 3643 | } |
| 3644 | |
| 3645 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3646 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3647 | { |
| 3648 | struct bgp_static *bgp_static; |
| 3649 | struct bgp *bgp; |
| 3650 | struct bgp_node *rn; |
| 3651 | struct prefix *p; |
| 3652 | |
| 3653 | bgp = rsclient->bgp; |
| 3654 | |
| 3655 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3656 | if ((bgp_static = rn->info) != NULL) |
| 3657 | { |
| 3658 | p = &rn->p; |
| 3659 | |
| 3660 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3661 | afi, safi); |
| 3662 | } |
| 3663 | } |
| 3664 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3665 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3666 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3667 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3668 | { |
| 3669 | struct bgp_node *rn; |
| 3670 | struct bgp_info *ri; |
| 3671 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3672 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3673 | |
| 3674 | /* Check selected route and self inserted route. */ |
| 3675 | for (ri = rn->info; ri; ri = ri->next) |
| 3676 | if (ri->peer == bgp->peer_self |
| 3677 | && ri->type == ZEBRA_ROUTE_BGP |
| 3678 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3679 | break; |
| 3680 | |
| 3681 | /* Withdraw static BGP route from routing table. */ |
| 3682 | if (ri) |
| 3683 | { |
| 3684 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3685 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3686 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3687 | } |
| 3688 | |
| 3689 | /* Unlock bgp_node_lookup. */ |
| 3690 | bgp_unlock_node (rn); |
| 3691 | } |
| 3692 | |
| 3693 | /* Configure static BGP network. When user don't run zebra, static |
| 3694 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3695 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3696 | 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] | 3697 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3698 | { |
| 3699 | int ret; |
| 3700 | struct prefix p; |
| 3701 | struct bgp_static *bgp_static; |
| 3702 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3703 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3704 | |
| 3705 | /* Convert IP prefix string to struct prefix. */ |
| 3706 | ret = str2prefix (ip_str, &p); |
| 3707 | if (! ret) |
| 3708 | { |
| 3709 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3710 | return CMD_WARNING; |
| 3711 | } |
| 3712 | #ifdef HAVE_IPV6 |
| 3713 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3714 | { |
| 3715 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3716 | VTY_NEWLINE); |
| 3717 | return CMD_WARNING; |
| 3718 | } |
| 3719 | #endif /* HAVE_IPV6 */ |
| 3720 | |
| 3721 | apply_mask (&p); |
| 3722 | |
| 3723 | /* Set BGP static route configuration. */ |
| 3724 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3725 | |
| 3726 | if (rn->info) |
| 3727 | { |
| 3728 | /* Configuration change. */ |
| 3729 | bgp_static = rn->info; |
| 3730 | |
| 3731 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3732 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 3733 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3734 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3735 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3736 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3737 | if (rmap) |
| 3738 | { |
| 3739 | if (bgp_static->rmap.name) |
| 3740 | free (bgp_static->rmap.name); |
| 3741 | bgp_static->rmap.name = strdup (rmap); |
| 3742 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3743 | } |
| 3744 | else |
| 3745 | { |
| 3746 | if (bgp_static->rmap.name) |
| 3747 | free (bgp_static->rmap.name); |
| 3748 | bgp_static->rmap.name = NULL; |
| 3749 | bgp_static->rmap.map = NULL; |
| 3750 | bgp_static->valid = 0; |
| 3751 | } |
| 3752 | bgp_unlock_node (rn); |
| 3753 | } |
| 3754 | else |
| 3755 | { |
| 3756 | /* New configuration. */ |
| 3757 | bgp_static = bgp_static_new (); |
| 3758 | bgp_static->backdoor = backdoor; |
| 3759 | bgp_static->valid = 0; |
| 3760 | bgp_static->igpmetric = 0; |
| 3761 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3762 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3763 | if (rmap) |
| 3764 | { |
| 3765 | if (bgp_static->rmap.name) |
| 3766 | free (bgp_static->rmap.name); |
| 3767 | bgp_static->rmap.name = strdup (rmap); |
| 3768 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3769 | } |
| 3770 | rn->info = bgp_static; |
| 3771 | } |
| 3772 | |
| 3773 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3774 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3775 | { |
| 3776 | bgp_static->valid = 1; |
| 3777 | |
| 3778 | if (need_update) |
| 3779 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3780 | |
| 3781 | if (! bgp_static->backdoor) |
| 3782 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3783 | } |
| 3784 | |
| 3785 | return CMD_SUCCESS; |
| 3786 | } |
| 3787 | |
| 3788 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3789 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3790 | 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] | 3791 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3792 | { |
| 3793 | int ret; |
| 3794 | struct prefix p; |
| 3795 | struct bgp_static *bgp_static; |
| 3796 | struct bgp_node *rn; |
| 3797 | |
| 3798 | /* Convert IP prefix string to struct prefix. */ |
| 3799 | ret = str2prefix (ip_str, &p); |
| 3800 | if (! ret) |
| 3801 | { |
| 3802 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3803 | return CMD_WARNING; |
| 3804 | } |
| 3805 | #ifdef HAVE_IPV6 |
| 3806 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3807 | { |
| 3808 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3809 | VTY_NEWLINE); |
| 3810 | return CMD_WARNING; |
| 3811 | } |
| 3812 | #endif /* HAVE_IPV6 */ |
| 3813 | |
| 3814 | apply_mask (&p); |
| 3815 | |
| 3816 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3817 | if (! rn) |
| 3818 | { |
| 3819 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3820 | VTY_NEWLINE); |
| 3821 | return CMD_WARNING; |
| 3822 | } |
| 3823 | |
| 3824 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3825 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3826 | /* Update BGP RIB. */ |
| 3827 | if (! bgp_static->backdoor) |
| 3828 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3829 | |
| 3830 | /* Clear configuration. */ |
| 3831 | bgp_static_free (bgp_static); |
| 3832 | rn->info = NULL; |
| 3833 | bgp_unlock_node (rn); |
| 3834 | bgp_unlock_node (rn); |
| 3835 | |
| 3836 | return CMD_SUCCESS; |
| 3837 | } |
| 3838 | |
| 3839 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3840 | instance. */ |
| 3841 | void |
| 3842 | bgp_static_delete (struct bgp *bgp) |
| 3843 | { |
| 3844 | afi_t afi; |
| 3845 | safi_t safi; |
| 3846 | struct bgp_node *rn; |
| 3847 | struct bgp_node *rm; |
| 3848 | struct bgp_table *table; |
| 3849 | struct bgp_static *bgp_static; |
| 3850 | |
| 3851 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3852 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3853 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3854 | if (rn->info != NULL) |
| 3855 | { |
| 3856 | if (safi == SAFI_MPLS_VPN) |
| 3857 | { |
| 3858 | table = rn->info; |
| 3859 | |
| 3860 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3861 | { |
| 3862 | bgp_static = rn->info; |
| 3863 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3864 | AFI_IP, SAFI_MPLS_VPN, |
| 3865 | (struct prefix_rd *)&rn->p, |
| 3866 | bgp_static->tag); |
| 3867 | bgp_static_free (bgp_static); |
| 3868 | rn->info = NULL; |
| 3869 | bgp_unlock_node (rn); |
| 3870 | } |
| 3871 | } |
| 3872 | else |
| 3873 | { |
| 3874 | bgp_static = rn->info; |
| 3875 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3876 | bgp_static_free (bgp_static); |
| 3877 | rn->info = NULL; |
| 3878 | bgp_unlock_node (rn); |
| 3879 | } |
| 3880 | } |
| 3881 | } |
| 3882 | |
| 3883 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3884 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3885 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3886 | { |
| 3887 | int ret; |
| 3888 | struct prefix p; |
| 3889 | struct prefix_rd prd; |
| 3890 | struct bgp *bgp; |
| 3891 | struct bgp_node *prn; |
| 3892 | struct bgp_node *rn; |
| 3893 | struct bgp_table *table; |
| 3894 | struct bgp_static *bgp_static; |
| 3895 | u_char tag[3]; |
| 3896 | |
| 3897 | bgp = vty->index; |
| 3898 | |
| 3899 | ret = str2prefix (ip_str, &p); |
| 3900 | if (! ret) |
| 3901 | { |
| 3902 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3903 | return CMD_WARNING; |
| 3904 | } |
| 3905 | apply_mask (&p); |
| 3906 | |
| 3907 | ret = str2prefix_rd (rd_str, &prd); |
| 3908 | if (! ret) |
| 3909 | { |
| 3910 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3911 | return CMD_WARNING; |
| 3912 | } |
| 3913 | |
| 3914 | ret = str2tag (tag_str, tag); |
| 3915 | if (! ret) |
| 3916 | { |
| 3917 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3918 | return CMD_WARNING; |
| 3919 | } |
| 3920 | |
| 3921 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3922 | (struct prefix *)&prd); |
| 3923 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3924 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3925 | else |
| 3926 | bgp_unlock_node (prn); |
| 3927 | table = prn->info; |
| 3928 | |
| 3929 | rn = bgp_node_get (table, &p); |
| 3930 | |
| 3931 | if (rn->info) |
| 3932 | { |
| 3933 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3934 | bgp_unlock_node (rn); |
| 3935 | } |
| 3936 | else |
| 3937 | { |
| 3938 | /* New configuration. */ |
| 3939 | bgp_static = bgp_static_new (); |
| 3940 | bgp_static->valid = 1; |
| 3941 | memcpy (bgp_static->tag, tag, 3); |
| 3942 | rn->info = bgp_static; |
| 3943 | |
| 3944 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3945 | } |
| 3946 | |
| 3947 | return CMD_SUCCESS; |
| 3948 | } |
| 3949 | |
| 3950 | /* Configure static BGP network. */ |
| 3951 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3952 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3953 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3954 | { |
| 3955 | int ret; |
| 3956 | struct bgp *bgp; |
| 3957 | struct prefix p; |
| 3958 | struct prefix_rd prd; |
| 3959 | struct bgp_node *prn; |
| 3960 | struct bgp_node *rn; |
| 3961 | struct bgp_table *table; |
| 3962 | struct bgp_static *bgp_static; |
| 3963 | u_char tag[3]; |
| 3964 | |
| 3965 | bgp = vty->index; |
| 3966 | |
| 3967 | /* Convert IP prefix string to struct prefix. */ |
| 3968 | ret = str2prefix (ip_str, &p); |
| 3969 | if (! ret) |
| 3970 | { |
| 3971 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3972 | return CMD_WARNING; |
| 3973 | } |
| 3974 | apply_mask (&p); |
| 3975 | |
| 3976 | ret = str2prefix_rd (rd_str, &prd); |
| 3977 | if (! ret) |
| 3978 | { |
| 3979 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3980 | return CMD_WARNING; |
| 3981 | } |
| 3982 | |
| 3983 | ret = str2tag (tag_str, tag); |
| 3984 | if (! ret) |
| 3985 | { |
| 3986 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3987 | return CMD_WARNING; |
| 3988 | } |
| 3989 | |
| 3990 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3991 | (struct prefix *)&prd); |
| 3992 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3993 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3994 | else |
| 3995 | bgp_unlock_node (prn); |
| 3996 | table = prn->info; |
| 3997 | |
| 3998 | rn = bgp_node_lookup (table, &p); |
| 3999 | |
| 4000 | if (rn) |
| 4001 | { |
| 4002 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 4003 | |
| 4004 | bgp_static = rn->info; |
| 4005 | bgp_static_free (bgp_static); |
| 4006 | rn->info = NULL; |
| 4007 | bgp_unlock_node (rn); |
| 4008 | bgp_unlock_node (rn); |
| 4009 | } |
| 4010 | else |
| 4011 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 4012 | |
| 4013 | return CMD_SUCCESS; |
| 4014 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4015 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4016 | DEFUN (bgp_network, |
| 4017 | bgp_network_cmd, |
| 4018 | "network A.B.C.D/M", |
| 4019 | "Specify a network to announce via BGP\n" |
| 4020 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4021 | { |
| 4022 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4023 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4024 | } |
| 4025 | |
| 4026 | DEFUN (bgp_network_route_map, |
| 4027 | bgp_network_route_map_cmd, |
| 4028 | "network A.B.C.D/M route-map WORD", |
| 4029 | "Specify a network to announce via BGP\n" |
| 4030 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4031 | "Route-map to modify the attributes\n" |
| 4032 | "Name of the route map\n") |
| 4033 | { |
| 4034 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4035 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4036 | } |
| 4037 | |
| 4038 | DEFUN (bgp_network_backdoor, |
| 4039 | bgp_network_backdoor_cmd, |
| 4040 | "network A.B.C.D/M backdoor", |
| 4041 | "Specify a network to announce via BGP\n" |
| 4042 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4043 | "Specify a BGP backdoor route\n") |
| 4044 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4045 | 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] | 4046 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4047 | } |
| 4048 | |
| 4049 | DEFUN (bgp_network_mask, |
| 4050 | bgp_network_mask_cmd, |
| 4051 | "network A.B.C.D mask A.B.C.D", |
| 4052 | "Specify a network to announce via BGP\n" |
| 4053 | "Network number\n" |
| 4054 | "Network mask\n" |
| 4055 | "Network mask\n") |
| 4056 | { |
| 4057 | int ret; |
| 4058 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4059 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4060 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4061 | if (! ret) |
| 4062 | { |
| 4063 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4064 | return CMD_WARNING; |
| 4065 | } |
| 4066 | |
| 4067 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4068 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4069 | } |
| 4070 | |
| 4071 | DEFUN (bgp_network_mask_route_map, |
| 4072 | bgp_network_mask_route_map_cmd, |
| 4073 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4074 | "Specify a network to announce via BGP\n" |
| 4075 | "Network number\n" |
| 4076 | "Network mask\n" |
| 4077 | "Network mask\n" |
| 4078 | "Route-map to modify the attributes\n" |
| 4079 | "Name of the route map\n") |
| 4080 | { |
| 4081 | int ret; |
| 4082 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4083 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4084 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4085 | if (! ret) |
| 4086 | { |
| 4087 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4088 | return CMD_WARNING; |
| 4089 | } |
| 4090 | |
| 4091 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4092 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4093 | } |
| 4094 | |
| 4095 | DEFUN (bgp_network_mask_backdoor, |
| 4096 | bgp_network_mask_backdoor_cmd, |
| 4097 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4098 | "Specify a network to announce via BGP\n" |
| 4099 | "Network number\n" |
| 4100 | "Network mask\n" |
| 4101 | "Network mask\n" |
| 4102 | "Specify a BGP backdoor route\n") |
| 4103 | { |
| 4104 | int ret; |
| 4105 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4106 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4107 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4108 | if (! ret) |
| 4109 | { |
| 4110 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4111 | return CMD_WARNING; |
| 4112 | } |
| 4113 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4114 | 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] | 4115 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4116 | } |
| 4117 | |
| 4118 | DEFUN (bgp_network_mask_natural, |
| 4119 | bgp_network_mask_natural_cmd, |
| 4120 | "network A.B.C.D", |
| 4121 | "Specify a network to announce via BGP\n" |
| 4122 | "Network number\n") |
| 4123 | { |
| 4124 | int ret; |
| 4125 | char prefix_str[BUFSIZ]; |
| 4126 | |
| 4127 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4128 | if (! ret) |
| 4129 | { |
| 4130 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4131 | return CMD_WARNING; |
| 4132 | } |
| 4133 | |
| 4134 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4135 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4136 | } |
| 4137 | |
| 4138 | DEFUN (bgp_network_mask_natural_route_map, |
| 4139 | bgp_network_mask_natural_route_map_cmd, |
| 4140 | "network A.B.C.D route-map WORD", |
| 4141 | "Specify a network to announce via BGP\n" |
| 4142 | "Network number\n" |
| 4143 | "Route-map to modify the attributes\n" |
| 4144 | "Name of the route map\n") |
| 4145 | { |
| 4146 | int ret; |
| 4147 | char prefix_str[BUFSIZ]; |
| 4148 | |
| 4149 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4150 | if (! ret) |
| 4151 | { |
| 4152 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4153 | return CMD_WARNING; |
| 4154 | } |
| 4155 | |
| 4156 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4157 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4158 | } |
| 4159 | |
| 4160 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4161 | bgp_network_mask_natural_backdoor_cmd, |
| 4162 | "network A.B.C.D backdoor", |
| 4163 | "Specify a network to announce via BGP\n" |
| 4164 | "Network number\n" |
| 4165 | "Specify a BGP backdoor route\n") |
| 4166 | { |
| 4167 | int ret; |
| 4168 | char prefix_str[BUFSIZ]; |
| 4169 | |
| 4170 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4171 | if (! ret) |
| 4172 | { |
| 4173 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4174 | return CMD_WARNING; |
| 4175 | } |
| 4176 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4177 | 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] | 4178 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4179 | } |
| 4180 | |
| 4181 | DEFUN (no_bgp_network, |
| 4182 | no_bgp_network_cmd, |
| 4183 | "no network A.B.C.D/M", |
| 4184 | NO_STR |
| 4185 | "Specify a network to announce via BGP\n" |
| 4186 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4187 | { |
| 4188 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4189 | bgp_node_safi (vty)); |
| 4190 | } |
| 4191 | |
| 4192 | ALIAS (no_bgp_network, |
| 4193 | no_bgp_network_route_map_cmd, |
| 4194 | "no network A.B.C.D/M route-map WORD", |
| 4195 | NO_STR |
| 4196 | "Specify a network to announce via BGP\n" |
| 4197 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4198 | "Route-map to modify the attributes\n" |
| 4199 | "Name of the route map\n") |
| 4200 | |
| 4201 | ALIAS (no_bgp_network, |
| 4202 | no_bgp_network_backdoor_cmd, |
| 4203 | "no network A.B.C.D/M backdoor", |
| 4204 | NO_STR |
| 4205 | "Specify a network to announce via BGP\n" |
| 4206 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4207 | "Specify a BGP backdoor route\n") |
| 4208 | |
| 4209 | DEFUN (no_bgp_network_mask, |
| 4210 | no_bgp_network_mask_cmd, |
| 4211 | "no network A.B.C.D mask A.B.C.D", |
| 4212 | NO_STR |
| 4213 | "Specify a network to announce via BGP\n" |
| 4214 | "Network number\n" |
| 4215 | "Network mask\n" |
| 4216 | "Network mask\n") |
| 4217 | { |
| 4218 | int ret; |
| 4219 | char prefix_str[BUFSIZ]; |
| 4220 | |
| 4221 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4222 | if (! ret) |
| 4223 | { |
| 4224 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4225 | return CMD_WARNING; |
| 4226 | } |
| 4227 | |
| 4228 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4229 | bgp_node_safi (vty)); |
| 4230 | } |
| 4231 | |
| 4232 | ALIAS (no_bgp_network_mask, |
| 4233 | no_bgp_network_mask_route_map_cmd, |
| 4234 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4235 | NO_STR |
| 4236 | "Specify a network to announce via BGP\n" |
| 4237 | "Network number\n" |
| 4238 | "Network mask\n" |
| 4239 | "Network mask\n" |
| 4240 | "Route-map to modify the attributes\n" |
| 4241 | "Name of the route map\n") |
| 4242 | |
| 4243 | ALIAS (no_bgp_network_mask, |
| 4244 | no_bgp_network_mask_backdoor_cmd, |
| 4245 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4246 | NO_STR |
| 4247 | "Specify a network to announce via BGP\n" |
| 4248 | "Network number\n" |
| 4249 | "Network mask\n" |
| 4250 | "Network mask\n" |
| 4251 | "Specify a BGP backdoor route\n") |
| 4252 | |
| 4253 | DEFUN (no_bgp_network_mask_natural, |
| 4254 | no_bgp_network_mask_natural_cmd, |
| 4255 | "no network A.B.C.D", |
| 4256 | NO_STR |
| 4257 | "Specify a network to announce via BGP\n" |
| 4258 | "Network number\n") |
| 4259 | { |
| 4260 | int ret; |
| 4261 | char prefix_str[BUFSIZ]; |
| 4262 | |
| 4263 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4264 | if (! ret) |
| 4265 | { |
| 4266 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4267 | return CMD_WARNING; |
| 4268 | } |
| 4269 | |
| 4270 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4271 | bgp_node_safi (vty)); |
| 4272 | } |
| 4273 | |
| 4274 | ALIAS (no_bgp_network_mask_natural, |
| 4275 | no_bgp_network_mask_natural_route_map_cmd, |
| 4276 | "no network A.B.C.D route-map WORD", |
| 4277 | NO_STR |
| 4278 | "Specify a network to announce via BGP\n" |
| 4279 | "Network number\n" |
| 4280 | "Route-map to modify the attributes\n" |
| 4281 | "Name of the route map\n") |
| 4282 | |
| 4283 | ALIAS (no_bgp_network_mask_natural, |
| 4284 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4285 | "no network A.B.C.D backdoor", |
| 4286 | NO_STR |
| 4287 | "Specify a network to announce via BGP\n" |
| 4288 | "Network number\n" |
| 4289 | "Specify a BGP backdoor route\n") |
| 4290 | |
| 4291 | #ifdef HAVE_IPV6 |
| 4292 | DEFUN (ipv6_bgp_network, |
| 4293 | ipv6_bgp_network_cmd, |
| 4294 | "network X:X::X:X/M", |
| 4295 | "Specify a network to announce via BGP\n" |
| 4296 | "IPv6 prefix <network>/<length>\n") |
| 4297 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4298 | 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] | 4299 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4300 | } |
| 4301 | |
| 4302 | DEFUN (ipv6_bgp_network_route_map, |
| 4303 | ipv6_bgp_network_route_map_cmd, |
| 4304 | "network X:X::X:X/M route-map WORD", |
| 4305 | "Specify a network to announce via BGP\n" |
| 4306 | "IPv6 prefix <network>/<length>\n" |
| 4307 | "Route-map to modify the attributes\n" |
| 4308 | "Name of the route map\n") |
| 4309 | { |
| 4310 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4311 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4312 | } |
| 4313 | |
| 4314 | DEFUN (no_ipv6_bgp_network, |
| 4315 | no_ipv6_bgp_network_cmd, |
| 4316 | "no network X:X::X:X/M", |
| 4317 | NO_STR |
| 4318 | "Specify a network to announce via BGP\n" |
| 4319 | "IPv6 prefix <network>/<length>\n") |
| 4320 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4321 | 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] | 4322 | } |
| 4323 | |
| 4324 | ALIAS (no_ipv6_bgp_network, |
| 4325 | no_ipv6_bgp_network_route_map_cmd, |
| 4326 | "no network X:X::X:X/M route-map WORD", |
| 4327 | NO_STR |
| 4328 | "Specify a network to announce via BGP\n" |
| 4329 | "IPv6 prefix <network>/<length>\n" |
| 4330 | "Route-map to modify the attributes\n" |
| 4331 | "Name of the route map\n") |
| 4332 | |
| 4333 | ALIAS (ipv6_bgp_network, |
| 4334 | old_ipv6_bgp_network_cmd, |
| 4335 | "ipv6 bgp network X:X::X:X/M", |
| 4336 | IPV6_STR |
| 4337 | BGP_STR |
| 4338 | "Specify a network to announce via BGP\n" |
| 4339 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4340 | |
| 4341 | ALIAS (no_ipv6_bgp_network, |
| 4342 | old_no_ipv6_bgp_network_cmd, |
| 4343 | "no ipv6 bgp network X:X::X:X/M", |
| 4344 | NO_STR |
| 4345 | IPV6_STR |
| 4346 | BGP_STR |
| 4347 | "Specify a network to announce via BGP\n" |
| 4348 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4349 | #endif /* HAVE_IPV6 */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4350 | |
| 4351 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4352 | ALIAS_DEPRECATED (bgp_network, |
| 4353 | bgp_network_ttl_cmd, |
| 4354 | "network A.B.C.D/M pathlimit <0-255>", |
| 4355 | "Specify a network to announce via BGP\n" |
| 4356 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4357 | "AS-Path hopcount limit attribute\n" |
| 4358 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4359 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4360 | bgp_network_backdoor_ttl_cmd, |
| 4361 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4362 | "Specify a network to announce via BGP\n" |
| 4363 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4364 | "Specify a BGP backdoor route\n" |
| 4365 | "AS-Path hopcount limit attribute\n" |
| 4366 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4367 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4368 | bgp_network_mask_ttl_cmd, |
| 4369 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4370 | "Specify a network to announce via BGP\n" |
| 4371 | "Network number\n" |
| 4372 | "Network mask\n" |
| 4373 | "Network mask\n" |
| 4374 | "AS-Path hopcount limit attribute\n" |
| 4375 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4376 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4377 | bgp_network_mask_backdoor_ttl_cmd, |
| 4378 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4379 | "Specify a network to announce via BGP\n" |
| 4380 | "Network number\n" |
| 4381 | "Network mask\n" |
| 4382 | "Network mask\n" |
| 4383 | "Specify a BGP backdoor route\n" |
| 4384 | "AS-Path hopcount limit attribute\n" |
| 4385 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4386 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4387 | bgp_network_mask_natural_ttl_cmd, |
| 4388 | "network A.B.C.D pathlimit <0-255>", |
| 4389 | "Specify a network to announce via BGP\n" |
| 4390 | "Network number\n" |
| 4391 | "AS-Path hopcount limit attribute\n" |
| 4392 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4393 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4394 | bgp_network_mask_natural_backdoor_ttl_cmd, |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 4395 | "network A.B.C.D backdoor pathlimit <1-255>", |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4396 | "Specify a network to announce via BGP\n" |
| 4397 | "Network number\n" |
| 4398 | "Specify a BGP backdoor route\n" |
| 4399 | "AS-Path hopcount limit attribute\n" |
| 4400 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4401 | ALIAS_DEPRECATED (no_bgp_network, |
| 4402 | no_bgp_network_ttl_cmd, |
| 4403 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4404 | NO_STR |
| 4405 | "Specify a network to announce via BGP\n" |
| 4406 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4407 | "AS-Path hopcount limit attribute\n" |
| 4408 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4409 | ALIAS_DEPRECATED (no_bgp_network, |
| 4410 | no_bgp_network_backdoor_ttl_cmd, |
| 4411 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4412 | NO_STR |
| 4413 | "Specify a network to announce via BGP\n" |
| 4414 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4415 | "Specify a BGP backdoor route\n" |
| 4416 | "AS-Path hopcount limit attribute\n" |
| 4417 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4418 | ALIAS_DEPRECATED (no_bgp_network, |
| 4419 | no_bgp_network_mask_ttl_cmd, |
| 4420 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4421 | NO_STR |
| 4422 | "Specify a network to announce via BGP\n" |
| 4423 | "Network number\n" |
| 4424 | "Network mask\n" |
| 4425 | "Network mask\n" |
| 4426 | "AS-Path hopcount limit attribute\n" |
| 4427 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4428 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4429 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4430 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4431 | NO_STR |
| 4432 | "Specify a network to announce via BGP\n" |
| 4433 | "Network number\n" |
| 4434 | "Network mask\n" |
| 4435 | "Network mask\n" |
| 4436 | "Specify a BGP backdoor route\n" |
| 4437 | "AS-Path hopcount limit attribute\n" |
| 4438 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4439 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4440 | no_bgp_network_mask_natural_ttl_cmd, |
| 4441 | "no network A.B.C.D pathlimit <0-255>", |
| 4442 | NO_STR |
| 4443 | "Specify a network to announce via BGP\n" |
| 4444 | "Network number\n" |
| 4445 | "AS-Path hopcount limit attribute\n" |
| 4446 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4447 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4448 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4449 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4450 | NO_STR |
| 4451 | "Specify a network to announce via BGP\n" |
| 4452 | "Network number\n" |
| 4453 | "Specify a BGP backdoor route\n" |
| 4454 | "AS-Path hopcount limit attribute\n" |
| 4455 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4456 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4457 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4458 | ipv6_bgp_network_ttl_cmd, |
| 4459 | "network X:X::X:X/M pathlimit <0-255>", |
| 4460 | "Specify a network to announce via BGP\n" |
| 4461 | "IPv6 prefix <network>/<length>\n" |
| 4462 | "AS-Path hopcount limit attribute\n" |
| 4463 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4464 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4465 | no_ipv6_bgp_network_ttl_cmd, |
| 4466 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4467 | NO_STR |
| 4468 | "Specify a network to announce via BGP\n" |
| 4469 | "IPv6 prefix <network>/<length>\n" |
| 4470 | "AS-Path hopcount limit attribute\n" |
| 4471 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4472 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4473 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4474 | /* Aggreagete address: |
| 4475 | |
| 4476 | advertise-map Set condition to advertise attribute |
| 4477 | as-set Generate AS set path information |
| 4478 | attribute-map Set attributes of aggregate |
| 4479 | route-map Set parameters of aggregate |
| 4480 | summary-only Filter more specific routes from updates |
| 4481 | suppress-map Conditionally filter more specific routes from updates |
| 4482 | <cr> |
| 4483 | */ |
| 4484 | struct bgp_aggregate |
| 4485 | { |
| 4486 | /* Summary-only flag. */ |
| 4487 | u_char summary_only; |
| 4488 | |
| 4489 | /* AS set generation. */ |
| 4490 | u_char as_set; |
| 4491 | |
| 4492 | /* Route-map for aggregated route. */ |
| 4493 | struct route_map *map; |
| 4494 | |
| 4495 | /* Suppress-count. */ |
| 4496 | unsigned long count; |
| 4497 | |
| 4498 | /* SAFI configuration. */ |
| 4499 | safi_t safi; |
| 4500 | }; |
| 4501 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4502 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4503 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4504 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4505 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4506 | } |
| 4507 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4508 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4509 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4510 | { |
| 4511 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4512 | } |
| 4513 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4514 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4515 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4516 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4517 | struct bgp_aggregate *aggregate) |
| 4518 | { |
| 4519 | struct bgp_table *table; |
| 4520 | struct bgp_node *top; |
| 4521 | struct bgp_node *rn; |
| 4522 | u_char origin; |
| 4523 | struct aspath *aspath = NULL; |
| 4524 | struct aspath *asmerge = NULL; |
| 4525 | struct community *community = NULL; |
| 4526 | struct community *commerge = NULL; |
| 4527 | struct in_addr nexthop; |
| 4528 | u_int32_t med = 0; |
| 4529 | struct bgp_info *ri; |
| 4530 | struct bgp_info *new; |
| 4531 | int first = 1; |
| 4532 | unsigned long match = 0; |
| 4533 | |
| 4534 | /* Record adding route's nexthop and med. */ |
| 4535 | if (rinew) |
| 4536 | { |
| 4537 | nexthop = rinew->attr->nexthop; |
| 4538 | med = rinew->attr->med; |
| 4539 | } |
| 4540 | |
| 4541 | /* ORIGIN attribute: If at least one route among routes that are |
| 4542 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4543 | aggregated route must have the ORIGIN attribute with the value |
| 4544 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4545 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4546 | route must have the origin attribute with the value EGP. In all |
| 4547 | other case the value of the ORIGIN attribute of the aggregated |
| 4548 | route is INTERNAL. */ |
| 4549 | origin = BGP_ORIGIN_IGP; |
| 4550 | |
| 4551 | table = bgp->rib[afi][safi]; |
| 4552 | |
| 4553 | top = bgp_node_get (table, p); |
| 4554 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4555 | if (rn->p.prefixlen > p->prefixlen) |
| 4556 | { |
| 4557 | match = 0; |
| 4558 | |
| 4559 | for (ri = rn->info; ri; ri = ri->next) |
| 4560 | { |
| 4561 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4562 | continue; |
| 4563 | |
| 4564 | if (del && ri == del) |
| 4565 | continue; |
| 4566 | |
| 4567 | if (! rinew && first) |
| 4568 | { |
| 4569 | nexthop = ri->attr->nexthop; |
| 4570 | med = ri->attr->med; |
| 4571 | first = 0; |
| 4572 | } |
| 4573 | |
| 4574 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4575 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4576 | || ri->attr->med != med) |
| 4577 | { |
| 4578 | if (aspath) |
| 4579 | aspath_free (aspath); |
| 4580 | if (community) |
| 4581 | community_free (community); |
| 4582 | bgp_unlock_node (rn); |
| 4583 | bgp_unlock_node (top); |
| 4584 | return; |
| 4585 | } |
| 4586 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4587 | |
| 4588 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4589 | { |
| 4590 | if (aggregate->summary_only) |
| 4591 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4592 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4593 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4594 | match++; |
| 4595 | } |
| 4596 | |
| 4597 | aggregate->count++; |
| 4598 | |
| 4599 | if (aggregate->as_set) |
| 4600 | { |
| 4601 | if (origin < ri->attr->origin) |
| 4602 | origin = ri->attr->origin; |
| 4603 | |
| 4604 | if (aspath) |
| 4605 | { |
| 4606 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4607 | aspath_free (aspath); |
| 4608 | aspath = asmerge; |
| 4609 | } |
| 4610 | else |
| 4611 | aspath = aspath_dup (ri->attr->aspath); |
| 4612 | |
| 4613 | if (ri->attr->community) |
| 4614 | { |
| 4615 | if (community) |
| 4616 | { |
| 4617 | commerge = community_merge (community, |
| 4618 | ri->attr->community); |
| 4619 | community = community_uniq_sort (commerge); |
| 4620 | community_free (commerge); |
| 4621 | } |
| 4622 | else |
| 4623 | community = community_dup (ri->attr->community); |
| 4624 | } |
| 4625 | } |
| 4626 | } |
| 4627 | } |
| 4628 | if (match) |
| 4629 | bgp_process (bgp, rn, afi, safi); |
| 4630 | } |
| 4631 | bgp_unlock_node (top); |
| 4632 | |
| 4633 | if (rinew) |
| 4634 | { |
| 4635 | aggregate->count++; |
| 4636 | |
| 4637 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4638 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4639 | |
| 4640 | if (aggregate->as_set) |
| 4641 | { |
| 4642 | if (origin < rinew->attr->origin) |
| 4643 | origin = rinew->attr->origin; |
| 4644 | |
| 4645 | if (aspath) |
| 4646 | { |
| 4647 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4648 | aspath_free (aspath); |
| 4649 | aspath = asmerge; |
| 4650 | } |
| 4651 | else |
| 4652 | aspath = aspath_dup (rinew->attr->aspath); |
| 4653 | |
| 4654 | if (rinew->attr->community) |
| 4655 | { |
| 4656 | if (community) |
| 4657 | { |
| 4658 | commerge = community_merge (community, |
| 4659 | rinew->attr->community); |
| 4660 | community = community_uniq_sort (commerge); |
| 4661 | community_free (commerge); |
| 4662 | } |
| 4663 | else |
| 4664 | community = community_dup (rinew->attr->community); |
| 4665 | } |
| 4666 | } |
| 4667 | } |
| 4668 | |
| 4669 | if (aggregate->count > 0) |
| 4670 | { |
| 4671 | rn = bgp_node_get (table, p); |
| 4672 | new = bgp_info_new (); |
| 4673 | new->type = ZEBRA_ROUTE_BGP; |
| 4674 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4675 | new->peer = bgp->peer_self; |
| 4676 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4677 | 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] | 4678 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4679 | |
| 4680 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4681 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4682 | bgp_process (bgp, rn, afi, safi); |
| 4683 | } |
| 4684 | else |
| 4685 | { |
| 4686 | if (aspath) |
| 4687 | aspath_free (aspath); |
| 4688 | if (community) |
| 4689 | community_free (community); |
| 4690 | } |
| 4691 | } |
| 4692 | |
| 4693 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4694 | struct bgp_aggregate *); |
| 4695 | |
| 4696 | void |
| 4697 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4698 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4699 | { |
| 4700 | struct bgp_node *child; |
| 4701 | struct bgp_node *rn; |
| 4702 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4703 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4704 | |
| 4705 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4706 | if (safi == SAFI_MPLS_VPN) |
| 4707 | return; |
| 4708 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4709 | table = bgp->aggregate[afi][safi]; |
| 4710 | |
| 4711 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4712 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4713 | return; |
| 4714 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4715 | if (p->prefixlen == 0) |
| 4716 | return; |
| 4717 | |
| 4718 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4719 | return; |
| 4720 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4721 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4722 | |
| 4723 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4724 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4725 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4726 | { |
| 4727 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4728 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4729 | } |
| 4730 | bgp_unlock_node (child); |
| 4731 | } |
| 4732 | |
| 4733 | void |
| 4734 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4735 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4736 | { |
| 4737 | struct bgp_node *child; |
| 4738 | struct bgp_node *rn; |
| 4739 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4740 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4741 | |
| 4742 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4743 | if (safi == SAFI_MPLS_VPN) |
| 4744 | return; |
| 4745 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4746 | table = bgp->aggregate[afi][safi]; |
| 4747 | |
| 4748 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4749 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4750 | return; |
| 4751 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4752 | if (p->prefixlen == 0) |
| 4753 | return; |
| 4754 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4755 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4756 | |
| 4757 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4758 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4759 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4760 | { |
| 4761 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4762 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4763 | } |
| 4764 | bgp_unlock_node (child); |
| 4765 | } |
| 4766 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4767 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4768 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4769 | struct bgp_aggregate *aggregate) |
| 4770 | { |
| 4771 | struct bgp_table *table; |
| 4772 | struct bgp_node *top; |
| 4773 | struct bgp_node *rn; |
| 4774 | struct bgp_info *new; |
| 4775 | struct bgp_info *ri; |
| 4776 | unsigned long match; |
| 4777 | u_char origin = BGP_ORIGIN_IGP; |
| 4778 | struct aspath *aspath = NULL; |
| 4779 | struct aspath *asmerge = NULL; |
| 4780 | struct community *community = NULL; |
| 4781 | struct community *commerge = NULL; |
| 4782 | |
| 4783 | table = bgp->rib[afi][safi]; |
| 4784 | |
| 4785 | /* Sanity check. */ |
| 4786 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4787 | return; |
| 4788 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4789 | return; |
| 4790 | |
| 4791 | /* If routes exists below this node, generate aggregate routes. */ |
| 4792 | top = bgp_node_get (table, p); |
| 4793 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4794 | if (rn->p.prefixlen > p->prefixlen) |
| 4795 | { |
| 4796 | match = 0; |
| 4797 | |
| 4798 | for (ri = rn->info; ri; ri = ri->next) |
| 4799 | { |
| 4800 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4801 | continue; |
| 4802 | |
| 4803 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4804 | { |
| 4805 | /* summary-only aggregate route suppress aggregated |
| 4806 | route announcement. */ |
| 4807 | if (aggregate->summary_only) |
| 4808 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4809 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4810 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4811 | match++; |
| 4812 | } |
| 4813 | /* as-set aggregate route generate origin, as path, |
| 4814 | community aggregation. */ |
| 4815 | if (aggregate->as_set) |
| 4816 | { |
| 4817 | if (origin < ri->attr->origin) |
| 4818 | origin = ri->attr->origin; |
| 4819 | |
| 4820 | if (aspath) |
| 4821 | { |
| 4822 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4823 | aspath_free (aspath); |
| 4824 | aspath = asmerge; |
| 4825 | } |
| 4826 | else |
| 4827 | aspath = aspath_dup (ri->attr->aspath); |
| 4828 | |
| 4829 | if (ri->attr->community) |
| 4830 | { |
| 4831 | if (community) |
| 4832 | { |
| 4833 | commerge = community_merge (community, |
| 4834 | ri->attr->community); |
| 4835 | community = community_uniq_sort (commerge); |
| 4836 | community_free (commerge); |
| 4837 | } |
| 4838 | else |
| 4839 | community = community_dup (ri->attr->community); |
| 4840 | } |
| 4841 | } |
| 4842 | aggregate->count++; |
| 4843 | } |
| 4844 | } |
| 4845 | |
| 4846 | /* If this node is suppressed, process the change. */ |
| 4847 | if (match) |
| 4848 | bgp_process (bgp, rn, afi, safi); |
| 4849 | } |
| 4850 | bgp_unlock_node (top); |
| 4851 | |
| 4852 | /* Add aggregate route to BGP table. */ |
| 4853 | if (aggregate->count) |
| 4854 | { |
| 4855 | rn = bgp_node_get (table, p); |
| 4856 | |
| 4857 | new = bgp_info_new (); |
| 4858 | new->type = ZEBRA_ROUTE_BGP; |
| 4859 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4860 | new->peer = bgp->peer_self; |
| 4861 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4862 | 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] | 4863 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4864 | |
| 4865 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4866 | bgp_unlock_node (rn); |
| 4867 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4868 | /* Process change. */ |
| 4869 | bgp_process (bgp, rn, afi, safi); |
| 4870 | } |
| 4871 | } |
| 4872 | |
| 4873 | void |
| 4874 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4875 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4876 | { |
| 4877 | struct bgp_table *table; |
| 4878 | struct bgp_node *top; |
| 4879 | struct bgp_node *rn; |
| 4880 | struct bgp_info *ri; |
| 4881 | unsigned long match; |
| 4882 | |
| 4883 | table = bgp->rib[afi][safi]; |
| 4884 | |
| 4885 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4886 | return; |
| 4887 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4888 | return; |
| 4889 | |
| 4890 | /* If routes exists below this node, generate aggregate routes. */ |
| 4891 | top = bgp_node_get (table, p); |
| 4892 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4893 | if (rn->p.prefixlen > p->prefixlen) |
| 4894 | { |
| 4895 | match = 0; |
| 4896 | |
| 4897 | for (ri = rn->info; ri; ri = ri->next) |
| 4898 | { |
| 4899 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4900 | continue; |
| 4901 | |
| 4902 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4903 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4904 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4905 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4906 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4907 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4908 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4909 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4910 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4911 | match++; |
| 4912 | } |
| 4913 | } |
| 4914 | aggregate->count--; |
| 4915 | } |
| 4916 | } |
| 4917 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4918 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4919 | if (match) |
| 4920 | bgp_process (bgp, rn, afi, safi); |
| 4921 | } |
| 4922 | bgp_unlock_node (top); |
| 4923 | |
| 4924 | /* Delete aggregate route from BGP table. */ |
| 4925 | rn = bgp_node_get (table, p); |
| 4926 | |
| 4927 | for (ri = rn->info; ri; ri = ri->next) |
| 4928 | if (ri->peer == bgp->peer_self |
| 4929 | && ri->type == ZEBRA_ROUTE_BGP |
| 4930 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4931 | break; |
| 4932 | |
| 4933 | /* Withdraw static BGP route from routing table. */ |
| 4934 | if (ri) |
| 4935 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4936 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4937 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4938 | } |
| 4939 | |
| 4940 | /* Unlock bgp_node_lookup. */ |
| 4941 | bgp_unlock_node (rn); |
| 4942 | } |
| 4943 | |
| 4944 | /* Aggregate route attribute. */ |
| 4945 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4946 | #define AGGREGATE_AS_SET 1 |
| 4947 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4948 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4949 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4950 | afi_t afi, safi_t safi) |
| 4951 | { |
| 4952 | int ret; |
| 4953 | struct prefix p; |
| 4954 | struct bgp_node *rn; |
| 4955 | struct bgp *bgp; |
| 4956 | struct bgp_aggregate *aggregate; |
| 4957 | |
| 4958 | /* Convert string to prefix structure. */ |
| 4959 | ret = str2prefix (prefix_str, &p); |
| 4960 | if (!ret) |
| 4961 | { |
| 4962 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4963 | return CMD_WARNING; |
| 4964 | } |
| 4965 | apply_mask (&p); |
| 4966 | |
| 4967 | /* Get BGP structure. */ |
| 4968 | bgp = vty->index; |
| 4969 | |
| 4970 | /* Old configuration check. */ |
| 4971 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4972 | if (! rn) |
| 4973 | { |
| 4974 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4975 | VTY_NEWLINE); |
| 4976 | return CMD_WARNING; |
| 4977 | } |
| 4978 | |
| 4979 | aggregate = rn->info; |
| 4980 | if (aggregate->safi & SAFI_UNICAST) |
| 4981 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4982 | if (aggregate->safi & SAFI_MULTICAST) |
| 4983 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4984 | |
| 4985 | /* Unlock aggregate address configuration. */ |
| 4986 | rn->info = NULL; |
| 4987 | bgp_aggregate_free (aggregate); |
| 4988 | bgp_unlock_node (rn); |
| 4989 | bgp_unlock_node (rn); |
| 4990 | |
| 4991 | return CMD_SUCCESS; |
| 4992 | } |
| 4993 | |
| 4994 | static int |
| 4995 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4996 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4997 | u_char summary_only, u_char as_set) |
| 4998 | { |
| 4999 | int ret; |
| 5000 | struct prefix p; |
| 5001 | struct bgp_node *rn; |
| 5002 | struct bgp *bgp; |
| 5003 | struct bgp_aggregate *aggregate; |
| 5004 | |
| 5005 | /* Convert string to prefix structure. */ |
| 5006 | ret = str2prefix (prefix_str, &p); |
| 5007 | if (!ret) |
| 5008 | { |
| 5009 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5010 | return CMD_WARNING; |
| 5011 | } |
| 5012 | apply_mask (&p); |
| 5013 | |
| 5014 | /* Get BGP structure. */ |
| 5015 | bgp = vty->index; |
| 5016 | |
| 5017 | /* Old configuration check. */ |
| 5018 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 5019 | |
| 5020 | if (rn->info) |
| 5021 | { |
| 5022 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5023 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5024 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 5025 | if (ret) |
| 5026 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5027 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 5028 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5029 | return CMD_WARNING; |
| 5030 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5031 | } |
| 5032 | |
| 5033 | /* Make aggregate address structure. */ |
| 5034 | aggregate = bgp_aggregate_new (); |
| 5035 | aggregate->summary_only = summary_only; |
| 5036 | aggregate->as_set = as_set; |
| 5037 | aggregate->safi = safi; |
| 5038 | rn->info = aggregate; |
| 5039 | |
| 5040 | /* Aggregate address insert into BGP routing table. */ |
| 5041 | if (safi & SAFI_UNICAST) |
| 5042 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5043 | if (safi & SAFI_MULTICAST) |
| 5044 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5045 | |
| 5046 | return CMD_SUCCESS; |
| 5047 | } |
| 5048 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5049 | DEFUN (aggregate_address, |
| 5050 | aggregate_address_cmd, |
| 5051 | "aggregate-address A.B.C.D/M", |
| 5052 | "Configure BGP aggregate entries\n" |
| 5053 | "Aggregate prefix\n") |
| 5054 | { |
| 5055 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5056 | } |
| 5057 | |
| 5058 | DEFUN (aggregate_address_mask, |
| 5059 | aggregate_address_mask_cmd, |
| 5060 | "aggregate-address A.B.C.D A.B.C.D", |
| 5061 | "Configure BGP aggregate entries\n" |
| 5062 | "Aggregate address\n" |
| 5063 | "Aggregate mask\n") |
| 5064 | { |
| 5065 | int ret; |
| 5066 | char prefix_str[BUFSIZ]; |
| 5067 | |
| 5068 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5069 | |
| 5070 | if (! ret) |
| 5071 | { |
| 5072 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5073 | return CMD_WARNING; |
| 5074 | } |
| 5075 | |
| 5076 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5077 | 0, 0); |
| 5078 | } |
| 5079 | |
| 5080 | DEFUN (aggregate_address_summary_only, |
| 5081 | aggregate_address_summary_only_cmd, |
| 5082 | "aggregate-address A.B.C.D/M summary-only", |
| 5083 | "Configure BGP aggregate entries\n" |
| 5084 | "Aggregate prefix\n" |
| 5085 | "Filter more specific routes from updates\n") |
| 5086 | { |
| 5087 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5088 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5089 | } |
| 5090 | |
| 5091 | DEFUN (aggregate_address_mask_summary_only, |
| 5092 | aggregate_address_mask_summary_only_cmd, |
| 5093 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5094 | "Configure BGP aggregate entries\n" |
| 5095 | "Aggregate address\n" |
| 5096 | "Aggregate mask\n" |
| 5097 | "Filter more specific routes from updates\n") |
| 5098 | { |
| 5099 | int ret; |
| 5100 | char prefix_str[BUFSIZ]; |
| 5101 | |
| 5102 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5103 | |
| 5104 | if (! ret) |
| 5105 | { |
| 5106 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5107 | return CMD_WARNING; |
| 5108 | } |
| 5109 | |
| 5110 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5111 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5112 | } |
| 5113 | |
| 5114 | DEFUN (aggregate_address_as_set, |
| 5115 | aggregate_address_as_set_cmd, |
| 5116 | "aggregate-address A.B.C.D/M as-set", |
| 5117 | "Configure BGP aggregate entries\n" |
| 5118 | "Aggregate prefix\n" |
| 5119 | "Generate AS set path information\n") |
| 5120 | { |
| 5121 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5122 | 0, AGGREGATE_AS_SET); |
| 5123 | } |
| 5124 | |
| 5125 | DEFUN (aggregate_address_mask_as_set, |
| 5126 | aggregate_address_mask_as_set_cmd, |
| 5127 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5128 | "Configure BGP aggregate entries\n" |
| 5129 | "Aggregate address\n" |
| 5130 | "Aggregate mask\n" |
| 5131 | "Generate AS set path information\n") |
| 5132 | { |
| 5133 | int ret; |
| 5134 | char prefix_str[BUFSIZ]; |
| 5135 | |
| 5136 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5137 | |
| 5138 | if (! ret) |
| 5139 | { |
| 5140 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5141 | return CMD_WARNING; |
| 5142 | } |
| 5143 | |
| 5144 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5145 | 0, AGGREGATE_AS_SET); |
| 5146 | } |
| 5147 | |
| 5148 | |
| 5149 | DEFUN (aggregate_address_as_set_summary, |
| 5150 | aggregate_address_as_set_summary_cmd, |
| 5151 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5152 | "Configure BGP aggregate entries\n" |
| 5153 | "Aggregate prefix\n" |
| 5154 | "Generate AS set path information\n" |
| 5155 | "Filter more specific routes from updates\n") |
| 5156 | { |
| 5157 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5158 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5159 | } |
| 5160 | |
| 5161 | ALIAS (aggregate_address_as_set_summary, |
| 5162 | aggregate_address_summary_as_set_cmd, |
| 5163 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5164 | "Configure BGP aggregate entries\n" |
| 5165 | "Aggregate prefix\n" |
| 5166 | "Filter more specific routes from updates\n" |
| 5167 | "Generate AS set path information\n") |
| 5168 | |
| 5169 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5170 | aggregate_address_mask_as_set_summary_cmd, |
| 5171 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5172 | "Configure BGP aggregate entries\n" |
| 5173 | "Aggregate address\n" |
| 5174 | "Aggregate mask\n" |
| 5175 | "Generate AS set path information\n" |
| 5176 | "Filter more specific routes from updates\n") |
| 5177 | { |
| 5178 | int ret; |
| 5179 | char prefix_str[BUFSIZ]; |
| 5180 | |
| 5181 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5182 | |
| 5183 | if (! ret) |
| 5184 | { |
| 5185 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5186 | return CMD_WARNING; |
| 5187 | } |
| 5188 | |
| 5189 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5190 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5191 | } |
| 5192 | |
| 5193 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5194 | aggregate_address_mask_summary_as_set_cmd, |
| 5195 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5196 | "Configure BGP aggregate entries\n" |
| 5197 | "Aggregate address\n" |
| 5198 | "Aggregate mask\n" |
| 5199 | "Filter more specific routes from updates\n" |
| 5200 | "Generate AS set path information\n") |
| 5201 | |
| 5202 | DEFUN (no_aggregate_address, |
| 5203 | no_aggregate_address_cmd, |
| 5204 | "no aggregate-address A.B.C.D/M", |
| 5205 | NO_STR |
| 5206 | "Configure BGP aggregate entries\n" |
| 5207 | "Aggregate prefix\n") |
| 5208 | { |
| 5209 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5210 | } |
| 5211 | |
| 5212 | ALIAS (no_aggregate_address, |
| 5213 | no_aggregate_address_summary_only_cmd, |
| 5214 | "no aggregate-address A.B.C.D/M summary-only", |
| 5215 | NO_STR |
| 5216 | "Configure BGP aggregate entries\n" |
| 5217 | "Aggregate prefix\n" |
| 5218 | "Filter more specific routes from updates\n") |
| 5219 | |
| 5220 | ALIAS (no_aggregate_address, |
| 5221 | no_aggregate_address_as_set_cmd, |
| 5222 | "no aggregate-address A.B.C.D/M as-set", |
| 5223 | NO_STR |
| 5224 | "Configure BGP aggregate entries\n" |
| 5225 | "Aggregate prefix\n" |
| 5226 | "Generate AS set path information\n") |
| 5227 | |
| 5228 | ALIAS (no_aggregate_address, |
| 5229 | no_aggregate_address_as_set_summary_cmd, |
| 5230 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5231 | NO_STR |
| 5232 | "Configure BGP aggregate entries\n" |
| 5233 | "Aggregate prefix\n" |
| 5234 | "Generate AS set path information\n" |
| 5235 | "Filter more specific routes from updates\n") |
| 5236 | |
| 5237 | ALIAS (no_aggregate_address, |
| 5238 | no_aggregate_address_summary_as_set_cmd, |
| 5239 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5240 | NO_STR |
| 5241 | "Configure BGP aggregate entries\n" |
| 5242 | "Aggregate prefix\n" |
| 5243 | "Filter more specific routes from updates\n" |
| 5244 | "Generate AS set path information\n") |
| 5245 | |
| 5246 | DEFUN (no_aggregate_address_mask, |
| 5247 | no_aggregate_address_mask_cmd, |
| 5248 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5249 | NO_STR |
| 5250 | "Configure BGP aggregate entries\n" |
| 5251 | "Aggregate address\n" |
| 5252 | "Aggregate mask\n") |
| 5253 | { |
| 5254 | int ret; |
| 5255 | char prefix_str[BUFSIZ]; |
| 5256 | |
| 5257 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5258 | |
| 5259 | if (! ret) |
| 5260 | { |
| 5261 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5262 | return CMD_WARNING; |
| 5263 | } |
| 5264 | |
| 5265 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5266 | } |
| 5267 | |
| 5268 | ALIAS (no_aggregate_address_mask, |
| 5269 | no_aggregate_address_mask_summary_only_cmd, |
| 5270 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5271 | NO_STR |
| 5272 | "Configure BGP aggregate entries\n" |
| 5273 | "Aggregate address\n" |
| 5274 | "Aggregate mask\n" |
| 5275 | "Filter more specific routes from updates\n") |
| 5276 | |
| 5277 | ALIAS (no_aggregate_address_mask, |
| 5278 | no_aggregate_address_mask_as_set_cmd, |
| 5279 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5280 | NO_STR |
| 5281 | "Configure BGP aggregate entries\n" |
| 5282 | "Aggregate address\n" |
| 5283 | "Aggregate mask\n" |
| 5284 | "Generate AS set path information\n") |
| 5285 | |
| 5286 | ALIAS (no_aggregate_address_mask, |
| 5287 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5288 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5289 | NO_STR |
| 5290 | "Configure BGP aggregate entries\n" |
| 5291 | "Aggregate address\n" |
| 5292 | "Aggregate mask\n" |
| 5293 | "Generate AS set path information\n" |
| 5294 | "Filter more specific routes from updates\n") |
| 5295 | |
| 5296 | ALIAS (no_aggregate_address_mask, |
| 5297 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5298 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5299 | NO_STR |
| 5300 | "Configure BGP aggregate entries\n" |
| 5301 | "Aggregate address\n" |
| 5302 | "Aggregate mask\n" |
| 5303 | "Filter more specific routes from updates\n" |
| 5304 | "Generate AS set path information\n") |
| 5305 | |
| 5306 | #ifdef HAVE_IPV6 |
| 5307 | DEFUN (ipv6_aggregate_address, |
| 5308 | ipv6_aggregate_address_cmd, |
| 5309 | "aggregate-address X:X::X:X/M", |
| 5310 | "Configure BGP aggregate entries\n" |
| 5311 | "Aggregate prefix\n") |
| 5312 | { |
| 5313 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5314 | } |
| 5315 | |
| 5316 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5317 | ipv6_aggregate_address_summary_only_cmd, |
| 5318 | "aggregate-address X:X::X:X/M summary-only", |
| 5319 | "Configure BGP aggregate entries\n" |
| 5320 | "Aggregate prefix\n" |
| 5321 | "Filter more specific routes from updates\n") |
| 5322 | { |
| 5323 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5324 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5325 | } |
| 5326 | |
| 5327 | DEFUN (no_ipv6_aggregate_address, |
| 5328 | no_ipv6_aggregate_address_cmd, |
| 5329 | "no aggregate-address X:X::X:X/M", |
| 5330 | NO_STR |
| 5331 | "Configure BGP aggregate entries\n" |
| 5332 | "Aggregate prefix\n") |
| 5333 | { |
| 5334 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5335 | } |
| 5336 | |
| 5337 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5338 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5339 | "no aggregate-address X:X::X:X/M summary-only", |
| 5340 | NO_STR |
| 5341 | "Configure BGP aggregate entries\n" |
| 5342 | "Aggregate prefix\n" |
| 5343 | "Filter more specific routes from updates\n") |
| 5344 | { |
| 5345 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5346 | } |
| 5347 | |
| 5348 | ALIAS (ipv6_aggregate_address, |
| 5349 | old_ipv6_aggregate_address_cmd, |
| 5350 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5351 | IPV6_STR |
| 5352 | BGP_STR |
| 5353 | "Configure BGP aggregate entries\n" |
| 5354 | "Aggregate prefix\n") |
| 5355 | |
| 5356 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5357 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5358 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5359 | IPV6_STR |
| 5360 | BGP_STR |
| 5361 | "Configure BGP aggregate entries\n" |
| 5362 | "Aggregate prefix\n" |
| 5363 | "Filter more specific routes from updates\n") |
| 5364 | |
| 5365 | ALIAS (no_ipv6_aggregate_address, |
| 5366 | old_no_ipv6_aggregate_address_cmd, |
| 5367 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5368 | NO_STR |
| 5369 | IPV6_STR |
| 5370 | BGP_STR |
| 5371 | "Configure BGP aggregate entries\n" |
| 5372 | "Aggregate prefix\n") |
| 5373 | |
| 5374 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5375 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5376 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5377 | NO_STR |
| 5378 | IPV6_STR |
| 5379 | BGP_STR |
| 5380 | "Configure BGP aggregate entries\n" |
| 5381 | "Aggregate prefix\n" |
| 5382 | "Filter more specific routes from updates\n") |
| 5383 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5384 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5385 | /* Redistribute route treatment. */ |
| 5386 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5387 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5388 | const struct in6_addr *nexthop6, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5389 | u_int32_t metric, u_char type) |
| 5390 | { |
| 5391 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5392 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5393 | struct bgp_info *new; |
| 5394 | struct bgp_info *bi; |
| 5395 | struct bgp_info info; |
| 5396 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5397 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5398 | struct attr *new_attr; |
| 5399 | afi_t afi; |
| 5400 | int ret; |
| 5401 | |
| 5402 | /* Make default attribute. */ |
| 5403 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5404 | if (nexthop) |
| 5405 | attr.nexthop = *nexthop; |
| 5406 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5407 | #ifdef HAVE_IPV6 |
| 5408 | if (nexthop6) |
| 5409 | { |
| 5410 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5411 | extra->mp_nexthop_global = *nexthop6; |
| 5412 | extra->mp_nexthop_len = 16; |
| 5413 | } |
| 5414 | #endif |
| 5415 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5416 | attr.med = metric; |
| 5417 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5418 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5419 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5420 | { |
| 5421 | afi = family2afi (p->family); |
| 5422 | |
| 5423 | if (bgp->redist[afi][type]) |
| 5424 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5425 | struct attr attr_new; |
| 5426 | struct attr_extra extra_new; |
| 5427 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5428 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5429 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5430 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5431 | |
| 5432 | if (bgp->redist_metric_flag[afi][type]) |
| 5433 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5434 | |
| 5435 | /* Apply route-map. */ |
| 5436 | if (bgp->rmap[afi][type].map) |
| 5437 | { |
| 5438 | info.peer = bgp->peer_self; |
| 5439 | info.attr = &attr_new; |
| 5440 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5441 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5442 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5443 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5444 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5445 | |
| 5446 | bgp->peer_self->rmap_type = 0; |
| 5447 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5448 | if (ret == RMAP_DENYMATCH) |
| 5449 | { |
| 5450 | /* Free uninterned attribute. */ |
| 5451 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5452 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5453 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5454 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5455 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5456 | bgp_redistribute_delete (p, type); |
| 5457 | return; |
| 5458 | } |
| 5459 | } |
| 5460 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5461 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5462 | afi, SAFI_UNICAST, p, NULL); |
| 5463 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5464 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5465 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5466 | for (bi = bn->info; bi; bi = bi->next) |
| 5467 | if (bi->peer == bgp->peer_self |
| 5468 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5469 | break; |
| 5470 | |
| 5471 | if (bi) |
| 5472 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5473 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5474 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5475 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5476 | bgp_attr_unintern (&new_attr); |
| 5477 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5478 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5479 | bgp_unlock_node (bn); |
| 5480 | return; |
| 5481 | } |
| 5482 | else |
| 5483 | { |
| 5484 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5485 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5486 | |
| 5487 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5488 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5489 | bgp_info_restore(bn, bi); |
| 5490 | else |
| 5491 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5492 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5493 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5494 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5495 | |
| 5496 | /* Process change. */ |
| 5497 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5498 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5499 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5500 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5501 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5502 | return; |
| 5503 | } |
| 5504 | } |
| 5505 | |
| 5506 | new = bgp_info_new (); |
| 5507 | new->type = type; |
| 5508 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 5509 | new->peer = bgp->peer_self; |
| 5510 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5511 | new->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5512 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5513 | |
| 5514 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5515 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5516 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5517 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5518 | } |
| 5519 | } |
| 5520 | |
| 5521 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5522 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5523 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5524 | } |
| 5525 | |
| 5526 | void |
| 5527 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5528 | { |
| 5529 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5530 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5531 | afi_t afi; |
| 5532 | struct bgp_node *rn; |
| 5533 | struct bgp_info *ri; |
| 5534 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5535 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5536 | { |
| 5537 | afi = family2afi (p->family); |
| 5538 | |
| 5539 | if (bgp->redist[afi][type]) |
| 5540 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5541 | 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] | 5542 | |
| 5543 | for (ri = rn->info; ri; ri = ri->next) |
| 5544 | if (ri->peer == bgp->peer_self |
| 5545 | && ri->type == type) |
| 5546 | break; |
| 5547 | |
| 5548 | if (ri) |
| 5549 | { |
| 5550 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5551 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5552 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5553 | } |
| 5554 | bgp_unlock_node (rn); |
| 5555 | } |
| 5556 | } |
| 5557 | } |
| 5558 | |
| 5559 | /* Withdraw specified route type's route. */ |
| 5560 | void |
| 5561 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5562 | { |
| 5563 | struct bgp_node *rn; |
| 5564 | struct bgp_info *ri; |
| 5565 | struct bgp_table *table; |
| 5566 | |
| 5567 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5568 | |
| 5569 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5570 | { |
| 5571 | for (ri = rn->info; ri; ri = ri->next) |
| 5572 | if (ri->peer == bgp->peer_self |
| 5573 | && ri->type == type) |
| 5574 | break; |
| 5575 | |
| 5576 | if (ri) |
| 5577 | { |
| 5578 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5579 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5580 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5581 | } |
| 5582 | } |
| 5583 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5584 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5585 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5586 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5587 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5588 | { |
| 5589 | int len; |
| 5590 | u_int32_t destination; |
| 5591 | char buf[BUFSIZ]; |
| 5592 | |
| 5593 | if (p->family == AF_INET) |
| 5594 | { |
| 5595 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5596 | destination = ntohl (p->u.prefix4.s_addr); |
| 5597 | |
| 5598 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5599 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5600 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5601 | || p->u.prefix4.s_addr == 0) |
| 5602 | { |
| 5603 | /* When mask is natural, mask is not displayed. */ |
| 5604 | } |
| 5605 | else |
| 5606 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5607 | } |
| 5608 | else |
| 5609 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5610 | p->prefixlen); |
| 5611 | |
| 5612 | len = 17 - len; |
| 5613 | if (len < 1) |
| 5614 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5615 | else |
| 5616 | vty_out (vty, "%*s", len, " "); |
| 5617 | } |
| 5618 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5619 | enum bgp_display_type |
| 5620 | { |
| 5621 | normal_list, |
| 5622 | }; |
| 5623 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5624 | /* Print the short form route status for a bgp_info */ |
| 5625 | static void |
| 5626 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5627 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5628 | /* Route status display. */ |
| 5629 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5630 | vty_out (vty, "R"); |
| 5631 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5632 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5633 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5634 | vty_out (vty, "s"); |
| 5635 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5636 | vty_out (vty, "*"); |
| 5637 | else |
| 5638 | vty_out (vty, " "); |
| 5639 | |
| 5640 | /* Selected */ |
| 5641 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5642 | vty_out (vty, "h"); |
| 5643 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5644 | vty_out (vty, "d"); |
| 5645 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5646 | vty_out (vty, ">"); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 5647 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
| 5648 | vty_out (vty, "="); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5649 | else |
| 5650 | vty_out (vty, " "); |
| 5651 | |
| 5652 | /* Internal route. */ |
| 5653 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5654 | vty_out (vty, "i"); |
| 5655 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5656 | vty_out (vty, " "); |
| 5657 | } |
| 5658 | |
| 5659 | /* called from terminal list command */ |
| 5660 | void |
| 5661 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5662 | struct bgp_info *binfo, int display, safi_t safi) |
| 5663 | { |
| 5664 | struct attr *attr; |
| 5665 | |
| 5666 | /* short status lead text */ |
| 5667 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5668 | |
| 5669 | /* print prefix and mask */ |
| 5670 | if (! display) |
| 5671 | route_vty_out_route (p, vty); |
| 5672 | else |
| 5673 | vty_out (vty, "%*s", 17, " "); |
| 5674 | |
| 5675 | /* Print attribute */ |
| 5676 | attr = binfo->attr; |
| 5677 | if (attr) |
| 5678 | { |
| 5679 | if (p->family == AF_INET) |
| 5680 | { |
| 5681 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5682 | vty_out (vty, "%-16s", |
| 5683 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5684 | else |
| 5685 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5686 | } |
| 5687 | #ifdef HAVE_IPV6 |
| 5688 | else if (p->family == AF_INET6) |
| 5689 | { |
| 5690 | int len; |
| 5691 | char buf[BUFSIZ]; |
| 5692 | |
| 5693 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5694 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5695 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5696 | len = 16 - len; |
| 5697 | if (len < 1) |
| 5698 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5699 | else |
| 5700 | vty_out (vty, "%*s", len, " "); |
| 5701 | } |
| 5702 | #endif /* HAVE_IPV6 */ |
| 5703 | |
| 5704 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5705 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5706 | else |
| 5707 | vty_out (vty, " "); |
| 5708 | |
| 5709 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5710 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5711 | else |
| 5712 | vty_out (vty, " "); |
| 5713 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5714 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5715 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5716 | /* Print aspath */ |
| 5717 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5718 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5719 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5720 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5721 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5722 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5723 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5724 | } |
| 5725 | |
| 5726 | /* called from terminal list command */ |
| 5727 | void |
| 5728 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5729 | struct attr *attr, safi_t safi) |
| 5730 | { |
| 5731 | /* Route status display. */ |
| 5732 | vty_out (vty, "*"); |
| 5733 | vty_out (vty, ">"); |
| 5734 | vty_out (vty, " "); |
| 5735 | |
| 5736 | /* print prefix and mask */ |
| 5737 | route_vty_out_route (p, vty); |
| 5738 | |
| 5739 | /* Print attribute */ |
| 5740 | if (attr) |
| 5741 | { |
| 5742 | if (p->family == AF_INET) |
| 5743 | { |
| 5744 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5745 | vty_out (vty, "%-16s", |
| 5746 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5747 | else |
| 5748 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5749 | } |
| 5750 | #ifdef HAVE_IPV6 |
| 5751 | else if (p->family == AF_INET6) |
| 5752 | { |
| 5753 | int len; |
| 5754 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5755 | |
| 5756 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5757 | |
| 5758 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5759 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5760 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5761 | len = 16 - len; |
| 5762 | if (len < 1) |
| 5763 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5764 | else |
| 5765 | vty_out (vty, "%*s", len, " "); |
| 5766 | } |
| 5767 | #endif /* HAVE_IPV6 */ |
| 5768 | |
| 5769 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5770 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5771 | else |
| 5772 | vty_out (vty, " "); |
| 5773 | |
| 5774 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5775 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5776 | else |
| 5777 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5778 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5779 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5780 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5781 | /* Print aspath */ |
| 5782 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5783 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5784 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5785 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5786 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5787 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5788 | |
| 5789 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5790 | } |
| 5791 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5792 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5793 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 5794 | struct bgp_info *binfo, int display, safi_t safi) |
| 5795 | { |
| 5796 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5797 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5798 | |
| 5799 | if (!binfo->extra) |
| 5800 | return; |
| 5801 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5802 | /* short status lead text */ |
| 5803 | route_vty_short_status_out (vty, binfo); |
| 5804 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5805 | /* print prefix and mask */ |
| 5806 | if (! display) |
| 5807 | route_vty_out_route (p, vty); |
| 5808 | else |
| 5809 | vty_out (vty, "%*s", 17, " "); |
| 5810 | |
| 5811 | /* Print attribute */ |
| 5812 | attr = binfo->attr; |
| 5813 | if (attr) |
| 5814 | { |
| 5815 | if (p->family == AF_INET) |
| 5816 | { |
| 5817 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5818 | vty_out (vty, "%-16s", |
| 5819 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5820 | else |
| 5821 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5822 | } |
| 5823 | #ifdef HAVE_IPV6 |
| 5824 | else if (p->family == AF_INET6) |
| 5825 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5826 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5827 | char buf[BUFSIZ]; |
| 5828 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5829 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5830 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5831 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5832 | buf, BUFSIZ)); |
| 5833 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5834 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5835 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5836 | buf, BUFSIZ), |
| 5837 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 5838 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5839 | |
| 5840 | } |
| 5841 | #endif /* HAVE_IPV6 */ |
| 5842 | } |
| 5843 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5844 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5845 | |
| 5846 | vty_out (vty, "notag/%d", label); |
| 5847 | |
| 5848 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5849 | } |
| 5850 | |
| 5851 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5852 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5853 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5854 | struct bgp_info *binfo, int display, safi_t safi) |
| 5855 | { |
| 5856 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5857 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5858 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5859 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5860 | /* short status lead text */ |
| 5861 | route_vty_short_status_out (vty, binfo); |
| 5862 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5863 | /* print prefix and mask */ |
| 5864 | if (! display) |
| 5865 | route_vty_out_route (p, vty); |
| 5866 | else |
| 5867 | vty_out (vty, "%*s", 17, " "); |
| 5868 | |
| 5869 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5870 | len = 17 - len; |
| 5871 | if (len < 1) |
| 5872 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5873 | else |
| 5874 | vty_out (vty, "%*s", len, " "); |
| 5875 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5876 | 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] | 5877 | |
| 5878 | /* Print attribute */ |
| 5879 | attr = binfo->attr; |
| 5880 | if (attr) |
| 5881 | { |
| 5882 | /* Print aspath */ |
| 5883 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5884 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5885 | |
| 5886 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5887 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5888 | } |
| 5889 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5890 | } |
| 5891 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5892 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5893 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5894 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5895 | struct bgp_info *binfo, int display, safi_t safi) |
| 5896 | { |
| 5897 | struct attr *attr; |
| 5898 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5899 | char timebuf[BGP_UPTIME_LEN]; |
| 5900 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5901 | |
| 5902 | if (!binfo->extra) |
| 5903 | return; |
| 5904 | |
| 5905 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5906 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5907 | /* short status lead text */ |
| 5908 | route_vty_short_status_out (vty, binfo); |
| 5909 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5910 | /* print prefix and mask */ |
| 5911 | if (! display) |
| 5912 | route_vty_out_route (p, vty); |
| 5913 | else |
| 5914 | vty_out (vty, "%*s", 17, " "); |
| 5915 | |
| 5916 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5917 | len = 16 - len; |
| 5918 | if (len < 1) |
| 5919 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5920 | else |
| 5921 | vty_out (vty, "%*s", len, " "); |
| 5922 | |
| 5923 | len = vty_out (vty, "%d", bdi->flap); |
| 5924 | len = 5 - len; |
| 5925 | if (len < 1) |
| 5926 | vty_out (vty, " "); |
| 5927 | else |
| 5928 | vty_out (vty, "%*s ", len, " "); |
| 5929 | |
| 5930 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5931 | timebuf, BGP_UPTIME_LEN)); |
| 5932 | |
| 5933 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5934 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5935 | 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] | 5936 | else |
| 5937 | vty_out (vty, "%*s ", 8, " "); |
| 5938 | |
| 5939 | /* Print attribute */ |
| 5940 | attr = binfo->attr; |
| 5941 | if (attr) |
| 5942 | { |
| 5943 | /* Print aspath */ |
| 5944 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5945 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5946 | |
| 5947 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5948 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5949 | } |
| 5950 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5951 | } |
| 5952 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5953 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5954 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5955 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5956 | { |
| 5957 | char buf[INET6_ADDRSTRLEN]; |
| 5958 | char buf1[BUFSIZ]; |
| 5959 | struct attr *attr; |
| 5960 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 5961 | #ifdef HAVE_CLOCK_MONOTONIC |
| 5962 | time_t tbuf; |
| 5963 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5964 | |
| 5965 | attr = binfo->attr; |
| 5966 | |
| 5967 | if (attr) |
| 5968 | { |
| 5969 | /* Line1 display AS-path, Aggregator */ |
| 5970 | if (attr->aspath) |
| 5971 | { |
| 5972 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 5973 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5974 | vty_out (vty, "Local"); |
| 5975 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5976 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5977 | } |
| 5978 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5979 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5980 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5981 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 5982 | vty_out (vty, ", (stale)"); |
| 5983 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 5984 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5985 | attr->extra->aggregator_as, |
| 5986 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5987 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 5988 | vty_out (vty, ", (Received from a RR-client)"); |
| 5989 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 5990 | vty_out (vty, ", (Received from a RS-client)"); |
| 5991 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5992 | vty_out (vty, ", (history entry)"); |
| 5993 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5994 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5995 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5996 | |
| 5997 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 5998 | if (p->family == AF_INET) |
| 5999 | { |
| 6000 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6001 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6002 | inet_ntoa (attr->nexthop)); |
| 6003 | } |
| 6004 | #ifdef HAVE_IPV6 |
| 6005 | else |
| 6006 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6007 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6008 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6009 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6010 | buf, INET6_ADDRSTRLEN)); |
| 6011 | } |
| 6012 | #endif /* HAVE_IPV6 */ |
| 6013 | |
| 6014 | if (binfo->peer == bgp->peer_self) |
| 6015 | { |
| 6016 | vty_out (vty, " from %s ", |
| 6017 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 6018 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 6019 | } |
| 6020 | else |
| 6021 | { |
| 6022 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6023 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6024 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 6025 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 6026 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6027 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6028 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6029 | else |
| 6030 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 6031 | } |
| 6032 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6033 | |
| 6034 | #ifdef HAVE_IPV6 |
| 6035 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6036 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6037 | { |
| 6038 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6039 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6040 | buf, INET6_ADDRSTRLEN), |
| 6041 | VTY_NEWLINE); |
| 6042 | } |
| 6043 | #endif /* HAVE_IPV6 */ |
| 6044 | |
| 6045 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 6046 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 6047 | |
| 6048 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6049 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6050 | |
| 6051 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6052 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6053 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6054 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6055 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6056 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6057 | vty_out (vty, ", weight %u", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6058 | |
| 6059 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6060 | vty_out (vty, ", valid"); |
| 6061 | |
| 6062 | if (binfo->peer != bgp->peer_self) |
| 6063 | { |
| 6064 | if (binfo->peer->as == binfo->peer->local_as) |
| 6065 | vty_out (vty, ", internal"); |
| 6066 | else |
| 6067 | vty_out (vty, ", %s", |
| 6068 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6069 | } |
| 6070 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6071 | vty_out (vty, ", aggregated, local"); |
| 6072 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6073 | vty_out (vty, ", sourced"); |
| 6074 | else |
| 6075 | vty_out (vty, ", sourced, local"); |
| 6076 | |
| 6077 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6078 | vty_out (vty, ", atomic-aggregate"); |
| 6079 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6080 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6081 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6082 | bgp_info_mpath_count (binfo))) |
| 6083 | vty_out (vty, ", multipath"); |
| 6084 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6085 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6086 | vty_out (vty, ", best"); |
| 6087 | |
| 6088 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6089 | |
| 6090 | /* Line 4 display Community */ |
| 6091 | if (attr->community) |
| 6092 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6093 | VTY_NEWLINE); |
| 6094 | |
| 6095 | /* Line 5 display Extended-community */ |
| 6096 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6097 | vty_out (vty, " Extended Community: %s%s", |
| 6098 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6099 | |
| 6100 | /* Line 6 display Originator, Cluster-id */ |
| 6101 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6102 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6103 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6104 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6105 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6106 | vty_out (vty, " Originator: %s", |
| 6107 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6108 | |
| 6109 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6110 | { |
| 6111 | int i; |
| 6112 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6113 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6114 | vty_out (vty, "%s ", |
| 6115 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6116 | } |
| 6117 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6118 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6119 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6120 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6121 | bgp_damp_info_vty (vty, binfo); |
| 6122 | |
| 6123 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6124 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6125 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6126 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6127 | #else |
| 6128 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6129 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6130 | } |
| 6131 | vty_out (vty, "%s", VTY_NEWLINE); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 6132 | } |
| 6133 | |
| 6134 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\ |
| 6135 | "h history, * valid, > best, = multipath,%s"\ |
| 6136 | " i internal, r RIB-failure, S Stale, R Removed%s" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6137 | #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] | 6138 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6139 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6140 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6141 | |
| 6142 | enum bgp_show_type |
| 6143 | { |
| 6144 | bgp_show_type_normal, |
| 6145 | bgp_show_type_regexp, |
| 6146 | bgp_show_type_prefix_list, |
| 6147 | bgp_show_type_filter_list, |
| 6148 | bgp_show_type_route_map, |
| 6149 | bgp_show_type_neighbor, |
| 6150 | bgp_show_type_cidr_only, |
| 6151 | bgp_show_type_prefix_longer, |
| 6152 | bgp_show_type_community_all, |
| 6153 | bgp_show_type_community, |
| 6154 | bgp_show_type_community_exact, |
| 6155 | bgp_show_type_community_list, |
| 6156 | bgp_show_type_community_list_exact, |
| 6157 | bgp_show_type_flap_statistics, |
| 6158 | bgp_show_type_flap_address, |
| 6159 | bgp_show_type_flap_prefix, |
| 6160 | bgp_show_type_flap_cidr_only, |
| 6161 | bgp_show_type_flap_regexp, |
| 6162 | bgp_show_type_flap_filter_list, |
| 6163 | bgp_show_type_flap_prefix_list, |
| 6164 | bgp_show_type_flap_prefix_longer, |
| 6165 | bgp_show_type_flap_route_map, |
| 6166 | bgp_show_type_flap_neighbor, |
| 6167 | bgp_show_type_dampend_paths, |
| 6168 | bgp_show_type_damp_neighbor |
| 6169 | }; |
| 6170 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6171 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6172 | 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] | 6173 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6174 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6175 | struct bgp_info *ri; |
| 6176 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6177 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6178 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6179 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6180 | |
| 6181 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6182 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6183 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6184 | /* Start processing of routes. */ |
| 6185 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6186 | if (rn->info != NULL) |
| 6187 | { |
| 6188 | display = 0; |
| 6189 | |
| 6190 | for (ri = rn->info; ri; ri = ri->next) |
| 6191 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6192 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6193 | || type == bgp_show_type_flap_address |
| 6194 | || type == bgp_show_type_flap_prefix |
| 6195 | || type == bgp_show_type_flap_cidr_only |
| 6196 | || type == bgp_show_type_flap_regexp |
| 6197 | || type == bgp_show_type_flap_filter_list |
| 6198 | || type == bgp_show_type_flap_prefix_list |
| 6199 | || type == bgp_show_type_flap_prefix_longer |
| 6200 | || type == bgp_show_type_flap_route_map |
| 6201 | || type == bgp_show_type_flap_neighbor |
| 6202 | || type == bgp_show_type_dampend_paths |
| 6203 | || type == bgp_show_type_damp_neighbor) |
| 6204 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6205 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6206 | continue; |
| 6207 | } |
| 6208 | if (type == bgp_show_type_regexp |
| 6209 | || type == bgp_show_type_flap_regexp) |
| 6210 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6211 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6212 | |
| 6213 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6214 | continue; |
| 6215 | } |
| 6216 | if (type == bgp_show_type_prefix_list |
| 6217 | || type == bgp_show_type_flap_prefix_list) |
| 6218 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6219 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6220 | |
| 6221 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6222 | continue; |
| 6223 | } |
| 6224 | if (type == bgp_show_type_filter_list |
| 6225 | || type == bgp_show_type_flap_filter_list) |
| 6226 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6227 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6228 | |
| 6229 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6230 | continue; |
| 6231 | } |
| 6232 | if (type == bgp_show_type_route_map |
| 6233 | || type == bgp_show_type_flap_route_map) |
| 6234 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6235 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6236 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6237 | struct attr dummy_attr; |
| 6238 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6239 | int ret; |
| 6240 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6241 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6242 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6243 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6244 | binfo.peer = ri->peer; |
| 6245 | binfo.attr = &dummy_attr; |
| 6246 | |
| 6247 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6248 | if (ret == RMAP_DENYMATCH) |
| 6249 | continue; |
| 6250 | } |
| 6251 | if (type == bgp_show_type_neighbor |
| 6252 | || type == bgp_show_type_flap_neighbor |
| 6253 | || type == bgp_show_type_damp_neighbor) |
| 6254 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6255 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6256 | |
| 6257 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6258 | continue; |
| 6259 | } |
| 6260 | if (type == bgp_show_type_cidr_only |
| 6261 | || type == bgp_show_type_flap_cidr_only) |
| 6262 | { |
| 6263 | u_int32_t destination; |
| 6264 | |
| 6265 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6266 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6267 | continue; |
| 6268 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6269 | continue; |
| 6270 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6271 | continue; |
| 6272 | } |
| 6273 | if (type == bgp_show_type_prefix_longer |
| 6274 | || type == bgp_show_type_flap_prefix_longer) |
| 6275 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6276 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6277 | |
| 6278 | if (! prefix_match (p, &rn->p)) |
| 6279 | continue; |
| 6280 | } |
| 6281 | if (type == bgp_show_type_community_all) |
| 6282 | { |
| 6283 | if (! ri->attr->community) |
| 6284 | continue; |
| 6285 | } |
| 6286 | if (type == bgp_show_type_community) |
| 6287 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6288 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6289 | |
| 6290 | if (! ri->attr->community || |
| 6291 | ! community_match (ri->attr->community, com)) |
| 6292 | continue; |
| 6293 | } |
| 6294 | if (type == bgp_show_type_community_exact) |
| 6295 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6296 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6297 | |
| 6298 | if (! ri->attr->community || |
| 6299 | ! community_cmp (ri->attr->community, com)) |
| 6300 | continue; |
| 6301 | } |
| 6302 | if (type == bgp_show_type_community_list) |
| 6303 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6304 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6305 | |
| 6306 | if (! community_list_match (ri->attr->community, list)) |
| 6307 | continue; |
| 6308 | } |
| 6309 | if (type == bgp_show_type_community_list_exact) |
| 6310 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6311 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6312 | |
| 6313 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6314 | continue; |
| 6315 | } |
| 6316 | if (type == bgp_show_type_flap_address |
| 6317 | || type == bgp_show_type_flap_prefix) |
| 6318 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6319 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6320 | |
| 6321 | if (! prefix_match (&rn->p, p)) |
| 6322 | continue; |
| 6323 | |
| 6324 | if (type == bgp_show_type_flap_prefix) |
| 6325 | if (p->prefixlen != rn->p.prefixlen) |
| 6326 | continue; |
| 6327 | } |
| 6328 | if (type == bgp_show_type_dampend_paths |
| 6329 | || type == bgp_show_type_damp_neighbor) |
| 6330 | { |
| 6331 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6332 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6333 | continue; |
| 6334 | } |
| 6335 | |
| 6336 | if (header) |
| 6337 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6338 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6339 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6340 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6341 | if (type == bgp_show_type_dampend_paths |
| 6342 | || type == bgp_show_type_damp_neighbor) |
| 6343 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6344 | else if (type == bgp_show_type_flap_statistics |
| 6345 | || type == bgp_show_type_flap_address |
| 6346 | || type == bgp_show_type_flap_prefix |
| 6347 | || type == bgp_show_type_flap_cidr_only |
| 6348 | || type == bgp_show_type_flap_regexp |
| 6349 | || type == bgp_show_type_flap_filter_list |
| 6350 | || type == bgp_show_type_flap_prefix_list |
| 6351 | || type == bgp_show_type_flap_prefix_longer |
| 6352 | || type == bgp_show_type_flap_route_map |
| 6353 | || type == bgp_show_type_flap_neighbor) |
| 6354 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6355 | else |
| 6356 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6357 | header = 0; |
| 6358 | } |
| 6359 | |
| 6360 | if (type == bgp_show_type_dampend_paths |
| 6361 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6362 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6363 | else if (type == bgp_show_type_flap_statistics |
| 6364 | || type == bgp_show_type_flap_address |
| 6365 | || type == bgp_show_type_flap_prefix |
| 6366 | || type == bgp_show_type_flap_cidr_only |
| 6367 | || type == bgp_show_type_flap_regexp |
| 6368 | || type == bgp_show_type_flap_filter_list |
| 6369 | || type == bgp_show_type_flap_prefix_list |
| 6370 | || type == bgp_show_type_flap_prefix_longer |
| 6371 | || type == bgp_show_type_flap_route_map |
| 6372 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6373 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6374 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6375 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6376 | display++; |
| 6377 | } |
| 6378 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6379 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6380 | } |
| 6381 | |
| 6382 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6383 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6384 | { |
| 6385 | if (type == bgp_show_type_normal) |
| 6386 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 6387 | } |
| 6388 | else |
| 6389 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6390 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6391 | |
| 6392 | return CMD_SUCCESS; |
| 6393 | } |
| 6394 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6395 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6396 | 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] | 6397 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6398 | { |
| 6399 | struct bgp_table *table; |
| 6400 | |
| 6401 | if (bgp == NULL) { |
| 6402 | bgp = bgp_get_default (); |
| 6403 | } |
| 6404 | |
| 6405 | if (bgp == NULL) |
| 6406 | { |
| 6407 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6408 | return CMD_WARNING; |
| 6409 | } |
| 6410 | |
| 6411 | |
| 6412 | table = bgp->rib[afi][safi]; |
| 6413 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6414 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6415 | } |
| 6416 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6417 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6418 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6419 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6420 | struct bgp_node *rn, |
| 6421 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6422 | { |
| 6423 | struct bgp_info *ri; |
| 6424 | struct prefix *p; |
| 6425 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6426 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6427 | char buf1[INET6_ADDRSTRLEN]; |
| 6428 | char buf2[INET6_ADDRSTRLEN]; |
| 6429 | int count = 0; |
| 6430 | int best = 0; |
| 6431 | int suppress = 0; |
| 6432 | int no_export = 0; |
| 6433 | int no_advertise = 0; |
| 6434 | int local_as = 0; |
| 6435 | int first = 0; |
| 6436 | |
| 6437 | p = &rn->p; |
| 6438 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 6439 | (safi == SAFI_MPLS_VPN ? |
| 6440 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6441 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 6442 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6443 | p->prefixlen, VTY_NEWLINE); |
| 6444 | |
| 6445 | for (ri = rn->info; ri; ri = ri->next) |
| 6446 | { |
| 6447 | count++; |
| 6448 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6449 | { |
| 6450 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6451 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6452 | suppress = 1; |
| 6453 | if (ri->attr->community != NULL) |
| 6454 | { |
| 6455 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6456 | no_advertise = 1; |
| 6457 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6458 | no_export = 1; |
| 6459 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6460 | local_as = 1; |
| 6461 | } |
| 6462 | } |
| 6463 | } |
| 6464 | |
| 6465 | vty_out (vty, "Paths: (%d available", count); |
| 6466 | if (best) |
| 6467 | { |
| 6468 | vty_out (vty, ", best #%d", best); |
| 6469 | if (safi == SAFI_UNICAST) |
| 6470 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6471 | } |
| 6472 | else |
| 6473 | vty_out (vty, ", no best path"); |
| 6474 | if (no_advertise) |
| 6475 | vty_out (vty, ", not advertised to any peer"); |
| 6476 | else if (no_export) |
| 6477 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6478 | else if (local_as) |
| 6479 | vty_out (vty, ", not advertised outside local AS"); |
| 6480 | if (suppress) |
| 6481 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6482 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6483 | |
| 6484 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6485 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6486 | { |
| 6487 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6488 | { |
| 6489 | if (! first) |
| 6490 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6491 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6492 | first = 1; |
| 6493 | } |
| 6494 | } |
| 6495 | if (! first) |
| 6496 | vty_out (vty, " Not advertised to any peer"); |
| 6497 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6498 | } |
| 6499 | |
| 6500 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6501 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6502 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6503 | struct bgp_table *rib, const char *ip_str, |
| 6504 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6505 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6506 | { |
| 6507 | int ret; |
| 6508 | int header; |
| 6509 | int display = 0; |
| 6510 | struct prefix match; |
| 6511 | struct bgp_node *rn; |
| 6512 | struct bgp_node *rm; |
| 6513 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6514 | struct bgp_table *table; |
| 6515 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6516 | /* Check IP address argument. */ |
| 6517 | ret = str2prefix (ip_str, &match); |
| 6518 | if (! ret) |
| 6519 | { |
| 6520 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6521 | return CMD_WARNING; |
| 6522 | } |
| 6523 | |
| 6524 | match.family = afi2family (afi); |
| 6525 | |
| 6526 | if (safi == SAFI_MPLS_VPN) |
| 6527 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6528 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6529 | { |
| 6530 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6531 | continue; |
| 6532 | |
| 6533 | if ((table = rn->info) != NULL) |
| 6534 | { |
| 6535 | header = 1; |
| 6536 | |
| 6537 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6538 | { |
| 6539 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6540 | { |
| 6541 | bgp_unlock_node (rm); |
| 6542 | continue; |
| 6543 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6544 | |
| 6545 | for (ri = rm->info; ri; ri = ri->next) |
| 6546 | { |
| 6547 | if (header) |
| 6548 | { |
| 6549 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 6550 | AFI_IP, SAFI_MPLS_VPN); |
| 6551 | |
| 6552 | header = 0; |
| 6553 | } |
| 6554 | display++; |
| 6555 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 6556 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6557 | |
| 6558 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6559 | } |
| 6560 | } |
| 6561 | } |
| 6562 | } |
| 6563 | else |
| 6564 | { |
| 6565 | header = 1; |
| 6566 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6567 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6568 | { |
| 6569 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6570 | { |
| 6571 | for (ri = rn->info; ri; ri = ri->next) |
| 6572 | { |
| 6573 | if (header) |
| 6574 | { |
| 6575 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6576 | header = 0; |
| 6577 | } |
| 6578 | display++; |
| 6579 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6580 | } |
| 6581 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6582 | |
| 6583 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6584 | } |
| 6585 | } |
| 6586 | |
| 6587 | if (! display) |
| 6588 | { |
| 6589 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6590 | return CMD_WARNING; |
| 6591 | } |
| 6592 | |
| 6593 | return CMD_SUCCESS; |
| 6594 | } |
| 6595 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6596 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6597 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6598 | 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] | 6599 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6600 | int prefix_check) |
| 6601 | { |
| 6602 | struct bgp *bgp; |
| 6603 | |
| 6604 | /* BGP structure lookup. */ |
| 6605 | if (view_name) |
| 6606 | { |
| 6607 | bgp = bgp_lookup_by_name (view_name); |
| 6608 | if (bgp == NULL) |
| 6609 | { |
| 6610 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6611 | return CMD_WARNING; |
| 6612 | } |
| 6613 | } |
| 6614 | else |
| 6615 | { |
| 6616 | bgp = bgp_get_default (); |
| 6617 | if (bgp == NULL) |
| 6618 | { |
| 6619 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6620 | return CMD_WARNING; |
| 6621 | } |
| 6622 | } |
| 6623 | |
| 6624 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6625 | afi, safi, prd, prefix_check); |
| 6626 | } |
| 6627 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6628 | /* BGP route print out function. */ |
| 6629 | DEFUN (show_ip_bgp, |
| 6630 | show_ip_bgp_cmd, |
| 6631 | "show ip bgp", |
| 6632 | SHOW_STR |
| 6633 | IP_STR |
| 6634 | BGP_STR) |
| 6635 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6636 | 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] | 6637 | } |
| 6638 | |
| 6639 | DEFUN (show_ip_bgp_ipv4, |
| 6640 | show_ip_bgp_ipv4_cmd, |
| 6641 | "show ip bgp ipv4 (unicast|multicast)", |
| 6642 | SHOW_STR |
| 6643 | IP_STR |
| 6644 | BGP_STR |
| 6645 | "Address family\n" |
| 6646 | "Address Family modifier\n" |
| 6647 | "Address Family modifier\n") |
| 6648 | { |
| 6649 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6650 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6651 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6652 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6653 | 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] | 6654 | } |
| 6655 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6656 | ALIAS (show_ip_bgp_ipv4, |
| 6657 | show_bgp_ipv4_safi_cmd, |
| 6658 | "show bgp ipv4 (unicast|multicast)", |
| 6659 | SHOW_STR |
| 6660 | BGP_STR |
| 6661 | "Address family\n" |
| 6662 | "Address Family modifier\n" |
| 6663 | "Address Family modifier\n") |
| 6664 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6665 | DEFUN (show_ip_bgp_route, |
| 6666 | show_ip_bgp_route_cmd, |
| 6667 | "show ip bgp A.B.C.D", |
| 6668 | SHOW_STR |
| 6669 | IP_STR |
| 6670 | BGP_STR |
| 6671 | "Network in the BGP routing table to display\n") |
| 6672 | { |
| 6673 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6674 | } |
| 6675 | |
| 6676 | DEFUN (show_ip_bgp_ipv4_route, |
| 6677 | show_ip_bgp_ipv4_route_cmd, |
| 6678 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6679 | SHOW_STR |
| 6680 | IP_STR |
| 6681 | BGP_STR |
| 6682 | "Address family\n" |
| 6683 | "Address Family modifier\n" |
| 6684 | "Address Family modifier\n" |
| 6685 | "Network in the BGP routing table to display\n") |
| 6686 | { |
| 6687 | if (strncmp (argv[0], "m", 1) == 0) |
| 6688 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6689 | |
| 6690 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6691 | } |
| 6692 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6693 | ALIAS (show_ip_bgp_ipv4_route, |
| 6694 | show_bgp_ipv4_safi_route_cmd, |
| 6695 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6696 | SHOW_STR |
| 6697 | BGP_STR |
| 6698 | "Address family\n" |
| 6699 | "Address Family modifier\n" |
| 6700 | "Address Family modifier\n" |
| 6701 | "Network in the BGP routing table to display\n") |
| 6702 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6703 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6704 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6705 | "show ip bgp vpnv4 all A.B.C.D", |
| 6706 | SHOW_STR |
| 6707 | IP_STR |
| 6708 | BGP_STR |
| 6709 | "Display VPNv4 NLRI specific information\n" |
| 6710 | "Display information about all VPNv4 NLRIs\n" |
| 6711 | "Network in the BGP routing table to display\n") |
| 6712 | { |
| 6713 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6714 | } |
| 6715 | |
| 6716 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6717 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6718 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6719 | SHOW_STR |
| 6720 | IP_STR |
| 6721 | BGP_STR |
| 6722 | "Display VPNv4 NLRI specific information\n" |
| 6723 | "Display information for a route distinguisher\n" |
| 6724 | "VPN Route Distinguisher\n" |
| 6725 | "Network in the BGP routing table to display\n") |
| 6726 | { |
| 6727 | int ret; |
| 6728 | struct prefix_rd prd; |
| 6729 | |
| 6730 | ret = str2prefix_rd (argv[0], &prd); |
| 6731 | if (! ret) |
| 6732 | { |
| 6733 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6734 | return CMD_WARNING; |
| 6735 | } |
| 6736 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6737 | } |
| 6738 | |
| 6739 | DEFUN (show_ip_bgp_prefix, |
| 6740 | show_ip_bgp_prefix_cmd, |
| 6741 | "show ip bgp A.B.C.D/M", |
| 6742 | SHOW_STR |
| 6743 | IP_STR |
| 6744 | BGP_STR |
| 6745 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6746 | { |
| 6747 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6748 | } |
| 6749 | |
| 6750 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6751 | show_ip_bgp_ipv4_prefix_cmd, |
| 6752 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6753 | SHOW_STR |
| 6754 | IP_STR |
| 6755 | BGP_STR |
| 6756 | "Address family\n" |
| 6757 | "Address Family modifier\n" |
| 6758 | "Address Family modifier\n" |
| 6759 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6760 | { |
| 6761 | if (strncmp (argv[0], "m", 1) == 0) |
| 6762 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6763 | |
| 6764 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6765 | } |
| 6766 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6767 | ALIAS (show_ip_bgp_ipv4_prefix, |
| 6768 | show_bgp_ipv4_safi_prefix_cmd, |
| 6769 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6770 | SHOW_STR |
| 6771 | BGP_STR |
| 6772 | "Address family\n" |
| 6773 | "Address Family modifier\n" |
| 6774 | "Address Family modifier\n" |
| 6775 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6776 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6777 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 6778 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 6779 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 6780 | SHOW_STR |
| 6781 | IP_STR |
| 6782 | BGP_STR |
| 6783 | "Display VPNv4 NLRI specific information\n" |
| 6784 | "Display information about all VPNv4 NLRIs\n" |
| 6785 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6786 | { |
| 6787 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 6788 | } |
| 6789 | |
| 6790 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 6791 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 6792 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 6793 | SHOW_STR |
| 6794 | IP_STR |
| 6795 | BGP_STR |
| 6796 | "Display VPNv4 NLRI specific information\n" |
| 6797 | "Display information for a route distinguisher\n" |
| 6798 | "VPN Route Distinguisher\n" |
| 6799 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6800 | { |
| 6801 | int ret; |
| 6802 | struct prefix_rd prd; |
| 6803 | |
| 6804 | ret = str2prefix_rd (argv[0], &prd); |
| 6805 | if (! ret) |
| 6806 | { |
| 6807 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6808 | return CMD_WARNING; |
| 6809 | } |
| 6810 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 6811 | } |
| 6812 | |
| 6813 | DEFUN (show_ip_bgp_view, |
| 6814 | show_ip_bgp_view_cmd, |
| 6815 | "show ip bgp view WORD", |
| 6816 | SHOW_STR |
| 6817 | IP_STR |
| 6818 | BGP_STR |
| 6819 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6820 | "View name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6821 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6822 | struct bgp *bgp; |
| 6823 | |
| 6824 | /* BGP structure lookup. */ |
| 6825 | bgp = bgp_lookup_by_name (argv[0]); |
| 6826 | if (bgp == NULL) |
| 6827 | { |
| 6828 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6829 | return CMD_WARNING; |
| 6830 | } |
| 6831 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6832 | 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] | 6833 | } |
| 6834 | |
| 6835 | DEFUN (show_ip_bgp_view_route, |
| 6836 | show_ip_bgp_view_route_cmd, |
| 6837 | "show ip bgp view WORD A.B.C.D", |
| 6838 | SHOW_STR |
| 6839 | IP_STR |
| 6840 | BGP_STR |
| 6841 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6842 | "View name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6843 | "Network in the BGP routing table to display\n") |
| 6844 | { |
| 6845 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6846 | } |
| 6847 | |
| 6848 | DEFUN (show_ip_bgp_view_prefix, |
| 6849 | show_ip_bgp_view_prefix_cmd, |
| 6850 | "show ip bgp view WORD A.B.C.D/M", |
| 6851 | SHOW_STR |
| 6852 | IP_STR |
| 6853 | BGP_STR |
| 6854 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6855 | "View name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6856 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6857 | { |
| 6858 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6859 | } |
| 6860 | |
| 6861 | #ifdef HAVE_IPV6 |
| 6862 | DEFUN (show_bgp, |
| 6863 | show_bgp_cmd, |
| 6864 | "show bgp", |
| 6865 | SHOW_STR |
| 6866 | BGP_STR) |
| 6867 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6868 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6869 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6870 | } |
| 6871 | |
| 6872 | ALIAS (show_bgp, |
| 6873 | show_bgp_ipv6_cmd, |
| 6874 | "show bgp ipv6", |
| 6875 | SHOW_STR |
| 6876 | BGP_STR |
| 6877 | "Address family\n") |
| 6878 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6879 | DEFUN (show_bgp_ipv6_safi, |
| 6880 | show_bgp_ipv6_safi_cmd, |
| 6881 | "show bgp ipv6 (unicast|multicast)", |
| 6882 | SHOW_STR |
| 6883 | BGP_STR |
| 6884 | "Address family\n" |
| 6885 | "Address Family modifier\n" |
| 6886 | "Address Family modifier\n") |
| 6887 | { |
| 6888 | if (strncmp (argv[0], "m", 1) == 0) |
| 6889 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6890 | NULL); |
| 6891 | |
| 6892 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6893 | } |
| 6894 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6895 | /* old command */ |
| 6896 | DEFUN (show_ipv6_bgp, |
| 6897 | show_ipv6_bgp_cmd, |
| 6898 | "show ipv6 bgp", |
| 6899 | SHOW_STR |
| 6900 | IP_STR |
| 6901 | BGP_STR) |
| 6902 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6903 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6904 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6905 | } |
| 6906 | |
| 6907 | DEFUN (show_bgp_route, |
| 6908 | show_bgp_route_cmd, |
| 6909 | "show bgp X:X::X:X", |
| 6910 | SHOW_STR |
| 6911 | BGP_STR |
| 6912 | "Network in the BGP routing table to display\n") |
| 6913 | { |
| 6914 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6915 | } |
| 6916 | |
| 6917 | ALIAS (show_bgp_route, |
| 6918 | show_bgp_ipv6_route_cmd, |
| 6919 | "show bgp ipv6 X:X::X:X", |
| 6920 | SHOW_STR |
| 6921 | BGP_STR |
| 6922 | "Address family\n" |
| 6923 | "Network in the BGP routing table to display\n") |
| 6924 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6925 | DEFUN (show_bgp_ipv6_safi_route, |
| 6926 | show_bgp_ipv6_safi_route_cmd, |
| 6927 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
| 6928 | SHOW_STR |
| 6929 | BGP_STR |
| 6930 | "Address family\n" |
| 6931 | "Address Family modifier\n" |
| 6932 | "Address Family modifier\n" |
| 6933 | "Network in the BGP routing table to display\n") |
| 6934 | { |
| 6935 | if (strncmp (argv[0], "m", 1) == 0) |
| 6936 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6937 | |
| 6938 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6939 | } |
| 6940 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6941 | /* old command */ |
| 6942 | DEFUN (show_ipv6_bgp_route, |
| 6943 | show_ipv6_bgp_route_cmd, |
| 6944 | "show ipv6 bgp X:X::X:X", |
| 6945 | SHOW_STR |
| 6946 | IP_STR |
| 6947 | BGP_STR |
| 6948 | "Network in the BGP routing table to display\n") |
| 6949 | { |
| 6950 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6951 | } |
| 6952 | |
| 6953 | DEFUN (show_bgp_prefix, |
| 6954 | show_bgp_prefix_cmd, |
| 6955 | "show bgp X:X::X:X/M", |
| 6956 | SHOW_STR |
| 6957 | BGP_STR |
| 6958 | "IPv6 prefix <network>/<length>\n") |
| 6959 | { |
| 6960 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6961 | } |
| 6962 | |
| 6963 | ALIAS (show_bgp_prefix, |
| 6964 | show_bgp_ipv6_prefix_cmd, |
| 6965 | "show bgp ipv6 X:X::X:X/M", |
| 6966 | SHOW_STR |
| 6967 | BGP_STR |
| 6968 | "Address family\n" |
| 6969 | "IPv6 prefix <network>/<length>\n") |
| 6970 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6971 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 6972 | show_bgp_ipv6_safi_prefix_cmd, |
| 6973 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 6974 | SHOW_STR |
| 6975 | BGP_STR |
| 6976 | "Address family\n" |
| 6977 | "Address Family modifier\n" |
| 6978 | "Address Family modifier\n" |
| 6979 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6980 | { |
| 6981 | if (strncmp (argv[0], "m", 1) == 0) |
| 6982 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 6983 | |
| 6984 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6985 | } |
| 6986 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6987 | /* old command */ |
| 6988 | DEFUN (show_ipv6_bgp_prefix, |
| 6989 | show_ipv6_bgp_prefix_cmd, |
| 6990 | "show ipv6 bgp X:X::X:X/M", |
| 6991 | SHOW_STR |
| 6992 | IP_STR |
| 6993 | BGP_STR |
| 6994 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6995 | { |
| 6996 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6997 | } |
| 6998 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6999 | DEFUN (show_bgp_view, |
| 7000 | show_bgp_view_cmd, |
| 7001 | "show bgp view WORD", |
| 7002 | SHOW_STR |
| 7003 | BGP_STR |
| 7004 | "BGP view\n" |
| 7005 | "View name\n") |
| 7006 | { |
| 7007 | struct bgp *bgp; |
| 7008 | |
| 7009 | /* BGP structure lookup. */ |
| 7010 | bgp = bgp_lookup_by_name (argv[0]); |
| 7011 | if (bgp == NULL) |
| 7012 | { |
| 7013 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7014 | return CMD_WARNING; |
| 7015 | } |
| 7016 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7017 | 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] | 7018 | } |
| 7019 | |
| 7020 | ALIAS (show_bgp_view, |
| 7021 | show_bgp_view_ipv6_cmd, |
| 7022 | "show bgp view WORD ipv6", |
| 7023 | SHOW_STR |
| 7024 | BGP_STR |
| 7025 | "BGP view\n" |
| 7026 | "View name\n" |
| 7027 | "Address family\n") |
| 7028 | |
| 7029 | DEFUN (show_bgp_view_route, |
| 7030 | show_bgp_view_route_cmd, |
| 7031 | "show bgp view WORD X:X::X:X", |
| 7032 | SHOW_STR |
| 7033 | BGP_STR |
| 7034 | "BGP view\n" |
| 7035 | "View name\n" |
| 7036 | "Network in the BGP routing table to display\n") |
| 7037 | { |
| 7038 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7039 | } |
| 7040 | |
| 7041 | ALIAS (show_bgp_view_route, |
| 7042 | show_bgp_view_ipv6_route_cmd, |
| 7043 | "show bgp view WORD ipv6 X:X::X:X", |
| 7044 | SHOW_STR |
| 7045 | BGP_STR |
| 7046 | "BGP view\n" |
| 7047 | "View name\n" |
| 7048 | "Address family\n" |
| 7049 | "Network in the BGP routing table to display\n") |
| 7050 | |
| 7051 | DEFUN (show_bgp_view_prefix, |
| 7052 | show_bgp_view_prefix_cmd, |
| 7053 | "show bgp view WORD X:X::X:X/M", |
| 7054 | SHOW_STR |
| 7055 | BGP_STR |
| 7056 | "BGP view\n" |
| 7057 | "View name\n" |
| 7058 | "IPv6 prefix <network>/<length>\n") |
| 7059 | { |
| 7060 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7061 | } |
| 7062 | |
| 7063 | ALIAS (show_bgp_view_prefix, |
| 7064 | show_bgp_view_ipv6_prefix_cmd, |
| 7065 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 7066 | SHOW_STR |
| 7067 | BGP_STR |
| 7068 | "BGP view\n" |
| 7069 | "View name\n" |
| 7070 | "Address family\n" |
| 7071 | "IPv6 prefix <network>/<length>\n") |
| 7072 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7073 | /* old command */ |
| 7074 | DEFUN (show_ipv6_mbgp, |
| 7075 | show_ipv6_mbgp_cmd, |
| 7076 | "show ipv6 mbgp", |
| 7077 | SHOW_STR |
| 7078 | IP_STR |
| 7079 | MBGP_STR) |
| 7080 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7081 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7082 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7083 | } |
| 7084 | |
| 7085 | /* old command */ |
| 7086 | DEFUN (show_ipv6_mbgp_route, |
| 7087 | show_ipv6_mbgp_route_cmd, |
| 7088 | "show ipv6 mbgp X:X::X:X", |
| 7089 | SHOW_STR |
| 7090 | IP_STR |
| 7091 | MBGP_STR |
| 7092 | "Network in the MBGP routing table to display\n") |
| 7093 | { |
| 7094 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7095 | } |
| 7096 | |
| 7097 | /* old command */ |
| 7098 | DEFUN (show_ipv6_mbgp_prefix, |
| 7099 | show_ipv6_mbgp_prefix_cmd, |
| 7100 | "show ipv6 mbgp X:X::X:X/M", |
| 7101 | SHOW_STR |
| 7102 | IP_STR |
| 7103 | MBGP_STR |
| 7104 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7105 | { |
| 7106 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7107 | } |
| 7108 | #endif |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7109 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7110 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7111 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7112 | 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] | 7113 | safi_t safi, enum bgp_show_type type) |
| 7114 | { |
| 7115 | int i; |
| 7116 | struct buffer *b; |
| 7117 | char *regstr; |
| 7118 | int first; |
| 7119 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7120 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7121 | |
| 7122 | first = 0; |
| 7123 | b = buffer_new (1024); |
| 7124 | for (i = 0; i < argc; i++) |
| 7125 | { |
| 7126 | if (first) |
| 7127 | buffer_putc (b, ' '); |
| 7128 | else |
| 7129 | { |
| 7130 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7131 | continue; |
| 7132 | first = 1; |
| 7133 | } |
| 7134 | |
| 7135 | buffer_putstr (b, argv[i]); |
| 7136 | } |
| 7137 | buffer_putc (b, '\0'); |
| 7138 | |
| 7139 | regstr = buffer_getstr (b); |
| 7140 | buffer_free (b); |
| 7141 | |
| 7142 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7143 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7144 | if (! regex) |
| 7145 | { |
| 7146 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 7147 | VTY_NEWLINE); |
| 7148 | return CMD_WARNING; |
| 7149 | } |
| 7150 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7151 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 7152 | bgp_regex_free (regex); |
| 7153 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7154 | } |
| 7155 | |
| 7156 | DEFUN (show_ip_bgp_regexp, |
| 7157 | show_ip_bgp_regexp_cmd, |
| 7158 | "show ip bgp regexp .LINE", |
| 7159 | SHOW_STR |
| 7160 | IP_STR |
| 7161 | BGP_STR |
| 7162 | "Display routes matching the AS path regular expression\n" |
| 7163 | "A regular-expression to match the BGP AS paths\n") |
| 7164 | { |
| 7165 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7166 | bgp_show_type_regexp); |
| 7167 | } |
| 7168 | |
| 7169 | DEFUN (show_ip_bgp_flap_regexp, |
| 7170 | show_ip_bgp_flap_regexp_cmd, |
| 7171 | "show ip bgp flap-statistics regexp .LINE", |
| 7172 | SHOW_STR |
| 7173 | IP_STR |
| 7174 | BGP_STR |
| 7175 | "Display flap statistics of routes\n" |
| 7176 | "Display routes matching the AS path regular expression\n" |
| 7177 | "A regular-expression to match the BGP AS paths\n") |
| 7178 | { |
| 7179 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7180 | bgp_show_type_flap_regexp); |
| 7181 | } |
| 7182 | |
| 7183 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 7184 | show_ip_bgp_ipv4_regexp_cmd, |
| 7185 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 7186 | SHOW_STR |
| 7187 | IP_STR |
| 7188 | BGP_STR |
| 7189 | "Address family\n" |
| 7190 | "Address Family modifier\n" |
| 7191 | "Address Family modifier\n" |
| 7192 | "Display routes matching the AS path regular expression\n" |
| 7193 | "A regular-expression to match the BGP AS paths\n") |
| 7194 | { |
| 7195 | if (strncmp (argv[0], "m", 1) == 0) |
| 7196 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 7197 | bgp_show_type_regexp); |
| 7198 | |
| 7199 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7200 | bgp_show_type_regexp); |
| 7201 | } |
| 7202 | |
| 7203 | #ifdef HAVE_IPV6 |
| 7204 | DEFUN (show_bgp_regexp, |
| 7205 | show_bgp_regexp_cmd, |
| 7206 | "show bgp regexp .LINE", |
| 7207 | SHOW_STR |
| 7208 | BGP_STR |
| 7209 | "Display routes matching the AS path regular expression\n" |
| 7210 | "A regular-expression to match the BGP AS paths\n") |
| 7211 | { |
| 7212 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7213 | bgp_show_type_regexp); |
| 7214 | } |
| 7215 | |
| 7216 | ALIAS (show_bgp_regexp, |
| 7217 | show_bgp_ipv6_regexp_cmd, |
| 7218 | "show bgp ipv6 regexp .LINE", |
| 7219 | SHOW_STR |
| 7220 | BGP_STR |
| 7221 | "Address family\n" |
| 7222 | "Display routes matching the AS path regular expression\n" |
| 7223 | "A regular-expression to match the BGP AS paths\n") |
| 7224 | |
| 7225 | /* old command */ |
| 7226 | DEFUN (show_ipv6_bgp_regexp, |
| 7227 | show_ipv6_bgp_regexp_cmd, |
| 7228 | "show ipv6 bgp regexp .LINE", |
| 7229 | SHOW_STR |
| 7230 | IP_STR |
| 7231 | BGP_STR |
| 7232 | "Display routes matching the AS path regular expression\n" |
| 7233 | "A regular-expression to match the BGP AS paths\n") |
| 7234 | { |
| 7235 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7236 | bgp_show_type_regexp); |
| 7237 | } |
| 7238 | |
| 7239 | /* old command */ |
| 7240 | DEFUN (show_ipv6_mbgp_regexp, |
| 7241 | show_ipv6_mbgp_regexp_cmd, |
| 7242 | "show ipv6 mbgp regexp .LINE", |
| 7243 | SHOW_STR |
| 7244 | IP_STR |
| 7245 | BGP_STR |
| 7246 | "Display routes matching the AS path regular expression\n" |
| 7247 | "A regular-expression to match the MBGP AS paths\n") |
| 7248 | { |
| 7249 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 7250 | bgp_show_type_regexp); |
| 7251 | } |
| 7252 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7253 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7254 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7255 | 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] | 7256 | safi_t safi, enum bgp_show_type type) |
| 7257 | { |
| 7258 | struct prefix_list *plist; |
| 7259 | |
| 7260 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 7261 | if (plist == NULL) |
| 7262 | { |
| 7263 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 7264 | prefix_list_str, VTY_NEWLINE); |
| 7265 | return CMD_WARNING; |
| 7266 | } |
| 7267 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7268 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7269 | } |
| 7270 | |
| 7271 | DEFUN (show_ip_bgp_prefix_list, |
| 7272 | show_ip_bgp_prefix_list_cmd, |
| 7273 | "show ip bgp prefix-list WORD", |
| 7274 | SHOW_STR |
| 7275 | IP_STR |
| 7276 | BGP_STR |
| 7277 | "Display routes conforming to the prefix-list\n" |
| 7278 | "IP prefix-list name\n") |
| 7279 | { |
| 7280 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7281 | bgp_show_type_prefix_list); |
| 7282 | } |
| 7283 | |
| 7284 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 7285 | show_ip_bgp_flap_prefix_list_cmd, |
| 7286 | "show ip bgp flap-statistics prefix-list WORD", |
| 7287 | SHOW_STR |
| 7288 | IP_STR |
| 7289 | BGP_STR |
| 7290 | "Display flap statistics of routes\n" |
| 7291 | "Display routes conforming to the prefix-list\n" |
| 7292 | "IP prefix-list name\n") |
| 7293 | { |
| 7294 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7295 | bgp_show_type_flap_prefix_list); |
| 7296 | } |
| 7297 | |
| 7298 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 7299 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 7300 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 7301 | SHOW_STR |
| 7302 | IP_STR |
| 7303 | BGP_STR |
| 7304 | "Address family\n" |
| 7305 | "Address Family modifier\n" |
| 7306 | "Address Family modifier\n" |
| 7307 | "Display routes conforming to the prefix-list\n" |
| 7308 | "IP prefix-list name\n") |
| 7309 | { |
| 7310 | if (strncmp (argv[0], "m", 1) == 0) |
| 7311 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7312 | bgp_show_type_prefix_list); |
| 7313 | |
| 7314 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7315 | bgp_show_type_prefix_list); |
| 7316 | } |
| 7317 | |
| 7318 | #ifdef HAVE_IPV6 |
| 7319 | DEFUN (show_bgp_prefix_list, |
| 7320 | show_bgp_prefix_list_cmd, |
| 7321 | "show bgp prefix-list WORD", |
| 7322 | SHOW_STR |
| 7323 | BGP_STR |
| 7324 | "Display routes conforming to the prefix-list\n" |
| 7325 | "IPv6 prefix-list name\n") |
| 7326 | { |
| 7327 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7328 | bgp_show_type_prefix_list); |
| 7329 | } |
| 7330 | |
| 7331 | ALIAS (show_bgp_prefix_list, |
| 7332 | show_bgp_ipv6_prefix_list_cmd, |
| 7333 | "show bgp ipv6 prefix-list WORD", |
| 7334 | SHOW_STR |
| 7335 | BGP_STR |
| 7336 | "Address family\n" |
| 7337 | "Display routes conforming to the prefix-list\n" |
| 7338 | "IPv6 prefix-list name\n") |
| 7339 | |
| 7340 | /* old command */ |
| 7341 | DEFUN (show_ipv6_bgp_prefix_list, |
| 7342 | show_ipv6_bgp_prefix_list_cmd, |
| 7343 | "show ipv6 bgp prefix-list WORD", |
| 7344 | SHOW_STR |
| 7345 | IPV6_STR |
| 7346 | BGP_STR |
| 7347 | "Display routes matching the prefix-list\n" |
| 7348 | "IPv6 prefix-list name\n") |
| 7349 | { |
| 7350 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7351 | bgp_show_type_prefix_list); |
| 7352 | } |
| 7353 | |
| 7354 | /* old command */ |
| 7355 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 7356 | show_ipv6_mbgp_prefix_list_cmd, |
| 7357 | "show ipv6 mbgp prefix-list WORD", |
| 7358 | SHOW_STR |
| 7359 | IPV6_STR |
| 7360 | MBGP_STR |
| 7361 | "Display routes matching the prefix-list\n" |
| 7362 | "IPv6 prefix-list name\n") |
| 7363 | { |
| 7364 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7365 | bgp_show_type_prefix_list); |
| 7366 | } |
| 7367 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7368 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7369 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7370 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7371 | safi_t safi, enum bgp_show_type type) |
| 7372 | { |
| 7373 | struct as_list *as_list; |
| 7374 | |
| 7375 | as_list = as_list_lookup (filter); |
| 7376 | if (as_list == NULL) |
| 7377 | { |
| 7378 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 7379 | return CMD_WARNING; |
| 7380 | } |
| 7381 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7382 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7383 | } |
| 7384 | |
| 7385 | DEFUN (show_ip_bgp_filter_list, |
| 7386 | show_ip_bgp_filter_list_cmd, |
| 7387 | "show ip bgp filter-list WORD", |
| 7388 | SHOW_STR |
| 7389 | IP_STR |
| 7390 | BGP_STR |
| 7391 | "Display routes conforming to the filter-list\n" |
| 7392 | "Regular expression access list name\n") |
| 7393 | { |
| 7394 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7395 | bgp_show_type_filter_list); |
| 7396 | } |
| 7397 | |
| 7398 | DEFUN (show_ip_bgp_flap_filter_list, |
| 7399 | show_ip_bgp_flap_filter_list_cmd, |
| 7400 | "show ip bgp flap-statistics filter-list WORD", |
| 7401 | SHOW_STR |
| 7402 | IP_STR |
| 7403 | BGP_STR |
| 7404 | "Display flap statistics of routes\n" |
| 7405 | "Display routes conforming to the filter-list\n" |
| 7406 | "Regular expression access list name\n") |
| 7407 | { |
| 7408 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7409 | bgp_show_type_flap_filter_list); |
| 7410 | } |
| 7411 | |
| 7412 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 7413 | show_ip_bgp_ipv4_filter_list_cmd, |
| 7414 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 7415 | SHOW_STR |
| 7416 | IP_STR |
| 7417 | BGP_STR |
| 7418 | "Address family\n" |
| 7419 | "Address Family modifier\n" |
| 7420 | "Address Family modifier\n" |
| 7421 | "Display routes conforming to the filter-list\n" |
| 7422 | "Regular expression access list name\n") |
| 7423 | { |
| 7424 | if (strncmp (argv[0], "m", 1) == 0) |
| 7425 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7426 | bgp_show_type_filter_list); |
| 7427 | |
| 7428 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7429 | bgp_show_type_filter_list); |
| 7430 | } |
| 7431 | |
| 7432 | #ifdef HAVE_IPV6 |
| 7433 | DEFUN (show_bgp_filter_list, |
| 7434 | show_bgp_filter_list_cmd, |
| 7435 | "show bgp filter-list WORD", |
| 7436 | SHOW_STR |
| 7437 | BGP_STR |
| 7438 | "Display routes conforming to the filter-list\n" |
| 7439 | "Regular expression access list name\n") |
| 7440 | { |
| 7441 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7442 | bgp_show_type_filter_list); |
| 7443 | } |
| 7444 | |
| 7445 | ALIAS (show_bgp_filter_list, |
| 7446 | show_bgp_ipv6_filter_list_cmd, |
| 7447 | "show bgp ipv6 filter-list WORD", |
| 7448 | SHOW_STR |
| 7449 | BGP_STR |
| 7450 | "Address family\n" |
| 7451 | "Display routes conforming to the filter-list\n" |
| 7452 | "Regular expression access list name\n") |
| 7453 | |
| 7454 | /* old command */ |
| 7455 | DEFUN (show_ipv6_bgp_filter_list, |
| 7456 | show_ipv6_bgp_filter_list_cmd, |
| 7457 | "show ipv6 bgp filter-list WORD", |
| 7458 | SHOW_STR |
| 7459 | IPV6_STR |
| 7460 | BGP_STR |
| 7461 | "Display routes conforming to the filter-list\n" |
| 7462 | "Regular expression access list name\n") |
| 7463 | { |
| 7464 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7465 | bgp_show_type_filter_list); |
| 7466 | } |
| 7467 | |
| 7468 | /* old command */ |
| 7469 | DEFUN (show_ipv6_mbgp_filter_list, |
| 7470 | show_ipv6_mbgp_filter_list_cmd, |
| 7471 | "show ipv6 mbgp filter-list WORD", |
| 7472 | SHOW_STR |
| 7473 | IPV6_STR |
| 7474 | MBGP_STR |
| 7475 | "Display routes conforming to the filter-list\n" |
| 7476 | "Regular expression access list name\n") |
| 7477 | { |
| 7478 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7479 | bgp_show_type_filter_list); |
| 7480 | } |
| 7481 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7482 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7483 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7484 | 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] | 7485 | safi_t safi, enum bgp_show_type type) |
| 7486 | { |
| 7487 | struct route_map *rmap; |
| 7488 | |
| 7489 | rmap = route_map_lookup_by_name (rmap_str); |
| 7490 | if (! rmap) |
| 7491 | { |
| 7492 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 7493 | rmap_str, VTY_NEWLINE); |
| 7494 | return CMD_WARNING; |
| 7495 | } |
| 7496 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7497 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7498 | } |
| 7499 | |
| 7500 | DEFUN (show_ip_bgp_route_map, |
| 7501 | show_ip_bgp_route_map_cmd, |
| 7502 | "show ip bgp route-map WORD", |
| 7503 | SHOW_STR |
| 7504 | IP_STR |
| 7505 | BGP_STR |
| 7506 | "Display routes matching the route-map\n" |
| 7507 | "A route-map to match on\n") |
| 7508 | { |
| 7509 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7510 | bgp_show_type_route_map); |
| 7511 | } |
| 7512 | |
| 7513 | DEFUN (show_ip_bgp_flap_route_map, |
| 7514 | show_ip_bgp_flap_route_map_cmd, |
| 7515 | "show ip bgp flap-statistics route-map WORD", |
| 7516 | SHOW_STR |
| 7517 | IP_STR |
| 7518 | BGP_STR |
| 7519 | "Display flap statistics of routes\n" |
| 7520 | "Display routes matching the route-map\n" |
| 7521 | "A route-map to match on\n") |
| 7522 | { |
| 7523 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7524 | bgp_show_type_flap_route_map); |
| 7525 | } |
| 7526 | |
| 7527 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 7528 | show_ip_bgp_ipv4_route_map_cmd, |
| 7529 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 7530 | SHOW_STR |
| 7531 | IP_STR |
| 7532 | BGP_STR |
| 7533 | "Address family\n" |
| 7534 | "Address Family modifier\n" |
| 7535 | "Address Family modifier\n" |
| 7536 | "Display routes matching the route-map\n" |
| 7537 | "A route-map to match on\n") |
| 7538 | { |
| 7539 | if (strncmp (argv[0], "m", 1) == 0) |
| 7540 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7541 | bgp_show_type_route_map); |
| 7542 | |
| 7543 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7544 | bgp_show_type_route_map); |
| 7545 | } |
| 7546 | |
| 7547 | DEFUN (show_bgp_route_map, |
| 7548 | show_bgp_route_map_cmd, |
| 7549 | "show bgp route-map WORD", |
| 7550 | SHOW_STR |
| 7551 | BGP_STR |
| 7552 | "Display routes matching the route-map\n" |
| 7553 | "A route-map to match on\n") |
| 7554 | { |
| 7555 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7556 | bgp_show_type_route_map); |
| 7557 | } |
| 7558 | |
| 7559 | ALIAS (show_bgp_route_map, |
| 7560 | show_bgp_ipv6_route_map_cmd, |
| 7561 | "show bgp ipv6 route-map WORD", |
| 7562 | SHOW_STR |
| 7563 | BGP_STR |
| 7564 | "Address family\n" |
| 7565 | "Display routes matching the route-map\n" |
| 7566 | "A route-map to match on\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7567 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7568 | DEFUN (show_ip_bgp_cidr_only, |
| 7569 | show_ip_bgp_cidr_only_cmd, |
| 7570 | "show ip bgp cidr-only", |
| 7571 | SHOW_STR |
| 7572 | IP_STR |
| 7573 | BGP_STR |
| 7574 | "Display only routes with non-natural netmasks\n") |
| 7575 | { |
| 7576 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7577 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7578 | } |
| 7579 | |
| 7580 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 7581 | show_ip_bgp_flap_cidr_only_cmd, |
| 7582 | "show ip bgp flap-statistics cidr-only", |
| 7583 | SHOW_STR |
| 7584 | IP_STR |
| 7585 | BGP_STR |
| 7586 | "Display flap statistics of routes\n" |
| 7587 | "Display only routes with non-natural netmasks\n") |
| 7588 | { |
| 7589 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7590 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7591 | } |
| 7592 | |
| 7593 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 7594 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 7595 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 7596 | SHOW_STR |
| 7597 | IP_STR |
| 7598 | BGP_STR |
| 7599 | "Address family\n" |
| 7600 | "Address Family modifier\n" |
| 7601 | "Address Family modifier\n" |
| 7602 | "Display only routes with non-natural netmasks\n") |
| 7603 | { |
| 7604 | if (strncmp (argv[0], "m", 1) == 0) |
| 7605 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
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 | |
| 7608 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7609 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7610 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7611 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7612 | DEFUN (show_ip_bgp_community_all, |
| 7613 | show_ip_bgp_community_all_cmd, |
| 7614 | "show ip bgp community", |
| 7615 | SHOW_STR |
| 7616 | IP_STR |
| 7617 | BGP_STR |
| 7618 | "Display routes matching the communities\n") |
| 7619 | { |
| 7620 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7621 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7622 | } |
| 7623 | |
| 7624 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 7625 | show_ip_bgp_ipv4_community_all_cmd, |
| 7626 | "show ip bgp ipv4 (unicast|multicast) community", |
| 7627 | SHOW_STR |
| 7628 | IP_STR |
| 7629 | BGP_STR |
| 7630 | "Address family\n" |
| 7631 | "Address Family modifier\n" |
| 7632 | "Address Family modifier\n" |
| 7633 | "Display routes matching the communities\n") |
| 7634 | { |
| 7635 | if (strncmp (argv[0], "m", 1) == 0) |
| 7636 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
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 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7640 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7641 | } |
| 7642 | |
| 7643 | #ifdef HAVE_IPV6 |
| 7644 | DEFUN (show_bgp_community_all, |
| 7645 | show_bgp_community_all_cmd, |
| 7646 | "show bgp community", |
| 7647 | SHOW_STR |
| 7648 | BGP_STR |
| 7649 | "Display routes matching the communities\n") |
| 7650 | { |
| 7651 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7652 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7653 | } |
| 7654 | |
| 7655 | ALIAS (show_bgp_community_all, |
| 7656 | show_bgp_ipv6_community_all_cmd, |
| 7657 | "show bgp ipv6 community", |
| 7658 | SHOW_STR |
| 7659 | BGP_STR |
| 7660 | "Address family\n" |
| 7661 | "Display routes matching the communities\n") |
| 7662 | |
| 7663 | /* old command */ |
| 7664 | DEFUN (show_ipv6_bgp_community_all, |
| 7665 | show_ipv6_bgp_community_all_cmd, |
| 7666 | "show ipv6 bgp community", |
| 7667 | SHOW_STR |
| 7668 | IPV6_STR |
| 7669 | BGP_STR |
| 7670 | "Display routes matching the communities\n") |
| 7671 | { |
| 7672 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7673 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7674 | } |
| 7675 | |
| 7676 | /* old command */ |
| 7677 | DEFUN (show_ipv6_mbgp_community_all, |
| 7678 | show_ipv6_mbgp_community_all_cmd, |
| 7679 | "show ipv6 mbgp community", |
| 7680 | SHOW_STR |
| 7681 | IPV6_STR |
| 7682 | MBGP_STR |
| 7683 | "Display routes matching the communities\n") |
| 7684 | { |
| 7685 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7686 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7687 | } |
| 7688 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7689 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7690 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7691 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 7692 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7693 | { |
| 7694 | struct community *com; |
| 7695 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7696 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7697 | int i; |
| 7698 | char *str; |
| 7699 | int first = 0; |
| 7700 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7701 | /* BGP structure lookup */ |
| 7702 | if (view_name) |
| 7703 | { |
| 7704 | bgp = bgp_lookup_by_name (view_name); |
| 7705 | if (bgp == NULL) |
| 7706 | { |
| 7707 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 7708 | return CMD_WARNING; |
| 7709 | } |
| 7710 | } |
| 7711 | else |
| 7712 | { |
| 7713 | bgp = bgp_get_default (); |
| 7714 | if (bgp == NULL) |
| 7715 | { |
| 7716 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 7717 | return CMD_WARNING; |
| 7718 | } |
| 7719 | } |
| 7720 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7721 | b = buffer_new (1024); |
| 7722 | for (i = 0; i < argc; i++) |
| 7723 | { |
| 7724 | if (first) |
| 7725 | buffer_putc (b, ' '); |
| 7726 | else |
| 7727 | { |
| 7728 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7729 | continue; |
| 7730 | first = 1; |
| 7731 | } |
| 7732 | |
| 7733 | buffer_putstr (b, argv[i]); |
| 7734 | } |
| 7735 | buffer_putc (b, '\0'); |
| 7736 | |
| 7737 | str = buffer_getstr (b); |
| 7738 | buffer_free (b); |
| 7739 | |
| 7740 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7741 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7742 | if (! com) |
| 7743 | { |
| 7744 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 7745 | return CMD_WARNING; |
| 7746 | } |
| 7747 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7748 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7749 | (exact ? bgp_show_type_community_exact : |
| 7750 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7751 | } |
| 7752 | |
| 7753 | DEFUN (show_ip_bgp_community, |
| 7754 | show_ip_bgp_community_cmd, |
| 7755 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7756 | SHOW_STR |
| 7757 | IP_STR |
| 7758 | BGP_STR |
| 7759 | "Display routes matching the communities\n" |
| 7760 | "community number\n" |
| 7761 | "Do not send outside local AS (well-known community)\n" |
| 7762 | "Do not advertise to any peer (well-known community)\n" |
| 7763 | "Do not export to next AS (well-known community)\n") |
| 7764 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7765 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7766 | } |
| 7767 | |
| 7768 | ALIAS (show_ip_bgp_community, |
| 7769 | show_ip_bgp_community2_cmd, |
| 7770 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7771 | SHOW_STR |
| 7772 | IP_STR |
| 7773 | BGP_STR |
| 7774 | "Display routes matching the communities\n" |
| 7775 | "community number\n" |
| 7776 | "Do not send outside local AS (well-known community)\n" |
| 7777 | "Do not advertise to any peer (well-known community)\n" |
| 7778 | "Do not export to next AS (well-known community)\n" |
| 7779 | "community number\n" |
| 7780 | "Do not send outside local AS (well-known community)\n" |
| 7781 | "Do not advertise to any peer (well-known community)\n" |
| 7782 | "Do not export to next AS (well-known community)\n") |
| 7783 | |
| 7784 | ALIAS (show_ip_bgp_community, |
| 7785 | show_ip_bgp_community3_cmd, |
| 7786 | "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)", |
| 7787 | SHOW_STR |
| 7788 | IP_STR |
| 7789 | BGP_STR |
| 7790 | "Display routes matching the communities\n" |
| 7791 | "community number\n" |
| 7792 | "Do not send outside local AS (well-known community)\n" |
| 7793 | "Do not advertise to any peer (well-known community)\n" |
| 7794 | "Do not export to next AS (well-known community)\n" |
| 7795 | "community number\n" |
| 7796 | "Do not send outside local AS (well-known community)\n" |
| 7797 | "Do not advertise to any peer (well-known community)\n" |
| 7798 | "Do not export to next AS (well-known community)\n" |
| 7799 | "community number\n" |
| 7800 | "Do not send outside local AS (well-known community)\n" |
| 7801 | "Do not advertise to any peer (well-known community)\n" |
| 7802 | "Do not export to next AS (well-known community)\n") |
| 7803 | |
| 7804 | ALIAS (show_ip_bgp_community, |
| 7805 | show_ip_bgp_community4_cmd, |
| 7806 | "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)", |
| 7807 | SHOW_STR |
| 7808 | IP_STR |
| 7809 | BGP_STR |
| 7810 | "Display routes matching the communities\n" |
| 7811 | "community number\n" |
| 7812 | "Do not send outside local AS (well-known community)\n" |
| 7813 | "Do not advertise to any peer (well-known community)\n" |
| 7814 | "Do not export to next AS (well-known community)\n" |
| 7815 | "community number\n" |
| 7816 | "Do not send outside local AS (well-known community)\n" |
| 7817 | "Do not advertise to any peer (well-known community)\n" |
| 7818 | "Do not export to next AS (well-known community)\n" |
| 7819 | "community number\n" |
| 7820 | "Do not send outside local AS (well-known community)\n" |
| 7821 | "Do not advertise to any peer (well-known community)\n" |
| 7822 | "Do not export to next AS (well-known community)\n" |
| 7823 | "community number\n" |
| 7824 | "Do not send outside local AS (well-known community)\n" |
| 7825 | "Do not advertise to any peer (well-known community)\n" |
| 7826 | "Do not export to next AS (well-known community)\n") |
| 7827 | |
| 7828 | DEFUN (show_ip_bgp_ipv4_community, |
| 7829 | show_ip_bgp_ipv4_community_cmd, |
| 7830 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7831 | SHOW_STR |
| 7832 | IP_STR |
| 7833 | BGP_STR |
| 7834 | "Address family\n" |
| 7835 | "Address Family modifier\n" |
| 7836 | "Address Family modifier\n" |
| 7837 | "Display routes matching the communities\n" |
| 7838 | "community number\n" |
| 7839 | "Do not send outside local AS (well-known community)\n" |
| 7840 | "Do not advertise to any peer (well-known community)\n" |
| 7841 | "Do not export to next AS (well-known community)\n") |
| 7842 | { |
| 7843 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7844 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7845 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7846 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7847 | } |
| 7848 | |
| 7849 | ALIAS (show_ip_bgp_ipv4_community, |
| 7850 | show_ip_bgp_ipv4_community2_cmd, |
| 7851 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7852 | SHOW_STR |
| 7853 | IP_STR |
| 7854 | BGP_STR |
| 7855 | "Address family\n" |
| 7856 | "Address Family modifier\n" |
| 7857 | "Address Family modifier\n" |
| 7858 | "Display routes matching the communities\n" |
| 7859 | "community number\n" |
| 7860 | "Do not send outside local AS (well-known community)\n" |
| 7861 | "Do not advertise to any peer (well-known community)\n" |
| 7862 | "Do not export to next AS (well-known community)\n" |
| 7863 | "community number\n" |
| 7864 | "Do not send outside local AS (well-known community)\n" |
| 7865 | "Do not advertise to any peer (well-known community)\n" |
| 7866 | "Do not export to next AS (well-known community)\n") |
| 7867 | |
| 7868 | ALIAS (show_ip_bgp_ipv4_community, |
| 7869 | show_ip_bgp_ipv4_community3_cmd, |
| 7870 | "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)", |
| 7871 | SHOW_STR |
| 7872 | IP_STR |
| 7873 | BGP_STR |
| 7874 | "Address family\n" |
| 7875 | "Address Family modifier\n" |
| 7876 | "Address Family modifier\n" |
| 7877 | "Display routes matching the communities\n" |
| 7878 | "community number\n" |
| 7879 | "Do not send outside local AS (well-known community)\n" |
| 7880 | "Do not advertise to any peer (well-known community)\n" |
| 7881 | "Do not export to next AS (well-known community)\n" |
| 7882 | "community number\n" |
| 7883 | "Do not send outside local AS (well-known community)\n" |
| 7884 | "Do not advertise to any peer (well-known community)\n" |
| 7885 | "Do not export to next AS (well-known community)\n" |
| 7886 | "community number\n" |
| 7887 | "Do not send outside local AS (well-known community)\n" |
| 7888 | "Do not advertise to any peer (well-known community)\n" |
| 7889 | "Do not export to next AS (well-known community)\n") |
| 7890 | |
| 7891 | ALIAS (show_ip_bgp_ipv4_community, |
| 7892 | show_ip_bgp_ipv4_community4_cmd, |
| 7893 | "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)", |
| 7894 | SHOW_STR |
| 7895 | IP_STR |
| 7896 | BGP_STR |
| 7897 | "Address family\n" |
| 7898 | "Address Family modifier\n" |
| 7899 | "Address Family modifier\n" |
| 7900 | "Display routes matching the communities\n" |
| 7901 | "community number\n" |
| 7902 | "Do not send outside local AS (well-known community)\n" |
| 7903 | "Do not advertise to any peer (well-known community)\n" |
| 7904 | "Do not export to next AS (well-known community)\n" |
| 7905 | "community number\n" |
| 7906 | "Do not send outside local AS (well-known community)\n" |
| 7907 | "Do not advertise to any peer (well-known community)\n" |
| 7908 | "Do not export to next AS (well-known community)\n" |
| 7909 | "community number\n" |
| 7910 | "Do not send outside local AS (well-known community)\n" |
| 7911 | "Do not advertise to any peer (well-known community)\n" |
| 7912 | "Do not export to next AS (well-known community)\n" |
| 7913 | "community number\n" |
| 7914 | "Do not send outside local AS (well-known community)\n" |
| 7915 | "Do not advertise to any peer (well-known community)\n" |
| 7916 | "Do not export to next AS (well-known community)\n") |
| 7917 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7918 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 7919 | show_bgp_view_afi_safi_community_all_cmd, |
| 7920 | #ifdef HAVE_IPV6 |
| 7921 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
| 7922 | #else |
| 7923 | "show bgp view WORD ipv4 (unicast|multicast) community", |
| 7924 | #endif |
| 7925 | SHOW_STR |
| 7926 | BGP_STR |
| 7927 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 7928 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7929 | "Address family\n" |
| 7930 | #ifdef HAVE_IPV6 |
| 7931 | "Address family\n" |
| 7932 | #endif |
| 7933 | "Address Family modifier\n" |
| 7934 | "Address Family modifier\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 7935 | "Display routes matching the communities\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7936 | { |
| 7937 | int afi; |
| 7938 | int safi; |
| 7939 | struct bgp *bgp; |
| 7940 | |
| 7941 | /* BGP structure lookup. */ |
| 7942 | bgp = bgp_lookup_by_name (argv[0]); |
| 7943 | if (bgp == NULL) |
| 7944 | { |
| 7945 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7946 | return CMD_WARNING; |
| 7947 | } |
| 7948 | |
| 7949 | #ifdef HAVE_IPV6 |
| 7950 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 7951 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7952 | #else |
| 7953 | afi = AFI_IP; |
| 7954 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7955 | #endif |
| 7956 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 7957 | } |
| 7958 | |
| 7959 | DEFUN (show_bgp_view_afi_safi_community, |
| 7960 | show_bgp_view_afi_safi_community_cmd, |
| 7961 | #ifdef HAVE_IPV6 |
| 7962 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7963 | #else |
| 7964 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7965 | #endif |
| 7966 | SHOW_STR |
| 7967 | BGP_STR |
| 7968 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 7969 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7970 | "Address family\n" |
| 7971 | #ifdef HAVE_IPV6 |
| 7972 | "Address family\n" |
| 7973 | #endif |
| 7974 | "Address family modifier\n" |
| 7975 | "Address family modifier\n" |
| 7976 | "Display routes matching the communities\n" |
| 7977 | "community number\n" |
| 7978 | "Do not send outside local AS (well-known community)\n" |
| 7979 | "Do not advertise to any peer (well-known community)\n" |
| 7980 | "Do not export to next AS (well-known community)\n") |
| 7981 | { |
| 7982 | int afi; |
| 7983 | int safi; |
| 7984 | |
| 7985 | #ifdef HAVE_IPV6 |
| 7986 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 7987 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7988 | return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi); |
| 7989 | #else |
| 7990 | afi = AFI_IP; |
| 7991 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 7992 | return bgp_show_community (vty, argv[0], argc-2, &argv[2], 0, afi, safi); |
| 7993 | #endif |
| 7994 | } |
| 7995 | |
| 7996 | ALIAS (show_bgp_view_afi_safi_community, |
| 7997 | show_bgp_view_afi_safi_community2_cmd, |
| 7998 | #ifdef HAVE_IPV6 |
| 7999 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8000 | #else |
| 8001 | "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8002 | #endif |
| 8003 | SHOW_STR |
| 8004 | BGP_STR |
| 8005 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8006 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8007 | "Address family\n" |
| 8008 | #ifdef HAVE_IPV6 |
| 8009 | "Address family\n" |
| 8010 | #endif |
| 8011 | "Address family modifier\n" |
| 8012 | "Address family modifier\n" |
| 8013 | "Display routes matching the communities\n" |
| 8014 | "community number\n" |
| 8015 | "Do not send outside local AS (well-known community)\n" |
| 8016 | "Do not advertise to any peer (well-known community)\n" |
| 8017 | "Do not export to next AS (well-known community)\n" |
| 8018 | "community number\n" |
| 8019 | "Do not send outside local AS (well-known community)\n" |
| 8020 | "Do not advertise to any peer (well-known community)\n" |
| 8021 | "Do not export to next AS (well-known community)\n") |
| 8022 | |
| 8023 | ALIAS (show_bgp_view_afi_safi_community, |
| 8024 | show_bgp_view_afi_safi_community3_cmd, |
| 8025 | #ifdef HAVE_IPV6 |
| 8026 | "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)", |
| 8027 | #else |
| 8028 | "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)", |
| 8029 | #endif |
| 8030 | SHOW_STR |
| 8031 | BGP_STR |
| 8032 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8033 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8034 | "Address family\n" |
| 8035 | #ifdef HAVE_IPV6 |
| 8036 | "Address family\n" |
| 8037 | #endif |
| 8038 | "Address family modifier\n" |
| 8039 | "Address family modifier\n" |
| 8040 | "Display routes matching the communities\n" |
| 8041 | "community number\n" |
| 8042 | "Do not send outside local AS (well-known community)\n" |
| 8043 | "Do not advertise to any peer (well-known community)\n" |
| 8044 | "Do not export to next AS (well-known community)\n" |
| 8045 | "community number\n" |
| 8046 | "Do not send outside local AS (well-known community)\n" |
| 8047 | "Do not advertise to any peer (well-known community)\n" |
| 8048 | "Do not export to next AS (well-known community)\n" |
| 8049 | "community number\n" |
| 8050 | "Do not send outside local AS (well-known community)\n" |
| 8051 | "Do not advertise to any peer (well-known community)\n" |
| 8052 | "Do not export to next AS (well-known community)\n") |
| 8053 | |
| 8054 | ALIAS (show_bgp_view_afi_safi_community, |
| 8055 | show_bgp_view_afi_safi_community4_cmd, |
| 8056 | #ifdef HAVE_IPV6 |
| 8057 | "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)", |
| 8058 | #else |
| 8059 | "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)", |
| 8060 | #endif |
| 8061 | SHOW_STR |
| 8062 | BGP_STR |
| 8063 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8064 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8065 | "Address family\n" |
| 8066 | #ifdef HAVE_IPV6 |
| 8067 | "Address family\n" |
| 8068 | #endif |
| 8069 | "Address family modifier\n" |
| 8070 | "Address family modifier\n" |
| 8071 | "Display routes matching the communities\n" |
| 8072 | "community number\n" |
| 8073 | "Do not send outside local AS (well-known community)\n" |
| 8074 | "Do not advertise to any peer (well-known community)\n" |
| 8075 | "Do not export to next AS (well-known community)\n" |
| 8076 | "community number\n" |
| 8077 | "Do not send outside local AS (well-known community)\n" |
| 8078 | "Do not advertise to any peer (well-known community)\n" |
| 8079 | "Do not export to next AS (well-known community)\n" |
| 8080 | "community number\n" |
| 8081 | "Do not send outside local AS (well-known community)\n" |
| 8082 | "Do not advertise to any peer (well-known community)\n" |
| 8083 | "Do not export to next AS (well-known community)\n" |
| 8084 | "community number\n" |
| 8085 | "Do not send outside local AS (well-known community)\n" |
| 8086 | "Do not advertise to any peer (well-known community)\n" |
| 8087 | "Do not export to next AS (well-known community)\n") |
| 8088 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8089 | DEFUN (show_ip_bgp_community_exact, |
| 8090 | show_ip_bgp_community_exact_cmd, |
| 8091 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8092 | SHOW_STR |
| 8093 | IP_STR |
| 8094 | BGP_STR |
| 8095 | "Display routes matching the communities\n" |
| 8096 | "community number\n" |
| 8097 | "Do not send outside local AS (well-known community)\n" |
| 8098 | "Do not advertise to any peer (well-known community)\n" |
| 8099 | "Do not export to next AS (well-known community)\n" |
| 8100 | "Exact match of the communities") |
| 8101 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8102 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8103 | } |
| 8104 | |
| 8105 | ALIAS (show_ip_bgp_community_exact, |
| 8106 | show_ip_bgp_community2_exact_cmd, |
| 8107 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8108 | SHOW_STR |
| 8109 | IP_STR |
| 8110 | BGP_STR |
| 8111 | "Display routes matching the communities\n" |
| 8112 | "community number\n" |
| 8113 | "Do not send outside local AS (well-known community)\n" |
| 8114 | "Do not advertise to any peer (well-known community)\n" |
| 8115 | "Do not export to next AS (well-known community)\n" |
| 8116 | "community number\n" |
| 8117 | "Do not send outside local AS (well-known community)\n" |
| 8118 | "Do not advertise to any peer (well-known community)\n" |
| 8119 | "Do not export to next AS (well-known community)\n" |
| 8120 | "Exact match of the communities") |
| 8121 | |
| 8122 | ALIAS (show_ip_bgp_community_exact, |
| 8123 | show_ip_bgp_community3_exact_cmd, |
| 8124 | "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", |
| 8125 | SHOW_STR |
| 8126 | IP_STR |
| 8127 | BGP_STR |
| 8128 | "Display routes matching the communities\n" |
| 8129 | "community number\n" |
| 8130 | "Do not send outside local AS (well-known community)\n" |
| 8131 | "Do not advertise to any peer (well-known community)\n" |
| 8132 | "Do not export to next AS (well-known community)\n" |
| 8133 | "community number\n" |
| 8134 | "Do not send outside local AS (well-known community)\n" |
| 8135 | "Do not advertise to any peer (well-known community)\n" |
| 8136 | "Do not export to next AS (well-known community)\n" |
| 8137 | "community number\n" |
| 8138 | "Do not send outside local AS (well-known community)\n" |
| 8139 | "Do not advertise to any peer (well-known community)\n" |
| 8140 | "Do not export to next AS (well-known community)\n" |
| 8141 | "Exact match of the communities") |
| 8142 | |
| 8143 | ALIAS (show_ip_bgp_community_exact, |
| 8144 | show_ip_bgp_community4_exact_cmd, |
| 8145 | "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", |
| 8146 | SHOW_STR |
| 8147 | IP_STR |
| 8148 | BGP_STR |
| 8149 | "Display routes matching the communities\n" |
| 8150 | "community number\n" |
| 8151 | "Do not send outside local AS (well-known community)\n" |
| 8152 | "Do not advertise to any peer (well-known community)\n" |
| 8153 | "Do not export to next AS (well-known community)\n" |
| 8154 | "community number\n" |
| 8155 | "Do not send outside local AS (well-known community)\n" |
| 8156 | "Do not advertise to any peer (well-known community)\n" |
| 8157 | "Do not export to next AS (well-known community)\n" |
| 8158 | "community number\n" |
| 8159 | "Do not send outside local AS (well-known community)\n" |
| 8160 | "Do not advertise to any peer (well-known community)\n" |
| 8161 | "Do not export to next AS (well-known community)\n" |
| 8162 | "community number\n" |
| 8163 | "Do not send outside local AS (well-known community)\n" |
| 8164 | "Do not advertise to any peer (well-known community)\n" |
| 8165 | "Do not export to next AS (well-known community)\n" |
| 8166 | "Exact match of the communities") |
| 8167 | |
| 8168 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 8169 | show_ip_bgp_ipv4_community_exact_cmd, |
| 8170 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8171 | SHOW_STR |
| 8172 | IP_STR |
| 8173 | BGP_STR |
| 8174 | "Address family\n" |
| 8175 | "Address Family modifier\n" |
| 8176 | "Address Family modifier\n" |
| 8177 | "Display routes matching the communities\n" |
| 8178 | "community number\n" |
| 8179 | "Do not send outside local AS (well-known community)\n" |
| 8180 | "Do not advertise to any peer (well-known community)\n" |
| 8181 | "Do not export to next AS (well-known community)\n" |
| 8182 | "Exact match of the communities") |
| 8183 | { |
| 8184 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8185 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8186 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8187 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8188 | } |
| 8189 | |
| 8190 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8191 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 8192 | "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", |
| 8193 | SHOW_STR |
| 8194 | IP_STR |
| 8195 | BGP_STR |
| 8196 | "Address family\n" |
| 8197 | "Address Family modifier\n" |
| 8198 | "Address Family modifier\n" |
| 8199 | "Display routes matching the communities\n" |
| 8200 | "community number\n" |
| 8201 | "Do not send outside local AS (well-known community)\n" |
| 8202 | "Do not advertise to any peer (well-known community)\n" |
| 8203 | "Do not export to next AS (well-known community)\n" |
| 8204 | "community number\n" |
| 8205 | "Do not send outside local AS (well-known community)\n" |
| 8206 | "Do not advertise to any peer (well-known community)\n" |
| 8207 | "Do not export to next AS (well-known community)\n" |
| 8208 | "Exact match of the communities") |
| 8209 | |
| 8210 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8211 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 8212 | "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", |
| 8213 | SHOW_STR |
| 8214 | IP_STR |
| 8215 | BGP_STR |
| 8216 | "Address family\n" |
| 8217 | "Address Family modifier\n" |
| 8218 | "Address Family modifier\n" |
| 8219 | "Display routes matching the communities\n" |
| 8220 | "community number\n" |
| 8221 | "Do not send outside local AS (well-known community)\n" |
| 8222 | "Do not advertise to any peer (well-known community)\n" |
| 8223 | "Do not export to next AS (well-known community)\n" |
| 8224 | "community number\n" |
| 8225 | "Do not send outside local AS (well-known community)\n" |
| 8226 | "Do not advertise to any peer (well-known community)\n" |
| 8227 | "Do not export to next AS (well-known community)\n" |
| 8228 | "community number\n" |
| 8229 | "Do not send outside local AS (well-known community)\n" |
| 8230 | "Do not advertise to any peer (well-known community)\n" |
| 8231 | "Do not export to next AS (well-known community)\n" |
| 8232 | "Exact match of the communities") |
| 8233 | |
| 8234 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8235 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 8236 | "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", |
| 8237 | SHOW_STR |
| 8238 | IP_STR |
| 8239 | BGP_STR |
| 8240 | "Address family\n" |
| 8241 | "Address Family modifier\n" |
| 8242 | "Address Family modifier\n" |
| 8243 | "Display routes matching the communities\n" |
| 8244 | "community number\n" |
| 8245 | "Do not send outside local AS (well-known community)\n" |
| 8246 | "Do not advertise to any peer (well-known community)\n" |
| 8247 | "Do not export to next AS (well-known community)\n" |
| 8248 | "community number\n" |
| 8249 | "Do not send outside local AS (well-known community)\n" |
| 8250 | "Do not advertise to any peer (well-known community)\n" |
| 8251 | "Do not export to next AS (well-known community)\n" |
| 8252 | "community number\n" |
| 8253 | "Do not send outside local AS (well-known community)\n" |
| 8254 | "Do not advertise to any peer (well-known community)\n" |
| 8255 | "Do not export to next AS (well-known community)\n" |
| 8256 | "community number\n" |
| 8257 | "Do not send outside local AS (well-known community)\n" |
| 8258 | "Do not advertise to any peer (well-known community)\n" |
| 8259 | "Do not export to next AS (well-known community)\n" |
| 8260 | "Exact match of the communities") |
| 8261 | |
| 8262 | #ifdef HAVE_IPV6 |
| 8263 | DEFUN (show_bgp_community, |
| 8264 | show_bgp_community_cmd, |
| 8265 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8266 | SHOW_STR |
| 8267 | BGP_STR |
| 8268 | "Display routes matching the communities\n" |
| 8269 | "community number\n" |
| 8270 | "Do not send outside local AS (well-known community)\n" |
| 8271 | "Do not advertise to any peer (well-known community)\n" |
| 8272 | "Do not export to next AS (well-known community)\n") |
| 8273 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8274 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8275 | } |
| 8276 | |
| 8277 | ALIAS (show_bgp_community, |
| 8278 | show_bgp_ipv6_community_cmd, |
| 8279 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 8280 | SHOW_STR |
| 8281 | BGP_STR |
| 8282 | "Address family\n" |
| 8283 | "Display routes matching the communities\n" |
| 8284 | "community number\n" |
| 8285 | "Do not send outside local AS (well-known community)\n" |
| 8286 | "Do not advertise to any peer (well-known community)\n" |
| 8287 | "Do not export to next AS (well-known community)\n") |
| 8288 | |
| 8289 | ALIAS (show_bgp_community, |
| 8290 | show_bgp_community2_cmd, |
| 8291 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8292 | SHOW_STR |
| 8293 | BGP_STR |
| 8294 | "Display routes matching the communities\n" |
| 8295 | "community number\n" |
| 8296 | "Do not send outside local AS (well-known community)\n" |
| 8297 | "Do not advertise to any peer (well-known community)\n" |
| 8298 | "Do not export to next AS (well-known community)\n" |
| 8299 | "community number\n" |
| 8300 | "Do not send outside local AS (well-known community)\n" |
| 8301 | "Do not advertise to any peer (well-known community)\n" |
| 8302 | "Do not export to next AS (well-known community)\n") |
| 8303 | |
| 8304 | ALIAS (show_bgp_community, |
| 8305 | show_bgp_ipv6_community2_cmd, |
| 8306 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8307 | SHOW_STR |
| 8308 | BGP_STR |
| 8309 | "Address family\n" |
| 8310 | "Display routes matching the communities\n" |
| 8311 | "community number\n" |
| 8312 | "Do not send outside local AS (well-known community)\n" |
| 8313 | "Do not advertise to any peer (well-known community)\n" |
| 8314 | "Do not export to next AS (well-known community)\n" |
| 8315 | "community number\n" |
| 8316 | "Do not send outside local AS (well-known community)\n" |
| 8317 | "Do not advertise to any peer (well-known community)\n" |
| 8318 | "Do not export to next AS (well-known community)\n") |
| 8319 | |
| 8320 | ALIAS (show_bgp_community, |
| 8321 | show_bgp_community3_cmd, |
| 8322 | "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)", |
| 8323 | SHOW_STR |
| 8324 | BGP_STR |
| 8325 | "Display routes matching the communities\n" |
| 8326 | "community number\n" |
| 8327 | "Do not send outside local AS (well-known community)\n" |
| 8328 | "Do not advertise to any peer (well-known community)\n" |
| 8329 | "Do not export to next AS (well-known community)\n" |
| 8330 | "community number\n" |
| 8331 | "Do not send outside local AS (well-known community)\n" |
| 8332 | "Do not advertise to any peer (well-known community)\n" |
| 8333 | "Do not export to next AS (well-known community)\n" |
| 8334 | "community number\n" |
| 8335 | "Do not send outside local AS (well-known community)\n" |
| 8336 | "Do not advertise to any peer (well-known community)\n" |
| 8337 | "Do not export to next AS (well-known community)\n") |
| 8338 | |
| 8339 | ALIAS (show_bgp_community, |
| 8340 | show_bgp_ipv6_community3_cmd, |
| 8341 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8342 | SHOW_STR |
| 8343 | BGP_STR |
| 8344 | "Address family\n" |
| 8345 | "Display routes matching the communities\n" |
| 8346 | "community number\n" |
| 8347 | "Do not send outside local AS (well-known community)\n" |
| 8348 | "Do not advertise to any peer (well-known community)\n" |
| 8349 | "Do not export to next AS (well-known community)\n" |
| 8350 | "community number\n" |
| 8351 | "Do not send outside local AS (well-known community)\n" |
| 8352 | "Do not advertise to any peer (well-known community)\n" |
| 8353 | "Do not export to next AS (well-known community)\n" |
| 8354 | "community number\n" |
| 8355 | "Do not send outside local AS (well-known community)\n" |
| 8356 | "Do not advertise to any peer (well-known community)\n" |
| 8357 | "Do not export to next AS (well-known community)\n") |
| 8358 | |
| 8359 | ALIAS (show_bgp_community, |
| 8360 | show_bgp_community4_cmd, |
| 8361 | "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)", |
| 8362 | SHOW_STR |
| 8363 | BGP_STR |
| 8364 | "Display routes matching the communities\n" |
| 8365 | "community number\n" |
| 8366 | "Do not send outside local AS (well-known community)\n" |
| 8367 | "Do not advertise to any peer (well-known community)\n" |
| 8368 | "Do not export to next AS (well-known community)\n" |
| 8369 | "community number\n" |
| 8370 | "Do not send outside local AS (well-known community)\n" |
| 8371 | "Do not advertise to any peer (well-known community)\n" |
| 8372 | "Do not export to next AS (well-known community)\n" |
| 8373 | "community number\n" |
| 8374 | "Do not send outside local AS (well-known community)\n" |
| 8375 | "Do not advertise to any peer (well-known community)\n" |
| 8376 | "Do not export to next AS (well-known community)\n" |
| 8377 | "community number\n" |
| 8378 | "Do not send outside local AS (well-known community)\n" |
| 8379 | "Do not advertise to any peer (well-known community)\n" |
| 8380 | "Do not export to next AS (well-known community)\n") |
| 8381 | |
| 8382 | ALIAS (show_bgp_community, |
| 8383 | show_bgp_ipv6_community4_cmd, |
| 8384 | "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)", |
| 8385 | SHOW_STR |
| 8386 | BGP_STR |
| 8387 | "Address family\n" |
| 8388 | "Display routes matching the communities\n" |
| 8389 | "community number\n" |
| 8390 | "Do not send outside local AS (well-known community)\n" |
| 8391 | "Do not advertise to any peer (well-known community)\n" |
| 8392 | "Do not export to next AS (well-known community)\n" |
| 8393 | "community number\n" |
| 8394 | "Do not send outside local AS (well-known community)\n" |
| 8395 | "Do not advertise to any peer (well-known community)\n" |
| 8396 | "Do not export to next AS (well-known community)\n" |
| 8397 | "community number\n" |
| 8398 | "Do not send outside local AS (well-known community)\n" |
| 8399 | "Do not advertise to any peer (well-known community)\n" |
| 8400 | "Do not export to next AS (well-known community)\n" |
| 8401 | "community number\n" |
| 8402 | "Do not send outside local AS (well-known community)\n" |
| 8403 | "Do not advertise to any peer (well-known community)\n" |
| 8404 | "Do not export to next AS (well-known community)\n") |
| 8405 | |
| 8406 | /* old command */ |
| 8407 | DEFUN (show_ipv6_bgp_community, |
| 8408 | show_ipv6_bgp_community_cmd, |
| 8409 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8410 | SHOW_STR |
| 8411 | IPV6_STR |
| 8412 | BGP_STR |
| 8413 | "Display routes matching the communities\n" |
| 8414 | "community number\n" |
| 8415 | "Do not send outside local AS (well-known community)\n" |
| 8416 | "Do not advertise to any peer (well-known community)\n" |
| 8417 | "Do not export to next AS (well-known community)\n") |
| 8418 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8419 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8420 | } |
| 8421 | |
| 8422 | /* old command */ |
| 8423 | ALIAS (show_ipv6_bgp_community, |
| 8424 | show_ipv6_bgp_community2_cmd, |
| 8425 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8426 | SHOW_STR |
| 8427 | IPV6_STR |
| 8428 | BGP_STR |
| 8429 | "Display routes matching the communities\n" |
| 8430 | "community number\n" |
| 8431 | "Do not send outside local AS (well-known community)\n" |
| 8432 | "Do not advertise to any peer (well-known community)\n" |
| 8433 | "Do not export to next AS (well-known community)\n" |
| 8434 | "community number\n" |
| 8435 | "Do not send outside local AS (well-known community)\n" |
| 8436 | "Do not advertise to any peer (well-known community)\n" |
| 8437 | "Do not export to next AS (well-known community)\n") |
| 8438 | |
| 8439 | /* old command */ |
| 8440 | ALIAS (show_ipv6_bgp_community, |
| 8441 | show_ipv6_bgp_community3_cmd, |
| 8442 | "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)", |
| 8443 | SHOW_STR |
| 8444 | IPV6_STR |
| 8445 | BGP_STR |
| 8446 | "Display routes matching the communities\n" |
| 8447 | "community number\n" |
| 8448 | "Do not send outside local AS (well-known community)\n" |
| 8449 | "Do not advertise to any peer (well-known community)\n" |
| 8450 | "Do not export to next AS (well-known community)\n" |
| 8451 | "community number\n" |
| 8452 | "Do not send outside local AS (well-known community)\n" |
| 8453 | "Do not advertise to any peer (well-known community)\n" |
| 8454 | "Do not export to next AS (well-known community)\n" |
| 8455 | "community number\n" |
| 8456 | "Do not send outside local AS (well-known community)\n" |
| 8457 | "Do not advertise to any peer (well-known community)\n" |
| 8458 | "Do not export to next AS (well-known community)\n") |
| 8459 | |
| 8460 | /* old command */ |
| 8461 | ALIAS (show_ipv6_bgp_community, |
| 8462 | show_ipv6_bgp_community4_cmd, |
| 8463 | "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)", |
| 8464 | SHOW_STR |
| 8465 | IPV6_STR |
| 8466 | BGP_STR |
| 8467 | "Display routes matching the communities\n" |
| 8468 | "community number\n" |
| 8469 | "Do not send outside local AS (well-known community)\n" |
| 8470 | "Do not advertise to any peer (well-known community)\n" |
| 8471 | "Do not export to next AS (well-known community)\n" |
| 8472 | "community number\n" |
| 8473 | "Do not send outside local AS (well-known community)\n" |
| 8474 | "Do not advertise to any peer (well-known community)\n" |
| 8475 | "Do not export to next AS (well-known community)\n" |
| 8476 | "community number\n" |
| 8477 | "Do not send outside local AS (well-known community)\n" |
| 8478 | "Do not advertise to any peer (well-known community)\n" |
| 8479 | "Do not export to next AS (well-known community)\n" |
| 8480 | "community number\n" |
| 8481 | "Do not send outside local AS (well-known community)\n" |
| 8482 | "Do not advertise to any peer (well-known community)\n" |
| 8483 | "Do not export to next AS (well-known community)\n") |
| 8484 | |
| 8485 | DEFUN (show_bgp_community_exact, |
| 8486 | show_bgp_community_exact_cmd, |
| 8487 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8488 | SHOW_STR |
| 8489 | BGP_STR |
| 8490 | "Display routes matching the communities\n" |
| 8491 | "community number\n" |
| 8492 | "Do not send outside local AS (well-known community)\n" |
| 8493 | "Do not advertise to any peer (well-known community)\n" |
| 8494 | "Do not export to next AS (well-known community)\n" |
| 8495 | "Exact match of the communities") |
| 8496 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8497 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8498 | } |
| 8499 | |
| 8500 | ALIAS (show_bgp_community_exact, |
| 8501 | show_bgp_ipv6_community_exact_cmd, |
| 8502 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8503 | SHOW_STR |
| 8504 | BGP_STR |
| 8505 | "Address family\n" |
| 8506 | "Display routes matching the communities\n" |
| 8507 | "community number\n" |
| 8508 | "Do not send outside local AS (well-known community)\n" |
| 8509 | "Do not advertise to any peer (well-known community)\n" |
| 8510 | "Do not export to next AS (well-known community)\n" |
| 8511 | "Exact match of the communities") |
| 8512 | |
| 8513 | ALIAS (show_bgp_community_exact, |
| 8514 | show_bgp_community2_exact_cmd, |
| 8515 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8516 | SHOW_STR |
| 8517 | BGP_STR |
| 8518 | "Display routes matching the communities\n" |
| 8519 | "community number\n" |
| 8520 | "Do not send outside local AS (well-known community)\n" |
| 8521 | "Do not advertise to any peer (well-known community)\n" |
| 8522 | "Do not export to next AS (well-known community)\n" |
| 8523 | "community number\n" |
| 8524 | "Do not send outside local AS (well-known community)\n" |
| 8525 | "Do not advertise to any peer (well-known community)\n" |
| 8526 | "Do not export to next AS (well-known community)\n" |
| 8527 | "Exact match of the communities") |
| 8528 | |
| 8529 | ALIAS (show_bgp_community_exact, |
| 8530 | show_bgp_ipv6_community2_exact_cmd, |
| 8531 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8532 | SHOW_STR |
| 8533 | BGP_STR |
| 8534 | "Address family\n" |
| 8535 | "Display routes matching the communities\n" |
| 8536 | "community number\n" |
| 8537 | "Do not send outside local AS (well-known community)\n" |
| 8538 | "Do not advertise to any peer (well-known community)\n" |
| 8539 | "Do not export to next AS (well-known community)\n" |
| 8540 | "community number\n" |
| 8541 | "Do not send outside local AS (well-known community)\n" |
| 8542 | "Do not advertise to any peer (well-known community)\n" |
| 8543 | "Do not export to next AS (well-known community)\n" |
| 8544 | "Exact match of the communities") |
| 8545 | |
| 8546 | ALIAS (show_bgp_community_exact, |
| 8547 | show_bgp_community3_exact_cmd, |
| 8548 | "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", |
| 8549 | SHOW_STR |
| 8550 | BGP_STR |
| 8551 | "Display routes matching the communities\n" |
| 8552 | "community number\n" |
| 8553 | "Do not send outside local AS (well-known community)\n" |
| 8554 | "Do not advertise to any peer (well-known community)\n" |
| 8555 | "Do not export to next AS (well-known community)\n" |
| 8556 | "community number\n" |
| 8557 | "Do not send outside local AS (well-known community)\n" |
| 8558 | "Do not advertise to any peer (well-known community)\n" |
| 8559 | "Do not export to next AS (well-known community)\n" |
| 8560 | "community number\n" |
| 8561 | "Do not send outside local AS (well-known community)\n" |
| 8562 | "Do not advertise to any peer (well-known community)\n" |
| 8563 | "Do not export to next AS (well-known community)\n" |
| 8564 | "Exact match of the communities") |
| 8565 | |
| 8566 | ALIAS (show_bgp_community_exact, |
| 8567 | show_bgp_ipv6_community3_exact_cmd, |
| 8568 | "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", |
| 8569 | SHOW_STR |
| 8570 | BGP_STR |
| 8571 | "Address family\n" |
| 8572 | "Display routes matching the communities\n" |
| 8573 | "community number\n" |
| 8574 | "Do not send outside local AS (well-known community)\n" |
| 8575 | "Do not advertise to any peer (well-known community)\n" |
| 8576 | "Do not export to next AS (well-known community)\n" |
| 8577 | "community number\n" |
| 8578 | "Do not send outside local AS (well-known community)\n" |
| 8579 | "Do not advertise to any peer (well-known community)\n" |
| 8580 | "Do not export to next AS (well-known community)\n" |
| 8581 | "community number\n" |
| 8582 | "Do not send outside local AS (well-known community)\n" |
| 8583 | "Do not advertise to any peer (well-known community)\n" |
| 8584 | "Do not export to next AS (well-known community)\n" |
| 8585 | "Exact match of the communities") |
| 8586 | |
| 8587 | ALIAS (show_bgp_community_exact, |
| 8588 | show_bgp_community4_exact_cmd, |
| 8589 | "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", |
| 8590 | SHOW_STR |
| 8591 | BGP_STR |
| 8592 | "Display routes matching the communities\n" |
| 8593 | "community number\n" |
| 8594 | "Do not send outside local AS (well-known community)\n" |
| 8595 | "Do not advertise to any peer (well-known community)\n" |
| 8596 | "Do not export to next AS (well-known community)\n" |
| 8597 | "community number\n" |
| 8598 | "Do not send outside local AS (well-known community)\n" |
| 8599 | "Do not advertise to any peer (well-known community)\n" |
| 8600 | "Do not export to next AS (well-known community)\n" |
| 8601 | "community number\n" |
| 8602 | "Do not send outside local AS (well-known community)\n" |
| 8603 | "Do not advertise to any peer (well-known community)\n" |
| 8604 | "Do not export to next AS (well-known community)\n" |
| 8605 | "community number\n" |
| 8606 | "Do not send outside local AS (well-known community)\n" |
| 8607 | "Do not advertise to any peer (well-known community)\n" |
| 8608 | "Do not export to next AS (well-known community)\n" |
| 8609 | "Exact match of the communities") |
| 8610 | |
| 8611 | ALIAS (show_bgp_community_exact, |
| 8612 | show_bgp_ipv6_community4_exact_cmd, |
| 8613 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8614 | SHOW_STR |
| 8615 | BGP_STR |
| 8616 | "Address family\n" |
| 8617 | "Display routes matching the communities\n" |
| 8618 | "community number\n" |
| 8619 | "Do not send outside local AS (well-known community)\n" |
| 8620 | "Do not advertise to any peer (well-known community)\n" |
| 8621 | "Do not export to next AS (well-known community)\n" |
| 8622 | "community number\n" |
| 8623 | "Do not send outside local AS (well-known community)\n" |
| 8624 | "Do not advertise to any peer (well-known community)\n" |
| 8625 | "Do not export to next AS (well-known community)\n" |
| 8626 | "community number\n" |
| 8627 | "Do not send outside local AS (well-known community)\n" |
| 8628 | "Do not advertise to any peer (well-known community)\n" |
| 8629 | "Do not export to next AS (well-known community)\n" |
| 8630 | "community number\n" |
| 8631 | "Do not send outside local AS (well-known community)\n" |
| 8632 | "Do not advertise to any peer (well-known community)\n" |
| 8633 | "Do not export to next AS (well-known community)\n" |
| 8634 | "Exact match of the communities") |
| 8635 | |
| 8636 | /* old command */ |
| 8637 | DEFUN (show_ipv6_bgp_community_exact, |
| 8638 | show_ipv6_bgp_community_exact_cmd, |
| 8639 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8640 | SHOW_STR |
| 8641 | IPV6_STR |
| 8642 | BGP_STR |
| 8643 | "Display routes matching the communities\n" |
| 8644 | "community number\n" |
| 8645 | "Do not send outside local AS (well-known community)\n" |
| 8646 | "Do not advertise to any peer (well-known community)\n" |
| 8647 | "Do not export to next AS (well-known community)\n" |
| 8648 | "Exact match of the communities") |
| 8649 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8650 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8651 | } |
| 8652 | |
| 8653 | /* old command */ |
| 8654 | ALIAS (show_ipv6_bgp_community_exact, |
| 8655 | show_ipv6_bgp_community2_exact_cmd, |
| 8656 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8657 | SHOW_STR |
| 8658 | IPV6_STR |
| 8659 | BGP_STR |
| 8660 | "Display routes matching the communities\n" |
| 8661 | "community number\n" |
| 8662 | "Do not send outside local AS (well-known community)\n" |
| 8663 | "Do not advertise to any peer (well-known community)\n" |
| 8664 | "Do not export to next AS (well-known community)\n" |
| 8665 | "community number\n" |
| 8666 | "Do not send outside local AS (well-known community)\n" |
| 8667 | "Do not advertise to any peer (well-known community)\n" |
| 8668 | "Do not export to next AS (well-known community)\n" |
| 8669 | "Exact match of the communities") |
| 8670 | |
| 8671 | /* old command */ |
| 8672 | ALIAS (show_ipv6_bgp_community_exact, |
| 8673 | show_ipv6_bgp_community3_exact_cmd, |
| 8674 | "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", |
| 8675 | SHOW_STR |
| 8676 | IPV6_STR |
| 8677 | BGP_STR |
| 8678 | "Display routes matching the communities\n" |
| 8679 | "community number\n" |
| 8680 | "Do not send outside local AS (well-known community)\n" |
| 8681 | "Do not advertise to any peer (well-known community)\n" |
| 8682 | "Do not export to next AS (well-known community)\n" |
| 8683 | "community number\n" |
| 8684 | "Do not send outside local AS (well-known community)\n" |
| 8685 | "Do not advertise to any peer (well-known community)\n" |
| 8686 | "Do not export to next AS (well-known community)\n" |
| 8687 | "community number\n" |
| 8688 | "Do not send outside local AS (well-known community)\n" |
| 8689 | "Do not advertise to any peer (well-known community)\n" |
| 8690 | "Do not export to next AS (well-known community)\n" |
| 8691 | "Exact match of the communities") |
| 8692 | |
| 8693 | /* old command */ |
| 8694 | ALIAS (show_ipv6_bgp_community_exact, |
| 8695 | show_ipv6_bgp_community4_exact_cmd, |
| 8696 | "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", |
| 8697 | SHOW_STR |
| 8698 | IPV6_STR |
| 8699 | BGP_STR |
| 8700 | "Display routes matching the communities\n" |
| 8701 | "community number\n" |
| 8702 | "Do not send outside local AS (well-known community)\n" |
| 8703 | "Do not advertise to any peer (well-known community)\n" |
| 8704 | "Do not export to next AS (well-known community)\n" |
| 8705 | "community number\n" |
| 8706 | "Do not send outside local AS (well-known community)\n" |
| 8707 | "Do not advertise to any peer (well-known community)\n" |
| 8708 | "Do not export to next AS (well-known community)\n" |
| 8709 | "community number\n" |
| 8710 | "Do not send outside local AS (well-known community)\n" |
| 8711 | "Do not advertise to any peer (well-known community)\n" |
| 8712 | "Do not export to next AS (well-known community)\n" |
| 8713 | "community number\n" |
| 8714 | "Do not send outside local AS (well-known community)\n" |
| 8715 | "Do not advertise to any peer (well-known community)\n" |
| 8716 | "Do not export to next AS (well-known community)\n" |
| 8717 | "Exact match of the communities") |
| 8718 | |
| 8719 | /* old command */ |
| 8720 | DEFUN (show_ipv6_mbgp_community, |
| 8721 | show_ipv6_mbgp_community_cmd, |
| 8722 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8723 | SHOW_STR |
| 8724 | IPV6_STR |
| 8725 | MBGP_STR |
| 8726 | "Display routes matching the communities\n" |
| 8727 | "community number\n" |
| 8728 | "Do not send outside local AS (well-known community)\n" |
| 8729 | "Do not advertise to any peer (well-known community)\n" |
| 8730 | "Do not export to next AS (well-known community)\n") |
| 8731 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8732 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8733 | } |
| 8734 | |
| 8735 | /* old command */ |
| 8736 | ALIAS (show_ipv6_mbgp_community, |
| 8737 | show_ipv6_mbgp_community2_cmd, |
| 8738 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8739 | SHOW_STR |
| 8740 | IPV6_STR |
| 8741 | MBGP_STR |
| 8742 | "Display routes matching the communities\n" |
| 8743 | "community number\n" |
| 8744 | "Do not send outside local AS (well-known community)\n" |
| 8745 | "Do not advertise to any peer (well-known community)\n" |
| 8746 | "Do not export to next AS (well-known community)\n" |
| 8747 | "community number\n" |
| 8748 | "Do not send outside local AS (well-known community)\n" |
| 8749 | "Do not advertise to any peer (well-known community)\n" |
| 8750 | "Do not export to next AS (well-known community)\n") |
| 8751 | |
| 8752 | /* old command */ |
| 8753 | ALIAS (show_ipv6_mbgp_community, |
| 8754 | show_ipv6_mbgp_community3_cmd, |
| 8755 | "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)", |
| 8756 | SHOW_STR |
| 8757 | IPV6_STR |
| 8758 | MBGP_STR |
| 8759 | "Display routes matching the communities\n" |
| 8760 | "community number\n" |
| 8761 | "Do not send outside local AS (well-known community)\n" |
| 8762 | "Do not advertise to any peer (well-known community)\n" |
| 8763 | "Do not export to next AS (well-known community)\n" |
| 8764 | "community number\n" |
| 8765 | "Do not send outside local AS (well-known community)\n" |
| 8766 | "Do not advertise to any peer (well-known community)\n" |
| 8767 | "Do not export to next AS (well-known community)\n" |
| 8768 | "community number\n" |
| 8769 | "Do not send outside local AS (well-known community)\n" |
| 8770 | "Do not advertise to any peer (well-known community)\n" |
| 8771 | "Do not export to next AS (well-known community)\n") |
| 8772 | |
| 8773 | /* old command */ |
| 8774 | ALIAS (show_ipv6_mbgp_community, |
| 8775 | show_ipv6_mbgp_community4_cmd, |
| 8776 | "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)", |
| 8777 | SHOW_STR |
| 8778 | IPV6_STR |
| 8779 | MBGP_STR |
| 8780 | "Display routes matching the communities\n" |
| 8781 | "community number\n" |
| 8782 | "Do not send outside local AS (well-known community)\n" |
| 8783 | "Do not advertise to any peer (well-known community)\n" |
| 8784 | "Do not export to next AS (well-known community)\n" |
| 8785 | "community number\n" |
| 8786 | "Do not send outside local AS (well-known community)\n" |
| 8787 | "Do not advertise to any peer (well-known community)\n" |
| 8788 | "Do not export to next AS (well-known community)\n" |
| 8789 | "community number\n" |
| 8790 | "Do not send outside local AS (well-known community)\n" |
| 8791 | "Do not advertise to any peer (well-known community)\n" |
| 8792 | "Do not export to next AS (well-known community)\n" |
| 8793 | "community number\n" |
| 8794 | "Do not send outside local AS (well-known community)\n" |
| 8795 | "Do not advertise to any peer (well-known community)\n" |
| 8796 | "Do not export to next AS (well-known community)\n") |
| 8797 | |
| 8798 | /* old command */ |
| 8799 | DEFUN (show_ipv6_mbgp_community_exact, |
| 8800 | show_ipv6_mbgp_community_exact_cmd, |
| 8801 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8802 | SHOW_STR |
| 8803 | IPV6_STR |
| 8804 | MBGP_STR |
| 8805 | "Display routes matching the communities\n" |
| 8806 | "community number\n" |
| 8807 | "Do not send outside local AS (well-known community)\n" |
| 8808 | "Do not advertise to any peer (well-known community)\n" |
| 8809 | "Do not export to next AS (well-known community)\n" |
| 8810 | "Exact match of the communities") |
| 8811 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8812 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8813 | } |
| 8814 | |
| 8815 | /* old command */ |
| 8816 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8817 | show_ipv6_mbgp_community2_exact_cmd, |
| 8818 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8819 | SHOW_STR |
| 8820 | IPV6_STR |
| 8821 | MBGP_STR |
| 8822 | "Display routes matching the communities\n" |
| 8823 | "community number\n" |
| 8824 | "Do not send outside local AS (well-known community)\n" |
| 8825 | "Do not advertise to any peer (well-known community)\n" |
| 8826 | "Do not export to next AS (well-known community)\n" |
| 8827 | "community number\n" |
| 8828 | "Do not send outside local AS (well-known community)\n" |
| 8829 | "Do not advertise to any peer (well-known community)\n" |
| 8830 | "Do not export to next AS (well-known community)\n" |
| 8831 | "Exact match of the communities") |
| 8832 | |
| 8833 | /* old command */ |
| 8834 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8835 | show_ipv6_mbgp_community3_exact_cmd, |
| 8836 | "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", |
| 8837 | SHOW_STR |
| 8838 | IPV6_STR |
| 8839 | MBGP_STR |
| 8840 | "Display routes matching the communities\n" |
| 8841 | "community number\n" |
| 8842 | "Do not send outside local AS (well-known community)\n" |
| 8843 | "Do not advertise to any peer (well-known community)\n" |
| 8844 | "Do not export to next AS (well-known community)\n" |
| 8845 | "community number\n" |
| 8846 | "Do not send outside local AS (well-known community)\n" |
| 8847 | "Do not advertise to any peer (well-known community)\n" |
| 8848 | "Do not export to next AS (well-known community)\n" |
| 8849 | "community number\n" |
| 8850 | "Do not send outside local AS (well-known community)\n" |
| 8851 | "Do not advertise to any peer (well-known community)\n" |
| 8852 | "Do not export to next AS (well-known community)\n" |
| 8853 | "Exact match of the communities") |
| 8854 | |
| 8855 | /* old command */ |
| 8856 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8857 | show_ipv6_mbgp_community4_exact_cmd, |
| 8858 | "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", |
| 8859 | SHOW_STR |
| 8860 | IPV6_STR |
| 8861 | MBGP_STR |
| 8862 | "Display routes matching the communities\n" |
| 8863 | "community number\n" |
| 8864 | "Do not send outside local AS (well-known community)\n" |
| 8865 | "Do not advertise to any peer (well-known community)\n" |
| 8866 | "Do not export to next AS (well-known community)\n" |
| 8867 | "community number\n" |
| 8868 | "Do not send outside local AS (well-known community)\n" |
| 8869 | "Do not advertise to any peer (well-known community)\n" |
| 8870 | "Do not export to next AS (well-known community)\n" |
| 8871 | "community number\n" |
| 8872 | "Do not send outside local AS (well-known community)\n" |
| 8873 | "Do not advertise to any peer (well-known community)\n" |
| 8874 | "Do not export to next AS (well-known community)\n" |
| 8875 | "community number\n" |
| 8876 | "Do not send outside local AS (well-known community)\n" |
| 8877 | "Do not advertise to any peer (well-known community)\n" |
| 8878 | "Do not export to next AS (well-known community)\n" |
| 8879 | "Exact match of the communities") |
| 8880 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 8881 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8882 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8883 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 8884 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8885 | { |
| 8886 | struct community_list *list; |
| 8887 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8888 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8889 | if (list == NULL) |
| 8890 | { |
| 8891 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 8892 | VTY_NEWLINE); |
| 8893 | return CMD_WARNING; |
| 8894 | } |
| 8895 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8896 | return bgp_show (vty, NULL, afi, safi, |
| 8897 | (exact ? bgp_show_type_community_list_exact : |
| 8898 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8899 | } |
| 8900 | |
| 8901 | DEFUN (show_ip_bgp_community_list, |
| 8902 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8903 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8904 | SHOW_STR |
| 8905 | IP_STR |
| 8906 | BGP_STR |
| 8907 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8908 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8909 | "community-list name\n") |
| 8910 | { |
| 8911 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 8912 | } |
| 8913 | |
| 8914 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 8915 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8916 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8917 | SHOW_STR |
| 8918 | IP_STR |
| 8919 | BGP_STR |
| 8920 | "Address family\n" |
| 8921 | "Address Family modifier\n" |
| 8922 | "Address Family modifier\n" |
| 8923 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8924 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8925 | "community-list name\n") |
| 8926 | { |
| 8927 | if (strncmp (argv[0], "m", 1) == 0) |
| 8928 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 8929 | |
| 8930 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 8931 | } |
| 8932 | |
| 8933 | DEFUN (show_ip_bgp_community_list_exact, |
| 8934 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8935 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8936 | SHOW_STR |
| 8937 | IP_STR |
| 8938 | BGP_STR |
| 8939 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8940 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8941 | "community-list name\n" |
| 8942 | "Exact match of the communities\n") |
| 8943 | { |
| 8944 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 8945 | } |
| 8946 | |
| 8947 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 8948 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8949 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8950 | SHOW_STR |
| 8951 | IP_STR |
| 8952 | BGP_STR |
| 8953 | "Address family\n" |
| 8954 | "Address Family modifier\n" |
| 8955 | "Address Family modifier\n" |
| 8956 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8957 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8958 | "community-list name\n" |
| 8959 | "Exact match of the communities\n") |
| 8960 | { |
| 8961 | if (strncmp (argv[0], "m", 1) == 0) |
| 8962 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 8963 | |
| 8964 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 8965 | } |
| 8966 | |
| 8967 | #ifdef HAVE_IPV6 |
| 8968 | DEFUN (show_bgp_community_list, |
| 8969 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8970 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8971 | SHOW_STR |
| 8972 | BGP_STR |
| 8973 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8974 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8975 | "community-list name\n") |
| 8976 | { |
| 8977 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8978 | } |
| 8979 | |
| 8980 | ALIAS (show_bgp_community_list, |
| 8981 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8982 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8983 | SHOW_STR |
| 8984 | BGP_STR |
| 8985 | "Address family\n" |
| 8986 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8987 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 8988 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8989 | |
| 8990 | /* old command */ |
| 8991 | DEFUN (show_ipv6_bgp_community_list, |
| 8992 | show_ipv6_bgp_community_list_cmd, |
| 8993 | "show ipv6 bgp community-list WORD", |
| 8994 | SHOW_STR |
| 8995 | IPV6_STR |
| 8996 | BGP_STR |
| 8997 | "Display routes matching the community-list\n" |
| 8998 | "community-list name\n") |
| 8999 | { |
| 9000 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 9001 | } |
| 9002 | |
| 9003 | /* old command */ |
| 9004 | DEFUN (show_ipv6_mbgp_community_list, |
| 9005 | show_ipv6_mbgp_community_list_cmd, |
| 9006 | "show ipv6 mbgp community-list WORD", |
| 9007 | SHOW_STR |
| 9008 | IPV6_STR |
| 9009 | MBGP_STR |
| 9010 | "Display routes matching the community-list\n" |
| 9011 | "community-list name\n") |
| 9012 | { |
| 9013 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 9014 | } |
| 9015 | |
| 9016 | DEFUN (show_bgp_community_list_exact, |
| 9017 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9018 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9019 | SHOW_STR |
| 9020 | BGP_STR |
| 9021 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9022 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9023 | "community-list name\n" |
| 9024 | "Exact match of the communities\n") |
| 9025 | { |
| 9026 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9027 | } |
| 9028 | |
| 9029 | ALIAS (show_bgp_community_list_exact, |
| 9030 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9031 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9032 | SHOW_STR |
| 9033 | BGP_STR |
| 9034 | "Address family\n" |
| 9035 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9036 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9037 | "community-list name\n" |
| 9038 | "Exact match of the communities\n") |
| 9039 | |
| 9040 | /* old command */ |
| 9041 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 9042 | show_ipv6_bgp_community_list_exact_cmd, |
| 9043 | "show ipv6 bgp community-list WORD exact-match", |
| 9044 | SHOW_STR |
| 9045 | IPV6_STR |
| 9046 | BGP_STR |
| 9047 | "Display routes matching the community-list\n" |
| 9048 | "community-list name\n" |
| 9049 | "Exact match of the communities\n") |
| 9050 | { |
| 9051 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9052 | } |
| 9053 | |
| 9054 | /* old command */ |
| 9055 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 9056 | show_ipv6_mbgp_community_list_exact_cmd, |
| 9057 | "show ipv6 mbgp community-list WORD exact-match", |
| 9058 | SHOW_STR |
| 9059 | IPV6_STR |
| 9060 | MBGP_STR |
| 9061 | "Display routes matching the community-list\n" |
| 9062 | "community-list name\n" |
| 9063 | "Exact match of the communities\n") |
| 9064 | { |
| 9065 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 9066 | } |
| 9067 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9068 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9069 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9070 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9071 | safi_t safi, enum bgp_show_type type) |
| 9072 | { |
| 9073 | int ret; |
| 9074 | struct prefix *p; |
| 9075 | |
| 9076 | p = prefix_new(); |
| 9077 | |
| 9078 | ret = str2prefix (prefix, p); |
| 9079 | if (! ret) |
| 9080 | { |
| 9081 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 9082 | return CMD_WARNING; |
| 9083 | } |
| 9084 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9085 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 9086 | prefix_free(p); |
| 9087 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9088 | } |
| 9089 | |
| 9090 | DEFUN (show_ip_bgp_prefix_longer, |
| 9091 | show_ip_bgp_prefix_longer_cmd, |
| 9092 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 9093 | SHOW_STR |
| 9094 | IP_STR |
| 9095 | BGP_STR |
| 9096 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9097 | "Display route and more specific routes\n") |
| 9098 | { |
| 9099 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9100 | bgp_show_type_prefix_longer); |
| 9101 | } |
| 9102 | |
| 9103 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 9104 | show_ip_bgp_flap_prefix_longer_cmd, |
| 9105 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 9106 | SHOW_STR |
| 9107 | IP_STR |
| 9108 | BGP_STR |
| 9109 | "Display flap statistics of routes\n" |
| 9110 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9111 | "Display route and more specific routes\n") |
| 9112 | { |
| 9113 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9114 | bgp_show_type_flap_prefix_longer); |
| 9115 | } |
| 9116 | |
| 9117 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 9118 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 9119 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 9120 | SHOW_STR |
| 9121 | IP_STR |
| 9122 | BGP_STR |
| 9123 | "Address family\n" |
| 9124 | "Address Family modifier\n" |
| 9125 | "Address Family modifier\n" |
| 9126 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9127 | "Display route and more specific routes\n") |
| 9128 | { |
| 9129 | if (strncmp (argv[0], "m", 1) == 0) |
| 9130 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 9131 | bgp_show_type_prefix_longer); |
| 9132 | |
| 9133 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 9134 | bgp_show_type_prefix_longer); |
| 9135 | } |
| 9136 | |
| 9137 | DEFUN (show_ip_bgp_flap_address, |
| 9138 | show_ip_bgp_flap_address_cmd, |
| 9139 | "show ip bgp flap-statistics A.B.C.D", |
| 9140 | SHOW_STR |
| 9141 | IP_STR |
| 9142 | BGP_STR |
| 9143 | "Display flap statistics of routes\n" |
| 9144 | "Network in the BGP routing table to display\n") |
| 9145 | { |
| 9146 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9147 | bgp_show_type_flap_address); |
| 9148 | } |
| 9149 | |
| 9150 | DEFUN (show_ip_bgp_flap_prefix, |
| 9151 | show_ip_bgp_flap_prefix_cmd, |
| 9152 | "show ip bgp flap-statistics A.B.C.D/M", |
| 9153 | SHOW_STR |
| 9154 | IP_STR |
| 9155 | BGP_STR |
| 9156 | "Display flap statistics of routes\n" |
| 9157 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9158 | { |
| 9159 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9160 | bgp_show_type_flap_prefix); |
| 9161 | } |
| 9162 | #ifdef HAVE_IPV6 |
| 9163 | DEFUN (show_bgp_prefix_longer, |
| 9164 | show_bgp_prefix_longer_cmd, |
| 9165 | "show bgp X:X::X:X/M longer-prefixes", |
| 9166 | SHOW_STR |
| 9167 | BGP_STR |
| 9168 | "IPv6 prefix <network>/<length>\n" |
| 9169 | "Display route and more specific routes\n") |
| 9170 | { |
| 9171 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9172 | bgp_show_type_prefix_longer); |
| 9173 | } |
| 9174 | |
| 9175 | ALIAS (show_bgp_prefix_longer, |
| 9176 | show_bgp_ipv6_prefix_longer_cmd, |
| 9177 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 9178 | SHOW_STR |
| 9179 | BGP_STR |
| 9180 | "Address family\n" |
| 9181 | "IPv6 prefix <network>/<length>\n" |
| 9182 | "Display route and more specific routes\n") |
| 9183 | |
| 9184 | /* old command */ |
| 9185 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 9186 | show_ipv6_bgp_prefix_longer_cmd, |
| 9187 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 9188 | SHOW_STR |
| 9189 | IPV6_STR |
| 9190 | BGP_STR |
| 9191 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9192 | "Display route and more specific routes\n") |
| 9193 | { |
| 9194 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9195 | bgp_show_type_prefix_longer); |
| 9196 | } |
| 9197 | |
| 9198 | /* old command */ |
| 9199 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 9200 | show_ipv6_mbgp_prefix_longer_cmd, |
| 9201 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 9202 | SHOW_STR |
| 9203 | IPV6_STR |
| 9204 | MBGP_STR |
| 9205 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9206 | "Display route and more specific routes\n") |
| 9207 | { |
| 9208 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 9209 | bgp_show_type_prefix_longer); |
| 9210 | } |
| 9211 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9212 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9213 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9214 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 9215 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9216 | { |
| 9217 | int ret; |
| 9218 | struct bgp *bgp; |
| 9219 | struct peer *peer; |
| 9220 | union sockunion su; |
| 9221 | |
| 9222 | /* BGP structure lookup. */ |
| 9223 | if (view_name) |
| 9224 | { |
| 9225 | bgp = bgp_lookup_by_name (view_name); |
| 9226 | if (! bgp) |
| 9227 | { |
| 9228 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9229 | return NULL; |
| 9230 | } |
| 9231 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 9232 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9233 | { |
| 9234 | bgp = bgp_get_default (); |
| 9235 | if (! bgp) |
| 9236 | { |
| 9237 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9238 | return NULL; |
| 9239 | } |
| 9240 | } |
| 9241 | |
| 9242 | /* Get peer sockunion. */ |
| 9243 | ret = str2sockunion (ip_str, &su); |
| 9244 | if (ret < 0) |
| 9245 | { |
| 9246 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 9247 | return NULL; |
| 9248 | } |
| 9249 | |
| 9250 | /* Peer structure lookup. */ |
| 9251 | peer = peer_lookup (bgp, &su); |
| 9252 | if (! peer) |
| 9253 | { |
| 9254 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 9255 | return NULL; |
| 9256 | } |
| 9257 | |
| 9258 | return peer; |
| 9259 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9260 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9261 | enum bgp_stats |
| 9262 | { |
| 9263 | BGP_STATS_MAXBITLEN = 0, |
| 9264 | BGP_STATS_RIB, |
| 9265 | BGP_STATS_PREFIXES, |
| 9266 | BGP_STATS_TOTPLEN, |
| 9267 | BGP_STATS_UNAGGREGATEABLE, |
| 9268 | BGP_STATS_MAX_AGGREGATEABLE, |
| 9269 | BGP_STATS_AGGREGATES, |
| 9270 | BGP_STATS_SPACE, |
| 9271 | BGP_STATS_ASPATH_COUNT, |
| 9272 | BGP_STATS_ASPATH_MAXHOPS, |
| 9273 | BGP_STATS_ASPATH_TOTHOPS, |
| 9274 | BGP_STATS_ASPATH_MAXSIZE, |
| 9275 | BGP_STATS_ASPATH_TOTSIZE, |
| 9276 | BGP_STATS_ASN_HIGHEST, |
| 9277 | BGP_STATS_MAX, |
| 9278 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9279 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9280 | static const char *table_stats_strs[] = |
| 9281 | { |
| 9282 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 9283 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 9284 | [BGP_STATS_RIB] = "Total Advertisements", |
| 9285 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 9286 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 9287 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 9288 | [BGP_STATS_SPACE] = "Address space advertised", |
| 9289 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 9290 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 9291 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 9292 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 9293 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 9294 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 9295 | [BGP_STATS_MAX] = NULL, |
| 9296 | }; |
| 9297 | |
| 9298 | struct bgp_table_stats |
| 9299 | { |
| 9300 | struct bgp_table *table; |
| 9301 | unsigned long long counts[BGP_STATS_MAX]; |
| 9302 | }; |
| 9303 | |
| 9304 | #if 0 |
| 9305 | #define TALLY_SIGFIG 100000 |
| 9306 | static unsigned long |
| 9307 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 9308 | { |
| 9309 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 9310 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 9311 | unsigned long ret = newtot / count; |
| 9312 | |
| 9313 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 9314 | return ret + 1; |
| 9315 | else |
| 9316 | return ret; |
| 9317 | } |
| 9318 | #endif |
| 9319 | |
| 9320 | static int |
| 9321 | bgp_table_stats_walker (struct thread *t) |
| 9322 | { |
| 9323 | struct bgp_node *rn; |
| 9324 | struct bgp_node *top; |
| 9325 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 9326 | unsigned int space = 0; |
| 9327 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 9328 | if (!(top = bgp_table_top (ts->table))) |
| 9329 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9330 | |
| 9331 | switch (top->p.family) |
| 9332 | { |
| 9333 | case AF_INET: |
| 9334 | space = IPV4_MAX_BITLEN; |
| 9335 | break; |
| 9336 | case AF_INET6: |
| 9337 | space = IPV6_MAX_BITLEN; |
| 9338 | break; |
| 9339 | } |
| 9340 | |
| 9341 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 9342 | |
| 9343 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 9344 | { |
| 9345 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9346 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9347 | unsigned int rinum = 0; |
| 9348 | |
| 9349 | if (rn == top) |
| 9350 | continue; |
| 9351 | |
| 9352 | if (!rn->info) |
| 9353 | continue; |
| 9354 | |
| 9355 | ts->counts[BGP_STATS_PREFIXES]++; |
| 9356 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 9357 | |
| 9358 | #if 0 |
| 9359 | ts->counts[BGP_STATS_AVGPLEN] |
| 9360 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 9361 | ts->counts[BGP_STATS_AVGPLEN], |
| 9362 | rn->p.prefixlen); |
| 9363 | #endif |
| 9364 | |
| 9365 | /* check if the prefix is included by any other announcements */ |
| 9366 | while (prn && !prn->info) |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9367 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9368 | |
| 9369 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 9370 | { |
| 9371 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 9372 | /* announced address space */ |
| 9373 | if (space) |
| 9374 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 9375 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9376 | else if (prn->info) |
| 9377 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 9378 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9379 | for (ri = rn->info; ri; ri = ri->next) |
| 9380 | { |
| 9381 | rinum++; |
| 9382 | ts->counts[BGP_STATS_RIB]++; |
| 9383 | |
| 9384 | if (ri->attr && |
| 9385 | (CHECK_FLAG (ri->attr->flag, |
| 9386 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 9387 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 9388 | |
| 9389 | /* as-path stats */ |
| 9390 | if (ri->attr && ri->attr->aspath) |
| 9391 | { |
| 9392 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 9393 | unsigned int size = aspath_size (ri->attr->aspath); |
| 9394 | as_t highest = aspath_highest (ri->attr->aspath); |
| 9395 | |
| 9396 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 9397 | |
| 9398 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 9399 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 9400 | |
| 9401 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 9402 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 9403 | |
| 9404 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 9405 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 9406 | #if 0 |
| 9407 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 9408 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9409 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 9410 | hops); |
| 9411 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 9412 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9413 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 9414 | size); |
| 9415 | #endif |
| 9416 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 9417 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 9418 | } |
| 9419 | } |
| 9420 | } |
| 9421 | return 0; |
| 9422 | } |
| 9423 | |
| 9424 | static int |
| 9425 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 9426 | { |
| 9427 | struct bgp_table_stats ts; |
| 9428 | unsigned int i; |
| 9429 | |
| 9430 | if (!bgp->rib[afi][safi]) |
| 9431 | { |
| 9432 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); |
| 9433 | return CMD_WARNING; |
| 9434 | } |
| 9435 | |
| 9436 | memset (&ts, 0, sizeof (ts)); |
| 9437 | ts.table = bgp->rib[afi][safi]; |
| 9438 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 9439 | |
| 9440 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 9441 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 9442 | |
| 9443 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 9444 | { |
| 9445 | if (!table_stats_strs[i]) |
| 9446 | continue; |
| 9447 | |
| 9448 | switch (i) |
| 9449 | { |
| 9450 | #if 0 |
| 9451 | case BGP_STATS_ASPATH_AVGHOPS: |
| 9452 | case BGP_STATS_ASPATH_AVGSIZE: |
| 9453 | case BGP_STATS_AVGPLEN: |
| 9454 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9455 | vty_out (vty, "%12.2f", |
| 9456 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 9457 | break; |
| 9458 | #endif |
| 9459 | case BGP_STATS_ASPATH_TOTHOPS: |
| 9460 | case BGP_STATS_ASPATH_TOTSIZE: |
| 9461 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9462 | vty_out (vty, "%12.2f", |
| 9463 | ts.counts[i] ? |
| 9464 | (float)ts.counts[i] / |
| 9465 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 9466 | : 0); |
| 9467 | break; |
| 9468 | case BGP_STATS_TOTPLEN: |
| 9469 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9470 | vty_out (vty, "%12.2f", |
| 9471 | ts.counts[i] ? |
| 9472 | (float)ts.counts[i] / |
| 9473 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 9474 | : 0); |
| 9475 | break; |
| 9476 | case BGP_STATS_SPACE: |
| 9477 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9478 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 9479 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 9480 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 9481 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9482 | vty_out (vty, "%12.2f%s", |
| 9483 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 9484 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9485 | VTY_NEWLINE); |
| 9486 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 9487 | vty_out (vty, "%12.2f%s", |
| 9488 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9489 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 9490 | VTY_NEWLINE); |
| 9491 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 9492 | break; |
| 9493 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 9494 | vty_out (vty, "%12.2f", |
| 9495 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9496 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 9497 | break; |
| 9498 | default: |
| 9499 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9500 | vty_out (vty, "%12llu", ts.counts[i]); |
| 9501 | } |
| 9502 | |
| 9503 | vty_out (vty, "%s", VTY_NEWLINE); |
| 9504 | } |
| 9505 | return CMD_SUCCESS; |
| 9506 | } |
| 9507 | |
| 9508 | static int |
| 9509 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 9510 | const char *afi_str, const char *safi_str) |
| 9511 | { |
| 9512 | struct bgp *bgp; |
| 9513 | afi_t afi; |
| 9514 | safi_t safi; |
| 9515 | |
| 9516 | if (name) |
| 9517 | bgp = bgp_lookup_by_name (name); |
| 9518 | else |
| 9519 | bgp = bgp_get_default (); |
| 9520 | |
| 9521 | if (!bgp) |
| 9522 | { |
| 9523 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); |
| 9524 | return CMD_WARNING; |
| 9525 | } |
| 9526 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 9527 | { |
| 9528 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 9529 | afi = AFI_IP; |
| 9530 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 9531 | afi = AFI_IP6; |
| 9532 | else |
| 9533 | { |
| 9534 | vty_out (vty, "%% Invalid address family %s%s", |
| 9535 | afi_str, VTY_NEWLINE); |
| 9536 | return CMD_WARNING; |
| 9537 | } |
| 9538 | if (strncmp (safi_str, "m", 1) == 0) |
| 9539 | safi = SAFI_MULTICAST; |
| 9540 | else if (strncmp (safi_str, "u", 1) == 0) |
| 9541 | safi = SAFI_UNICAST; |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 9542 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
| 9543 | safi = SAFI_MPLS_LABELED_VPN; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9544 | else |
| 9545 | { |
| 9546 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
| 9547 | safi_str, VTY_NEWLINE); |
| 9548 | return CMD_WARNING; |
| 9549 | } |
| 9550 | } |
| 9551 | else |
| 9552 | { |
| 9553 | vty_out (vty, "%% Invalid address family %s%s", |
| 9554 | afi_str, VTY_NEWLINE); |
| 9555 | return CMD_WARNING; |
| 9556 | } |
| 9557 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9558 | return bgp_table_stats (vty, bgp, afi, safi); |
| 9559 | } |
| 9560 | |
| 9561 | DEFUN (show_bgp_statistics, |
| 9562 | show_bgp_statistics_cmd, |
| 9563 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", |
| 9564 | SHOW_STR |
| 9565 | BGP_STR |
| 9566 | "Address family\n" |
| 9567 | "Address family\n" |
| 9568 | "Address Family modifier\n" |
| 9569 | "Address Family modifier\n" |
| 9570 | "BGP RIB advertisement statistics\n") |
| 9571 | { |
| 9572 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9573 | } |
| 9574 | |
| 9575 | ALIAS (show_bgp_statistics, |
| 9576 | show_bgp_statistics_vpnv4_cmd, |
| 9577 | "show bgp (ipv4) (vpnv4) statistics", |
| 9578 | SHOW_STR |
| 9579 | BGP_STR |
| 9580 | "Address family\n" |
| 9581 | "Address Family modifier\n" |
| 9582 | "BGP RIB advertisement statistics\n") |
| 9583 | |
| 9584 | DEFUN (show_bgp_statistics_view, |
| 9585 | show_bgp_statistics_view_cmd, |
| 9586 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", |
| 9587 | SHOW_STR |
| 9588 | BGP_STR |
| 9589 | "BGP view\n" |
| 9590 | "Address family\n" |
| 9591 | "Address family\n" |
| 9592 | "Address Family modifier\n" |
| 9593 | "Address Family modifier\n" |
| 9594 | "BGP RIB advertisement statistics\n") |
| 9595 | { |
| 9596 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9597 | } |
| 9598 | |
| 9599 | ALIAS (show_bgp_statistics_view, |
| 9600 | show_bgp_statistics_view_vpnv4_cmd, |
| 9601 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
| 9602 | SHOW_STR |
| 9603 | BGP_STR |
| 9604 | "BGP view\n" |
| 9605 | "Address family\n" |
| 9606 | "Address Family modifier\n" |
| 9607 | "BGP RIB advertisement statistics\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9608 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9609 | enum bgp_pcounts |
| 9610 | { |
| 9611 | PCOUNT_ADJ_IN = 0, |
| 9612 | PCOUNT_DAMPED, |
| 9613 | PCOUNT_REMOVED, |
| 9614 | PCOUNT_HISTORY, |
| 9615 | PCOUNT_STALE, |
| 9616 | PCOUNT_VALID, |
| 9617 | PCOUNT_ALL, |
| 9618 | PCOUNT_COUNTED, |
| 9619 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 9620 | PCOUNT_MAX, |
| 9621 | }; |
| 9622 | |
| 9623 | static const char *pcount_strs[] = |
| 9624 | { |
| 9625 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 9626 | [PCOUNT_DAMPED] = "Damped", |
| 9627 | [PCOUNT_REMOVED] = "Removed", |
| 9628 | [PCOUNT_HISTORY] = "History", |
| 9629 | [PCOUNT_STALE] = "Stale", |
| 9630 | [PCOUNT_VALID] = "Valid", |
| 9631 | [PCOUNT_ALL] = "All RIB", |
| 9632 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 9633 | [PCOUNT_PFCNT] = "Useable", |
| 9634 | [PCOUNT_MAX] = NULL, |
| 9635 | }; |
| 9636 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9637 | struct peer_pcounts |
| 9638 | { |
| 9639 | unsigned int count[PCOUNT_MAX]; |
| 9640 | const struct peer *peer; |
| 9641 | const struct bgp_table *table; |
| 9642 | }; |
| 9643 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9644 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9645 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9646 | { |
| 9647 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9648 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 9649 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9650 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9651 | 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] | 9652 | { |
| 9653 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9654 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9655 | |
| 9656 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9657 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9658 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9659 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9660 | for (ri = rn->info; ri; ri = ri->next) |
| 9661 | { |
| 9662 | char buf[SU_ADDRSTRLEN]; |
| 9663 | |
| 9664 | if (ri->peer != peer) |
| 9665 | continue; |
| 9666 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9667 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9668 | |
| 9669 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9670 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9671 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9672 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9673 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9674 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9675 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9676 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9677 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9678 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9679 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9680 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9681 | |
| 9682 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 9683 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9684 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9685 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9686 | plog_warn (peer->log, |
| 9687 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 9688 | peer->host, |
| 9689 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9690 | buf, SU_ADDRSTRLEN), |
| 9691 | rn->p.prefixlen, |
| 9692 | ri->flags); |
| 9693 | } |
| 9694 | else |
| 9695 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9696 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9697 | plog_warn (peer->log, |
| 9698 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 9699 | peer->host, |
| 9700 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9701 | buf, SU_ADDRSTRLEN), |
| 9702 | rn->p.prefixlen, |
| 9703 | ri->flags); |
| 9704 | } |
| 9705 | } |
| 9706 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9707 | return 0; |
| 9708 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9709 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9710 | static int |
| 9711 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 9712 | { |
| 9713 | struct peer_pcounts pcounts = { .peer = peer }; |
| 9714 | unsigned int i; |
| 9715 | |
| 9716 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 9717 | || !peer->bgp->rib[afi][safi]) |
| 9718 | { |
| 9719 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9720 | return CMD_WARNING; |
| 9721 | } |
| 9722 | |
| 9723 | memset (&pcounts, 0, sizeof(pcounts)); |
| 9724 | pcounts.peer = peer; |
| 9725 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 9726 | |
| 9727 | /* in-place call via thread subsystem so as to record execution time |
| 9728 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 9729 | * on just vty_read()). |
| 9730 | */ |
| 9731 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 9732 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9733 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 9734 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 9735 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 9736 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 9737 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 9738 | |
| 9739 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9740 | vty_out (vty, "%20s: %-10d%s", |
| 9741 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9742 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9743 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9744 | { |
| 9745 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 9746 | peer->host, VTY_NEWLINE); |
| 9747 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 9748 | VTY_NEWLINE); |
| 9749 | } |
| 9750 | |
| 9751 | return CMD_SUCCESS; |
| 9752 | } |
| 9753 | |
| 9754 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 9755 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 9756 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9757 | SHOW_STR |
| 9758 | IP_STR |
| 9759 | BGP_STR |
| 9760 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9761 | "Neighbor to display information about\n" |
| 9762 | "Neighbor to display information about\n" |
| 9763 | "Display detailed prefix count information\n") |
| 9764 | { |
| 9765 | struct peer *peer; |
| 9766 | |
| 9767 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9768 | if (! peer) |
| 9769 | return CMD_WARNING; |
| 9770 | |
| 9771 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9772 | } |
| 9773 | |
| 9774 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 9775 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 9776 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9777 | SHOW_STR |
| 9778 | BGP_STR |
| 9779 | "Address family\n" |
| 9780 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9781 | "Neighbor to display information about\n" |
| 9782 | "Neighbor to display information about\n" |
| 9783 | "Display detailed prefix count information\n") |
| 9784 | { |
| 9785 | struct peer *peer; |
| 9786 | |
| 9787 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9788 | if (! peer) |
| 9789 | return CMD_WARNING; |
| 9790 | |
| 9791 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 9792 | } |
| 9793 | |
| 9794 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 9795 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 9796 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9797 | SHOW_STR |
| 9798 | IP_STR |
| 9799 | BGP_STR |
| 9800 | "Address family\n" |
| 9801 | "Address Family modifier\n" |
| 9802 | "Address Family modifier\n" |
| 9803 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9804 | "Neighbor to display information about\n" |
| 9805 | "Neighbor to display information about\n" |
| 9806 | "Display detailed prefix count information\n") |
| 9807 | { |
| 9808 | struct peer *peer; |
| 9809 | |
| 9810 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9811 | if (! peer) |
| 9812 | return CMD_WARNING; |
| 9813 | |
| 9814 | if (strncmp (argv[0], "m", 1) == 0) |
| 9815 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 9816 | |
| 9817 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9818 | } |
| 9819 | |
| 9820 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 9821 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 9822 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9823 | SHOW_STR |
| 9824 | IP_STR |
| 9825 | BGP_STR |
| 9826 | "Address family\n" |
| 9827 | "Address Family modifier\n" |
| 9828 | "Address Family modifier\n" |
| 9829 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9830 | "Neighbor to display information about\n" |
| 9831 | "Neighbor to display information about\n" |
| 9832 | "Display detailed prefix count information\n") |
| 9833 | { |
| 9834 | struct peer *peer; |
| 9835 | |
| 9836 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9837 | if (! peer) |
| 9838 | return CMD_WARNING; |
| 9839 | |
| 9840 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 9841 | } |
| 9842 | |
| 9843 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9844 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9845 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 9846 | int in) |
| 9847 | { |
| 9848 | struct bgp_table *table; |
| 9849 | struct bgp_adj_in *ain; |
| 9850 | struct bgp_adj_out *adj; |
| 9851 | unsigned long output_count; |
| 9852 | struct bgp_node *rn; |
| 9853 | int header1 = 1; |
| 9854 | struct bgp *bgp; |
| 9855 | int header2 = 1; |
| 9856 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9857 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9858 | |
| 9859 | if (! bgp) |
| 9860 | return; |
| 9861 | |
| 9862 | table = bgp->rib[afi][safi]; |
| 9863 | |
| 9864 | output_count = 0; |
| 9865 | |
| 9866 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 9867 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 9868 | { |
| 9869 | 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] | 9870 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9871 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9872 | |
| 9873 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 9874 | VTY_NEWLINE, VTY_NEWLINE); |
| 9875 | header1 = 0; |
| 9876 | } |
| 9877 | |
| 9878 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 9879 | if (in) |
| 9880 | { |
| 9881 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9882 | if (ain->peer == peer) |
| 9883 | { |
| 9884 | if (header1) |
| 9885 | { |
| 9886 | 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] | 9887 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9888 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9889 | header1 = 0; |
| 9890 | } |
| 9891 | if (header2) |
| 9892 | { |
| 9893 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9894 | header2 = 0; |
| 9895 | } |
| 9896 | if (ain->attr) |
| 9897 | { |
| 9898 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 9899 | output_count++; |
| 9900 | } |
| 9901 | } |
| 9902 | } |
| 9903 | else |
| 9904 | { |
| 9905 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 9906 | if (adj->peer == peer) |
| 9907 | { |
| 9908 | if (header1) |
| 9909 | { |
| 9910 | 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] | 9911 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9912 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9913 | header1 = 0; |
| 9914 | } |
| 9915 | if (header2) |
| 9916 | { |
| 9917 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9918 | header2 = 0; |
| 9919 | } |
| 9920 | if (adj->attr) |
| 9921 | { |
| 9922 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 9923 | output_count++; |
| 9924 | } |
| 9925 | } |
| 9926 | } |
| 9927 | |
| 9928 | if (output_count != 0) |
| 9929 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 9930 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 9931 | } |
| 9932 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9933 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9934 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 9935 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9936 | if (! peer || ! peer->afc[afi][safi]) |
| 9937 | { |
| 9938 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9939 | return CMD_WARNING; |
| 9940 | } |
| 9941 | |
| 9942 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 9943 | { |
| 9944 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 9945 | VTY_NEWLINE); |
| 9946 | return CMD_WARNING; |
| 9947 | } |
| 9948 | |
| 9949 | show_adj_route (vty, peer, afi, safi, in); |
| 9950 | |
| 9951 | return CMD_SUCCESS; |
| 9952 | } |
| 9953 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 9954 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 9955 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 9956 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9957 | SHOW_STR |
| 9958 | IP_STR |
| 9959 | BGP_STR |
| 9960 | "BGP view\n" |
| 9961 | "View name\n" |
| 9962 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9963 | "Neighbor to display information about\n" |
| 9964 | "Neighbor to display information about\n" |
| 9965 | "Display the routes advertised to a BGP neighbor\n") |
| 9966 | { |
| 9967 | struct peer *peer; |
| 9968 | |
| 9969 | if (argc == 2) |
| 9970 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9971 | else |
| 9972 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9973 | |
| 9974 | if (! peer) |
| 9975 | return CMD_WARNING; |
| 9976 | |
| 9977 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 9978 | } |
| 9979 | |
| 9980 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9981 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 9982 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9983 | SHOW_STR |
| 9984 | IP_STR |
| 9985 | BGP_STR |
| 9986 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9987 | "Neighbor to display information about\n" |
| 9988 | "Neighbor to display information about\n" |
| 9989 | "Display the routes advertised to a BGP neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9990 | |
| 9991 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 9992 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 9993 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 9994 | SHOW_STR |
| 9995 | IP_STR |
| 9996 | BGP_STR |
| 9997 | "Address family\n" |
| 9998 | "Address Family modifier\n" |
| 9999 | "Address Family modifier\n" |
| 10000 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10001 | "Neighbor to display information about\n" |
| 10002 | "Neighbor to display information about\n" |
| 10003 | "Display the routes advertised to a BGP neighbor\n") |
| 10004 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10005 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10006 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10007 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10008 | if (! peer) |
| 10009 | return CMD_WARNING; |
| 10010 | |
| 10011 | if (strncmp (argv[0], "m", 1) == 0) |
| 10012 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 10013 | |
| 10014 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10015 | } |
| 10016 | |
| 10017 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10018 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 10019 | show_bgp_view_neighbor_advertised_route_cmd, |
| 10020 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10021 | SHOW_STR |
| 10022 | BGP_STR |
| 10023 | "BGP view\n" |
| 10024 | "View name\n" |
| 10025 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10026 | "Neighbor to display information about\n" |
| 10027 | "Neighbor to display information about\n" |
| 10028 | "Display the routes advertised to a BGP neighbor\n") |
| 10029 | { |
| 10030 | struct peer *peer; |
| 10031 | |
| 10032 | if (argc == 2) |
| 10033 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10034 | else |
| 10035 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10036 | |
| 10037 | if (! peer) |
| 10038 | return CMD_WARNING; |
| 10039 | |
| 10040 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 10041 | } |
| 10042 | |
| 10043 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 10044 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 10045 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10046 | SHOW_STR |
| 10047 | BGP_STR |
| 10048 | "BGP view\n" |
| 10049 | "View name\n" |
| 10050 | "Address family\n" |
| 10051 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10052 | "Neighbor to display information about\n" |
| 10053 | "Neighbor to display information about\n" |
| 10054 | "Display the routes advertised to a BGP neighbor\n") |
| 10055 | |
| 10056 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 10057 | show_bgp_view_neighbor_received_routes_cmd, |
| 10058 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10059 | SHOW_STR |
| 10060 | BGP_STR |
| 10061 | "BGP view\n" |
| 10062 | "View name\n" |
| 10063 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10064 | "Neighbor to display information about\n" |
| 10065 | "Neighbor to display information about\n" |
| 10066 | "Display the received routes from neighbor\n") |
| 10067 | { |
| 10068 | struct peer *peer; |
| 10069 | |
| 10070 | if (argc == 2) |
| 10071 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10072 | else |
| 10073 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10074 | |
| 10075 | if (! peer) |
| 10076 | return CMD_WARNING; |
| 10077 | |
| 10078 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 10079 | } |
| 10080 | |
| 10081 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 10082 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 10083 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10084 | SHOW_STR |
| 10085 | BGP_STR |
| 10086 | "BGP view\n" |
| 10087 | "View name\n" |
| 10088 | "Address family\n" |
| 10089 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10090 | "Neighbor to display information about\n" |
| 10091 | "Neighbor to display information about\n" |
| 10092 | "Display the received routes from neighbor\n") |
| 10093 | |
| 10094 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10095 | show_bgp_neighbor_advertised_route_cmd, |
| 10096 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10097 | SHOW_STR |
| 10098 | BGP_STR |
| 10099 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10100 | "Neighbor to display information about\n" |
| 10101 | "Neighbor to display information about\n" |
| 10102 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10103 | |
| 10104 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10105 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 10106 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10107 | SHOW_STR |
| 10108 | BGP_STR |
| 10109 | "Address family\n" |
| 10110 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10111 | "Neighbor to display information about\n" |
| 10112 | "Neighbor to display information about\n" |
| 10113 | "Display the routes advertised to a BGP neighbor\n") |
| 10114 | |
| 10115 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10116 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10117 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 10118 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10119 | SHOW_STR |
| 10120 | IPV6_STR |
| 10121 | BGP_STR |
| 10122 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10123 | "Neighbor to display information about\n" |
| 10124 | "Neighbor to display information about\n" |
| 10125 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10126 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10127 | /* old command */ |
| 10128 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 10129 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 10130 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10131 | SHOW_STR |
| 10132 | IPV6_STR |
| 10133 | MBGP_STR |
| 10134 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10135 | "Neighbor to display information about\n" |
| 10136 | "Neighbor to display information about\n" |
| 10137 | "Display the routes advertised to a BGP neighbor\n") |
| 10138 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10139 | struct peer *peer; |
| 10140 | |
| 10141 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10142 | if (! peer) |
| 10143 | return CMD_WARNING; |
| 10144 | |
| 10145 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10146 | } |
| 10147 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 10148 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10149 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 10150 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 10151 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10152 | SHOW_STR |
| 10153 | IP_STR |
| 10154 | BGP_STR |
| 10155 | "BGP view\n" |
| 10156 | "View name\n" |
| 10157 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10158 | "Neighbor to display information about\n" |
| 10159 | "Neighbor to display information about\n" |
| 10160 | "Display the received routes from neighbor\n") |
| 10161 | { |
| 10162 | struct peer *peer; |
| 10163 | |
| 10164 | if (argc == 2) |
| 10165 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10166 | else |
| 10167 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10168 | |
| 10169 | if (! peer) |
| 10170 | return CMD_WARNING; |
| 10171 | |
| 10172 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 10173 | } |
| 10174 | |
| 10175 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10176 | show_ip_bgp_neighbor_received_routes_cmd, |
| 10177 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10178 | SHOW_STR |
| 10179 | IP_STR |
| 10180 | BGP_STR |
| 10181 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10182 | "Neighbor to display information about\n" |
| 10183 | "Neighbor to display information about\n" |
| 10184 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10185 | |
| 10186 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 10187 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 10188 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10189 | SHOW_STR |
| 10190 | IP_STR |
| 10191 | BGP_STR |
| 10192 | "Address family\n" |
| 10193 | "Address Family modifier\n" |
| 10194 | "Address Family modifier\n" |
| 10195 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10196 | "Neighbor to display information about\n" |
| 10197 | "Neighbor to display information about\n" |
| 10198 | "Display the received routes from neighbor\n") |
| 10199 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10200 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10201 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10202 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10203 | if (! peer) |
| 10204 | return CMD_WARNING; |
| 10205 | |
| 10206 | if (strncmp (argv[0], "m", 1) == 0) |
| 10207 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 10208 | |
| 10209 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10210 | } |
| 10211 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10212 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 10213 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
| 10214 | #ifdef HAVE_IPV6 |
| 10215 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
| 10216 | #else |
| 10217 | "show bgp view WORD ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
| 10218 | #endif |
| 10219 | SHOW_STR |
| 10220 | BGP_STR |
| 10221 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10222 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10223 | "Address family\n" |
| 10224 | #ifdef HAVE_IPV6 |
| 10225 | "Address family\n" |
| 10226 | #endif |
| 10227 | "Address family modifier\n" |
| 10228 | "Address family modifier\n" |
| 10229 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10230 | "Neighbor to display information about\n" |
| 10231 | "Neighbor to display information about\n" |
| 10232 | "Display the advertised routes to neighbor\n" |
| 10233 | "Display the received routes from neighbor\n") |
| 10234 | { |
| 10235 | int afi; |
| 10236 | int safi; |
| 10237 | int in; |
| 10238 | struct peer *peer; |
| 10239 | |
| 10240 | #ifdef HAVE_IPV6 |
| 10241 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
| 10242 | #else |
| 10243 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10244 | #endif |
| 10245 | |
| 10246 | if (! peer) |
| 10247 | return CMD_WARNING; |
| 10248 | |
| 10249 | #ifdef HAVE_IPV6 |
| 10250 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10251 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10252 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
| 10253 | #else |
| 10254 | afi = AFI_IP; |
| 10255 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10256 | in = (strncmp (argv[3], "r", 1) == 0) ? 1 : 0; |
| 10257 | #endif |
| 10258 | |
| 10259 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 10260 | } |
| 10261 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10262 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 10263 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 10264 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10265 | SHOW_STR |
| 10266 | IP_STR |
| 10267 | BGP_STR |
| 10268 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10269 | "Neighbor to display information about\n" |
| 10270 | "Neighbor to display information about\n" |
| 10271 | "Display information received from a BGP neighbor\n" |
| 10272 | "Display the prefixlist filter\n") |
| 10273 | { |
| 10274 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10275 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10276 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10277 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10278 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10279 | ret = str2sockunion (argv[0], &su); |
| 10280 | if (ret < 0) |
| 10281 | { |
| 10282 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10283 | return CMD_WARNING; |
| 10284 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10285 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10286 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10287 | if (! peer) |
| 10288 | return CMD_WARNING; |
| 10289 | |
| 10290 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10291 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10292 | if (count) |
| 10293 | { |
| 10294 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10295 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10296 | } |
| 10297 | |
| 10298 | return CMD_SUCCESS; |
| 10299 | } |
| 10300 | |
| 10301 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 10302 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 10303 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10304 | SHOW_STR |
| 10305 | IP_STR |
| 10306 | BGP_STR |
| 10307 | "Address family\n" |
| 10308 | "Address Family modifier\n" |
| 10309 | "Address Family modifier\n" |
| 10310 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10311 | "Neighbor to display information about\n" |
| 10312 | "Neighbor to display information about\n" |
| 10313 | "Display information received from a BGP neighbor\n" |
| 10314 | "Display the prefixlist filter\n") |
| 10315 | { |
| 10316 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10317 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10318 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10319 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10320 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10321 | ret = str2sockunion (argv[1], &su); |
| 10322 | if (ret < 0) |
| 10323 | { |
| 10324 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10325 | return CMD_WARNING; |
| 10326 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10327 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10328 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10329 | if (! peer) |
| 10330 | return CMD_WARNING; |
| 10331 | |
| 10332 | if (strncmp (argv[0], "m", 1) == 0) |
| 10333 | { |
| 10334 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 10335 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10336 | if (count) |
| 10337 | { |
| 10338 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 10339 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10340 | } |
| 10341 | } |
| 10342 | else |
| 10343 | { |
| 10344 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10345 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10346 | if (count) |
| 10347 | { |
| 10348 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10349 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10350 | } |
| 10351 | } |
| 10352 | |
| 10353 | return CMD_SUCCESS; |
| 10354 | } |
| 10355 | |
| 10356 | |
| 10357 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10358 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10359 | show_bgp_neighbor_received_routes_cmd, |
| 10360 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10361 | SHOW_STR |
| 10362 | BGP_STR |
| 10363 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10364 | "Neighbor to display information about\n" |
| 10365 | "Neighbor to display information about\n" |
| 10366 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10367 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10368 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10369 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 10370 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10371 | SHOW_STR |
| 10372 | BGP_STR |
| 10373 | "Address family\n" |
| 10374 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10375 | "Neighbor to display information about\n" |
| 10376 | "Neighbor to display information about\n" |
| 10377 | "Display the received routes from neighbor\n") |
| 10378 | |
| 10379 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 10380 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 10381 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10382 | SHOW_STR |
| 10383 | BGP_STR |
| 10384 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10385 | "Neighbor to display information about\n" |
| 10386 | "Neighbor to display information about\n" |
| 10387 | "Display information received from a BGP neighbor\n" |
| 10388 | "Display the prefixlist filter\n") |
| 10389 | { |
| 10390 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10391 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10392 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10393 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10394 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10395 | ret = str2sockunion (argv[0], &su); |
| 10396 | if (ret < 0) |
| 10397 | { |
| 10398 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10399 | return CMD_WARNING; |
| 10400 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10401 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10402 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10403 | if (! peer) |
| 10404 | return CMD_WARNING; |
| 10405 | |
| 10406 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10407 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10408 | if (count) |
| 10409 | { |
| 10410 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10411 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10412 | } |
| 10413 | |
| 10414 | return CMD_SUCCESS; |
| 10415 | } |
| 10416 | |
| 10417 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 10418 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 10419 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10420 | SHOW_STR |
| 10421 | BGP_STR |
| 10422 | "Address family\n" |
| 10423 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10424 | "Neighbor to display information about\n" |
| 10425 | "Neighbor to display information about\n" |
| 10426 | "Display information received from a BGP neighbor\n" |
| 10427 | "Display the prefixlist filter\n") |
| 10428 | |
| 10429 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10430 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10431 | ipv6_bgp_neighbor_received_routes_cmd, |
| 10432 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10433 | SHOW_STR |
| 10434 | IPV6_STR |
| 10435 | BGP_STR |
| 10436 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10437 | "Neighbor to display information about\n" |
| 10438 | "Neighbor to display information about\n" |
| 10439 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10440 | |
| 10441 | /* old command */ |
| 10442 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 10443 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 10444 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10445 | SHOW_STR |
| 10446 | IPV6_STR |
| 10447 | MBGP_STR |
| 10448 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10449 | "Neighbor to display information about\n" |
| 10450 | "Neighbor to display information about\n" |
| 10451 | "Display the received routes from neighbor\n") |
| 10452 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10453 | struct peer *peer; |
| 10454 | |
| 10455 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10456 | if (! peer) |
| 10457 | return CMD_WARNING; |
| 10458 | |
| 10459 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10460 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10461 | |
| 10462 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 10463 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 10464 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10465 | SHOW_STR |
| 10466 | BGP_STR |
| 10467 | "BGP view\n" |
| 10468 | "View name\n" |
| 10469 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10470 | "Neighbor to display information about\n" |
| 10471 | "Neighbor to display information about\n" |
| 10472 | "Display information received from a BGP neighbor\n" |
| 10473 | "Display the prefixlist filter\n") |
| 10474 | { |
| 10475 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10476 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10477 | struct peer *peer; |
| 10478 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10479 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10480 | |
| 10481 | /* BGP structure lookup. */ |
| 10482 | bgp = bgp_lookup_by_name (argv[0]); |
| 10483 | if (bgp == NULL) |
| 10484 | { |
| 10485 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10486 | return CMD_WARNING; |
| 10487 | } |
| 10488 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10489 | ret = str2sockunion (argv[1], &su); |
| 10490 | if (ret < 0) |
| 10491 | { |
| 10492 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10493 | return CMD_WARNING; |
| 10494 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10495 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10496 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10497 | if (! peer) |
| 10498 | return CMD_WARNING; |
| 10499 | |
| 10500 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10501 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10502 | if (count) |
| 10503 | { |
| 10504 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10505 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10506 | } |
| 10507 | |
| 10508 | return CMD_SUCCESS; |
| 10509 | } |
| 10510 | |
| 10511 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 10512 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 10513 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10514 | SHOW_STR |
| 10515 | BGP_STR |
| 10516 | "BGP view\n" |
| 10517 | "View name\n" |
| 10518 | "Address family\n" |
| 10519 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10520 | "Neighbor to display information about\n" |
| 10521 | "Neighbor to display information about\n" |
| 10522 | "Display information received from a BGP neighbor\n" |
| 10523 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10524 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 10525 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10526 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10527 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10528 | safi_t safi, enum bgp_show_type type) |
| 10529 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10530 | if (! peer || ! peer->afc[afi][safi]) |
| 10531 | { |
| 10532 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10533 | return CMD_WARNING; |
| 10534 | } |
| 10535 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10536 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10537 | } |
| 10538 | |
| 10539 | DEFUN (show_ip_bgp_neighbor_routes, |
| 10540 | show_ip_bgp_neighbor_routes_cmd, |
| 10541 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10542 | SHOW_STR |
| 10543 | IP_STR |
| 10544 | BGP_STR |
| 10545 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10546 | "Neighbor to display information about\n" |
| 10547 | "Neighbor to display information about\n" |
| 10548 | "Display routes learned from neighbor\n") |
| 10549 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10550 | struct peer *peer; |
| 10551 | |
| 10552 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10553 | if (! peer) |
| 10554 | return CMD_WARNING; |
| 10555 | |
| 10556 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10557 | bgp_show_type_neighbor); |
| 10558 | } |
| 10559 | |
| 10560 | DEFUN (show_ip_bgp_neighbor_flap, |
| 10561 | show_ip_bgp_neighbor_flap_cmd, |
| 10562 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10563 | SHOW_STR |
| 10564 | IP_STR |
| 10565 | BGP_STR |
| 10566 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10567 | "Neighbor to display information about\n" |
| 10568 | "Neighbor to display information about\n" |
| 10569 | "Display flap statistics of the routes learned from neighbor\n") |
| 10570 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10571 | struct peer *peer; |
| 10572 | |
| 10573 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10574 | if (! peer) |
| 10575 | return CMD_WARNING; |
| 10576 | |
| 10577 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10578 | bgp_show_type_flap_neighbor); |
| 10579 | } |
| 10580 | |
| 10581 | DEFUN (show_ip_bgp_neighbor_damp, |
| 10582 | show_ip_bgp_neighbor_damp_cmd, |
| 10583 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10584 | SHOW_STR |
| 10585 | IP_STR |
| 10586 | BGP_STR |
| 10587 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10588 | "Neighbor to display information about\n" |
| 10589 | "Neighbor to display information about\n" |
| 10590 | "Display the dampened routes received from neighbor\n") |
| 10591 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10592 | struct peer *peer; |
| 10593 | |
| 10594 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10595 | if (! peer) |
| 10596 | return CMD_WARNING; |
| 10597 | |
| 10598 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10599 | bgp_show_type_damp_neighbor); |
| 10600 | } |
| 10601 | |
| 10602 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 10603 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 10604 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 10605 | SHOW_STR |
| 10606 | IP_STR |
| 10607 | BGP_STR |
| 10608 | "Address family\n" |
| 10609 | "Address Family modifier\n" |
| 10610 | "Address Family modifier\n" |
| 10611 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10612 | "Neighbor to display information about\n" |
| 10613 | "Neighbor to display information about\n" |
| 10614 | "Display routes learned from neighbor\n") |
| 10615 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10616 | struct peer *peer; |
| 10617 | |
| 10618 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10619 | if (! peer) |
| 10620 | return CMD_WARNING; |
| 10621 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10622 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10623 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
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 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10627 | bgp_show_type_neighbor); |
| 10628 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10629 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10630 | DEFUN (show_ip_bgp_view_rsclient, |
| 10631 | show_ip_bgp_view_rsclient_cmd, |
| 10632 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 10633 | SHOW_STR |
| 10634 | IP_STR |
| 10635 | BGP_STR |
| 10636 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10637 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10638 | "Information about Route Server Client\n" |
| 10639 | NEIGHBOR_ADDR_STR) |
| 10640 | { |
| 10641 | struct bgp_table *table; |
| 10642 | struct peer *peer; |
| 10643 | |
| 10644 | if (argc == 2) |
| 10645 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10646 | else |
| 10647 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10648 | |
| 10649 | if (! peer) |
| 10650 | return CMD_WARNING; |
| 10651 | |
| 10652 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10653 | { |
| 10654 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10655 | VTY_NEWLINE); |
| 10656 | return CMD_WARNING; |
| 10657 | } |
| 10658 | |
| 10659 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10660 | PEER_FLAG_RSERVER_CLIENT)) |
| 10661 | { |
| 10662 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10663 | VTY_NEWLINE); |
| 10664 | return CMD_WARNING; |
| 10665 | } |
| 10666 | |
| 10667 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 10668 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10669 | 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] | 10670 | } |
| 10671 | |
| 10672 | ALIAS (show_ip_bgp_view_rsclient, |
| 10673 | show_ip_bgp_rsclient_cmd, |
| 10674 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 10675 | SHOW_STR |
| 10676 | IP_STR |
| 10677 | BGP_STR |
| 10678 | "Information about Route Server Client\n" |
| 10679 | NEIGHBOR_ADDR_STR) |
| 10680 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10681 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 10682 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 10683 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10684 | SHOW_STR |
| 10685 | BGP_STR |
| 10686 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10687 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10688 | "Address family\n" |
| 10689 | "Address Family modifier\n" |
| 10690 | "Address Family modifier\n" |
| 10691 | "Information about Route Server Client\n" |
| 10692 | NEIGHBOR_ADDR_STR) |
| 10693 | { |
| 10694 | struct bgp_table *table; |
| 10695 | struct peer *peer; |
| 10696 | safi_t safi; |
| 10697 | |
| 10698 | if (argc == 3) { |
| 10699 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10700 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10701 | } else { |
| 10702 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10703 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10704 | } |
| 10705 | |
| 10706 | if (! peer) |
| 10707 | return CMD_WARNING; |
| 10708 | |
| 10709 | if (! peer->afc[AFI_IP][safi]) |
| 10710 | { |
| 10711 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10712 | VTY_NEWLINE); |
| 10713 | return CMD_WARNING; |
| 10714 | } |
| 10715 | |
| 10716 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10717 | PEER_FLAG_RSERVER_CLIENT)) |
| 10718 | { |
| 10719 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10720 | VTY_NEWLINE); |
| 10721 | return CMD_WARNING; |
| 10722 | } |
| 10723 | |
| 10724 | table = peer->rib[AFI_IP][safi]; |
| 10725 | |
| 10726 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 10727 | } |
| 10728 | |
| 10729 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 10730 | show_bgp_ipv4_safi_rsclient_cmd, |
| 10731 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10732 | SHOW_STR |
| 10733 | BGP_STR |
| 10734 | "Address family\n" |
| 10735 | "Address Family modifier\n" |
| 10736 | "Address Family modifier\n" |
| 10737 | "Information about Route Server Client\n" |
| 10738 | NEIGHBOR_ADDR_STR) |
| 10739 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10740 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 10741 | show_ip_bgp_view_rsclient_route_cmd, |
Michael Lambert | a8bf6f5 | 2008-09-24 17:23:11 +0100 | [diff] [blame] | 10742 | "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] | 10743 | SHOW_STR |
| 10744 | IP_STR |
| 10745 | BGP_STR |
| 10746 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10747 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10748 | "Information about Route Server Client\n" |
| 10749 | NEIGHBOR_ADDR_STR |
| 10750 | "Network in the BGP routing table to display\n") |
| 10751 | { |
| 10752 | struct bgp *bgp; |
| 10753 | struct peer *peer; |
| 10754 | |
| 10755 | /* BGP structure lookup. */ |
| 10756 | if (argc == 3) |
| 10757 | { |
| 10758 | bgp = bgp_lookup_by_name (argv[0]); |
| 10759 | if (bgp == NULL) |
| 10760 | { |
| 10761 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10762 | return CMD_WARNING; |
| 10763 | } |
| 10764 | } |
| 10765 | else |
| 10766 | { |
| 10767 | bgp = bgp_get_default (); |
| 10768 | if (bgp == NULL) |
| 10769 | { |
| 10770 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10771 | return CMD_WARNING; |
| 10772 | } |
| 10773 | } |
| 10774 | |
| 10775 | if (argc == 3) |
| 10776 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10777 | else |
| 10778 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10779 | |
| 10780 | if (! peer) |
| 10781 | return CMD_WARNING; |
| 10782 | |
| 10783 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10784 | { |
| 10785 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10786 | VTY_NEWLINE); |
| 10787 | return CMD_WARNING; |
| 10788 | } |
| 10789 | |
| 10790 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10791 | PEER_FLAG_RSERVER_CLIENT)) |
| 10792 | { |
| 10793 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10794 | VTY_NEWLINE); |
| 10795 | return CMD_WARNING; |
| 10796 | } |
| 10797 | |
| 10798 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10799 | (argc == 3) ? argv[2] : argv[1], |
| 10800 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 10801 | } |
| 10802 | |
| 10803 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 10804 | show_ip_bgp_rsclient_route_cmd, |
| 10805 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10806 | SHOW_STR |
| 10807 | IP_STR |
| 10808 | BGP_STR |
| 10809 | "Information about Route Server Client\n" |
| 10810 | NEIGHBOR_ADDR_STR |
| 10811 | "Network in the BGP routing table to display\n") |
| 10812 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10813 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 10814 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 10815 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10816 | SHOW_STR |
| 10817 | BGP_STR |
| 10818 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10819 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10820 | "Address family\n" |
| 10821 | "Address Family modifier\n" |
| 10822 | "Address Family modifier\n" |
| 10823 | "Information about Route Server Client\n" |
| 10824 | NEIGHBOR_ADDR_STR |
| 10825 | "Network in the BGP routing table to display\n") |
| 10826 | { |
| 10827 | struct bgp *bgp; |
| 10828 | struct peer *peer; |
| 10829 | safi_t safi; |
| 10830 | |
| 10831 | /* BGP structure lookup. */ |
| 10832 | if (argc == 4) |
| 10833 | { |
| 10834 | bgp = bgp_lookup_by_name (argv[0]); |
| 10835 | if (bgp == NULL) |
| 10836 | { |
| 10837 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10838 | return CMD_WARNING; |
| 10839 | } |
| 10840 | } |
| 10841 | else |
| 10842 | { |
| 10843 | bgp = bgp_get_default (); |
| 10844 | if (bgp == NULL) |
| 10845 | { |
| 10846 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10847 | return CMD_WARNING; |
| 10848 | } |
| 10849 | } |
| 10850 | |
| 10851 | if (argc == 4) { |
| 10852 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10853 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10854 | } else { |
| 10855 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10856 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10857 | } |
| 10858 | |
| 10859 | if (! peer) |
| 10860 | return CMD_WARNING; |
| 10861 | |
| 10862 | if (! peer->afc[AFI_IP][safi]) |
| 10863 | { |
| 10864 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10865 | VTY_NEWLINE); |
| 10866 | return CMD_WARNING; |
| 10867 | } |
| 10868 | |
| 10869 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10870 | PEER_FLAG_RSERVER_CLIENT)) |
| 10871 | { |
| 10872 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10873 | VTY_NEWLINE); |
| 10874 | return CMD_WARNING; |
| 10875 | } |
| 10876 | |
| 10877 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10878 | (argc == 4) ? argv[3] : argv[2], |
| 10879 | AFI_IP, safi, NULL, 0); |
| 10880 | } |
| 10881 | |
| 10882 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 10883 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 10884 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10885 | SHOW_STR |
| 10886 | BGP_STR |
| 10887 | "Address family\n" |
| 10888 | "Address Family modifier\n" |
| 10889 | "Address Family modifier\n" |
| 10890 | "Information about Route Server Client\n" |
| 10891 | NEIGHBOR_ADDR_STR |
| 10892 | "Network in the BGP routing table to display\n") |
| 10893 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10894 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 10895 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 10896 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10897 | SHOW_STR |
| 10898 | IP_STR |
| 10899 | BGP_STR |
| 10900 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10901 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10902 | "Information about Route Server Client\n" |
| 10903 | NEIGHBOR_ADDR_STR |
| 10904 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10905 | { |
| 10906 | struct bgp *bgp; |
| 10907 | struct peer *peer; |
| 10908 | |
| 10909 | /* BGP structure lookup. */ |
| 10910 | if (argc == 3) |
| 10911 | { |
| 10912 | bgp = bgp_lookup_by_name (argv[0]); |
| 10913 | if (bgp == NULL) |
| 10914 | { |
| 10915 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10916 | return CMD_WARNING; |
| 10917 | } |
| 10918 | } |
| 10919 | else |
| 10920 | { |
| 10921 | bgp = bgp_get_default (); |
| 10922 | if (bgp == NULL) |
| 10923 | { |
| 10924 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10925 | return CMD_WARNING; |
| 10926 | } |
| 10927 | } |
| 10928 | |
| 10929 | if (argc == 3) |
| 10930 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10931 | else |
| 10932 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10933 | |
| 10934 | if (! peer) |
| 10935 | return CMD_WARNING; |
| 10936 | |
| 10937 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10938 | { |
| 10939 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10940 | VTY_NEWLINE); |
| 10941 | return CMD_WARNING; |
| 10942 | } |
| 10943 | |
| 10944 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10945 | PEER_FLAG_RSERVER_CLIENT)) |
| 10946 | { |
| 10947 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10948 | VTY_NEWLINE); |
| 10949 | return CMD_WARNING; |
| 10950 | } |
| 10951 | |
| 10952 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10953 | (argc == 3) ? argv[2] : argv[1], |
| 10954 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 10955 | } |
| 10956 | |
| 10957 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 10958 | show_ip_bgp_rsclient_prefix_cmd, |
| 10959 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10960 | SHOW_STR |
| 10961 | IP_STR |
| 10962 | BGP_STR |
| 10963 | "Information about Route Server Client\n" |
| 10964 | NEIGHBOR_ADDR_STR |
| 10965 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10966 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10967 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 10968 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 10969 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10970 | SHOW_STR |
| 10971 | BGP_STR |
| 10972 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10973 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10974 | "Address family\n" |
| 10975 | "Address Family modifier\n" |
| 10976 | "Address Family modifier\n" |
| 10977 | "Information about Route Server Client\n" |
| 10978 | NEIGHBOR_ADDR_STR |
| 10979 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10980 | { |
| 10981 | struct bgp *bgp; |
| 10982 | struct peer *peer; |
| 10983 | safi_t safi; |
| 10984 | |
| 10985 | /* BGP structure lookup. */ |
| 10986 | if (argc == 4) |
| 10987 | { |
| 10988 | bgp = bgp_lookup_by_name (argv[0]); |
| 10989 | if (bgp == NULL) |
| 10990 | { |
| 10991 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10992 | return CMD_WARNING; |
| 10993 | } |
| 10994 | } |
| 10995 | else |
| 10996 | { |
| 10997 | bgp = bgp_get_default (); |
| 10998 | if (bgp == NULL) |
| 10999 | { |
| 11000 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11001 | return CMD_WARNING; |
| 11002 | } |
| 11003 | } |
| 11004 | |
| 11005 | if (argc == 4) { |
| 11006 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11007 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11008 | } else { |
| 11009 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11010 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11011 | } |
| 11012 | |
| 11013 | if (! peer) |
| 11014 | return CMD_WARNING; |
| 11015 | |
| 11016 | if (! peer->afc[AFI_IP][safi]) |
| 11017 | { |
| 11018 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11019 | VTY_NEWLINE); |
| 11020 | return CMD_WARNING; |
| 11021 | } |
| 11022 | |
| 11023 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 11024 | PEER_FLAG_RSERVER_CLIENT)) |
| 11025 | { |
| 11026 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11027 | VTY_NEWLINE); |
| 11028 | return CMD_WARNING; |
| 11029 | } |
| 11030 | |
| 11031 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 11032 | (argc == 4) ? argv[3] : argv[2], |
| 11033 | AFI_IP, safi, NULL, 1); |
| 11034 | } |
| 11035 | |
| 11036 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 11037 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 11038 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11039 | SHOW_STR |
| 11040 | BGP_STR |
| 11041 | "Address family\n" |
| 11042 | "Address Family modifier\n" |
| 11043 | "Address Family modifier\n" |
| 11044 | "Information about Route Server Client\n" |
| 11045 | NEIGHBOR_ADDR_STR |
| 11046 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11047 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11048 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11049 | DEFUN (show_bgp_view_neighbor_routes, |
| 11050 | show_bgp_view_neighbor_routes_cmd, |
| 11051 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 11052 | SHOW_STR |
| 11053 | BGP_STR |
| 11054 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11055 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11056 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11057 | "Neighbor to display information about\n" |
| 11058 | "Neighbor to display information about\n" |
| 11059 | "Display routes learned from neighbor\n") |
| 11060 | { |
| 11061 | struct peer *peer; |
| 11062 | |
| 11063 | if (argc == 2) |
| 11064 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11065 | else |
| 11066 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11067 | |
| 11068 | if (! peer) |
| 11069 | return CMD_WARNING; |
| 11070 | |
| 11071 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11072 | bgp_show_type_neighbor); |
| 11073 | } |
| 11074 | |
| 11075 | ALIAS (show_bgp_view_neighbor_routes, |
| 11076 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 11077 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11078 | SHOW_STR |
| 11079 | BGP_STR |
| 11080 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11081 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11082 | "Address family\n" |
| 11083 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11084 | "Neighbor to display information about\n" |
| 11085 | "Neighbor to display information about\n" |
| 11086 | "Display routes learned from neighbor\n") |
| 11087 | |
| 11088 | DEFUN (show_bgp_view_neighbor_damp, |
| 11089 | show_bgp_view_neighbor_damp_cmd, |
| 11090 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11091 | SHOW_STR |
| 11092 | BGP_STR |
| 11093 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11094 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11095 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11096 | "Neighbor to display information about\n" |
| 11097 | "Neighbor to display information about\n" |
| 11098 | "Display the dampened routes received from neighbor\n") |
| 11099 | { |
| 11100 | struct peer *peer; |
| 11101 | |
| 11102 | if (argc == 2) |
| 11103 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11104 | else |
| 11105 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11106 | |
| 11107 | if (! peer) |
| 11108 | return CMD_WARNING; |
| 11109 | |
| 11110 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11111 | bgp_show_type_damp_neighbor); |
| 11112 | } |
| 11113 | |
| 11114 | ALIAS (show_bgp_view_neighbor_damp, |
| 11115 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 11116 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11117 | SHOW_STR |
| 11118 | BGP_STR |
| 11119 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11120 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11121 | "Address family\n" |
| 11122 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11123 | "Neighbor to display information about\n" |
| 11124 | "Neighbor to display information about\n" |
| 11125 | "Display the dampened routes received from neighbor\n") |
| 11126 | |
| 11127 | DEFUN (show_bgp_view_neighbor_flap, |
| 11128 | show_bgp_view_neighbor_flap_cmd, |
| 11129 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11130 | SHOW_STR |
| 11131 | BGP_STR |
| 11132 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11133 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11134 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11135 | "Neighbor to display information about\n" |
| 11136 | "Neighbor to display information about\n" |
| 11137 | "Display flap statistics of the routes learned from neighbor\n") |
| 11138 | { |
| 11139 | struct peer *peer; |
| 11140 | |
| 11141 | if (argc == 2) |
| 11142 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11143 | else |
| 11144 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11145 | |
| 11146 | if (! peer) |
| 11147 | return CMD_WARNING; |
| 11148 | |
| 11149 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11150 | bgp_show_type_flap_neighbor); |
| 11151 | } |
| 11152 | |
| 11153 | ALIAS (show_bgp_view_neighbor_flap, |
| 11154 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 11155 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11156 | SHOW_STR |
| 11157 | BGP_STR |
| 11158 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11159 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11160 | "Address family\n" |
| 11161 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11162 | "Neighbor to display information about\n" |
| 11163 | "Neighbor to display information about\n" |
| 11164 | "Display flap statistics of the routes learned from neighbor\n") |
| 11165 | |
| 11166 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11167 | show_bgp_neighbor_routes_cmd, |
| 11168 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11169 | SHOW_STR |
| 11170 | BGP_STR |
| 11171 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11172 | "Neighbor to display information about\n" |
| 11173 | "Neighbor to display information about\n" |
| 11174 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11175 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11176 | |
| 11177 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11178 | show_bgp_ipv6_neighbor_routes_cmd, |
| 11179 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11180 | SHOW_STR |
| 11181 | BGP_STR |
| 11182 | "Address family\n" |
| 11183 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11184 | "Neighbor to display information about\n" |
| 11185 | "Neighbor to display information about\n" |
| 11186 | "Display routes learned from neighbor\n") |
| 11187 | |
| 11188 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11189 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11190 | ipv6_bgp_neighbor_routes_cmd, |
| 11191 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11192 | SHOW_STR |
| 11193 | IPV6_STR |
| 11194 | BGP_STR |
| 11195 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11196 | "Neighbor to display information about\n" |
| 11197 | "Neighbor to display information about\n" |
| 11198 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11199 | |
| 11200 | /* old command */ |
| 11201 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 11202 | ipv6_mbgp_neighbor_routes_cmd, |
| 11203 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11204 | SHOW_STR |
| 11205 | IPV6_STR |
| 11206 | MBGP_STR |
| 11207 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11208 | "Neighbor to display information about\n" |
| 11209 | "Neighbor to display information about\n" |
| 11210 | "Display routes learned from neighbor\n") |
| 11211 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11212 | struct peer *peer; |
| 11213 | |
| 11214 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11215 | if (! peer) |
| 11216 | return CMD_WARNING; |
| 11217 | |
| 11218 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11219 | bgp_show_type_neighbor); |
| 11220 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11221 | |
| 11222 | ALIAS (show_bgp_view_neighbor_flap, |
| 11223 | show_bgp_neighbor_flap_cmd, |
| 11224 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11225 | SHOW_STR |
| 11226 | BGP_STR |
| 11227 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11228 | "Neighbor to display information about\n" |
| 11229 | "Neighbor to display information about\n" |
| 11230 | "Display flap statistics of the routes learned from neighbor\n") |
| 11231 | |
| 11232 | ALIAS (show_bgp_view_neighbor_flap, |
| 11233 | show_bgp_ipv6_neighbor_flap_cmd, |
| 11234 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11235 | SHOW_STR |
| 11236 | BGP_STR |
| 11237 | "Address family\n" |
| 11238 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11239 | "Neighbor to display information about\n" |
| 11240 | "Neighbor to display information about\n" |
| 11241 | "Display flap statistics of the routes learned from neighbor\n") |
| 11242 | |
| 11243 | ALIAS (show_bgp_view_neighbor_damp, |
| 11244 | show_bgp_neighbor_damp_cmd, |
| 11245 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11246 | SHOW_STR |
| 11247 | BGP_STR |
| 11248 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11249 | "Neighbor to display information about\n" |
| 11250 | "Neighbor to display information about\n" |
| 11251 | "Display the dampened routes received from neighbor\n") |
| 11252 | |
| 11253 | ALIAS (show_bgp_view_neighbor_damp, |
| 11254 | show_bgp_ipv6_neighbor_damp_cmd, |
| 11255 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11256 | SHOW_STR |
| 11257 | BGP_STR |
| 11258 | "Address family\n" |
| 11259 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11260 | "Neighbor to display information about\n" |
| 11261 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 11262 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11263 | |
| 11264 | DEFUN (show_bgp_view_rsclient, |
| 11265 | show_bgp_view_rsclient_cmd, |
| 11266 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 11267 | SHOW_STR |
| 11268 | BGP_STR |
| 11269 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11270 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11271 | "Information about Route Server Client\n" |
| 11272 | NEIGHBOR_ADDR_STR) |
| 11273 | { |
| 11274 | struct bgp_table *table; |
| 11275 | struct peer *peer; |
| 11276 | |
| 11277 | if (argc == 2) |
| 11278 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11279 | else |
| 11280 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11281 | |
| 11282 | if (! peer) |
| 11283 | return CMD_WARNING; |
| 11284 | |
| 11285 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11286 | { |
| 11287 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11288 | VTY_NEWLINE); |
| 11289 | return CMD_WARNING; |
| 11290 | } |
| 11291 | |
| 11292 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11293 | PEER_FLAG_RSERVER_CLIENT)) |
| 11294 | { |
| 11295 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11296 | VTY_NEWLINE); |
| 11297 | return CMD_WARNING; |
| 11298 | } |
| 11299 | |
| 11300 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 11301 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11302 | 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] | 11303 | } |
| 11304 | |
| 11305 | ALIAS (show_bgp_view_rsclient, |
| 11306 | show_bgp_rsclient_cmd, |
| 11307 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 11308 | SHOW_STR |
| 11309 | BGP_STR |
| 11310 | "Information about Route Server Client\n" |
| 11311 | NEIGHBOR_ADDR_STR) |
| 11312 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11313 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 11314 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 11315 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11316 | SHOW_STR |
| 11317 | BGP_STR |
| 11318 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11319 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11320 | "Address family\n" |
| 11321 | "Address Family modifier\n" |
| 11322 | "Address Family modifier\n" |
| 11323 | "Information about Route Server Client\n" |
| 11324 | NEIGHBOR_ADDR_STR) |
| 11325 | { |
| 11326 | struct bgp_table *table; |
| 11327 | struct peer *peer; |
| 11328 | safi_t safi; |
| 11329 | |
| 11330 | if (argc == 3) { |
| 11331 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11332 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11333 | } else { |
| 11334 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11335 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11336 | } |
| 11337 | |
| 11338 | if (! peer) |
| 11339 | return CMD_WARNING; |
| 11340 | |
| 11341 | if (! peer->afc[AFI_IP6][safi]) |
| 11342 | { |
| 11343 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11344 | VTY_NEWLINE); |
| 11345 | return CMD_WARNING; |
| 11346 | } |
| 11347 | |
| 11348 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11349 | PEER_FLAG_RSERVER_CLIENT)) |
| 11350 | { |
| 11351 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11352 | VTY_NEWLINE); |
| 11353 | return CMD_WARNING; |
| 11354 | } |
| 11355 | |
| 11356 | table = peer->rib[AFI_IP6][safi]; |
| 11357 | |
| 11358 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 11359 | } |
| 11360 | |
| 11361 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 11362 | show_bgp_ipv6_safi_rsclient_cmd, |
| 11363 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11364 | SHOW_STR |
| 11365 | BGP_STR |
| 11366 | "Address family\n" |
| 11367 | "Address Family modifier\n" |
| 11368 | "Address Family modifier\n" |
| 11369 | "Information about Route Server Client\n" |
| 11370 | NEIGHBOR_ADDR_STR) |
| 11371 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11372 | DEFUN (show_bgp_view_rsclient_route, |
| 11373 | show_bgp_view_rsclient_route_cmd, |
| 11374 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11375 | SHOW_STR |
| 11376 | BGP_STR |
| 11377 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11378 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11379 | "Information about Route Server Client\n" |
| 11380 | NEIGHBOR_ADDR_STR |
| 11381 | "Network in the BGP routing table to display\n") |
| 11382 | { |
| 11383 | struct bgp *bgp; |
| 11384 | struct peer *peer; |
| 11385 | |
| 11386 | /* BGP structure lookup. */ |
| 11387 | if (argc == 3) |
| 11388 | { |
| 11389 | bgp = bgp_lookup_by_name (argv[0]); |
| 11390 | if (bgp == NULL) |
| 11391 | { |
| 11392 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11393 | return CMD_WARNING; |
| 11394 | } |
| 11395 | } |
| 11396 | else |
| 11397 | { |
| 11398 | bgp = bgp_get_default (); |
| 11399 | if (bgp == NULL) |
| 11400 | { |
| 11401 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11402 | return CMD_WARNING; |
| 11403 | } |
| 11404 | } |
| 11405 | |
| 11406 | if (argc == 3) |
| 11407 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11408 | else |
| 11409 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11410 | |
| 11411 | if (! peer) |
| 11412 | return CMD_WARNING; |
| 11413 | |
| 11414 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11415 | { |
| 11416 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11417 | VTY_NEWLINE); |
| 11418 | return CMD_WARNING; |
| 11419 | } |
| 11420 | |
| 11421 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11422 | PEER_FLAG_RSERVER_CLIENT)) |
| 11423 | { |
| 11424 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11425 | VTY_NEWLINE); |
| 11426 | return CMD_WARNING; |
| 11427 | } |
| 11428 | |
| 11429 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11430 | (argc == 3) ? argv[2] : argv[1], |
| 11431 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 11432 | } |
| 11433 | |
| 11434 | ALIAS (show_bgp_view_rsclient_route, |
| 11435 | show_bgp_rsclient_route_cmd, |
| 11436 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11437 | SHOW_STR |
| 11438 | BGP_STR |
| 11439 | "Information about Route Server Client\n" |
| 11440 | NEIGHBOR_ADDR_STR |
| 11441 | "Network in the BGP routing table to display\n") |
| 11442 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11443 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 11444 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 11445 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11446 | SHOW_STR |
| 11447 | BGP_STR |
| 11448 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11449 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11450 | "Address family\n" |
| 11451 | "Address Family modifier\n" |
| 11452 | "Address Family modifier\n" |
| 11453 | "Information about Route Server Client\n" |
| 11454 | NEIGHBOR_ADDR_STR |
| 11455 | "Network in the BGP routing table to display\n") |
| 11456 | { |
| 11457 | struct bgp *bgp; |
| 11458 | struct peer *peer; |
| 11459 | safi_t safi; |
| 11460 | |
| 11461 | /* BGP structure lookup. */ |
| 11462 | if (argc == 4) |
| 11463 | { |
| 11464 | bgp = bgp_lookup_by_name (argv[0]); |
| 11465 | if (bgp == NULL) |
| 11466 | { |
| 11467 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11468 | return CMD_WARNING; |
| 11469 | } |
| 11470 | } |
| 11471 | else |
| 11472 | { |
| 11473 | bgp = bgp_get_default (); |
| 11474 | if (bgp == NULL) |
| 11475 | { |
| 11476 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11477 | return CMD_WARNING; |
| 11478 | } |
| 11479 | } |
| 11480 | |
| 11481 | if (argc == 4) { |
| 11482 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11483 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11484 | } else { |
| 11485 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11486 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11487 | } |
| 11488 | |
| 11489 | if (! peer) |
| 11490 | return CMD_WARNING; |
| 11491 | |
| 11492 | if (! peer->afc[AFI_IP6][safi]) |
| 11493 | { |
| 11494 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11495 | VTY_NEWLINE); |
| 11496 | return CMD_WARNING; |
| 11497 | } |
| 11498 | |
| 11499 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11500 | PEER_FLAG_RSERVER_CLIENT)) |
| 11501 | { |
| 11502 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11503 | VTY_NEWLINE); |
| 11504 | return CMD_WARNING; |
| 11505 | } |
| 11506 | |
| 11507 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11508 | (argc == 4) ? argv[3] : argv[2], |
| 11509 | AFI_IP6, safi, NULL, 0); |
| 11510 | } |
| 11511 | |
| 11512 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 11513 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 11514 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11515 | SHOW_STR |
| 11516 | BGP_STR |
| 11517 | "Address family\n" |
| 11518 | "Address Family modifier\n" |
| 11519 | "Address Family modifier\n" |
| 11520 | "Information about Route Server Client\n" |
| 11521 | NEIGHBOR_ADDR_STR |
| 11522 | "Network in the BGP routing table to display\n") |
| 11523 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11524 | DEFUN (show_bgp_view_rsclient_prefix, |
| 11525 | show_bgp_view_rsclient_prefix_cmd, |
| 11526 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11527 | SHOW_STR |
| 11528 | BGP_STR |
| 11529 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11530 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11531 | "Information about Route Server Client\n" |
| 11532 | NEIGHBOR_ADDR_STR |
| 11533 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11534 | { |
| 11535 | struct bgp *bgp; |
| 11536 | struct peer *peer; |
| 11537 | |
| 11538 | /* BGP structure lookup. */ |
| 11539 | if (argc == 3) |
| 11540 | { |
| 11541 | bgp = bgp_lookup_by_name (argv[0]); |
| 11542 | if (bgp == NULL) |
| 11543 | { |
| 11544 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11545 | return CMD_WARNING; |
| 11546 | } |
| 11547 | } |
| 11548 | else |
| 11549 | { |
| 11550 | bgp = bgp_get_default (); |
| 11551 | if (bgp == NULL) |
| 11552 | { |
| 11553 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11554 | return CMD_WARNING; |
| 11555 | } |
| 11556 | } |
| 11557 | |
| 11558 | if (argc == 3) |
| 11559 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11560 | else |
| 11561 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11562 | |
| 11563 | if (! peer) |
| 11564 | return CMD_WARNING; |
| 11565 | |
| 11566 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11567 | { |
| 11568 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11569 | VTY_NEWLINE); |
| 11570 | return CMD_WARNING; |
| 11571 | } |
| 11572 | |
| 11573 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11574 | PEER_FLAG_RSERVER_CLIENT)) |
| 11575 | { |
| 11576 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11577 | VTY_NEWLINE); |
| 11578 | return CMD_WARNING; |
| 11579 | } |
| 11580 | |
| 11581 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11582 | (argc == 3) ? argv[2] : argv[1], |
| 11583 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 11584 | } |
| 11585 | |
| 11586 | ALIAS (show_bgp_view_rsclient_prefix, |
| 11587 | show_bgp_rsclient_prefix_cmd, |
| 11588 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11589 | SHOW_STR |
| 11590 | BGP_STR |
| 11591 | "Information about Route Server Client\n" |
| 11592 | NEIGHBOR_ADDR_STR |
| 11593 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11594 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11595 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11596 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 11597 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11598 | SHOW_STR |
| 11599 | BGP_STR |
| 11600 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11601 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11602 | "Address family\n" |
| 11603 | "Address Family modifier\n" |
| 11604 | "Address Family modifier\n" |
| 11605 | "Information about Route Server Client\n" |
| 11606 | NEIGHBOR_ADDR_STR |
| 11607 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11608 | { |
| 11609 | struct bgp *bgp; |
| 11610 | struct peer *peer; |
| 11611 | safi_t safi; |
| 11612 | |
| 11613 | /* BGP structure lookup. */ |
| 11614 | if (argc == 4) |
| 11615 | { |
| 11616 | bgp = bgp_lookup_by_name (argv[0]); |
| 11617 | if (bgp == NULL) |
| 11618 | { |
| 11619 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11620 | return CMD_WARNING; |
| 11621 | } |
| 11622 | } |
| 11623 | else |
| 11624 | { |
| 11625 | bgp = bgp_get_default (); |
| 11626 | if (bgp == NULL) |
| 11627 | { |
| 11628 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11629 | return CMD_WARNING; |
| 11630 | } |
| 11631 | } |
| 11632 | |
| 11633 | if (argc == 4) { |
| 11634 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11635 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11636 | } else { |
| 11637 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11638 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11639 | } |
| 11640 | |
| 11641 | if (! peer) |
| 11642 | return CMD_WARNING; |
| 11643 | |
| 11644 | if (! peer->afc[AFI_IP6][safi]) |
| 11645 | { |
| 11646 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11647 | VTY_NEWLINE); |
| 11648 | return CMD_WARNING; |
| 11649 | } |
| 11650 | |
| 11651 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11652 | PEER_FLAG_RSERVER_CLIENT)) |
| 11653 | { |
| 11654 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11655 | VTY_NEWLINE); |
| 11656 | return CMD_WARNING; |
| 11657 | } |
| 11658 | |
| 11659 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11660 | (argc == 4) ? argv[3] : argv[2], |
| 11661 | AFI_IP6, safi, NULL, 1); |
| 11662 | } |
| 11663 | |
| 11664 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11665 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 11666 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11667 | SHOW_STR |
| 11668 | BGP_STR |
| 11669 | "Address family\n" |
| 11670 | "Address Family modifier\n" |
| 11671 | "Address Family modifier\n" |
| 11672 | "Information about Route Server Client\n" |
| 11673 | NEIGHBOR_ADDR_STR |
| 11674 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11675 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11676 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11677 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11678 | struct bgp_table *bgp_distance_table; |
| 11679 | |
| 11680 | struct bgp_distance |
| 11681 | { |
| 11682 | /* Distance value for the IP source prefix. */ |
| 11683 | u_char distance; |
| 11684 | |
| 11685 | /* Name of the access-list to be matched. */ |
| 11686 | char *access_list; |
| 11687 | }; |
| 11688 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11689 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 11690 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11691 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 11692 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11693 | } |
| 11694 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11695 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11696 | bgp_distance_free (struct bgp_distance *bdistance) |
| 11697 | { |
| 11698 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 11699 | } |
| 11700 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11701 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11702 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 11703 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11704 | { |
| 11705 | int ret; |
| 11706 | struct prefix_ipv4 p; |
| 11707 | u_char distance; |
| 11708 | struct bgp_node *rn; |
| 11709 | struct bgp_distance *bdistance; |
| 11710 | |
| 11711 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11712 | if (ret == 0) |
| 11713 | { |
| 11714 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11715 | return CMD_WARNING; |
| 11716 | } |
| 11717 | |
| 11718 | distance = atoi (distance_str); |
| 11719 | |
| 11720 | /* Get BGP distance node. */ |
| 11721 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 11722 | if (rn->info) |
| 11723 | { |
| 11724 | bdistance = rn->info; |
| 11725 | bgp_unlock_node (rn); |
| 11726 | } |
| 11727 | else |
| 11728 | { |
| 11729 | bdistance = bgp_distance_new (); |
| 11730 | rn->info = bdistance; |
| 11731 | } |
| 11732 | |
| 11733 | /* Set distance value. */ |
| 11734 | bdistance->distance = distance; |
| 11735 | |
| 11736 | /* Reset access-list configuration. */ |
| 11737 | if (bdistance->access_list) |
| 11738 | { |
| 11739 | free (bdistance->access_list); |
| 11740 | bdistance->access_list = NULL; |
| 11741 | } |
| 11742 | if (access_list_str) |
| 11743 | bdistance->access_list = strdup (access_list_str); |
| 11744 | |
| 11745 | return CMD_SUCCESS; |
| 11746 | } |
| 11747 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11748 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11749 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 11750 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11751 | { |
| 11752 | int ret; |
| 11753 | struct prefix_ipv4 p; |
| 11754 | u_char distance; |
| 11755 | struct bgp_node *rn; |
| 11756 | struct bgp_distance *bdistance; |
| 11757 | |
| 11758 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11759 | if (ret == 0) |
| 11760 | { |
| 11761 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11762 | return CMD_WARNING; |
| 11763 | } |
| 11764 | |
| 11765 | distance = atoi (distance_str); |
| 11766 | |
| 11767 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 11768 | if (! rn) |
| 11769 | { |
| 11770 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 11771 | return CMD_WARNING; |
| 11772 | } |
| 11773 | |
| 11774 | bdistance = rn->info; |
| 11775 | |
| 11776 | if (bdistance->access_list) |
| 11777 | free (bdistance->access_list); |
| 11778 | bgp_distance_free (bdistance); |
| 11779 | |
| 11780 | rn->info = NULL; |
| 11781 | bgp_unlock_node (rn); |
| 11782 | bgp_unlock_node (rn); |
| 11783 | |
| 11784 | return CMD_SUCCESS; |
| 11785 | } |
| 11786 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11787 | /* Apply BGP information to distance method. */ |
| 11788 | u_char |
| 11789 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 11790 | { |
| 11791 | struct bgp_node *rn; |
| 11792 | struct prefix_ipv4 q; |
| 11793 | struct peer *peer; |
| 11794 | struct bgp_distance *bdistance; |
| 11795 | struct access_list *alist; |
| 11796 | struct bgp_static *bgp_static; |
| 11797 | |
| 11798 | if (! bgp) |
| 11799 | return 0; |
| 11800 | |
| 11801 | if (p->family != AF_INET) |
| 11802 | return 0; |
| 11803 | |
| 11804 | peer = rinfo->peer; |
| 11805 | |
| 11806 | if (peer->su.sa.sa_family != AF_INET) |
| 11807 | return 0; |
| 11808 | |
| 11809 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 11810 | q.family = AF_INET; |
| 11811 | q.prefix = peer->su.sin.sin_addr; |
| 11812 | q.prefixlen = IPV4_MAX_BITLEN; |
| 11813 | |
| 11814 | /* Check source address. */ |
| 11815 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 11816 | if (rn) |
| 11817 | { |
| 11818 | bdistance = rn->info; |
| 11819 | bgp_unlock_node (rn); |
| 11820 | |
| 11821 | if (bdistance->access_list) |
| 11822 | { |
| 11823 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 11824 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 11825 | return bdistance->distance; |
| 11826 | } |
| 11827 | else |
| 11828 | return bdistance->distance; |
| 11829 | } |
| 11830 | |
| 11831 | /* Backdoor check. */ |
| 11832 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 11833 | if (rn) |
| 11834 | { |
| 11835 | bgp_static = rn->info; |
| 11836 | bgp_unlock_node (rn); |
| 11837 | |
| 11838 | if (bgp_static->backdoor) |
| 11839 | { |
| 11840 | if (bgp->distance_local) |
| 11841 | return bgp->distance_local; |
| 11842 | else |
| 11843 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11844 | } |
| 11845 | } |
| 11846 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 11847 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11848 | { |
| 11849 | if (bgp->distance_ebgp) |
| 11850 | return bgp->distance_ebgp; |
| 11851 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 11852 | } |
| 11853 | else |
| 11854 | { |
| 11855 | if (bgp->distance_ibgp) |
| 11856 | return bgp->distance_ibgp; |
| 11857 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11858 | } |
| 11859 | } |
| 11860 | |
| 11861 | DEFUN (bgp_distance, |
| 11862 | bgp_distance_cmd, |
| 11863 | "distance bgp <1-255> <1-255> <1-255>", |
| 11864 | "Define an administrative distance\n" |
| 11865 | "BGP distance\n" |
| 11866 | "Distance for routes external to the AS\n" |
| 11867 | "Distance for routes internal to the AS\n" |
| 11868 | "Distance for local routes\n") |
| 11869 | { |
| 11870 | struct bgp *bgp; |
| 11871 | |
| 11872 | bgp = vty->index; |
| 11873 | |
| 11874 | bgp->distance_ebgp = atoi (argv[0]); |
| 11875 | bgp->distance_ibgp = atoi (argv[1]); |
| 11876 | bgp->distance_local = atoi (argv[2]); |
| 11877 | return CMD_SUCCESS; |
| 11878 | } |
| 11879 | |
| 11880 | DEFUN (no_bgp_distance, |
| 11881 | no_bgp_distance_cmd, |
| 11882 | "no distance bgp <1-255> <1-255> <1-255>", |
| 11883 | NO_STR |
| 11884 | "Define an administrative distance\n" |
| 11885 | "BGP distance\n" |
| 11886 | "Distance for routes external to the AS\n" |
| 11887 | "Distance for routes internal to the AS\n" |
| 11888 | "Distance for local routes\n") |
| 11889 | { |
| 11890 | struct bgp *bgp; |
| 11891 | |
| 11892 | bgp = vty->index; |
| 11893 | |
| 11894 | bgp->distance_ebgp= 0; |
| 11895 | bgp->distance_ibgp = 0; |
| 11896 | bgp->distance_local = 0; |
| 11897 | return CMD_SUCCESS; |
| 11898 | } |
| 11899 | |
| 11900 | ALIAS (no_bgp_distance, |
| 11901 | no_bgp_distance2_cmd, |
| 11902 | "no distance bgp", |
| 11903 | NO_STR |
| 11904 | "Define an administrative distance\n" |
| 11905 | "BGP distance\n") |
| 11906 | |
| 11907 | DEFUN (bgp_distance_source, |
| 11908 | bgp_distance_source_cmd, |
| 11909 | "distance <1-255> A.B.C.D/M", |
| 11910 | "Define an administrative distance\n" |
| 11911 | "Administrative distance\n" |
| 11912 | "IP source prefix\n") |
| 11913 | { |
| 11914 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 11915 | return CMD_SUCCESS; |
| 11916 | } |
| 11917 | |
| 11918 | DEFUN (no_bgp_distance_source, |
| 11919 | no_bgp_distance_source_cmd, |
| 11920 | "no distance <1-255> A.B.C.D/M", |
| 11921 | NO_STR |
| 11922 | "Define an administrative distance\n" |
| 11923 | "Administrative distance\n" |
| 11924 | "IP source prefix\n") |
| 11925 | { |
| 11926 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 11927 | return CMD_SUCCESS; |
| 11928 | } |
| 11929 | |
| 11930 | DEFUN (bgp_distance_source_access_list, |
| 11931 | bgp_distance_source_access_list_cmd, |
| 11932 | "distance <1-255> A.B.C.D/M WORD", |
| 11933 | "Define an administrative distance\n" |
| 11934 | "Administrative distance\n" |
| 11935 | "IP source prefix\n" |
| 11936 | "Access list name\n") |
| 11937 | { |
| 11938 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 11939 | return CMD_SUCCESS; |
| 11940 | } |
| 11941 | |
| 11942 | DEFUN (no_bgp_distance_source_access_list, |
| 11943 | no_bgp_distance_source_access_list_cmd, |
| 11944 | "no distance <1-255> A.B.C.D/M WORD", |
| 11945 | NO_STR |
| 11946 | "Define an administrative distance\n" |
| 11947 | "Administrative distance\n" |
| 11948 | "IP source prefix\n" |
| 11949 | "Access list name\n") |
| 11950 | { |
| 11951 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 11952 | return CMD_SUCCESS; |
| 11953 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11954 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11955 | DEFUN (bgp_damp_set, |
| 11956 | bgp_damp_set_cmd, |
| 11957 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 11958 | "BGP Specific commands\n" |
| 11959 | "Enable route-flap dampening\n" |
| 11960 | "Half-life time for the penalty\n" |
| 11961 | "Value to start reusing a route\n" |
| 11962 | "Value to start suppressing a route\n" |
| 11963 | "Maximum duration to suppress a stable route\n") |
| 11964 | { |
| 11965 | struct bgp *bgp; |
| 11966 | int half = DEFAULT_HALF_LIFE * 60; |
| 11967 | int reuse = DEFAULT_REUSE; |
| 11968 | int suppress = DEFAULT_SUPPRESS; |
| 11969 | int max = 4 * half; |
| 11970 | |
| 11971 | if (argc == 4) |
| 11972 | { |
| 11973 | half = atoi (argv[0]) * 60; |
| 11974 | reuse = atoi (argv[1]); |
| 11975 | suppress = atoi (argv[2]); |
| 11976 | max = atoi (argv[3]) * 60; |
| 11977 | } |
| 11978 | else if (argc == 1) |
| 11979 | { |
| 11980 | half = atoi (argv[0]) * 60; |
| 11981 | max = 4 * half; |
| 11982 | } |
| 11983 | |
| 11984 | bgp = vty->index; |
| 11985 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 11986 | half, reuse, suppress, max); |
| 11987 | } |
| 11988 | |
| 11989 | ALIAS (bgp_damp_set, |
| 11990 | bgp_damp_set2_cmd, |
| 11991 | "bgp dampening <1-45>", |
| 11992 | "BGP Specific commands\n" |
| 11993 | "Enable route-flap dampening\n" |
| 11994 | "Half-life time for the penalty\n") |
| 11995 | |
| 11996 | ALIAS (bgp_damp_set, |
| 11997 | bgp_damp_set3_cmd, |
| 11998 | "bgp dampening", |
| 11999 | "BGP Specific commands\n" |
| 12000 | "Enable route-flap dampening\n") |
| 12001 | |
| 12002 | DEFUN (bgp_damp_unset, |
| 12003 | bgp_damp_unset_cmd, |
| 12004 | "no bgp dampening", |
| 12005 | NO_STR |
| 12006 | "BGP Specific commands\n" |
| 12007 | "Enable route-flap dampening\n") |
| 12008 | { |
| 12009 | struct bgp *bgp; |
| 12010 | |
| 12011 | bgp = vty->index; |
| 12012 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 12013 | } |
| 12014 | |
| 12015 | ALIAS (bgp_damp_unset, |
| 12016 | bgp_damp_unset2_cmd, |
| 12017 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 12018 | NO_STR |
| 12019 | "BGP Specific commands\n" |
| 12020 | "Enable route-flap dampening\n" |
| 12021 | "Half-life time for the penalty\n" |
| 12022 | "Value to start reusing a route\n" |
| 12023 | "Value to start suppressing a route\n" |
| 12024 | "Maximum duration to suppress a stable route\n") |
| 12025 | |
| 12026 | DEFUN (show_ip_bgp_dampened_paths, |
| 12027 | show_ip_bgp_dampened_paths_cmd, |
| 12028 | "show ip bgp dampened-paths", |
| 12029 | SHOW_STR |
| 12030 | IP_STR |
| 12031 | BGP_STR |
| 12032 | "Display paths suppressed due to dampening\n") |
| 12033 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12034 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 12035 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12036 | } |
| 12037 | |
| 12038 | DEFUN (show_ip_bgp_flap_statistics, |
| 12039 | show_ip_bgp_flap_statistics_cmd, |
| 12040 | "show ip bgp flap-statistics", |
| 12041 | SHOW_STR |
| 12042 | IP_STR |
| 12043 | BGP_STR |
| 12044 | "Display flap statistics of routes\n") |
| 12045 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12046 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 12047 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12048 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12049 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12050 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12051 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 12052 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 12053 | const char *ip_str, afi_t afi, safi_t safi, |
| 12054 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12055 | { |
| 12056 | int ret; |
| 12057 | struct prefix match; |
| 12058 | struct bgp_node *rn; |
| 12059 | struct bgp_node *rm; |
| 12060 | struct bgp_info *ri; |
| 12061 | struct bgp_info *ri_temp; |
| 12062 | struct bgp *bgp; |
| 12063 | struct bgp_table *table; |
| 12064 | |
| 12065 | /* BGP structure lookup. */ |
| 12066 | if (view_name) |
| 12067 | { |
| 12068 | bgp = bgp_lookup_by_name (view_name); |
| 12069 | if (bgp == NULL) |
| 12070 | { |
| 12071 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 12072 | return CMD_WARNING; |
| 12073 | } |
| 12074 | } |
| 12075 | else |
| 12076 | { |
| 12077 | bgp = bgp_get_default (); |
| 12078 | if (bgp == NULL) |
| 12079 | { |
| 12080 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 12081 | return CMD_WARNING; |
| 12082 | } |
| 12083 | } |
| 12084 | |
| 12085 | /* Check IP address argument. */ |
| 12086 | ret = str2prefix (ip_str, &match); |
| 12087 | if (! ret) |
| 12088 | { |
| 12089 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 12090 | return CMD_WARNING; |
| 12091 | } |
| 12092 | |
| 12093 | match.family = afi2family (afi); |
| 12094 | |
| 12095 | if (safi == SAFI_MPLS_VPN) |
| 12096 | { |
| 12097 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 12098 | { |
| 12099 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 12100 | continue; |
| 12101 | |
| 12102 | if ((table = rn->info) != NULL) |
| 12103 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12104 | { |
| 12105 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 12106 | { |
| 12107 | ri = rm->info; |
| 12108 | while (ri) |
| 12109 | { |
| 12110 | if (ri->extra && ri->extra->damp_info) |
| 12111 | { |
| 12112 | ri_temp = ri->next; |
| 12113 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12114 | ri = ri_temp; |
| 12115 | } |
| 12116 | else |
| 12117 | ri = ri->next; |
| 12118 | } |
| 12119 | } |
| 12120 | |
| 12121 | bgp_unlock_node (rm); |
| 12122 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12123 | } |
| 12124 | } |
| 12125 | else |
| 12126 | { |
| 12127 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12128 | { |
| 12129 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 12130 | { |
| 12131 | ri = rn->info; |
| 12132 | while (ri) |
| 12133 | { |
| 12134 | if (ri->extra && ri->extra->damp_info) |
| 12135 | { |
| 12136 | ri_temp = ri->next; |
| 12137 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12138 | ri = ri_temp; |
| 12139 | } |
| 12140 | else |
| 12141 | ri = ri->next; |
| 12142 | } |
| 12143 | } |
| 12144 | |
| 12145 | bgp_unlock_node (rn); |
| 12146 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12147 | } |
| 12148 | |
| 12149 | return CMD_SUCCESS; |
| 12150 | } |
| 12151 | |
| 12152 | DEFUN (clear_ip_bgp_dampening, |
| 12153 | clear_ip_bgp_dampening_cmd, |
| 12154 | "clear ip bgp dampening", |
| 12155 | CLEAR_STR |
| 12156 | IP_STR |
| 12157 | BGP_STR |
| 12158 | "Clear route flap dampening information\n") |
| 12159 | { |
| 12160 | bgp_damp_info_clean (); |
| 12161 | return CMD_SUCCESS; |
| 12162 | } |
| 12163 | |
| 12164 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 12165 | clear_ip_bgp_dampening_prefix_cmd, |
| 12166 | "clear ip bgp dampening A.B.C.D/M", |
| 12167 | CLEAR_STR |
| 12168 | IP_STR |
| 12169 | BGP_STR |
| 12170 | "Clear route flap dampening information\n" |
| 12171 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 12172 | { |
| 12173 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12174 | SAFI_UNICAST, NULL, 1); |
| 12175 | } |
| 12176 | |
| 12177 | DEFUN (clear_ip_bgp_dampening_address, |
| 12178 | clear_ip_bgp_dampening_address_cmd, |
| 12179 | "clear ip bgp dampening A.B.C.D", |
| 12180 | CLEAR_STR |
| 12181 | IP_STR |
| 12182 | BGP_STR |
| 12183 | "Clear route flap dampening information\n" |
| 12184 | "Network to clear damping information\n") |
| 12185 | { |
| 12186 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12187 | SAFI_UNICAST, NULL, 0); |
| 12188 | } |
| 12189 | |
| 12190 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 12191 | clear_ip_bgp_dampening_address_mask_cmd, |
| 12192 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 12193 | CLEAR_STR |
| 12194 | IP_STR |
| 12195 | BGP_STR |
| 12196 | "Clear route flap dampening information\n" |
| 12197 | "Network to clear damping information\n" |
| 12198 | "Network mask\n") |
| 12199 | { |
| 12200 | int ret; |
| 12201 | char prefix_str[BUFSIZ]; |
| 12202 | |
| 12203 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 12204 | if (! ret) |
| 12205 | { |
| 12206 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 12207 | return CMD_WARNING; |
| 12208 | } |
| 12209 | |
| 12210 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 12211 | SAFI_UNICAST, NULL, 0); |
| 12212 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12213 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12214 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12215 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 12216 | afi_t afi, safi_t safi, int *write) |
| 12217 | { |
| 12218 | struct bgp_node *prn; |
| 12219 | struct bgp_node *rn; |
| 12220 | struct bgp_table *table; |
| 12221 | struct prefix *p; |
| 12222 | struct prefix_rd *prd; |
| 12223 | struct bgp_static *bgp_static; |
| 12224 | u_int32_t label; |
| 12225 | char buf[SU_ADDRSTRLEN]; |
| 12226 | char rdbuf[RD_ADDRSTRLEN]; |
| 12227 | |
| 12228 | /* Network configuration. */ |
| 12229 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 12230 | if ((table = prn->info) != NULL) |
| 12231 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12232 | if ((bgp_static = rn->info) != NULL) |
| 12233 | { |
| 12234 | p = &rn->p; |
| 12235 | prd = (struct prefix_rd *) &prn->p; |
| 12236 | |
| 12237 | /* "address-family" display. */ |
| 12238 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12239 | |
| 12240 | /* "network" configuration display. */ |
| 12241 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 12242 | label = decode_label (bgp_static->tag); |
| 12243 | |
| 12244 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 12245 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12246 | p->prefixlen, |
| 12247 | rdbuf, label); |
| 12248 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12249 | } |
| 12250 | return 0; |
| 12251 | } |
| 12252 | |
| 12253 | /* Configuration of static route announcement and aggregate |
| 12254 | information. */ |
| 12255 | int |
| 12256 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 12257 | afi_t afi, safi_t safi, int *write) |
| 12258 | { |
| 12259 | struct bgp_node *rn; |
| 12260 | struct prefix *p; |
| 12261 | struct bgp_static *bgp_static; |
| 12262 | struct bgp_aggregate *bgp_aggregate; |
| 12263 | char buf[SU_ADDRSTRLEN]; |
| 12264 | |
| 12265 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 12266 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 12267 | |
| 12268 | /* Network configuration. */ |
| 12269 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12270 | if ((bgp_static = rn->info) != NULL) |
| 12271 | { |
| 12272 | p = &rn->p; |
| 12273 | |
| 12274 | /* "address-family" display. */ |
| 12275 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12276 | |
| 12277 | /* "network" configuration display. */ |
| 12278 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12279 | { |
| 12280 | u_int32_t destination; |
| 12281 | struct in_addr netmask; |
| 12282 | |
| 12283 | destination = ntohl (p->u.prefix4.s_addr); |
| 12284 | masklen2ip (p->prefixlen, &netmask); |
| 12285 | vty_out (vty, " network %s", |
| 12286 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 12287 | |
| 12288 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 12289 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 12290 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 12291 | || p->u.prefix4.s_addr == 0) |
| 12292 | { |
| 12293 | /* Natural mask is not display. */ |
| 12294 | } |
| 12295 | else |
| 12296 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 12297 | } |
| 12298 | else |
| 12299 | { |
| 12300 | vty_out (vty, " network %s/%d", |
| 12301 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12302 | p->prefixlen); |
| 12303 | } |
| 12304 | |
| 12305 | if (bgp_static->rmap.name) |
| 12306 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12307 | else |
| 12308 | { |
| 12309 | if (bgp_static->backdoor) |
| 12310 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12311 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12312 | |
| 12313 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12314 | } |
| 12315 | |
| 12316 | /* Aggregate-address configuration. */ |
| 12317 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12318 | if ((bgp_aggregate = rn->info) != NULL) |
| 12319 | { |
| 12320 | p = &rn->p; |
| 12321 | |
| 12322 | /* "address-family" display. */ |
| 12323 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12324 | |
| 12325 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12326 | { |
| 12327 | struct in_addr netmask; |
| 12328 | |
| 12329 | masklen2ip (p->prefixlen, &netmask); |
| 12330 | vty_out (vty, " aggregate-address %s %s", |
| 12331 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12332 | inet_ntoa (netmask)); |
| 12333 | } |
| 12334 | else |
| 12335 | { |
| 12336 | vty_out (vty, " aggregate-address %s/%d", |
| 12337 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12338 | p->prefixlen); |
| 12339 | } |
| 12340 | |
| 12341 | if (bgp_aggregate->as_set) |
| 12342 | vty_out (vty, " as-set"); |
| 12343 | |
| 12344 | if (bgp_aggregate->summary_only) |
| 12345 | vty_out (vty, " summary-only"); |
| 12346 | |
| 12347 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12348 | } |
| 12349 | |
| 12350 | return 0; |
| 12351 | } |
| 12352 | |
| 12353 | int |
| 12354 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 12355 | { |
| 12356 | struct bgp_node *rn; |
| 12357 | struct bgp_distance *bdistance; |
| 12358 | |
| 12359 | /* Distance configuration. */ |
| 12360 | if (bgp->distance_ebgp |
| 12361 | && bgp->distance_ibgp |
| 12362 | && bgp->distance_local |
| 12363 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 12364 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 12365 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 12366 | vty_out (vty, " distance bgp %d %d %d%s", |
| 12367 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 12368 | VTY_NEWLINE); |
| 12369 | |
| 12370 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 12371 | if ((bdistance = rn->info) != NULL) |
| 12372 | { |
| 12373 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 12374 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 12375 | bdistance->access_list ? bdistance->access_list : "", |
| 12376 | VTY_NEWLINE); |
| 12377 | } |
| 12378 | |
| 12379 | return 0; |
| 12380 | } |
| 12381 | |
| 12382 | /* Allocate routing table structure and install commands. */ |
| 12383 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 12384 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12385 | { |
| 12386 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 12387 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12388 | |
| 12389 | /* IPv4 BGP commands. */ |
| 12390 | install_element (BGP_NODE, &bgp_network_cmd); |
| 12391 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 12392 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 12393 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 12394 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 12395 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12396 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 12397 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 12398 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 12399 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 12400 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 12401 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 12402 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 12403 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12404 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12405 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 12406 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 12407 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 12408 | |
| 12409 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 12410 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 12411 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 12412 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12413 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 12414 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 12415 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 12416 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12417 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 12418 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12419 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 12420 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 12421 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 12422 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12423 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12424 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 12425 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12426 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12427 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12428 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12429 | |
| 12430 | /* IPv4 unicast configuration. */ |
| 12431 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 12432 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 12433 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 12434 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 12435 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 12436 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 12437 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12438 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 12439 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 12440 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 12441 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12442 | 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] | 12443 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12444 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 12445 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 12446 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 12447 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12448 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 12449 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 12450 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 12451 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12452 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 12453 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12454 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 12455 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 12456 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 12457 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12458 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12459 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 12460 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12461 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12462 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12463 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12464 | |
| 12465 | /* IPv4 multicast configuration. */ |
| 12466 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 12467 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 12468 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 12469 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 12470 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 12471 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12472 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 12473 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 12474 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 12475 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 12476 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12477 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12478 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 12479 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 12480 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 12481 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12482 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 12483 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 12484 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 12485 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12486 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 12487 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12488 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 12489 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 12490 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 12491 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12492 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12493 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 12494 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12495 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12496 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12497 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12498 | |
| 12499 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 12500 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12501 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12502 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 12503 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12504 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12505 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12506 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12507 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 12508 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12509 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12510 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12511 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12512 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 12513 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 12514 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12515 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 12516 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12517 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12518 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12519 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 12520 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12521 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 12522 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12523 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12524 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12525 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 12526 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12527 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 12528 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 12529 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 12530 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 12531 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12532 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12533 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12534 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12535 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12536 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12537 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12538 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12539 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12540 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 12541 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12542 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12543 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12544 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12545 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12546 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12547 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12548 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 12549 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12550 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12551 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12552 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12553 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12554 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12555 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12556 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12557 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12558 | 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] | 12559 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12560 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12561 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12562 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 12563 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 12564 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 12565 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 12566 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12567 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 12568 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12569 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 12570 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 12571 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 12572 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 12573 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12574 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12575 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12576 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12577 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12578 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12579 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12580 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12581 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12582 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12583 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12584 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12585 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12586 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12587 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12588 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12589 | |
| 12590 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
| 12591 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
| 12592 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12593 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12594 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12595 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 12596 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12597 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12598 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12599 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12600 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 12601 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12602 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 12603 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 12604 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 12605 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 12606 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12607 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12608 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12609 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12610 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12611 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12612 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12613 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12614 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12615 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 12616 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12617 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12618 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12619 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12620 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12621 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12622 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12623 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12624 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12625 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12626 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12627 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12628 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12629 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12630 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12631 | |
| 12632 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 12633 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12634 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12635 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 12636 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12637 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12638 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12639 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12640 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 12641 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12642 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12643 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12644 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12645 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 12646 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 12647 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12648 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 12649 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12650 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12651 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12652 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 12653 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12654 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 12655 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12656 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12657 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12658 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 12659 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12660 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 12661 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 12662 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 12663 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 12664 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12665 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12666 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12667 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12668 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12669 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12670 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12671 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12672 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12673 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 12674 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12675 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12676 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12677 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12678 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12679 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12680 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12681 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 12682 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12683 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12684 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12685 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12686 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12687 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12688 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12689 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12690 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12691 | 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] | 12692 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12693 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12694 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12695 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 12696 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 12697 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 12698 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 12699 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12700 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 12701 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12702 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 12703 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 12704 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 12705 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 12706 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12707 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12708 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12709 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12710 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12711 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12712 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12713 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12714 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12715 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12716 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12717 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12718 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12719 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12720 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12721 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12722 | |
| 12723 | /* BGP dampening clear commands */ |
| 12724 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 12725 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 12726 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 12727 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 12728 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12729 | /* prefix count */ |
| 12730 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 12731 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 12732 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12733 | #ifdef HAVE_IPV6 |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12734 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 12735 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12736 | /* New config IPv6 BGP commands. */ |
| 12737 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 12738 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 12739 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 12740 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 12741 | |
| 12742 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 12743 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 12744 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 12745 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 12746 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 12747 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 12748 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 12749 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12750 | /* Old config IPv6 BGP commands. */ |
| 12751 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 12752 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 12753 | |
| 12754 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 12755 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 12756 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 12757 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 12758 | |
| 12759 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 12760 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12761 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12762 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 12763 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12764 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12765 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 12766 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12767 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12768 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 12769 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12770 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 12771 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12772 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 12773 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12774 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 12775 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12776 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 12777 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12778 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 12779 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 12780 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 12781 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 12782 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 12783 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 12784 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 12785 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 12786 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 12787 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12788 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 12789 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12790 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 12791 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12792 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 12793 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12794 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 12795 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12796 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 12797 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12798 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 12799 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12800 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12801 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12802 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12803 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12804 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 12805 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12806 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12807 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12808 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 12809 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12810 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 12811 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12812 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12813 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12814 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12815 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12816 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12817 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12818 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 12819 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 12820 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 12821 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12822 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 12823 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12824 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12825 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12826 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12827 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12828 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12829 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12830 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12831 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12832 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12833 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12834 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12835 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12836 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12837 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12838 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12839 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12840 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12841 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12842 | |
| 12843 | /* Restricted: |
| 12844 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 12845 | */ |
| 12846 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 12847 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12848 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12849 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
| 12850 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12851 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12852 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 12853 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 12854 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 12855 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 12856 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 12857 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 12858 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 12859 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 12860 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 12861 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12862 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 12863 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12864 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 12865 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12866 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 12867 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12868 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12869 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12870 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12871 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12872 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 12873 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12874 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 12875 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12876 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12877 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12878 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12879 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12880 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12881 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12882 | |
| 12883 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 12884 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12885 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12886 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 12887 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12888 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12889 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 12890 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12891 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12892 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 12893 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12894 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 12895 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12896 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 12897 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12898 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 12899 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12900 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 12901 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12902 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 12903 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 12904 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 12905 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 12906 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 12907 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 12908 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 12909 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 12910 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 12911 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12912 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 12913 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12914 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 12915 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12916 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 12917 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12918 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 12919 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12920 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 12921 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12922 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 12923 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12924 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12925 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12926 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12927 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12928 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 12929 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12930 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12931 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12932 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 12933 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12934 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 12935 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12936 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12937 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12938 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12939 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12940 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12941 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12942 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 12943 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 12944 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 12945 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12946 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 12947 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12948 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12949 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12950 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12951 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12952 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12953 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12954 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12955 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12956 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12957 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12958 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12959 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12960 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12961 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12962 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12963 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12964 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12965 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12966 | |
| 12967 | /* Statistics */ |
| 12968 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
| 12969 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 12970 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
| 12971 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
| 12972 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12973 | /* old command */ |
| 12974 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 12975 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 12976 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 12977 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 12978 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 12979 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 12980 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 12981 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 12982 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 12983 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 12984 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 12985 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 12986 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 12987 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 12988 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 12989 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 12990 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 12991 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 12992 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 12993 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 12994 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 12995 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 12996 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 12997 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 12998 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 12999 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 13000 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 13001 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 13002 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 13003 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 13004 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 13005 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 13006 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 13007 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 13008 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 13009 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13010 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13011 | /* old command */ |
| 13012 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 13013 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 13014 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 13015 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 13016 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 13017 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 13018 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 13019 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 13020 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 13021 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 13022 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 13023 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 13024 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 13025 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 13026 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 13027 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 13028 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 13029 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 13030 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 13031 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 13032 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 13033 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 13034 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 13035 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 13036 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 13037 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 13038 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 13039 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 13040 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 13041 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 13042 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 13043 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 13044 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 13045 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 13046 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 13047 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 13048 | |
| 13049 | /* old command */ |
| 13050 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13051 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13052 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13053 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13054 | |
| 13055 | /* old command */ |
| 13056 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13057 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13058 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13059 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13060 | |
| 13061 | /* old command */ |
| 13062 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13063 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13064 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13065 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13066 | #endif /* HAVE_IPV6 */ |
| 13067 | |
| 13068 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 13069 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 13070 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 13071 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 13072 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 13073 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 13074 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 13075 | |
| 13076 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 13077 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 13078 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 13079 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 13080 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 13081 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 13082 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 13083 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 13084 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 13085 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13086 | |
| 13087 | /* Deprecated AS-Pathlimit commands */ |
| 13088 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 13089 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 13090 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13091 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13092 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13093 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13094 | |
| 13095 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 13096 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13097 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13098 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13099 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13100 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13101 | |
| 13102 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 13103 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 13104 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13105 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13106 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13107 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13108 | |
| 13109 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 13110 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13111 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13112 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13113 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13114 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13115 | |
| 13116 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 13117 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 13118 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13119 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13120 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13121 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13122 | |
| 13123 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 13124 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13125 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13126 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13127 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13128 | 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] | 13129 | |
| 13130 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13131 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 13132 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 13133 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13134 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 13135 | |
| 13136 | void |
| 13137 | bgp_route_finish (void) |
| 13138 | { |
| 13139 | bgp_table_unlock (bgp_distance_table); |
| 13140 | bgp_distance_table = NULL; |
| 13141 | } |