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 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 324 | /* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist |
| 325 | * is preferred, or 0 if they are the same (usually will only occur if |
| 326 | * multipath is enabled */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 327 | static int |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 328 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 329 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 330 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 331 | struct attr *newattr, *existattr; |
| 332 | struct attr_extra *newattre, *existattre; |
| 333 | bgp_peer_sort_t new_sort; |
| 334 | bgp_peer_sort_t exist_sort; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 335 | u_int32_t new_pref; |
| 336 | u_int32_t exist_pref; |
| 337 | u_int32_t new_med; |
| 338 | u_int32_t exist_med; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 339 | u_int32_t new_weight; |
| 340 | u_int32_t exist_weight; |
| 341 | uint32_t newm, existm; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 342 | struct in_addr new_id; |
| 343 | struct in_addr exist_id; |
| 344 | int new_cluster; |
| 345 | int exist_cluster; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 346 | int internal_as_route; |
| 347 | int confed_as_route; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 348 | int ret; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 349 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 350 | /* 0. Null check. */ |
| 351 | if (new == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 352 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 353 | if (exist == NULL) |
| 354 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 Jakma | 6d4742b | 2015-11-25 17:14:37 +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 Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 372 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 383 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 384 | if (new_pref < exist_pref) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 385 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 393 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 394 | if (! (exist->sub_type == BGP_ROUTE_NORMAL)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 395 | return 1; |
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)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +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)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 413 | return 1; |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 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) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 420 | return -1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 421 | if (newhops > exist_hops) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 422 | return 1; |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 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 Jakma | 6d4742b | 2015-11-25 17:14:37 +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 Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 430 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 451 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 452 | if (new_med > exist_med) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 453 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 Jakma | 6d4742b | 2015-11-25 17:14:37 +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 Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 465 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 476 | return -1; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 477 | if (newm > existm) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 478 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 479 | |
| 480 | /* 9. Maximum path check. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 481 | if (bgp_mpath_is_configured (bgp, afi, safi)) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 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 | { |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 485 | /* |
| 486 | * For the two paths, all comparison steps till IGP metric |
| 487 | * have succeeded - including AS_PATH hop count. Since 'bgp |
| 488 | * bestpath as-path multipath-relax' knob is on, we don't need |
| 489 | * an exact match of AS_PATH. Thus, mark the paths are equal. |
| 490 | * That will trigger both these paths to get into the multipath |
| 491 | * array. |
| 492 | */ |
| 493 | return 0; |
Pradosh Mohapatra | 2fdd455 | 2013-09-07 07:02:36 +0000 | [diff] [blame] | 494 | } |
| 495 | else if (new->peer->sort == BGP_PEER_IBGP) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 496 | { |
| 497 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) |
| 498 | return 0; |
| 499 | } |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 500 | else if (new->peer->as == exist->peer->as) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 501 | return 0; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 502 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 503 | |
| 504 | /* 10. If both paths are external, prefer the path that was received |
| 505 | first (the oldest one). This step minimizes route-flap, since a |
| 506 | newer path won't displace an older one, even if it was the |
| 507 | preferred route based on the additional decision criteria below. */ |
| 508 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 509 | && new_sort == BGP_PEER_EBGP |
| 510 | && exist_sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 511 | { |
| 512 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 513 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 514 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 515 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 516 | } |
| 517 | |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 518 | /* 11. Router-ID comparision. */ |
| 519 | /* If one of the paths is "stale", the corresponding peer router-id will |
| 520 | * be 0 and would always win over the other path. If originator id is |
| 521 | * used for the comparision, it will decide which path is better. |
| 522 | */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 523 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 524 | new_id.s_addr = newattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 525 | else |
| 526 | new_id.s_addr = new->peer->remote_id.s_addr; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 527 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 528 | exist_id.s_addr = existattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 529 | else |
| 530 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 531 | |
| 532 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 533 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 534 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 535 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 536 | |
| 537 | /* 12. Cluster length comparision. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 538 | new_cluster = exist_cluster = 0; |
| 539 | |
| 540 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 541 | new_cluster = newattre->cluster->length; |
| 542 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 543 | exist_cluster = existattre->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 544 | |
| 545 | if (new_cluster < exist_cluster) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 546 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 547 | if (new_cluster > exist_cluster) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 548 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 549 | |
| 550 | /* 13. Neighbor address comparision. */ |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 551 | /* Do this only if neither path is "stale" as stale paths do not have |
| 552 | * valid peer information (as the connection may or may not be up). |
| 553 | */ |
| 554 | if (CHECK_FLAG (exist->flags, BGP_INFO_STALE)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 555 | return -1; |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 556 | if (CHECK_FLAG (new->flags, BGP_INFO_STALE)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 557 | return 1; |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 558 | /* locally configured routes to advertise do not have su_remote */ |
| 559 | if (new->peer->su_remote == NULL) |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 560 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 561 | if (exist->peer->su_remote == NULL) |
| 562 | return -1; |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 563 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 564 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 565 | |
| 566 | if (ret == 1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 567 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 568 | if (ret == -1) |
| 569 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 570 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 571 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 572 | } |
| 573 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 574 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 575 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 576 | afi_t afi, safi_t safi) |
| 577 | { |
| 578 | struct bgp_filter *filter; |
| 579 | |
| 580 | filter = &peer->filter[afi][safi]; |
| 581 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 582 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 583 | if (BGP_DEBUG (update, UPDATE_IN) \ |
| 584 | && !(F ## _IN (filter))) \ |
| 585 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ |
| 586 | peer->host, #f, F ## _IN_NAME(filter)); |
| 587 | |
| 588 | if (DISTRIBUTE_IN_NAME (filter)) { |
| 589 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 590 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 591 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 592 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 593 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 594 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 595 | if (PREFIX_LIST_IN_NAME (filter)) { |
| 596 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 597 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 598 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 599 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 600 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 601 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 602 | if (FILTER_LIST_IN_NAME (filter)) { |
| 603 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 604 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 605 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 606 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 607 | } |
| 608 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 609 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 610 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 611 | } |
| 612 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 613 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 614 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 615 | afi_t afi, safi_t safi) |
| 616 | { |
| 617 | struct bgp_filter *filter; |
| 618 | |
| 619 | filter = &peer->filter[afi][safi]; |
| 620 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 621 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 622 | if (BGP_DEBUG (update, UPDATE_OUT) \ |
| 623 | && !(F ## _OUT (filter))) \ |
| 624 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ |
| 625 | peer->host, #f, F ## _OUT_NAME(filter)); |
| 626 | |
| 627 | if (DISTRIBUTE_OUT_NAME (filter)) { |
| 628 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 629 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 630 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 631 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 632 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 633 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 634 | if (PREFIX_LIST_OUT_NAME (filter)) { |
| 635 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 636 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 637 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 638 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 639 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 640 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 641 | if (FILTER_LIST_OUT_NAME (filter)) { |
| 642 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 643 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 644 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 645 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 646 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 647 | |
| 648 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 649 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 653 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 654 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 655 | { |
| 656 | if (attr->community) |
| 657 | { |
| 658 | /* NO_ADVERTISE check. */ |
| 659 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 660 | return 1; |
| 661 | |
| 662 | /* NO_EXPORT check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 663 | if (peer->sort == BGP_PEER_EBGP && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 664 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 665 | return 1; |
| 666 | |
| 667 | /* NO_EXPORT_SUBCONFED check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 668 | if (peer->sort == BGP_PEER_EBGP |
| 669 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 670 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 671 | return 1; |
| 672 | } |
| 673 | return 0; |
| 674 | } |
| 675 | |
| 676 | /* Route reflection loop check. */ |
| 677 | static int |
| 678 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 679 | { |
| 680 | struct in_addr cluster_id; |
| 681 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 682 | if (attr->extra && attr->extra->cluster) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 683 | { |
| 684 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 685 | cluster_id = peer->bgp->cluster_id; |
| 686 | else |
| 687 | cluster_id = peer->bgp->router_id; |
| 688 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 689 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 690 | return 1; |
| 691 | } |
| 692 | return 0; |
| 693 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 694 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 695 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 696 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 697 | afi_t afi, safi_t safi) |
| 698 | { |
| 699 | struct bgp_filter *filter; |
| 700 | struct bgp_info info; |
| 701 | route_map_result_t ret; |
| 702 | |
| 703 | filter = &peer->filter[afi][safi]; |
| 704 | |
| 705 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 706 | if (peer->weight) |
| 707 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 708 | |
| 709 | /* Route map apply. */ |
| 710 | if (ROUTE_MAP_IN_NAME (filter)) |
| 711 | { |
| 712 | /* Duplicate current value to new strucutre for modification. */ |
| 713 | info.peer = peer; |
| 714 | info.attr = attr; |
| 715 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 716 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 717 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 718 | /* Apply BGP route map to the attribute. */ |
| 719 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 720 | |
| 721 | peer->rmap_type = 0; |
| 722 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 723 | if (ret == RMAP_DENYMATCH) |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 724 | /* caller has multiple error paths with bgp_attr_flush() */ |
| 725 | return RMAP_DENY; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 726 | } |
| 727 | return RMAP_PERMIT; |
| 728 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 729 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 730 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 731 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 732 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 733 | { |
| 734 | struct bgp_filter *filter; |
| 735 | struct bgp_info info; |
| 736 | route_map_result_t ret; |
| 737 | |
| 738 | filter = &peer->filter[afi][safi]; |
| 739 | |
| 740 | /* Route map apply. */ |
| 741 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 742 | { |
| 743 | /* Duplicate current value to new strucutre for modification. */ |
| 744 | info.peer = rsclient; |
| 745 | info.attr = attr; |
| 746 | |
| 747 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 748 | |
| 749 | /* Apply BGP route map to the attribute. */ |
| 750 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 751 | |
| 752 | rsclient->rmap_type = 0; |
| 753 | |
| 754 | if (ret == RMAP_DENYMATCH) |
| 755 | { |
| 756 | /* Free newly generated AS path and community by route-map. */ |
| 757 | bgp_attr_flush (attr); |
| 758 | return RMAP_DENY; |
| 759 | } |
| 760 | } |
| 761 | return RMAP_PERMIT; |
| 762 | } |
| 763 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 764 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 765 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 766 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 767 | { |
| 768 | struct bgp_filter *filter; |
| 769 | struct bgp_info info; |
| 770 | route_map_result_t ret; |
| 771 | |
| 772 | filter = &rsclient->filter[afi][safi]; |
| 773 | |
| 774 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 775 | if (peer->weight) |
| 776 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 777 | |
| 778 | /* Route map apply. */ |
| 779 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 780 | { |
| 781 | /* Duplicate current value to new strucutre for modification. */ |
| 782 | info.peer = peer; |
| 783 | info.attr = attr; |
| 784 | |
| 785 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 786 | |
| 787 | /* Apply BGP route map to the attribute. */ |
| 788 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 789 | |
| 790 | peer->rmap_type = 0; |
| 791 | |
| 792 | if (ret == RMAP_DENYMATCH) |
| 793 | { |
| 794 | /* Free newly generated AS path and community by route-map. */ |
| 795 | bgp_attr_flush (attr); |
| 796 | return RMAP_DENY; |
| 797 | } |
| 798 | } |
| 799 | return RMAP_PERMIT; |
| 800 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 801 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 802 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 803 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 804 | struct attr *attr, afi_t afi, safi_t safi) |
| 805 | { |
| 806 | int ret; |
| 807 | char buf[SU_ADDRSTRLEN]; |
| 808 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 809 | struct peer *from; |
| 810 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 811 | int transparent; |
| 812 | int reflect; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 813 | struct attr *riattr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 814 | |
| 815 | from = ri->peer; |
| 816 | filter = &peer->filter[afi][safi]; |
| 817 | bgp = peer->bgp; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 818 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 819 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 820 | if (DISABLE_BGP_ANNOUNCE) |
| 821 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 822 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 823 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 824 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 825 | return 0; |
| 826 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 827 | /* Do not send back route to sender. */ |
| 828 | if (from == peer) |
| 829 | return 0; |
| 830 | |
| 831 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 832 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 833 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 834 | return 0; |
| 835 | |
| 836 | /* Default route check. */ |
| 837 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 838 | { |
| 839 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 840 | return 0; |
| 841 | #ifdef HAVE_IPV6 |
| 842 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 843 | return 0; |
| 844 | #endif /* HAVE_IPV6 */ |
| 845 | } |
| 846 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 847 | /* Transparency check. */ |
| 848 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 849 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 850 | transparent = 1; |
| 851 | else |
| 852 | transparent = 0; |
| 853 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 854 | /* If community is not disabled check the no-export and local. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 855 | if (! transparent && bgp_community_filter (peer, riattr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 856 | return 0; |
| 857 | |
| 858 | /* If the attribute has originator-id and it is same as remote |
| 859 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 860 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 861 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 862 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 863 | { |
| 864 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 865 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 866 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 867 | peer->host, |
| 868 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 869 | p->prefixlen); |
| 870 | return 0; |
| 871 | } |
| 872 | } |
| 873 | |
| 874 | /* ORF prefix-list filter check */ |
| 875 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 876 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 877 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 878 | if (peer->orf_plist[afi][safi]) |
| 879 | { |
| 880 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 881 | return 0; |
| 882 | } |
| 883 | |
| 884 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 885 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 886 | { |
| 887 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 888 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 889 | "%s [Update:SEND] %s/%d is filtered", |
| 890 | peer->host, |
| 891 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 892 | p->prefixlen); |
| 893 | return 0; |
| 894 | } |
| 895 | |
| 896 | #ifdef BGP_SEND_ASPATH_CHECK |
| 897 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 898 | if (aspath_loop_check (riattr->aspath, peer->as)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 899 | { |
| 900 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 901 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 902 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 903 | peer->host, peer->as); |
| 904 | return 0; |
| 905 | } |
| 906 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 907 | |
| 908 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 909 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 910 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 911 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 912 | { |
| 913 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 914 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 915 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 916 | peer->host, |
| 917 | bgp->confed_id); |
| 918 | return 0; |
| 919 | } |
| 920 | } |
| 921 | |
| 922 | /* Route-Reflect check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 923 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 924 | reflect = 1; |
| 925 | else |
| 926 | reflect = 0; |
| 927 | |
| 928 | /* IBGP reflection check. */ |
| 929 | if (reflect) |
| 930 | { |
| 931 | /* A route from a Client peer. */ |
| 932 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 933 | { |
| 934 | /* Reflect to all the Non-Client peers and also to the |
| 935 | Client peers other than the originator. Originator check |
| 936 | is already done. So there is noting to do. */ |
| 937 | /* no bgp client-to-client reflection check. */ |
| 938 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 939 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 940 | return 0; |
| 941 | } |
| 942 | else |
| 943 | { |
| 944 | /* A route from a Non-client peer. Reflect to all other |
| 945 | clients. */ |
| 946 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 947 | return 0; |
| 948 | } |
| 949 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 950 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 951 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 952 | bgp_attr_dup (attr, riattr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 953 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 954 | /* If local-preference is not set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 955 | if ((peer->sort == BGP_PEER_IBGP |
| 956 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 957 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 958 | { |
| 959 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 960 | attr->local_pref = bgp->default_local_pref; |
| 961 | } |
| 962 | |
Pradosh Mohapatra | 689bb66 | 2013-09-07 07:13:37 +0000 | [diff] [blame] | 963 | /* If originator-id is not set and the route is to be reflected, |
| 964 | set the originator id */ |
| 965 | if (peer && from && peer->sort == BGP_PEER_IBGP && |
| 966 | from->sort == BGP_PEER_IBGP && |
| 967 | (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) |
| 968 | { |
| 969 | attr->extra = bgp_attr_extra_get(attr); |
| 970 | IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id)); |
| 971 | SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID); |
| 972 | } |
| 973 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 974 | /* 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] | 975 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 976 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 977 | { |
| 978 | if (ri->peer != bgp->peer_self && ! transparent |
| 979 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 980 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 981 | } |
| 982 | |
| 983 | /* next-hop-set */ |
Timo Teräs | 9e7a53c | 2014-04-24 10:22:37 +0300 | [diff] [blame] | 984 | if (transparent |
| 985 | || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 986 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 987 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 988 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 989 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 990 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 991 | #endif /* HAVE_IPV6 */ |
| 992 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 993 | { |
| 994 | /* NEXT-HOP Unchanged. */ |
| 995 | } |
| 996 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 997 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 998 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 999 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1000 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1001 | #endif /* HAVE_IPV6 */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1002 | || (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1003 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 1004 | { |
| 1005 | /* Set IPv4 nexthop. */ |
| 1006 | if (p->family == AF_INET) |
| 1007 | { |
| 1008 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1009 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 1010 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1011 | else |
| 1012 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1013 | } |
| 1014 | #ifdef HAVE_IPV6 |
| 1015 | /* Set IPv6 nexthop. */ |
| 1016 | if (p->family == AF_INET6) |
| 1017 | { |
| 1018 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1019 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1020 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1021 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1022 | } |
| 1023 | #endif /* HAVE_IPV6 */ |
| 1024 | } |
| 1025 | |
| 1026 | #ifdef HAVE_IPV6 |
| 1027 | if (p->family == AF_INET6) |
| 1028 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1029 | /* Left nexthop_local unchanged if so configured. */ |
| 1030 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 1031 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1032 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1033 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 1034 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1035 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1036 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1037 | } |
| 1038 | |
| 1039 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 1040 | else |
| 1041 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1042 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1043 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1044 | |
| 1045 | /* Set link-local address for shared network peer. */ |
| 1046 | if (peer->shared_network |
| 1047 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 1048 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1049 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1050 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1051 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1052 | } |
| 1053 | |
| 1054 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 1055 | address.*/ |
| 1056 | if (reflect) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1057 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1058 | |
| 1059 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 1060 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1061 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1062 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1063 | |
| 1064 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1065 | #endif /* HAVE_IPV6 */ |
| 1066 | |
| 1067 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1068 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1069 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1070 | && aspath_private_as_check (attr->aspath)) |
| 1071 | attr->aspath = aspath_empty_get (); |
| 1072 | |
| 1073 | /* Route map & unsuppress-map apply. */ |
| 1074 | if (ROUTE_MAP_OUT_NAME (filter) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1075 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1076 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1077 | struct bgp_info info; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1078 | struct attr dummy_attr; |
| 1079 | struct attr_extra dummy_extra; |
| 1080 | |
| 1081 | dummy_attr.extra = &dummy_extra; |
| 1082 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1083 | info.peer = peer; |
| 1084 | info.attr = attr; |
| 1085 | |
| 1086 | /* The route reflector is not allowed to modify the attributes |
| 1087 | of the reflected IBGP routes. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1088 | if (from->sort == BGP_PEER_IBGP |
| 1089 | && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1090 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1091 | bgp_attr_dup (&dummy_attr, attr); |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1092 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1093 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1094 | |
| 1095 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1096 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1097 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1098 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1099 | else |
| 1100 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1101 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1102 | peer->rmap_type = 0; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1103 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1104 | if (ret == RMAP_DENYMATCH) |
| 1105 | { |
| 1106 | bgp_attr_flush (attr); |
| 1107 | return 0; |
| 1108 | } |
| 1109 | } |
| 1110 | return 1; |
| 1111 | } |
| 1112 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1113 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1114 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1115 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1116 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1117 | int ret; |
| 1118 | char buf[SU_ADDRSTRLEN]; |
| 1119 | struct bgp_filter *filter; |
| 1120 | struct bgp_info info; |
| 1121 | struct peer *from; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1122 | struct attr *riattr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1123 | |
| 1124 | from = ri->peer; |
| 1125 | filter = &rsclient->filter[afi][safi]; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1126 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1127 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 1128 | if (DISABLE_BGP_ANNOUNCE) |
| 1129 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1130 | |
| 1131 | /* Do not send back route to sender. */ |
| 1132 | if (from == rsclient) |
| 1133 | return 0; |
| 1134 | |
| 1135 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1136 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1137 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 1138 | return 0; |
| 1139 | |
| 1140 | /* Default route check. */ |
| 1141 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1142 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1143 | { |
| 1144 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1145 | return 0; |
| 1146 | #ifdef HAVE_IPV6 |
| 1147 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1148 | return 0; |
| 1149 | #endif /* HAVE_IPV6 */ |
| 1150 | } |
| 1151 | |
| 1152 | /* If the attribute has originator-id and it is same as remote |
| 1153 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1154 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1155 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1156 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1157 | &riattr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1158 | { |
| 1159 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1160 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1161 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1162 | rsclient->host, |
| 1163 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1164 | p->prefixlen); |
| 1165 | return 0; |
| 1166 | } |
| 1167 | } |
| 1168 | |
| 1169 | /* ORF prefix-list filter check */ |
| 1170 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1171 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1172 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1173 | if (rsclient->orf_plist[afi][safi]) |
| 1174 | { |
| 1175 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1176 | return 0; |
| 1177 | } |
| 1178 | |
| 1179 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1180 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1181 | { |
| 1182 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1183 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1184 | "%s [Update:SEND] %s/%d is filtered", |
| 1185 | rsclient->host, |
| 1186 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1187 | p->prefixlen); |
| 1188 | return 0; |
| 1189 | } |
| 1190 | |
| 1191 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1192 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1193 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1194 | { |
| 1195 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1196 | zlog (rsclient->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 1197 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1198 | rsclient->host, rsclient->as); |
| 1199 | return 0; |
| 1200 | } |
| 1201 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1202 | |
| 1203 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1204 | bgp_attr_dup (attr, riattr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1205 | |
| 1206 | /* next-hop-set */ |
| 1207 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1208 | #ifdef HAVE_IPV6 |
| 1209 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1210 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1211 | #endif /* HAVE_IPV6 */ |
| 1212 | ) |
| 1213 | { |
| 1214 | /* Set IPv4 nexthop. */ |
| 1215 | if (p->family == AF_INET) |
| 1216 | { |
| 1217 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1218 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1219 | IPV4_MAX_BYTELEN); |
| 1220 | else |
| 1221 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1222 | } |
| 1223 | #ifdef HAVE_IPV6 |
| 1224 | /* Set IPv6 nexthop. */ |
| 1225 | if (p->family == AF_INET6) |
| 1226 | { |
| 1227 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1228 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1229 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1230 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1231 | } |
| 1232 | #endif /* HAVE_IPV6 */ |
| 1233 | } |
| 1234 | |
| 1235 | #ifdef HAVE_IPV6 |
| 1236 | if (p->family == AF_INET6) |
| 1237 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1238 | struct attr_extra *attre = attr->extra; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1239 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1240 | /* Left nexthop_local unchanged if so configured. */ |
| 1241 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1242 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1243 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1244 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1245 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1246 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1247 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1248 | } |
| 1249 | |
| 1250 | /* Default nexthop_local treatment for RS-Clients */ |
| 1251 | else |
| 1252 | { |
| 1253 | /* Announcer and RS-Client are both in the same network */ |
| 1254 | if (rsclient->shared_network && from->shared_network && |
| 1255 | (rsclient->ifindex == from->ifindex)) |
| 1256 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1257 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1258 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1259 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1260 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1261 | } |
| 1262 | |
| 1263 | /* Set link-local address for shared network peer. */ |
| 1264 | else if (rsclient->shared_network |
| 1265 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1266 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1267 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1268 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1269 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1270 | } |
| 1271 | |
| 1272 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1273 | attre->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1274 | } |
| 1275 | |
| 1276 | } |
| 1277 | #endif /* HAVE_IPV6 */ |
| 1278 | |
| 1279 | |
| 1280 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1281 | if (rsclient->sort == BGP_PEER_EBGP |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1282 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1283 | && aspath_private_as_check (attr->aspath)) |
| 1284 | attr->aspath = aspath_empty_get (); |
| 1285 | |
| 1286 | /* Route map & unsuppress-map apply. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1287 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1288 | { |
| 1289 | info.peer = rsclient; |
| 1290 | info.attr = attr; |
| 1291 | |
| 1292 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1293 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1294 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1295 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1296 | else |
| 1297 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1298 | |
| 1299 | rsclient->rmap_type = 0; |
| 1300 | |
| 1301 | if (ret == RMAP_DENYMATCH) |
| 1302 | { |
| 1303 | bgp_attr_flush (attr); |
| 1304 | return 0; |
| 1305 | } |
| 1306 | } |
| 1307 | |
| 1308 | return 1; |
| 1309 | } |
| 1310 | |
| 1311 | struct bgp_info_pair |
| 1312 | { |
| 1313 | struct bgp_info *old; |
| 1314 | struct bgp_info *new; |
| 1315 | }; |
| 1316 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1317 | static void |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1318 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1319 | struct bgp_info_pair *result, |
| 1320 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1321 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1322 | struct bgp_info *new_select; |
| 1323 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1324 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1325 | struct bgp_info *ri1; |
| 1326 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1327 | struct bgp_info *nextri = NULL; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1328 | int cmpret, do_mpath; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1329 | struct list mp_list; |
Paul Jakma | 91b9e85 | 2015-12-01 14:32:11 +0000 | [diff] [blame] | 1330 | |
| 1331 | result->old = result->new = NULL; |
| 1332 | |
| 1333 | if (rn->info == NULL) |
| 1334 | { |
| 1335 | char buf[PREFIX_STRLEN]; |
| 1336 | zlog_warn ("%s: Called for route_node %s with no routing entries!", |
| 1337 | __func__, |
| 1338 | prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf))); |
| 1339 | return; |
| 1340 | } |
| 1341 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1342 | bgp_mp_list_init (&mp_list); |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1343 | do_mpath = bgp_mpath_is_configured (bgp, afi, safi); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1344 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1345 | /* bgp deterministic-med */ |
| 1346 | new_select = NULL; |
| 1347 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1348 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1349 | { |
| 1350 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1351 | continue; |
| 1352 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1353 | continue; |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1354 | if (ri1->peer && ri1->peer != bgp->peer_self) |
| 1355 | if (ri1->peer->status != Established) |
| 1356 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1357 | |
| 1358 | new_select = ri1; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1359 | if (do_mpath) |
| 1360 | bgp_mp_list_add (&mp_list, ri1); |
| 1361 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1362 | if (ri1->next) |
| 1363 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1364 | { |
| 1365 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1366 | continue; |
| 1367 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1368 | continue; |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1369 | if (ri2->peer && |
| 1370 | ri2->peer != bgp->peer_self && |
| 1371 | !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT)) |
| 1372 | if (ri2->peer->status != Established) |
| 1373 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1374 | |
| 1375 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1376 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1377 | ri2->attr->aspath)) |
| 1378 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1379 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
| 1380 | old_select = ri2; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1381 | if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi)) |
| 1382 | == -1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1383 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1384 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1385 | new_select = ri2; |
| 1386 | } |
| 1387 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1388 | if (do_mpath) |
| 1389 | { |
| 1390 | if (cmpret != 0) |
| 1391 | bgp_mp_list_clear (&mp_list); |
| 1392 | |
| 1393 | if (cmpret == 0 || cmpret == -1) |
| 1394 | bgp_mp_list_add (&mp_list, ri2); |
| 1395 | } |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1396 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1397 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1398 | } |
| 1399 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1400 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1401 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1402 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1403 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1404 | bgp_mp_list_clear (&mp_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1405 | } |
| 1406 | |
| 1407 | /* Check old selected route and new selected route. */ |
| 1408 | old_select = NULL; |
| 1409 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1410 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1411 | { |
| 1412 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1413 | old_select = ri; |
| 1414 | |
| 1415 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1416 | { |
| 1417 | /* reap REMOVED routes, if needs be |
| 1418 | * selected route must stay for a while longer though |
| 1419 | */ |
| 1420 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1421 | && (ri != old_select)) |
| 1422 | bgp_info_reap (rn, ri); |
| 1423 | |
| 1424 | continue; |
| 1425 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1426 | |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1427 | if (ri->peer && |
| 1428 | ri->peer != bgp->peer_self && |
| 1429 | !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT)) |
| 1430 | if (ri->peer->status != Established) |
| 1431 | continue; |
| 1432 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1433 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1434 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1435 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1436 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1437 | continue; |
| 1438 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1439 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1440 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1441 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1442 | if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1443 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1444 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1445 | bgp_mp_dmed_deselect (new_select); |
| 1446 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1447 | new_select = ri; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1448 | } |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1449 | else if (cmpret == 1 && do_mpath |
| 1450 | && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1451 | bgp_mp_dmed_deselect (ri); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1452 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1453 | if (do_mpath) |
| 1454 | { |
| 1455 | if (cmpret != 0) |
| 1456 | bgp_mp_list_clear (&mp_list); |
| 1457 | |
| 1458 | if (cmpret == 0 || cmpret == -1) |
| 1459 | bgp_mp_list_add (&mp_list, ri); |
| 1460 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1461 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1462 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1463 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1464 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1465 | |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1466 | bgp_info_mpath_aggregate_update (new_select, old_select); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1467 | bgp_mp_list_clear (&mp_list); |
| 1468 | |
| 1469 | result->old = old_select; |
| 1470 | result->new = new_select; |
| 1471 | |
| 1472 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1473 | } |
| 1474 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1475 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1476 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1477 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1478 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1479 | struct prefix *p; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1480 | struct attr attr; |
| 1481 | struct attr_extra extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1482 | |
| 1483 | p = &rn->p; |
| 1484 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1485 | /* Announce route to Established peer. */ |
| 1486 | if (peer->status != Established) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1487 | return 0; |
| 1488 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1489 | /* Address family configuration check. */ |
| 1490 | if (! peer->afc_nego[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1491 | return 0; |
| 1492 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1493 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1494 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1495 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1496 | return 0; |
| 1497 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1498 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 1499 | attr.extra = &extra; |
| 1500 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1501 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1502 | { |
| 1503 | case BGP_TABLE_MAIN: |
| 1504 | /* Announcement to peer->conf. If the route is filtered, |
| 1505 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1506 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
| 1507 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1508 | else |
| 1509 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1510 | break; |
| 1511 | case BGP_TABLE_RSCLIENT: |
| 1512 | /* Announcement to peer->conf. If the route is filtered, |
| 1513 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1514 | if (selected && |
| 1515 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) |
| 1516 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
| 1517 | else |
| 1518 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1519 | break; |
| 1520 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1521 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1522 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1523 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1524 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1525 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1526 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1527 | struct bgp *bgp; |
| 1528 | struct bgp_node *rn; |
| 1529 | afi_t afi; |
| 1530 | safi_t safi; |
| 1531 | }; |
| 1532 | |
| 1533 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1534 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1535 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1536 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1537 | struct bgp *bgp = pq->bgp; |
| 1538 | struct bgp_node *rn = pq->rn; |
| 1539 | afi_t afi = pq->afi; |
| 1540 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1541 | struct bgp_info *new_select; |
| 1542 | struct bgp_info *old_select; |
| 1543 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1544 | struct listnode *node, *nnode; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1545 | struct peer *rsclient = bgp_node_table (rn)->owner; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1546 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1547 | /* Best path selection. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1548 | bgp_best_selection (bgp, rn, &old_and_new, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1549 | new_select = old_and_new.new; |
| 1550 | old_select = old_and_new.old; |
| 1551 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1552 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1553 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1554 | if (rsclient->group) |
| 1555 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1556 | { |
| 1557 | /* Nothing to do. */ |
| 1558 | if (old_select && old_select == new_select) |
| 1559 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1560 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1561 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1562 | if (old_select) |
| 1563 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
| 1564 | if (new_select) |
| 1565 | { |
| 1566 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1567 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1568 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
| 1569 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1570 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1571 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1572 | afi, safi); |
| 1573 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1574 | } |
| 1575 | else |
| 1576 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1577 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1578 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1579 | if (new_select) |
| 1580 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1581 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1582 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1583 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1584 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1585 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1586 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1587 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1588 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1589 | bgp_info_reap (rn, old_select); |
| 1590 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1591 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1592 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1593 | } |
| 1594 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1595 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1596 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1597 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1598 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1599 | struct bgp *bgp = pq->bgp; |
| 1600 | struct bgp_node *rn = pq->rn; |
| 1601 | afi_t afi = pq->afi; |
| 1602 | safi_t safi = pq->safi; |
| 1603 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1604 | struct bgp_info *new_select; |
| 1605 | struct bgp_info *old_select; |
| 1606 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1607 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1608 | struct peer *peer; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1609 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1610 | /* Best path selection. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1611 | bgp_best_selection (bgp, rn, &old_and_new, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1612 | old_select = old_and_new.old; |
| 1613 | new_select = old_and_new.new; |
| 1614 | |
| 1615 | /* Nothing to do. */ |
| 1616 | if (old_select && old_select == new_select) |
| 1617 | { |
| 1618 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1619 | { |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1620 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
| 1621 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1622 | bgp_zebra_announce (p, old_select, bgp, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1623 | |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1624 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1625 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1626 | return WQ_SUCCESS; |
| 1627 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1628 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1629 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1630 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1631 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1632 | if (new_select) |
| 1633 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1634 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1635 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1636 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1637 | } |
| 1638 | |
| 1639 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1640 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1641 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1642 | { |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1643 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1644 | } |
| 1645 | |
| 1646 | /* FIB update. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1647 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
| 1648 | ! bgp_option_check (BGP_OPT_NO_FIB))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1649 | { |
| 1650 | if (new_select |
| 1651 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1652 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1653 | bgp_zebra_announce (p, new_select, bgp, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1654 | else |
| 1655 | { |
| 1656 | /* Withdraw the route from the kernel. */ |
| 1657 | if (old_select |
| 1658 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1659 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1660 | bgp_zebra_withdraw (p, old_select, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1661 | } |
| 1662 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1663 | |
| 1664 | /* Reap old select bgp_info, it it has been removed */ |
| 1665 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1666 | bgp_info_reap (rn, old_select); |
| 1667 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1668 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1669 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1670 | } |
| 1671 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1672 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1673 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1674 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1675 | struct bgp_process_queue *pq = data; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1676 | struct bgp_table *table = bgp_node_table (pq->rn); |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1677 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1678 | bgp_unlock (pq->bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1679 | bgp_unlock_node (pq->rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1680 | bgp_table_unlock (table); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1681 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1682 | } |
| 1683 | |
| 1684 | static void |
| 1685 | bgp_process_queue_init (void) |
| 1686 | { |
| 1687 | bm->process_main_queue |
| 1688 | = work_queue_new (bm->master, "process_main_queue"); |
| 1689 | bm->process_rsclient_queue |
| 1690 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1691 | |
| 1692 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1693 | { |
| 1694 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1695 | exit (1); |
| 1696 | } |
| 1697 | |
| 1698 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1699 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1700 | bm->process_main_queue->spec.max_retries = 0; |
| 1701 | bm->process_main_queue->spec.hold = 50; |
| 1702 | |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1703 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
David Lamparter | d43f8b3 | 2015-03-03 08:54:54 +0100 | [diff] [blame] | 1704 | bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del; |
| 1705 | bm->process_rsclient_queue->spec.max_retries = 0; |
| 1706 | bm->process_rsclient_queue->spec.hold = 50; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1707 | } |
| 1708 | |
| 1709 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1710 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1711 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1712 | struct bgp_process_queue *pqnode; |
| 1713 | |
| 1714 | /* already scheduled for processing? */ |
| 1715 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1716 | return; |
| 1717 | |
Paul Jakma | 91b9e85 | 2015-12-01 14:32:11 +0000 | [diff] [blame] | 1718 | if (rn->info == NULL) |
| 1719 | { |
| 1720 | /* XXX: Perhaps remove before next release, after we've flushed out |
| 1721 | * any obvious cases |
| 1722 | */ |
| 1723 | assert (rn->info != NULL); |
| 1724 | char buf[PREFIX_STRLEN]; |
| 1725 | zlog_warn ("%s: Called for route_node %s with no routing entries!", |
| 1726 | __func__, |
| 1727 | prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf))); |
| 1728 | return; |
| 1729 | } |
| 1730 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1731 | if ( (bm->process_main_queue == NULL) || |
| 1732 | (bm->process_rsclient_queue == NULL) ) |
| 1733 | bgp_process_queue_init (); |
| 1734 | |
| 1735 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1736 | sizeof (struct bgp_process_queue)); |
| 1737 | if (!pqnode) |
| 1738 | return; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1739 | |
| 1740 | /* all unlocked in bgp_processq_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1741 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1742 | pqnode->rn = bgp_lock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1743 | pqnode->bgp = bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1744 | bgp_lock (bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1745 | pqnode->afi = afi; |
| 1746 | pqnode->safi = safi; |
| 1747 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1748 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1749 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1750 | case BGP_TABLE_MAIN: |
| 1751 | work_queue_add (bm->process_main_queue, pqnode); |
| 1752 | break; |
| 1753 | case BGP_TABLE_RSCLIENT: |
| 1754 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1755 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1756 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1757 | |
Stephen Hemminger | 07ff4dc | 2013-01-04 22:29:20 +0000 | [diff] [blame] | 1758 | SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1759 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1760 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1761 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1762 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1763 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1764 | { |
| 1765 | struct peer *peer; |
| 1766 | |
| 1767 | peer = THREAD_ARG (thread); |
| 1768 | peer->t_pmax_restart = NULL; |
| 1769 | |
| 1770 | if (BGP_DEBUG (events, EVENTS)) |
| 1771 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1772 | peer->host); |
| 1773 | |
| 1774 | peer_clear (peer); |
| 1775 | |
| 1776 | return 0; |
| 1777 | } |
| 1778 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1779 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1780 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1781 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1782 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1783 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1784 | return 0; |
| 1785 | |
| 1786 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1787 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1788 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1789 | && ! always) |
| 1790 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1791 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1792 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1793 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1794 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1795 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1796 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1797 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1798 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1799 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1800 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1801 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1802 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1803 | |
| 1804 | if (safi == SAFI_MPLS_VPN) |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 1805 | safi = SAFI_MPLS_LABELED_VPN; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1806 | |
| 1807 | ndata[0] = (afi >> 8); |
| 1808 | ndata[1] = afi; |
| 1809 | ndata[2] = safi; |
| 1810 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1811 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1812 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1813 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1814 | |
| 1815 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1816 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1817 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1818 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1819 | |
| 1820 | /* restart timer start */ |
| 1821 | if (peer->pmax_restart[afi][safi]) |
| 1822 | { |
| 1823 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1824 | |
| 1825 | if (BGP_DEBUG (events, EVENTS)) |
| 1826 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1827 | peer->host, peer->v_pmax_restart); |
| 1828 | |
| 1829 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1830 | peer->v_pmax_restart); |
| 1831 | } |
| 1832 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1833 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1834 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1835 | else |
| 1836 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1837 | |
| 1838 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1839 | { |
| 1840 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1841 | && ! always) |
| 1842 | return 0; |
| 1843 | |
| 1844 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1845 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1846 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1847 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1848 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1849 | } |
| 1850 | else |
| 1851 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1852 | return 0; |
| 1853 | } |
| 1854 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1855 | /* Unconditionally remove the route from the RIB, without taking |
| 1856 | * damping into consideration (eg, because the session went down) |
| 1857 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1858 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1859 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1860 | afi_t afi, safi_t safi) |
| 1861 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1862 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1863 | |
| 1864 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1865 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1866 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1867 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1868 | } |
| 1869 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1870 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1871 | 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] | 1872 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1873 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1874 | int status = BGP_DAMP_NONE; |
| 1875 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1876 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1877 | * the bgp_info in the RIB for historical reference. |
| 1878 | */ |
| 1879 | 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] | 1880 | && peer->sort == BGP_PEER_EBGP) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1881 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1882 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1883 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1884 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1885 | return; |
| 1886 | } |
| 1887 | |
| 1888 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1889 | } |
| 1890 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1891 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1892 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1893 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1894 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1895 | { |
| 1896 | struct bgp_node *rn; |
| 1897 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1898 | struct attr new_attr; |
| 1899 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1900 | struct attr *attr_new; |
| 1901 | struct attr *attr_new2; |
| 1902 | struct bgp_info *ri; |
| 1903 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1904 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1905 | char buf[SU_ADDRSTRLEN]; |
| 1906 | |
| 1907 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1908 | if (peer == rsclient) |
| 1909 | return; |
| 1910 | |
| 1911 | bgp = peer->bgp; |
| 1912 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1913 | |
| 1914 | /* Check previously received route. */ |
| 1915 | for (ri = rn->info; ri; ri = ri->next) |
| 1916 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1917 | break; |
| 1918 | |
| 1919 | /* AS path loop check. */ |
Milan Kocian | 000e157 | 2013-10-18 07:59:38 +0000 | [diff] [blame] | 1920 | if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1921 | { |
| 1922 | reason = "as-path contains our own AS;"; |
| 1923 | goto filtered; |
| 1924 | } |
| 1925 | |
| 1926 | /* Route reflector originator ID check. */ |
| 1927 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1928 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1929 | { |
| 1930 | reason = "originator is us;"; |
| 1931 | goto filtered; |
| 1932 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1933 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1934 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1935 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1936 | |
| 1937 | /* Apply export policy. */ |
| 1938 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1939 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1940 | { |
| 1941 | reason = "export-policy;"; |
| 1942 | goto filtered; |
| 1943 | } |
| 1944 | |
| 1945 | attr_new2 = bgp_attr_intern (&new_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1946 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1947 | /* Apply import policy. */ |
| 1948 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1949 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1950 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1951 | |
| 1952 | reason = "import-policy;"; |
| 1953 | goto filtered; |
| 1954 | } |
| 1955 | |
| 1956 | attr_new = bgp_attr_intern (&new_attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1957 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1958 | |
| 1959 | /* IPv4 unicast next hop check. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1960 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1961 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1962 | /* 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] | 1963 | if (new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1964 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1965 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1966 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1967 | |
| 1968 | reason = "martian next-hop;"; |
| 1969 | goto filtered; |
| 1970 | } |
| 1971 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1972 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1973 | /* If the update is implicit withdraw. */ |
| 1974 | if (ri) |
| 1975 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1976 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1977 | |
| 1978 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1979 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1980 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1981 | { |
| 1982 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1983 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1984 | |
| 1985 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1986 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1987 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1988 | peer->host, |
| 1989 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1990 | p->prefixlen, rsclient->host); |
| 1991 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1992 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1993 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1994 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1995 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1996 | } |
| 1997 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1998 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 1999 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2000 | bgp_info_restore (rn, ri); |
| 2001 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2002 | /* Received Logging. */ |
| 2003 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2004 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2005 | peer->host, |
| 2006 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2007 | p->prefixlen, rsclient->host); |
| 2008 | |
| 2009 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2010 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2011 | |
| 2012 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2013 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2014 | ri->attr = attr_new; |
| 2015 | |
| 2016 | /* Update MPLS tag. */ |
| 2017 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2018 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2019 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2020 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2021 | |
| 2022 | /* Process change. */ |
| 2023 | bgp_process (bgp, rn, afi, safi); |
| 2024 | bgp_unlock_node (rn); |
| 2025 | |
| 2026 | return; |
| 2027 | } |
| 2028 | |
| 2029 | /* Received Logging. */ |
| 2030 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2031 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2032 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2033 | peer->host, |
| 2034 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2035 | p->prefixlen, rsclient->host); |
| 2036 | } |
| 2037 | |
| 2038 | /* Make new BGP info. */ |
| 2039 | new = bgp_info_new (); |
| 2040 | new->type = type; |
| 2041 | new->sub_type = sub_type; |
| 2042 | new->peer = peer; |
| 2043 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2044 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2045 | |
| 2046 | /* Update MPLS tag. */ |
| 2047 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2048 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2049 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2050 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2051 | |
| 2052 | /* Register new BGP information. */ |
| 2053 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2054 | |
| 2055 | /* route_node_get lock */ |
| 2056 | bgp_unlock_node (rn); |
| 2057 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2058 | /* Process change. */ |
| 2059 | bgp_process (bgp, rn, afi, safi); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2060 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2061 | return; |
| 2062 | |
| 2063 | filtered: |
| 2064 | |
| 2065 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2066 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2067 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2068 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 2069 | peer->host, |
| 2070 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2071 | p->prefixlen, rsclient->host, reason); |
| 2072 | |
| 2073 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2074 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2075 | |
| 2076 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2077 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2078 | return; |
| 2079 | } |
| 2080 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2081 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2082 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 2083 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 2084 | struct prefix_rd *prd, u_char *tag) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2085 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2086 | struct bgp_node *rn; |
| 2087 | struct bgp_info *ri; |
| 2088 | char buf[SU_ADDRSTRLEN]; |
| 2089 | |
| 2090 | if (rsclient == peer) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2091 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2092 | |
| 2093 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 2094 | |
| 2095 | /* Lookup withdrawn route. */ |
| 2096 | for (ri = rn->info; ri; ri = ri->next) |
| 2097 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2098 | break; |
| 2099 | |
| 2100 | /* Withdraw specified route from routing table. */ |
| 2101 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2102 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2103 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2104 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2105 | "%s Can't find the route %s/%d", peer->host, |
| 2106 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2107 | p->prefixlen); |
| 2108 | |
| 2109 | /* Unlock bgp_node_get() lock. */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2110 | bgp_unlock_node (rn); |
| 2111 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2112 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2113 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2114 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2115 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2116 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2117 | { |
| 2118 | int ret; |
| 2119 | int aspath_loop_count = 0; |
| 2120 | struct bgp_node *rn; |
| 2121 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2122 | struct attr new_attr; |
| 2123 | struct attr_extra new_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2124 | struct attr *attr_new; |
| 2125 | struct bgp_info *ri; |
| 2126 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2127 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2128 | char buf[SU_ADDRSTRLEN]; |
| 2129 | |
| 2130 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2131 | 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] | 2132 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2133 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2134 | Adj-RIBs-In. */ |
Jorge Boncompte [DTI2] | 343aa82 | 2012-05-07 16:53:08 +0000 | [diff] [blame] | 2135 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2136 | && peer != bgp->peer_self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2137 | bgp_adj_in_set (rn, peer, attr); |
| 2138 | |
| 2139 | /* Check previously received route. */ |
| 2140 | for (ri = rn->info; ri; ri = ri->next) |
| 2141 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2142 | break; |
| 2143 | |
| 2144 | /* AS path local-as loop check. */ |
| 2145 | if (peer->change_local_as) |
| 2146 | { |
| 2147 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 2148 | aspath_loop_count = 1; |
| 2149 | |
| 2150 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 2151 | { |
| 2152 | reason = "as-path contains our own AS;"; |
| 2153 | goto filtered; |
| 2154 | } |
| 2155 | } |
| 2156 | |
| 2157 | /* AS path loop check. */ |
| 2158 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 2159 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2160 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2161 | > peer->allowas_in[afi][safi])) |
| 2162 | { |
| 2163 | reason = "as-path contains our own AS;"; |
| 2164 | goto filtered; |
| 2165 | } |
| 2166 | |
| 2167 | /* Route reflector originator ID check. */ |
| 2168 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2169 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2170 | { |
| 2171 | reason = "originator is us;"; |
| 2172 | goto filtered; |
| 2173 | } |
| 2174 | |
| 2175 | /* Route reflector cluster ID check. */ |
| 2176 | if (bgp_cluster_filter (peer, attr)) |
| 2177 | { |
| 2178 | reason = "reflected from the same cluster;"; |
| 2179 | goto filtered; |
| 2180 | } |
| 2181 | |
| 2182 | /* Apply incoming filter. */ |
| 2183 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2184 | { |
| 2185 | reason = "filter;"; |
| 2186 | goto filtered; |
| 2187 | } |
| 2188 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2189 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2190 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2191 | |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2192 | /* Apply incoming route-map. |
| 2193 | * NB: new_attr may now contain newly allocated values from route-map "set" |
| 2194 | * commands, so we need bgp_attr_flush in the error paths, until we intern |
| 2195 | * the attr (which takes over the memory references) */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2196 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2197 | { |
| 2198 | reason = "route-map;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2199 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2200 | goto filtered; |
| 2201 | } |
| 2202 | |
| 2203 | /* IPv4 unicast next hop check. */ |
| 2204 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2205 | { |
| 2206 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2207 | discard it. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2208 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 |
Denis Ovsienko | 8e80bdf | 2011-08-05 18:52:52 +0400 | [diff] [blame] | 2209 | && ! bgp_nexthop_onlink (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2210 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2211 | { |
| 2212 | reason = "non-connected next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2213 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2214 | goto filtered; |
| 2215 | } |
| 2216 | |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2217 | /* 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] | 2218 | must not be my own address. */ |
Jorge Boncompte [DTI2] | 10f9bf3 | 2012-05-07 16:52:52 +0000 | [diff] [blame] | 2219 | if (new_attr.nexthop.s_addr == 0 |
| 2220 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) |
| 2221 | || bgp_nexthop_self (&new_attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2222 | { |
| 2223 | reason = "martian next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2224 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2225 | goto filtered; |
| 2226 | } |
| 2227 | } |
| 2228 | |
| 2229 | attr_new = bgp_attr_intern (&new_attr); |
| 2230 | |
| 2231 | /* If the update is implicit withdraw. */ |
| 2232 | if (ri) |
| 2233 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2234 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2235 | |
| 2236 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2237 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2238 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2239 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2240 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2241 | |
| 2242 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2243 | && peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2244 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2245 | { |
| 2246 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2247 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2248 | peer->host, |
| 2249 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2250 | p->prefixlen); |
| 2251 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2252 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2253 | { |
| 2254 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2255 | bgp_process (bgp, rn, afi, safi); |
| 2256 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2257 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2258 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2259 | { |
| 2260 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2261 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2262 | "%s rcvd %s/%d...duplicate ignored", |
| 2263 | peer->host, |
| 2264 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2265 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2266 | |
| 2267 | /* graceful restart STALE flag unset. */ |
| 2268 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2269 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2270 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2271 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2272 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2273 | } |
| 2274 | |
| 2275 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2276 | bgp_attr_unintern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2277 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2278 | return 0; |
| 2279 | } |
| 2280 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2281 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2282 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2283 | { |
| 2284 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2285 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2286 | peer->host, |
| 2287 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2288 | p->prefixlen); |
| 2289 | bgp_info_restore (rn, ri); |
| 2290 | } |
| 2291 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2292 | /* Received Logging. */ |
| 2293 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2294 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2295 | peer->host, |
| 2296 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2297 | p->prefixlen); |
| 2298 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2299 | /* graceful restart STALE flag unset. */ |
| 2300 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2301 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2302 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2303 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2304 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2305 | |
| 2306 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2307 | * only if update is accepted, they'll increment below. |
| 2308 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2309 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2310 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2311 | /* Update bgp route dampening information. */ |
| 2312 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2313 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2314 | { |
| 2315 | /* This is implicit withdraw so we should update dampening |
| 2316 | information. */ |
| 2317 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2318 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2319 | } |
| 2320 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2321 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2322 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2323 | ri->attr = attr_new; |
| 2324 | |
| 2325 | /* Update MPLS tag. */ |
| 2326 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2327 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2328 | |
| 2329 | /* Update bgp route dampening information. */ |
| 2330 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2331 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2332 | { |
| 2333 | /* Now we do normal update dampening. */ |
| 2334 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2335 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2336 | { |
| 2337 | bgp_unlock_node (rn); |
| 2338 | return 0; |
| 2339 | } |
| 2340 | } |
| 2341 | |
| 2342 | /* Nexthop reachability check. */ |
| 2343 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2344 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2345 | && (peer->sort == BGP_PEER_IBGP |
| 2346 | || peer->sort == BGP_PEER_CONFED |
| 2347 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2348 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2349 | { |
| 2350 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2351 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2352 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2353 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2354 | } |
| 2355 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2356 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2357 | |
| 2358 | /* Process change. */ |
| 2359 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2360 | |
| 2361 | bgp_process (bgp, rn, afi, safi); |
| 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 | return 0; |
| 2365 | } |
| 2366 | |
| 2367 | /* Received Logging. */ |
| 2368 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2369 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2370 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2371 | peer->host, |
| 2372 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2373 | p->prefixlen); |
| 2374 | } |
| 2375 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2376 | /* Make new BGP info. */ |
| 2377 | new = bgp_info_new (); |
| 2378 | new->type = type; |
| 2379 | new->sub_type = sub_type; |
| 2380 | new->peer = peer; |
| 2381 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2382 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2383 | |
| 2384 | /* Update MPLS tag. */ |
| 2385 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2386 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2387 | |
| 2388 | /* Nexthop reachability check. */ |
| 2389 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2390 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2391 | && (peer->sort == BGP_PEER_IBGP |
| 2392 | || peer->sort == BGP_PEER_CONFED |
| 2393 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2394 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2395 | { |
| 2396 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2397 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2398 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2399 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2400 | } |
| 2401 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2402 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2403 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2404 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2405 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2406 | |
| 2407 | /* Register new BGP information. */ |
| 2408 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2409 | |
| 2410 | /* route_node_get lock */ |
| 2411 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2412 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2413 | /* If maximum prefix count is configured and current prefix |
| 2414 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2415 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2416 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2417 | |
| 2418 | /* Process change. */ |
| 2419 | bgp_process (bgp, rn, afi, safi); |
| 2420 | |
| 2421 | return 0; |
| 2422 | |
| 2423 | /* This BGP update is filtered. Log the reason then update BGP |
| 2424 | entry. */ |
| 2425 | filtered: |
| 2426 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2427 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2428 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2429 | peer->host, |
| 2430 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2431 | p->prefixlen, reason); |
| 2432 | |
| 2433 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2434 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2435 | |
| 2436 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2437 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2438 | return 0; |
| 2439 | } |
| 2440 | |
| 2441 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2442 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2443 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2444 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2445 | { |
| 2446 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2447 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2448 | struct bgp *bgp; |
| 2449 | int ret; |
| 2450 | |
| 2451 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2452 | soft_reconfig); |
| 2453 | |
| 2454 | bgp = peer->bgp; |
| 2455 | |
| 2456 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2457 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2458 | { |
| 2459 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2460 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2461 | sub_type, prd, tag); |
| 2462 | } |
| 2463 | |
| 2464 | return ret; |
| 2465 | } |
| 2466 | |
| 2467 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2468 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2469 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2470 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2471 | { |
| 2472 | struct bgp *bgp; |
| 2473 | char buf[SU_ADDRSTRLEN]; |
| 2474 | struct bgp_node *rn; |
| 2475 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2476 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2477 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2478 | |
| 2479 | bgp = peer->bgp; |
| 2480 | |
David Lamparter | 4584c23 | 2015-04-13 09:50:00 +0200 | [diff] [blame] | 2481 | /* Lookup node. */ |
| 2482 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
| 2483 | |
| 2484 | /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all |
| 2485 | * routes that are filtered. This tanks out Quagga RS pretty badly due to |
| 2486 | * the iteration over all RS clients. |
| 2487 | * Since we need to remove the entry from adj_in anyway, do that first and |
| 2488 | * if there was no entry, we don't need to do anything more. */ |
| 2489 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2490 | && peer != bgp->peer_self) |
| 2491 | if (!bgp_adj_in_unset (rn, peer)) |
| 2492 | { |
| 2493 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2494 | zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d " |
| 2495 | "not in adj-in", peer->host, |
| 2496 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2497 | p->prefixlen); |
| 2498 | bgp_unlock_node (rn); |
| 2499 | return 0; |
| 2500 | } |
| 2501 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2502 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2503 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2504 | { |
| 2505 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2506 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2507 | } |
| 2508 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2509 | /* Logging. */ |
| 2510 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2511 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2512 | peer->host, |
| 2513 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2514 | p->prefixlen); |
| 2515 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2516 | /* Lookup withdrawn route. */ |
| 2517 | for (ri = rn->info; ri; ri = ri->next) |
| 2518 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2519 | break; |
| 2520 | |
| 2521 | /* Withdraw specified route from routing table. */ |
| 2522 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2523 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2524 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2525 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2526 | "%s Can't find the route %s/%d", peer->host, |
| 2527 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2528 | p->prefixlen); |
| 2529 | |
| 2530 | /* Unlock bgp_node_get() lock. */ |
| 2531 | bgp_unlock_node (rn); |
| 2532 | |
| 2533 | return 0; |
| 2534 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2535 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2536 | void |
| 2537 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2538 | { |
| 2539 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 2540 | struct attr attr; |
Jorge Boncompte [DTI2] | 577ac57 | 2012-05-07 16:53:06 +0000 | [diff] [blame] | 2541 | struct aspath *aspath; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2542 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2543 | struct peer *from; |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2544 | struct bgp_node *rn; |
| 2545 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2546 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2547 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2548 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2549 | return; |
| 2550 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2551 | bgp = peer->bgp; |
| 2552 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2553 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2554 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2555 | aspath = attr.aspath; |
| 2556 | attr.local_pref = bgp->default_local_pref; |
| 2557 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2558 | |
| 2559 | if (afi == AFI_IP) |
| 2560 | str2prefix ("0.0.0.0/0", &p); |
| 2561 | #ifdef HAVE_IPV6 |
| 2562 | else if (afi == AFI_IP6) |
| 2563 | { |
Jorge Boncompte [DTI2] | 6182d65 | 2012-05-07 16:53:02 +0000 | [diff] [blame] | 2564 | struct attr_extra *ae = attr.extra; |
| 2565 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2566 | str2prefix ("::/0", &p); |
| 2567 | |
| 2568 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2569 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2570 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2571 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2572 | |
| 2573 | /* If the peer is on shared nextwork and we have link-local |
| 2574 | nexthop set it. */ |
| 2575 | if (peer->shared_network |
| 2576 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2577 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2578 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2579 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2580 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2581 | } |
| 2582 | } |
| 2583 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2584 | |
| 2585 | if (peer->default_rmap[afi][safi].name) |
| 2586 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2587 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2588 | for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn)) |
| 2589 | { |
| 2590 | for (ri = rn->info; ri; ri = ri->next) |
| 2591 | { |
| 2592 | struct attr dummy_attr; |
| 2593 | struct attr_extra dummy_extra; |
| 2594 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2595 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2596 | /* Provide dummy so the route-map can't modify the attributes */ |
| 2597 | dummy_attr.extra = &dummy_extra; |
| 2598 | bgp_attr_dup(&dummy_attr, ri->attr); |
| 2599 | info.peer = ri->peer; |
| 2600 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2601 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2602 | ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p, |
| 2603 | RMAP_BGP, &info); |
| 2604 | |
| 2605 | /* The route map might have set attributes. If we don't flush them |
| 2606 | * here, they will be leaked. */ |
| 2607 | bgp_attr_flush(&dummy_attr); |
| 2608 | if (ret != RMAP_DENYMATCH) |
| 2609 | break; |
| 2610 | } |
| 2611 | if (ret != RMAP_DENYMATCH) |
| 2612 | break; |
| 2613 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2614 | bgp->peer_self->rmap_type = 0; |
| 2615 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2616 | if (ret == RMAP_DENYMATCH) |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2617 | withdraw = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2618 | } |
| 2619 | |
| 2620 | if (withdraw) |
| 2621 | { |
| 2622 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2623 | bgp_default_withdraw_send (peer, afi, safi); |
| 2624 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2625 | } |
| 2626 | else |
| 2627 | { |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2628 | if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2629 | { |
| 2630 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2631 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2632 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2633 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2634 | |
| 2635 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2636 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2637 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2638 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2639 | static void |
| 2640 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2641 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2642 | { |
| 2643 | struct bgp_node *rn; |
| 2644 | struct bgp_info *ri; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2645 | struct attr attr; |
| 2646 | struct attr_extra extra; |
| 2647 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2648 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2649 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2650 | |
| 2651 | if (safi != SAFI_MPLS_VPN |
| 2652 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2653 | bgp_default_originate (peer, afi, safi, 0); |
| 2654 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2655 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 2656 | attr.extra = &extra; |
| 2657 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2658 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2659 | for (ri = rn->info; ri; ri = ri->next) |
| 2660 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2661 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2662 | if ( (rsclient) ? |
| 2663 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2664 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2665 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2666 | else |
| 2667 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2668 | } |
| 2669 | } |
| 2670 | |
| 2671 | void |
| 2672 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2673 | { |
| 2674 | struct bgp_node *rn; |
| 2675 | struct bgp_table *table; |
| 2676 | |
| 2677 | if (peer->status != Established) |
| 2678 | return; |
| 2679 | |
| 2680 | if (! peer->afc_nego[afi][safi]) |
| 2681 | return; |
| 2682 | |
| 2683 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2684 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2685 | return; |
| 2686 | |
| 2687 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2688 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2689 | else |
| 2690 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2691 | rn = bgp_route_next(rn)) |
| 2692 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2693 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2694 | |
| 2695 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2696 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2697 | } |
| 2698 | |
| 2699 | void |
| 2700 | bgp_announce_route_all (struct peer *peer) |
| 2701 | { |
| 2702 | afi_t afi; |
| 2703 | safi_t safi; |
| 2704 | |
| 2705 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2706 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2707 | bgp_announce_route (peer, afi, safi); |
| 2708 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2709 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2710 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2711 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2712 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2713 | { |
| 2714 | struct bgp_node *rn; |
| 2715 | struct bgp_adj_in *ain; |
| 2716 | |
| 2717 | if (! table) |
| 2718 | table = rsclient->bgp->rib[afi][safi]; |
| 2719 | |
| 2720 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2721 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2722 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2723 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2724 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2725 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2726 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2727 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2728 | } |
| 2729 | } |
| 2730 | |
| 2731 | void |
| 2732 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2733 | { |
| 2734 | struct bgp_table *table; |
| 2735 | struct bgp_node *rn; |
| 2736 | |
| 2737 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2738 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2739 | |
| 2740 | else |
| 2741 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2742 | rn = bgp_route_next (rn)) |
| 2743 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2744 | { |
| 2745 | struct prefix_rd prd; |
| 2746 | prd.family = AF_UNSPEC; |
| 2747 | prd.prefixlen = 64; |
| 2748 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2749 | |
| 2750 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); |
| 2751 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2752 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2753 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2754 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2755 | 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] | 2756 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2757 | { |
| 2758 | int ret; |
| 2759 | struct bgp_node *rn; |
| 2760 | struct bgp_adj_in *ain; |
| 2761 | |
| 2762 | if (! table) |
| 2763 | table = peer->bgp->rib[afi][safi]; |
| 2764 | |
| 2765 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2766 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2767 | { |
| 2768 | if (ain->peer == peer) |
| 2769 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2770 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2771 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2772 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2773 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2774 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2775 | prd, tag, 1); |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2776 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2777 | if (ret < 0) |
| 2778 | { |
| 2779 | bgp_unlock_node (rn); |
| 2780 | return; |
| 2781 | } |
| 2782 | continue; |
| 2783 | } |
| 2784 | } |
| 2785 | } |
| 2786 | |
| 2787 | void |
| 2788 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2789 | { |
| 2790 | struct bgp_node *rn; |
| 2791 | struct bgp_table *table; |
| 2792 | |
| 2793 | if (peer->status != Established) |
| 2794 | return; |
| 2795 | |
| 2796 | if (safi != SAFI_MPLS_VPN) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2797 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2798 | else |
| 2799 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2800 | rn = bgp_route_next (rn)) |
| 2801 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2802 | { |
| 2803 | struct prefix_rd prd; |
| 2804 | prd.family = AF_UNSPEC; |
| 2805 | prd.prefixlen = 64; |
| 2806 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2807 | |
| 2808 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); |
| 2809 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2810 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2811 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2812 | |
| 2813 | struct bgp_clear_node_queue |
| 2814 | { |
| 2815 | struct bgp_node *rn; |
| 2816 | enum bgp_clear_route_type purpose; |
| 2817 | }; |
| 2818 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2819 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2820 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2821 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2822 | struct bgp_clear_node_queue *cnq = data; |
| 2823 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2824 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2825 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2826 | afi_t afi = bgp_node_table (rn)->afi; |
| 2827 | safi_t safi = bgp_node_table (rn)->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2828 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2829 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2830 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2831 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2832 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2833 | { |
| 2834 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2835 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2836 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2837 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2838 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2839 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2840 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2841 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2842 | break; |
| 2843 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2844 | return WQ_SUCCESS; |
| 2845 | } |
| 2846 | |
| 2847 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2848 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2849 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2850 | struct bgp_clear_node_queue *cnq = data; |
| 2851 | struct bgp_node *rn = cnq->rn; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2852 | struct bgp_table *table = bgp_node_table (rn); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2853 | |
| 2854 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2855 | bgp_table_unlock (table); |
| 2856 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2857 | } |
| 2858 | |
| 2859 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2860 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2861 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2862 | struct peer *peer = wq->spec.data; |
| 2863 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2864 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2865 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2866 | |
| 2867 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2868 | } |
| 2869 | |
| 2870 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2871 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2872 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2873 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2874 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2875 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2876 | #undef CLEAR_QUEUE_NAME_LEN |
| 2877 | |
| 2878 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2879 | { |
| 2880 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2881 | exit (1); |
| 2882 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2883 | peer->clear_node_queue->spec.hold = 10; |
| 2884 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2885 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2886 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2887 | peer->clear_node_queue->spec.max_retries = 0; |
| 2888 | |
| 2889 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2890 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2891 | } |
| 2892 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2893 | static void |
| 2894 | 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] | 2895 | struct bgp_table *table, struct peer *rsclient, |
| 2896 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2897 | { |
| 2898 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2899 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2900 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2901 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2902 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2903 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2904 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2905 | if (! table) |
| 2906 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2907 | |
| 2908 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2909 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2910 | struct bgp_info *ri; |
| 2911 | struct bgp_adj_in *ain; |
| 2912 | struct bgp_adj_out *aout; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2913 | |
| 2914 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2915 | * queued for every clearing peer, regardless of whether it is |
| 2916 | * relevant to the peer at hand. |
| 2917 | * |
| 2918 | * Overview: There are 3 different indices which need to be |
| 2919 | * scrubbed, potentially, when a peer is removed: |
| 2920 | * |
| 2921 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2922 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2923 | * 3 other routes visible by the peer's adj-out index |
| 2924 | * |
| 2925 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2926 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2927 | * adj-outs at our leisure. |
| 2928 | * |
| 2929 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2930 | * invisible via RIB index before peer session is allowed to be |
| 2931 | * brought back up. So one needs to know when such a 'search' is |
| 2932 | * complete. |
| 2933 | * |
| 2934 | * Ideally: |
| 2935 | * |
| 2936 | * - there'd be a single global queue or a single RIB walker |
| 2937 | * - rather than tracking which route_nodes still need to be |
| 2938 | * examined on a peer basis, we'd track which peers still |
| 2939 | * aren't cleared |
| 2940 | * |
| 2941 | * Given that our per-peer prefix-counts now should be reliable, |
| 2942 | * this may actually be achievable. It doesn't seem to be a huge |
| 2943 | * problem at this time, |
| 2944 | */ |
Jorge Boncompte [DTI2] | 24e50f2 | 2012-05-07 15:17:33 +0000 | [diff] [blame] | 2945 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2946 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2947 | { |
| 2948 | bgp_adj_in_remove (rn, ain); |
| 2949 | bgp_unlock_node (rn); |
| 2950 | break; |
| 2951 | } |
| 2952 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2953 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2954 | { |
| 2955 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2956 | bgp_unlock_node (rn); |
| 2957 | break; |
| 2958 | } |
| 2959 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2960 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2961 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2962 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2963 | struct bgp_clear_node_queue *cnq; |
| 2964 | |
| 2965 | /* both unlocked in bgp_clear_node_queue_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2966 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2967 | bgp_lock_node (rn); |
| 2968 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2969 | sizeof (struct bgp_clear_node_queue)); |
| 2970 | cnq->rn = rn; |
| 2971 | cnq->purpose = purpose; |
| 2972 | work_queue_add (peer->clear_node_queue, cnq); |
| 2973 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2974 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2975 | } |
| 2976 | return; |
| 2977 | } |
| 2978 | |
| 2979 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2980 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2981 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2982 | { |
| 2983 | struct bgp_node *rn; |
| 2984 | struct bgp_table *table; |
| 2985 | struct peer *rsclient; |
| 2986 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2987 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2988 | if (peer->clear_node_queue == NULL) |
| 2989 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2990 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2991 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 2992 | * Idle until it receives a Clearing_Completed event. This protects |
| 2993 | * against peers which flap faster than we can we clear, which could |
| 2994 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2995 | * |
| 2996 | * a) race with routes from the new session being installed before |
| 2997 | * clear_route_node visits the node (to delete the route of that |
| 2998 | * peer) |
| 2999 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 3000 | * on the process_main queue. Fast-flapping could cause that queue |
| 3001 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3002 | */ |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3003 | |
| 3004 | /* lock peer in assumption that clear-node-queue will get nodes; if so, |
| 3005 | * the unlock will happen upon work-queue completion; other wise, the |
| 3006 | * unlock happens at the end of this function. |
| 3007 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 3008 | if (!peer->clear_node_queue->thread) |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3009 | peer_lock (peer); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3010 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3011 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3012 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3013 | case BGP_CLEAR_ROUTE_NORMAL: |
| 3014 | if (safi != SAFI_MPLS_VPN) |
| 3015 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 3016 | else |
| 3017 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 3018 | rn = bgp_route_next (rn)) |
| 3019 | if ((table = rn->info) != NULL) |
| 3020 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 3021 | |
| 3022 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 3023 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 3024 | PEER_FLAG_RSERVER_CLIENT)) |
| 3025 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 3026 | break; |
| 3027 | |
| 3028 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
| 3029 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 3030 | break; |
| 3031 | |
| 3032 | default: |
| 3033 | assert (0); |
| 3034 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3035 | } |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3036 | |
| 3037 | /* unlock if no nodes got added to the clear-node-queue. */ |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 3038 | if (!peer->clear_node_queue->thread) |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3039 | peer_unlock (peer); |
| 3040 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3041 | } |
| 3042 | |
| 3043 | void |
| 3044 | bgp_clear_route_all (struct peer *peer) |
| 3045 | { |
| 3046 | afi_t afi; |
| 3047 | safi_t safi; |
| 3048 | |
| 3049 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3050 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3051 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3052 | } |
| 3053 | |
| 3054 | void |
| 3055 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 3056 | { |
| 3057 | struct bgp_table *table; |
| 3058 | struct bgp_node *rn; |
| 3059 | struct bgp_adj_in *ain; |
| 3060 | |
| 3061 | table = peer->bgp->rib[afi][safi]; |
| 3062 | |
| 3063 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3064 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 3065 | if (ain->peer == peer) |
| 3066 | { |
| 3067 | bgp_adj_in_remove (rn, ain); |
| 3068 | bgp_unlock_node (rn); |
| 3069 | break; |
| 3070 | } |
| 3071 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 3072 | |
| 3073 | void |
| 3074 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 3075 | { |
| 3076 | struct bgp_node *rn; |
| 3077 | struct bgp_info *ri; |
| 3078 | struct bgp_table *table; |
| 3079 | |
| 3080 | table = peer->bgp->rib[afi][safi]; |
| 3081 | |
| 3082 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3083 | { |
| 3084 | for (ri = rn->info; ri; ri = ri->next) |
| 3085 | if (ri->peer == peer) |
| 3086 | { |
| 3087 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 3088 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3089 | break; |
| 3090 | } |
| 3091 | } |
| 3092 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3093 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3094 | /* Delete all kernel routes. */ |
| 3095 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3096 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3097 | { |
| 3098 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3099 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3100 | struct bgp_node *rn; |
| 3101 | struct bgp_table *table; |
| 3102 | struct bgp_info *ri; |
| 3103 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3104 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3105 | { |
| 3106 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 3107 | |
| 3108 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3109 | for (ri = rn->info; ri; ri = ri->next) |
| 3110 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3111 | && ri->type == ZEBRA_ROUTE_BGP |
| 3112 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3113 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3114 | |
| 3115 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 3116 | |
| 3117 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3118 | for (ri = rn->info; ri; ri = ri->next) |
| 3119 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3120 | && ri->type == ZEBRA_ROUTE_BGP |
| 3121 | && ri->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 3122 | bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3123 | } |
| 3124 | } |
| 3125 | |
| 3126 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3127 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3128 | { |
| 3129 | vty_reset (); |
| 3130 | bgp_zclient_reset (); |
| 3131 | access_list_reset (); |
| 3132 | prefix_list_reset (); |
| 3133 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3134 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3135 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3136 | value. */ |
| 3137 | int |
| 3138 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 3139 | { |
| 3140 | u_char *pnt; |
| 3141 | u_char *lim; |
| 3142 | struct prefix p; |
| 3143 | int psize; |
| 3144 | int ret; |
| 3145 | |
| 3146 | /* Check peer status. */ |
| 3147 | if (peer->status != Established) |
| 3148 | return 0; |
| 3149 | |
| 3150 | pnt = packet->nlri; |
| 3151 | lim = pnt + packet->length; |
| 3152 | |
| 3153 | for (; pnt < lim; pnt += psize) |
| 3154 | { |
| 3155 | /* Clear prefix structure. */ |
| 3156 | memset (&p, 0, sizeof (struct prefix)); |
| 3157 | |
| 3158 | /* Fetch prefix length. */ |
| 3159 | p.prefixlen = *pnt++; |
| 3160 | p.family = afi2family (packet->afi); |
| 3161 | |
| 3162 | /* Already checked in nlri_sanity_check(). We do double check |
| 3163 | here. */ |
| 3164 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 3165 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 3166 | return -1; |
| 3167 | |
| 3168 | /* Packet size overflow check. */ |
| 3169 | psize = PSIZE (p.prefixlen); |
| 3170 | |
| 3171 | /* When packet overflow occur return immediately. */ |
| 3172 | if (pnt + psize > lim) |
| 3173 | return -1; |
| 3174 | |
| 3175 | /* Fetch prefix from NLRI packet. */ |
| 3176 | memcpy (&p.u.prefix, pnt, psize); |
| 3177 | |
| 3178 | /* Check address. */ |
| 3179 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3180 | { |
| 3181 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3182 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3183 | /* |
| 3184 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 3185 | * If a BGP router receives an UPDATE message with a |
| 3186 | * semantically incorrect NLRI field, in which a prefix is |
| 3187 | * semantically incorrect (eg. an unexpected multicast IP |
| 3188 | * address), it should ignore the prefix. |
| 3189 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3190 | zlog (peer->log, LOG_ERR, |
| 3191 | "IPv4 unicast NLRI is multicast address %s", |
| 3192 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3193 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3194 | return -1; |
| 3195 | } |
| 3196 | } |
| 3197 | |
| 3198 | #ifdef HAVE_IPV6 |
| 3199 | /* Check address. */ |
| 3200 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3201 | { |
| 3202 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3203 | { |
| 3204 | char buf[BUFSIZ]; |
| 3205 | |
| 3206 | zlog (peer->log, LOG_WARNING, |
| 3207 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 3208 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3209 | |
| 3210 | continue; |
| 3211 | } |
| 3212 | } |
| 3213 | #endif /* HAVE_IPV6 */ |
| 3214 | |
| 3215 | /* Normal process. */ |
| 3216 | if (attr) |
| 3217 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3218 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3219 | else |
| 3220 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3221 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3222 | |
| 3223 | /* Address family configuration mismatch or maximum-prefix count |
| 3224 | overflow. */ |
| 3225 | if (ret < 0) |
| 3226 | return -1; |
| 3227 | } |
| 3228 | |
| 3229 | /* Packet length consistency check. */ |
| 3230 | if (pnt != lim) |
| 3231 | return -1; |
| 3232 | |
| 3233 | return 0; |
| 3234 | } |
| 3235 | |
| 3236 | /* NLRI encode syntax check routine. */ |
| 3237 | int |
| 3238 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 3239 | bgp_size_t length) |
| 3240 | { |
| 3241 | u_char *end; |
| 3242 | u_char prefixlen; |
| 3243 | int psize; |
| 3244 | |
| 3245 | end = pnt + length; |
| 3246 | |
| 3247 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 3248 | syntactic validity. If the field is syntactically incorrect, |
| 3249 | then the Error Subcode is set to Invalid Network Field. */ |
| 3250 | |
| 3251 | while (pnt < end) |
| 3252 | { |
| 3253 | prefixlen = *pnt++; |
| 3254 | |
| 3255 | /* Prefix length check. */ |
| 3256 | if ((afi == AFI_IP && prefixlen > 32) |
| 3257 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 3258 | { |
| 3259 | plog_err (peer->log, |
| 3260 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 3261 | peer->host, prefixlen); |
| 3262 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3263 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3264 | return -1; |
| 3265 | } |
| 3266 | |
| 3267 | /* Packet size overflow check. */ |
| 3268 | psize = PSIZE (prefixlen); |
| 3269 | |
| 3270 | if (pnt + psize > end) |
| 3271 | { |
| 3272 | plog_err (peer->log, |
| 3273 | "%s [Error] Update packet error" |
| 3274 | " (prefix data overflow prefix size is %d)", |
| 3275 | peer->host, psize); |
| 3276 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3277 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3278 | return -1; |
| 3279 | } |
| 3280 | |
| 3281 | pnt += psize; |
| 3282 | } |
| 3283 | |
| 3284 | /* Packet length consistency check. */ |
| 3285 | if (pnt != end) |
| 3286 | { |
| 3287 | plog_err (peer->log, |
| 3288 | "%s [Error] Update packet error" |
| 3289 | " (prefix length mismatch with total length)", |
| 3290 | peer->host); |
| 3291 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3292 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3293 | return -1; |
| 3294 | } |
| 3295 | return 0; |
| 3296 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3297 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3298 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3299 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3300 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3301 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3302 | } |
| 3303 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3304 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3305 | bgp_static_free (struct bgp_static *bgp_static) |
| 3306 | { |
| 3307 | if (bgp_static->rmap.name) |
| 3308 | free (bgp_static->rmap.name); |
| 3309 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3310 | } |
| 3311 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3312 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3313 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3314 | struct prefix *p, afi_t afi, safi_t safi) |
| 3315 | { |
| 3316 | struct bgp_node *rn; |
| 3317 | struct bgp_info *ri; |
| 3318 | |
| 3319 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3320 | |
| 3321 | /* Check selected route and self inserted route. */ |
| 3322 | for (ri = rn->info; ri; ri = ri->next) |
| 3323 | if (ri->peer == bgp->peer_self |
| 3324 | && ri->type == ZEBRA_ROUTE_BGP |
| 3325 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3326 | break; |
| 3327 | |
| 3328 | /* Withdraw static BGP route from routing table. */ |
| 3329 | if (ri) |
| 3330 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3331 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3332 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3333 | } |
| 3334 | |
| 3335 | /* Unlock bgp_node_lookup. */ |
| 3336 | bgp_unlock_node (rn); |
| 3337 | } |
| 3338 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3339 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3340 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3341 | struct bgp_static *bgp_static, |
| 3342 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3343 | { |
| 3344 | struct bgp_node *rn; |
| 3345 | struct bgp_info *ri; |
| 3346 | struct bgp_info *new; |
| 3347 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3348 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3349 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3350 | struct attr new_attr; |
| 3351 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3352 | struct bgp *bgp; |
| 3353 | int ret; |
| 3354 | char buf[SU_ADDRSTRLEN]; |
| 3355 | |
| 3356 | bgp = rsclient->bgp; |
| 3357 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3358 | assert (bgp_static); |
| 3359 | if (!bgp_static) |
| 3360 | return; |
| 3361 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3362 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3363 | |
| 3364 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3365 | |
| 3366 | attr.nexthop = bgp_static->igpnexthop; |
| 3367 | attr.med = bgp_static->igpmetric; |
| 3368 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3369 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3370 | if (bgp_static->atomic) |
| 3371 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3372 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3373 | /* Apply network route-map for export to this rsclient. */ |
| 3374 | if (bgp_static->rmap.name) |
| 3375 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3376 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3377 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3378 | info.attr = &attr_tmp; |
| 3379 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3380 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3381 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3382 | |
| 3383 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3384 | |
| 3385 | rsclient->rmap_type = 0; |
| 3386 | |
| 3387 | if (ret == RMAP_DENYMATCH) |
| 3388 | { |
| 3389 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3390 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3391 | |
| 3392 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3393 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3394 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3395 | bgp_attr_extra_free (&attr); |
| 3396 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3397 | return; |
| 3398 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3399 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3400 | } |
| 3401 | else |
| 3402 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3403 | |
| 3404 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3405 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3406 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3407 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3408 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3409 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3410 | == RMAP_DENY) |
| 3411 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3412 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3413 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3414 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3415 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3416 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3417 | p->prefixlen, rsclient->host); |
| 3418 | |
| 3419 | bgp->peer_self->rmap_type = 0; |
| 3420 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3421 | bgp_attr_unintern (&attr_new); |
| 3422 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3423 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3424 | |
| 3425 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3426 | |
| 3427 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3428 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3429 | |
| 3430 | bgp->peer_self->rmap_type = 0; |
| 3431 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3432 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3433 | attr_new = bgp_attr_intern (&new_attr); |
| 3434 | |
| 3435 | for (ri = rn->info; ri; ri = ri->next) |
| 3436 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3437 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3438 | break; |
| 3439 | |
| 3440 | if (ri) |
| 3441 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3442 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3443 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3444 | { |
| 3445 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3446 | bgp_attr_unintern (&attr_new); |
| 3447 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3448 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3449 | return; |
| 3450 | } |
| 3451 | else |
| 3452 | { |
| 3453 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3454 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3455 | |
| 3456 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3457 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3458 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3459 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3460 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3461 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3462 | |
| 3463 | /* Process change. */ |
| 3464 | bgp_process (bgp, rn, afi, safi); |
| 3465 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3466 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3467 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3468 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3469 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3470 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3471 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3472 | /* Make new BGP info. */ |
| 3473 | new = bgp_info_new (); |
| 3474 | new->type = ZEBRA_ROUTE_BGP; |
| 3475 | new->sub_type = BGP_ROUTE_STATIC; |
| 3476 | new->peer = bgp->peer_self; |
| 3477 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3478 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3479 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3480 | |
| 3481 | /* Register new BGP information. */ |
| 3482 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3483 | |
| 3484 | /* route_node_get lock */ |
| 3485 | bgp_unlock_node (rn); |
| 3486 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3487 | /* Process change. */ |
| 3488 | bgp_process (bgp, rn, afi, safi); |
| 3489 | |
| 3490 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3491 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3492 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3493 | } |
| 3494 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3495 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3496 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3497 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3498 | { |
| 3499 | struct bgp_node *rn; |
| 3500 | struct bgp_info *ri; |
| 3501 | struct bgp_info *new; |
| 3502 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3503 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3504 | struct attr *attr_new; |
| 3505 | int ret; |
| 3506 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3507 | assert (bgp_static); |
| 3508 | if (!bgp_static) |
| 3509 | return; |
| 3510 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3511 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3512 | |
| 3513 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3514 | |
| 3515 | attr.nexthop = bgp_static->igpnexthop; |
| 3516 | attr.med = bgp_static->igpmetric; |
| 3517 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3518 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3519 | if (bgp_static->atomic) |
| 3520 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3521 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3522 | /* Apply route-map. */ |
| 3523 | if (bgp_static->rmap.name) |
| 3524 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3525 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3526 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3527 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3528 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3529 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3530 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3531 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3532 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3533 | bgp->peer_self->rmap_type = 0; |
| 3534 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3535 | if (ret == RMAP_DENYMATCH) |
| 3536 | { |
| 3537 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3538 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3539 | |
| 3540 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3541 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3542 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3543 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3544 | return; |
| 3545 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3546 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3547 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3548 | else |
| 3549 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3550 | |
| 3551 | for (ri = rn->info; ri; ri = ri->next) |
| 3552 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3553 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3554 | break; |
| 3555 | |
| 3556 | if (ri) |
| 3557 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3558 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3559 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3560 | { |
| 3561 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3562 | bgp_attr_unintern (&attr_new); |
| 3563 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3564 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3565 | return; |
| 3566 | } |
| 3567 | else |
| 3568 | { |
| 3569 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3570 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3571 | |
| 3572 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3573 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3574 | bgp_info_restore(rn, ri); |
| 3575 | else |
| 3576 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3577 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3578 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3579 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3580 | |
| 3581 | /* Process change. */ |
| 3582 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3583 | bgp_process (bgp, rn, afi, safi); |
| 3584 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3585 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3586 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3587 | return; |
| 3588 | } |
| 3589 | } |
| 3590 | |
| 3591 | /* Make new BGP info. */ |
| 3592 | new = bgp_info_new (); |
| 3593 | new->type = ZEBRA_ROUTE_BGP; |
| 3594 | new->sub_type = BGP_ROUTE_STATIC; |
| 3595 | new->peer = bgp->peer_self; |
| 3596 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3597 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3598 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3599 | |
| 3600 | /* Aggregate address increment. */ |
| 3601 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3602 | |
| 3603 | /* Register new BGP information. */ |
| 3604 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3605 | |
| 3606 | /* route_node_get lock */ |
| 3607 | bgp_unlock_node (rn); |
| 3608 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3609 | /* Process change. */ |
| 3610 | bgp_process (bgp, rn, afi, safi); |
| 3611 | |
| 3612 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3613 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3614 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3615 | } |
| 3616 | |
| 3617 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3618 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3619 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3620 | { |
| 3621 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3622 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3623 | |
| 3624 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3625 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3626 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3627 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3628 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3629 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3630 | } |
| 3631 | } |
| 3632 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3633 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3634 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3635 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3636 | { |
| 3637 | struct bgp_node *rn; |
| 3638 | struct bgp_info *new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3639 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3640 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3641 | |
| 3642 | /* Make new BGP info. */ |
| 3643 | new = bgp_info_new (); |
| 3644 | new->type = ZEBRA_ROUTE_BGP; |
| 3645 | new->sub_type = BGP_ROUTE_STATIC; |
| 3646 | new->peer = bgp->peer_self; |
| 3647 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 3648 | SET_FLAG (new->flags, BGP_INFO_VALID); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3649 | new->uptime = bgp_clock (); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3650 | new->extra = bgp_info_extra_new(); |
| 3651 | memcpy (new->extra->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3652 | |
| 3653 | /* Aggregate address increment. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3654 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3655 | |
| 3656 | /* Register new BGP information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3657 | bgp_info_add (rn, new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3658 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3659 | /* route_node_get lock */ |
| 3660 | bgp_unlock_node (rn); |
| 3661 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3662 | /* Process change. */ |
| 3663 | bgp_process (bgp, rn, afi, safi); |
| 3664 | } |
| 3665 | |
| 3666 | void |
| 3667 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3668 | safi_t safi) |
| 3669 | { |
| 3670 | struct bgp_node *rn; |
| 3671 | struct bgp_info *ri; |
| 3672 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3673 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3674 | |
| 3675 | /* Check selected route and self inserted route. */ |
| 3676 | for (ri = rn->info; ri; ri = ri->next) |
| 3677 | if (ri->peer == bgp->peer_self |
| 3678 | && ri->type == ZEBRA_ROUTE_BGP |
| 3679 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3680 | break; |
| 3681 | |
| 3682 | /* Withdraw static BGP route from routing table. */ |
| 3683 | if (ri) |
| 3684 | { |
| 3685 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3686 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3687 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3688 | } |
| 3689 | |
| 3690 | /* Unlock bgp_node_lookup. */ |
| 3691 | bgp_unlock_node (rn); |
| 3692 | } |
| 3693 | |
| 3694 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3695 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3696 | { |
| 3697 | struct bgp_static *bgp_static; |
| 3698 | struct bgp *bgp; |
| 3699 | struct bgp_node *rn; |
| 3700 | struct prefix *p; |
| 3701 | |
| 3702 | bgp = rsclient->bgp; |
| 3703 | |
| 3704 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3705 | if ((bgp_static = rn->info) != NULL) |
| 3706 | { |
| 3707 | p = &rn->p; |
| 3708 | |
| 3709 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3710 | afi, safi); |
| 3711 | } |
| 3712 | } |
| 3713 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3714 | static void |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 3715 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3716 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3717 | { |
| 3718 | struct bgp_node *rn; |
| 3719 | struct bgp_info *ri; |
| 3720 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3721 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3722 | |
| 3723 | /* Check selected route and self inserted route. */ |
| 3724 | for (ri = rn->info; ri; ri = ri->next) |
| 3725 | if (ri->peer == bgp->peer_self |
| 3726 | && ri->type == ZEBRA_ROUTE_BGP |
| 3727 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3728 | break; |
| 3729 | |
| 3730 | /* Withdraw static BGP route from routing table. */ |
| 3731 | if (ri) |
| 3732 | { |
| 3733 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3734 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3735 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3736 | } |
| 3737 | |
| 3738 | /* Unlock bgp_node_lookup. */ |
| 3739 | bgp_unlock_node (rn); |
| 3740 | } |
| 3741 | |
| 3742 | /* Configure static BGP network. When user don't run zebra, static |
| 3743 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3744 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3745 | 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] | 3746 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3747 | { |
| 3748 | int ret; |
| 3749 | struct prefix p; |
| 3750 | struct bgp_static *bgp_static; |
| 3751 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3752 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3753 | |
| 3754 | /* Convert IP prefix string to struct prefix. */ |
| 3755 | ret = str2prefix (ip_str, &p); |
| 3756 | if (! ret) |
| 3757 | { |
| 3758 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3759 | return CMD_WARNING; |
| 3760 | } |
| 3761 | #ifdef HAVE_IPV6 |
| 3762 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3763 | { |
| 3764 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3765 | VTY_NEWLINE); |
| 3766 | return CMD_WARNING; |
| 3767 | } |
| 3768 | #endif /* HAVE_IPV6 */ |
| 3769 | |
| 3770 | apply_mask (&p); |
| 3771 | |
| 3772 | /* Set BGP static route configuration. */ |
| 3773 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3774 | |
| 3775 | if (rn->info) |
| 3776 | { |
| 3777 | /* Configuration change. */ |
| 3778 | bgp_static = rn->info; |
| 3779 | |
| 3780 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3781 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 3782 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3783 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3784 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3785 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3786 | if (rmap) |
| 3787 | { |
| 3788 | if (bgp_static->rmap.name) |
| 3789 | free (bgp_static->rmap.name); |
| 3790 | bgp_static->rmap.name = strdup (rmap); |
| 3791 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3792 | } |
| 3793 | else |
| 3794 | { |
| 3795 | if (bgp_static->rmap.name) |
| 3796 | free (bgp_static->rmap.name); |
| 3797 | bgp_static->rmap.name = NULL; |
| 3798 | bgp_static->rmap.map = NULL; |
| 3799 | bgp_static->valid = 0; |
| 3800 | } |
| 3801 | bgp_unlock_node (rn); |
| 3802 | } |
| 3803 | else |
| 3804 | { |
| 3805 | /* New configuration. */ |
| 3806 | bgp_static = bgp_static_new (); |
| 3807 | bgp_static->backdoor = backdoor; |
| 3808 | bgp_static->valid = 0; |
| 3809 | bgp_static->igpmetric = 0; |
| 3810 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3811 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3812 | if (rmap) |
| 3813 | { |
| 3814 | if (bgp_static->rmap.name) |
| 3815 | free (bgp_static->rmap.name); |
| 3816 | bgp_static->rmap.name = strdup (rmap); |
| 3817 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3818 | } |
| 3819 | rn->info = bgp_static; |
| 3820 | } |
| 3821 | |
| 3822 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3823 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3824 | { |
| 3825 | bgp_static->valid = 1; |
| 3826 | |
| 3827 | if (need_update) |
| 3828 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3829 | |
| 3830 | if (! bgp_static->backdoor) |
| 3831 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3832 | } |
| 3833 | |
| 3834 | return CMD_SUCCESS; |
| 3835 | } |
| 3836 | |
| 3837 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3838 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3839 | 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] | 3840 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3841 | { |
| 3842 | int ret; |
| 3843 | struct prefix p; |
| 3844 | struct bgp_static *bgp_static; |
| 3845 | struct bgp_node *rn; |
| 3846 | |
| 3847 | /* Convert IP prefix string to struct prefix. */ |
| 3848 | ret = str2prefix (ip_str, &p); |
| 3849 | if (! ret) |
| 3850 | { |
| 3851 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3852 | return CMD_WARNING; |
| 3853 | } |
| 3854 | #ifdef HAVE_IPV6 |
| 3855 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3856 | { |
| 3857 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3858 | VTY_NEWLINE); |
| 3859 | return CMD_WARNING; |
| 3860 | } |
| 3861 | #endif /* HAVE_IPV6 */ |
| 3862 | |
| 3863 | apply_mask (&p); |
| 3864 | |
| 3865 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3866 | if (! rn) |
| 3867 | { |
| 3868 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3869 | VTY_NEWLINE); |
| 3870 | return CMD_WARNING; |
| 3871 | } |
| 3872 | |
| 3873 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3874 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3875 | /* Update BGP RIB. */ |
| 3876 | if (! bgp_static->backdoor) |
| 3877 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3878 | |
| 3879 | /* Clear configuration. */ |
| 3880 | bgp_static_free (bgp_static); |
| 3881 | rn->info = NULL; |
| 3882 | bgp_unlock_node (rn); |
| 3883 | bgp_unlock_node (rn); |
| 3884 | |
| 3885 | return CMD_SUCCESS; |
| 3886 | } |
| 3887 | |
| 3888 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3889 | instance. */ |
| 3890 | void |
| 3891 | bgp_static_delete (struct bgp *bgp) |
| 3892 | { |
| 3893 | afi_t afi; |
| 3894 | safi_t safi; |
| 3895 | struct bgp_node *rn; |
| 3896 | struct bgp_node *rm; |
| 3897 | struct bgp_table *table; |
| 3898 | struct bgp_static *bgp_static; |
| 3899 | |
| 3900 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3901 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3902 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3903 | if (rn->info != NULL) |
| 3904 | { |
| 3905 | if (safi == SAFI_MPLS_VPN) |
| 3906 | { |
| 3907 | table = rn->info; |
| 3908 | |
| 3909 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3910 | { |
| 3911 | bgp_static = rn->info; |
| 3912 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3913 | AFI_IP, SAFI_MPLS_VPN, |
| 3914 | (struct prefix_rd *)&rn->p, |
| 3915 | bgp_static->tag); |
| 3916 | bgp_static_free (bgp_static); |
| 3917 | rn->info = NULL; |
| 3918 | bgp_unlock_node (rn); |
| 3919 | } |
| 3920 | } |
| 3921 | else |
| 3922 | { |
| 3923 | bgp_static = rn->info; |
| 3924 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3925 | bgp_static_free (bgp_static); |
| 3926 | rn->info = NULL; |
| 3927 | bgp_unlock_node (rn); |
| 3928 | } |
| 3929 | } |
| 3930 | } |
| 3931 | |
| 3932 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3933 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3934 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3935 | { |
| 3936 | int ret; |
| 3937 | struct prefix p; |
| 3938 | struct prefix_rd prd; |
| 3939 | struct bgp *bgp; |
| 3940 | struct bgp_node *prn; |
| 3941 | struct bgp_node *rn; |
| 3942 | struct bgp_table *table; |
| 3943 | struct bgp_static *bgp_static; |
| 3944 | u_char tag[3]; |
| 3945 | |
| 3946 | bgp = vty->index; |
| 3947 | |
| 3948 | ret = str2prefix (ip_str, &p); |
| 3949 | if (! ret) |
| 3950 | { |
| 3951 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3952 | return CMD_WARNING; |
| 3953 | } |
| 3954 | apply_mask (&p); |
| 3955 | |
| 3956 | ret = str2prefix_rd (rd_str, &prd); |
| 3957 | if (! ret) |
| 3958 | { |
| 3959 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3960 | return CMD_WARNING; |
| 3961 | } |
| 3962 | |
| 3963 | ret = str2tag (tag_str, tag); |
| 3964 | if (! ret) |
| 3965 | { |
| 3966 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3967 | return CMD_WARNING; |
| 3968 | } |
| 3969 | |
| 3970 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3971 | (struct prefix *)&prd); |
| 3972 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3973 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3974 | else |
| 3975 | bgp_unlock_node (prn); |
| 3976 | table = prn->info; |
| 3977 | |
| 3978 | rn = bgp_node_get (table, &p); |
| 3979 | |
| 3980 | if (rn->info) |
| 3981 | { |
| 3982 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3983 | bgp_unlock_node (rn); |
| 3984 | } |
| 3985 | else |
| 3986 | { |
| 3987 | /* New configuration. */ |
| 3988 | bgp_static = bgp_static_new (); |
| 3989 | bgp_static->valid = 1; |
| 3990 | memcpy (bgp_static->tag, tag, 3); |
| 3991 | rn->info = bgp_static; |
| 3992 | |
| 3993 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3994 | } |
| 3995 | |
| 3996 | return CMD_SUCCESS; |
| 3997 | } |
| 3998 | |
| 3999 | /* Configure static BGP network. */ |
| 4000 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4001 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 4002 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4003 | { |
| 4004 | int ret; |
| 4005 | struct bgp *bgp; |
| 4006 | struct prefix p; |
| 4007 | struct prefix_rd prd; |
| 4008 | struct bgp_node *prn; |
| 4009 | struct bgp_node *rn; |
| 4010 | struct bgp_table *table; |
| 4011 | struct bgp_static *bgp_static; |
| 4012 | u_char tag[3]; |
| 4013 | |
| 4014 | bgp = vty->index; |
| 4015 | |
| 4016 | /* Convert IP prefix string to struct prefix. */ |
| 4017 | ret = str2prefix (ip_str, &p); |
| 4018 | if (! ret) |
| 4019 | { |
| 4020 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4021 | return CMD_WARNING; |
| 4022 | } |
| 4023 | apply_mask (&p); |
| 4024 | |
| 4025 | ret = str2prefix_rd (rd_str, &prd); |
| 4026 | if (! ret) |
| 4027 | { |
| 4028 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4029 | return CMD_WARNING; |
| 4030 | } |
| 4031 | |
| 4032 | ret = str2tag (tag_str, tag); |
| 4033 | if (! ret) |
| 4034 | { |
| 4035 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4036 | return CMD_WARNING; |
| 4037 | } |
| 4038 | |
| 4039 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 4040 | (struct prefix *)&prd); |
| 4041 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 4042 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4043 | else |
| 4044 | bgp_unlock_node (prn); |
| 4045 | table = prn->info; |
| 4046 | |
| 4047 | rn = bgp_node_lookup (table, &p); |
| 4048 | |
| 4049 | if (rn) |
| 4050 | { |
| 4051 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 4052 | |
| 4053 | bgp_static = rn->info; |
| 4054 | bgp_static_free (bgp_static); |
| 4055 | rn->info = NULL; |
| 4056 | bgp_unlock_node (rn); |
| 4057 | bgp_unlock_node (rn); |
| 4058 | } |
| 4059 | else |
| 4060 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 4061 | |
| 4062 | return CMD_SUCCESS; |
| 4063 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4064 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4065 | DEFUN (bgp_network, |
| 4066 | bgp_network_cmd, |
| 4067 | "network A.B.C.D/M", |
| 4068 | "Specify a network to announce via BGP\n" |
| 4069 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4070 | { |
| 4071 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4072 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4073 | } |
| 4074 | |
| 4075 | DEFUN (bgp_network_route_map, |
| 4076 | bgp_network_route_map_cmd, |
| 4077 | "network A.B.C.D/M route-map WORD", |
| 4078 | "Specify a network to announce via BGP\n" |
| 4079 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4080 | "Route-map to modify the attributes\n" |
| 4081 | "Name of the route map\n") |
| 4082 | { |
| 4083 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4084 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4085 | } |
| 4086 | |
| 4087 | DEFUN (bgp_network_backdoor, |
| 4088 | bgp_network_backdoor_cmd, |
| 4089 | "network A.B.C.D/M backdoor", |
| 4090 | "Specify a network to announce via BGP\n" |
| 4091 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4092 | "Specify a BGP backdoor route\n") |
| 4093 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4094 | 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] | 4095 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4096 | } |
| 4097 | |
| 4098 | DEFUN (bgp_network_mask, |
| 4099 | bgp_network_mask_cmd, |
| 4100 | "network A.B.C.D mask A.B.C.D", |
| 4101 | "Specify a network to announce via BGP\n" |
| 4102 | "Network number\n" |
| 4103 | "Network mask\n" |
| 4104 | "Network mask\n") |
| 4105 | { |
| 4106 | int ret; |
| 4107 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4108 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4109 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4110 | if (! ret) |
| 4111 | { |
| 4112 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4113 | return CMD_WARNING; |
| 4114 | } |
| 4115 | |
| 4116 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4117 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4118 | } |
| 4119 | |
| 4120 | DEFUN (bgp_network_mask_route_map, |
| 4121 | bgp_network_mask_route_map_cmd, |
| 4122 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4123 | "Specify a network to announce via BGP\n" |
| 4124 | "Network number\n" |
| 4125 | "Network mask\n" |
| 4126 | "Network mask\n" |
| 4127 | "Route-map to modify the attributes\n" |
| 4128 | "Name of the route map\n") |
| 4129 | { |
| 4130 | int ret; |
| 4131 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4132 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4133 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4134 | if (! ret) |
| 4135 | { |
| 4136 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4137 | return CMD_WARNING; |
| 4138 | } |
| 4139 | |
| 4140 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4141 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4142 | } |
| 4143 | |
| 4144 | DEFUN (bgp_network_mask_backdoor, |
| 4145 | bgp_network_mask_backdoor_cmd, |
| 4146 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4147 | "Specify a network to announce via BGP\n" |
| 4148 | "Network number\n" |
| 4149 | "Network mask\n" |
| 4150 | "Network mask\n" |
| 4151 | "Specify a BGP backdoor route\n") |
| 4152 | { |
| 4153 | int ret; |
| 4154 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4155 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4156 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4157 | if (! ret) |
| 4158 | { |
| 4159 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4160 | return CMD_WARNING; |
| 4161 | } |
| 4162 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4163 | 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] | 4164 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4165 | } |
| 4166 | |
| 4167 | DEFUN (bgp_network_mask_natural, |
| 4168 | bgp_network_mask_natural_cmd, |
| 4169 | "network A.B.C.D", |
| 4170 | "Specify a network to announce via BGP\n" |
| 4171 | "Network number\n") |
| 4172 | { |
| 4173 | int ret; |
| 4174 | char prefix_str[BUFSIZ]; |
| 4175 | |
| 4176 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4177 | if (! ret) |
| 4178 | { |
| 4179 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4180 | return CMD_WARNING; |
| 4181 | } |
| 4182 | |
| 4183 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4184 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4185 | } |
| 4186 | |
| 4187 | DEFUN (bgp_network_mask_natural_route_map, |
| 4188 | bgp_network_mask_natural_route_map_cmd, |
| 4189 | "network A.B.C.D route-map WORD", |
| 4190 | "Specify a network to announce via BGP\n" |
| 4191 | "Network number\n" |
| 4192 | "Route-map to modify the attributes\n" |
| 4193 | "Name of the route map\n") |
| 4194 | { |
| 4195 | int ret; |
| 4196 | char prefix_str[BUFSIZ]; |
| 4197 | |
| 4198 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4199 | if (! ret) |
| 4200 | { |
| 4201 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4202 | return CMD_WARNING; |
| 4203 | } |
| 4204 | |
| 4205 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4206 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4207 | } |
| 4208 | |
| 4209 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4210 | bgp_network_mask_natural_backdoor_cmd, |
| 4211 | "network A.B.C.D backdoor", |
| 4212 | "Specify a network to announce via BGP\n" |
| 4213 | "Network number\n" |
| 4214 | "Specify a BGP backdoor route\n") |
| 4215 | { |
| 4216 | int ret; |
| 4217 | char prefix_str[BUFSIZ]; |
| 4218 | |
| 4219 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4220 | if (! ret) |
| 4221 | { |
| 4222 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4223 | return CMD_WARNING; |
| 4224 | } |
| 4225 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4226 | 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] | 4227 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4228 | } |
| 4229 | |
| 4230 | DEFUN (no_bgp_network, |
| 4231 | no_bgp_network_cmd, |
| 4232 | "no network A.B.C.D/M", |
| 4233 | NO_STR |
| 4234 | "Specify a network to announce via BGP\n" |
| 4235 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4236 | { |
| 4237 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4238 | bgp_node_safi (vty)); |
| 4239 | } |
| 4240 | |
| 4241 | ALIAS (no_bgp_network, |
| 4242 | no_bgp_network_route_map_cmd, |
| 4243 | "no network A.B.C.D/M route-map WORD", |
| 4244 | NO_STR |
| 4245 | "Specify a network to announce via BGP\n" |
| 4246 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4247 | "Route-map to modify the attributes\n" |
| 4248 | "Name of the route map\n") |
| 4249 | |
| 4250 | ALIAS (no_bgp_network, |
| 4251 | no_bgp_network_backdoor_cmd, |
| 4252 | "no network A.B.C.D/M backdoor", |
| 4253 | NO_STR |
| 4254 | "Specify a network to announce via BGP\n" |
| 4255 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4256 | "Specify a BGP backdoor route\n") |
| 4257 | |
| 4258 | DEFUN (no_bgp_network_mask, |
| 4259 | no_bgp_network_mask_cmd, |
| 4260 | "no network A.B.C.D mask A.B.C.D", |
| 4261 | NO_STR |
| 4262 | "Specify a network to announce via BGP\n" |
| 4263 | "Network number\n" |
| 4264 | "Network mask\n" |
| 4265 | "Network mask\n") |
| 4266 | { |
| 4267 | int ret; |
| 4268 | char prefix_str[BUFSIZ]; |
| 4269 | |
| 4270 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4271 | if (! ret) |
| 4272 | { |
| 4273 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4274 | return CMD_WARNING; |
| 4275 | } |
| 4276 | |
| 4277 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4278 | bgp_node_safi (vty)); |
| 4279 | } |
| 4280 | |
| 4281 | ALIAS (no_bgp_network_mask, |
| 4282 | no_bgp_network_mask_route_map_cmd, |
| 4283 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4284 | NO_STR |
| 4285 | "Specify a network to announce via BGP\n" |
| 4286 | "Network number\n" |
| 4287 | "Network mask\n" |
| 4288 | "Network mask\n" |
| 4289 | "Route-map to modify the attributes\n" |
| 4290 | "Name of the route map\n") |
| 4291 | |
| 4292 | ALIAS (no_bgp_network_mask, |
| 4293 | no_bgp_network_mask_backdoor_cmd, |
| 4294 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4295 | NO_STR |
| 4296 | "Specify a network to announce via BGP\n" |
| 4297 | "Network number\n" |
| 4298 | "Network mask\n" |
| 4299 | "Network mask\n" |
| 4300 | "Specify a BGP backdoor route\n") |
| 4301 | |
| 4302 | DEFUN (no_bgp_network_mask_natural, |
| 4303 | no_bgp_network_mask_natural_cmd, |
| 4304 | "no network A.B.C.D", |
| 4305 | NO_STR |
| 4306 | "Specify a network to announce via BGP\n" |
| 4307 | "Network number\n") |
| 4308 | { |
| 4309 | int ret; |
| 4310 | char prefix_str[BUFSIZ]; |
| 4311 | |
| 4312 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4313 | if (! ret) |
| 4314 | { |
| 4315 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4316 | return CMD_WARNING; |
| 4317 | } |
| 4318 | |
| 4319 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4320 | bgp_node_safi (vty)); |
| 4321 | } |
| 4322 | |
| 4323 | ALIAS (no_bgp_network_mask_natural, |
| 4324 | no_bgp_network_mask_natural_route_map_cmd, |
| 4325 | "no network A.B.C.D route-map WORD", |
| 4326 | NO_STR |
| 4327 | "Specify a network to announce via BGP\n" |
| 4328 | "Network number\n" |
| 4329 | "Route-map to modify the attributes\n" |
| 4330 | "Name of the route map\n") |
| 4331 | |
| 4332 | ALIAS (no_bgp_network_mask_natural, |
| 4333 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4334 | "no network A.B.C.D backdoor", |
| 4335 | NO_STR |
| 4336 | "Specify a network to announce via BGP\n" |
| 4337 | "Network number\n" |
| 4338 | "Specify a BGP backdoor route\n") |
| 4339 | |
| 4340 | #ifdef HAVE_IPV6 |
| 4341 | DEFUN (ipv6_bgp_network, |
| 4342 | ipv6_bgp_network_cmd, |
| 4343 | "network X:X::X:X/M", |
| 4344 | "Specify a network to announce via BGP\n" |
| 4345 | "IPv6 prefix <network>/<length>\n") |
| 4346 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4347 | 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] | 4348 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4349 | } |
| 4350 | |
| 4351 | DEFUN (ipv6_bgp_network_route_map, |
| 4352 | ipv6_bgp_network_route_map_cmd, |
| 4353 | "network X:X::X:X/M route-map WORD", |
| 4354 | "Specify a network to announce via BGP\n" |
| 4355 | "IPv6 prefix <network>/<length>\n" |
| 4356 | "Route-map to modify the attributes\n" |
| 4357 | "Name of the route map\n") |
| 4358 | { |
| 4359 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4360 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4361 | } |
| 4362 | |
| 4363 | DEFUN (no_ipv6_bgp_network, |
| 4364 | no_ipv6_bgp_network_cmd, |
| 4365 | "no network X:X::X:X/M", |
| 4366 | NO_STR |
| 4367 | "Specify a network to announce via BGP\n" |
| 4368 | "IPv6 prefix <network>/<length>\n") |
| 4369 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4370 | 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] | 4371 | } |
| 4372 | |
| 4373 | ALIAS (no_ipv6_bgp_network, |
| 4374 | no_ipv6_bgp_network_route_map_cmd, |
| 4375 | "no network X:X::X:X/M route-map WORD", |
| 4376 | NO_STR |
| 4377 | "Specify a network to announce via BGP\n" |
| 4378 | "IPv6 prefix <network>/<length>\n" |
| 4379 | "Route-map to modify the attributes\n" |
| 4380 | "Name of the route map\n") |
| 4381 | |
| 4382 | ALIAS (ipv6_bgp_network, |
| 4383 | old_ipv6_bgp_network_cmd, |
| 4384 | "ipv6 bgp network X:X::X:X/M", |
| 4385 | IPV6_STR |
| 4386 | BGP_STR |
| 4387 | "Specify a network to announce via BGP\n" |
| 4388 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4389 | |
| 4390 | ALIAS (no_ipv6_bgp_network, |
| 4391 | old_no_ipv6_bgp_network_cmd, |
| 4392 | "no ipv6 bgp network X:X::X:X/M", |
| 4393 | NO_STR |
| 4394 | IPV6_STR |
| 4395 | BGP_STR |
| 4396 | "Specify a network to announce via BGP\n" |
| 4397 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4398 | #endif /* HAVE_IPV6 */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4399 | |
| 4400 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4401 | ALIAS_DEPRECATED (bgp_network, |
| 4402 | bgp_network_ttl_cmd, |
| 4403 | "network A.B.C.D/M pathlimit <0-255>", |
| 4404 | "Specify a network to announce via BGP\n" |
| 4405 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4406 | "AS-Path hopcount limit attribute\n" |
| 4407 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4408 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4409 | bgp_network_backdoor_ttl_cmd, |
| 4410 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4411 | "Specify a network to announce via BGP\n" |
| 4412 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4413 | "Specify a BGP backdoor route\n" |
| 4414 | "AS-Path hopcount limit attribute\n" |
| 4415 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4416 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4417 | bgp_network_mask_ttl_cmd, |
| 4418 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4419 | "Specify a network to announce via BGP\n" |
| 4420 | "Network number\n" |
| 4421 | "Network mask\n" |
| 4422 | "Network mask\n" |
| 4423 | "AS-Path hopcount limit attribute\n" |
| 4424 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4425 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4426 | bgp_network_mask_backdoor_ttl_cmd, |
| 4427 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4428 | "Specify a network to announce via BGP\n" |
| 4429 | "Network number\n" |
| 4430 | "Network mask\n" |
| 4431 | "Network mask\n" |
| 4432 | "Specify a BGP backdoor route\n" |
| 4433 | "AS-Path hopcount limit attribute\n" |
| 4434 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4435 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4436 | bgp_network_mask_natural_ttl_cmd, |
| 4437 | "network A.B.C.D pathlimit <0-255>", |
| 4438 | "Specify a network to announce via BGP\n" |
| 4439 | "Network number\n" |
| 4440 | "AS-Path hopcount limit attribute\n" |
| 4441 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4442 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4443 | bgp_network_mask_natural_backdoor_ttl_cmd, |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 4444 | "network A.B.C.D backdoor pathlimit <1-255>", |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4445 | "Specify a network to announce via BGP\n" |
| 4446 | "Network number\n" |
| 4447 | "Specify a BGP backdoor route\n" |
| 4448 | "AS-Path hopcount limit attribute\n" |
| 4449 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4450 | ALIAS_DEPRECATED (no_bgp_network, |
| 4451 | no_bgp_network_ttl_cmd, |
| 4452 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4453 | NO_STR |
| 4454 | "Specify a network to announce via BGP\n" |
| 4455 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4456 | "AS-Path hopcount limit attribute\n" |
| 4457 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4458 | ALIAS_DEPRECATED (no_bgp_network, |
| 4459 | no_bgp_network_backdoor_ttl_cmd, |
| 4460 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4461 | NO_STR |
| 4462 | "Specify a network to announce via BGP\n" |
| 4463 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4464 | "Specify a BGP backdoor route\n" |
| 4465 | "AS-Path hopcount limit attribute\n" |
| 4466 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4467 | ALIAS_DEPRECATED (no_bgp_network, |
| 4468 | no_bgp_network_mask_ttl_cmd, |
| 4469 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4470 | NO_STR |
| 4471 | "Specify a network to announce via BGP\n" |
| 4472 | "Network number\n" |
| 4473 | "Network mask\n" |
| 4474 | "Network mask\n" |
| 4475 | "AS-Path hopcount limit attribute\n" |
| 4476 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4477 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4478 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4479 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4480 | NO_STR |
| 4481 | "Specify a network to announce via BGP\n" |
| 4482 | "Network number\n" |
| 4483 | "Network mask\n" |
| 4484 | "Network mask\n" |
| 4485 | "Specify a BGP backdoor route\n" |
| 4486 | "AS-Path hopcount limit attribute\n" |
| 4487 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4488 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4489 | no_bgp_network_mask_natural_ttl_cmd, |
| 4490 | "no network A.B.C.D pathlimit <0-255>", |
| 4491 | NO_STR |
| 4492 | "Specify a network to announce via BGP\n" |
| 4493 | "Network number\n" |
| 4494 | "AS-Path hopcount limit attribute\n" |
| 4495 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4496 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4497 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4498 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4499 | NO_STR |
| 4500 | "Specify a network to announce via BGP\n" |
| 4501 | "Network number\n" |
| 4502 | "Specify a BGP backdoor route\n" |
| 4503 | "AS-Path hopcount limit attribute\n" |
| 4504 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4505 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4506 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4507 | ipv6_bgp_network_ttl_cmd, |
| 4508 | "network X:X::X:X/M pathlimit <0-255>", |
| 4509 | "Specify a network to announce via BGP\n" |
| 4510 | "IPv6 prefix <network>/<length>\n" |
| 4511 | "AS-Path hopcount limit attribute\n" |
| 4512 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4513 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4514 | no_ipv6_bgp_network_ttl_cmd, |
| 4515 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4516 | NO_STR |
| 4517 | "Specify a network to announce via BGP\n" |
| 4518 | "IPv6 prefix <network>/<length>\n" |
| 4519 | "AS-Path hopcount limit attribute\n" |
| 4520 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4521 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4522 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4523 | /* Aggreagete address: |
| 4524 | |
| 4525 | advertise-map Set condition to advertise attribute |
| 4526 | as-set Generate AS set path information |
| 4527 | attribute-map Set attributes of aggregate |
| 4528 | route-map Set parameters of aggregate |
| 4529 | summary-only Filter more specific routes from updates |
| 4530 | suppress-map Conditionally filter more specific routes from updates |
| 4531 | <cr> |
| 4532 | */ |
| 4533 | struct bgp_aggregate |
| 4534 | { |
| 4535 | /* Summary-only flag. */ |
| 4536 | u_char summary_only; |
| 4537 | |
| 4538 | /* AS set generation. */ |
| 4539 | u_char as_set; |
| 4540 | |
| 4541 | /* Route-map for aggregated route. */ |
| 4542 | struct route_map *map; |
| 4543 | |
| 4544 | /* Suppress-count. */ |
| 4545 | unsigned long count; |
| 4546 | |
| 4547 | /* SAFI configuration. */ |
| 4548 | safi_t safi; |
| 4549 | }; |
| 4550 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4551 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4552 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4553 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4554 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4555 | } |
| 4556 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4557 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4558 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4559 | { |
| 4560 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4561 | } |
| 4562 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4563 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4564 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4565 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4566 | struct bgp_aggregate *aggregate) |
| 4567 | { |
| 4568 | struct bgp_table *table; |
| 4569 | struct bgp_node *top; |
| 4570 | struct bgp_node *rn; |
| 4571 | u_char origin; |
| 4572 | struct aspath *aspath = NULL; |
| 4573 | struct aspath *asmerge = NULL; |
| 4574 | struct community *community = NULL; |
| 4575 | struct community *commerge = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4576 | struct bgp_info *ri; |
| 4577 | struct bgp_info *new; |
| 4578 | int first = 1; |
| 4579 | unsigned long match = 0; |
| 4580 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4581 | /* ORIGIN attribute: If at least one route among routes that are |
| 4582 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4583 | aggregated route must have the ORIGIN attribute with the value |
| 4584 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4585 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4586 | route must have the origin attribute with the value EGP. In all |
| 4587 | other case the value of the ORIGIN attribute of the aggregated |
| 4588 | route is INTERNAL. */ |
| 4589 | origin = BGP_ORIGIN_IGP; |
| 4590 | |
| 4591 | table = bgp->rib[afi][safi]; |
| 4592 | |
| 4593 | top = bgp_node_get (table, p); |
| 4594 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4595 | if (rn->p.prefixlen > p->prefixlen) |
| 4596 | { |
| 4597 | match = 0; |
| 4598 | |
| 4599 | for (ri = rn->info; ri; ri = ri->next) |
| 4600 | { |
| 4601 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4602 | continue; |
| 4603 | |
| 4604 | if (del && ri == del) |
| 4605 | continue; |
| 4606 | |
| 4607 | if (! rinew && first) |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 4608 | first = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4609 | |
| 4610 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4611 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4612 | || ri->attr->med != med) |
| 4613 | { |
| 4614 | if (aspath) |
| 4615 | aspath_free (aspath); |
| 4616 | if (community) |
| 4617 | community_free (community); |
| 4618 | bgp_unlock_node (rn); |
| 4619 | bgp_unlock_node (top); |
| 4620 | return; |
| 4621 | } |
| 4622 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4623 | |
| 4624 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4625 | { |
| 4626 | if (aggregate->summary_only) |
| 4627 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4628 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4629 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4630 | match++; |
| 4631 | } |
| 4632 | |
| 4633 | aggregate->count++; |
| 4634 | |
| 4635 | if (aggregate->as_set) |
| 4636 | { |
| 4637 | if (origin < ri->attr->origin) |
| 4638 | origin = ri->attr->origin; |
| 4639 | |
| 4640 | if (aspath) |
| 4641 | { |
| 4642 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4643 | aspath_free (aspath); |
| 4644 | aspath = asmerge; |
| 4645 | } |
| 4646 | else |
| 4647 | aspath = aspath_dup (ri->attr->aspath); |
| 4648 | |
| 4649 | if (ri->attr->community) |
| 4650 | { |
| 4651 | if (community) |
| 4652 | { |
| 4653 | commerge = community_merge (community, |
| 4654 | ri->attr->community); |
| 4655 | community = community_uniq_sort (commerge); |
| 4656 | community_free (commerge); |
| 4657 | } |
| 4658 | else |
| 4659 | community = community_dup (ri->attr->community); |
| 4660 | } |
| 4661 | } |
| 4662 | } |
| 4663 | } |
| 4664 | if (match) |
| 4665 | bgp_process (bgp, rn, afi, safi); |
| 4666 | } |
| 4667 | bgp_unlock_node (top); |
| 4668 | |
| 4669 | if (rinew) |
| 4670 | { |
| 4671 | aggregate->count++; |
| 4672 | |
| 4673 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4674 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4675 | |
| 4676 | if (aggregate->as_set) |
| 4677 | { |
| 4678 | if (origin < rinew->attr->origin) |
| 4679 | origin = rinew->attr->origin; |
| 4680 | |
| 4681 | if (aspath) |
| 4682 | { |
| 4683 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4684 | aspath_free (aspath); |
| 4685 | aspath = asmerge; |
| 4686 | } |
| 4687 | else |
| 4688 | aspath = aspath_dup (rinew->attr->aspath); |
| 4689 | |
| 4690 | if (rinew->attr->community) |
| 4691 | { |
| 4692 | if (community) |
| 4693 | { |
| 4694 | commerge = community_merge (community, |
| 4695 | rinew->attr->community); |
| 4696 | community = community_uniq_sort (commerge); |
| 4697 | community_free (commerge); |
| 4698 | } |
| 4699 | else |
| 4700 | community = community_dup (rinew->attr->community); |
| 4701 | } |
| 4702 | } |
| 4703 | } |
| 4704 | |
| 4705 | if (aggregate->count > 0) |
| 4706 | { |
| 4707 | rn = bgp_node_get (table, p); |
| 4708 | new = bgp_info_new (); |
| 4709 | new->type = ZEBRA_ROUTE_BGP; |
| 4710 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4711 | new->peer = bgp->peer_self; |
| 4712 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4713 | 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] | 4714 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4715 | |
| 4716 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4717 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4718 | bgp_process (bgp, rn, afi, safi); |
| 4719 | } |
| 4720 | else |
| 4721 | { |
| 4722 | if (aspath) |
| 4723 | aspath_free (aspath); |
| 4724 | if (community) |
| 4725 | community_free (community); |
| 4726 | } |
| 4727 | } |
| 4728 | |
| 4729 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4730 | struct bgp_aggregate *); |
| 4731 | |
| 4732 | void |
| 4733 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4734 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4735 | { |
| 4736 | struct bgp_node *child; |
| 4737 | struct bgp_node *rn; |
| 4738 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4739 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4740 | |
| 4741 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4742 | if (safi == SAFI_MPLS_VPN) |
| 4743 | return; |
| 4744 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4745 | table = bgp->aggregate[afi][safi]; |
| 4746 | |
| 4747 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4748 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4749 | return; |
| 4750 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4751 | if (p->prefixlen == 0) |
| 4752 | return; |
| 4753 | |
| 4754 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4755 | return; |
| 4756 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4757 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4758 | |
| 4759 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4760 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4761 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4762 | { |
| 4763 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4764 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4765 | } |
| 4766 | bgp_unlock_node (child); |
| 4767 | } |
| 4768 | |
| 4769 | void |
| 4770 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4771 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4772 | { |
| 4773 | struct bgp_node *child; |
| 4774 | struct bgp_node *rn; |
| 4775 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4776 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4777 | |
| 4778 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4779 | if (safi == SAFI_MPLS_VPN) |
| 4780 | return; |
| 4781 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4782 | table = bgp->aggregate[afi][safi]; |
| 4783 | |
| 4784 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4785 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4786 | return; |
| 4787 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4788 | if (p->prefixlen == 0) |
| 4789 | return; |
| 4790 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4791 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4792 | |
| 4793 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4794 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4795 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4796 | { |
| 4797 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4798 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4799 | } |
| 4800 | bgp_unlock_node (child); |
| 4801 | } |
| 4802 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4803 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4804 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4805 | struct bgp_aggregate *aggregate) |
| 4806 | { |
| 4807 | struct bgp_table *table; |
| 4808 | struct bgp_node *top; |
| 4809 | struct bgp_node *rn; |
| 4810 | struct bgp_info *new; |
| 4811 | struct bgp_info *ri; |
| 4812 | unsigned long match; |
| 4813 | u_char origin = BGP_ORIGIN_IGP; |
| 4814 | struct aspath *aspath = NULL; |
| 4815 | struct aspath *asmerge = NULL; |
| 4816 | struct community *community = NULL; |
| 4817 | struct community *commerge = NULL; |
| 4818 | |
| 4819 | table = bgp->rib[afi][safi]; |
| 4820 | |
| 4821 | /* Sanity check. */ |
| 4822 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4823 | return; |
| 4824 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4825 | return; |
| 4826 | |
| 4827 | /* If routes exists below this node, generate aggregate routes. */ |
| 4828 | top = bgp_node_get (table, p); |
| 4829 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4830 | if (rn->p.prefixlen > p->prefixlen) |
| 4831 | { |
| 4832 | match = 0; |
| 4833 | |
| 4834 | for (ri = rn->info; ri; ri = ri->next) |
| 4835 | { |
| 4836 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4837 | continue; |
| 4838 | |
| 4839 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4840 | { |
| 4841 | /* summary-only aggregate route suppress aggregated |
| 4842 | route announcement. */ |
| 4843 | if (aggregate->summary_only) |
| 4844 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4845 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4846 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4847 | match++; |
| 4848 | } |
| 4849 | /* as-set aggregate route generate origin, as path, |
| 4850 | community aggregation. */ |
| 4851 | if (aggregate->as_set) |
| 4852 | { |
| 4853 | if (origin < ri->attr->origin) |
| 4854 | origin = ri->attr->origin; |
| 4855 | |
| 4856 | if (aspath) |
| 4857 | { |
| 4858 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4859 | aspath_free (aspath); |
| 4860 | aspath = asmerge; |
| 4861 | } |
| 4862 | else |
| 4863 | aspath = aspath_dup (ri->attr->aspath); |
| 4864 | |
| 4865 | if (ri->attr->community) |
| 4866 | { |
| 4867 | if (community) |
| 4868 | { |
| 4869 | commerge = community_merge (community, |
| 4870 | ri->attr->community); |
| 4871 | community = community_uniq_sort (commerge); |
| 4872 | community_free (commerge); |
| 4873 | } |
| 4874 | else |
| 4875 | community = community_dup (ri->attr->community); |
| 4876 | } |
| 4877 | } |
| 4878 | aggregate->count++; |
| 4879 | } |
| 4880 | } |
| 4881 | |
| 4882 | /* If this node is suppressed, process the change. */ |
| 4883 | if (match) |
| 4884 | bgp_process (bgp, rn, afi, safi); |
| 4885 | } |
| 4886 | bgp_unlock_node (top); |
| 4887 | |
| 4888 | /* Add aggregate route to BGP table. */ |
| 4889 | if (aggregate->count) |
| 4890 | { |
| 4891 | rn = bgp_node_get (table, p); |
| 4892 | |
| 4893 | new = bgp_info_new (); |
| 4894 | new->type = ZEBRA_ROUTE_BGP; |
| 4895 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4896 | new->peer = bgp->peer_self; |
| 4897 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4898 | 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] | 4899 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4900 | |
| 4901 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4902 | bgp_unlock_node (rn); |
| 4903 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4904 | /* Process change. */ |
| 4905 | bgp_process (bgp, rn, afi, safi); |
| 4906 | } |
Denil Vira | e2a9258 | 2015-08-11 13:34:59 -0700 | [diff] [blame] | 4907 | else |
| 4908 | { |
| 4909 | if (aspath) |
| 4910 | aspath_free (aspath); |
| 4911 | if (community) |
| 4912 | community_free (community); |
| 4913 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4914 | } |
| 4915 | |
| 4916 | void |
| 4917 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4918 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4919 | { |
| 4920 | struct bgp_table *table; |
| 4921 | struct bgp_node *top; |
| 4922 | struct bgp_node *rn; |
| 4923 | struct bgp_info *ri; |
| 4924 | unsigned long match; |
| 4925 | |
| 4926 | table = bgp->rib[afi][safi]; |
| 4927 | |
| 4928 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4929 | return; |
| 4930 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4931 | return; |
| 4932 | |
| 4933 | /* If routes exists below this node, generate aggregate routes. */ |
| 4934 | top = bgp_node_get (table, p); |
| 4935 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4936 | if (rn->p.prefixlen > p->prefixlen) |
| 4937 | { |
| 4938 | match = 0; |
| 4939 | |
| 4940 | for (ri = rn->info; ri; ri = ri->next) |
| 4941 | { |
| 4942 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4943 | continue; |
| 4944 | |
| 4945 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4946 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4947 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4948 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4949 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4950 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4951 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4952 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4953 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4954 | match++; |
| 4955 | } |
| 4956 | } |
| 4957 | aggregate->count--; |
| 4958 | } |
| 4959 | } |
| 4960 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4961 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4962 | if (match) |
| 4963 | bgp_process (bgp, rn, afi, safi); |
| 4964 | } |
| 4965 | bgp_unlock_node (top); |
| 4966 | |
| 4967 | /* Delete aggregate route from BGP table. */ |
| 4968 | rn = bgp_node_get (table, p); |
| 4969 | |
| 4970 | for (ri = rn->info; ri; ri = ri->next) |
| 4971 | if (ri->peer == bgp->peer_self |
| 4972 | && ri->type == ZEBRA_ROUTE_BGP |
| 4973 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4974 | break; |
| 4975 | |
| 4976 | /* Withdraw static BGP route from routing table. */ |
| 4977 | if (ri) |
| 4978 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4979 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4980 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4981 | } |
| 4982 | |
| 4983 | /* Unlock bgp_node_lookup. */ |
| 4984 | bgp_unlock_node (rn); |
| 4985 | } |
| 4986 | |
| 4987 | /* Aggregate route attribute. */ |
| 4988 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4989 | #define AGGREGATE_AS_SET 1 |
| 4990 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4991 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 4992 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4993 | afi_t afi, safi_t safi) |
| 4994 | { |
| 4995 | int ret; |
| 4996 | struct prefix p; |
| 4997 | struct bgp_node *rn; |
| 4998 | struct bgp *bgp; |
| 4999 | struct bgp_aggregate *aggregate; |
| 5000 | |
| 5001 | /* Convert string to prefix structure. */ |
| 5002 | ret = str2prefix (prefix_str, &p); |
| 5003 | if (!ret) |
| 5004 | { |
| 5005 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5006 | return CMD_WARNING; |
| 5007 | } |
| 5008 | apply_mask (&p); |
| 5009 | |
| 5010 | /* Get BGP structure. */ |
| 5011 | bgp = vty->index; |
| 5012 | |
| 5013 | /* Old configuration check. */ |
| 5014 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 5015 | if (! rn) |
| 5016 | { |
| 5017 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 5018 | VTY_NEWLINE); |
| 5019 | return CMD_WARNING; |
| 5020 | } |
| 5021 | |
| 5022 | aggregate = rn->info; |
| 5023 | if (aggregate->safi & SAFI_UNICAST) |
| 5024 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5025 | if (aggregate->safi & SAFI_MULTICAST) |
| 5026 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5027 | |
| 5028 | /* Unlock aggregate address configuration. */ |
| 5029 | rn->info = NULL; |
| 5030 | bgp_aggregate_free (aggregate); |
| 5031 | bgp_unlock_node (rn); |
| 5032 | bgp_unlock_node (rn); |
| 5033 | |
| 5034 | return CMD_SUCCESS; |
| 5035 | } |
| 5036 | |
| 5037 | static int |
| 5038 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5039 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5040 | u_char summary_only, u_char as_set) |
| 5041 | { |
| 5042 | int ret; |
| 5043 | struct prefix p; |
| 5044 | struct bgp_node *rn; |
| 5045 | struct bgp *bgp; |
| 5046 | struct bgp_aggregate *aggregate; |
| 5047 | |
| 5048 | /* Convert string to prefix structure. */ |
| 5049 | ret = str2prefix (prefix_str, &p); |
| 5050 | if (!ret) |
| 5051 | { |
| 5052 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5053 | return CMD_WARNING; |
| 5054 | } |
| 5055 | apply_mask (&p); |
| 5056 | |
| 5057 | /* Get BGP structure. */ |
| 5058 | bgp = vty->index; |
| 5059 | |
| 5060 | /* Old configuration check. */ |
| 5061 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 5062 | |
| 5063 | if (rn->info) |
| 5064 | { |
| 5065 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5066 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5067 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 5068 | if (ret) |
| 5069 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5070 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 5071 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5072 | return CMD_WARNING; |
| 5073 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5074 | } |
| 5075 | |
| 5076 | /* Make aggregate address structure. */ |
| 5077 | aggregate = bgp_aggregate_new (); |
| 5078 | aggregate->summary_only = summary_only; |
| 5079 | aggregate->as_set = as_set; |
| 5080 | aggregate->safi = safi; |
| 5081 | rn->info = aggregate; |
| 5082 | |
| 5083 | /* Aggregate address insert into BGP routing table. */ |
| 5084 | if (safi & SAFI_UNICAST) |
| 5085 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5086 | if (safi & SAFI_MULTICAST) |
| 5087 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5088 | |
| 5089 | return CMD_SUCCESS; |
| 5090 | } |
| 5091 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5092 | DEFUN (aggregate_address, |
| 5093 | aggregate_address_cmd, |
| 5094 | "aggregate-address A.B.C.D/M", |
| 5095 | "Configure BGP aggregate entries\n" |
| 5096 | "Aggregate prefix\n") |
| 5097 | { |
| 5098 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5099 | } |
| 5100 | |
| 5101 | DEFUN (aggregate_address_mask, |
| 5102 | aggregate_address_mask_cmd, |
| 5103 | "aggregate-address A.B.C.D A.B.C.D", |
| 5104 | "Configure BGP aggregate entries\n" |
| 5105 | "Aggregate address\n" |
| 5106 | "Aggregate mask\n") |
| 5107 | { |
| 5108 | int ret; |
| 5109 | char prefix_str[BUFSIZ]; |
| 5110 | |
| 5111 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5112 | |
| 5113 | if (! ret) |
| 5114 | { |
| 5115 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5116 | return CMD_WARNING; |
| 5117 | } |
| 5118 | |
| 5119 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5120 | 0, 0); |
| 5121 | } |
| 5122 | |
| 5123 | DEFUN (aggregate_address_summary_only, |
| 5124 | aggregate_address_summary_only_cmd, |
| 5125 | "aggregate-address A.B.C.D/M summary-only", |
| 5126 | "Configure BGP aggregate entries\n" |
| 5127 | "Aggregate prefix\n" |
| 5128 | "Filter more specific routes from updates\n") |
| 5129 | { |
| 5130 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5131 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5132 | } |
| 5133 | |
| 5134 | DEFUN (aggregate_address_mask_summary_only, |
| 5135 | aggregate_address_mask_summary_only_cmd, |
| 5136 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5137 | "Configure BGP aggregate entries\n" |
| 5138 | "Aggregate address\n" |
| 5139 | "Aggregate mask\n" |
| 5140 | "Filter more specific routes from updates\n") |
| 5141 | { |
| 5142 | int ret; |
| 5143 | char prefix_str[BUFSIZ]; |
| 5144 | |
| 5145 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5146 | |
| 5147 | if (! ret) |
| 5148 | { |
| 5149 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5150 | return CMD_WARNING; |
| 5151 | } |
| 5152 | |
| 5153 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5154 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5155 | } |
| 5156 | |
| 5157 | DEFUN (aggregate_address_as_set, |
| 5158 | aggregate_address_as_set_cmd, |
| 5159 | "aggregate-address A.B.C.D/M as-set", |
| 5160 | "Configure BGP aggregate entries\n" |
| 5161 | "Aggregate prefix\n" |
| 5162 | "Generate AS set path information\n") |
| 5163 | { |
| 5164 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5165 | 0, AGGREGATE_AS_SET); |
| 5166 | } |
| 5167 | |
| 5168 | DEFUN (aggregate_address_mask_as_set, |
| 5169 | aggregate_address_mask_as_set_cmd, |
| 5170 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5171 | "Configure BGP aggregate entries\n" |
| 5172 | "Aggregate address\n" |
| 5173 | "Aggregate mask\n" |
| 5174 | "Generate AS set path information\n") |
| 5175 | { |
| 5176 | int ret; |
| 5177 | char prefix_str[BUFSIZ]; |
| 5178 | |
| 5179 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5180 | |
| 5181 | if (! ret) |
| 5182 | { |
| 5183 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5184 | return CMD_WARNING; |
| 5185 | } |
| 5186 | |
| 5187 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5188 | 0, AGGREGATE_AS_SET); |
| 5189 | } |
| 5190 | |
| 5191 | |
| 5192 | DEFUN (aggregate_address_as_set_summary, |
| 5193 | aggregate_address_as_set_summary_cmd, |
| 5194 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5195 | "Configure BGP aggregate entries\n" |
| 5196 | "Aggregate prefix\n" |
| 5197 | "Generate AS set path information\n" |
| 5198 | "Filter more specific routes from updates\n") |
| 5199 | { |
| 5200 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5201 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5202 | } |
| 5203 | |
| 5204 | ALIAS (aggregate_address_as_set_summary, |
| 5205 | aggregate_address_summary_as_set_cmd, |
| 5206 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5207 | "Configure BGP aggregate entries\n" |
| 5208 | "Aggregate prefix\n" |
| 5209 | "Filter more specific routes from updates\n" |
| 5210 | "Generate AS set path information\n") |
| 5211 | |
| 5212 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5213 | aggregate_address_mask_as_set_summary_cmd, |
| 5214 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5215 | "Configure BGP aggregate entries\n" |
| 5216 | "Aggregate address\n" |
| 5217 | "Aggregate mask\n" |
| 5218 | "Generate AS set path information\n" |
| 5219 | "Filter more specific routes from updates\n") |
| 5220 | { |
| 5221 | int ret; |
| 5222 | char prefix_str[BUFSIZ]; |
| 5223 | |
| 5224 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5225 | |
| 5226 | if (! ret) |
| 5227 | { |
| 5228 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5229 | return CMD_WARNING; |
| 5230 | } |
| 5231 | |
| 5232 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5233 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5234 | } |
| 5235 | |
| 5236 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5237 | aggregate_address_mask_summary_as_set_cmd, |
| 5238 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5239 | "Configure BGP aggregate entries\n" |
| 5240 | "Aggregate address\n" |
| 5241 | "Aggregate mask\n" |
| 5242 | "Filter more specific routes from updates\n" |
| 5243 | "Generate AS set path information\n") |
| 5244 | |
| 5245 | DEFUN (no_aggregate_address, |
| 5246 | no_aggregate_address_cmd, |
| 5247 | "no aggregate-address A.B.C.D/M", |
| 5248 | NO_STR |
| 5249 | "Configure BGP aggregate entries\n" |
| 5250 | "Aggregate prefix\n") |
| 5251 | { |
| 5252 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5253 | } |
| 5254 | |
| 5255 | ALIAS (no_aggregate_address, |
| 5256 | no_aggregate_address_summary_only_cmd, |
| 5257 | "no aggregate-address A.B.C.D/M summary-only", |
| 5258 | NO_STR |
| 5259 | "Configure BGP aggregate entries\n" |
| 5260 | "Aggregate prefix\n" |
| 5261 | "Filter more specific routes from updates\n") |
| 5262 | |
| 5263 | ALIAS (no_aggregate_address, |
| 5264 | no_aggregate_address_as_set_cmd, |
| 5265 | "no aggregate-address A.B.C.D/M as-set", |
| 5266 | NO_STR |
| 5267 | "Configure BGP aggregate entries\n" |
| 5268 | "Aggregate prefix\n" |
| 5269 | "Generate AS set path information\n") |
| 5270 | |
| 5271 | ALIAS (no_aggregate_address, |
| 5272 | no_aggregate_address_as_set_summary_cmd, |
| 5273 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5274 | NO_STR |
| 5275 | "Configure BGP aggregate entries\n" |
| 5276 | "Aggregate prefix\n" |
| 5277 | "Generate AS set path information\n" |
| 5278 | "Filter more specific routes from updates\n") |
| 5279 | |
| 5280 | ALIAS (no_aggregate_address, |
| 5281 | no_aggregate_address_summary_as_set_cmd, |
| 5282 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5283 | NO_STR |
| 5284 | "Configure BGP aggregate entries\n" |
| 5285 | "Aggregate prefix\n" |
| 5286 | "Filter more specific routes from updates\n" |
| 5287 | "Generate AS set path information\n") |
| 5288 | |
| 5289 | DEFUN (no_aggregate_address_mask, |
| 5290 | no_aggregate_address_mask_cmd, |
| 5291 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5292 | NO_STR |
| 5293 | "Configure BGP aggregate entries\n" |
| 5294 | "Aggregate address\n" |
| 5295 | "Aggregate mask\n") |
| 5296 | { |
| 5297 | int ret; |
| 5298 | char prefix_str[BUFSIZ]; |
| 5299 | |
| 5300 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5301 | |
| 5302 | if (! ret) |
| 5303 | { |
| 5304 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5305 | return CMD_WARNING; |
| 5306 | } |
| 5307 | |
| 5308 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5309 | } |
| 5310 | |
| 5311 | ALIAS (no_aggregate_address_mask, |
| 5312 | no_aggregate_address_mask_summary_only_cmd, |
| 5313 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5314 | NO_STR |
| 5315 | "Configure BGP aggregate entries\n" |
| 5316 | "Aggregate address\n" |
| 5317 | "Aggregate mask\n" |
| 5318 | "Filter more specific routes from updates\n") |
| 5319 | |
| 5320 | ALIAS (no_aggregate_address_mask, |
| 5321 | no_aggregate_address_mask_as_set_cmd, |
| 5322 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5323 | NO_STR |
| 5324 | "Configure BGP aggregate entries\n" |
| 5325 | "Aggregate address\n" |
| 5326 | "Aggregate mask\n" |
| 5327 | "Generate AS set path information\n") |
| 5328 | |
| 5329 | ALIAS (no_aggregate_address_mask, |
| 5330 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5331 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5332 | NO_STR |
| 5333 | "Configure BGP aggregate entries\n" |
| 5334 | "Aggregate address\n" |
| 5335 | "Aggregate mask\n" |
| 5336 | "Generate AS set path information\n" |
| 5337 | "Filter more specific routes from updates\n") |
| 5338 | |
| 5339 | ALIAS (no_aggregate_address_mask, |
| 5340 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5341 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5342 | NO_STR |
| 5343 | "Configure BGP aggregate entries\n" |
| 5344 | "Aggregate address\n" |
| 5345 | "Aggregate mask\n" |
| 5346 | "Filter more specific routes from updates\n" |
| 5347 | "Generate AS set path information\n") |
| 5348 | |
| 5349 | #ifdef HAVE_IPV6 |
| 5350 | DEFUN (ipv6_aggregate_address, |
| 5351 | ipv6_aggregate_address_cmd, |
| 5352 | "aggregate-address X:X::X:X/M", |
| 5353 | "Configure BGP aggregate entries\n" |
| 5354 | "Aggregate prefix\n") |
| 5355 | { |
| 5356 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5357 | } |
| 5358 | |
| 5359 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5360 | ipv6_aggregate_address_summary_only_cmd, |
| 5361 | "aggregate-address X:X::X:X/M summary-only", |
| 5362 | "Configure BGP aggregate entries\n" |
| 5363 | "Aggregate prefix\n" |
| 5364 | "Filter more specific routes from updates\n") |
| 5365 | { |
| 5366 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5367 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5368 | } |
| 5369 | |
| 5370 | DEFUN (no_ipv6_aggregate_address, |
| 5371 | no_ipv6_aggregate_address_cmd, |
| 5372 | "no aggregate-address X:X::X:X/M", |
| 5373 | NO_STR |
| 5374 | "Configure BGP aggregate entries\n" |
| 5375 | "Aggregate prefix\n") |
| 5376 | { |
| 5377 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5378 | } |
| 5379 | |
| 5380 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5381 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5382 | "no aggregate-address X:X::X:X/M summary-only", |
| 5383 | NO_STR |
| 5384 | "Configure BGP aggregate entries\n" |
| 5385 | "Aggregate prefix\n" |
| 5386 | "Filter more specific routes from updates\n") |
| 5387 | { |
| 5388 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5389 | } |
| 5390 | |
| 5391 | ALIAS (ipv6_aggregate_address, |
| 5392 | old_ipv6_aggregate_address_cmd, |
| 5393 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5394 | IPV6_STR |
| 5395 | BGP_STR |
| 5396 | "Configure BGP aggregate entries\n" |
| 5397 | "Aggregate prefix\n") |
| 5398 | |
| 5399 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5400 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5401 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5402 | IPV6_STR |
| 5403 | BGP_STR |
| 5404 | "Configure BGP aggregate entries\n" |
| 5405 | "Aggregate prefix\n" |
| 5406 | "Filter more specific routes from updates\n") |
| 5407 | |
| 5408 | ALIAS (no_ipv6_aggregate_address, |
| 5409 | old_no_ipv6_aggregate_address_cmd, |
| 5410 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5411 | NO_STR |
| 5412 | IPV6_STR |
| 5413 | BGP_STR |
| 5414 | "Configure BGP aggregate entries\n" |
| 5415 | "Aggregate prefix\n") |
| 5416 | |
| 5417 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5418 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5419 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5420 | NO_STR |
| 5421 | IPV6_STR |
| 5422 | BGP_STR |
| 5423 | "Configure BGP aggregate entries\n" |
| 5424 | "Aggregate prefix\n" |
| 5425 | "Filter more specific routes from updates\n") |
| 5426 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5427 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5428 | /* Redistribute route treatment. */ |
| 5429 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5430 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5431 | const struct in6_addr *nexthop6, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5432 | u_int32_t metric, u_char type) |
| 5433 | { |
| 5434 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5435 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5436 | struct bgp_info *new; |
| 5437 | struct bgp_info *bi; |
| 5438 | struct bgp_info info; |
| 5439 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5440 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5441 | struct attr *new_attr; |
| 5442 | afi_t afi; |
| 5443 | int ret; |
| 5444 | |
| 5445 | /* Make default attribute. */ |
| 5446 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5447 | if (nexthop) |
| 5448 | attr.nexthop = *nexthop; |
| 5449 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5450 | #ifdef HAVE_IPV6 |
| 5451 | if (nexthop6) |
| 5452 | { |
| 5453 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5454 | extra->mp_nexthop_global = *nexthop6; |
| 5455 | extra->mp_nexthop_len = 16; |
| 5456 | } |
| 5457 | #endif |
| 5458 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5459 | attr.med = metric; |
| 5460 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5461 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5462 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5463 | { |
| 5464 | afi = family2afi (p->family); |
| 5465 | |
| 5466 | if (bgp->redist[afi][type]) |
| 5467 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5468 | struct attr attr_new; |
| 5469 | struct attr_extra extra_new; |
| 5470 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5471 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5472 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5473 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5474 | |
| 5475 | if (bgp->redist_metric_flag[afi][type]) |
| 5476 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5477 | |
| 5478 | /* Apply route-map. */ |
Daniel Walton | 1994dc8 | 2015-09-17 10:15:59 -0400 | [diff] [blame] | 5479 | if (bgp->rmap[afi][type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5480 | { |
| 5481 | info.peer = bgp->peer_self; |
| 5482 | info.attr = &attr_new; |
| 5483 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5484 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5485 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5486 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5487 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5488 | |
| 5489 | bgp->peer_self->rmap_type = 0; |
| 5490 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5491 | if (ret == RMAP_DENYMATCH) |
| 5492 | { |
| 5493 | /* Free uninterned attribute. */ |
| 5494 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5495 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5496 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5497 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5498 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5499 | bgp_redistribute_delete (p, type); |
| 5500 | return; |
| 5501 | } |
| 5502 | } |
| 5503 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5504 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5505 | afi, SAFI_UNICAST, p, NULL); |
| 5506 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5507 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5508 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5509 | for (bi = bn->info; bi; bi = bi->next) |
| 5510 | if (bi->peer == bgp->peer_self |
| 5511 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5512 | break; |
| 5513 | |
| 5514 | if (bi) |
| 5515 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5516 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5517 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5518 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5519 | bgp_attr_unintern (&new_attr); |
| 5520 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5521 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5522 | bgp_unlock_node (bn); |
| 5523 | return; |
| 5524 | } |
| 5525 | else |
| 5526 | { |
| 5527 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5528 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5529 | |
| 5530 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5531 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5532 | bgp_info_restore(bn, bi); |
| 5533 | else |
| 5534 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5535 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5536 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5537 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5538 | |
| 5539 | /* Process change. */ |
| 5540 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5541 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5542 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5543 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5544 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5545 | return; |
| 5546 | } |
| 5547 | } |
| 5548 | |
| 5549 | new = bgp_info_new (); |
| 5550 | new->type = type; |
| 5551 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 5552 | new->peer = bgp->peer_self; |
| 5553 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5554 | new->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5555 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5556 | |
| 5557 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5558 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5559 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5560 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5561 | } |
| 5562 | } |
| 5563 | |
| 5564 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5565 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5566 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5567 | } |
| 5568 | |
| 5569 | void |
| 5570 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5571 | { |
| 5572 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5573 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5574 | afi_t afi; |
| 5575 | struct bgp_node *rn; |
| 5576 | struct bgp_info *ri; |
| 5577 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5578 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5579 | { |
| 5580 | afi = family2afi (p->family); |
| 5581 | |
| 5582 | if (bgp->redist[afi][type]) |
| 5583 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5584 | 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] | 5585 | |
| 5586 | for (ri = rn->info; ri; ri = ri->next) |
| 5587 | if (ri->peer == bgp->peer_self |
| 5588 | && ri->type == type) |
| 5589 | break; |
| 5590 | |
| 5591 | if (ri) |
| 5592 | { |
| 5593 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5594 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5595 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5596 | } |
| 5597 | bgp_unlock_node (rn); |
| 5598 | } |
| 5599 | } |
| 5600 | } |
| 5601 | |
| 5602 | /* Withdraw specified route type's route. */ |
| 5603 | void |
| 5604 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5605 | { |
| 5606 | struct bgp_node *rn; |
| 5607 | struct bgp_info *ri; |
| 5608 | struct bgp_table *table; |
| 5609 | |
| 5610 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5611 | |
| 5612 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5613 | { |
| 5614 | for (ri = rn->info; ri; ri = ri->next) |
| 5615 | if (ri->peer == bgp->peer_self |
| 5616 | && ri->type == type) |
| 5617 | break; |
| 5618 | |
| 5619 | if (ri) |
| 5620 | { |
| 5621 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5622 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5623 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5624 | } |
| 5625 | } |
| 5626 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5627 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5628 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5629 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5630 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5631 | { |
| 5632 | int len; |
| 5633 | u_int32_t destination; |
| 5634 | char buf[BUFSIZ]; |
| 5635 | |
| 5636 | if (p->family == AF_INET) |
| 5637 | { |
| 5638 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5639 | destination = ntohl (p->u.prefix4.s_addr); |
| 5640 | |
| 5641 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5642 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5643 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5644 | || p->u.prefix4.s_addr == 0) |
| 5645 | { |
| 5646 | /* When mask is natural, mask is not displayed. */ |
| 5647 | } |
| 5648 | else |
| 5649 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5650 | } |
| 5651 | else |
| 5652 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5653 | p->prefixlen); |
| 5654 | |
| 5655 | len = 17 - len; |
| 5656 | if (len < 1) |
| 5657 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5658 | else |
| 5659 | vty_out (vty, "%*s", len, " "); |
| 5660 | } |
| 5661 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5662 | enum bgp_display_type |
| 5663 | { |
| 5664 | normal_list, |
| 5665 | }; |
| 5666 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5667 | /* Print the short form route status for a bgp_info */ |
| 5668 | static void |
| 5669 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5670 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5671 | /* Route status display. */ |
| 5672 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5673 | vty_out (vty, "R"); |
| 5674 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5675 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5676 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5677 | vty_out (vty, "s"); |
| 5678 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5679 | vty_out (vty, "*"); |
| 5680 | else |
| 5681 | vty_out (vty, " "); |
| 5682 | |
| 5683 | /* Selected */ |
| 5684 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5685 | vty_out (vty, "h"); |
| 5686 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5687 | vty_out (vty, "d"); |
| 5688 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5689 | vty_out (vty, ">"); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 5690 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
| 5691 | vty_out (vty, "="); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5692 | else |
| 5693 | vty_out (vty, " "); |
| 5694 | |
| 5695 | /* Internal route. */ |
| 5696 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5697 | vty_out (vty, "i"); |
| 5698 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5699 | vty_out (vty, " "); |
| 5700 | } |
| 5701 | |
| 5702 | /* called from terminal list command */ |
| 5703 | void |
| 5704 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5705 | struct bgp_info *binfo, int display, safi_t safi) |
| 5706 | { |
| 5707 | struct attr *attr; |
| 5708 | |
| 5709 | /* short status lead text */ |
| 5710 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5711 | |
| 5712 | /* print prefix and mask */ |
| 5713 | if (! display) |
| 5714 | route_vty_out_route (p, vty); |
| 5715 | else |
| 5716 | vty_out (vty, "%*s", 17, " "); |
| 5717 | |
| 5718 | /* Print attribute */ |
| 5719 | attr = binfo->attr; |
| 5720 | if (attr) |
| 5721 | { |
| 5722 | if (p->family == AF_INET) |
| 5723 | { |
| 5724 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5725 | vty_out (vty, "%-16s", |
| 5726 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5727 | else |
| 5728 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5729 | } |
| 5730 | #ifdef HAVE_IPV6 |
| 5731 | else if (p->family == AF_INET6) |
| 5732 | { |
| 5733 | int len; |
| 5734 | char buf[BUFSIZ]; |
| 5735 | |
| 5736 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5737 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5738 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5739 | len = 16 - len; |
| 5740 | if (len < 1) |
| 5741 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5742 | else |
| 5743 | vty_out (vty, "%*s", len, " "); |
| 5744 | } |
| 5745 | #endif /* HAVE_IPV6 */ |
| 5746 | |
| 5747 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5748 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5749 | else |
| 5750 | vty_out (vty, " "); |
| 5751 | |
| 5752 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5753 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5754 | else |
| 5755 | vty_out (vty, " "); |
| 5756 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5757 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5758 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5759 | /* Print aspath */ |
| 5760 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5761 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5762 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5763 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5764 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5765 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5766 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5767 | } |
| 5768 | |
| 5769 | /* called from terminal list command */ |
| 5770 | void |
| 5771 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5772 | struct attr *attr, safi_t safi) |
| 5773 | { |
| 5774 | /* Route status display. */ |
| 5775 | vty_out (vty, "*"); |
| 5776 | vty_out (vty, ">"); |
| 5777 | vty_out (vty, " "); |
| 5778 | |
| 5779 | /* print prefix and mask */ |
| 5780 | route_vty_out_route (p, vty); |
| 5781 | |
| 5782 | /* Print attribute */ |
| 5783 | if (attr) |
| 5784 | { |
| 5785 | if (p->family == AF_INET) |
| 5786 | { |
| 5787 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5788 | vty_out (vty, "%-16s", |
| 5789 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5790 | else |
| 5791 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5792 | } |
| 5793 | #ifdef HAVE_IPV6 |
| 5794 | else if (p->family == AF_INET6) |
| 5795 | { |
| 5796 | int len; |
| 5797 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5798 | |
| 5799 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5800 | |
| 5801 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5802 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5803 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5804 | len = 16 - len; |
| 5805 | if (len < 1) |
| 5806 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5807 | else |
| 5808 | vty_out (vty, "%*s", len, " "); |
| 5809 | } |
| 5810 | #endif /* HAVE_IPV6 */ |
| 5811 | |
| 5812 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5813 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5814 | else |
| 5815 | vty_out (vty, " "); |
| 5816 | |
| 5817 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5818 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5819 | else |
| 5820 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5821 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 5822 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5823 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5824 | /* Print aspath */ |
| 5825 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5826 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5827 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5828 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5829 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5830 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5831 | |
| 5832 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5833 | } |
| 5834 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5835 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5836 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 5837 | struct bgp_info *binfo, int display, safi_t safi) |
| 5838 | { |
| 5839 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5840 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5841 | |
| 5842 | if (!binfo->extra) |
| 5843 | return; |
| 5844 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5845 | /* short status lead text */ |
| 5846 | route_vty_short_status_out (vty, binfo); |
| 5847 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5848 | /* print prefix and mask */ |
| 5849 | if (! display) |
| 5850 | route_vty_out_route (p, vty); |
| 5851 | else |
| 5852 | vty_out (vty, "%*s", 17, " "); |
| 5853 | |
| 5854 | /* Print attribute */ |
| 5855 | attr = binfo->attr; |
| 5856 | if (attr) |
| 5857 | { |
| 5858 | if (p->family == AF_INET) |
| 5859 | { |
| 5860 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5861 | vty_out (vty, "%-16s", |
| 5862 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5863 | else |
| 5864 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5865 | } |
| 5866 | #ifdef HAVE_IPV6 |
| 5867 | else if (p->family == AF_INET6) |
| 5868 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5869 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5870 | char buf[BUFSIZ]; |
| 5871 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5872 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5873 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5874 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5875 | buf, BUFSIZ)); |
| 5876 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5877 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5878 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5879 | buf, BUFSIZ), |
| 5880 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 5881 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5882 | |
| 5883 | } |
| 5884 | #endif /* HAVE_IPV6 */ |
| 5885 | } |
| 5886 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5887 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5888 | |
| 5889 | vty_out (vty, "notag/%d", label); |
| 5890 | |
| 5891 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5892 | } |
| 5893 | |
| 5894 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5895 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5896 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5897 | struct bgp_info *binfo, int display, safi_t safi) |
| 5898 | { |
| 5899 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5900 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5901 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5902 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5903 | /* short status lead text */ |
| 5904 | route_vty_short_status_out (vty, binfo); |
| 5905 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5906 | /* print prefix and mask */ |
| 5907 | if (! display) |
| 5908 | route_vty_out_route (p, vty); |
| 5909 | else |
| 5910 | vty_out (vty, "%*s", 17, " "); |
| 5911 | |
| 5912 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5913 | len = 17 - len; |
| 5914 | if (len < 1) |
| 5915 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5916 | else |
| 5917 | vty_out (vty, "%*s", len, " "); |
| 5918 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5919 | 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] | 5920 | |
| 5921 | /* Print attribute */ |
| 5922 | attr = binfo->attr; |
| 5923 | if (attr) |
| 5924 | { |
| 5925 | /* Print aspath */ |
| 5926 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5927 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5928 | |
| 5929 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5930 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5931 | } |
| 5932 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5933 | } |
| 5934 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5935 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5936 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5937 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5938 | struct bgp_info *binfo, int display, safi_t safi) |
| 5939 | { |
| 5940 | struct attr *attr; |
| 5941 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5942 | char timebuf[BGP_UPTIME_LEN]; |
| 5943 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5944 | |
| 5945 | if (!binfo->extra) |
| 5946 | return; |
| 5947 | |
| 5948 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5949 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5950 | /* short status lead text */ |
| 5951 | route_vty_short_status_out (vty, binfo); |
| 5952 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5953 | /* print prefix and mask */ |
| 5954 | if (! display) |
| 5955 | route_vty_out_route (p, vty); |
| 5956 | else |
| 5957 | vty_out (vty, "%*s", 17, " "); |
| 5958 | |
| 5959 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5960 | len = 16 - len; |
| 5961 | if (len < 1) |
| 5962 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5963 | else |
| 5964 | vty_out (vty, "%*s", len, " "); |
| 5965 | |
| 5966 | len = vty_out (vty, "%d", bdi->flap); |
| 5967 | len = 5 - len; |
| 5968 | if (len < 1) |
| 5969 | vty_out (vty, " "); |
| 5970 | else |
| 5971 | vty_out (vty, "%*s ", len, " "); |
| 5972 | |
| 5973 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5974 | timebuf, BGP_UPTIME_LEN)); |
| 5975 | |
| 5976 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5977 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 5978 | 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] | 5979 | else |
| 5980 | vty_out (vty, "%*s ", 8, " "); |
| 5981 | |
| 5982 | /* Print attribute */ |
| 5983 | attr = binfo->attr; |
| 5984 | if (attr) |
| 5985 | { |
| 5986 | /* Print aspath */ |
| 5987 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5988 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5989 | |
| 5990 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5991 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5992 | } |
| 5993 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5994 | } |
| 5995 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5996 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5997 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5998 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5999 | { |
| 6000 | char buf[INET6_ADDRSTRLEN]; |
| 6001 | char buf1[BUFSIZ]; |
| 6002 | struct attr *attr; |
| 6003 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6004 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6005 | time_t tbuf; |
| 6006 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6007 | |
| 6008 | attr = binfo->attr; |
| 6009 | |
| 6010 | if (attr) |
| 6011 | { |
| 6012 | /* Line1 display AS-path, Aggregator */ |
| 6013 | if (attr->aspath) |
| 6014 | { |
| 6015 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 6016 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6017 | vty_out (vty, "Local"); |
| 6018 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6019 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6020 | } |
| 6021 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6022 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 6023 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6024 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 6025 | vty_out (vty, ", (stale)"); |
| 6026 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 6027 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6028 | attr->extra->aggregator_as, |
| 6029 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6030 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 6031 | vty_out (vty, ", (Received from a RR-client)"); |
| 6032 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 6033 | vty_out (vty, ", (Received from a RS-client)"); |
| 6034 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6035 | vty_out (vty, ", (history entry)"); |
| 6036 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 6037 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6038 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6039 | |
| 6040 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 6041 | if (p->family == AF_INET) |
| 6042 | { |
| 6043 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6044 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6045 | inet_ntoa (attr->nexthop)); |
| 6046 | } |
| 6047 | #ifdef HAVE_IPV6 |
| 6048 | else |
| 6049 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6050 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6051 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6052 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6053 | buf, INET6_ADDRSTRLEN)); |
| 6054 | } |
| 6055 | #endif /* HAVE_IPV6 */ |
| 6056 | |
| 6057 | if (binfo->peer == bgp->peer_self) |
| 6058 | { |
| 6059 | vty_out (vty, " from %s ", |
| 6060 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 6061 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 6062 | } |
| 6063 | else |
| 6064 | { |
| 6065 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6066 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6067 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 6068 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 6069 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6070 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6071 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6072 | else |
| 6073 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 6074 | } |
| 6075 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6076 | |
| 6077 | #ifdef HAVE_IPV6 |
| 6078 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6079 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6080 | { |
| 6081 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6082 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6083 | buf, INET6_ADDRSTRLEN), |
| 6084 | VTY_NEWLINE); |
| 6085 | } |
| 6086 | #endif /* HAVE_IPV6 */ |
| 6087 | |
| 6088 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 6089 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 6090 | |
| 6091 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6092 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6093 | |
| 6094 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6095 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6096 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6097 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6098 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6099 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6100 | vty_out (vty, ", weight %u", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6101 | |
| 6102 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6103 | vty_out (vty, ", valid"); |
| 6104 | |
| 6105 | if (binfo->peer != bgp->peer_self) |
| 6106 | { |
| 6107 | if (binfo->peer->as == binfo->peer->local_as) |
| 6108 | vty_out (vty, ", internal"); |
| 6109 | else |
| 6110 | vty_out (vty, ", %s", |
| 6111 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6112 | } |
| 6113 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6114 | vty_out (vty, ", aggregated, local"); |
| 6115 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6116 | vty_out (vty, ", sourced"); |
| 6117 | else |
| 6118 | vty_out (vty, ", sourced, local"); |
| 6119 | |
| 6120 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6121 | vty_out (vty, ", atomic-aggregate"); |
| 6122 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6123 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6124 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6125 | bgp_info_mpath_count (binfo))) |
| 6126 | vty_out (vty, ", multipath"); |
| 6127 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6128 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6129 | vty_out (vty, ", best"); |
| 6130 | |
| 6131 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6132 | |
| 6133 | /* Line 4 display Community */ |
| 6134 | if (attr->community) |
| 6135 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6136 | VTY_NEWLINE); |
| 6137 | |
| 6138 | /* Line 5 display Extended-community */ |
| 6139 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6140 | vty_out (vty, " Extended Community: %s%s", |
| 6141 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6142 | |
| 6143 | /* Line 6 display Originator, Cluster-id */ |
| 6144 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6145 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6146 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6147 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6148 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6149 | vty_out (vty, " Originator: %s", |
| 6150 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6151 | |
| 6152 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6153 | { |
| 6154 | int i; |
| 6155 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6156 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6157 | vty_out (vty, "%s ", |
| 6158 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6159 | } |
| 6160 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6161 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6162 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6163 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6164 | bgp_damp_info_vty (vty, binfo); |
| 6165 | |
| 6166 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6167 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6168 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6169 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6170 | #else |
| 6171 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6172 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6173 | } |
| 6174 | vty_out (vty, "%s", VTY_NEWLINE); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 6175 | } |
| 6176 | |
| 6177 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\ |
| 6178 | "h history, * valid, > best, = multipath,%s"\ |
| 6179 | " i internal, r RIB-failure, S Stale, R Removed%s" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6180 | #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] | 6181 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6182 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6183 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6184 | |
| 6185 | enum bgp_show_type |
| 6186 | { |
| 6187 | bgp_show_type_normal, |
| 6188 | bgp_show_type_regexp, |
| 6189 | bgp_show_type_prefix_list, |
| 6190 | bgp_show_type_filter_list, |
| 6191 | bgp_show_type_route_map, |
| 6192 | bgp_show_type_neighbor, |
| 6193 | bgp_show_type_cidr_only, |
| 6194 | bgp_show_type_prefix_longer, |
| 6195 | bgp_show_type_community_all, |
| 6196 | bgp_show_type_community, |
| 6197 | bgp_show_type_community_exact, |
| 6198 | bgp_show_type_community_list, |
| 6199 | bgp_show_type_community_list_exact, |
| 6200 | bgp_show_type_flap_statistics, |
| 6201 | bgp_show_type_flap_address, |
| 6202 | bgp_show_type_flap_prefix, |
| 6203 | bgp_show_type_flap_cidr_only, |
| 6204 | bgp_show_type_flap_regexp, |
| 6205 | bgp_show_type_flap_filter_list, |
| 6206 | bgp_show_type_flap_prefix_list, |
| 6207 | bgp_show_type_flap_prefix_longer, |
| 6208 | bgp_show_type_flap_route_map, |
| 6209 | bgp_show_type_flap_neighbor, |
| 6210 | bgp_show_type_dampend_paths, |
| 6211 | bgp_show_type_damp_neighbor |
| 6212 | }; |
| 6213 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6214 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6215 | 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] | 6216 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6217 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6218 | struct bgp_info *ri; |
| 6219 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6220 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6221 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6222 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6223 | |
| 6224 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6225 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6226 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6227 | /* Start processing of routes. */ |
| 6228 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6229 | if (rn->info != NULL) |
| 6230 | { |
| 6231 | display = 0; |
| 6232 | |
| 6233 | for (ri = rn->info; ri; ri = ri->next) |
| 6234 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6235 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6236 | || type == bgp_show_type_flap_address |
| 6237 | || type == bgp_show_type_flap_prefix |
| 6238 | || type == bgp_show_type_flap_cidr_only |
| 6239 | || type == bgp_show_type_flap_regexp |
| 6240 | || type == bgp_show_type_flap_filter_list |
| 6241 | || type == bgp_show_type_flap_prefix_list |
| 6242 | || type == bgp_show_type_flap_prefix_longer |
| 6243 | || type == bgp_show_type_flap_route_map |
| 6244 | || type == bgp_show_type_flap_neighbor |
| 6245 | || type == bgp_show_type_dampend_paths |
| 6246 | || type == bgp_show_type_damp_neighbor) |
| 6247 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6248 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6249 | continue; |
| 6250 | } |
| 6251 | if (type == bgp_show_type_regexp |
| 6252 | || type == bgp_show_type_flap_regexp) |
| 6253 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6254 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6255 | |
| 6256 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6257 | continue; |
| 6258 | } |
| 6259 | if (type == bgp_show_type_prefix_list |
| 6260 | || type == bgp_show_type_flap_prefix_list) |
| 6261 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6262 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6263 | |
| 6264 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6265 | continue; |
| 6266 | } |
| 6267 | if (type == bgp_show_type_filter_list |
| 6268 | || type == bgp_show_type_flap_filter_list) |
| 6269 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6270 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6271 | |
| 6272 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6273 | continue; |
| 6274 | } |
| 6275 | if (type == bgp_show_type_route_map |
| 6276 | || type == bgp_show_type_flap_route_map) |
| 6277 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6278 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6279 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6280 | struct attr dummy_attr; |
| 6281 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6282 | int ret; |
| 6283 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6284 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6285 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6286 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6287 | binfo.peer = ri->peer; |
| 6288 | binfo.attr = &dummy_attr; |
| 6289 | |
| 6290 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6291 | if (ret == RMAP_DENYMATCH) |
| 6292 | continue; |
| 6293 | } |
| 6294 | if (type == bgp_show_type_neighbor |
| 6295 | || type == bgp_show_type_flap_neighbor |
| 6296 | || type == bgp_show_type_damp_neighbor) |
| 6297 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6298 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6299 | |
| 6300 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6301 | continue; |
| 6302 | } |
| 6303 | if (type == bgp_show_type_cidr_only |
| 6304 | || type == bgp_show_type_flap_cidr_only) |
| 6305 | { |
| 6306 | u_int32_t destination; |
| 6307 | |
| 6308 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6309 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6310 | continue; |
| 6311 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6312 | continue; |
| 6313 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6314 | continue; |
| 6315 | } |
| 6316 | if (type == bgp_show_type_prefix_longer |
| 6317 | || type == bgp_show_type_flap_prefix_longer) |
| 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 (p, &rn->p)) |
| 6322 | continue; |
| 6323 | } |
| 6324 | if (type == bgp_show_type_community_all) |
| 6325 | { |
| 6326 | if (! ri->attr->community) |
| 6327 | continue; |
| 6328 | } |
| 6329 | if (type == bgp_show_type_community) |
| 6330 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6331 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6332 | |
| 6333 | if (! ri->attr->community || |
| 6334 | ! community_match (ri->attr->community, com)) |
| 6335 | continue; |
| 6336 | } |
| 6337 | if (type == bgp_show_type_community_exact) |
| 6338 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6339 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6340 | |
| 6341 | if (! ri->attr->community || |
| 6342 | ! community_cmp (ri->attr->community, com)) |
| 6343 | continue; |
| 6344 | } |
| 6345 | if (type == bgp_show_type_community_list) |
| 6346 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6347 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6348 | |
| 6349 | if (! community_list_match (ri->attr->community, list)) |
| 6350 | continue; |
| 6351 | } |
| 6352 | if (type == bgp_show_type_community_list_exact) |
| 6353 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6354 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6355 | |
| 6356 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6357 | continue; |
| 6358 | } |
| 6359 | if (type == bgp_show_type_flap_address |
| 6360 | || type == bgp_show_type_flap_prefix) |
| 6361 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6362 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6363 | |
| 6364 | if (! prefix_match (&rn->p, p)) |
| 6365 | continue; |
| 6366 | |
| 6367 | if (type == bgp_show_type_flap_prefix) |
| 6368 | if (p->prefixlen != rn->p.prefixlen) |
| 6369 | continue; |
| 6370 | } |
| 6371 | if (type == bgp_show_type_dampend_paths |
| 6372 | || type == bgp_show_type_damp_neighbor) |
| 6373 | { |
| 6374 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6375 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6376 | continue; |
| 6377 | } |
| 6378 | |
| 6379 | if (header) |
| 6380 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6381 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6382 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6383 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6384 | if (type == bgp_show_type_dampend_paths |
| 6385 | || type == bgp_show_type_damp_neighbor) |
| 6386 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6387 | else if (type == bgp_show_type_flap_statistics |
| 6388 | || type == bgp_show_type_flap_address |
| 6389 | || type == bgp_show_type_flap_prefix |
| 6390 | || type == bgp_show_type_flap_cidr_only |
| 6391 | || type == bgp_show_type_flap_regexp |
| 6392 | || type == bgp_show_type_flap_filter_list |
| 6393 | || type == bgp_show_type_flap_prefix_list |
| 6394 | || type == bgp_show_type_flap_prefix_longer |
| 6395 | || type == bgp_show_type_flap_route_map |
| 6396 | || type == bgp_show_type_flap_neighbor) |
| 6397 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6398 | else |
| 6399 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6400 | header = 0; |
| 6401 | } |
| 6402 | |
| 6403 | if (type == bgp_show_type_dampend_paths |
| 6404 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6405 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6406 | else if (type == bgp_show_type_flap_statistics |
| 6407 | || type == bgp_show_type_flap_address |
| 6408 | || type == bgp_show_type_flap_prefix |
| 6409 | || type == bgp_show_type_flap_cidr_only |
| 6410 | || type == bgp_show_type_flap_regexp |
| 6411 | || type == bgp_show_type_flap_filter_list |
| 6412 | || type == bgp_show_type_flap_prefix_list |
| 6413 | || type == bgp_show_type_flap_prefix_longer |
| 6414 | || type == bgp_show_type_flap_route_map |
| 6415 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6416 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6417 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6418 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6419 | display++; |
| 6420 | } |
| 6421 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6422 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6423 | } |
| 6424 | |
| 6425 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6426 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6427 | { |
| 6428 | if (type == bgp_show_type_normal) |
| 6429 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 6430 | } |
| 6431 | else |
| 6432 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6433 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6434 | |
| 6435 | return CMD_SUCCESS; |
| 6436 | } |
| 6437 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6438 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6439 | 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] | 6440 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6441 | { |
| 6442 | struct bgp_table *table; |
| 6443 | |
| 6444 | if (bgp == NULL) { |
| 6445 | bgp = bgp_get_default (); |
| 6446 | } |
| 6447 | |
| 6448 | if (bgp == NULL) |
| 6449 | { |
| 6450 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6451 | return CMD_WARNING; |
| 6452 | } |
| 6453 | |
| 6454 | |
| 6455 | table = bgp->rib[afi][safi]; |
| 6456 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6457 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6458 | } |
| 6459 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6460 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6461 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6462 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6463 | struct bgp_node *rn, |
| 6464 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6465 | { |
| 6466 | struct bgp_info *ri; |
| 6467 | struct prefix *p; |
| 6468 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6469 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6470 | char buf1[INET6_ADDRSTRLEN]; |
| 6471 | char buf2[INET6_ADDRSTRLEN]; |
| 6472 | int count = 0; |
| 6473 | int best = 0; |
| 6474 | int suppress = 0; |
| 6475 | int no_export = 0; |
| 6476 | int no_advertise = 0; |
| 6477 | int local_as = 0; |
| 6478 | int first = 0; |
| 6479 | |
| 6480 | p = &rn->p; |
| 6481 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 6482 | (safi == SAFI_MPLS_VPN ? |
| 6483 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6484 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 6485 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6486 | p->prefixlen, VTY_NEWLINE); |
| 6487 | |
| 6488 | for (ri = rn->info; ri; ri = ri->next) |
| 6489 | { |
| 6490 | count++; |
| 6491 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6492 | { |
| 6493 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6494 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6495 | suppress = 1; |
| 6496 | if (ri->attr->community != NULL) |
| 6497 | { |
| 6498 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6499 | no_advertise = 1; |
| 6500 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6501 | no_export = 1; |
| 6502 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6503 | local_as = 1; |
| 6504 | } |
| 6505 | } |
| 6506 | } |
| 6507 | |
| 6508 | vty_out (vty, "Paths: (%d available", count); |
| 6509 | if (best) |
| 6510 | { |
| 6511 | vty_out (vty, ", best #%d", best); |
| 6512 | if (safi == SAFI_UNICAST) |
| 6513 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6514 | } |
| 6515 | else |
| 6516 | vty_out (vty, ", no best path"); |
| 6517 | if (no_advertise) |
| 6518 | vty_out (vty, ", not advertised to any peer"); |
| 6519 | else if (no_export) |
| 6520 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6521 | else if (local_as) |
| 6522 | vty_out (vty, ", not advertised outside local AS"); |
| 6523 | if (suppress) |
| 6524 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6525 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6526 | |
| 6527 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6528 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6529 | { |
| 6530 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6531 | { |
| 6532 | if (! first) |
| 6533 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6534 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6535 | first = 1; |
| 6536 | } |
| 6537 | } |
| 6538 | if (! first) |
| 6539 | vty_out (vty, " Not advertised to any peer"); |
| 6540 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6541 | } |
| 6542 | |
| 6543 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6544 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6545 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6546 | struct bgp_table *rib, const char *ip_str, |
| 6547 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6548 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6549 | { |
| 6550 | int ret; |
| 6551 | int header; |
| 6552 | int display = 0; |
| 6553 | struct prefix match; |
| 6554 | struct bgp_node *rn; |
| 6555 | struct bgp_node *rm; |
| 6556 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6557 | struct bgp_table *table; |
| 6558 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6559 | /* Check IP address argument. */ |
| 6560 | ret = str2prefix (ip_str, &match); |
| 6561 | if (! ret) |
| 6562 | { |
| 6563 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6564 | return CMD_WARNING; |
| 6565 | } |
| 6566 | |
| 6567 | match.family = afi2family (afi); |
| 6568 | |
| 6569 | if (safi == SAFI_MPLS_VPN) |
| 6570 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6571 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6572 | { |
| 6573 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6574 | continue; |
| 6575 | |
| 6576 | if ((table = rn->info) != NULL) |
| 6577 | { |
| 6578 | header = 1; |
| 6579 | |
| 6580 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6581 | { |
| 6582 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6583 | { |
| 6584 | bgp_unlock_node (rm); |
| 6585 | continue; |
| 6586 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6587 | |
| 6588 | for (ri = rm->info; ri; ri = ri->next) |
| 6589 | { |
| 6590 | if (header) |
| 6591 | { |
| 6592 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 6593 | AFI_IP, SAFI_MPLS_VPN); |
| 6594 | |
| 6595 | header = 0; |
| 6596 | } |
| 6597 | display++; |
| 6598 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 6599 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6600 | |
| 6601 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6602 | } |
| 6603 | } |
| 6604 | } |
| 6605 | } |
| 6606 | else |
| 6607 | { |
| 6608 | header = 1; |
| 6609 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6610 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6611 | { |
| 6612 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6613 | { |
| 6614 | for (ri = rn->info; ri; ri = ri->next) |
| 6615 | { |
| 6616 | if (header) |
| 6617 | { |
| 6618 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6619 | header = 0; |
| 6620 | } |
| 6621 | display++; |
| 6622 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6623 | } |
| 6624 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6625 | |
| 6626 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6627 | } |
| 6628 | } |
| 6629 | |
| 6630 | if (! display) |
| 6631 | { |
| 6632 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6633 | return CMD_WARNING; |
| 6634 | } |
| 6635 | |
| 6636 | return CMD_SUCCESS; |
| 6637 | } |
| 6638 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6639 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6640 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6641 | 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] | 6642 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6643 | int prefix_check) |
| 6644 | { |
| 6645 | struct bgp *bgp; |
| 6646 | |
| 6647 | /* BGP structure lookup. */ |
| 6648 | if (view_name) |
| 6649 | { |
| 6650 | bgp = bgp_lookup_by_name (view_name); |
| 6651 | if (bgp == NULL) |
| 6652 | { |
| 6653 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6654 | return CMD_WARNING; |
| 6655 | } |
| 6656 | } |
| 6657 | else |
| 6658 | { |
| 6659 | bgp = bgp_get_default (); |
| 6660 | if (bgp == NULL) |
| 6661 | { |
| 6662 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6663 | return CMD_WARNING; |
| 6664 | } |
| 6665 | } |
| 6666 | |
| 6667 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6668 | afi, safi, prd, prefix_check); |
| 6669 | } |
| 6670 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6671 | /* BGP route print out function. */ |
| 6672 | DEFUN (show_ip_bgp, |
| 6673 | show_ip_bgp_cmd, |
| 6674 | "show ip bgp", |
| 6675 | SHOW_STR |
| 6676 | IP_STR |
| 6677 | BGP_STR) |
| 6678 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6679 | 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] | 6680 | } |
| 6681 | |
| 6682 | DEFUN (show_ip_bgp_ipv4, |
| 6683 | show_ip_bgp_ipv4_cmd, |
| 6684 | "show ip bgp ipv4 (unicast|multicast)", |
| 6685 | SHOW_STR |
| 6686 | IP_STR |
| 6687 | BGP_STR |
| 6688 | "Address family\n" |
| 6689 | "Address Family modifier\n" |
| 6690 | "Address Family modifier\n") |
| 6691 | { |
| 6692 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6693 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6694 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6695 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6696 | 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] | 6697 | } |
| 6698 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6699 | ALIAS (show_ip_bgp_ipv4, |
| 6700 | show_bgp_ipv4_safi_cmd, |
| 6701 | "show bgp ipv4 (unicast|multicast)", |
| 6702 | SHOW_STR |
| 6703 | BGP_STR |
| 6704 | "Address family\n" |
| 6705 | "Address Family modifier\n" |
| 6706 | "Address Family modifier\n") |
| 6707 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6708 | DEFUN (show_ip_bgp_route, |
| 6709 | show_ip_bgp_route_cmd, |
| 6710 | "show ip bgp A.B.C.D", |
| 6711 | SHOW_STR |
| 6712 | IP_STR |
| 6713 | BGP_STR |
| 6714 | "Network in the BGP routing table to display\n") |
| 6715 | { |
| 6716 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6717 | } |
| 6718 | |
| 6719 | DEFUN (show_ip_bgp_ipv4_route, |
| 6720 | show_ip_bgp_ipv4_route_cmd, |
| 6721 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6722 | SHOW_STR |
| 6723 | IP_STR |
| 6724 | BGP_STR |
| 6725 | "Address family\n" |
| 6726 | "Address Family modifier\n" |
| 6727 | "Address Family modifier\n" |
| 6728 | "Network in the BGP routing table to display\n") |
| 6729 | { |
| 6730 | if (strncmp (argv[0], "m", 1) == 0) |
| 6731 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6732 | |
| 6733 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6734 | } |
| 6735 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6736 | ALIAS (show_ip_bgp_ipv4_route, |
| 6737 | show_bgp_ipv4_safi_route_cmd, |
| 6738 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6739 | SHOW_STR |
| 6740 | BGP_STR |
| 6741 | "Address family\n" |
| 6742 | "Address Family modifier\n" |
| 6743 | "Address Family modifier\n" |
| 6744 | "Network in the BGP routing table to display\n") |
| 6745 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6746 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6747 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6748 | "show ip bgp vpnv4 all A.B.C.D", |
| 6749 | SHOW_STR |
| 6750 | IP_STR |
| 6751 | BGP_STR |
| 6752 | "Display VPNv4 NLRI specific information\n" |
| 6753 | "Display information about all VPNv4 NLRIs\n" |
| 6754 | "Network in the BGP routing table to display\n") |
| 6755 | { |
| 6756 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6757 | } |
| 6758 | |
| 6759 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6760 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6761 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6762 | SHOW_STR |
| 6763 | IP_STR |
| 6764 | BGP_STR |
| 6765 | "Display VPNv4 NLRI specific information\n" |
| 6766 | "Display information for a route distinguisher\n" |
| 6767 | "VPN Route Distinguisher\n" |
| 6768 | "Network in the BGP routing table to display\n") |
| 6769 | { |
| 6770 | int ret; |
| 6771 | struct prefix_rd prd; |
| 6772 | |
| 6773 | ret = str2prefix_rd (argv[0], &prd); |
| 6774 | if (! ret) |
| 6775 | { |
| 6776 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6777 | return CMD_WARNING; |
| 6778 | } |
| 6779 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6780 | } |
| 6781 | |
| 6782 | DEFUN (show_ip_bgp_prefix, |
| 6783 | show_ip_bgp_prefix_cmd, |
| 6784 | "show ip bgp A.B.C.D/M", |
| 6785 | SHOW_STR |
| 6786 | IP_STR |
| 6787 | BGP_STR |
| 6788 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6789 | { |
| 6790 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6791 | } |
| 6792 | |
| 6793 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6794 | show_ip_bgp_ipv4_prefix_cmd, |
| 6795 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6796 | SHOW_STR |
| 6797 | IP_STR |
| 6798 | BGP_STR |
| 6799 | "Address family\n" |
| 6800 | "Address Family modifier\n" |
| 6801 | "Address Family modifier\n" |
| 6802 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6803 | { |
| 6804 | if (strncmp (argv[0], "m", 1) == 0) |
| 6805 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6806 | |
| 6807 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6808 | } |
| 6809 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6810 | ALIAS (show_ip_bgp_ipv4_prefix, |
| 6811 | show_bgp_ipv4_safi_prefix_cmd, |
| 6812 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6813 | SHOW_STR |
| 6814 | BGP_STR |
| 6815 | "Address family\n" |
| 6816 | "Address Family modifier\n" |
| 6817 | "Address Family modifier\n" |
| 6818 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6819 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6820 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 6821 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 6822 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 6823 | SHOW_STR |
| 6824 | IP_STR |
| 6825 | BGP_STR |
| 6826 | "Display VPNv4 NLRI specific information\n" |
| 6827 | "Display information about all VPNv4 NLRIs\n" |
| 6828 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6829 | { |
| 6830 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 6831 | } |
| 6832 | |
| 6833 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 6834 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 6835 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 6836 | SHOW_STR |
| 6837 | IP_STR |
| 6838 | BGP_STR |
| 6839 | "Display VPNv4 NLRI specific information\n" |
| 6840 | "Display information for a route distinguisher\n" |
| 6841 | "VPN Route Distinguisher\n" |
| 6842 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6843 | { |
| 6844 | int ret; |
| 6845 | struct prefix_rd prd; |
| 6846 | |
| 6847 | ret = str2prefix_rd (argv[0], &prd); |
| 6848 | if (! ret) |
| 6849 | { |
| 6850 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6851 | return CMD_WARNING; |
| 6852 | } |
| 6853 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 6854 | } |
| 6855 | |
| 6856 | DEFUN (show_ip_bgp_view, |
| 6857 | show_ip_bgp_view_cmd, |
| 6858 | "show ip bgp view WORD", |
| 6859 | SHOW_STR |
| 6860 | IP_STR |
| 6861 | BGP_STR |
| 6862 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6863 | "View name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6864 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6865 | struct bgp *bgp; |
| 6866 | |
| 6867 | /* BGP structure lookup. */ |
| 6868 | bgp = bgp_lookup_by_name (argv[0]); |
| 6869 | if (bgp == NULL) |
| 6870 | { |
| 6871 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6872 | return CMD_WARNING; |
| 6873 | } |
| 6874 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6875 | 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] | 6876 | } |
| 6877 | |
| 6878 | DEFUN (show_ip_bgp_view_route, |
| 6879 | show_ip_bgp_view_route_cmd, |
| 6880 | "show ip bgp view WORD A.B.C.D", |
| 6881 | SHOW_STR |
| 6882 | IP_STR |
| 6883 | BGP_STR |
| 6884 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6885 | "View name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6886 | "Network in the BGP routing table to display\n") |
| 6887 | { |
| 6888 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6889 | } |
| 6890 | |
| 6891 | DEFUN (show_ip_bgp_view_prefix, |
| 6892 | show_ip_bgp_view_prefix_cmd, |
| 6893 | "show ip bgp view WORD A.B.C.D/M", |
| 6894 | SHOW_STR |
| 6895 | IP_STR |
| 6896 | BGP_STR |
| 6897 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 6898 | "View name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6899 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6900 | { |
| 6901 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6902 | } |
| 6903 | |
| 6904 | #ifdef HAVE_IPV6 |
| 6905 | DEFUN (show_bgp, |
| 6906 | show_bgp_cmd, |
| 6907 | "show bgp", |
| 6908 | SHOW_STR |
| 6909 | BGP_STR) |
| 6910 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6911 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6912 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6913 | } |
| 6914 | |
| 6915 | ALIAS (show_bgp, |
| 6916 | show_bgp_ipv6_cmd, |
| 6917 | "show bgp ipv6", |
| 6918 | SHOW_STR |
| 6919 | BGP_STR |
| 6920 | "Address family\n") |
| 6921 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6922 | DEFUN (show_bgp_ipv6_safi, |
| 6923 | show_bgp_ipv6_safi_cmd, |
| 6924 | "show bgp ipv6 (unicast|multicast)", |
| 6925 | SHOW_STR |
| 6926 | BGP_STR |
| 6927 | "Address family\n" |
| 6928 | "Address Family modifier\n" |
| 6929 | "Address Family modifier\n") |
| 6930 | { |
| 6931 | if (strncmp (argv[0], "m", 1) == 0) |
| 6932 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6933 | NULL); |
| 6934 | |
| 6935 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6936 | } |
| 6937 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6938 | /* old command */ |
| 6939 | DEFUN (show_ipv6_bgp, |
| 6940 | show_ipv6_bgp_cmd, |
| 6941 | "show ipv6 bgp", |
| 6942 | SHOW_STR |
| 6943 | IP_STR |
| 6944 | BGP_STR) |
| 6945 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6946 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6947 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6948 | } |
| 6949 | |
| 6950 | DEFUN (show_bgp_route, |
| 6951 | show_bgp_route_cmd, |
| 6952 | "show bgp X:X::X:X", |
| 6953 | SHOW_STR |
| 6954 | BGP_STR |
| 6955 | "Network in the BGP routing table to display\n") |
| 6956 | { |
| 6957 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6958 | } |
| 6959 | |
| 6960 | ALIAS (show_bgp_route, |
| 6961 | show_bgp_ipv6_route_cmd, |
| 6962 | "show bgp ipv6 X:X::X:X", |
| 6963 | SHOW_STR |
| 6964 | BGP_STR |
| 6965 | "Address family\n" |
| 6966 | "Network in the BGP routing table to display\n") |
| 6967 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6968 | DEFUN (show_bgp_ipv6_safi_route, |
| 6969 | show_bgp_ipv6_safi_route_cmd, |
| 6970 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
| 6971 | SHOW_STR |
| 6972 | BGP_STR |
| 6973 | "Address family\n" |
| 6974 | "Address Family modifier\n" |
| 6975 | "Address Family modifier\n" |
| 6976 | "Network in the BGP routing table to display\n") |
| 6977 | { |
| 6978 | if (strncmp (argv[0], "m", 1) == 0) |
| 6979 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6980 | |
| 6981 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6982 | } |
| 6983 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6984 | /* old command */ |
| 6985 | DEFUN (show_ipv6_bgp_route, |
| 6986 | show_ipv6_bgp_route_cmd, |
| 6987 | "show ipv6 bgp X:X::X:X", |
| 6988 | SHOW_STR |
| 6989 | IP_STR |
| 6990 | BGP_STR |
| 6991 | "Network in the BGP routing table to display\n") |
| 6992 | { |
| 6993 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6994 | } |
| 6995 | |
| 6996 | DEFUN (show_bgp_prefix, |
| 6997 | show_bgp_prefix_cmd, |
| 6998 | "show bgp X:X::X:X/M", |
| 6999 | SHOW_STR |
| 7000 | BGP_STR |
| 7001 | "IPv6 prefix <network>/<length>\n") |
| 7002 | { |
| 7003 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7004 | } |
| 7005 | |
| 7006 | ALIAS (show_bgp_prefix, |
| 7007 | show_bgp_ipv6_prefix_cmd, |
| 7008 | "show bgp ipv6 X:X::X:X/M", |
| 7009 | SHOW_STR |
| 7010 | BGP_STR |
| 7011 | "Address family\n" |
| 7012 | "IPv6 prefix <network>/<length>\n") |
| 7013 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7014 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 7015 | show_bgp_ipv6_safi_prefix_cmd, |
| 7016 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 7017 | SHOW_STR |
| 7018 | BGP_STR |
| 7019 | "Address family\n" |
| 7020 | "Address Family modifier\n" |
| 7021 | "Address Family modifier\n" |
| 7022 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7023 | { |
| 7024 | if (strncmp (argv[0], "m", 1) == 0) |
| 7025 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7026 | |
| 7027 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7028 | } |
| 7029 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7030 | /* old command */ |
| 7031 | DEFUN (show_ipv6_bgp_prefix, |
| 7032 | show_ipv6_bgp_prefix_cmd, |
| 7033 | "show ipv6 bgp X:X::X:X/M", |
| 7034 | SHOW_STR |
| 7035 | IP_STR |
| 7036 | BGP_STR |
| 7037 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7038 | { |
| 7039 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7040 | } |
| 7041 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7042 | DEFUN (show_bgp_view, |
| 7043 | show_bgp_view_cmd, |
| 7044 | "show bgp view WORD", |
| 7045 | SHOW_STR |
| 7046 | BGP_STR |
| 7047 | "BGP view\n" |
| 7048 | "View name\n") |
| 7049 | { |
| 7050 | struct bgp *bgp; |
| 7051 | |
| 7052 | /* BGP structure lookup. */ |
| 7053 | bgp = bgp_lookup_by_name (argv[0]); |
| 7054 | if (bgp == NULL) |
| 7055 | { |
| 7056 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7057 | return CMD_WARNING; |
| 7058 | } |
| 7059 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7060 | 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] | 7061 | } |
| 7062 | |
| 7063 | ALIAS (show_bgp_view, |
| 7064 | show_bgp_view_ipv6_cmd, |
| 7065 | "show bgp view WORD ipv6", |
| 7066 | SHOW_STR |
| 7067 | BGP_STR |
| 7068 | "BGP view\n" |
| 7069 | "View name\n" |
| 7070 | "Address family\n") |
| 7071 | |
| 7072 | DEFUN (show_bgp_view_route, |
| 7073 | show_bgp_view_route_cmd, |
| 7074 | "show bgp view WORD X:X::X:X", |
| 7075 | SHOW_STR |
| 7076 | BGP_STR |
| 7077 | "BGP view\n" |
| 7078 | "View name\n" |
| 7079 | "Network in the BGP routing table to display\n") |
| 7080 | { |
| 7081 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7082 | } |
| 7083 | |
| 7084 | ALIAS (show_bgp_view_route, |
| 7085 | show_bgp_view_ipv6_route_cmd, |
| 7086 | "show bgp view WORD ipv6 X:X::X:X", |
| 7087 | SHOW_STR |
| 7088 | BGP_STR |
| 7089 | "BGP view\n" |
| 7090 | "View name\n" |
| 7091 | "Address family\n" |
| 7092 | "Network in the BGP routing table to display\n") |
| 7093 | |
| 7094 | DEFUN (show_bgp_view_prefix, |
| 7095 | show_bgp_view_prefix_cmd, |
| 7096 | "show bgp view WORD X:X::X:X/M", |
| 7097 | SHOW_STR |
| 7098 | BGP_STR |
| 7099 | "BGP view\n" |
| 7100 | "View name\n" |
| 7101 | "IPv6 prefix <network>/<length>\n") |
| 7102 | { |
| 7103 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7104 | } |
| 7105 | |
| 7106 | ALIAS (show_bgp_view_prefix, |
| 7107 | show_bgp_view_ipv6_prefix_cmd, |
| 7108 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 7109 | SHOW_STR |
| 7110 | BGP_STR |
| 7111 | "BGP view\n" |
| 7112 | "View name\n" |
| 7113 | "Address family\n" |
| 7114 | "IPv6 prefix <network>/<length>\n") |
| 7115 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7116 | /* old command */ |
| 7117 | DEFUN (show_ipv6_mbgp, |
| 7118 | show_ipv6_mbgp_cmd, |
| 7119 | "show ipv6 mbgp", |
| 7120 | SHOW_STR |
| 7121 | IP_STR |
| 7122 | MBGP_STR) |
| 7123 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7124 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7125 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7126 | } |
| 7127 | |
| 7128 | /* old command */ |
| 7129 | DEFUN (show_ipv6_mbgp_route, |
| 7130 | show_ipv6_mbgp_route_cmd, |
| 7131 | "show ipv6 mbgp X:X::X:X", |
| 7132 | SHOW_STR |
| 7133 | IP_STR |
| 7134 | MBGP_STR |
| 7135 | "Network in the MBGP routing table to display\n") |
| 7136 | { |
| 7137 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7138 | } |
| 7139 | |
| 7140 | /* old command */ |
| 7141 | DEFUN (show_ipv6_mbgp_prefix, |
| 7142 | show_ipv6_mbgp_prefix_cmd, |
| 7143 | "show ipv6 mbgp X:X::X:X/M", |
| 7144 | SHOW_STR |
| 7145 | IP_STR |
| 7146 | MBGP_STR |
| 7147 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7148 | { |
| 7149 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7150 | } |
| 7151 | #endif |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7152 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7153 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7154 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7155 | 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] | 7156 | safi_t safi, enum bgp_show_type type) |
| 7157 | { |
| 7158 | int i; |
| 7159 | struct buffer *b; |
| 7160 | char *regstr; |
| 7161 | int first; |
| 7162 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7163 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7164 | |
| 7165 | first = 0; |
| 7166 | b = buffer_new (1024); |
| 7167 | for (i = 0; i < argc; i++) |
| 7168 | { |
| 7169 | if (first) |
| 7170 | buffer_putc (b, ' '); |
| 7171 | else |
| 7172 | { |
| 7173 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7174 | continue; |
| 7175 | first = 1; |
| 7176 | } |
| 7177 | |
| 7178 | buffer_putstr (b, argv[i]); |
| 7179 | } |
| 7180 | buffer_putc (b, '\0'); |
| 7181 | |
| 7182 | regstr = buffer_getstr (b); |
| 7183 | buffer_free (b); |
| 7184 | |
| 7185 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7186 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7187 | if (! regex) |
| 7188 | { |
| 7189 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 7190 | VTY_NEWLINE); |
| 7191 | return CMD_WARNING; |
| 7192 | } |
| 7193 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7194 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 7195 | bgp_regex_free (regex); |
| 7196 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7197 | } |
| 7198 | |
| 7199 | DEFUN (show_ip_bgp_regexp, |
| 7200 | show_ip_bgp_regexp_cmd, |
| 7201 | "show ip bgp regexp .LINE", |
| 7202 | SHOW_STR |
| 7203 | IP_STR |
| 7204 | BGP_STR |
| 7205 | "Display routes matching the AS path regular expression\n" |
| 7206 | "A regular-expression to match the BGP AS paths\n") |
| 7207 | { |
| 7208 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7209 | bgp_show_type_regexp); |
| 7210 | } |
| 7211 | |
| 7212 | DEFUN (show_ip_bgp_flap_regexp, |
| 7213 | show_ip_bgp_flap_regexp_cmd, |
| 7214 | "show ip bgp flap-statistics regexp .LINE", |
| 7215 | SHOW_STR |
| 7216 | IP_STR |
| 7217 | BGP_STR |
| 7218 | "Display flap statistics of routes\n" |
| 7219 | "Display routes matching the AS path regular expression\n" |
| 7220 | "A regular-expression to match the BGP AS paths\n") |
| 7221 | { |
| 7222 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7223 | bgp_show_type_flap_regexp); |
| 7224 | } |
| 7225 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7226 | ALIAS (show_ip_bgp_flap_regexp, |
| 7227 | show_ip_bgp_damp_flap_regexp_cmd, |
| 7228 | "show ip bgp dampening flap-statistics regexp .LINE", |
| 7229 | SHOW_STR |
| 7230 | IP_STR |
| 7231 | BGP_STR |
| 7232 | "Display detailed information about dampening\n" |
| 7233 | "Display flap statistics of routes\n" |
| 7234 | "Display routes matching the AS path regular expression\n" |
| 7235 | "A regular-expression to match the BGP AS paths\n") |
| 7236 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7237 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 7238 | show_ip_bgp_ipv4_regexp_cmd, |
| 7239 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 7240 | SHOW_STR |
| 7241 | IP_STR |
| 7242 | BGP_STR |
| 7243 | "Address family\n" |
| 7244 | "Address Family modifier\n" |
| 7245 | "Address Family modifier\n" |
| 7246 | "Display routes matching the AS path regular expression\n" |
| 7247 | "A regular-expression to match the BGP AS paths\n") |
| 7248 | { |
| 7249 | if (strncmp (argv[0], "m", 1) == 0) |
| 7250 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 7251 | bgp_show_type_regexp); |
| 7252 | |
| 7253 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7254 | bgp_show_type_regexp); |
| 7255 | } |
| 7256 | |
| 7257 | #ifdef HAVE_IPV6 |
| 7258 | DEFUN (show_bgp_regexp, |
| 7259 | show_bgp_regexp_cmd, |
| 7260 | "show bgp regexp .LINE", |
| 7261 | SHOW_STR |
| 7262 | BGP_STR |
| 7263 | "Display routes matching the AS path regular expression\n" |
| 7264 | "A regular-expression to match the BGP AS paths\n") |
| 7265 | { |
| 7266 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7267 | bgp_show_type_regexp); |
| 7268 | } |
| 7269 | |
| 7270 | ALIAS (show_bgp_regexp, |
| 7271 | show_bgp_ipv6_regexp_cmd, |
| 7272 | "show bgp ipv6 regexp .LINE", |
| 7273 | SHOW_STR |
| 7274 | BGP_STR |
| 7275 | "Address family\n" |
| 7276 | "Display routes matching the AS path regular expression\n" |
| 7277 | "A regular-expression to match the BGP AS paths\n") |
| 7278 | |
| 7279 | /* old command */ |
| 7280 | DEFUN (show_ipv6_bgp_regexp, |
| 7281 | show_ipv6_bgp_regexp_cmd, |
| 7282 | "show ipv6 bgp regexp .LINE", |
| 7283 | SHOW_STR |
| 7284 | IP_STR |
| 7285 | BGP_STR |
| 7286 | "Display routes matching the AS path regular expression\n" |
| 7287 | "A regular-expression to match the BGP AS paths\n") |
| 7288 | { |
| 7289 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7290 | bgp_show_type_regexp); |
| 7291 | } |
| 7292 | |
| 7293 | /* old command */ |
| 7294 | DEFUN (show_ipv6_mbgp_regexp, |
| 7295 | show_ipv6_mbgp_regexp_cmd, |
| 7296 | "show ipv6 mbgp regexp .LINE", |
| 7297 | SHOW_STR |
| 7298 | IP_STR |
| 7299 | BGP_STR |
| 7300 | "Display routes matching the AS path regular expression\n" |
| 7301 | "A regular-expression to match the MBGP AS paths\n") |
| 7302 | { |
| 7303 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 7304 | bgp_show_type_regexp); |
| 7305 | } |
| 7306 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7307 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7308 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7309 | 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] | 7310 | safi_t safi, enum bgp_show_type type) |
| 7311 | { |
| 7312 | struct prefix_list *plist; |
| 7313 | |
| 7314 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 7315 | if (plist == NULL) |
| 7316 | { |
| 7317 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 7318 | prefix_list_str, VTY_NEWLINE); |
| 7319 | return CMD_WARNING; |
| 7320 | } |
| 7321 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7322 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7323 | } |
| 7324 | |
| 7325 | DEFUN (show_ip_bgp_prefix_list, |
| 7326 | show_ip_bgp_prefix_list_cmd, |
| 7327 | "show ip bgp prefix-list WORD", |
| 7328 | SHOW_STR |
| 7329 | IP_STR |
| 7330 | BGP_STR |
| 7331 | "Display routes conforming to the prefix-list\n" |
| 7332 | "IP prefix-list name\n") |
| 7333 | { |
| 7334 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7335 | bgp_show_type_prefix_list); |
| 7336 | } |
| 7337 | |
| 7338 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 7339 | show_ip_bgp_flap_prefix_list_cmd, |
| 7340 | "show ip bgp flap-statistics prefix-list WORD", |
| 7341 | SHOW_STR |
| 7342 | IP_STR |
| 7343 | BGP_STR |
| 7344 | "Display flap statistics of routes\n" |
| 7345 | "Display routes conforming to the prefix-list\n" |
| 7346 | "IP prefix-list name\n") |
| 7347 | { |
| 7348 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7349 | bgp_show_type_flap_prefix_list); |
| 7350 | } |
| 7351 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7352 | ALIAS (show_ip_bgp_flap_prefix_list, |
| 7353 | show_ip_bgp_damp_flap_prefix_list_cmd, |
| 7354 | "show ip bgp dampening flap-statistics prefix-list WORD", |
| 7355 | SHOW_STR |
| 7356 | IP_STR |
| 7357 | BGP_STR |
| 7358 | "Display detailed information about dampening\n" |
| 7359 | "Display flap statistics of routes\n" |
| 7360 | "Display routes conforming to the prefix-list\n" |
| 7361 | "IP prefix-list name\n") |
| 7362 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7363 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 7364 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 7365 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 7366 | SHOW_STR |
| 7367 | IP_STR |
| 7368 | BGP_STR |
| 7369 | "Address family\n" |
| 7370 | "Address Family modifier\n" |
| 7371 | "Address Family modifier\n" |
| 7372 | "Display routes conforming to the prefix-list\n" |
| 7373 | "IP prefix-list name\n") |
| 7374 | { |
| 7375 | if (strncmp (argv[0], "m", 1) == 0) |
| 7376 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7377 | bgp_show_type_prefix_list); |
| 7378 | |
| 7379 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7380 | bgp_show_type_prefix_list); |
| 7381 | } |
| 7382 | |
| 7383 | #ifdef HAVE_IPV6 |
| 7384 | DEFUN (show_bgp_prefix_list, |
| 7385 | show_bgp_prefix_list_cmd, |
| 7386 | "show bgp prefix-list WORD", |
| 7387 | SHOW_STR |
| 7388 | BGP_STR |
| 7389 | "Display routes conforming to the prefix-list\n" |
| 7390 | "IPv6 prefix-list name\n") |
| 7391 | { |
| 7392 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7393 | bgp_show_type_prefix_list); |
| 7394 | } |
| 7395 | |
| 7396 | ALIAS (show_bgp_prefix_list, |
| 7397 | show_bgp_ipv6_prefix_list_cmd, |
| 7398 | "show bgp ipv6 prefix-list WORD", |
| 7399 | SHOW_STR |
| 7400 | BGP_STR |
| 7401 | "Address family\n" |
| 7402 | "Display routes conforming to the prefix-list\n" |
| 7403 | "IPv6 prefix-list name\n") |
| 7404 | |
| 7405 | /* old command */ |
| 7406 | DEFUN (show_ipv6_bgp_prefix_list, |
| 7407 | show_ipv6_bgp_prefix_list_cmd, |
| 7408 | "show ipv6 bgp prefix-list WORD", |
| 7409 | SHOW_STR |
| 7410 | IPV6_STR |
| 7411 | BGP_STR |
| 7412 | "Display routes matching the prefix-list\n" |
| 7413 | "IPv6 prefix-list name\n") |
| 7414 | { |
| 7415 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7416 | bgp_show_type_prefix_list); |
| 7417 | } |
| 7418 | |
| 7419 | /* old command */ |
| 7420 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 7421 | show_ipv6_mbgp_prefix_list_cmd, |
| 7422 | "show ipv6 mbgp prefix-list WORD", |
| 7423 | SHOW_STR |
| 7424 | IPV6_STR |
| 7425 | MBGP_STR |
| 7426 | "Display routes matching the prefix-list\n" |
| 7427 | "IPv6 prefix-list name\n") |
| 7428 | { |
| 7429 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7430 | bgp_show_type_prefix_list); |
| 7431 | } |
| 7432 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7433 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7434 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7435 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7436 | safi_t safi, enum bgp_show_type type) |
| 7437 | { |
| 7438 | struct as_list *as_list; |
| 7439 | |
| 7440 | as_list = as_list_lookup (filter); |
| 7441 | if (as_list == NULL) |
| 7442 | { |
| 7443 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 7444 | return CMD_WARNING; |
| 7445 | } |
| 7446 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7447 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7448 | } |
| 7449 | |
| 7450 | DEFUN (show_ip_bgp_filter_list, |
| 7451 | show_ip_bgp_filter_list_cmd, |
| 7452 | "show ip bgp filter-list WORD", |
| 7453 | SHOW_STR |
| 7454 | IP_STR |
| 7455 | BGP_STR |
| 7456 | "Display routes conforming to the filter-list\n" |
| 7457 | "Regular expression access list name\n") |
| 7458 | { |
| 7459 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7460 | bgp_show_type_filter_list); |
| 7461 | } |
| 7462 | |
| 7463 | DEFUN (show_ip_bgp_flap_filter_list, |
| 7464 | show_ip_bgp_flap_filter_list_cmd, |
| 7465 | "show ip bgp flap-statistics filter-list WORD", |
| 7466 | SHOW_STR |
| 7467 | IP_STR |
| 7468 | BGP_STR |
| 7469 | "Display flap statistics of routes\n" |
| 7470 | "Display routes conforming to the filter-list\n" |
| 7471 | "Regular expression access list name\n") |
| 7472 | { |
| 7473 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7474 | bgp_show_type_flap_filter_list); |
| 7475 | } |
| 7476 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7477 | ALIAS (show_ip_bgp_flap_filter_list, |
| 7478 | show_ip_bgp_damp_flap_filter_list_cmd, |
| 7479 | "show ip bgp dampening flap-statistics filter-list WORD", |
| 7480 | SHOW_STR |
| 7481 | IP_STR |
| 7482 | BGP_STR |
| 7483 | "Display detailed information about dampening\n" |
| 7484 | "Display flap statistics of routes\n" |
| 7485 | "Display routes conforming to the filter-list\n" |
| 7486 | "Regular expression access list name\n") |
| 7487 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7488 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 7489 | show_ip_bgp_ipv4_filter_list_cmd, |
| 7490 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 7491 | SHOW_STR |
| 7492 | IP_STR |
| 7493 | BGP_STR |
| 7494 | "Address family\n" |
| 7495 | "Address Family modifier\n" |
| 7496 | "Address Family modifier\n" |
| 7497 | "Display routes conforming to the filter-list\n" |
| 7498 | "Regular expression access list name\n") |
| 7499 | { |
| 7500 | if (strncmp (argv[0], "m", 1) == 0) |
| 7501 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7502 | bgp_show_type_filter_list); |
| 7503 | |
| 7504 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7505 | bgp_show_type_filter_list); |
| 7506 | } |
| 7507 | |
| 7508 | #ifdef HAVE_IPV6 |
| 7509 | DEFUN (show_bgp_filter_list, |
| 7510 | show_bgp_filter_list_cmd, |
| 7511 | "show bgp filter-list WORD", |
| 7512 | SHOW_STR |
| 7513 | BGP_STR |
| 7514 | "Display routes conforming to the filter-list\n" |
| 7515 | "Regular expression access list name\n") |
| 7516 | { |
| 7517 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7518 | bgp_show_type_filter_list); |
| 7519 | } |
| 7520 | |
| 7521 | ALIAS (show_bgp_filter_list, |
| 7522 | show_bgp_ipv6_filter_list_cmd, |
| 7523 | "show bgp ipv6 filter-list WORD", |
| 7524 | SHOW_STR |
| 7525 | BGP_STR |
| 7526 | "Address family\n" |
| 7527 | "Display routes conforming to the filter-list\n" |
| 7528 | "Regular expression access list name\n") |
| 7529 | |
| 7530 | /* old command */ |
| 7531 | DEFUN (show_ipv6_bgp_filter_list, |
| 7532 | show_ipv6_bgp_filter_list_cmd, |
| 7533 | "show ipv6 bgp filter-list WORD", |
| 7534 | SHOW_STR |
| 7535 | IPV6_STR |
| 7536 | BGP_STR |
| 7537 | "Display routes conforming to the filter-list\n" |
| 7538 | "Regular expression access list name\n") |
| 7539 | { |
| 7540 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7541 | bgp_show_type_filter_list); |
| 7542 | } |
| 7543 | |
| 7544 | /* old command */ |
| 7545 | DEFUN (show_ipv6_mbgp_filter_list, |
| 7546 | show_ipv6_mbgp_filter_list_cmd, |
| 7547 | "show ipv6 mbgp filter-list WORD", |
| 7548 | SHOW_STR |
| 7549 | IPV6_STR |
| 7550 | MBGP_STR |
| 7551 | "Display routes conforming to the filter-list\n" |
| 7552 | "Regular expression access list name\n") |
| 7553 | { |
| 7554 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7555 | bgp_show_type_filter_list); |
| 7556 | } |
| 7557 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7558 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7559 | DEFUN (show_ip_bgp_dampening_info, |
| 7560 | show_ip_bgp_dampening_params_cmd, |
| 7561 | "show ip bgp dampening parameters", |
| 7562 | SHOW_STR |
| 7563 | IP_STR |
| 7564 | BGP_STR |
| 7565 | "Display detailed information about dampening\n" |
| 7566 | "Display detail of configured dampening parameters\n") |
| 7567 | { |
| 7568 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); |
| 7569 | } |
| 7570 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7571 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7572 | 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] | 7573 | safi_t safi, enum bgp_show_type type) |
| 7574 | { |
| 7575 | struct route_map *rmap; |
| 7576 | |
| 7577 | rmap = route_map_lookup_by_name (rmap_str); |
| 7578 | if (! rmap) |
| 7579 | { |
| 7580 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 7581 | rmap_str, VTY_NEWLINE); |
| 7582 | return CMD_WARNING; |
| 7583 | } |
| 7584 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7585 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7586 | } |
| 7587 | |
| 7588 | DEFUN (show_ip_bgp_route_map, |
| 7589 | show_ip_bgp_route_map_cmd, |
| 7590 | "show ip bgp route-map WORD", |
| 7591 | SHOW_STR |
| 7592 | IP_STR |
| 7593 | BGP_STR |
| 7594 | "Display routes matching the route-map\n" |
| 7595 | "A route-map to match on\n") |
| 7596 | { |
| 7597 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7598 | bgp_show_type_route_map); |
| 7599 | } |
| 7600 | |
| 7601 | DEFUN (show_ip_bgp_flap_route_map, |
| 7602 | show_ip_bgp_flap_route_map_cmd, |
| 7603 | "show ip bgp flap-statistics route-map WORD", |
| 7604 | SHOW_STR |
| 7605 | IP_STR |
| 7606 | BGP_STR |
| 7607 | "Display flap statistics of routes\n" |
| 7608 | "Display routes matching the route-map\n" |
| 7609 | "A route-map to match on\n") |
| 7610 | { |
| 7611 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7612 | bgp_show_type_flap_route_map); |
| 7613 | } |
| 7614 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7615 | ALIAS (show_ip_bgp_flap_route_map, |
| 7616 | show_ip_bgp_damp_flap_route_map_cmd, |
| 7617 | "show ip bgp dampening flap-statistics route-map WORD", |
| 7618 | SHOW_STR |
| 7619 | IP_STR |
| 7620 | BGP_STR |
| 7621 | "Display detailed information about dampening\n" |
| 7622 | "Display flap statistics of routes\n" |
| 7623 | "Display routes matching the route-map\n" |
| 7624 | "A route-map to match on\n") |
| 7625 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7626 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 7627 | show_ip_bgp_ipv4_route_map_cmd, |
| 7628 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 7629 | SHOW_STR |
| 7630 | IP_STR |
| 7631 | BGP_STR |
| 7632 | "Address family\n" |
| 7633 | "Address Family modifier\n" |
| 7634 | "Address Family modifier\n" |
| 7635 | "Display routes matching the route-map\n" |
| 7636 | "A route-map to match on\n") |
| 7637 | { |
| 7638 | if (strncmp (argv[0], "m", 1) == 0) |
| 7639 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7640 | bgp_show_type_route_map); |
| 7641 | |
| 7642 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7643 | bgp_show_type_route_map); |
| 7644 | } |
| 7645 | |
| 7646 | DEFUN (show_bgp_route_map, |
| 7647 | show_bgp_route_map_cmd, |
| 7648 | "show bgp route-map WORD", |
| 7649 | SHOW_STR |
| 7650 | BGP_STR |
| 7651 | "Display routes matching the route-map\n" |
| 7652 | "A route-map to match on\n") |
| 7653 | { |
| 7654 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7655 | bgp_show_type_route_map); |
| 7656 | } |
| 7657 | |
| 7658 | ALIAS (show_bgp_route_map, |
| 7659 | show_bgp_ipv6_route_map_cmd, |
| 7660 | "show bgp ipv6 route-map WORD", |
| 7661 | SHOW_STR |
| 7662 | BGP_STR |
| 7663 | "Address family\n" |
| 7664 | "Display routes matching the route-map\n" |
| 7665 | "A route-map to match on\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7666 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7667 | DEFUN (show_ip_bgp_cidr_only, |
| 7668 | show_ip_bgp_cidr_only_cmd, |
| 7669 | "show ip bgp cidr-only", |
| 7670 | SHOW_STR |
| 7671 | IP_STR |
| 7672 | BGP_STR |
| 7673 | "Display only routes with non-natural netmasks\n") |
| 7674 | { |
| 7675 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7676 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7677 | } |
| 7678 | |
| 7679 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 7680 | show_ip_bgp_flap_cidr_only_cmd, |
| 7681 | "show ip bgp flap-statistics cidr-only", |
| 7682 | SHOW_STR |
| 7683 | IP_STR |
| 7684 | BGP_STR |
| 7685 | "Display flap statistics of routes\n" |
| 7686 | "Display only routes with non-natural netmasks\n") |
| 7687 | { |
| 7688 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7689 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7690 | } |
| 7691 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7692 | ALIAS (show_ip_bgp_flap_cidr_only, |
| 7693 | show_ip_bgp_damp_flap_cidr_only_cmd, |
| 7694 | "show ip bgp dampening flap-statistics cidr-only", |
| 7695 | SHOW_STR |
| 7696 | IP_STR |
| 7697 | BGP_STR |
| 7698 | "Display detailed information about dampening\n" |
| 7699 | "Display flap statistics of routes\n" |
| 7700 | "Display only routes with non-natural netmasks\n") |
| 7701 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7702 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 7703 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 7704 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 7705 | SHOW_STR |
| 7706 | IP_STR |
| 7707 | BGP_STR |
| 7708 | "Address family\n" |
| 7709 | "Address Family modifier\n" |
| 7710 | "Address Family modifier\n" |
| 7711 | "Display only routes with non-natural netmasks\n") |
| 7712 | { |
| 7713 | if (strncmp (argv[0], "m", 1) == 0) |
| 7714 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7715 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7716 | |
| 7717 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7718 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7719 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7720 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7721 | DEFUN (show_ip_bgp_community_all, |
| 7722 | show_ip_bgp_community_all_cmd, |
| 7723 | "show ip bgp community", |
| 7724 | SHOW_STR |
| 7725 | IP_STR |
| 7726 | BGP_STR |
| 7727 | "Display routes matching the communities\n") |
| 7728 | { |
| 7729 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7730 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7731 | } |
| 7732 | |
| 7733 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 7734 | show_ip_bgp_ipv4_community_all_cmd, |
| 7735 | "show ip bgp ipv4 (unicast|multicast) community", |
| 7736 | SHOW_STR |
| 7737 | IP_STR |
| 7738 | BGP_STR |
| 7739 | "Address family\n" |
| 7740 | "Address Family modifier\n" |
| 7741 | "Address Family modifier\n" |
| 7742 | "Display routes matching the communities\n") |
| 7743 | { |
| 7744 | if (strncmp (argv[0], "m", 1) == 0) |
| 7745 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7746 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7747 | |
| 7748 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7749 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7750 | } |
| 7751 | |
| 7752 | #ifdef HAVE_IPV6 |
| 7753 | DEFUN (show_bgp_community_all, |
| 7754 | show_bgp_community_all_cmd, |
| 7755 | "show bgp community", |
| 7756 | SHOW_STR |
| 7757 | BGP_STR |
| 7758 | "Display routes matching the communities\n") |
| 7759 | { |
| 7760 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7761 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7762 | } |
| 7763 | |
| 7764 | ALIAS (show_bgp_community_all, |
| 7765 | show_bgp_ipv6_community_all_cmd, |
| 7766 | "show bgp ipv6 community", |
| 7767 | SHOW_STR |
| 7768 | BGP_STR |
| 7769 | "Address family\n" |
| 7770 | "Display routes matching the communities\n") |
| 7771 | |
| 7772 | /* old command */ |
| 7773 | DEFUN (show_ipv6_bgp_community_all, |
| 7774 | show_ipv6_bgp_community_all_cmd, |
| 7775 | "show ipv6 bgp community", |
| 7776 | SHOW_STR |
| 7777 | IPV6_STR |
| 7778 | BGP_STR |
| 7779 | "Display routes matching the communities\n") |
| 7780 | { |
| 7781 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7782 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7783 | } |
| 7784 | |
| 7785 | /* old command */ |
| 7786 | DEFUN (show_ipv6_mbgp_community_all, |
| 7787 | show_ipv6_mbgp_community_all_cmd, |
| 7788 | "show ipv6 mbgp community", |
| 7789 | SHOW_STR |
| 7790 | IPV6_STR |
| 7791 | MBGP_STR |
| 7792 | "Display routes matching the communities\n") |
| 7793 | { |
| 7794 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7795 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7796 | } |
| 7797 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7798 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7799 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7800 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 7801 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7802 | { |
| 7803 | struct community *com; |
| 7804 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7805 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7806 | int i; |
| 7807 | char *str; |
| 7808 | int first = 0; |
| 7809 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7810 | /* BGP structure lookup */ |
| 7811 | if (view_name) |
| 7812 | { |
| 7813 | bgp = bgp_lookup_by_name (view_name); |
| 7814 | if (bgp == NULL) |
| 7815 | { |
| 7816 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 7817 | return CMD_WARNING; |
| 7818 | } |
| 7819 | } |
| 7820 | else |
| 7821 | { |
| 7822 | bgp = bgp_get_default (); |
| 7823 | if (bgp == NULL) |
| 7824 | { |
| 7825 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 7826 | return CMD_WARNING; |
| 7827 | } |
| 7828 | } |
| 7829 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7830 | b = buffer_new (1024); |
| 7831 | for (i = 0; i < argc; i++) |
| 7832 | { |
| 7833 | if (first) |
| 7834 | buffer_putc (b, ' '); |
| 7835 | else |
| 7836 | { |
| 7837 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7838 | continue; |
| 7839 | first = 1; |
| 7840 | } |
| 7841 | |
| 7842 | buffer_putstr (b, argv[i]); |
| 7843 | } |
| 7844 | buffer_putc (b, '\0'); |
| 7845 | |
| 7846 | str = buffer_getstr (b); |
| 7847 | buffer_free (b); |
| 7848 | |
| 7849 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7850 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7851 | if (! com) |
| 7852 | { |
| 7853 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 7854 | return CMD_WARNING; |
| 7855 | } |
| 7856 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7857 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7858 | (exact ? bgp_show_type_community_exact : |
| 7859 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7860 | } |
| 7861 | |
| 7862 | DEFUN (show_ip_bgp_community, |
| 7863 | show_ip_bgp_community_cmd, |
| 7864 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7865 | SHOW_STR |
| 7866 | IP_STR |
| 7867 | BGP_STR |
| 7868 | "Display routes matching the communities\n" |
| 7869 | "community number\n" |
| 7870 | "Do not send outside local AS (well-known community)\n" |
| 7871 | "Do not advertise to any peer (well-known community)\n" |
| 7872 | "Do not export to next AS (well-known community)\n") |
| 7873 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7874 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7875 | } |
| 7876 | |
| 7877 | ALIAS (show_ip_bgp_community, |
| 7878 | show_ip_bgp_community2_cmd, |
| 7879 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7880 | SHOW_STR |
| 7881 | IP_STR |
| 7882 | BGP_STR |
| 7883 | "Display routes matching the communities\n" |
| 7884 | "community number\n" |
| 7885 | "Do not send outside local AS (well-known community)\n" |
| 7886 | "Do not advertise to any peer (well-known community)\n" |
| 7887 | "Do not export to next AS (well-known community)\n" |
| 7888 | "community number\n" |
| 7889 | "Do not send outside local AS (well-known community)\n" |
| 7890 | "Do not advertise to any peer (well-known community)\n" |
| 7891 | "Do not export to next AS (well-known community)\n") |
| 7892 | |
| 7893 | ALIAS (show_ip_bgp_community, |
| 7894 | show_ip_bgp_community3_cmd, |
| 7895 | "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)", |
| 7896 | SHOW_STR |
| 7897 | IP_STR |
| 7898 | BGP_STR |
| 7899 | "Display routes matching the communities\n" |
| 7900 | "community number\n" |
| 7901 | "Do not send outside local AS (well-known community)\n" |
| 7902 | "Do not advertise to any peer (well-known community)\n" |
| 7903 | "Do not export to next AS (well-known community)\n" |
| 7904 | "community number\n" |
| 7905 | "Do not send outside local AS (well-known community)\n" |
| 7906 | "Do not advertise to any peer (well-known community)\n" |
| 7907 | "Do not export to next AS (well-known community)\n" |
| 7908 | "community number\n" |
| 7909 | "Do not send outside local AS (well-known community)\n" |
| 7910 | "Do not advertise to any peer (well-known community)\n" |
| 7911 | "Do not export to next AS (well-known community)\n") |
| 7912 | |
| 7913 | ALIAS (show_ip_bgp_community, |
| 7914 | show_ip_bgp_community4_cmd, |
| 7915 | "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)", |
| 7916 | SHOW_STR |
| 7917 | IP_STR |
| 7918 | BGP_STR |
| 7919 | "Display routes matching the communities\n" |
| 7920 | "community number\n" |
| 7921 | "Do not send outside local AS (well-known community)\n" |
| 7922 | "Do not advertise to any peer (well-known community)\n" |
| 7923 | "Do not export to next AS (well-known community)\n" |
| 7924 | "community number\n" |
| 7925 | "Do not send outside local AS (well-known community)\n" |
| 7926 | "Do not advertise to any peer (well-known community)\n" |
| 7927 | "Do not export to next AS (well-known community)\n" |
| 7928 | "community number\n" |
| 7929 | "Do not send outside local AS (well-known community)\n" |
| 7930 | "Do not advertise to any peer (well-known community)\n" |
| 7931 | "Do not export to next AS (well-known community)\n" |
| 7932 | "community number\n" |
| 7933 | "Do not send outside local AS (well-known community)\n" |
| 7934 | "Do not advertise to any peer (well-known community)\n" |
| 7935 | "Do not export to next AS (well-known community)\n") |
| 7936 | |
| 7937 | DEFUN (show_ip_bgp_ipv4_community, |
| 7938 | show_ip_bgp_ipv4_community_cmd, |
| 7939 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7940 | SHOW_STR |
| 7941 | IP_STR |
| 7942 | BGP_STR |
| 7943 | "Address family\n" |
| 7944 | "Address Family modifier\n" |
| 7945 | "Address Family modifier\n" |
| 7946 | "Display routes matching the communities\n" |
| 7947 | "community number\n" |
| 7948 | "Do not send outside local AS (well-known community)\n" |
| 7949 | "Do not advertise to any peer (well-known community)\n" |
| 7950 | "Do not export to next AS (well-known community)\n") |
| 7951 | { |
| 7952 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7953 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7954 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7955 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7956 | } |
| 7957 | |
| 7958 | ALIAS (show_ip_bgp_ipv4_community, |
| 7959 | show_ip_bgp_ipv4_community2_cmd, |
| 7960 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7961 | SHOW_STR |
| 7962 | IP_STR |
| 7963 | BGP_STR |
| 7964 | "Address family\n" |
| 7965 | "Address Family modifier\n" |
| 7966 | "Address Family modifier\n" |
| 7967 | "Display routes matching the communities\n" |
| 7968 | "community number\n" |
| 7969 | "Do not send outside local AS (well-known community)\n" |
| 7970 | "Do not advertise to any peer (well-known community)\n" |
| 7971 | "Do not export to next AS (well-known community)\n" |
| 7972 | "community number\n" |
| 7973 | "Do not send outside local AS (well-known community)\n" |
| 7974 | "Do not advertise to any peer (well-known community)\n" |
| 7975 | "Do not export to next AS (well-known community)\n") |
| 7976 | |
| 7977 | ALIAS (show_ip_bgp_ipv4_community, |
| 7978 | show_ip_bgp_ipv4_community3_cmd, |
| 7979 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7980 | SHOW_STR |
| 7981 | IP_STR |
| 7982 | BGP_STR |
| 7983 | "Address family\n" |
| 7984 | "Address Family modifier\n" |
| 7985 | "Address Family modifier\n" |
| 7986 | "Display routes matching the communities\n" |
| 7987 | "community number\n" |
| 7988 | "Do not send outside local AS (well-known community)\n" |
| 7989 | "Do not advertise to any peer (well-known community)\n" |
| 7990 | "Do not export to next AS (well-known community)\n" |
| 7991 | "community number\n" |
| 7992 | "Do not send outside local AS (well-known community)\n" |
| 7993 | "Do not advertise to any peer (well-known community)\n" |
| 7994 | "Do not export to next AS (well-known community)\n" |
| 7995 | "community number\n" |
| 7996 | "Do not send outside local AS (well-known community)\n" |
| 7997 | "Do not advertise to any peer (well-known community)\n" |
| 7998 | "Do not export to next AS (well-known community)\n") |
| 7999 | |
| 8000 | ALIAS (show_ip_bgp_ipv4_community, |
| 8001 | show_ip_bgp_ipv4_community4_cmd, |
| 8002 | "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)", |
| 8003 | SHOW_STR |
| 8004 | IP_STR |
| 8005 | BGP_STR |
| 8006 | "Address family\n" |
| 8007 | "Address Family modifier\n" |
| 8008 | "Address Family modifier\n" |
| 8009 | "Display routes matching the communities\n" |
| 8010 | "community number\n" |
| 8011 | "Do not send outside local AS (well-known community)\n" |
| 8012 | "Do not advertise to any peer (well-known community)\n" |
| 8013 | "Do not export to next AS (well-known community)\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 | "community number\n" |
| 8023 | "Do not send outside local AS (well-known community)\n" |
| 8024 | "Do not advertise to any peer (well-known community)\n" |
| 8025 | "Do not export to next AS (well-known community)\n") |
| 8026 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8027 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 8028 | show_bgp_view_afi_safi_community_all_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8029 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 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" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8035 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8036 | "Address Family modifier\n" |
| 8037 | "Address Family modifier\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8038 | "Display routes matching the communities\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8039 | { |
| 8040 | int afi; |
| 8041 | int safi; |
| 8042 | struct bgp *bgp; |
| 8043 | |
| 8044 | /* BGP structure lookup. */ |
| 8045 | bgp = bgp_lookup_by_name (argv[0]); |
| 8046 | if (bgp == NULL) |
| 8047 | { |
| 8048 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 8049 | return CMD_WARNING; |
| 8050 | } |
| 8051 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8052 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 8053 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8054 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 8055 | } |
| 8056 | |
| 8057 | DEFUN (show_bgp_view_afi_safi_community, |
| 8058 | show_bgp_view_afi_safi_community_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8059 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8060 | SHOW_STR |
| 8061 | BGP_STR |
| 8062 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8063 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8064 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8065 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8066 | "Address family modifier\n" |
| 8067 | "Address family modifier\n" |
| 8068 | "Display routes matching the communities\n" |
| 8069 | "community number\n" |
| 8070 | "Do not send outside local AS (well-known community)\n" |
| 8071 | "Do not advertise to any peer (well-known community)\n" |
| 8072 | "Do not export to next AS (well-known community)\n") |
| 8073 | { |
| 8074 | int afi; |
| 8075 | int safi; |
| 8076 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8077 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 8078 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 8079 | return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8080 | } |
| 8081 | |
| 8082 | ALIAS (show_bgp_view_afi_safi_community, |
| 8083 | show_bgp_view_afi_safi_community2_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8084 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8085 | SHOW_STR |
| 8086 | BGP_STR |
| 8087 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8088 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8089 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8090 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8091 | "Address family modifier\n" |
| 8092 | "Address family modifier\n" |
| 8093 | "Display routes matching the communities\n" |
| 8094 | "community number\n" |
| 8095 | "Do not send outside local AS (well-known community)\n" |
| 8096 | "Do not advertise to any peer (well-known community)\n" |
| 8097 | "Do not export to next AS (well-known community)\n" |
| 8098 | "community number\n" |
| 8099 | "Do not send outside local AS (well-known community)\n" |
| 8100 | "Do not advertise to any peer (well-known community)\n" |
| 8101 | "Do not export to next AS (well-known community)\n") |
| 8102 | |
| 8103 | ALIAS (show_bgp_view_afi_safi_community, |
| 8104 | show_bgp_view_afi_safi_community3_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8105 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8106 | SHOW_STR |
| 8107 | BGP_STR |
| 8108 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8109 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8110 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8111 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8112 | "Address family modifier\n" |
| 8113 | "Address family modifier\n" |
| 8114 | "Display routes matching the communities\n" |
| 8115 | "community number\n" |
| 8116 | "Do not send outside local AS (well-known community)\n" |
| 8117 | "Do not advertise to any peer (well-known community)\n" |
| 8118 | "Do not export to next AS (well-known community)\n" |
| 8119 | "community number\n" |
| 8120 | "Do not send outside local AS (well-known community)\n" |
| 8121 | "Do not advertise to any peer (well-known community)\n" |
| 8122 | "Do not export to next AS (well-known community)\n" |
| 8123 | "community number\n" |
| 8124 | "Do not send outside local AS (well-known community)\n" |
| 8125 | "Do not advertise to any peer (well-known community)\n" |
| 8126 | "Do not export to next AS (well-known community)\n") |
| 8127 | |
| 8128 | ALIAS (show_bgp_view_afi_safi_community, |
| 8129 | show_bgp_view_afi_safi_community4_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8130 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8131 | SHOW_STR |
| 8132 | BGP_STR |
| 8133 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8134 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8135 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8136 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8137 | "Address family modifier\n" |
| 8138 | "Address family modifier\n" |
| 8139 | "Display routes matching the communities\n" |
| 8140 | "community number\n" |
| 8141 | "Do not send outside local AS (well-known community)\n" |
| 8142 | "Do not advertise to any peer (well-known community)\n" |
| 8143 | "Do not export to next AS (well-known community)\n" |
| 8144 | "community number\n" |
| 8145 | "Do not send outside local AS (well-known community)\n" |
| 8146 | "Do not advertise to any peer (well-known community)\n" |
| 8147 | "Do not export to next AS (well-known community)\n" |
| 8148 | "community number\n" |
| 8149 | "Do not send outside local AS (well-known community)\n" |
| 8150 | "Do not advertise to any peer (well-known community)\n" |
| 8151 | "Do not export to next AS (well-known community)\n" |
| 8152 | "community number\n" |
| 8153 | "Do not send outside local AS (well-known community)\n" |
| 8154 | "Do not advertise to any peer (well-known community)\n" |
| 8155 | "Do not export to next AS (well-known community)\n") |
| 8156 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8157 | DEFUN (show_ip_bgp_community_exact, |
| 8158 | show_ip_bgp_community_exact_cmd, |
| 8159 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8160 | SHOW_STR |
| 8161 | IP_STR |
| 8162 | BGP_STR |
| 8163 | "Display routes matching the communities\n" |
| 8164 | "community number\n" |
| 8165 | "Do not send outside local AS (well-known community)\n" |
| 8166 | "Do not advertise to any peer (well-known community)\n" |
| 8167 | "Do not export to next AS (well-known community)\n" |
| 8168 | "Exact match of the communities") |
| 8169 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8170 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8171 | } |
| 8172 | |
| 8173 | ALIAS (show_ip_bgp_community_exact, |
| 8174 | show_ip_bgp_community2_exact_cmd, |
| 8175 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8176 | SHOW_STR |
| 8177 | IP_STR |
| 8178 | BGP_STR |
| 8179 | "Display routes matching the communities\n" |
| 8180 | "community number\n" |
| 8181 | "Do not send outside local AS (well-known community)\n" |
| 8182 | "Do not advertise to any peer (well-known community)\n" |
| 8183 | "Do not export to next AS (well-known community)\n" |
| 8184 | "community number\n" |
| 8185 | "Do not send outside local AS (well-known community)\n" |
| 8186 | "Do not advertise to any peer (well-known community)\n" |
| 8187 | "Do not export to next AS (well-known community)\n" |
| 8188 | "Exact match of the communities") |
| 8189 | |
| 8190 | ALIAS (show_ip_bgp_community_exact, |
| 8191 | show_ip_bgp_community3_exact_cmd, |
| 8192 | "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", |
| 8193 | SHOW_STR |
| 8194 | IP_STR |
| 8195 | BGP_STR |
| 8196 | "Display routes matching the communities\n" |
| 8197 | "community number\n" |
| 8198 | "Do not send outside local AS (well-known community)\n" |
| 8199 | "Do not advertise to any peer (well-known community)\n" |
| 8200 | "Do not export to next AS (well-known community)\n" |
| 8201 | "community number\n" |
| 8202 | "Do not send outside local AS (well-known community)\n" |
| 8203 | "Do not advertise to any peer (well-known community)\n" |
| 8204 | "Do not export to next AS (well-known community)\n" |
| 8205 | "community number\n" |
| 8206 | "Do not send outside local AS (well-known community)\n" |
| 8207 | "Do not advertise to any peer (well-known community)\n" |
| 8208 | "Do not export to next AS (well-known community)\n" |
| 8209 | "Exact match of the communities") |
| 8210 | |
| 8211 | ALIAS (show_ip_bgp_community_exact, |
| 8212 | show_ip_bgp_community4_exact_cmd, |
| 8213 | "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", |
| 8214 | SHOW_STR |
| 8215 | IP_STR |
| 8216 | BGP_STR |
| 8217 | "Display routes matching the communities\n" |
| 8218 | "community number\n" |
| 8219 | "Do not send outside local AS (well-known community)\n" |
| 8220 | "Do not advertise to any peer (well-known community)\n" |
| 8221 | "Do not export to next AS (well-known community)\n" |
| 8222 | "community number\n" |
| 8223 | "Do not send outside local AS (well-known community)\n" |
| 8224 | "Do not advertise to any peer (well-known community)\n" |
| 8225 | "Do not export to next AS (well-known community)\n" |
| 8226 | "community number\n" |
| 8227 | "Do not send outside local AS (well-known community)\n" |
| 8228 | "Do not advertise to any peer (well-known community)\n" |
| 8229 | "Do not export to next AS (well-known community)\n" |
| 8230 | "community number\n" |
| 8231 | "Do not send outside local AS (well-known community)\n" |
| 8232 | "Do not advertise to any peer (well-known community)\n" |
| 8233 | "Do not export to next AS (well-known community)\n" |
| 8234 | "Exact match of the communities") |
| 8235 | |
| 8236 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 8237 | show_ip_bgp_ipv4_community_exact_cmd, |
| 8238 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8239 | SHOW_STR |
| 8240 | IP_STR |
| 8241 | BGP_STR |
| 8242 | "Address family\n" |
| 8243 | "Address Family modifier\n" |
| 8244 | "Address Family modifier\n" |
| 8245 | "Display routes matching the communities\n" |
| 8246 | "community number\n" |
| 8247 | "Do not send outside local AS (well-known community)\n" |
| 8248 | "Do not advertise to any peer (well-known community)\n" |
| 8249 | "Do not export to next AS (well-known community)\n" |
| 8250 | "Exact match of the communities") |
| 8251 | { |
| 8252 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8253 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8254 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8255 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8256 | } |
| 8257 | |
| 8258 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8259 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 8260 | "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", |
| 8261 | SHOW_STR |
| 8262 | IP_STR |
| 8263 | BGP_STR |
| 8264 | "Address family\n" |
| 8265 | "Address Family modifier\n" |
| 8266 | "Address Family modifier\n" |
| 8267 | "Display routes matching the communities\n" |
| 8268 | "community number\n" |
| 8269 | "Do not send outside local AS (well-known community)\n" |
| 8270 | "Do not advertise to any peer (well-known community)\n" |
| 8271 | "Do not export to next AS (well-known community)\n" |
| 8272 | "community number\n" |
| 8273 | "Do not send outside local AS (well-known community)\n" |
| 8274 | "Do not advertise to any peer (well-known community)\n" |
| 8275 | "Do not export to next AS (well-known community)\n" |
| 8276 | "Exact match of the communities") |
| 8277 | |
| 8278 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8279 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 8280 | "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", |
| 8281 | SHOW_STR |
| 8282 | IP_STR |
| 8283 | BGP_STR |
| 8284 | "Address family\n" |
| 8285 | "Address Family modifier\n" |
| 8286 | "Address Family modifier\n" |
| 8287 | "Display routes matching the communities\n" |
| 8288 | "community number\n" |
| 8289 | "Do not send outside local AS (well-known community)\n" |
| 8290 | "Do not advertise to any peer (well-known community)\n" |
| 8291 | "Do not export to next AS (well-known community)\n" |
| 8292 | "community number\n" |
| 8293 | "Do not send outside local AS (well-known community)\n" |
| 8294 | "Do not advertise to any peer (well-known community)\n" |
| 8295 | "Do not export to next AS (well-known community)\n" |
| 8296 | "community number\n" |
| 8297 | "Do not send outside local AS (well-known community)\n" |
| 8298 | "Do not advertise to any peer (well-known community)\n" |
| 8299 | "Do not export to next AS (well-known community)\n" |
| 8300 | "Exact match of the communities") |
| 8301 | |
| 8302 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8303 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 8304 | "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", |
| 8305 | SHOW_STR |
| 8306 | IP_STR |
| 8307 | BGP_STR |
| 8308 | "Address family\n" |
| 8309 | "Address Family modifier\n" |
| 8310 | "Address Family modifier\n" |
| 8311 | "Display routes matching the communities\n" |
| 8312 | "community number\n" |
| 8313 | "Do not send outside local AS (well-known community)\n" |
| 8314 | "Do not advertise to any peer (well-known community)\n" |
| 8315 | "Do not export to next AS (well-known community)\n" |
| 8316 | "community number\n" |
| 8317 | "Do not send outside local AS (well-known community)\n" |
| 8318 | "Do not advertise to any peer (well-known community)\n" |
| 8319 | "Do not export to next AS (well-known community)\n" |
| 8320 | "community number\n" |
| 8321 | "Do not send outside local AS (well-known community)\n" |
| 8322 | "Do not advertise to any peer (well-known community)\n" |
| 8323 | "Do not export to next AS (well-known community)\n" |
| 8324 | "community number\n" |
| 8325 | "Do not send outside local AS (well-known community)\n" |
| 8326 | "Do not advertise to any peer (well-known community)\n" |
| 8327 | "Do not export to next AS (well-known community)\n" |
| 8328 | "Exact match of the communities") |
| 8329 | |
| 8330 | #ifdef HAVE_IPV6 |
| 8331 | DEFUN (show_bgp_community, |
| 8332 | show_bgp_community_cmd, |
| 8333 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8334 | SHOW_STR |
| 8335 | BGP_STR |
| 8336 | "Display routes matching the communities\n" |
| 8337 | "community number\n" |
| 8338 | "Do not send outside local AS (well-known community)\n" |
| 8339 | "Do not advertise to any peer (well-known community)\n" |
| 8340 | "Do not export to next AS (well-known community)\n") |
| 8341 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8342 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8343 | } |
| 8344 | |
| 8345 | ALIAS (show_bgp_community, |
| 8346 | show_bgp_ipv6_community_cmd, |
| 8347 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 8348 | SHOW_STR |
| 8349 | BGP_STR |
| 8350 | "Address family\n" |
| 8351 | "Display routes matching the communities\n" |
| 8352 | "community number\n" |
| 8353 | "Do not send outside local AS (well-known community)\n" |
| 8354 | "Do not advertise to any peer (well-known community)\n" |
| 8355 | "Do not export to next AS (well-known community)\n") |
| 8356 | |
| 8357 | ALIAS (show_bgp_community, |
| 8358 | show_bgp_community2_cmd, |
| 8359 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8360 | SHOW_STR |
| 8361 | BGP_STR |
| 8362 | "Display routes matching the communities\n" |
| 8363 | "community number\n" |
| 8364 | "Do not send outside local AS (well-known community)\n" |
| 8365 | "Do not advertise to any peer (well-known community)\n" |
| 8366 | "Do not export to next AS (well-known community)\n" |
| 8367 | "community number\n" |
| 8368 | "Do not send outside local AS (well-known community)\n" |
| 8369 | "Do not advertise to any peer (well-known community)\n" |
| 8370 | "Do not export to next AS (well-known community)\n") |
| 8371 | |
| 8372 | ALIAS (show_bgp_community, |
| 8373 | show_bgp_ipv6_community2_cmd, |
| 8374 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8375 | SHOW_STR |
| 8376 | BGP_STR |
| 8377 | "Address family\n" |
| 8378 | "Display routes matching the communities\n" |
| 8379 | "community number\n" |
| 8380 | "Do not send outside local AS (well-known community)\n" |
| 8381 | "Do not advertise to any peer (well-known community)\n" |
| 8382 | "Do not export to next AS (well-known community)\n" |
| 8383 | "community number\n" |
| 8384 | "Do not send outside local AS (well-known community)\n" |
| 8385 | "Do not advertise to any peer (well-known community)\n" |
| 8386 | "Do not export to next AS (well-known community)\n") |
| 8387 | |
| 8388 | ALIAS (show_bgp_community, |
| 8389 | show_bgp_community3_cmd, |
| 8390 | "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)", |
| 8391 | SHOW_STR |
| 8392 | BGP_STR |
| 8393 | "Display routes matching the communities\n" |
| 8394 | "community number\n" |
| 8395 | "Do not send outside local AS (well-known community)\n" |
| 8396 | "Do not advertise to any peer (well-known community)\n" |
| 8397 | "Do not export to next AS (well-known community)\n" |
| 8398 | "community number\n" |
| 8399 | "Do not send outside local AS (well-known community)\n" |
| 8400 | "Do not advertise to any peer (well-known community)\n" |
| 8401 | "Do not export to next AS (well-known community)\n" |
| 8402 | "community number\n" |
| 8403 | "Do not send outside local AS (well-known community)\n" |
| 8404 | "Do not advertise to any peer (well-known community)\n" |
| 8405 | "Do not export to next AS (well-known community)\n") |
| 8406 | |
| 8407 | ALIAS (show_bgp_community, |
| 8408 | show_bgp_ipv6_community3_cmd, |
| 8409 | "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)", |
| 8410 | SHOW_STR |
| 8411 | BGP_STR |
| 8412 | "Address family\n" |
| 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 | "community number\n" |
| 8419 | "Do not send outside local AS (well-known community)\n" |
| 8420 | "Do not advertise to any peer (well-known community)\n" |
| 8421 | "Do not export to next AS (well-known community)\n" |
| 8422 | "community number\n" |
| 8423 | "Do not send outside local AS (well-known community)\n" |
| 8424 | "Do not advertise to any peer (well-known community)\n" |
| 8425 | "Do not export to next AS (well-known community)\n") |
| 8426 | |
| 8427 | ALIAS (show_bgp_community, |
| 8428 | show_bgp_community4_cmd, |
| 8429 | "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)", |
| 8430 | SHOW_STR |
| 8431 | BGP_STR |
| 8432 | "Display routes matching the communities\n" |
| 8433 | "community number\n" |
| 8434 | "Do not send outside local AS (well-known community)\n" |
| 8435 | "Do not advertise to any peer (well-known community)\n" |
| 8436 | "Do not export to next AS (well-known community)\n" |
| 8437 | "community number\n" |
| 8438 | "Do not send outside local AS (well-known community)\n" |
| 8439 | "Do not advertise to any peer (well-known community)\n" |
| 8440 | "Do not export to next AS (well-known community)\n" |
| 8441 | "community number\n" |
| 8442 | "Do not send outside local AS (well-known community)\n" |
| 8443 | "Do not advertise to any peer (well-known community)\n" |
| 8444 | "Do not export to next AS (well-known community)\n" |
| 8445 | "community number\n" |
| 8446 | "Do not send outside local AS (well-known community)\n" |
| 8447 | "Do not advertise to any peer (well-known community)\n" |
| 8448 | "Do not export to next AS (well-known community)\n") |
| 8449 | |
| 8450 | ALIAS (show_bgp_community, |
| 8451 | show_bgp_ipv6_community4_cmd, |
| 8452 | "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)", |
| 8453 | SHOW_STR |
| 8454 | BGP_STR |
| 8455 | "Address family\n" |
| 8456 | "Display routes matching the communities\n" |
| 8457 | "community number\n" |
| 8458 | "Do not send outside local AS (well-known community)\n" |
| 8459 | "Do not advertise to any peer (well-known community)\n" |
| 8460 | "Do not export to next AS (well-known community)\n" |
| 8461 | "community number\n" |
| 8462 | "Do not send outside local AS (well-known community)\n" |
| 8463 | "Do not advertise to any peer (well-known community)\n" |
| 8464 | "Do not export to next AS (well-known community)\n" |
| 8465 | "community number\n" |
| 8466 | "Do not send outside local AS (well-known community)\n" |
| 8467 | "Do not advertise to any peer (well-known community)\n" |
| 8468 | "Do not export to next AS (well-known community)\n" |
| 8469 | "community number\n" |
| 8470 | "Do not send outside local AS (well-known community)\n" |
| 8471 | "Do not advertise to any peer (well-known community)\n" |
| 8472 | "Do not export to next AS (well-known community)\n") |
| 8473 | |
| 8474 | /* old command */ |
| 8475 | DEFUN (show_ipv6_bgp_community, |
| 8476 | show_ipv6_bgp_community_cmd, |
| 8477 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8478 | SHOW_STR |
| 8479 | IPV6_STR |
| 8480 | BGP_STR |
| 8481 | "Display routes matching the communities\n" |
| 8482 | "community number\n" |
| 8483 | "Do not send outside local AS (well-known community)\n" |
| 8484 | "Do not advertise to any peer (well-known community)\n" |
| 8485 | "Do not export to next AS (well-known community)\n") |
| 8486 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8487 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8488 | } |
| 8489 | |
| 8490 | /* old command */ |
| 8491 | ALIAS (show_ipv6_bgp_community, |
| 8492 | show_ipv6_bgp_community2_cmd, |
| 8493 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8494 | SHOW_STR |
| 8495 | IPV6_STR |
| 8496 | BGP_STR |
| 8497 | "Display routes matching the communities\n" |
| 8498 | "community number\n" |
| 8499 | "Do not send outside local AS (well-known community)\n" |
| 8500 | "Do not advertise to any peer (well-known community)\n" |
| 8501 | "Do not export to next AS (well-known community)\n" |
| 8502 | "community number\n" |
| 8503 | "Do not send outside local AS (well-known community)\n" |
| 8504 | "Do not advertise to any peer (well-known community)\n" |
| 8505 | "Do not export to next AS (well-known community)\n") |
| 8506 | |
| 8507 | /* old command */ |
| 8508 | ALIAS (show_ipv6_bgp_community, |
| 8509 | show_ipv6_bgp_community3_cmd, |
| 8510 | "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)", |
| 8511 | SHOW_STR |
| 8512 | IPV6_STR |
| 8513 | BGP_STR |
| 8514 | "Display routes matching the communities\n" |
| 8515 | "community number\n" |
| 8516 | "Do not send outside local AS (well-known community)\n" |
| 8517 | "Do not advertise to any peer (well-known community)\n" |
| 8518 | "Do not export to next AS (well-known community)\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 | |
| 8528 | /* old command */ |
| 8529 | ALIAS (show_ipv6_bgp_community, |
| 8530 | show_ipv6_bgp_community4_cmd, |
| 8531 | "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)", |
| 8532 | SHOW_STR |
| 8533 | IPV6_STR |
| 8534 | BGP_STR |
| 8535 | "Display routes matching the communities\n" |
| 8536 | "community number\n" |
| 8537 | "Do not send outside local AS (well-known community)\n" |
| 8538 | "Do not advertise to any peer (well-known community)\n" |
| 8539 | "Do not export to next AS (well-known community)\n" |
| 8540 | "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 | "community number\n" |
| 8545 | "Do not send outside local AS (well-known community)\n" |
| 8546 | "Do not advertise to any peer (well-known community)\n" |
| 8547 | "Do not export to next AS (well-known community)\n" |
| 8548 | "community number\n" |
| 8549 | "Do not send outside local AS (well-known community)\n" |
| 8550 | "Do not advertise to any peer (well-known community)\n" |
| 8551 | "Do not export to next AS (well-known community)\n") |
| 8552 | |
| 8553 | DEFUN (show_bgp_community_exact, |
| 8554 | show_bgp_community_exact_cmd, |
| 8555 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8556 | SHOW_STR |
| 8557 | BGP_STR |
| 8558 | "Display routes matching the communities\n" |
| 8559 | "community number\n" |
| 8560 | "Do not send outside local AS (well-known community)\n" |
| 8561 | "Do not advertise to any peer (well-known community)\n" |
| 8562 | "Do not export to next AS (well-known community)\n" |
| 8563 | "Exact match of the communities") |
| 8564 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8565 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8566 | } |
| 8567 | |
| 8568 | ALIAS (show_bgp_community_exact, |
| 8569 | show_bgp_ipv6_community_exact_cmd, |
| 8570 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8571 | SHOW_STR |
| 8572 | BGP_STR |
| 8573 | "Address family\n" |
| 8574 | "Display routes matching the communities\n" |
| 8575 | "community number\n" |
| 8576 | "Do not send outside local AS (well-known community)\n" |
| 8577 | "Do not advertise to any peer (well-known community)\n" |
| 8578 | "Do not export to next AS (well-known community)\n" |
| 8579 | "Exact match of the communities") |
| 8580 | |
| 8581 | ALIAS (show_bgp_community_exact, |
| 8582 | show_bgp_community2_exact_cmd, |
| 8583 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8584 | SHOW_STR |
| 8585 | BGP_STR |
| 8586 | "Display routes matching the communities\n" |
| 8587 | "community number\n" |
| 8588 | "Do not send outside local AS (well-known community)\n" |
| 8589 | "Do not advertise to any peer (well-known community)\n" |
| 8590 | "Do not export to next AS (well-known community)\n" |
| 8591 | "community number\n" |
| 8592 | "Do not send outside local AS (well-known community)\n" |
| 8593 | "Do not advertise to any peer (well-known community)\n" |
| 8594 | "Do not export to next AS (well-known community)\n" |
| 8595 | "Exact match of the communities") |
| 8596 | |
| 8597 | ALIAS (show_bgp_community_exact, |
| 8598 | show_bgp_ipv6_community2_exact_cmd, |
| 8599 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8600 | SHOW_STR |
| 8601 | BGP_STR |
| 8602 | "Address family\n" |
| 8603 | "Display routes matching the communities\n" |
| 8604 | "community number\n" |
| 8605 | "Do not send outside local AS (well-known community)\n" |
| 8606 | "Do not advertise to any peer (well-known community)\n" |
| 8607 | "Do not export to next AS (well-known community)\n" |
| 8608 | "community number\n" |
| 8609 | "Do not send outside local AS (well-known community)\n" |
| 8610 | "Do not advertise to any peer (well-known community)\n" |
| 8611 | "Do not export to next AS (well-known community)\n" |
| 8612 | "Exact match of the communities") |
| 8613 | |
| 8614 | ALIAS (show_bgp_community_exact, |
| 8615 | show_bgp_community3_exact_cmd, |
| 8616 | "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", |
| 8617 | SHOW_STR |
| 8618 | BGP_STR |
| 8619 | "Display routes matching the communities\n" |
| 8620 | "community number\n" |
| 8621 | "Do not send outside local AS (well-known community)\n" |
| 8622 | "Do not advertise to any peer (well-known community)\n" |
| 8623 | "Do not export to next AS (well-known community)\n" |
| 8624 | "community number\n" |
| 8625 | "Do not send outside local AS (well-known community)\n" |
| 8626 | "Do not advertise to any peer (well-known community)\n" |
| 8627 | "Do not export to next AS (well-known community)\n" |
| 8628 | "community number\n" |
| 8629 | "Do not send outside local AS (well-known community)\n" |
| 8630 | "Do not advertise to any peer (well-known community)\n" |
| 8631 | "Do not export to next AS (well-known community)\n" |
| 8632 | "Exact match of the communities") |
| 8633 | |
| 8634 | ALIAS (show_bgp_community_exact, |
| 8635 | show_bgp_ipv6_community3_exact_cmd, |
| 8636 | "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", |
| 8637 | SHOW_STR |
| 8638 | BGP_STR |
| 8639 | "Address family\n" |
| 8640 | "Display routes matching the communities\n" |
| 8641 | "community number\n" |
| 8642 | "Do not send outside local AS (well-known community)\n" |
| 8643 | "Do not advertise to any peer (well-known community)\n" |
| 8644 | "Do not export to next AS (well-known community)\n" |
| 8645 | "community number\n" |
| 8646 | "Do not send outside local AS (well-known community)\n" |
| 8647 | "Do not advertise to any peer (well-known community)\n" |
| 8648 | "Do not export to next AS (well-known community)\n" |
| 8649 | "community number\n" |
| 8650 | "Do not send outside local AS (well-known community)\n" |
| 8651 | "Do not advertise to any peer (well-known community)\n" |
| 8652 | "Do not export to next AS (well-known community)\n" |
| 8653 | "Exact match of the communities") |
| 8654 | |
| 8655 | ALIAS (show_bgp_community_exact, |
| 8656 | show_bgp_community4_exact_cmd, |
| 8657 | "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", |
| 8658 | SHOW_STR |
| 8659 | BGP_STR |
| 8660 | "Display routes matching the communities\n" |
| 8661 | "community number\n" |
| 8662 | "Do not send outside local AS (well-known community)\n" |
| 8663 | "Do not advertise to any peer (well-known community)\n" |
| 8664 | "Do not export to next AS (well-known community)\n" |
| 8665 | "community number\n" |
| 8666 | "Do not send outside local AS (well-known community)\n" |
| 8667 | "Do not advertise to any peer (well-known community)\n" |
| 8668 | "Do not export to next AS (well-known community)\n" |
| 8669 | "community number\n" |
| 8670 | "Do not send outside local AS (well-known community)\n" |
| 8671 | "Do not advertise to any peer (well-known community)\n" |
| 8672 | "Do not export to next AS (well-known community)\n" |
| 8673 | "community number\n" |
| 8674 | "Do not send outside local AS (well-known community)\n" |
| 8675 | "Do not advertise to any peer (well-known community)\n" |
| 8676 | "Do not export to next AS (well-known community)\n" |
| 8677 | "Exact match of the communities") |
| 8678 | |
| 8679 | ALIAS (show_bgp_community_exact, |
| 8680 | show_bgp_ipv6_community4_exact_cmd, |
| 8681 | "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", |
| 8682 | SHOW_STR |
| 8683 | BGP_STR |
| 8684 | "Address family\n" |
| 8685 | "Display routes matching the communities\n" |
| 8686 | "community number\n" |
| 8687 | "Do not send outside local AS (well-known community)\n" |
| 8688 | "Do not advertise to any peer (well-known community)\n" |
| 8689 | "Do not export to next AS (well-known community)\n" |
| 8690 | "community number\n" |
| 8691 | "Do not send outside local AS (well-known community)\n" |
| 8692 | "Do not advertise to any peer (well-known community)\n" |
| 8693 | "Do not export to next AS (well-known community)\n" |
| 8694 | "community number\n" |
| 8695 | "Do not send outside local AS (well-known community)\n" |
| 8696 | "Do not advertise to any peer (well-known community)\n" |
| 8697 | "Do not export to next AS (well-known community)\n" |
| 8698 | "community number\n" |
| 8699 | "Do not send outside local AS (well-known community)\n" |
| 8700 | "Do not advertise to any peer (well-known community)\n" |
| 8701 | "Do not export to next AS (well-known community)\n" |
| 8702 | "Exact match of the communities") |
| 8703 | |
| 8704 | /* old command */ |
| 8705 | DEFUN (show_ipv6_bgp_community_exact, |
| 8706 | show_ipv6_bgp_community_exact_cmd, |
| 8707 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8708 | SHOW_STR |
| 8709 | IPV6_STR |
| 8710 | BGP_STR |
| 8711 | "Display routes matching the communities\n" |
| 8712 | "community number\n" |
| 8713 | "Do not send outside local AS (well-known community)\n" |
| 8714 | "Do not advertise to any peer (well-known community)\n" |
| 8715 | "Do not export to next AS (well-known community)\n" |
| 8716 | "Exact match of the communities") |
| 8717 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8718 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8719 | } |
| 8720 | |
| 8721 | /* old command */ |
| 8722 | ALIAS (show_ipv6_bgp_community_exact, |
| 8723 | show_ipv6_bgp_community2_exact_cmd, |
| 8724 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8725 | SHOW_STR |
| 8726 | IPV6_STR |
| 8727 | BGP_STR |
| 8728 | "Display routes matching the communities\n" |
| 8729 | "community number\n" |
| 8730 | "Do not send outside local AS (well-known community)\n" |
| 8731 | "Do not advertise to any peer (well-known community)\n" |
| 8732 | "Do not export to next AS (well-known community)\n" |
| 8733 | "community number\n" |
| 8734 | "Do not send outside local AS (well-known community)\n" |
| 8735 | "Do not advertise to any peer (well-known community)\n" |
| 8736 | "Do not export to next AS (well-known community)\n" |
| 8737 | "Exact match of the communities") |
| 8738 | |
| 8739 | /* old command */ |
| 8740 | ALIAS (show_ipv6_bgp_community_exact, |
| 8741 | show_ipv6_bgp_community3_exact_cmd, |
| 8742 | "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", |
| 8743 | SHOW_STR |
| 8744 | IPV6_STR |
| 8745 | BGP_STR |
| 8746 | "Display routes matching the communities\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 | "community number\n" |
| 8752 | "Do not send outside local AS (well-known community)\n" |
| 8753 | "Do not advertise to any peer (well-known community)\n" |
| 8754 | "Do not export to next AS (well-known community)\n" |
| 8755 | "community number\n" |
| 8756 | "Do not send outside local AS (well-known community)\n" |
| 8757 | "Do not advertise to any peer (well-known community)\n" |
| 8758 | "Do not export to next AS (well-known community)\n" |
| 8759 | "Exact match of the communities") |
| 8760 | |
| 8761 | /* old command */ |
| 8762 | ALIAS (show_ipv6_bgp_community_exact, |
| 8763 | show_ipv6_bgp_community4_exact_cmd, |
| 8764 | "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", |
| 8765 | SHOW_STR |
| 8766 | IPV6_STR |
| 8767 | BGP_STR |
| 8768 | "Display routes matching the communities\n" |
| 8769 | "community number\n" |
| 8770 | "Do not send outside local AS (well-known community)\n" |
| 8771 | "Do not advertise to any peer (well-known community)\n" |
| 8772 | "Do not export to next AS (well-known community)\n" |
| 8773 | "community number\n" |
| 8774 | "Do not send outside local AS (well-known community)\n" |
| 8775 | "Do not advertise to any peer (well-known community)\n" |
| 8776 | "Do not export to next AS (well-known community)\n" |
| 8777 | "community number\n" |
| 8778 | "Do not send outside local AS (well-known community)\n" |
| 8779 | "Do not advertise to any peer (well-known community)\n" |
| 8780 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") |
| 8786 | |
| 8787 | /* old command */ |
| 8788 | DEFUN (show_ipv6_mbgp_community, |
| 8789 | show_ipv6_mbgp_community_cmd, |
| 8790 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8791 | SHOW_STR |
| 8792 | IPV6_STR |
| 8793 | MBGP_STR |
| 8794 | "Display routes matching the communities\n" |
| 8795 | "community number\n" |
| 8796 | "Do not send outside local AS (well-known community)\n" |
| 8797 | "Do not advertise to any peer (well-known community)\n" |
| 8798 | "Do not export to next AS (well-known community)\n") |
| 8799 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8800 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8801 | } |
| 8802 | |
| 8803 | /* old command */ |
| 8804 | ALIAS (show_ipv6_mbgp_community, |
| 8805 | show_ipv6_mbgp_community2_cmd, |
| 8806 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8807 | SHOW_STR |
| 8808 | IPV6_STR |
| 8809 | MBGP_STR |
| 8810 | "Display routes matching the communities\n" |
| 8811 | "community number\n" |
| 8812 | "Do not send outside local AS (well-known community)\n" |
| 8813 | "Do not advertise to any peer (well-known community)\n" |
| 8814 | "Do not export to next AS (well-known community)\n" |
| 8815 | "community number\n" |
| 8816 | "Do not send outside local AS (well-known community)\n" |
| 8817 | "Do not advertise to any peer (well-known community)\n" |
| 8818 | "Do not export to next AS (well-known community)\n") |
| 8819 | |
| 8820 | /* old command */ |
| 8821 | ALIAS (show_ipv6_mbgp_community, |
| 8822 | show_ipv6_mbgp_community3_cmd, |
| 8823 | "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)", |
| 8824 | SHOW_STR |
| 8825 | IPV6_STR |
| 8826 | MBGP_STR |
| 8827 | "Display routes matching the communities\n" |
| 8828 | "community number\n" |
| 8829 | "Do not send outside local AS (well-known community)\n" |
| 8830 | "Do not advertise to any peer (well-known community)\n" |
| 8831 | "Do not export to next AS (well-known community)\n" |
| 8832 | "community number\n" |
| 8833 | "Do not send outside local AS (well-known community)\n" |
| 8834 | "Do not advertise to any peer (well-known community)\n" |
| 8835 | "Do not export to next AS (well-known community)\n" |
| 8836 | "community number\n" |
| 8837 | "Do not send outside local AS (well-known community)\n" |
| 8838 | "Do not advertise to any peer (well-known community)\n" |
| 8839 | "Do not export to next AS (well-known community)\n") |
| 8840 | |
| 8841 | /* old command */ |
| 8842 | ALIAS (show_ipv6_mbgp_community, |
| 8843 | show_ipv6_mbgp_community4_cmd, |
| 8844 | "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)", |
| 8845 | SHOW_STR |
| 8846 | IPV6_STR |
| 8847 | MBGP_STR |
| 8848 | "Display routes matching the communities\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 | "community number\n" |
| 8854 | "Do not send outside local AS (well-known community)\n" |
| 8855 | "Do not advertise to any peer (well-known community)\n" |
| 8856 | "Do not export to next AS (well-known community)\n" |
| 8857 | "community number\n" |
| 8858 | "Do not send outside local AS (well-known community)\n" |
| 8859 | "Do not advertise to any peer (well-known community)\n" |
| 8860 | "Do not export to next AS (well-known community)\n" |
| 8861 | "community number\n" |
| 8862 | "Do not send outside local AS (well-known community)\n" |
| 8863 | "Do not advertise to any peer (well-known community)\n" |
| 8864 | "Do not export to next AS (well-known community)\n") |
| 8865 | |
| 8866 | /* old command */ |
| 8867 | DEFUN (show_ipv6_mbgp_community_exact, |
| 8868 | show_ipv6_mbgp_community_exact_cmd, |
| 8869 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8870 | SHOW_STR |
| 8871 | IPV6_STR |
| 8872 | MBGP_STR |
| 8873 | "Display routes matching the communities\n" |
| 8874 | "community number\n" |
| 8875 | "Do not send outside local AS (well-known community)\n" |
| 8876 | "Do not advertise to any peer (well-known community)\n" |
| 8877 | "Do not export to next AS (well-known community)\n" |
| 8878 | "Exact match of the communities") |
| 8879 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8880 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8881 | } |
| 8882 | |
| 8883 | /* old command */ |
| 8884 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8885 | show_ipv6_mbgp_community2_exact_cmd, |
| 8886 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8887 | SHOW_STR |
| 8888 | IPV6_STR |
| 8889 | MBGP_STR |
| 8890 | "Display routes matching the communities\n" |
| 8891 | "community number\n" |
| 8892 | "Do not send outside local AS (well-known community)\n" |
| 8893 | "Do not advertise to any peer (well-known community)\n" |
| 8894 | "Do not export to next AS (well-known community)\n" |
| 8895 | "community number\n" |
| 8896 | "Do not send outside local AS (well-known community)\n" |
| 8897 | "Do not advertise to any peer (well-known community)\n" |
| 8898 | "Do not export to next AS (well-known community)\n" |
| 8899 | "Exact match of the communities") |
| 8900 | |
| 8901 | /* old command */ |
| 8902 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8903 | show_ipv6_mbgp_community3_exact_cmd, |
| 8904 | "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", |
| 8905 | SHOW_STR |
| 8906 | IPV6_STR |
| 8907 | MBGP_STR |
| 8908 | "Display routes matching the communities\n" |
| 8909 | "community number\n" |
| 8910 | "Do not send outside local AS (well-known community)\n" |
| 8911 | "Do not advertise to any peer (well-known community)\n" |
| 8912 | "Do not export to next AS (well-known community)\n" |
| 8913 | "community number\n" |
| 8914 | "Do not send outside local AS (well-known community)\n" |
| 8915 | "Do not advertise to any peer (well-known community)\n" |
| 8916 | "Do not export to next AS (well-known community)\n" |
| 8917 | "community number\n" |
| 8918 | "Do not send outside local AS (well-known community)\n" |
| 8919 | "Do not advertise to any peer (well-known community)\n" |
| 8920 | "Do not export to next AS (well-known community)\n" |
| 8921 | "Exact match of the communities") |
| 8922 | |
| 8923 | /* old command */ |
| 8924 | ALIAS (show_ipv6_mbgp_community_exact, |
| 8925 | show_ipv6_mbgp_community4_exact_cmd, |
| 8926 | "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", |
| 8927 | SHOW_STR |
| 8928 | IPV6_STR |
| 8929 | MBGP_STR |
| 8930 | "Display routes matching the communities\n" |
| 8931 | "community number\n" |
| 8932 | "Do not send outside local AS (well-known community)\n" |
| 8933 | "Do not advertise to any peer (well-known community)\n" |
| 8934 | "Do not export to next AS (well-known community)\n" |
| 8935 | "community number\n" |
| 8936 | "Do not send outside local AS (well-known community)\n" |
| 8937 | "Do not advertise to any peer (well-known community)\n" |
| 8938 | "Do not export to next AS (well-known community)\n" |
| 8939 | "community number\n" |
| 8940 | "Do not send outside local AS (well-known community)\n" |
| 8941 | "Do not advertise to any peer (well-known community)\n" |
| 8942 | "Do not export to next AS (well-known community)\n" |
| 8943 | "community number\n" |
| 8944 | "Do not send outside local AS (well-known community)\n" |
| 8945 | "Do not advertise to any peer (well-known community)\n" |
| 8946 | "Do not export to next AS (well-known community)\n" |
| 8947 | "Exact match of the communities") |
| 8948 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 8949 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8950 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8951 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 8952 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8953 | { |
| 8954 | struct community_list *list; |
| 8955 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8956 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8957 | if (list == NULL) |
| 8958 | { |
| 8959 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 8960 | VTY_NEWLINE); |
| 8961 | return CMD_WARNING; |
| 8962 | } |
| 8963 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8964 | return bgp_show (vty, NULL, afi, safi, |
| 8965 | (exact ? bgp_show_type_community_list_exact : |
| 8966 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8967 | } |
| 8968 | |
| 8969 | DEFUN (show_ip_bgp_community_list, |
| 8970 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8971 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8972 | SHOW_STR |
| 8973 | IP_STR |
| 8974 | BGP_STR |
| 8975 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8976 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8977 | "community-list name\n") |
| 8978 | { |
| 8979 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 8980 | } |
| 8981 | |
| 8982 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 8983 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8984 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8985 | SHOW_STR |
| 8986 | IP_STR |
| 8987 | BGP_STR |
| 8988 | "Address family\n" |
| 8989 | "Address Family modifier\n" |
| 8990 | "Address Family modifier\n" |
| 8991 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8992 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8993 | "community-list name\n") |
| 8994 | { |
| 8995 | if (strncmp (argv[0], "m", 1) == 0) |
| 8996 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 8997 | |
| 8998 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 8999 | } |
| 9000 | |
| 9001 | DEFUN (show_ip_bgp_community_list_exact, |
| 9002 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9003 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9004 | SHOW_STR |
| 9005 | IP_STR |
| 9006 | BGP_STR |
| 9007 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9008 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9009 | "community-list name\n" |
| 9010 | "Exact match of the communities\n") |
| 9011 | { |
| 9012 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 9013 | } |
| 9014 | |
| 9015 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 9016 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9017 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9018 | SHOW_STR |
| 9019 | IP_STR |
| 9020 | BGP_STR |
| 9021 | "Address family\n" |
| 9022 | "Address Family modifier\n" |
| 9023 | "Address Family modifier\n" |
| 9024 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9025 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9026 | "community-list name\n" |
| 9027 | "Exact match of the communities\n") |
| 9028 | { |
| 9029 | if (strncmp (argv[0], "m", 1) == 0) |
| 9030 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 9031 | |
| 9032 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 9033 | } |
| 9034 | |
| 9035 | #ifdef HAVE_IPV6 |
| 9036 | DEFUN (show_bgp_community_list, |
| 9037 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9038 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9039 | SHOW_STR |
| 9040 | BGP_STR |
| 9041 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9042 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9043 | "community-list name\n") |
| 9044 | { |
| 9045 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 9046 | } |
| 9047 | |
| 9048 | ALIAS (show_bgp_community_list, |
| 9049 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9050 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9051 | SHOW_STR |
| 9052 | BGP_STR |
| 9053 | "Address family\n" |
| 9054 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9055 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 9056 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9057 | |
| 9058 | /* old command */ |
| 9059 | DEFUN (show_ipv6_bgp_community_list, |
| 9060 | show_ipv6_bgp_community_list_cmd, |
| 9061 | "show ipv6 bgp community-list WORD", |
| 9062 | SHOW_STR |
| 9063 | IPV6_STR |
| 9064 | BGP_STR |
| 9065 | "Display routes matching the community-list\n" |
| 9066 | "community-list name\n") |
| 9067 | { |
| 9068 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 9069 | } |
| 9070 | |
| 9071 | /* old command */ |
| 9072 | DEFUN (show_ipv6_mbgp_community_list, |
| 9073 | show_ipv6_mbgp_community_list_cmd, |
| 9074 | "show ipv6 mbgp community-list WORD", |
| 9075 | SHOW_STR |
| 9076 | IPV6_STR |
| 9077 | MBGP_STR |
| 9078 | "Display routes matching the community-list\n" |
| 9079 | "community-list name\n") |
| 9080 | { |
| 9081 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 9082 | } |
| 9083 | |
| 9084 | DEFUN (show_bgp_community_list_exact, |
| 9085 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9086 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9087 | SHOW_STR |
| 9088 | BGP_STR |
| 9089 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9090 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9091 | "community-list name\n" |
| 9092 | "Exact match of the communities\n") |
| 9093 | { |
| 9094 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9095 | } |
| 9096 | |
| 9097 | ALIAS (show_bgp_community_list_exact, |
| 9098 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9099 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9100 | SHOW_STR |
| 9101 | BGP_STR |
| 9102 | "Address family\n" |
| 9103 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9104 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9105 | "community-list name\n" |
| 9106 | "Exact match of the communities\n") |
| 9107 | |
| 9108 | /* old command */ |
| 9109 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 9110 | show_ipv6_bgp_community_list_exact_cmd, |
| 9111 | "show ipv6 bgp community-list WORD exact-match", |
| 9112 | SHOW_STR |
| 9113 | IPV6_STR |
| 9114 | BGP_STR |
| 9115 | "Display routes matching the community-list\n" |
| 9116 | "community-list name\n" |
| 9117 | "Exact match of the communities\n") |
| 9118 | { |
| 9119 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9120 | } |
| 9121 | |
| 9122 | /* old command */ |
| 9123 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 9124 | show_ipv6_mbgp_community_list_exact_cmd, |
| 9125 | "show ipv6 mbgp community-list WORD exact-match", |
| 9126 | SHOW_STR |
| 9127 | IPV6_STR |
| 9128 | MBGP_STR |
| 9129 | "Display routes matching the community-list\n" |
| 9130 | "community-list name\n" |
| 9131 | "Exact match of the communities\n") |
| 9132 | { |
| 9133 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 9134 | } |
| 9135 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9136 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9137 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9138 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9139 | safi_t safi, enum bgp_show_type type) |
| 9140 | { |
| 9141 | int ret; |
| 9142 | struct prefix *p; |
| 9143 | |
| 9144 | p = prefix_new(); |
| 9145 | |
| 9146 | ret = str2prefix (prefix, p); |
| 9147 | if (! ret) |
| 9148 | { |
| 9149 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 9150 | return CMD_WARNING; |
| 9151 | } |
| 9152 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9153 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 9154 | prefix_free(p); |
| 9155 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9156 | } |
| 9157 | |
| 9158 | DEFUN (show_ip_bgp_prefix_longer, |
| 9159 | show_ip_bgp_prefix_longer_cmd, |
| 9160 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 9161 | SHOW_STR |
| 9162 | IP_STR |
| 9163 | BGP_STR |
| 9164 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9165 | "Display route and more specific routes\n") |
| 9166 | { |
| 9167 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9168 | bgp_show_type_prefix_longer); |
| 9169 | } |
| 9170 | |
| 9171 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 9172 | show_ip_bgp_flap_prefix_longer_cmd, |
| 9173 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 9174 | SHOW_STR |
| 9175 | IP_STR |
| 9176 | BGP_STR |
| 9177 | "Display flap statistics of routes\n" |
| 9178 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9179 | "Display route and more specific routes\n") |
| 9180 | { |
| 9181 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9182 | bgp_show_type_flap_prefix_longer); |
| 9183 | } |
| 9184 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9185 | ALIAS (show_ip_bgp_flap_prefix_longer, |
| 9186 | show_ip_bgp_damp_flap_prefix_longer_cmd, |
| 9187 | "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes", |
| 9188 | SHOW_STR |
| 9189 | IP_STR |
| 9190 | BGP_STR |
| 9191 | "Display detailed information about dampening\n" |
| 9192 | "Display flap statistics of routes\n" |
| 9193 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9194 | "Display route and more specific routes\n") |
| 9195 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9196 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 9197 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 9198 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 9199 | SHOW_STR |
| 9200 | IP_STR |
| 9201 | BGP_STR |
| 9202 | "Address family\n" |
| 9203 | "Address Family modifier\n" |
| 9204 | "Address Family modifier\n" |
| 9205 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9206 | "Display route and more specific routes\n") |
| 9207 | { |
| 9208 | if (strncmp (argv[0], "m", 1) == 0) |
| 9209 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 9210 | bgp_show_type_prefix_longer); |
| 9211 | |
| 9212 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 9213 | bgp_show_type_prefix_longer); |
| 9214 | } |
| 9215 | |
| 9216 | DEFUN (show_ip_bgp_flap_address, |
| 9217 | show_ip_bgp_flap_address_cmd, |
| 9218 | "show ip bgp flap-statistics A.B.C.D", |
| 9219 | SHOW_STR |
| 9220 | IP_STR |
| 9221 | BGP_STR |
| 9222 | "Display flap statistics of routes\n" |
| 9223 | "Network in the BGP routing table to display\n") |
| 9224 | { |
| 9225 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9226 | bgp_show_type_flap_address); |
| 9227 | } |
| 9228 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9229 | ALIAS (show_ip_bgp_flap_address, |
| 9230 | show_ip_bgp_damp_flap_address_cmd, |
| 9231 | "show ip bgp dampening flap-statistics A.B.C.D", |
| 9232 | SHOW_STR |
| 9233 | IP_STR |
| 9234 | BGP_STR |
| 9235 | "Display detailed information about dampening\n" |
| 9236 | "Display flap statistics of routes\n" |
| 9237 | "Network in the BGP routing table to display\n") |
| 9238 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9239 | DEFUN (show_ip_bgp_flap_prefix, |
| 9240 | show_ip_bgp_flap_prefix_cmd, |
| 9241 | "show ip bgp flap-statistics A.B.C.D/M", |
| 9242 | SHOW_STR |
| 9243 | IP_STR |
| 9244 | BGP_STR |
| 9245 | "Display flap statistics of routes\n" |
| 9246 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9247 | { |
| 9248 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9249 | bgp_show_type_flap_prefix); |
| 9250 | } |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9251 | |
| 9252 | ALIAS (show_ip_bgp_flap_prefix, |
| 9253 | show_ip_bgp_damp_flap_prefix_cmd, |
| 9254 | "show ip bgp dampening flap-statistics A.B.C.D/M", |
| 9255 | SHOW_STR |
| 9256 | IP_STR |
| 9257 | BGP_STR |
| 9258 | "Display detailed information about dampening\n" |
| 9259 | "Display flap statistics of routes\n" |
| 9260 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9261 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9262 | #ifdef HAVE_IPV6 |
| 9263 | DEFUN (show_bgp_prefix_longer, |
| 9264 | show_bgp_prefix_longer_cmd, |
| 9265 | "show bgp X:X::X:X/M longer-prefixes", |
| 9266 | SHOW_STR |
| 9267 | BGP_STR |
| 9268 | "IPv6 prefix <network>/<length>\n" |
| 9269 | "Display route and more specific routes\n") |
| 9270 | { |
| 9271 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9272 | bgp_show_type_prefix_longer); |
| 9273 | } |
| 9274 | |
| 9275 | ALIAS (show_bgp_prefix_longer, |
| 9276 | show_bgp_ipv6_prefix_longer_cmd, |
| 9277 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 9278 | SHOW_STR |
| 9279 | BGP_STR |
| 9280 | "Address family\n" |
| 9281 | "IPv6 prefix <network>/<length>\n" |
| 9282 | "Display route and more specific routes\n") |
| 9283 | |
| 9284 | /* old command */ |
| 9285 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 9286 | show_ipv6_bgp_prefix_longer_cmd, |
| 9287 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 9288 | SHOW_STR |
| 9289 | IPV6_STR |
| 9290 | BGP_STR |
| 9291 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9292 | "Display route and more specific routes\n") |
| 9293 | { |
| 9294 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9295 | bgp_show_type_prefix_longer); |
| 9296 | } |
| 9297 | |
| 9298 | /* old command */ |
| 9299 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 9300 | show_ipv6_mbgp_prefix_longer_cmd, |
| 9301 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 9302 | SHOW_STR |
| 9303 | IPV6_STR |
| 9304 | MBGP_STR |
| 9305 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9306 | "Display route and more specific routes\n") |
| 9307 | { |
| 9308 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 9309 | bgp_show_type_prefix_longer); |
| 9310 | } |
| 9311 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9312 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9313 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9314 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 9315 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9316 | { |
| 9317 | int ret; |
| 9318 | struct bgp *bgp; |
| 9319 | struct peer *peer; |
| 9320 | union sockunion su; |
| 9321 | |
| 9322 | /* BGP structure lookup. */ |
| 9323 | if (view_name) |
| 9324 | { |
| 9325 | bgp = bgp_lookup_by_name (view_name); |
| 9326 | if (! bgp) |
| 9327 | { |
| 9328 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9329 | return NULL; |
| 9330 | } |
| 9331 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 9332 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9333 | { |
| 9334 | bgp = bgp_get_default (); |
| 9335 | if (! bgp) |
| 9336 | { |
| 9337 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9338 | return NULL; |
| 9339 | } |
| 9340 | } |
| 9341 | |
| 9342 | /* Get peer sockunion. */ |
| 9343 | ret = str2sockunion (ip_str, &su); |
| 9344 | if (ret < 0) |
| 9345 | { |
| 9346 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 9347 | return NULL; |
| 9348 | } |
| 9349 | |
| 9350 | /* Peer structure lookup. */ |
| 9351 | peer = peer_lookup (bgp, &su); |
| 9352 | if (! peer) |
| 9353 | { |
| 9354 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 9355 | return NULL; |
| 9356 | } |
| 9357 | |
| 9358 | return peer; |
| 9359 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9360 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9361 | enum bgp_stats |
| 9362 | { |
| 9363 | BGP_STATS_MAXBITLEN = 0, |
| 9364 | BGP_STATS_RIB, |
| 9365 | BGP_STATS_PREFIXES, |
| 9366 | BGP_STATS_TOTPLEN, |
| 9367 | BGP_STATS_UNAGGREGATEABLE, |
| 9368 | BGP_STATS_MAX_AGGREGATEABLE, |
| 9369 | BGP_STATS_AGGREGATES, |
| 9370 | BGP_STATS_SPACE, |
| 9371 | BGP_STATS_ASPATH_COUNT, |
| 9372 | BGP_STATS_ASPATH_MAXHOPS, |
| 9373 | BGP_STATS_ASPATH_TOTHOPS, |
| 9374 | BGP_STATS_ASPATH_MAXSIZE, |
| 9375 | BGP_STATS_ASPATH_TOTSIZE, |
| 9376 | BGP_STATS_ASN_HIGHEST, |
| 9377 | BGP_STATS_MAX, |
| 9378 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9379 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9380 | static const char *table_stats_strs[] = |
| 9381 | { |
| 9382 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 9383 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 9384 | [BGP_STATS_RIB] = "Total Advertisements", |
| 9385 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 9386 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 9387 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 9388 | [BGP_STATS_SPACE] = "Address space advertised", |
| 9389 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 9390 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 9391 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 9392 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 9393 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 9394 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 9395 | [BGP_STATS_MAX] = NULL, |
| 9396 | }; |
| 9397 | |
| 9398 | struct bgp_table_stats |
| 9399 | { |
| 9400 | struct bgp_table *table; |
| 9401 | unsigned long long counts[BGP_STATS_MAX]; |
| 9402 | }; |
| 9403 | |
| 9404 | #if 0 |
| 9405 | #define TALLY_SIGFIG 100000 |
| 9406 | static unsigned long |
| 9407 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 9408 | { |
| 9409 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 9410 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 9411 | unsigned long ret = newtot / count; |
| 9412 | |
| 9413 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 9414 | return ret + 1; |
| 9415 | else |
| 9416 | return ret; |
| 9417 | } |
| 9418 | #endif |
| 9419 | |
| 9420 | static int |
| 9421 | bgp_table_stats_walker (struct thread *t) |
| 9422 | { |
| 9423 | struct bgp_node *rn; |
| 9424 | struct bgp_node *top; |
| 9425 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 9426 | unsigned int space = 0; |
| 9427 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 9428 | if (!(top = bgp_table_top (ts->table))) |
| 9429 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9430 | |
| 9431 | switch (top->p.family) |
| 9432 | { |
| 9433 | case AF_INET: |
| 9434 | space = IPV4_MAX_BITLEN; |
| 9435 | break; |
| 9436 | case AF_INET6: |
| 9437 | space = IPV6_MAX_BITLEN; |
| 9438 | break; |
| 9439 | } |
| 9440 | |
| 9441 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 9442 | |
| 9443 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 9444 | { |
| 9445 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9446 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9447 | unsigned int rinum = 0; |
| 9448 | |
| 9449 | if (rn == top) |
| 9450 | continue; |
| 9451 | |
| 9452 | if (!rn->info) |
| 9453 | continue; |
| 9454 | |
| 9455 | ts->counts[BGP_STATS_PREFIXES]++; |
| 9456 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 9457 | |
| 9458 | #if 0 |
| 9459 | ts->counts[BGP_STATS_AVGPLEN] |
| 9460 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 9461 | ts->counts[BGP_STATS_AVGPLEN], |
| 9462 | rn->p.prefixlen); |
| 9463 | #endif |
| 9464 | |
| 9465 | /* check if the prefix is included by any other announcements */ |
| 9466 | while (prn && !prn->info) |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9467 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9468 | |
| 9469 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 9470 | { |
| 9471 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 9472 | /* announced address space */ |
| 9473 | if (space) |
| 9474 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 9475 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9476 | else if (prn->info) |
| 9477 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 9478 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9479 | for (ri = rn->info; ri; ri = ri->next) |
| 9480 | { |
| 9481 | rinum++; |
| 9482 | ts->counts[BGP_STATS_RIB]++; |
| 9483 | |
| 9484 | if (ri->attr && |
| 9485 | (CHECK_FLAG (ri->attr->flag, |
| 9486 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 9487 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 9488 | |
| 9489 | /* as-path stats */ |
| 9490 | if (ri->attr && ri->attr->aspath) |
| 9491 | { |
| 9492 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 9493 | unsigned int size = aspath_size (ri->attr->aspath); |
| 9494 | as_t highest = aspath_highest (ri->attr->aspath); |
| 9495 | |
| 9496 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 9497 | |
| 9498 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 9499 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 9500 | |
| 9501 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 9502 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 9503 | |
| 9504 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 9505 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 9506 | #if 0 |
| 9507 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 9508 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9509 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 9510 | hops); |
| 9511 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 9512 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9513 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 9514 | size); |
| 9515 | #endif |
| 9516 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 9517 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 9518 | } |
| 9519 | } |
| 9520 | } |
| 9521 | return 0; |
| 9522 | } |
| 9523 | |
| 9524 | static int |
| 9525 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 9526 | { |
| 9527 | struct bgp_table_stats ts; |
| 9528 | unsigned int i; |
| 9529 | |
| 9530 | if (!bgp->rib[afi][safi]) |
| 9531 | { |
| 9532 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); |
| 9533 | return CMD_WARNING; |
| 9534 | } |
| 9535 | |
| 9536 | memset (&ts, 0, sizeof (ts)); |
| 9537 | ts.table = bgp->rib[afi][safi]; |
| 9538 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 9539 | |
| 9540 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 9541 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 9542 | |
| 9543 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 9544 | { |
| 9545 | if (!table_stats_strs[i]) |
| 9546 | continue; |
| 9547 | |
| 9548 | switch (i) |
| 9549 | { |
| 9550 | #if 0 |
| 9551 | case BGP_STATS_ASPATH_AVGHOPS: |
| 9552 | case BGP_STATS_ASPATH_AVGSIZE: |
| 9553 | case BGP_STATS_AVGPLEN: |
| 9554 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9555 | vty_out (vty, "%12.2f", |
| 9556 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 9557 | break; |
| 9558 | #endif |
| 9559 | case BGP_STATS_ASPATH_TOTHOPS: |
| 9560 | case BGP_STATS_ASPATH_TOTSIZE: |
| 9561 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9562 | vty_out (vty, "%12.2f", |
| 9563 | ts.counts[i] ? |
| 9564 | (float)ts.counts[i] / |
| 9565 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 9566 | : 0); |
| 9567 | break; |
| 9568 | case BGP_STATS_TOTPLEN: |
| 9569 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9570 | vty_out (vty, "%12.2f", |
| 9571 | ts.counts[i] ? |
| 9572 | (float)ts.counts[i] / |
| 9573 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 9574 | : 0); |
| 9575 | break; |
| 9576 | case BGP_STATS_SPACE: |
| 9577 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9578 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 9579 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 9580 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 9581 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9582 | vty_out (vty, "%12.2f%s", |
| 9583 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 9584 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9585 | VTY_NEWLINE); |
| 9586 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 9587 | vty_out (vty, "%12.2f%s", |
| 9588 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9589 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 9590 | VTY_NEWLINE); |
| 9591 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 9592 | break; |
| 9593 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 9594 | vty_out (vty, "%12.2f", |
| 9595 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9596 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 9597 | break; |
| 9598 | default: |
| 9599 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9600 | vty_out (vty, "%12llu", ts.counts[i]); |
| 9601 | } |
| 9602 | |
| 9603 | vty_out (vty, "%s", VTY_NEWLINE); |
| 9604 | } |
| 9605 | return CMD_SUCCESS; |
| 9606 | } |
| 9607 | |
| 9608 | static int |
| 9609 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 9610 | const char *afi_str, const char *safi_str) |
| 9611 | { |
| 9612 | struct bgp *bgp; |
| 9613 | afi_t afi; |
| 9614 | safi_t safi; |
| 9615 | |
| 9616 | if (name) |
| 9617 | bgp = bgp_lookup_by_name (name); |
| 9618 | else |
| 9619 | bgp = bgp_get_default (); |
| 9620 | |
| 9621 | if (!bgp) |
| 9622 | { |
| 9623 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); |
| 9624 | return CMD_WARNING; |
| 9625 | } |
| 9626 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 9627 | { |
| 9628 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 9629 | afi = AFI_IP; |
| 9630 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 9631 | afi = AFI_IP6; |
| 9632 | else |
| 9633 | { |
| 9634 | vty_out (vty, "%% Invalid address family %s%s", |
| 9635 | afi_str, VTY_NEWLINE); |
| 9636 | return CMD_WARNING; |
| 9637 | } |
| 9638 | if (strncmp (safi_str, "m", 1) == 0) |
| 9639 | safi = SAFI_MULTICAST; |
| 9640 | else if (strncmp (safi_str, "u", 1) == 0) |
| 9641 | safi = SAFI_UNICAST; |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 9642 | else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) |
| 9643 | safi = SAFI_MPLS_LABELED_VPN; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9644 | else |
| 9645 | { |
| 9646 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
| 9647 | safi_str, VTY_NEWLINE); |
| 9648 | return CMD_WARNING; |
| 9649 | } |
| 9650 | } |
| 9651 | else |
| 9652 | { |
| 9653 | vty_out (vty, "%% Invalid address family %s%s", |
| 9654 | afi_str, VTY_NEWLINE); |
| 9655 | return CMD_WARNING; |
| 9656 | } |
| 9657 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9658 | return bgp_table_stats (vty, bgp, afi, safi); |
| 9659 | } |
| 9660 | |
| 9661 | DEFUN (show_bgp_statistics, |
| 9662 | show_bgp_statistics_cmd, |
| 9663 | "show bgp (ipv4|ipv6) (unicast|multicast) statistics", |
| 9664 | SHOW_STR |
| 9665 | BGP_STR |
| 9666 | "Address family\n" |
| 9667 | "Address family\n" |
| 9668 | "Address Family modifier\n" |
| 9669 | "Address Family modifier\n" |
| 9670 | "BGP RIB advertisement statistics\n") |
| 9671 | { |
| 9672 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9673 | } |
| 9674 | |
| 9675 | ALIAS (show_bgp_statistics, |
| 9676 | show_bgp_statistics_vpnv4_cmd, |
| 9677 | "show bgp (ipv4) (vpnv4) statistics", |
| 9678 | SHOW_STR |
| 9679 | BGP_STR |
| 9680 | "Address family\n" |
| 9681 | "Address Family modifier\n" |
| 9682 | "BGP RIB advertisement statistics\n") |
| 9683 | |
| 9684 | DEFUN (show_bgp_statistics_view, |
| 9685 | show_bgp_statistics_view_cmd, |
| 9686 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics", |
| 9687 | SHOW_STR |
| 9688 | BGP_STR |
| 9689 | "BGP view\n" |
| 9690 | "Address family\n" |
| 9691 | "Address family\n" |
| 9692 | "Address Family modifier\n" |
| 9693 | "Address Family modifier\n" |
| 9694 | "BGP RIB advertisement statistics\n") |
| 9695 | { |
| 9696 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9697 | } |
| 9698 | |
| 9699 | ALIAS (show_bgp_statistics_view, |
| 9700 | show_bgp_statistics_view_vpnv4_cmd, |
| 9701 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
| 9702 | SHOW_STR |
| 9703 | BGP_STR |
| 9704 | "BGP view\n" |
| 9705 | "Address family\n" |
| 9706 | "Address Family modifier\n" |
| 9707 | "BGP RIB advertisement statistics\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9708 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9709 | enum bgp_pcounts |
| 9710 | { |
| 9711 | PCOUNT_ADJ_IN = 0, |
| 9712 | PCOUNT_DAMPED, |
| 9713 | PCOUNT_REMOVED, |
| 9714 | PCOUNT_HISTORY, |
| 9715 | PCOUNT_STALE, |
| 9716 | PCOUNT_VALID, |
| 9717 | PCOUNT_ALL, |
| 9718 | PCOUNT_COUNTED, |
| 9719 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 9720 | PCOUNT_MAX, |
| 9721 | }; |
| 9722 | |
| 9723 | static const char *pcount_strs[] = |
| 9724 | { |
| 9725 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 9726 | [PCOUNT_DAMPED] = "Damped", |
| 9727 | [PCOUNT_REMOVED] = "Removed", |
| 9728 | [PCOUNT_HISTORY] = "History", |
| 9729 | [PCOUNT_STALE] = "Stale", |
| 9730 | [PCOUNT_VALID] = "Valid", |
| 9731 | [PCOUNT_ALL] = "All RIB", |
| 9732 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 9733 | [PCOUNT_PFCNT] = "Useable", |
| 9734 | [PCOUNT_MAX] = NULL, |
| 9735 | }; |
| 9736 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9737 | struct peer_pcounts |
| 9738 | { |
| 9739 | unsigned int count[PCOUNT_MAX]; |
| 9740 | const struct peer *peer; |
| 9741 | const struct bgp_table *table; |
| 9742 | }; |
| 9743 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9744 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9745 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9746 | { |
| 9747 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9748 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 9749 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9750 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9751 | 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] | 9752 | { |
| 9753 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9754 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9755 | |
| 9756 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9757 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9758 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9759 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9760 | for (ri = rn->info; ri; ri = ri->next) |
| 9761 | { |
| 9762 | char buf[SU_ADDRSTRLEN]; |
| 9763 | |
| 9764 | if (ri->peer != peer) |
| 9765 | continue; |
| 9766 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9767 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9768 | |
| 9769 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9770 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9771 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9772 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9773 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9774 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9775 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9776 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9777 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9778 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9779 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9780 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9781 | |
| 9782 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 9783 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9784 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9785 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9786 | plog_warn (peer->log, |
| 9787 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 9788 | peer->host, |
| 9789 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9790 | buf, SU_ADDRSTRLEN), |
| 9791 | rn->p.prefixlen, |
| 9792 | ri->flags); |
| 9793 | } |
| 9794 | else |
| 9795 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9796 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9797 | plog_warn (peer->log, |
| 9798 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 9799 | peer->host, |
| 9800 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9801 | buf, SU_ADDRSTRLEN), |
| 9802 | rn->p.prefixlen, |
| 9803 | ri->flags); |
| 9804 | } |
| 9805 | } |
| 9806 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9807 | return 0; |
| 9808 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9809 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9810 | static int |
| 9811 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 9812 | { |
| 9813 | struct peer_pcounts pcounts = { .peer = peer }; |
| 9814 | unsigned int i; |
| 9815 | |
| 9816 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 9817 | || !peer->bgp->rib[afi][safi]) |
| 9818 | { |
| 9819 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9820 | return CMD_WARNING; |
| 9821 | } |
| 9822 | |
| 9823 | memset (&pcounts, 0, sizeof(pcounts)); |
| 9824 | pcounts.peer = peer; |
| 9825 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 9826 | |
| 9827 | /* in-place call via thread subsystem so as to record execution time |
| 9828 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 9829 | * on just vty_read()). |
| 9830 | */ |
| 9831 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 9832 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9833 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 9834 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 9835 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 9836 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 9837 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 9838 | |
| 9839 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9840 | vty_out (vty, "%20s: %-10d%s", |
| 9841 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9842 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9843 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9844 | { |
| 9845 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 9846 | peer->host, VTY_NEWLINE); |
| 9847 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 9848 | VTY_NEWLINE); |
| 9849 | } |
| 9850 | |
| 9851 | return CMD_SUCCESS; |
| 9852 | } |
| 9853 | |
| 9854 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 9855 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 9856 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9857 | SHOW_STR |
| 9858 | IP_STR |
| 9859 | BGP_STR |
| 9860 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9861 | "Neighbor to display information about\n" |
| 9862 | "Neighbor to display information about\n" |
| 9863 | "Display detailed prefix count information\n") |
| 9864 | { |
| 9865 | struct peer *peer; |
| 9866 | |
| 9867 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9868 | if (! peer) |
| 9869 | return CMD_WARNING; |
| 9870 | |
| 9871 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9872 | } |
| 9873 | |
| 9874 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 9875 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 9876 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9877 | SHOW_STR |
| 9878 | BGP_STR |
| 9879 | "Address family\n" |
| 9880 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9881 | "Neighbor to display information about\n" |
| 9882 | "Neighbor to display information about\n" |
| 9883 | "Display detailed prefix count information\n") |
| 9884 | { |
| 9885 | struct peer *peer; |
| 9886 | |
| 9887 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9888 | if (! peer) |
| 9889 | return CMD_WARNING; |
| 9890 | |
| 9891 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 9892 | } |
| 9893 | |
| 9894 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 9895 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 9896 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9897 | SHOW_STR |
| 9898 | IP_STR |
| 9899 | BGP_STR |
| 9900 | "Address family\n" |
| 9901 | "Address Family modifier\n" |
| 9902 | "Address Family modifier\n" |
| 9903 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9904 | "Neighbor to display information about\n" |
| 9905 | "Neighbor to display information about\n" |
| 9906 | "Display detailed prefix count information\n") |
| 9907 | { |
| 9908 | struct peer *peer; |
| 9909 | |
| 9910 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9911 | if (! peer) |
| 9912 | return CMD_WARNING; |
| 9913 | |
| 9914 | if (strncmp (argv[0], "m", 1) == 0) |
| 9915 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 9916 | |
| 9917 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 9918 | } |
| 9919 | |
| 9920 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 9921 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 9922 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 9923 | SHOW_STR |
| 9924 | IP_STR |
| 9925 | BGP_STR |
| 9926 | "Address family\n" |
| 9927 | "Address Family modifier\n" |
| 9928 | "Address Family modifier\n" |
| 9929 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9930 | "Neighbor to display information about\n" |
| 9931 | "Neighbor to display information about\n" |
| 9932 | "Display detailed prefix count information\n") |
| 9933 | { |
| 9934 | struct peer *peer; |
| 9935 | |
| 9936 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9937 | if (! peer) |
| 9938 | return CMD_WARNING; |
| 9939 | |
| 9940 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 9941 | } |
| 9942 | |
| 9943 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9944 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9945 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 9946 | int in) |
| 9947 | { |
| 9948 | struct bgp_table *table; |
| 9949 | struct bgp_adj_in *ain; |
| 9950 | struct bgp_adj_out *adj; |
| 9951 | unsigned long output_count; |
| 9952 | struct bgp_node *rn; |
| 9953 | int header1 = 1; |
| 9954 | struct bgp *bgp; |
| 9955 | int header2 = 1; |
| 9956 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9957 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9958 | |
| 9959 | if (! bgp) |
| 9960 | return; |
| 9961 | |
| 9962 | table = bgp->rib[afi][safi]; |
| 9963 | |
| 9964 | output_count = 0; |
| 9965 | |
| 9966 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 9967 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 9968 | { |
| 9969 | 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] | 9970 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9971 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9972 | |
| 9973 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 9974 | VTY_NEWLINE, VTY_NEWLINE); |
| 9975 | header1 = 0; |
| 9976 | } |
| 9977 | |
| 9978 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 9979 | if (in) |
| 9980 | { |
| 9981 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9982 | if (ain->peer == peer) |
| 9983 | { |
| 9984 | if (header1) |
| 9985 | { |
| 9986 | 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] | 9987 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 9988 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9989 | header1 = 0; |
| 9990 | } |
| 9991 | if (header2) |
| 9992 | { |
| 9993 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 9994 | header2 = 0; |
| 9995 | } |
| 9996 | if (ain->attr) |
| 9997 | { |
| 9998 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 9999 | output_count++; |
| 10000 | } |
| 10001 | } |
| 10002 | } |
| 10003 | else |
| 10004 | { |
| 10005 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 10006 | if (adj->peer == peer) |
| 10007 | { |
| 10008 | if (header1) |
| 10009 | { |
| 10010 | 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] | 10011 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 10012 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10013 | header1 = 0; |
| 10014 | } |
| 10015 | if (header2) |
| 10016 | { |
| 10017 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 10018 | header2 = 0; |
| 10019 | } |
| 10020 | if (adj->attr) |
| 10021 | { |
| 10022 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 10023 | output_count++; |
| 10024 | } |
| 10025 | } |
| 10026 | } |
| 10027 | |
| 10028 | if (output_count != 0) |
| 10029 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 10030 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 10031 | } |
| 10032 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10033 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10034 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 10035 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10036 | if (! peer || ! peer->afc[afi][safi]) |
| 10037 | { |
| 10038 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 10039 | return CMD_WARNING; |
| 10040 | } |
| 10041 | |
| 10042 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 10043 | { |
| 10044 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 10045 | VTY_NEWLINE); |
| 10046 | return CMD_WARNING; |
| 10047 | } |
| 10048 | |
| 10049 | show_adj_route (vty, peer, afi, safi, in); |
| 10050 | |
| 10051 | return CMD_SUCCESS; |
| 10052 | } |
| 10053 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10054 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 10055 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 10056 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10057 | SHOW_STR |
| 10058 | IP_STR |
| 10059 | BGP_STR |
| 10060 | "BGP view\n" |
| 10061 | "View name\n" |
| 10062 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10063 | "Neighbor to display information about\n" |
| 10064 | "Neighbor to display information about\n" |
| 10065 | "Display the routes advertised to a BGP neighbor\n") |
| 10066 | { |
| 10067 | struct peer *peer; |
| 10068 | |
| 10069 | if (argc == 2) |
| 10070 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10071 | else |
| 10072 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10073 | |
| 10074 | if (! peer) |
| 10075 | return CMD_WARNING; |
| 10076 | |
| 10077 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 10078 | } |
| 10079 | |
| 10080 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10081 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 10082 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10083 | SHOW_STR |
| 10084 | IP_STR |
| 10085 | BGP_STR |
| 10086 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10087 | "Neighbor to display information about\n" |
| 10088 | "Neighbor to display information about\n" |
| 10089 | "Display the routes advertised to a BGP neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10090 | |
| 10091 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 10092 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 10093 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10094 | SHOW_STR |
| 10095 | IP_STR |
| 10096 | BGP_STR |
| 10097 | "Address family\n" |
| 10098 | "Address Family modifier\n" |
| 10099 | "Address Family modifier\n" |
| 10100 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10101 | "Neighbor to display information about\n" |
| 10102 | "Neighbor to display information about\n" |
| 10103 | "Display the routes advertised to a BGP neighbor\n") |
| 10104 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10105 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10106 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10107 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10108 | if (! peer) |
| 10109 | return CMD_WARNING; |
| 10110 | |
| 10111 | if (strncmp (argv[0], "m", 1) == 0) |
| 10112 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 10113 | |
| 10114 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10115 | } |
| 10116 | |
| 10117 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10118 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 10119 | show_bgp_view_neighbor_advertised_route_cmd, |
| 10120 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10121 | SHOW_STR |
| 10122 | BGP_STR |
| 10123 | "BGP view\n" |
| 10124 | "View name\n" |
| 10125 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10126 | "Neighbor to display information about\n" |
| 10127 | "Neighbor to display information about\n" |
| 10128 | "Display the routes advertised to a BGP neighbor\n") |
| 10129 | { |
| 10130 | struct peer *peer; |
| 10131 | |
| 10132 | if (argc == 2) |
| 10133 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10134 | else |
| 10135 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10136 | |
| 10137 | if (! peer) |
| 10138 | return CMD_WARNING; |
| 10139 | |
| 10140 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 10141 | } |
| 10142 | |
| 10143 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 10144 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 10145 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10146 | SHOW_STR |
| 10147 | BGP_STR |
| 10148 | "BGP view\n" |
| 10149 | "View name\n" |
| 10150 | "Address family\n" |
| 10151 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10152 | "Neighbor to display information about\n" |
| 10153 | "Neighbor to display information about\n" |
| 10154 | "Display the routes advertised to a BGP neighbor\n") |
| 10155 | |
| 10156 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 10157 | show_bgp_view_neighbor_received_routes_cmd, |
| 10158 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10159 | SHOW_STR |
| 10160 | BGP_STR |
| 10161 | "BGP view\n" |
| 10162 | "View name\n" |
| 10163 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10164 | "Neighbor to display information about\n" |
| 10165 | "Neighbor to display information about\n" |
| 10166 | "Display the received routes from neighbor\n") |
| 10167 | { |
| 10168 | struct peer *peer; |
| 10169 | |
| 10170 | if (argc == 2) |
| 10171 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10172 | else |
| 10173 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10174 | |
| 10175 | if (! peer) |
| 10176 | return CMD_WARNING; |
| 10177 | |
| 10178 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 10179 | } |
| 10180 | |
| 10181 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 10182 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 10183 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10184 | SHOW_STR |
| 10185 | BGP_STR |
| 10186 | "BGP view\n" |
| 10187 | "View name\n" |
| 10188 | "Address family\n" |
| 10189 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10190 | "Neighbor to display information about\n" |
| 10191 | "Neighbor to display information about\n" |
| 10192 | "Display the received routes from neighbor\n") |
| 10193 | |
| 10194 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10195 | show_bgp_neighbor_advertised_route_cmd, |
| 10196 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10197 | SHOW_STR |
| 10198 | BGP_STR |
| 10199 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10200 | "Neighbor to display information about\n" |
| 10201 | "Neighbor to display information about\n" |
| 10202 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10203 | |
| 10204 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10205 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 10206 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10207 | SHOW_STR |
| 10208 | BGP_STR |
| 10209 | "Address family\n" |
| 10210 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10211 | "Neighbor to display information about\n" |
| 10212 | "Neighbor to display information about\n" |
| 10213 | "Display the routes advertised to a BGP neighbor\n") |
| 10214 | |
| 10215 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10216 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10217 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 10218 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10219 | SHOW_STR |
| 10220 | IPV6_STR |
| 10221 | BGP_STR |
| 10222 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10223 | "Neighbor to display information about\n" |
| 10224 | "Neighbor to display information about\n" |
| 10225 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10226 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10227 | /* old command */ |
| 10228 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 10229 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 10230 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10231 | SHOW_STR |
| 10232 | IPV6_STR |
| 10233 | MBGP_STR |
| 10234 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10235 | "Neighbor to display information about\n" |
| 10236 | "Neighbor to display information about\n" |
| 10237 | "Display the routes advertised to a BGP neighbor\n") |
| 10238 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10239 | struct peer *peer; |
| 10240 | |
| 10241 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10242 | if (! peer) |
| 10243 | return CMD_WARNING; |
| 10244 | |
| 10245 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10246 | } |
| 10247 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 10248 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10249 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 10250 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 10251 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10252 | SHOW_STR |
| 10253 | IP_STR |
| 10254 | BGP_STR |
| 10255 | "BGP view\n" |
| 10256 | "View name\n" |
| 10257 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10258 | "Neighbor to display information about\n" |
| 10259 | "Neighbor to display information about\n" |
| 10260 | "Display the received routes from neighbor\n") |
| 10261 | { |
| 10262 | struct peer *peer; |
| 10263 | |
| 10264 | if (argc == 2) |
| 10265 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10266 | else |
| 10267 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10268 | |
| 10269 | if (! peer) |
| 10270 | return CMD_WARNING; |
| 10271 | |
| 10272 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 10273 | } |
| 10274 | |
| 10275 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10276 | show_ip_bgp_neighbor_received_routes_cmd, |
| 10277 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10278 | SHOW_STR |
| 10279 | IP_STR |
| 10280 | BGP_STR |
| 10281 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10282 | "Neighbor to display information about\n" |
| 10283 | "Neighbor to display information about\n" |
| 10284 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10285 | |
| 10286 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 10287 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 10288 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10289 | SHOW_STR |
| 10290 | IP_STR |
| 10291 | BGP_STR |
| 10292 | "Address family\n" |
| 10293 | "Address Family modifier\n" |
| 10294 | "Address Family modifier\n" |
| 10295 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10296 | "Neighbor to display information about\n" |
| 10297 | "Neighbor to display information about\n" |
| 10298 | "Display the received routes from neighbor\n") |
| 10299 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10300 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10301 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10302 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10303 | if (! peer) |
| 10304 | return CMD_WARNING; |
| 10305 | |
| 10306 | if (strncmp (argv[0], "m", 1) == 0) |
| 10307 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 10308 | |
| 10309 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10310 | } |
| 10311 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10312 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 10313 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10314 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10315 | SHOW_STR |
| 10316 | BGP_STR |
| 10317 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10318 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10319 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10320 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10321 | "Address family modifier\n" |
| 10322 | "Address family modifier\n" |
| 10323 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10324 | "Neighbor to display information about\n" |
| 10325 | "Neighbor to display information about\n" |
| 10326 | "Display the advertised routes to neighbor\n" |
| 10327 | "Display the received routes from neighbor\n") |
| 10328 | { |
| 10329 | int afi; |
| 10330 | int safi; |
| 10331 | int in; |
| 10332 | struct peer *peer; |
| 10333 | |
David Lamparter | 94bad67 | 2015-03-03 08:52:22 +0100 | [diff] [blame] | 10334 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10335 | |
| 10336 | if (! peer) |
| 10337 | return CMD_WARNING; |
| 10338 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10339 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10340 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10341 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10342 | |
| 10343 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 10344 | } |
| 10345 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10346 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 10347 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 10348 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10349 | SHOW_STR |
| 10350 | IP_STR |
| 10351 | BGP_STR |
| 10352 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10353 | "Neighbor to display information about\n" |
| 10354 | "Neighbor to display information about\n" |
| 10355 | "Display information received from a BGP neighbor\n" |
| 10356 | "Display the prefixlist filter\n") |
| 10357 | { |
| 10358 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10359 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10360 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10361 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10362 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10363 | ret = str2sockunion (argv[0], &su); |
| 10364 | if (ret < 0) |
| 10365 | { |
| 10366 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10367 | return CMD_WARNING; |
| 10368 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10369 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10370 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10371 | if (! peer) |
| 10372 | return CMD_WARNING; |
| 10373 | |
| 10374 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10375 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10376 | if (count) |
| 10377 | { |
| 10378 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10379 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10380 | } |
| 10381 | |
| 10382 | return CMD_SUCCESS; |
| 10383 | } |
| 10384 | |
| 10385 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 10386 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 10387 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10388 | SHOW_STR |
| 10389 | IP_STR |
| 10390 | BGP_STR |
| 10391 | "Address family\n" |
| 10392 | "Address Family modifier\n" |
| 10393 | "Address Family modifier\n" |
| 10394 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10395 | "Neighbor to display information about\n" |
| 10396 | "Neighbor to display information about\n" |
| 10397 | "Display information received from a BGP neighbor\n" |
| 10398 | "Display the prefixlist filter\n") |
| 10399 | { |
| 10400 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10401 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10402 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10403 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10404 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10405 | ret = str2sockunion (argv[1], &su); |
| 10406 | if (ret < 0) |
| 10407 | { |
| 10408 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10409 | return CMD_WARNING; |
| 10410 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10411 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10412 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10413 | if (! peer) |
| 10414 | return CMD_WARNING; |
| 10415 | |
| 10416 | if (strncmp (argv[0], "m", 1) == 0) |
| 10417 | { |
| 10418 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 10419 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10420 | if (count) |
| 10421 | { |
| 10422 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 10423 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10424 | } |
| 10425 | } |
| 10426 | else |
| 10427 | { |
| 10428 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10429 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10430 | if (count) |
| 10431 | { |
| 10432 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10433 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10434 | } |
| 10435 | } |
| 10436 | |
| 10437 | return CMD_SUCCESS; |
| 10438 | } |
| 10439 | |
| 10440 | |
| 10441 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10442 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10443 | show_bgp_neighbor_received_routes_cmd, |
| 10444 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10445 | SHOW_STR |
| 10446 | BGP_STR |
| 10447 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10448 | "Neighbor to display information about\n" |
| 10449 | "Neighbor to display information about\n" |
| 10450 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10451 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10452 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10453 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 10454 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10455 | SHOW_STR |
| 10456 | BGP_STR |
| 10457 | "Address family\n" |
| 10458 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10459 | "Neighbor to display information about\n" |
| 10460 | "Neighbor to display information about\n" |
| 10461 | "Display the received routes from neighbor\n") |
| 10462 | |
| 10463 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 10464 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 10465 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10466 | SHOW_STR |
| 10467 | BGP_STR |
| 10468 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10469 | "Neighbor to display information about\n" |
| 10470 | "Neighbor to display information about\n" |
| 10471 | "Display information received from a BGP neighbor\n" |
| 10472 | "Display the prefixlist filter\n") |
| 10473 | { |
| 10474 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10475 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10476 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10477 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10478 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10479 | ret = str2sockunion (argv[0], &su); |
| 10480 | if (ret < 0) |
| 10481 | { |
| 10482 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10483 | return CMD_WARNING; |
| 10484 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10485 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10486 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10487 | if (! peer) |
| 10488 | return CMD_WARNING; |
| 10489 | |
| 10490 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10491 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10492 | if (count) |
| 10493 | { |
| 10494 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10495 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10496 | } |
| 10497 | |
| 10498 | return CMD_SUCCESS; |
| 10499 | } |
| 10500 | |
| 10501 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 10502 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 10503 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10504 | SHOW_STR |
| 10505 | BGP_STR |
| 10506 | "Address family\n" |
| 10507 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10508 | "Neighbor to display information about\n" |
| 10509 | "Neighbor to display information about\n" |
| 10510 | "Display information received from a BGP neighbor\n" |
| 10511 | "Display the prefixlist filter\n") |
| 10512 | |
| 10513 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10514 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10515 | ipv6_bgp_neighbor_received_routes_cmd, |
| 10516 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10517 | SHOW_STR |
| 10518 | IPV6_STR |
| 10519 | BGP_STR |
| 10520 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10521 | "Neighbor to display information about\n" |
| 10522 | "Neighbor to display information about\n" |
| 10523 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10524 | |
| 10525 | /* old command */ |
| 10526 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 10527 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 10528 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10529 | SHOW_STR |
| 10530 | IPV6_STR |
| 10531 | MBGP_STR |
| 10532 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10533 | "Neighbor to display information about\n" |
| 10534 | "Neighbor to display information about\n" |
| 10535 | "Display the received routes from neighbor\n") |
| 10536 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10537 | struct peer *peer; |
| 10538 | |
| 10539 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10540 | if (! peer) |
| 10541 | return CMD_WARNING; |
| 10542 | |
| 10543 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10544 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10545 | |
| 10546 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 10547 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 10548 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10549 | SHOW_STR |
| 10550 | BGP_STR |
| 10551 | "BGP view\n" |
| 10552 | "View name\n" |
| 10553 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10554 | "Neighbor to display information about\n" |
| 10555 | "Neighbor to display information about\n" |
| 10556 | "Display information received from a BGP neighbor\n" |
| 10557 | "Display the prefixlist filter\n") |
| 10558 | { |
| 10559 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10560 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10561 | struct peer *peer; |
| 10562 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10563 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10564 | |
| 10565 | /* BGP structure lookup. */ |
| 10566 | bgp = bgp_lookup_by_name (argv[0]); |
| 10567 | if (bgp == NULL) |
| 10568 | { |
| 10569 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10570 | return CMD_WARNING; |
| 10571 | } |
| 10572 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10573 | ret = str2sockunion (argv[1], &su); |
| 10574 | if (ret < 0) |
| 10575 | { |
| 10576 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10577 | return CMD_WARNING; |
| 10578 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10579 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10580 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10581 | if (! peer) |
| 10582 | return CMD_WARNING; |
| 10583 | |
| 10584 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10585 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10586 | if (count) |
| 10587 | { |
| 10588 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10589 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10590 | } |
| 10591 | |
| 10592 | return CMD_SUCCESS; |
| 10593 | } |
| 10594 | |
| 10595 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 10596 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 10597 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10598 | SHOW_STR |
| 10599 | BGP_STR |
| 10600 | "BGP view\n" |
| 10601 | "View name\n" |
| 10602 | "Address family\n" |
| 10603 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10604 | "Neighbor to display information about\n" |
| 10605 | "Neighbor to display information about\n" |
| 10606 | "Display information received from a BGP neighbor\n" |
| 10607 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10608 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 10609 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10610 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10611 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10612 | safi_t safi, enum bgp_show_type type) |
| 10613 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10614 | if (! peer || ! peer->afc[afi][safi]) |
| 10615 | { |
| 10616 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10617 | return CMD_WARNING; |
| 10618 | } |
| 10619 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10620 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10621 | } |
| 10622 | |
| 10623 | DEFUN (show_ip_bgp_neighbor_routes, |
| 10624 | show_ip_bgp_neighbor_routes_cmd, |
| 10625 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10626 | SHOW_STR |
| 10627 | IP_STR |
| 10628 | BGP_STR |
| 10629 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10630 | "Neighbor to display information about\n" |
| 10631 | "Neighbor to display information about\n" |
| 10632 | "Display routes learned from neighbor\n") |
| 10633 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10634 | struct peer *peer; |
| 10635 | |
| 10636 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10637 | if (! peer) |
| 10638 | return CMD_WARNING; |
| 10639 | |
| 10640 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10641 | bgp_show_type_neighbor); |
| 10642 | } |
| 10643 | |
| 10644 | DEFUN (show_ip_bgp_neighbor_flap, |
| 10645 | show_ip_bgp_neighbor_flap_cmd, |
| 10646 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10647 | SHOW_STR |
| 10648 | IP_STR |
| 10649 | BGP_STR |
| 10650 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10651 | "Neighbor to display information about\n" |
| 10652 | "Neighbor to display information about\n" |
| 10653 | "Display flap statistics of the routes learned from neighbor\n") |
| 10654 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10655 | struct peer *peer; |
| 10656 | |
| 10657 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10658 | if (! peer) |
| 10659 | return CMD_WARNING; |
| 10660 | |
| 10661 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10662 | bgp_show_type_flap_neighbor); |
| 10663 | } |
| 10664 | |
| 10665 | DEFUN (show_ip_bgp_neighbor_damp, |
| 10666 | show_ip_bgp_neighbor_damp_cmd, |
| 10667 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10668 | SHOW_STR |
| 10669 | IP_STR |
| 10670 | BGP_STR |
| 10671 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10672 | "Neighbor to display information about\n" |
| 10673 | "Neighbor to display information about\n" |
| 10674 | "Display the dampened routes received from neighbor\n") |
| 10675 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10676 | struct peer *peer; |
| 10677 | |
| 10678 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10679 | if (! peer) |
| 10680 | return CMD_WARNING; |
| 10681 | |
| 10682 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10683 | bgp_show_type_damp_neighbor); |
| 10684 | } |
| 10685 | |
| 10686 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 10687 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 10688 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 10689 | SHOW_STR |
| 10690 | IP_STR |
| 10691 | BGP_STR |
| 10692 | "Address family\n" |
| 10693 | "Address Family modifier\n" |
| 10694 | "Address Family modifier\n" |
| 10695 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10696 | "Neighbor to display information about\n" |
| 10697 | "Neighbor to display information about\n" |
| 10698 | "Display routes learned from neighbor\n") |
| 10699 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10700 | struct peer *peer; |
| 10701 | |
| 10702 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10703 | if (! peer) |
| 10704 | return CMD_WARNING; |
| 10705 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10706 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10707 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10708 | bgp_show_type_neighbor); |
| 10709 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10710 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10711 | bgp_show_type_neighbor); |
| 10712 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10713 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10714 | DEFUN (show_ip_bgp_view_rsclient, |
| 10715 | show_ip_bgp_view_rsclient_cmd, |
| 10716 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 10717 | SHOW_STR |
| 10718 | IP_STR |
| 10719 | BGP_STR |
| 10720 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10721 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10722 | "Information about Route Server Client\n" |
| 10723 | NEIGHBOR_ADDR_STR) |
| 10724 | { |
| 10725 | struct bgp_table *table; |
| 10726 | struct peer *peer; |
| 10727 | |
| 10728 | if (argc == 2) |
| 10729 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10730 | else |
| 10731 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10732 | |
| 10733 | if (! peer) |
| 10734 | return CMD_WARNING; |
| 10735 | |
| 10736 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10737 | { |
| 10738 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10739 | VTY_NEWLINE); |
| 10740 | return CMD_WARNING; |
| 10741 | } |
| 10742 | |
| 10743 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10744 | PEER_FLAG_RSERVER_CLIENT)) |
| 10745 | { |
| 10746 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10747 | VTY_NEWLINE); |
| 10748 | return CMD_WARNING; |
| 10749 | } |
| 10750 | |
| 10751 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 10752 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10753 | 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] | 10754 | } |
| 10755 | |
| 10756 | ALIAS (show_ip_bgp_view_rsclient, |
| 10757 | show_ip_bgp_rsclient_cmd, |
| 10758 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 10759 | SHOW_STR |
| 10760 | IP_STR |
| 10761 | BGP_STR |
| 10762 | "Information about Route Server Client\n" |
| 10763 | NEIGHBOR_ADDR_STR) |
| 10764 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10765 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 10766 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 10767 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10768 | SHOW_STR |
| 10769 | BGP_STR |
| 10770 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10771 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10772 | "Address family\n" |
| 10773 | "Address Family modifier\n" |
| 10774 | "Address Family modifier\n" |
| 10775 | "Information about Route Server Client\n" |
| 10776 | NEIGHBOR_ADDR_STR) |
| 10777 | { |
| 10778 | struct bgp_table *table; |
| 10779 | struct peer *peer; |
| 10780 | safi_t safi; |
| 10781 | |
| 10782 | if (argc == 3) { |
| 10783 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10784 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10785 | } else { |
| 10786 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10787 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10788 | } |
| 10789 | |
| 10790 | if (! peer) |
| 10791 | return CMD_WARNING; |
| 10792 | |
| 10793 | if (! peer->afc[AFI_IP][safi]) |
| 10794 | { |
| 10795 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10796 | VTY_NEWLINE); |
| 10797 | return CMD_WARNING; |
| 10798 | } |
| 10799 | |
| 10800 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10801 | PEER_FLAG_RSERVER_CLIENT)) |
| 10802 | { |
| 10803 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10804 | VTY_NEWLINE); |
| 10805 | return CMD_WARNING; |
| 10806 | } |
| 10807 | |
| 10808 | table = peer->rib[AFI_IP][safi]; |
| 10809 | |
| 10810 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 10811 | } |
| 10812 | |
| 10813 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 10814 | show_bgp_ipv4_safi_rsclient_cmd, |
| 10815 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10816 | SHOW_STR |
| 10817 | BGP_STR |
| 10818 | "Address family\n" |
| 10819 | "Address Family modifier\n" |
| 10820 | "Address Family modifier\n" |
| 10821 | "Information about Route Server Client\n" |
| 10822 | NEIGHBOR_ADDR_STR) |
| 10823 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10824 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 10825 | show_ip_bgp_view_rsclient_route_cmd, |
Michael Lambert | a8bf6f5 | 2008-09-24 17:23:11 +0100 | [diff] [blame] | 10826 | "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] | 10827 | SHOW_STR |
| 10828 | IP_STR |
| 10829 | BGP_STR |
| 10830 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10831 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10832 | "Information about Route Server Client\n" |
| 10833 | NEIGHBOR_ADDR_STR |
| 10834 | "Network in the BGP routing table to display\n") |
| 10835 | { |
| 10836 | struct bgp *bgp; |
| 10837 | struct peer *peer; |
| 10838 | |
| 10839 | /* BGP structure lookup. */ |
| 10840 | if (argc == 3) |
| 10841 | { |
| 10842 | bgp = bgp_lookup_by_name (argv[0]); |
| 10843 | if (bgp == NULL) |
| 10844 | { |
| 10845 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10846 | return CMD_WARNING; |
| 10847 | } |
| 10848 | } |
| 10849 | else |
| 10850 | { |
| 10851 | bgp = bgp_get_default (); |
| 10852 | if (bgp == NULL) |
| 10853 | { |
| 10854 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10855 | return CMD_WARNING; |
| 10856 | } |
| 10857 | } |
| 10858 | |
| 10859 | if (argc == 3) |
| 10860 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10861 | else |
| 10862 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10863 | |
| 10864 | if (! peer) |
| 10865 | return CMD_WARNING; |
| 10866 | |
| 10867 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10868 | { |
| 10869 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10870 | VTY_NEWLINE); |
| 10871 | return CMD_WARNING; |
| 10872 | } |
| 10873 | |
| 10874 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10875 | PEER_FLAG_RSERVER_CLIENT)) |
| 10876 | { |
| 10877 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10878 | VTY_NEWLINE); |
| 10879 | return CMD_WARNING; |
| 10880 | } |
| 10881 | |
| 10882 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 10883 | (argc == 3) ? argv[2] : argv[1], |
| 10884 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 10885 | } |
| 10886 | |
| 10887 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 10888 | show_ip_bgp_rsclient_route_cmd, |
| 10889 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10890 | SHOW_STR |
| 10891 | IP_STR |
| 10892 | BGP_STR |
| 10893 | "Information about Route Server Client\n" |
| 10894 | NEIGHBOR_ADDR_STR |
| 10895 | "Network in the BGP routing table to display\n") |
| 10896 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10897 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 10898 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 10899 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10900 | SHOW_STR |
| 10901 | BGP_STR |
| 10902 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10903 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10904 | "Address family\n" |
| 10905 | "Address Family modifier\n" |
| 10906 | "Address Family modifier\n" |
| 10907 | "Information about Route Server Client\n" |
| 10908 | NEIGHBOR_ADDR_STR |
| 10909 | "Network in the BGP routing table to display\n") |
| 10910 | { |
| 10911 | struct bgp *bgp; |
| 10912 | struct peer *peer; |
| 10913 | safi_t safi; |
| 10914 | |
| 10915 | /* BGP structure lookup. */ |
| 10916 | if (argc == 4) |
| 10917 | { |
| 10918 | bgp = bgp_lookup_by_name (argv[0]); |
| 10919 | if (bgp == NULL) |
| 10920 | { |
| 10921 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10922 | return CMD_WARNING; |
| 10923 | } |
| 10924 | } |
| 10925 | else |
| 10926 | { |
| 10927 | bgp = bgp_get_default (); |
| 10928 | if (bgp == NULL) |
| 10929 | { |
| 10930 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 10931 | return CMD_WARNING; |
| 10932 | } |
| 10933 | } |
| 10934 | |
| 10935 | if (argc == 4) { |
| 10936 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10937 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10938 | } else { |
| 10939 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10940 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10941 | } |
| 10942 | |
| 10943 | if (! peer) |
| 10944 | return CMD_WARNING; |
| 10945 | |
| 10946 | if (! peer->afc[AFI_IP][safi]) |
| 10947 | { |
| 10948 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10949 | VTY_NEWLINE); |
| 10950 | return CMD_WARNING; |
| 10951 | } |
| 10952 | |
| 10953 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10954 | PEER_FLAG_RSERVER_CLIENT)) |
| 10955 | { |
| 10956 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10957 | VTY_NEWLINE); |
| 10958 | return CMD_WARNING; |
| 10959 | } |
| 10960 | |
| 10961 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 10962 | (argc == 4) ? argv[3] : argv[2], |
| 10963 | AFI_IP, safi, NULL, 0); |
| 10964 | } |
| 10965 | |
| 10966 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 10967 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 10968 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 10969 | SHOW_STR |
| 10970 | BGP_STR |
| 10971 | "Address family\n" |
| 10972 | "Address Family modifier\n" |
| 10973 | "Address Family modifier\n" |
| 10974 | "Information about Route Server Client\n" |
| 10975 | NEIGHBOR_ADDR_STR |
| 10976 | "Network in the BGP routing table to display\n") |
| 10977 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10978 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 10979 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 10980 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 10981 | SHOW_STR |
| 10982 | IP_STR |
| 10983 | BGP_STR |
| 10984 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10985 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10986 | "Information about Route Server Client\n" |
| 10987 | NEIGHBOR_ADDR_STR |
| 10988 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10989 | { |
| 10990 | struct bgp *bgp; |
| 10991 | struct peer *peer; |
| 10992 | |
| 10993 | /* BGP structure lookup. */ |
| 10994 | if (argc == 3) |
| 10995 | { |
| 10996 | bgp = bgp_lookup_by_name (argv[0]); |
| 10997 | if (bgp == NULL) |
| 10998 | { |
| 10999 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11000 | return CMD_WARNING; |
| 11001 | } |
| 11002 | } |
| 11003 | else |
| 11004 | { |
| 11005 | bgp = bgp_get_default (); |
| 11006 | if (bgp == NULL) |
| 11007 | { |
| 11008 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11009 | return CMD_WARNING; |
| 11010 | } |
| 11011 | } |
| 11012 | |
| 11013 | if (argc == 3) |
| 11014 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11015 | else |
| 11016 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11017 | |
| 11018 | if (! peer) |
| 11019 | return CMD_WARNING; |
| 11020 | |
| 11021 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 11022 | { |
| 11023 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11024 | VTY_NEWLINE); |
| 11025 | return CMD_WARNING; |
| 11026 | } |
| 11027 | |
| 11028 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 11029 | PEER_FLAG_RSERVER_CLIENT)) |
| 11030 | { |
| 11031 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11032 | VTY_NEWLINE); |
| 11033 | return CMD_WARNING; |
| 11034 | } |
| 11035 | |
| 11036 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 11037 | (argc == 3) ? argv[2] : argv[1], |
| 11038 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 11039 | } |
| 11040 | |
| 11041 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 11042 | show_ip_bgp_rsclient_prefix_cmd, |
| 11043 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11044 | SHOW_STR |
| 11045 | IP_STR |
| 11046 | BGP_STR |
| 11047 | "Information about Route Server Client\n" |
| 11048 | NEIGHBOR_ADDR_STR |
| 11049 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11050 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11051 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 11052 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 11053 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11054 | SHOW_STR |
| 11055 | BGP_STR |
| 11056 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11057 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11058 | "Address family\n" |
| 11059 | "Address Family modifier\n" |
| 11060 | "Address Family modifier\n" |
| 11061 | "Information about Route Server Client\n" |
| 11062 | NEIGHBOR_ADDR_STR |
| 11063 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11064 | { |
| 11065 | struct bgp *bgp; |
| 11066 | struct peer *peer; |
| 11067 | safi_t safi; |
| 11068 | |
| 11069 | /* BGP structure lookup. */ |
| 11070 | if (argc == 4) |
| 11071 | { |
| 11072 | bgp = bgp_lookup_by_name (argv[0]); |
| 11073 | if (bgp == NULL) |
| 11074 | { |
| 11075 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11076 | return CMD_WARNING; |
| 11077 | } |
| 11078 | } |
| 11079 | else |
| 11080 | { |
| 11081 | bgp = bgp_get_default (); |
| 11082 | if (bgp == NULL) |
| 11083 | { |
| 11084 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11085 | return CMD_WARNING; |
| 11086 | } |
| 11087 | } |
| 11088 | |
| 11089 | if (argc == 4) { |
| 11090 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11091 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11092 | } else { |
| 11093 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11094 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11095 | } |
| 11096 | |
| 11097 | if (! peer) |
| 11098 | return CMD_WARNING; |
| 11099 | |
| 11100 | if (! peer->afc[AFI_IP][safi]) |
| 11101 | { |
| 11102 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11103 | VTY_NEWLINE); |
| 11104 | return CMD_WARNING; |
| 11105 | } |
| 11106 | |
| 11107 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 11108 | PEER_FLAG_RSERVER_CLIENT)) |
| 11109 | { |
| 11110 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11111 | VTY_NEWLINE); |
| 11112 | return CMD_WARNING; |
| 11113 | } |
| 11114 | |
| 11115 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 11116 | (argc == 4) ? argv[3] : argv[2], |
| 11117 | AFI_IP, safi, NULL, 1); |
| 11118 | } |
| 11119 | |
| 11120 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 11121 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 11122 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11123 | SHOW_STR |
| 11124 | BGP_STR |
| 11125 | "Address family\n" |
| 11126 | "Address Family modifier\n" |
| 11127 | "Address Family modifier\n" |
| 11128 | "Information about Route Server Client\n" |
| 11129 | NEIGHBOR_ADDR_STR |
| 11130 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11131 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11132 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11133 | DEFUN (show_bgp_view_neighbor_routes, |
| 11134 | show_bgp_view_neighbor_routes_cmd, |
| 11135 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 11136 | SHOW_STR |
| 11137 | BGP_STR |
| 11138 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11139 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11140 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11141 | "Neighbor to display information about\n" |
| 11142 | "Neighbor to display information about\n" |
| 11143 | "Display routes learned from neighbor\n") |
| 11144 | { |
| 11145 | struct peer *peer; |
| 11146 | |
| 11147 | if (argc == 2) |
| 11148 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11149 | else |
| 11150 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11151 | |
| 11152 | if (! peer) |
| 11153 | return CMD_WARNING; |
| 11154 | |
| 11155 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11156 | bgp_show_type_neighbor); |
| 11157 | } |
| 11158 | |
| 11159 | ALIAS (show_bgp_view_neighbor_routes, |
| 11160 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 11161 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11162 | SHOW_STR |
| 11163 | BGP_STR |
| 11164 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11165 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11166 | "Address family\n" |
| 11167 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11168 | "Neighbor to display information about\n" |
| 11169 | "Neighbor to display information about\n" |
| 11170 | "Display routes learned from neighbor\n") |
| 11171 | |
| 11172 | DEFUN (show_bgp_view_neighbor_damp, |
| 11173 | show_bgp_view_neighbor_damp_cmd, |
| 11174 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11175 | SHOW_STR |
| 11176 | BGP_STR |
| 11177 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11178 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11179 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11180 | "Neighbor to display information about\n" |
| 11181 | "Neighbor to display information about\n" |
| 11182 | "Display the dampened routes received from neighbor\n") |
| 11183 | { |
| 11184 | struct peer *peer; |
| 11185 | |
| 11186 | if (argc == 2) |
| 11187 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11188 | else |
| 11189 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11190 | |
| 11191 | if (! peer) |
| 11192 | return CMD_WARNING; |
| 11193 | |
| 11194 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11195 | bgp_show_type_damp_neighbor); |
| 11196 | } |
| 11197 | |
| 11198 | ALIAS (show_bgp_view_neighbor_damp, |
| 11199 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 11200 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11201 | SHOW_STR |
| 11202 | BGP_STR |
| 11203 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11204 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11205 | "Address family\n" |
| 11206 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11207 | "Neighbor to display information about\n" |
| 11208 | "Neighbor to display information about\n" |
| 11209 | "Display the dampened routes received from neighbor\n") |
| 11210 | |
| 11211 | DEFUN (show_bgp_view_neighbor_flap, |
| 11212 | show_bgp_view_neighbor_flap_cmd, |
| 11213 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11214 | SHOW_STR |
| 11215 | BGP_STR |
| 11216 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11217 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11218 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11219 | "Neighbor to display information about\n" |
| 11220 | "Neighbor to display information about\n" |
| 11221 | "Display flap statistics of the routes learned from neighbor\n") |
| 11222 | { |
| 11223 | struct peer *peer; |
| 11224 | |
| 11225 | if (argc == 2) |
| 11226 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11227 | else |
| 11228 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11229 | |
| 11230 | if (! peer) |
| 11231 | return CMD_WARNING; |
| 11232 | |
| 11233 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11234 | bgp_show_type_flap_neighbor); |
| 11235 | } |
| 11236 | |
| 11237 | ALIAS (show_bgp_view_neighbor_flap, |
| 11238 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 11239 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11240 | SHOW_STR |
| 11241 | BGP_STR |
| 11242 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11243 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11244 | "Address family\n" |
| 11245 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11246 | "Neighbor to display information about\n" |
| 11247 | "Neighbor to display information about\n" |
| 11248 | "Display flap statistics of the routes learned from neighbor\n") |
| 11249 | |
| 11250 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11251 | show_bgp_neighbor_routes_cmd, |
| 11252 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11253 | SHOW_STR |
| 11254 | BGP_STR |
| 11255 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11256 | "Neighbor to display information about\n" |
| 11257 | "Neighbor to display information about\n" |
| 11258 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11259 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11260 | |
| 11261 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11262 | show_bgp_ipv6_neighbor_routes_cmd, |
| 11263 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11264 | SHOW_STR |
| 11265 | BGP_STR |
| 11266 | "Address family\n" |
| 11267 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11268 | "Neighbor to display information about\n" |
| 11269 | "Neighbor to display information about\n" |
| 11270 | "Display routes learned from neighbor\n") |
| 11271 | |
| 11272 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11273 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11274 | ipv6_bgp_neighbor_routes_cmd, |
| 11275 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11276 | SHOW_STR |
| 11277 | IPV6_STR |
| 11278 | BGP_STR |
| 11279 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11280 | "Neighbor to display information about\n" |
| 11281 | "Neighbor to display information about\n" |
| 11282 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11283 | |
| 11284 | /* old command */ |
| 11285 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 11286 | ipv6_mbgp_neighbor_routes_cmd, |
| 11287 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11288 | SHOW_STR |
| 11289 | IPV6_STR |
| 11290 | MBGP_STR |
| 11291 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11292 | "Neighbor to display information about\n" |
| 11293 | "Neighbor to display information about\n" |
| 11294 | "Display routes learned from neighbor\n") |
| 11295 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11296 | struct peer *peer; |
| 11297 | |
| 11298 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11299 | if (! peer) |
| 11300 | return CMD_WARNING; |
| 11301 | |
| 11302 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11303 | bgp_show_type_neighbor); |
| 11304 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11305 | |
| 11306 | ALIAS (show_bgp_view_neighbor_flap, |
| 11307 | show_bgp_neighbor_flap_cmd, |
| 11308 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11309 | SHOW_STR |
| 11310 | BGP_STR |
| 11311 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11312 | "Neighbor to display information about\n" |
| 11313 | "Neighbor to display information about\n" |
| 11314 | "Display flap statistics of the routes learned from neighbor\n") |
| 11315 | |
| 11316 | ALIAS (show_bgp_view_neighbor_flap, |
| 11317 | show_bgp_ipv6_neighbor_flap_cmd, |
| 11318 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11319 | SHOW_STR |
| 11320 | BGP_STR |
| 11321 | "Address family\n" |
| 11322 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11323 | "Neighbor to display information about\n" |
| 11324 | "Neighbor to display information about\n" |
| 11325 | "Display flap statistics of the routes learned from neighbor\n") |
| 11326 | |
| 11327 | ALIAS (show_bgp_view_neighbor_damp, |
| 11328 | show_bgp_neighbor_damp_cmd, |
| 11329 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11330 | SHOW_STR |
| 11331 | BGP_STR |
| 11332 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11333 | "Neighbor to display information about\n" |
| 11334 | "Neighbor to display information about\n" |
| 11335 | "Display the dampened routes received from neighbor\n") |
| 11336 | |
| 11337 | ALIAS (show_bgp_view_neighbor_damp, |
| 11338 | show_bgp_ipv6_neighbor_damp_cmd, |
| 11339 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11340 | SHOW_STR |
| 11341 | BGP_STR |
| 11342 | "Address family\n" |
| 11343 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11344 | "Neighbor to display information about\n" |
| 11345 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 11346 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11347 | |
| 11348 | DEFUN (show_bgp_view_rsclient, |
| 11349 | show_bgp_view_rsclient_cmd, |
| 11350 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 11351 | SHOW_STR |
| 11352 | BGP_STR |
| 11353 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11354 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11355 | "Information about Route Server Client\n" |
| 11356 | NEIGHBOR_ADDR_STR) |
| 11357 | { |
| 11358 | struct bgp_table *table; |
| 11359 | struct peer *peer; |
| 11360 | |
| 11361 | if (argc == 2) |
| 11362 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11363 | else |
| 11364 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11365 | |
| 11366 | if (! peer) |
| 11367 | return CMD_WARNING; |
| 11368 | |
| 11369 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11370 | { |
| 11371 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11372 | VTY_NEWLINE); |
| 11373 | return CMD_WARNING; |
| 11374 | } |
| 11375 | |
| 11376 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11377 | PEER_FLAG_RSERVER_CLIENT)) |
| 11378 | { |
| 11379 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11380 | VTY_NEWLINE); |
| 11381 | return CMD_WARNING; |
| 11382 | } |
| 11383 | |
| 11384 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 11385 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11386 | 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] | 11387 | } |
| 11388 | |
| 11389 | ALIAS (show_bgp_view_rsclient, |
| 11390 | show_bgp_rsclient_cmd, |
| 11391 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 11392 | SHOW_STR |
| 11393 | BGP_STR |
| 11394 | "Information about Route Server Client\n" |
| 11395 | NEIGHBOR_ADDR_STR) |
| 11396 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11397 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 11398 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 11399 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11400 | SHOW_STR |
| 11401 | BGP_STR |
| 11402 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11403 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11404 | "Address family\n" |
| 11405 | "Address Family modifier\n" |
| 11406 | "Address Family modifier\n" |
| 11407 | "Information about Route Server Client\n" |
| 11408 | NEIGHBOR_ADDR_STR) |
| 11409 | { |
| 11410 | struct bgp_table *table; |
| 11411 | struct peer *peer; |
| 11412 | safi_t safi; |
| 11413 | |
| 11414 | if (argc == 3) { |
| 11415 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11416 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11417 | } else { |
| 11418 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11419 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11420 | } |
| 11421 | |
| 11422 | if (! peer) |
| 11423 | return CMD_WARNING; |
| 11424 | |
| 11425 | if (! peer->afc[AFI_IP6][safi]) |
| 11426 | { |
| 11427 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11428 | VTY_NEWLINE); |
| 11429 | return CMD_WARNING; |
| 11430 | } |
| 11431 | |
| 11432 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11433 | PEER_FLAG_RSERVER_CLIENT)) |
| 11434 | { |
| 11435 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11436 | VTY_NEWLINE); |
| 11437 | return CMD_WARNING; |
| 11438 | } |
| 11439 | |
| 11440 | table = peer->rib[AFI_IP6][safi]; |
| 11441 | |
| 11442 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 11443 | } |
| 11444 | |
| 11445 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 11446 | show_bgp_ipv6_safi_rsclient_cmd, |
| 11447 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11448 | SHOW_STR |
| 11449 | BGP_STR |
| 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 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11456 | DEFUN (show_bgp_view_rsclient_route, |
| 11457 | show_bgp_view_rsclient_route_cmd, |
| 11458 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11459 | SHOW_STR |
| 11460 | BGP_STR |
| 11461 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11462 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11463 | "Information about Route Server Client\n" |
| 11464 | NEIGHBOR_ADDR_STR |
| 11465 | "Network in the BGP routing table to display\n") |
| 11466 | { |
| 11467 | struct bgp *bgp; |
| 11468 | struct peer *peer; |
| 11469 | |
| 11470 | /* BGP structure lookup. */ |
| 11471 | if (argc == 3) |
| 11472 | { |
| 11473 | bgp = bgp_lookup_by_name (argv[0]); |
| 11474 | if (bgp == NULL) |
| 11475 | { |
| 11476 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11477 | return CMD_WARNING; |
| 11478 | } |
| 11479 | } |
| 11480 | else |
| 11481 | { |
| 11482 | bgp = bgp_get_default (); |
| 11483 | if (bgp == NULL) |
| 11484 | { |
| 11485 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11486 | return CMD_WARNING; |
| 11487 | } |
| 11488 | } |
| 11489 | |
| 11490 | if (argc == 3) |
| 11491 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11492 | else |
| 11493 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11494 | |
| 11495 | if (! peer) |
| 11496 | return CMD_WARNING; |
| 11497 | |
| 11498 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11499 | { |
| 11500 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11501 | VTY_NEWLINE); |
| 11502 | return CMD_WARNING; |
| 11503 | } |
| 11504 | |
| 11505 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11506 | PEER_FLAG_RSERVER_CLIENT)) |
| 11507 | { |
| 11508 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11509 | VTY_NEWLINE); |
| 11510 | return CMD_WARNING; |
| 11511 | } |
| 11512 | |
| 11513 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11514 | (argc == 3) ? argv[2] : argv[1], |
| 11515 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 11516 | } |
| 11517 | |
| 11518 | ALIAS (show_bgp_view_rsclient_route, |
| 11519 | show_bgp_rsclient_route_cmd, |
| 11520 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11521 | SHOW_STR |
| 11522 | BGP_STR |
| 11523 | "Information about Route Server Client\n" |
| 11524 | NEIGHBOR_ADDR_STR |
| 11525 | "Network in the BGP routing table to display\n") |
| 11526 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11527 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 11528 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 11529 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11530 | SHOW_STR |
| 11531 | BGP_STR |
| 11532 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11533 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11534 | "Address family\n" |
| 11535 | "Address Family modifier\n" |
| 11536 | "Address Family modifier\n" |
| 11537 | "Information about Route Server Client\n" |
| 11538 | NEIGHBOR_ADDR_STR |
| 11539 | "Network in the BGP routing table to display\n") |
| 11540 | { |
| 11541 | struct bgp *bgp; |
| 11542 | struct peer *peer; |
| 11543 | safi_t safi; |
| 11544 | |
| 11545 | /* BGP structure lookup. */ |
| 11546 | if (argc == 4) |
| 11547 | { |
| 11548 | bgp = bgp_lookup_by_name (argv[0]); |
| 11549 | if (bgp == NULL) |
| 11550 | { |
| 11551 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11552 | return CMD_WARNING; |
| 11553 | } |
| 11554 | } |
| 11555 | else |
| 11556 | { |
| 11557 | bgp = bgp_get_default (); |
| 11558 | if (bgp == NULL) |
| 11559 | { |
| 11560 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11561 | return CMD_WARNING; |
| 11562 | } |
| 11563 | } |
| 11564 | |
| 11565 | if (argc == 4) { |
| 11566 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11567 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11568 | } else { |
| 11569 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11570 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11571 | } |
| 11572 | |
| 11573 | if (! peer) |
| 11574 | return CMD_WARNING; |
| 11575 | |
| 11576 | if (! peer->afc[AFI_IP6][safi]) |
| 11577 | { |
| 11578 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11579 | VTY_NEWLINE); |
| 11580 | return CMD_WARNING; |
| 11581 | } |
| 11582 | |
| 11583 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11584 | PEER_FLAG_RSERVER_CLIENT)) |
| 11585 | { |
| 11586 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11587 | VTY_NEWLINE); |
| 11588 | return CMD_WARNING; |
| 11589 | } |
| 11590 | |
| 11591 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11592 | (argc == 4) ? argv[3] : argv[2], |
| 11593 | AFI_IP6, safi, NULL, 0); |
| 11594 | } |
| 11595 | |
| 11596 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 11597 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 11598 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11599 | SHOW_STR |
| 11600 | BGP_STR |
| 11601 | "Address family\n" |
| 11602 | "Address Family modifier\n" |
| 11603 | "Address Family modifier\n" |
| 11604 | "Information about Route Server Client\n" |
| 11605 | NEIGHBOR_ADDR_STR |
| 11606 | "Network in the BGP routing table to display\n") |
| 11607 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11608 | DEFUN (show_bgp_view_rsclient_prefix, |
| 11609 | show_bgp_view_rsclient_prefix_cmd, |
| 11610 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11611 | SHOW_STR |
| 11612 | BGP_STR |
| 11613 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11614 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11615 | "Information about Route Server Client\n" |
| 11616 | NEIGHBOR_ADDR_STR |
| 11617 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11618 | { |
| 11619 | struct bgp *bgp; |
| 11620 | struct peer *peer; |
| 11621 | |
| 11622 | /* BGP structure lookup. */ |
| 11623 | if (argc == 3) |
| 11624 | { |
| 11625 | bgp = bgp_lookup_by_name (argv[0]); |
| 11626 | if (bgp == NULL) |
| 11627 | { |
| 11628 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11629 | return CMD_WARNING; |
| 11630 | } |
| 11631 | } |
| 11632 | else |
| 11633 | { |
| 11634 | bgp = bgp_get_default (); |
| 11635 | if (bgp == NULL) |
| 11636 | { |
| 11637 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11638 | return CMD_WARNING; |
| 11639 | } |
| 11640 | } |
| 11641 | |
| 11642 | if (argc == 3) |
| 11643 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11644 | else |
| 11645 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11646 | |
| 11647 | if (! peer) |
| 11648 | return CMD_WARNING; |
| 11649 | |
| 11650 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11651 | { |
| 11652 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11653 | VTY_NEWLINE); |
| 11654 | return CMD_WARNING; |
| 11655 | } |
| 11656 | |
| 11657 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11658 | PEER_FLAG_RSERVER_CLIENT)) |
| 11659 | { |
| 11660 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11661 | VTY_NEWLINE); |
| 11662 | return CMD_WARNING; |
| 11663 | } |
| 11664 | |
| 11665 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11666 | (argc == 3) ? argv[2] : argv[1], |
| 11667 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 11668 | } |
| 11669 | |
| 11670 | ALIAS (show_bgp_view_rsclient_prefix, |
| 11671 | show_bgp_rsclient_prefix_cmd, |
| 11672 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11673 | SHOW_STR |
| 11674 | BGP_STR |
| 11675 | "Information about Route Server Client\n" |
| 11676 | NEIGHBOR_ADDR_STR |
| 11677 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11678 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11679 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11680 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 11681 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11682 | SHOW_STR |
| 11683 | BGP_STR |
| 11684 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11685 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11686 | "Address family\n" |
| 11687 | "Address Family modifier\n" |
| 11688 | "Address Family modifier\n" |
| 11689 | "Information about Route Server Client\n" |
| 11690 | NEIGHBOR_ADDR_STR |
| 11691 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11692 | { |
| 11693 | struct bgp *bgp; |
| 11694 | struct peer *peer; |
| 11695 | safi_t safi; |
| 11696 | |
| 11697 | /* BGP structure lookup. */ |
| 11698 | if (argc == 4) |
| 11699 | { |
| 11700 | bgp = bgp_lookup_by_name (argv[0]); |
| 11701 | if (bgp == NULL) |
| 11702 | { |
| 11703 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11704 | return CMD_WARNING; |
| 11705 | } |
| 11706 | } |
| 11707 | else |
| 11708 | { |
| 11709 | bgp = bgp_get_default (); |
| 11710 | if (bgp == NULL) |
| 11711 | { |
| 11712 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11713 | return CMD_WARNING; |
| 11714 | } |
| 11715 | } |
| 11716 | |
| 11717 | if (argc == 4) { |
| 11718 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11719 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11720 | } else { |
| 11721 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11722 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11723 | } |
| 11724 | |
| 11725 | if (! peer) |
| 11726 | return CMD_WARNING; |
| 11727 | |
| 11728 | if (! peer->afc[AFI_IP6][safi]) |
| 11729 | { |
| 11730 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11731 | VTY_NEWLINE); |
| 11732 | return CMD_WARNING; |
| 11733 | } |
| 11734 | |
| 11735 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11736 | PEER_FLAG_RSERVER_CLIENT)) |
| 11737 | { |
| 11738 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11739 | VTY_NEWLINE); |
| 11740 | return CMD_WARNING; |
| 11741 | } |
| 11742 | |
| 11743 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11744 | (argc == 4) ? argv[3] : argv[2], |
| 11745 | AFI_IP6, safi, NULL, 1); |
| 11746 | } |
| 11747 | |
| 11748 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11749 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 11750 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11751 | SHOW_STR |
| 11752 | BGP_STR |
| 11753 | "Address family\n" |
| 11754 | "Address Family modifier\n" |
| 11755 | "Address Family modifier\n" |
| 11756 | "Information about Route Server Client\n" |
| 11757 | NEIGHBOR_ADDR_STR |
| 11758 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11759 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11760 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11761 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11762 | struct bgp_table *bgp_distance_table; |
| 11763 | |
| 11764 | struct bgp_distance |
| 11765 | { |
| 11766 | /* Distance value for the IP source prefix. */ |
| 11767 | u_char distance; |
| 11768 | |
| 11769 | /* Name of the access-list to be matched. */ |
| 11770 | char *access_list; |
| 11771 | }; |
| 11772 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11773 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 11774 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11775 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 11776 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11777 | } |
| 11778 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11779 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11780 | bgp_distance_free (struct bgp_distance *bdistance) |
| 11781 | { |
| 11782 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 11783 | } |
| 11784 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11785 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11786 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 11787 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11788 | { |
| 11789 | int ret; |
| 11790 | struct prefix_ipv4 p; |
| 11791 | u_char distance; |
| 11792 | struct bgp_node *rn; |
| 11793 | struct bgp_distance *bdistance; |
| 11794 | |
| 11795 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11796 | if (ret == 0) |
| 11797 | { |
| 11798 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11799 | return CMD_WARNING; |
| 11800 | } |
| 11801 | |
| 11802 | distance = atoi (distance_str); |
| 11803 | |
| 11804 | /* Get BGP distance node. */ |
| 11805 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 11806 | if (rn->info) |
| 11807 | { |
| 11808 | bdistance = rn->info; |
| 11809 | bgp_unlock_node (rn); |
| 11810 | } |
| 11811 | else |
| 11812 | { |
| 11813 | bdistance = bgp_distance_new (); |
| 11814 | rn->info = bdistance; |
| 11815 | } |
| 11816 | |
| 11817 | /* Set distance value. */ |
| 11818 | bdistance->distance = distance; |
| 11819 | |
| 11820 | /* Reset access-list configuration. */ |
| 11821 | if (bdistance->access_list) |
| 11822 | { |
| 11823 | free (bdistance->access_list); |
| 11824 | bdistance->access_list = NULL; |
| 11825 | } |
| 11826 | if (access_list_str) |
| 11827 | bdistance->access_list = strdup (access_list_str); |
| 11828 | |
| 11829 | return CMD_SUCCESS; |
| 11830 | } |
| 11831 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11832 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11833 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 11834 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11835 | { |
| 11836 | int ret; |
| 11837 | struct prefix_ipv4 p; |
| 11838 | u_char distance; |
| 11839 | struct bgp_node *rn; |
| 11840 | struct bgp_distance *bdistance; |
| 11841 | |
| 11842 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11843 | if (ret == 0) |
| 11844 | { |
| 11845 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11846 | return CMD_WARNING; |
| 11847 | } |
| 11848 | |
| 11849 | distance = atoi (distance_str); |
| 11850 | |
| 11851 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 11852 | if (! rn) |
| 11853 | { |
| 11854 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 11855 | return CMD_WARNING; |
| 11856 | } |
| 11857 | |
| 11858 | bdistance = rn->info; |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 11859 | |
| 11860 | if (bdistance->distance != distance) |
| 11861 | { |
| 11862 | vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); |
| 11863 | return CMD_WARNING; |
| 11864 | } |
| 11865 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11866 | if (bdistance->access_list) |
| 11867 | free (bdistance->access_list); |
| 11868 | bgp_distance_free (bdistance); |
| 11869 | |
| 11870 | rn->info = NULL; |
| 11871 | bgp_unlock_node (rn); |
| 11872 | bgp_unlock_node (rn); |
| 11873 | |
| 11874 | return CMD_SUCCESS; |
| 11875 | } |
| 11876 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11877 | /* Apply BGP information to distance method. */ |
| 11878 | u_char |
| 11879 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 11880 | { |
| 11881 | struct bgp_node *rn; |
| 11882 | struct prefix_ipv4 q; |
| 11883 | struct peer *peer; |
| 11884 | struct bgp_distance *bdistance; |
| 11885 | struct access_list *alist; |
| 11886 | struct bgp_static *bgp_static; |
| 11887 | |
| 11888 | if (! bgp) |
| 11889 | return 0; |
| 11890 | |
| 11891 | if (p->family != AF_INET) |
| 11892 | return 0; |
| 11893 | |
| 11894 | peer = rinfo->peer; |
| 11895 | |
| 11896 | if (peer->su.sa.sa_family != AF_INET) |
| 11897 | return 0; |
| 11898 | |
| 11899 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 11900 | q.family = AF_INET; |
| 11901 | q.prefix = peer->su.sin.sin_addr; |
| 11902 | q.prefixlen = IPV4_MAX_BITLEN; |
| 11903 | |
| 11904 | /* Check source address. */ |
| 11905 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 11906 | if (rn) |
| 11907 | { |
| 11908 | bdistance = rn->info; |
| 11909 | bgp_unlock_node (rn); |
| 11910 | |
| 11911 | if (bdistance->access_list) |
| 11912 | { |
| 11913 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 11914 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 11915 | return bdistance->distance; |
| 11916 | } |
| 11917 | else |
| 11918 | return bdistance->distance; |
| 11919 | } |
| 11920 | |
| 11921 | /* Backdoor check. */ |
| 11922 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 11923 | if (rn) |
| 11924 | { |
| 11925 | bgp_static = rn->info; |
| 11926 | bgp_unlock_node (rn); |
| 11927 | |
| 11928 | if (bgp_static->backdoor) |
| 11929 | { |
| 11930 | if (bgp->distance_local) |
| 11931 | return bgp->distance_local; |
| 11932 | else |
| 11933 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11934 | } |
| 11935 | } |
| 11936 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 11937 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11938 | { |
| 11939 | if (bgp->distance_ebgp) |
| 11940 | return bgp->distance_ebgp; |
| 11941 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 11942 | } |
| 11943 | else |
| 11944 | { |
| 11945 | if (bgp->distance_ibgp) |
| 11946 | return bgp->distance_ibgp; |
| 11947 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 11948 | } |
| 11949 | } |
| 11950 | |
| 11951 | DEFUN (bgp_distance, |
| 11952 | bgp_distance_cmd, |
| 11953 | "distance bgp <1-255> <1-255> <1-255>", |
| 11954 | "Define an administrative distance\n" |
| 11955 | "BGP distance\n" |
| 11956 | "Distance for routes external to the AS\n" |
| 11957 | "Distance for routes internal to the AS\n" |
| 11958 | "Distance for local routes\n") |
| 11959 | { |
| 11960 | struct bgp *bgp; |
| 11961 | |
| 11962 | bgp = vty->index; |
| 11963 | |
| 11964 | bgp->distance_ebgp = atoi (argv[0]); |
| 11965 | bgp->distance_ibgp = atoi (argv[1]); |
| 11966 | bgp->distance_local = atoi (argv[2]); |
| 11967 | return CMD_SUCCESS; |
| 11968 | } |
| 11969 | |
| 11970 | DEFUN (no_bgp_distance, |
| 11971 | no_bgp_distance_cmd, |
| 11972 | "no distance bgp <1-255> <1-255> <1-255>", |
| 11973 | NO_STR |
| 11974 | "Define an administrative distance\n" |
| 11975 | "BGP distance\n" |
| 11976 | "Distance for routes external to the AS\n" |
| 11977 | "Distance for routes internal to the AS\n" |
| 11978 | "Distance for local routes\n") |
| 11979 | { |
| 11980 | struct bgp *bgp; |
| 11981 | |
| 11982 | bgp = vty->index; |
| 11983 | |
| 11984 | bgp->distance_ebgp= 0; |
| 11985 | bgp->distance_ibgp = 0; |
| 11986 | bgp->distance_local = 0; |
| 11987 | return CMD_SUCCESS; |
| 11988 | } |
| 11989 | |
| 11990 | ALIAS (no_bgp_distance, |
| 11991 | no_bgp_distance2_cmd, |
| 11992 | "no distance bgp", |
| 11993 | NO_STR |
| 11994 | "Define an administrative distance\n" |
| 11995 | "BGP distance\n") |
| 11996 | |
| 11997 | DEFUN (bgp_distance_source, |
| 11998 | bgp_distance_source_cmd, |
| 11999 | "distance <1-255> A.B.C.D/M", |
| 12000 | "Define an administrative distance\n" |
| 12001 | "Administrative distance\n" |
| 12002 | "IP source prefix\n") |
| 12003 | { |
| 12004 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 12005 | return CMD_SUCCESS; |
| 12006 | } |
| 12007 | |
| 12008 | DEFUN (no_bgp_distance_source, |
| 12009 | no_bgp_distance_source_cmd, |
| 12010 | "no distance <1-255> A.B.C.D/M", |
| 12011 | NO_STR |
| 12012 | "Define an administrative distance\n" |
| 12013 | "Administrative distance\n" |
| 12014 | "IP source prefix\n") |
| 12015 | { |
| 12016 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 12017 | return CMD_SUCCESS; |
| 12018 | } |
| 12019 | |
| 12020 | DEFUN (bgp_distance_source_access_list, |
| 12021 | bgp_distance_source_access_list_cmd, |
| 12022 | "distance <1-255> A.B.C.D/M WORD", |
| 12023 | "Define an administrative distance\n" |
| 12024 | "Administrative distance\n" |
| 12025 | "IP source prefix\n" |
| 12026 | "Access list name\n") |
| 12027 | { |
| 12028 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 12029 | return CMD_SUCCESS; |
| 12030 | } |
| 12031 | |
| 12032 | DEFUN (no_bgp_distance_source_access_list, |
| 12033 | no_bgp_distance_source_access_list_cmd, |
| 12034 | "no distance <1-255> A.B.C.D/M WORD", |
| 12035 | NO_STR |
| 12036 | "Define an administrative distance\n" |
| 12037 | "Administrative distance\n" |
| 12038 | "IP source prefix\n" |
| 12039 | "Access list name\n") |
| 12040 | { |
| 12041 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 12042 | return CMD_SUCCESS; |
| 12043 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12044 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12045 | DEFUN (bgp_damp_set, |
| 12046 | bgp_damp_set_cmd, |
| 12047 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 12048 | "BGP Specific commands\n" |
| 12049 | "Enable route-flap dampening\n" |
| 12050 | "Half-life time for the penalty\n" |
| 12051 | "Value to start reusing a route\n" |
| 12052 | "Value to start suppressing a route\n" |
| 12053 | "Maximum duration to suppress a stable route\n") |
| 12054 | { |
| 12055 | struct bgp *bgp; |
| 12056 | int half = DEFAULT_HALF_LIFE * 60; |
| 12057 | int reuse = DEFAULT_REUSE; |
| 12058 | int suppress = DEFAULT_SUPPRESS; |
| 12059 | int max = 4 * half; |
| 12060 | |
| 12061 | if (argc == 4) |
| 12062 | { |
| 12063 | half = atoi (argv[0]) * 60; |
| 12064 | reuse = atoi (argv[1]); |
| 12065 | suppress = atoi (argv[2]); |
| 12066 | max = atoi (argv[3]) * 60; |
| 12067 | } |
| 12068 | else if (argc == 1) |
| 12069 | { |
| 12070 | half = atoi (argv[0]) * 60; |
| 12071 | max = 4 * half; |
| 12072 | } |
| 12073 | |
| 12074 | bgp = vty->index; |
Balaji | aa7dbb1 | 2015-03-16 16:55:26 +0000 | [diff] [blame] | 12075 | |
| 12076 | if (suppress < reuse) |
| 12077 | { |
| 12078 | vty_out (vty, "Suppress value cannot be less than reuse value %s", |
| 12079 | VTY_NEWLINE); |
| 12080 | return 0; |
| 12081 | } |
| 12082 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12083 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 12084 | half, reuse, suppress, max); |
| 12085 | } |
| 12086 | |
| 12087 | ALIAS (bgp_damp_set, |
| 12088 | bgp_damp_set2_cmd, |
| 12089 | "bgp dampening <1-45>", |
| 12090 | "BGP Specific commands\n" |
| 12091 | "Enable route-flap dampening\n" |
| 12092 | "Half-life time for the penalty\n") |
| 12093 | |
| 12094 | ALIAS (bgp_damp_set, |
| 12095 | bgp_damp_set3_cmd, |
| 12096 | "bgp dampening", |
| 12097 | "BGP Specific commands\n" |
| 12098 | "Enable route-flap dampening\n") |
| 12099 | |
| 12100 | DEFUN (bgp_damp_unset, |
| 12101 | bgp_damp_unset_cmd, |
| 12102 | "no bgp dampening", |
| 12103 | NO_STR |
| 12104 | "BGP Specific commands\n" |
| 12105 | "Enable route-flap dampening\n") |
| 12106 | { |
| 12107 | struct bgp *bgp; |
| 12108 | |
| 12109 | bgp = vty->index; |
| 12110 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 12111 | } |
| 12112 | |
| 12113 | ALIAS (bgp_damp_unset, |
| 12114 | bgp_damp_unset2_cmd, |
| 12115 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 12116 | NO_STR |
| 12117 | "BGP Specific commands\n" |
| 12118 | "Enable route-flap dampening\n" |
| 12119 | "Half-life time for the penalty\n" |
| 12120 | "Value to start reusing a route\n" |
| 12121 | "Value to start suppressing a route\n" |
| 12122 | "Maximum duration to suppress a stable route\n") |
| 12123 | |
| 12124 | DEFUN (show_ip_bgp_dampened_paths, |
| 12125 | show_ip_bgp_dampened_paths_cmd, |
| 12126 | "show ip bgp dampened-paths", |
| 12127 | SHOW_STR |
| 12128 | IP_STR |
| 12129 | BGP_STR |
| 12130 | "Display paths suppressed due to dampening\n") |
| 12131 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12132 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 12133 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12134 | } |
| 12135 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12136 | ALIAS (show_ip_bgp_dampened_paths, |
| 12137 | show_ip_bgp_damp_dampened_paths_cmd, |
| 12138 | "show ip bgp dampening dampened-paths", |
| 12139 | SHOW_STR |
| 12140 | IP_STR |
| 12141 | BGP_STR |
| 12142 | "Display detailed information about dampening\n" |
| 12143 | "Display paths suppressed due to dampening\n") |
| 12144 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12145 | DEFUN (show_ip_bgp_flap_statistics, |
| 12146 | show_ip_bgp_flap_statistics_cmd, |
| 12147 | "show ip bgp flap-statistics", |
| 12148 | SHOW_STR |
| 12149 | IP_STR |
| 12150 | BGP_STR |
| 12151 | "Display flap statistics of routes\n") |
| 12152 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12153 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 12154 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12155 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12156 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12157 | ALIAS (show_ip_bgp_flap_statistics, |
| 12158 | show_ip_bgp_damp_flap_statistics_cmd, |
| 12159 | "show ip bgp dampening flap-statistics", |
| 12160 | SHOW_STR |
| 12161 | IP_STR |
| 12162 | BGP_STR |
| 12163 | "Display detailed information about dampening\n" |
| 12164 | "Display flap statistics of routes\n") |
| 12165 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12166 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12167 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 12168 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 12169 | const char *ip_str, afi_t afi, safi_t safi, |
| 12170 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12171 | { |
| 12172 | int ret; |
| 12173 | struct prefix match; |
| 12174 | struct bgp_node *rn; |
| 12175 | struct bgp_node *rm; |
| 12176 | struct bgp_info *ri; |
| 12177 | struct bgp_info *ri_temp; |
| 12178 | struct bgp *bgp; |
| 12179 | struct bgp_table *table; |
| 12180 | |
| 12181 | /* BGP structure lookup. */ |
| 12182 | if (view_name) |
| 12183 | { |
| 12184 | bgp = bgp_lookup_by_name (view_name); |
| 12185 | if (bgp == NULL) |
| 12186 | { |
| 12187 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 12188 | return CMD_WARNING; |
| 12189 | } |
| 12190 | } |
| 12191 | else |
| 12192 | { |
| 12193 | bgp = bgp_get_default (); |
| 12194 | if (bgp == NULL) |
| 12195 | { |
| 12196 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 12197 | return CMD_WARNING; |
| 12198 | } |
| 12199 | } |
| 12200 | |
| 12201 | /* Check IP address argument. */ |
| 12202 | ret = str2prefix (ip_str, &match); |
| 12203 | if (! ret) |
| 12204 | { |
| 12205 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 12206 | return CMD_WARNING; |
| 12207 | } |
| 12208 | |
| 12209 | match.family = afi2family (afi); |
| 12210 | |
| 12211 | if (safi == SAFI_MPLS_VPN) |
| 12212 | { |
| 12213 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 12214 | { |
| 12215 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 12216 | continue; |
| 12217 | |
| 12218 | if ((table = rn->info) != NULL) |
| 12219 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12220 | { |
| 12221 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 12222 | { |
| 12223 | ri = rm->info; |
| 12224 | while (ri) |
| 12225 | { |
| 12226 | if (ri->extra && ri->extra->damp_info) |
| 12227 | { |
| 12228 | ri_temp = ri->next; |
| 12229 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12230 | ri = ri_temp; |
| 12231 | } |
| 12232 | else |
| 12233 | ri = ri->next; |
| 12234 | } |
| 12235 | } |
| 12236 | |
| 12237 | bgp_unlock_node (rm); |
| 12238 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12239 | } |
| 12240 | } |
| 12241 | else |
| 12242 | { |
| 12243 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12244 | { |
| 12245 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 12246 | { |
| 12247 | ri = rn->info; |
| 12248 | while (ri) |
| 12249 | { |
| 12250 | if (ri->extra && ri->extra->damp_info) |
| 12251 | { |
| 12252 | ri_temp = ri->next; |
| 12253 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12254 | ri = ri_temp; |
| 12255 | } |
| 12256 | else |
| 12257 | ri = ri->next; |
| 12258 | } |
| 12259 | } |
| 12260 | |
| 12261 | bgp_unlock_node (rn); |
| 12262 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12263 | } |
| 12264 | |
| 12265 | return CMD_SUCCESS; |
| 12266 | } |
| 12267 | |
| 12268 | DEFUN (clear_ip_bgp_dampening, |
| 12269 | clear_ip_bgp_dampening_cmd, |
| 12270 | "clear ip bgp dampening", |
| 12271 | CLEAR_STR |
| 12272 | IP_STR |
| 12273 | BGP_STR |
| 12274 | "Clear route flap dampening information\n") |
| 12275 | { |
| 12276 | bgp_damp_info_clean (); |
| 12277 | return CMD_SUCCESS; |
| 12278 | } |
| 12279 | |
| 12280 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 12281 | clear_ip_bgp_dampening_prefix_cmd, |
| 12282 | "clear ip bgp dampening A.B.C.D/M", |
| 12283 | CLEAR_STR |
| 12284 | IP_STR |
| 12285 | BGP_STR |
| 12286 | "Clear route flap dampening information\n" |
| 12287 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 12288 | { |
| 12289 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12290 | SAFI_UNICAST, NULL, 1); |
| 12291 | } |
| 12292 | |
| 12293 | DEFUN (clear_ip_bgp_dampening_address, |
| 12294 | clear_ip_bgp_dampening_address_cmd, |
| 12295 | "clear ip bgp dampening A.B.C.D", |
| 12296 | CLEAR_STR |
| 12297 | IP_STR |
| 12298 | BGP_STR |
| 12299 | "Clear route flap dampening information\n" |
| 12300 | "Network to clear damping information\n") |
| 12301 | { |
| 12302 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12303 | SAFI_UNICAST, NULL, 0); |
| 12304 | } |
| 12305 | |
| 12306 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 12307 | clear_ip_bgp_dampening_address_mask_cmd, |
| 12308 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 12309 | CLEAR_STR |
| 12310 | IP_STR |
| 12311 | BGP_STR |
| 12312 | "Clear route flap dampening information\n" |
| 12313 | "Network to clear damping information\n" |
| 12314 | "Network mask\n") |
| 12315 | { |
| 12316 | int ret; |
| 12317 | char prefix_str[BUFSIZ]; |
| 12318 | |
| 12319 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 12320 | if (! ret) |
| 12321 | { |
| 12322 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 12323 | return CMD_WARNING; |
| 12324 | } |
| 12325 | |
| 12326 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 12327 | SAFI_UNICAST, NULL, 0); |
| 12328 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12329 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12330 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12331 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 12332 | afi_t afi, safi_t safi, int *write) |
| 12333 | { |
| 12334 | struct bgp_node *prn; |
| 12335 | struct bgp_node *rn; |
| 12336 | struct bgp_table *table; |
| 12337 | struct prefix *p; |
| 12338 | struct prefix_rd *prd; |
| 12339 | struct bgp_static *bgp_static; |
| 12340 | u_int32_t label; |
| 12341 | char buf[SU_ADDRSTRLEN]; |
| 12342 | char rdbuf[RD_ADDRSTRLEN]; |
| 12343 | |
| 12344 | /* Network configuration. */ |
| 12345 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 12346 | if ((table = prn->info) != NULL) |
| 12347 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12348 | if ((bgp_static = rn->info) != NULL) |
| 12349 | { |
| 12350 | p = &rn->p; |
| 12351 | prd = (struct prefix_rd *) &prn->p; |
| 12352 | |
| 12353 | /* "address-family" display. */ |
| 12354 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12355 | |
| 12356 | /* "network" configuration display. */ |
| 12357 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 12358 | label = decode_label (bgp_static->tag); |
| 12359 | |
| 12360 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 12361 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12362 | p->prefixlen, |
| 12363 | rdbuf, label); |
| 12364 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12365 | } |
| 12366 | return 0; |
| 12367 | } |
| 12368 | |
| 12369 | /* Configuration of static route announcement and aggregate |
| 12370 | information. */ |
| 12371 | int |
| 12372 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 12373 | afi_t afi, safi_t safi, int *write) |
| 12374 | { |
| 12375 | struct bgp_node *rn; |
| 12376 | struct prefix *p; |
| 12377 | struct bgp_static *bgp_static; |
| 12378 | struct bgp_aggregate *bgp_aggregate; |
| 12379 | char buf[SU_ADDRSTRLEN]; |
| 12380 | |
| 12381 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 12382 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 12383 | |
| 12384 | /* Network configuration. */ |
| 12385 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12386 | if ((bgp_static = rn->info) != NULL) |
| 12387 | { |
| 12388 | p = &rn->p; |
| 12389 | |
| 12390 | /* "address-family" display. */ |
| 12391 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12392 | |
| 12393 | /* "network" configuration display. */ |
| 12394 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12395 | { |
| 12396 | u_int32_t destination; |
| 12397 | struct in_addr netmask; |
| 12398 | |
| 12399 | destination = ntohl (p->u.prefix4.s_addr); |
| 12400 | masklen2ip (p->prefixlen, &netmask); |
| 12401 | vty_out (vty, " network %s", |
| 12402 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 12403 | |
| 12404 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 12405 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 12406 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 12407 | || p->u.prefix4.s_addr == 0) |
| 12408 | { |
| 12409 | /* Natural mask is not display. */ |
| 12410 | } |
| 12411 | else |
| 12412 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 12413 | } |
| 12414 | else |
| 12415 | { |
| 12416 | vty_out (vty, " network %s/%d", |
| 12417 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12418 | p->prefixlen); |
| 12419 | } |
| 12420 | |
| 12421 | if (bgp_static->rmap.name) |
| 12422 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12423 | else |
| 12424 | { |
| 12425 | if (bgp_static->backdoor) |
| 12426 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12427 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12428 | |
| 12429 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12430 | } |
| 12431 | |
| 12432 | /* Aggregate-address configuration. */ |
| 12433 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12434 | if ((bgp_aggregate = rn->info) != NULL) |
| 12435 | { |
| 12436 | p = &rn->p; |
| 12437 | |
| 12438 | /* "address-family" display. */ |
| 12439 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12440 | |
| 12441 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12442 | { |
| 12443 | struct in_addr netmask; |
| 12444 | |
| 12445 | masklen2ip (p->prefixlen, &netmask); |
| 12446 | vty_out (vty, " aggregate-address %s %s", |
| 12447 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12448 | inet_ntoa (netmask)); |
| 12449 | } |
| 12450 | else |
| 12451 | { |
| 12452 | vty_out (vty, " aggregate-address %s/%d", |
| 12453 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12454 | p->prefixlen); |
| 12455 | } |
| 12456 | |
| 12457 | if (bgp_aggregate->as_set) |
| 12458 | vty_out (vty, " as-set"); |
| 12459 | |
| 12460 | if (bgp_aggregate->summary_only) |
| 12461 | vty_out (vty, " summary-only"); |
| 12462 | |
| 12463 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12464 | } |
| 12465 | |
| 12466 | return 0; |
| 12467 | } |
| 12468 | |
| 12469 | int |
| 12470 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 12471 | { |
| 12472 | struct bgp_node *rn; |
| 12473 | struct bgp_distance *bdistance; |
| 12474 | |
| 12475 | /* Distance configuration. */ |
| 12476 | if (bgp->distance_ebgp |
| 12477 | && bgp->distance_ibgp |
| 12478 | && bgp->distance_local |
| 12479 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 12480 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 12481 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 12482 | vty_out (vty, " distance bgp %d %d %d%s", |
| 12483 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 12484 | VTY_NEWLINE); |
| 12485 | |
| 12486 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 12487 | if ((bdistance = rn->info) != NULL) |
| 12488 | { |
| 12489 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 12490 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 12491 | bdistance->access_list ? bdistance->access_list : "", |
| 12492 | VTY_NEWLINE); |
| 12493 | } |
| 12494 | |
| 12495 | return 0; |
| 12496 | } |
| 12497 | |
| 12498 | /* Allocate routing table structure and install commands. */ |
| 12499 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 12500 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12501 | { |
| 12502 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 12503 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12504 | |
| 12505 | /* IPv4 BGP commands. */ |
| 12506 | install_element (BGP_NODE, &bgp_network_cmd); |
| 12507 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 12508 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 12509 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 12510 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 12511 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12512 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 12513 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 12514 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 12515 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 12516 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 12517 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 12518 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 12519 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12520 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12521 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 12522 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 12523 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 12524 | |
| 12525 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 12526 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 12527 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 12528 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12529 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 12530 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 12531 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 12532 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12533 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 12534 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12535 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 12536 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 12537 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 12538 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12539 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12540 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 12541 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12542 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12543 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12544 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12545 | |
| 12546 | /* IPv4 unicast configuration. */ |
| 12547 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 12548 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 12549 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 12550 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 12551 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 12552 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 12553 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12554 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 12555 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 12556 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 12557 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12558 | 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] | 12559 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12560 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 12561 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 12562 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 12563 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12564 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 12565 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 12566 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 12567 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12568 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 12569 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12570 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 12571 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 12572 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 12573 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12574 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12575 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 12576 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12577 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12578 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12579 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12580 | |
| 12581 | /* IPv4 multicast configuration. */ |
| 12582 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 12583 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 12584 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 12585 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 12586 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 12587 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12588 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 12589 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 12590 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 12591 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 12592 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12593 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12594 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 12595 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 12596 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 12597 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12598 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 12599 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 12600 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 12601 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12602 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 12603 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12604 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 12605 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 12606 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 12607 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12608 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12609 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 12610 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12611 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12612 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12613 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12614 | |
| 12615 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 12616 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12617 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12618 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 12619 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12620 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12621 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12622 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12623 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 12624 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12625 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12626 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12627 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12628 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 12629 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 12630 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12631 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 12632 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12633 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12634 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12635 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 12636 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12637 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 12638 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12639 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12640 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12641 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 12642 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12643 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 12644 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 12645 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 12646 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 12647 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12648 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12649 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12650 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12651 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12652 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12653 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12654 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12655 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12656 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 12657 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12658 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12659 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12660 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12661 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12662 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12663 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12664 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 12665 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12666 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12667 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12668 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12669 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12670 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12671 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12672 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12673 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12674 | 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] | 12675 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12676 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12677 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12678 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12679 | install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12680 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12681 | install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12682 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12683 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12684 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12685 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12686 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12687 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12688 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12689 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12690 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12691 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12692 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12693 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12694 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12695 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12696 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12697 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12698 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12699 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12700 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12701 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12702 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12703 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12704 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12705 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12706 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12707 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12708 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12709 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12710 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12711 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12712 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12713 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12714 | |
| 12715 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
| 12716 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
| 12717 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12718 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12719 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12720 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 12721 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12722 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12723 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12724 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12725 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 12726 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12727 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 12728 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 12729 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 12730 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 12731 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12732 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12733 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12734 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12735 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12736 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12737 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12738 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12739 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12740 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 12741 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12742 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12743 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12744 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12745 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12746 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12747 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12748 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12749 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12750 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12751 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12752 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12753 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12754 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12755 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12756 | |
| 12757 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 12758 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12759 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12760 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 12761 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12762 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12763 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12764 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12765 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 12766 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12767 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12768 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12769 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12770 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 12771 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 12772 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12773 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 12774 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12775 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12776 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12777 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 12778 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12779 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 12780 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12781 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12782 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12783 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 12784 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12785 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 12786 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 12787 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 12788 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 12789 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12790 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12791 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12792 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12793 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12794 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12795 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12796 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12797 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12798 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 12799 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12800 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12801 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12802 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12803 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12804 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12805 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12806 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 12807 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12808 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12809 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12810 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12811 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12812 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12813 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12814 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12815 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12816 | 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] | 12817 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12818 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12819 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12820 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12821 | install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12822 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12823 | install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12824 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12825 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12826 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12827 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12828 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12829 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12830 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12831 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12832 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12833 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12834 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12835 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12836 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
| 12837 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12838 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12839 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12840 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12841 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12842 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12843 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12844 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12845 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12846 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12847 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12848 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12849 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12850 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12851 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12852 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12853 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12854 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12855 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12856 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12857 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12858 | |
| 12859 | /* BGP dampening clear commands */ |
| 12860 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 12861 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 12862 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 12863 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 12864 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12865 | /* prefix count */ |
| 12866 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 12867 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 12868 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12869 | #ifdef HAVE_IPV6 |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12870 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 12871 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12872 | /* New config IPv6 BGP commands. */ |
| 12873 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 12874 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 12875 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 12876 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 12877 | |
| 12878 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 12879 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 12880 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 12881 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 12882 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 12883 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 12884 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 12885 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12886 | /* Old config IPv6 BGP commands. */ |
| 12887 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 12888 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 12889 | |
| 12890 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 12891 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 12892 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 12893 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 12894 | |
| 12895 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 12896 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12897 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12898 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 12899 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12900 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12901 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 12902 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12903 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12904 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 12905 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 12906 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 12907 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 12908 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 12909 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 12910 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 12911 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 12912 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 12913 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 12914 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 12915 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 12916 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 12917 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 12918 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 12919 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 12920 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 12921 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 12922 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 12923 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12924 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 12925 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 12926 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 12927 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 12928 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 12929 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 12930 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 12931 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 12932 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 12933 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 12934 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 12935 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 12936 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 12937 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 12938 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 12939 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 12940 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 12941 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 12942 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 12943 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12944 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 12945 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 12946 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 12947 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12948 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12949 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12950 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12951 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12952 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12953 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12954 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 12955 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 12956 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 12957 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 12958 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 12959 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 12960 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 12961 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 12962 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 12963 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 12964 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 12965 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 12966 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 12967 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 12968 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 12969 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 12970 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 12971 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12972 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12973 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12974 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12975 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12976 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12977 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12978 | |
| 12979 | /* Restricted: |
| 12980 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 12981 | */ |
| 12982 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 12983 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12984 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12985 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
| 12986 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12987 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12988 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 12989 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 12990 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 12991 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 12992 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 12993 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 12994 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 12995 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 12996 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 12997 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 12998 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 12999 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 13000 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 13001 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 13002 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 13003 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 13004 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13005 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 13006 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13007 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 13008 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 13009 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
| 13010 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 13011 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 13012 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 13013 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 13014 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13015 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 13016 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13017 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13018 | |
| 13019 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 13020 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13021 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13022 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 13023 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13024 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13025 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 13026 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13027 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13028 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 13029 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 13030 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 13031 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 13032 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 13033 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 13034 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 13035 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 13036 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 13037 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 13038 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 13039 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 13040 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 13041 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 13042 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 13043 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 13044 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 13045 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 13046 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 13047 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 13048 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 13049 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 13050 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 13051 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 13052 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 13053 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 13054 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 13055 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 13056 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 13057 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 13058 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 13059 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 13060 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 13061 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 13062 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 13063 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 13064 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 13065 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 13066 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 13067 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13068 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 13069 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 13070 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 13071 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13072 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13073 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13074 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13075 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13076 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13077 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13078 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 13079 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 13080 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 13081 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 13082 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 13083 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 13084 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 13085 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 13086 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 13087 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 13088 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 13089 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 13090 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 13091 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 13092 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 13093 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 13094 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 13095 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13096 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13097 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13098 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13099 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13100 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13101 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13102 | |
| 13103 | /* Statistics */ |
| 13104 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
| 13105 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 13106 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
| 13107 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
| 13108 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13109 | /* old command */ |
| 13110 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 13111 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 13112 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 13113 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 13114 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 13115 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 13116 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 13117 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 13118 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 13119 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 13120 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 13121 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 13122 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 13123 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 13124 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 13125 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 13126 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 13127 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 13128 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 13129 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 13130 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 13131 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 13132 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 13133 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 13134 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 13135 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 13136 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 13137 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 13138 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 13139 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 13140 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 13141 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 13142 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 13143 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 13144 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 13145 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13146 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13147 | /* old command */ |
| 13148 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 13149 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 13150 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 13151 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 13152 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 13153 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 13154 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 13155 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 13156 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 13157 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 13158 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 13159 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 13160 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 13161 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 13162 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 13163 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 13164 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 13165 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 13166 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 13167 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 13168 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 13169 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 13170 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 13171 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 13172 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 13173 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 13174 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 13175 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 13176 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 13177 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 13178 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 13179 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 13180 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 13181 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 13182 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 13183 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 13184 | |
| 13185 | /* old command */ |
| 13186 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13187 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13188 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13189 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13190 | |
| 13191 | /* old command */ |
| 13192 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13193 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13194 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13195 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13196 | |
| 13197 | /* old command */ |
| 13198 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13199 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13200 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13201 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13202 | #endif /* HAVE_IPV6 */ |
| 13203 | |
| 13204 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 13205 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 13206 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 13207 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 13208 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 13209 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 13210 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 13211 | |
| 13212 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 13213 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 13214 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 13215 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 13216 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 13217 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 13218 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 13219 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 13220 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 13221 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13222 | |
| 13223 | /* Deprecated AS-Pathlimit commands */ |
| 13224 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 13225 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 13226 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13227 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13228 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13229 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13230 | |
| 13231 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 13232 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13233 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13234 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13235 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13236 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13237 | |
| 13238 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 13239 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 13240 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13241 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13242 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13243 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13244 | |
| 13245 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 13246 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13247 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13248 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13249 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13250 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13251 | |
| 13252 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 13253 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 13254 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13255 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13256 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13257 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13258 | |
| 13259 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 13260 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13261 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13262 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13263 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13264 | 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] | 13265 | |
| 13266 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13267 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 13268 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 13269 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13270 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 13271 | |
| 13272 | void |
| 13273 | bgp_route_finish (void) |
| 13274 | { |
| 13275 | bgp_table_unlock (bgp_distance_table); |
| 13276 | bgp_distance_table = NULL; |
| 13277 | } |