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" |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 58 | #include "bgpd/bgp_nht.c" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 59 | |
| 60 | /* Extern from bgp_dump.c */ |
Stephen Hemminger | dde7258 | 2009-05-08 15:19:07 -0700 | [diff] [blame] | 61 | extern const char *bgp_origin_str[]; |
| 62 | extern const char *bgp_origin_long_str[]; |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 63 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 64 | static struct bgp_node * |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 65 | 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] | 66 | struct prefix_rd *prd) |
| 67 | { |
| 68 | struct bgp_node *rn; |
| 69 | struct bgp_node *prn = NULL; |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 70 | |
| 71 | assert (table); |
| 72 | if (!table) |
| 73 | return NULL; |
| 74 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 75 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 76 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 77 | prn = bgp_node_get (table, (struct prefix *) prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 78 | |
| 79 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 80 | prn->info = bgp_table_init (afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 81 | else |
| 82 | bgp_unlock_node (prn); |
| 83 | table = prn->info; |
| 84 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 85 | |
| 86 | rn = bgp_node_get (table, p); |
| 87 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 88 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 89 | rn->prn = prn; |
| 90 | |
| 91 | return rn; |
| 92 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 93 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 94 | /* Allocate bgp_info_extra */ |
| 95 | static struct bgp_info_extra * |
| 96 | bgp_info_extra_new (void) |
| 97 | { |
| 98 | struct bgp_info_extra *new; |
| 99 | new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra)); |
| 100 | return new; |
| 101 | } |
| 102 | |
| 103 | static void |
| 104 | bgp_info_extra_free (struct bgp_info_extra **extra) |
| 105 | { |
| 106 | if (extra && *extra) |
| 107 | { |
| 108 | if ((*extra)->damp_info) |
| 109 | bgp_damp_info_free ((*extra)->damp_info, 0); |
| 110 | |
| 111 | (*extra)->damp_info = NULL; |
| 112 | |
| 113 | XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra); |
| 114 | |
| 115 | *extra = NULL; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | /* Get bgp_info extra information for the given bgp_info, lazy allocated |
| 120 | * if required. |
| 121 | */ |
| 122 | struct bgp_info_extra * |
| 123 | bgp_info_extra_get (struct bgp_info *ri) |
| 124 | { |
| 125 | if (!ri->extra) |
| 126 | ri->extra = bgp_info_extra_new(); |
| 127 | return ri->extra; |
| 128 | } |
| 129 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 130 | /* Free bgp route information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 131 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 132 | bgp_info_free (struct bgp_info *binfo) |
| 133 | { |
| 134 | if (binfo->attr) |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 135 | bgp_attr_unintern (&binfo->attr); |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 136 | |
| 137 | bgp_unlink_nexthop(binfo); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 138 | bgp_info_extra_free (&binfo->extra); |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 139 | bgp_info_mpath_free (&binfo->mpath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 140 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 141 | peer_unlock (binfo->peer); /* bgp_info peer reference */ |
| 142 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 143 | XFREE (MTYPE_BGP_ROUTE, binfo); |
| 144 | } |
| 145 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 146 | struct bgp_info * |
| 147 | bgp_info_lock (struct bgp_info *binfo) |
| 148 | { |
| 149 | binfo->lock++; |
| 150 | return binfo; |
| 151 | } |
| 152 | |
| 153 | struct bgp_info * |
| 154 | bgp_info_unlock (struct bgp_info *binfo) |
| 155 | { |
| 156 | assert (binfo && binfo->lock > 0); |
| 157 | binfo->lock--; |
| 158 | |
| 159 | if (binfo->lock == 0) |
| 160 | { |
| 161 | #if 0 |
| 162 | zlog_debug ("%s: unlocked and freeing", __func__); |
| 163 | zlog_backtrace (LOG_DEBUG); |
| 164 | #endif |
| 165 | bgp_info_free (binfo); |
| 166 | return NULL; |
| 167 | } |
| 168 | |
| 169 | #if 0 |
| 170 | if (binfo->lock == 1) |
| 171 | { |
| 172 | zlog_debug ("%s: unlocked to 1", __func__); |
| 173 | zlog_backtrace (LOG_DEBUG); |
| 174 | } |
| 175 | #endif |
| 176 | |
| 177 | return binfo; |
| 178 | } |
| 179 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 180 | void |
| 181 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) |
| 182 | { |
| 183 | struct bgp_info *top; |
| 184 | |
| 185 | top = rn->info; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 186 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 187 | ri->next = rn->info; |
| 188 | ri->prev = NULL; |
| 189 | if (top) |
| 190 | top->prev = ri; |
| 191 | rn->info = ri; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 192 | |
| 193 | bgp_info_lock (ri); |
| 194 | bgp_lock_node (rn); |
| 195 | peer_lock (ri->peer); /* bgp_info peer reference */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 196 | } |
| 197 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 198 | /* Do the actual removal of info from RIB, for use by bgp_process |
| 199 | completion callback *only* */ |
| 200 | static void |
| 201 | bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 202 | { |
| 203 | if (ri->next) |
| 204 | ri->next->prev = ri->prev; |
| 205 | if (ri->prev) |
| 206 | ri->prev->next = ri->next; |
| 207 | else |
| 208 | rn->info = ri->next; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 209 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 210 | bgp_info_mpath_dequeue (ri); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 211 | bgp_info_unlock (ri); |
| 212 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 213 | } |
| 214 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 215 | void |
| 216 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) |
| 217 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 218 | bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED); |
| 219 | /* set of previous already took care of pcount */ |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 220 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 221 | } |
| 222 | |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 223 | /* undo the effects of a previous call to bgp_info_delete; typically |
| 224 | called when a route is deleted and then quickly re-added before the |
| 225 | deletion has been processed */ |
| 226 | static void |
| 227 | bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri) |
| 228 | { |
| 229 | bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED); |
| 230 | /* unset of previous already took care of pcount */ |
| 231 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 232 | } |
| 233 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 234 | /* Adjust pcount as required */ |
| 235 | static void |
| 236 | bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) |
| 237 | { |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 238 | struct bgp_table *table; |
| 239 | |
| 240 | assert (rn && bgp_node_table (rn)); |
Paul Jakma | 6f58544 | 2006-10-22 19:13:07 +0000 | [diff] [blame] | 241 | assert (ri && ri->peer && ri->peer->bgp); |
| 242 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 243 | table = bgp_node_table (rn); |
| 244 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 245 | /* Ignore 'pcount' for RS-client tables */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 246 | if (table->type != BGP_TABLE_MAIN |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 247 | || ri->peer == ri->peer->bgp->peer_self) |
| 248 | return; |
| 249 | |
| 250 | if (BGP_INFO_HOLDDOWN (ri) |
| 251 | && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 252 | { |
| 253 | |
| 254 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 255 | |
| 256 | /* slight hack, but more robust against errors. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 257 | if (ri->peer->pcount[table->afi][table->safi]) |
| 258 | ri->peer->pcount[table->afi][table->safi]--; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 259 | else |
| 260 | { |
| 261 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", |
| 262 | __func__, ri->peer->host); |
| 263 | zlog_backtrace (LOG_WARNING); |
| 264 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); |
| 265 | } |
| 266 | } |
| 267 | else if (!BGP_INFO_HOLDDOWN (ri) |
| 268 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 269 | { |
| 270 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 271 | ri->peer->pcount[table->afi][table->safi]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 272 | } |
| 273 | } |
| 274 | |
| 275 | |
| 276 | /* Set/unset bgp_info flags, adjusting any other state as needed. |
| 277 | * This is here primarily to keep prefix-count in check. |
| 278 | */ |
| 279 | void |
| 280 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 281 | { |
| 282 | SET_FLAG (ri->flags, flag); |
| 283 | |
| 284 | /* early bath if we know it's not a flag that changes useability state */ |
| 285 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 286 | return; |
| 287 | |
| 288 | bgp_pcount_adjust (rn, ri); |
| 289 | } |
| 290 | |
| 291 | void |
| 292 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 293 | { |
| 294 | UNSET_FLAG (ri->flags, flag); |
| 295 | |
| 296 | /* early bath if we know it's not a flag that changes useability state */ |
| 297 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 298 | return; |
| 299 | |
| 300 | bgp_pcount_adjust (rn, ri); |
| 301 | } |
| 302 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 303 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 304 | missing-as-worst" is specified, treat it as the worst value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 305 | static u_int32_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 306 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
| 307 | { |
| 308 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 309 | return attr->med; |
| 310 | else |
| 311 | { |
| 312 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 313 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 314 | else |
| 315 | return 0; |
| 316 | } |
| 317 | } |
| 318 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 319 | /* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist |
| 320 | * is preferred, or 0 if they are the same (usually will only occur if |
| 321 | * multipath is enabled */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 322 | static int |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 323 | 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] | 324 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 325 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 326 | struct attr *newattr, *existattr; |
| 327 | struct attr_extra *newattre, *existattre; |
| 328 | bgp_peer_sort_t new_sort; |
| 329 | bgp_peer_sort_t exist_sort; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 330 | u_int32_t new_pref; |
| 331 | u_int32_t exist_pref; |
| 332 | u_int32_t new_med; |
| 333 | u_int32_t exist_med; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 334 | u_int32_t new_weight; |
| 335 | u_int32_t exist_weight; |
| 336 | uint32_t newm, existm; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 337 | struct in_addr new_id; |
| 338 | struct in_addr exist_id; |
| 339 | int new_cluster; |
| 340 | int exist_cluster; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 341 | int internal_as_route; |
| 342 | int confed_as_route; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 343 | int ret; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 344 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 345 | /* 0. Null check. */ |
| 346 | if (new == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 347 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 348 | if (exist == NULL) |
| 349 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 350 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 351 | newattr = new->attr; |
| 352 | existattr = exist->attr; |
| 353 | newattre = newattr->extra; |
| 354 | existattre = existattr->extra; |
| 355 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 356 | /* 1. Weight check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 357 | new_weight = exist_weight = 0; |
| 358 | |
| 359 | if (newattre) |
| 360 | new_weight = newattre->weight; |
| 361 | if (existattre) |
| 362 | exist_weight = existattre->weight; |
| 363 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 364 | if (new_weight > exist_weight) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 365 | return -1; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 366 | if (new_weight < exist_weight) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 367 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 368 | |
| 369 | /* 2. Local preference check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 370 | new_pref = exist_pref = bgp->default_local_pref; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 371 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 372 | if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 373 | new_pref = newattr->local_pref; |
| 374 | if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 375 | exist_pref = existattr->local_pref; |
| 376 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 377 | if (new_pref > exist_pref) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 378 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 379 | if (new_pref < exist_pref) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 380 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 381 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 382 | /* 3. Local route check. We prefer: |
| 383 | * - BGP_ROUTE_STATIC |
| 384 | * - BGP_ROUTE_AGGREGATE |
| 385 | * - BGP_ROUTE_REDISTRIBUTE |
| 386 | */ |
| 387 | if (! (new->sub_type == BGP_ROUTE_NORMAL)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 388 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 389 | if (! (exist->sub_type == BGP_ROUTE_NORMAL)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 390 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 391 | |
| 392 | /* 4. AS path length check. */ |
| 393 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 394 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 395 | int exist_hops = aspath_count_hops (existattr->aspath); |
| 396 | int exist_confeds = aspath_count_confeds (existattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 397 | |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 398 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
| 399 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 400 | int aspath_hops; |
| 401 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 402 | aspath_hops = aspath_count_hops (newattr->aspath); |
| 403 | aspath_hops += aspath_count_confeds (newattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 404 | |
| 405 | if ( aspath_hops < (exist_hops + exist_confeds)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 406 | return -1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 407 | if ( aspath_hops > (exist_hops + exist_confeds)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 408 | return 1; |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 409 | } |
| 410 | else |
| 411 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 412 | int newhops = aspath_count_hops (newattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 413 | |
| 414 | if (newhops < exist_hops) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 415 | return -1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 416 | if (newhops > exist_hops) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 417 | return 1; |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 418 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | /* 5. Origin check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 422 | if (newattr->origin < existattr->origin) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 423 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 424 | if (newattr->origin > existattr->origin) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 425 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 426 | |
| 427 | /* 6. MED check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 428 | internal_as_route = (aspath_count_hops (newattr->aspath) == 0 |
| 429 | && aspath_count_hops (existattr->aspath) == 0); |
| 430 | confed_as_route = (aspath_count_confeds (newattr->aspath) > 0 |
| 431 | && aspath_count_confeds (existattr->aspath) > 0 |
| 432 | && aspath_count_hops (newattr->aspath) == 0 |
| 433 | && aspath_count_hops (existattr->aspath) == 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 434 | |
| 435 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 436 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 437 | && confed_as_route) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 438 | || aspath_cmp_left (newattr->aspath, existattr->aspath) |
| 439 | || aspath_cmp_left_confed (newattr->aspath, existattr->aspath) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 440 | || internal_as_route) |
| 441 | { |
| 442 | new_med = bgp_med_value (new->attr, bgp); |
| 443 | exist_med = bgp_med_value (exist->attr, bgp); |
| 444 | |
| 445 | if (new_med < exist_med) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 446 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 447 | if (new_med > exist_med) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 448 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | /* 7. Peer type check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 452 | new_sort = new->peer->sort; |
| 453 | exist_sort = exist->peer->sort; |
| 454 | |
| 455 | if (new_sort == BGP_PEER_EBGP |
| 456 | && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 457 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 458 | if (exist_sort == BGP_PEER_EBGP |
| 459 | && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 460 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 461 | |
| 462 | /* 8. IGP metric check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 463 | newm = existm = 0; |
| 464 | |
| 465 | if (new->extra) |
| 466 | newm = new->extra->igpmetric; |
| 467 | if (exist->extra) |
| 468 | existm = exist->extra->igpmetric; |
| 469 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 470 | if (newm < existm) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 471 | return -1; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 472 | if (newm > existm) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 473 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 474 | |
| 475 | /* 9. Maximum path check. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 476 | if (bgp_mpath_is_configured (bgp, afi, safi)) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 477 | { |
Pradosh Mohapatra | 2fdd455 | 2013-09-07 07:02:36 +0000 | [diff] [blame] | 478 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) |
| 479 | { |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 480 | /* |
| 481 | * For the two paths, all comparison steps till IGP metric |
| 482 | * have succeeded - including AS_PATH hop count. Since 'bgp |
| 483 | * bestpath as-path multipath-relax' knob is on, we don't need |
| 484 | * an exact match of AS_PATH. Thus, mark the paths are equal. |
| 485 | * That will trigger both these paths to get into the multipath |
| 486 | * array. |
| 487 | */ |
| 488 | return 0; |
Pradosh Mohapatra | 2fdd455 | 2013-09-07 07:02:36 +0000 | [diff] [blame] | 489 | } |
| 490 | else if (new->peer->sort == BGP_PEER_IBGP) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 491 | { |
| 492 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) |
| 493 | return 0; |
| 494 | } |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 495 | else if (new->peer->as == exist->peer->as) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 496 | return 0; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 497 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 498 | |
| 499 | /* 10. If both paths are external, prefer the path that was received |
| 500 | first (the oldest one). This step minimizes route-flap, since a |
| 501 | newer path won't displace an older one, even if it was the |
| 502 | preferred route based on the additional decision criteria below. */ |
| 503 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 504 | && new_sort == BGP_PEER_EBGP |
| 505 | && exist_sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 506 | { |
| 507 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 508 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 509 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 510 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 511 | } |
| 512 | |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 513 | /* 11. Router-ID comparision. */ |
| 514 | /* If one of the paths is "stale", the corresponding peer router-id will |
| 515 | * be 0 and would always win over the other path. If originator id is |
| 516 | * used for the comparision, it will decide which path is better. |
| 517 | */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 518 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 519 | new_id.s_addr = newattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 520 | else |
| 521 | new_id.s_addr = new->peer->remote_id.s_addr; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 522 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 523 | exist_id.s_addr = existattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 524 | else |
| 525 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 526 | |
| 527 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 528 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 529 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 530 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 531 | |
| 532 | /* 12. Cluster length comparision. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 533 | new_cluster = exist_cluster = 0; |
| 534 | |
| 535 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 536 | new_cluster = newattre->cluster->length; |
| 537 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 538 | exist_cluster = existattre->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 539 | |
| 540 | if (new_cluster < exist_cluster) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 541 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 542 | if (new_cluster > exist_cluster) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 543 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 544 | |
| 545 | /* 13. Neighbor address comparision. */ |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 546 | /* Do this only if neither path is "stale" as stale paths do not have |
| 547 | * valid peer information (as the connection may or may not be up). |
| 548 | */ |
| 549 | if (CHECK_FLAG (exist->flags, BGP_INFO_STALE)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 550 | return -1; |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 551 | if (CHECK_FLAG (new->flags, BGP_INFO_STALE)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 552 | return 1; |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 553 | /* locally configured routes to advertise do not have su_remote */ |
| 554 | if (new->peer->su_remote == NULL) |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 555 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 556 | if (exist->peer->su_remote == NULL) |
| 557 | return -1; |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 558 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 559 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 560 | |
| 561 | if (ret == 1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 562 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 563 | if (ret == -1) |
| 564 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 565 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 566 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 567 | } |
| 568 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 569 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 570 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 571 | afi_t afi, safi_t safi) |
| 572 | { |
| 573 | struct bgp_filter *filter; |
| 574 | |
| 575 | filter = &peer->filter[afi][safi]; |
| 576 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 577 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 578 | if (BGP_DEBUG (update, UPDATE_IN) \ |
| 579 | && !(F ## _IN (filter))) \ |
| 580 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ |
| 581 | peer->host, #f, F ## _IN_NAME(filter)); |
| 582 | |
| 583 | if (DISTRIBUTE_IN_NAME (filter)) { |
| 584 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 585 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 586 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 587 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 588 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 589 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 590 | if (PREFIX_LIST_IN_NAME (filter)) { |
| 591 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 592 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 593 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 594 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 595 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 596 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 597 | if (FILTER_LIST_IN_NAME (filter)) { |
| 598 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 599 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 600 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 601 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 602 | } |
| 603 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 604 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 605 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 606 | } |
| 607 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 608 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 609 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 610 | afi_t afi, safi_t safi) |
| 611 | { |
| 612 | struct bgp_filter *filter; |
| 613 | |
| 614 | filter = &peer->filter[afi][safi]; |
| 615 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 616 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 617 | if (BGP_DEBUG (update, UPDATE_OUT) \ |
| 618 | && !(F ## _OUT (filter))) \ |
| 619 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ |
| 620 | peer->host, #f, F ## _OUT_NAME(filter)); |
| 621 | |
| 622 | if (DISTRIBUTE_OUT_NAME (filter)) { |
| 623 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 624 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 625 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 626 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 627 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 628 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 629 | if (PREFIX_LIST_OUT_NAME (filter)) { |
| 630 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 631 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 632 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 633 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 634 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 635 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 636 | if (FILTER_LIST_OUT_NAME (filter)) { |
| 637 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 638 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 639 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 640 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 641 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 642 | |
| 643 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 644 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 648 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 649 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 650 | { |
| 651 | if (attr->community) |
| 652 | { |
| 653 | /* NO_ADVERTISE check. */ |
| 654 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 655 | return 1; |
| 656 | |
| 657 | /* NO_EXPORT check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 658 | if (peer->sort == BGP_PEER_EBGP && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 659 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 660 | return 1; |
| 661 | |
| 662 | /* NO_EXPORT_SUBCONFED check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 663 | if (peer->sort == BGP_PEER_EBGP |
| 664 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 665 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 666 | return 1; |
| 667 | } |
| 668 | return 0; |
| 669 | } |
| 670 | |
| 671 | /* Route reflection loop check. */ |
| 672 | static int |
| 673 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 674 | { |
| 675 | struct in_addr cluster_id; |
| 676 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 677 | if (attr->extra && attr->extra->cluster) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 678 | { |
| 679 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 680 | cluster_id = peer->bgp->cluster_id; |
| 681 | else |
| 682 | cluster_id = peer->bgp->router_id; |
| 683 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 684 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 685 | return 1; |
| 686 | } |
| 687 | return 0; |
| 688 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 689 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 690 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 691 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 692 | afi_t afi, safi_t safi) |
| 693 | { |
| 694 | struct bgp_filter *filter; |
| 695 | struct bgp_info info; |
| 696 | route_map_result_t ret; |
| 697 | |
| 698 | filter = &peer->filter[afi][safi]; |
| 699 | |
| 700 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 701 | if (peer->weight) |
| 702 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 703 | |
| 704 | /* Route map apply. */ |
| 705 | if (ROUTE_MAP_IN_NAME (filter)) |
| 706 | { |
| 707 | /* Duplicate current value to new strucutre for modification. */ |
| 708 | info.peer = peer; |
| 709 | info.attr = attr; |
| 710 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 711 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 712 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 713 | /* Apply BGP route map to the attribute. */ |
| 714 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 715 | |
| 716 | peer->rmap_type = 0; |
| 717 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 718 | if (ret == RMAP_DENYMATCH) |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 719 | /* caller has multiple error paths with bgp_attr_flush() */ |
| 720 | return RMAP_DENY; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 721 | } |
| 722 | return RMAP_PERMIT; |
| 723 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 724 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 725 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 726 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 727 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 728 | { |
| 729 | struct bgp_filter *filter; |
| 730 | struct bgp_info info; |
| 731 | route_map_result_t ret; |
| 732 | |
| 733 | filter = &peer->filter[afi][safi]; |
| 734 | |
| 735 | /* Route map apply. */ |
| 736 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 737 | { |
| 738 | /* Duplicate current value to new strucutre for modification. */ |
| 739 | info.peer = rsclient; |
| 740 | info.attr = attr; |
| 741 | |
| 742 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 743 | |
| 744 | /* Apply BGP route map to the attribute. */ |
| 745 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 746 | |
| 747 | rsclient->rmap_type = 0; |
| 748 | |
| 749 | if (ret == RMAP_DENYMATCH) |
| 750 | { |
| 751 | /* Free newly generated AS path and community by route-map. */ |
| 752 | bgp_attr_flush (attr); |
| 753 | return RMAP_DENY; |
| 754 | } |
| 755 | } |
| 756 | return RMAP_PERMIT; |
| 757 | } |
| 758 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 759 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 760 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 761 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 762 | { |
| 763 | struct bgp_filter *filter; |
| 764 | struct bgp_info info; |
| 765 | route_map_result_t ret; |
| 766 | |
| 767 | filter = &rsclient->filter[afi][safi]; |
| 768 | |
| 769 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 770 | if (peer->weight) |
| 771 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 772 | |
| 773 | /* Route map apply. */ |
| 774 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 775 | { |
| 776 | /* Duplicate current value to new strucutre for modification. */ |
| 777 | info.peer = peer; |
| 778 | info.attr = attr; |
| 779 | |
| 780 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 781 | |
| 782 | /* Apply BGP route map to the attribute. */ |
| 783 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 784 | |
| 785 | peer->rmap_type = 0; |
| 786 | |
| 787 | if (ret == RMAP_DENYMATCH) |
| 788 | { |
| 789 | /* Free newly generated AS path and community by route-map. */ |
| 790 | bgp_attr_flush (attr); |
| 791 | return RMAP_DENY; |
| 792 | } |
| 793 | } |
| 794 | return RMAP_PERMIT; |
| 795 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 796 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 797 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 798 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 799 | struct attr *attr, afi_t afi, safi_t safi) |
| 800 | { |
| 801 | int ret; |
| 802 | char buf[SU_ADDRSTRLEN]; |
| 803 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 804 | struct peer *from; |
| 805 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 806 | int transparent; |
| 807 | int reflect; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 808 | struct attr *riattr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 809 | |
| 810 | from = ri->peer; |
| 811 | filter = &peer->filter[afi][safi]; |
| 812 | bgp = peer->bgp; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 813 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 814 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 815 | if (DISABLE_BGP_ANNOUNCE) |
| 816 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 817 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 818 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 819 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 820 | return 0; |
| 821 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 822 | /* Do not send back route to sender. */ |
| 823 | if (from == peer) |
| 824 | return 0; |
| 825 | |
| 826 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 827 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 828 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 829 | return 0; |
| 830 | |
| 831 | /* Default route check. */ |
| 832 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 833 | { |
| 834 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 835 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 836 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 837 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 838 | } |
| 839 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 840 | /* Transparency check. */ |
| 841 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 842 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 843 | transparent = 1; |
| 844 | else |
| 845 | transparent = 0; |
| 846 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 847 | /* If community is not disabled check the no-export and local. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 848 | if (! transparent && bgp_community_filter (peer, riattr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 849 | return 0; |
| 850 | |
| 851 | /* If the attribute has originator-id and it is same as remote |
| 852 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 853 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 854 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 855 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 856 | { |
| 857 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 858 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 859 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 860 | peer->host, |
| 861 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 862 | p->prefixlen); |
| 863 | return 0; |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | /* ORF prefix-list filter check */ |
| 868 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 869 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 870 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 871 | if (peer->orf_plist[afi][safi]) |
| 872 | { |
| 873 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 874 | return 0; |
| 875 | } |
| 876 | |
| 877 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 878 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 879 | { |
| 880 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 881 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 882 | "%s [Update:SEND] %s/%d is filtered", |
| 883 | peer->host, |
| 884 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 885 | p->prefixlen); |
| 886 | return 0; |
| 887 | } |
| 888 | |
| 889 | #ifdef BGP_SEND_ASPATH_CHECK |
| 890 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 891 | if (aspath_loop_check (riattr->aspath, peer->as)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 892 | { |
| 893 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 894 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 895 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 896 | peer->host, peer->as); |
| 897 | return 0; |
| 898 | } |
| 899 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 900 | |
| 901 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 902 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 903 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 904 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 905 | { |
| 906 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 907 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 908 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 909 | peer->host, |
| 910 | bgp->confed_id); |
| 911 | return 0; |
| 912 | } |
| 913 | } |
| 914 | |
| 915 | /* Route-Reflect check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 916 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 917 | reflect = 1; |
| 918 | else |
| 919 | reflect = 0; |
| 920 | |
| 921 | /* IBGP reflection check. */ |
| 922 | if (reflect) |
| 923 | { |
| 924 | /* A route from a Client peer. */ |
| 925 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 926 | { |
| 927 | /* Reflect to all the Non-Client peers and also to the |
| 928 | Client peers other than the originator. Originator check |
| 929 | is already done. So there is noting to do. */ |
| 930 | /* no bgp client-to-client reflection check. */ |
| 931 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 932 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 933 | return 0; |
| 934 | } |
| 935 | else |
| 936 | { |
| 937 | /* A route from a Non-client peer. Reflect to all other |
| 938 | clients. */ |
| 939 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 940 | return 0; |
| 941 | } |
| 942 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 943 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 944 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 945 | bgp_attr_dup (attr, riattr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 946 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 947 | /* If local-preference is not set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 948 | if ((peer->sort == BGP_PEER_IBGP |
| 949 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 950 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 951 | { |
| 952 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 953 | attr->local_pref = bgp->default_local_pref; |
| 954 | } |
| 955 | |
Pradosh Mohapatra | 689bb66 | 2013-09-07 07:13:37 +0000 | [diff] [blame] | 956 | /* If originator-id is not set and the route is to be reflected, |
| 957 | set the originator id */ |
| 958 | if (peer && from && peer->sort == BGP_PEER_IBGP && |
| 959 | from->sort == BGP_PEER_IBGP && |
| 960 | (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) |
| 961 | { |
| 962 | attr->extra = bgp_attr_extra_get(attr); |
| 963 | IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id)); |
| 964 | SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID); |
| 965 | } |
| 966 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 967 | /* 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] | 968 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 969 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 970 | { |
| 971 | if (ri->peer != bgp->peer_self && ! transparent |
| 972 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 973 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 974 | } |
| 975 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 976 | |
| 977 | #define NEXTHOP_IS_V4 (\ |
| 978 | (safi != SAFI_ENCAP && p->family == AF_INET) || \ |
| 979 | (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 4)) |
| 980 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 981 | #define NEXTHOP_IS_V6 (\ |
| 982 | (safi != SAFI_ENCAP && p->family == AF_INET6) || \ |
| 983 | (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16)) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 984 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 985 | /* next-hop-set */ |
Timo Teräs | 9e7a53c | 2014-04-24 10:22:37 +0300 | [diff] [blame] | 986 | if (transparent |
| 987 | || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 988 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 989 | && ((NEXTHOP_IS_V4 && attr->nexthop.s_addr) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 990 | || (NEXTHOP_IS_V6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 991 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 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) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 997 | || (NEXTHOP_IS_V4 && attr->nexthop.s_addr == 0) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 998 | || (NEXTHOP_IS_V6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 999 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1000 | || (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1001 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 1002 | { |
| 1003 | /* Set IPv4 nexthop. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1004 | if (NEXTHOP_IS_V4) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1005 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1006 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1007 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 1008 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1009 | else |
| 1010 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1011 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1012 | /* Set IPv6 nexthop. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1013 | if (NEXTHOP_IS_V6) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1014 | { |
| 1015 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1016 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1017 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1018 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1019 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1020 | } |
| 1021 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1022 | if (p->family == AF_INET6 && safi != SAFI_ENCAP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1023 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1024 | /* Left nexthop_local unchanged if so configured. */ |
| 1025 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 1026 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1027 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1028 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 1029 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1030 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1031 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1032 | } |
| 1033 | |
| 1034 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 1035 | else |
| 1036 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1037 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1038 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1039 | |
| 1040 | /* Set link-local address for shared network peer. */ |
| 1041 | if (peer->shared_network |
| 1042 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 1043 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1044 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1045 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1046 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1047 | } |
| 1048 | |
| 1049 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 1050 | address.*/ |
| 1051 | if (reflect) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1052 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1053 | |
| 1054 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 1055 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1056 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1057 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1058 | |
| 1059 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1060 | |
| 1061 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1062 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1063 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1064 | && aspath_private_as_check (attr->aspath)) |
| 1065 | attr->aspath = aspath_empty_get (); |
| 1066 | |
| 1067 | /* Route map & unsuppress-map apply. */ |
| 1068 | if (ROUTE_MAP_OUT_NAME (filter) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1069 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1070 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1071 | struct bgp_info info; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1072 | struct attr dummy_attr; |
| 1073 | struct attr_extra dummy_extra; |
| 1074 | |
| 1075 | dummy_attr.extra = &dummy_extra; |
| 1076 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1077 | info.peer = peer; |
| 1078 | info.attr = attr; |
| 1079 | |
| 1080 | /* The route reflector is not allowed to modify the attributes |
Dinesh Dutt | 083e5e2 | 2015-11-09 20:21:54 -0500 | [diff] [blame] | 1081 | of the reflected IBGP routes, unless configured to allow it */ |
| 1082 | if ((from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) && |
| 1083 | !bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1084 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1085 | bgp_attr_dup (&dummy_attr, attr); |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1086 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1087 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1088 | |
| 1089 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1090 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1091 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1092 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1093 | else |
| 1094 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1095 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1096 | peer->rmap_type = 0; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1097 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1098 | if (ret == RMAP_DENYMATCH) |
| 1099 | { |
| 1100 | bgp_attr_flush (attr); |
| 1101 | return 0; |
| 1102 | } |
| 1103 | } |
| 1104 | return 1; |
| 1105 | } |
| 1106 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1107 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1108 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1109 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1110 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1111 | int ret; |
| 1112 | char buf[SU_ADDRSTRLEN]; |
| 1113 | struct bgp_filter *filter; |
| 1114 | struct bgp_info info; |
| 1115 | struct peer *from; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1116 | struct attr *riattr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1117 | |
| 1118 | from = ri->peer; |
| 1119 | filter = &rsclient->filter[afi][safi]; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1120 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1121 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 1122 | if (DISABLE_BGP_ANNOUNCE) |
| 1123 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1124 | |
| 1125 | /* Do not send back route to sender. */ |
| 1126 | if (from == rsclient) |
| 1127 | return 0; |
| 1128 | |
| 1129 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1130 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1131 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 1132 | return 0; |
| 1133 | |
| 1134 | /* Default route check. */ |
| 1135 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1136 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1137 | { |
| 1138 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1139 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1140 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1141 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1142 | } |
| 1143 | |
| 1144 | /* If the attribute has originator-id and it is same as remote |
| 1145 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1146 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1147 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1148 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1149 | &riattr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1150 | { |
| 1151 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1152 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1153 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1154 | rsclient->host, |
| 1155 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1156 | p->prefixlen); |
| 1157 | return 0; |
| 1158 | } |
| 1159 | } |
| 1160 | |
| 1161 | /* ORF prefix-list filter check */ |
| 1162 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1163 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1164 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1165 | if (rsclient->orf_plist[afi][safi]) |
| 1166 | { |
| 1167 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1168 | return 0; |
| 1169 | } |
| 1170 | |
| 1171 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1172 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1173 | { |
| 1174 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1175 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1176 | "%s [Update:SEND] %s/%d is filtered", |
| 1177 | rsclient->host, |
| 1178 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1179 | p->prefixlen); |
| 1180 | return 0; |
| 1181 | } |
| 1182 | |
| 1183 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1184 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1185 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1186 | { |
| 1187 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1188 | zlog (rsclient->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 1189 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1190 | rsclient->host, rsclient->as); |
| 1191 | return 0; |
| 1192 | } |
| 1193 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1194 | |
| 1195 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1196 | bgp_attr_dup (attr, riattr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1197 | |
| 1198 | /* next-hop-set */ |
| 1199 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1200 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1201 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1202 | ) |
| 1203 | { |
| 1204 | /* Set IPv4 nexthop. */ |
| 1205 | if (p->family == AF_INET) |
| 1206 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1207 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1208 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1209 | IPV4_MAX_BYTELEN); |
| 1210 | else |
| 1211 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1212 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1213 | /* Set IPv6 nexthop. */ |
| 1214 | if (p->family == AF_INET6) |
| 1215 | { |
| 1216 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1217 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1218 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1219 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1220 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1221 | } |
| 1222 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1223 | if (p->family == AF_INET6) |
| 1224 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1225 | struct attr_extra *attre = attr->extra; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1226 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1227 | /* Left nexthop_local unchanged if so configured. */ |
| 1228 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1229 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1230 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1231 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1232 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1233 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1234 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1235 | } |
| 1236 | |
| 1237 | /* Default nexthop_local treatment for RS-Clients */ |
| 1238 | else |
| 1239 | { |
| 1240 | /* Announcer and RS-Client are both in the same network */ |
| 1241 | if (rsclient->shared_network && from->shared_network && |
| 1242 | (rsclient->ifindex == from->ifindex)) |
| 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 | /* Set link-local address for shared network peer. */ |
| 1251 | else if (rsclient->shared_network |
| 1252 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1253 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1254 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1255 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1256 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
| 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 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1264 | |
| 1265 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1266 | if (rsclient->sort == BGP_PEER_EBGP |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1267 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1268 | && aspath_private_as_check (attr->aspath)) |
| 1269 | attr->aspath = aspath_empty_get (); |
| 1270 | |
| 1271 | /* Route map & unsuppress-map apply. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1272 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1273 | { |
| 1274 | info.peer = rsclient; |
| 1275 | info.attr = attr; |
| 1276 | |
| 1277 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1278 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1279 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1280 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1281 | else |
| 1282 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1283 | |
| 1284 | rsclient->rmap_type = 0; |
| 1285 | |
| 1286 | if (ret == RMAP_DENYMATCH) |
| 1287 | { |
| 1288 | bgp_attr_flush (attr); |
| 1289 | return 0; |
| 1290 | } |
| 1291 | } |
| 1292 | |
| 1293 | return 1; |
| 1294 | } |
| 1295 | |
| 1296 | struct bgp_info_pair |
| 1297 | { |
| 1298 | struct bgp_info *old; |
| 1299 | struct bgp_info *new; |
| 1300 | }; |
| 1301 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1302 | static void |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1303 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1304 | struct bgp_info_pair *result, |
| 1305 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1306 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1307 | struct bgp_info *new_select; |
| 1308 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1309 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1310 | struct bgp_info *ri1; |
| 1311 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1312 | struct bgp_info *nextri = NULL; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1313 | int cmpret, do_mpath; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1314 | struct list mp_list; |
Paul Jakma | 91b9e85 | 2015-12-01 14:32:11 +0000 | [diff] [blame] | 1315 | |
| 1316 | result->old = result->new = NULL; |
| 1317 | |
| 1318 | if (rn->info == NULL) |
| 1319 | { |
| 1320 | char buf[PREFIX_STRLEN]; |
| 1321 | zlog_warn ("%s: Called for route_node %s with no routing entries!", |
| 1322 | __func__, |
| 1323 | prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf))); |
| 1324 | return; |
| 1325 | } |
| 1326 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1327 | bgp_mp_list_init (&mp_list); |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1328 | do_mpath = bgp_mpath_is_configured (bgp, afi, safi); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1329 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1330 | /* bgp deterministic-med */ |
| 1331 | new_select = NULL; |
| 1332 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1333 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1334 | { |
| 1335 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1336 | continue; |
| 1337 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1338 | continue; |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1339 | if (ri1->peer && ri1->peer != bgp->peer_self) |
| 1340 | if (ri1->peer->status != Established) |
| 1341 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1342 | |
| 1343 | new_select = ri1; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1344 | if (do_mpath) |
| 1345 | bgp_mp_list_add (&mp_list, ri1); |
| 1346 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1347 | if (ri1->next) |
| 1348 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1349 | { |
| 1350 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1351 | continue; |
| 1352 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1353 | continue; |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1354 | if (ri2->peer && |
| 1355 | ri2->peer != bgp->peer_self && |
| 1356 | !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT)) |
| 1357 | if (ri2->peer->status != Established) |
| 1358 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1359 | |
| 1360 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1361 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1362 | ri2->attr->aspath)) |
| 1363 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1364 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
| 1365 | old_select = ri2; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1366 | if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi)) |
| 1367 | == -1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1368 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1369 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1370 | new_select = ri2; |
| 1371 | } |
| 1372 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1373 | if (do_mpath) |
| 1374 | { |
| 1375 | if (cmpret != 0) |
| 1376 | bgp_mp_list_clear (&mp_list); |
| 1377 | |
| 1378 | if (cmpret == 0 || cmpret == -1) |
| 1379 | bgp_mp_list_add (&mp_list, ri2); |
| 1380 | } |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1381 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1382 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1383 | } |
| 1384 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1385 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1386 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1387 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1388 | 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] | 1389 | bgp_mp_list_clear (&mp_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1390 | } |
| 1391 | |
| 1392 | /* Check old selected route and new selected route. */ |
| 1393 | old_select = NULL; |
| 1394 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1395 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1396 | { |
| 1397 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1398 | old_select = ri; |
| 1399 | |
| 1400 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1401 | { |
| 1402 | /* reap REMOVED routes, if needs be |
| 1403 | * selected route must stay for a while longer though |
| 1404 | */ |
| 1405 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1406 | && (ri != old_select)) |
| 1407 | bgp_info_reap (rn, ri); |
| 1408 | |
| 1409 | continue; |
| 1410 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1411 | |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1412 | if (ri->peer && |
| 1413 | ri->peer != bgp->peer_self && |
| 1414 | !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT)) |
| 1415 | if (ri->peer->status != Established) |
| 1416 | continue; |
| 1417 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1418 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1419 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1420 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1421 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1422 | continue; |
| 1423 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1424 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1425 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1426 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1427 | if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1428 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1429 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1430 | bgp_mp_dmed_deselect (new_select); |
| 1431 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1432 | new_select = ri; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1433 | } |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1434 | else if (cmpret == 1 && do_mpath |
| 1435 | && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1436 | bgp_mp_dmed_deselect (ri); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1437 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1438 | if (do_mpath) |
| 1439 | { |
| 1440 | if (cmpret != 0) |
| 1441 | bgp_mp_list_clear (&mp_list); |
| 1442 | |
| 1443 | if (cmpret == 0 || cmpret == -1) |
| 1444 | bgp_mp_list_add (&mp_list, ri); |
| 1445 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1446 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1447 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1448 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1449 | 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] | 1450 | |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1451 | bgp_info_mpath_aggregate_update (new_select, old_select); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1452 | bgp_mp_list_clear (&mp_list); |
| 1453 | |
| 1454 | result->old = old_select; |
| 1455 | result->new = new_select; |
| 1456 | |
| 1457 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1458 | } |
| 1459 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1460 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1461 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1462 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1463 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1464 | struct prefix *p; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1465 | struct attr attr; |
| 1466 | struct attr_extra extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1467 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1468 | memset (&attr, 0, sizeof(struct attr)); |
| 1469 | memset (&extra, 0, sizeof(struct attr_extra)); |
| 1470 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1471 | p = &rn->p; |
| 1472 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1473 | /* Announce route to Established peer. */ |
| 1474 | if (peer->status != Established) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1475 | return 0; |
| 1476 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1477 | /* Address family configuration check. */ |
| 1478 | if (! peer->afc_nego[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1479 | return 0; |
| 1480 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1481 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1482 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1483 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1484 | return 0; |
| 1485 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1486 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 1487 | attr.extra = &extra; |
| 1488 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1489 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1490 | { |
| 1491 | case BGP_TABLE_MAIN: |
| 1492 | /* Announcement to peer->conf. If the route is filtered, |
| 1493 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1494 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
| 1495 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1496 | else |
| 1497 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1498 | break; |
| 1499 | case BGP_TABLE_RSCLIENT: |
| 1500 | /* Announcement to peer->conf. If the route is filtered, |
| 1501 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1502 | if (selected && |
| 1503 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) |
| 1504 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
| 1505 | else |
| 1506 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1507 | break; |
| 1508 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1509 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1510 | bgp_attr_flush (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1511 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1512 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1513 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1514 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1515 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1516 | struct bgp *bgp; |
| 1517 | struct bgp_node *rn; |
| 1518 | afi_t afi; |
| 1519 | safi_t safi; |
| 1520 | }; |
| 1521 | |
| 1522 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1523 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1524 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1525 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1526 | struct bgp *bgp = pq->bgp; |
| 1527 | struct bgp_node *rn = pq->rn; |
| 1528 | afi_t afi = pq->afi; |
| 1529 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1530 | struct bgp_info *new_select; |
| 1531 | struct bgp_info *old_select; |
| 1532 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1533 | struct listnode *node, *nnode; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1534 | struct peer *rsclient = bgp_node_table (rn)->owner; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1535 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1536 | /* Best path selection. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1537 | bgp_best_selection (bgp, rn, &old_and_new, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1538 | new_select = old_and_new.new; |
| 1539 | old_select = old_and_new.old; |
| 1540 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1541 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1542 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1543 | if (rsclient->group) |
| 1544 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1545 | { |
| 1546 | /* Nothing to do. */ |
| 1547 | if (old_select && old_select == new_select) |
| 1548 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1549 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1550 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1551 | if (old_select) |
| 1552 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
| 1553 | if (new_select) |
| 1554 | { |
| 1555 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1556 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1557 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
| 1558 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1559 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1560 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1561 | afi, safi); |
| 1562 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1563 | } |
| 1564 | else |
| 1565 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1566 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1567 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1568 | if (new_select) |
| 1569 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1570 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1571 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1572 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1573 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1574 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1575 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1576 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1577 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1578 | bgp_info_reap (rn, old_select); |
| 1579 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1580 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1581 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1582 | } |
| 1583 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1584 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1585 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1586 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1587 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1588 | struct bgp *bgp = pq->bgp; |
| 1589 | struct bgp_node *rn = pq->rn; |
| 1590 | afi_t afi = pq->afi; |
| 1591 | safi_t safi = pq->safi; |
| 1592 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1593 | struct bgp_info *new_select; |
| 1594 | struct bgp_info *old_select; |
| 1595 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1596 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1597 | struct peer *peer; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1598 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1599 | /* Best path selection. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1600 | bgp_best_selection (bgp, rn, &old_and_new, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1601 | old_select = old_and_new.old; |
| 1602 | new_select = old_and_new.new; |
| 1603 | |
| 1604 | /* Nothing to do. */ |
Daniel Walton | 325fcfb | 2015-05-19 17:58:10 -0700 | [diff] [blame] | 1605 | if (old_select && old_select == new_select |
| 1606 | && !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1607 | { |
| 1608 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1609 | { |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1610 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
| 1611 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1612 | bgp_zebra_announce (p, old_select, bgp, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1613 | |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1614 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1615 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1616 | return WQ_SUCCESS; |
| 1617 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1618 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1619 | |
Daniel Walton | 325fcfb | 2015-05-19 17:58:10 -0700 | [diff] [blame] | 1620 | /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */ |
| 1621 | UNSET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); |
| 1622 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1623 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1624 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1625 | if (new_select) |
| 1626 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1627 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1628 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1629 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1630 | } |
| 1631 | |
| 1632 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1633 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1634 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1635 | { |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1636 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1637 | } |
| 1638 | |
| 1639 | /* FIB update. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1640 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
| 1641 | ! bgp_option_check (BGP_OPT_NO_FIB))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1642 | { |
| 1643 | if (new_select |
| 1644 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1645 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1646 | bgp_zebra_announce (p, new_select, bgp, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1647 | else |
| 1648 | { |
| 1649 | /* Withdraw the route from the kernel. */ |
| 1650 | if (old_select |
| 1651 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1652 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1653 | bgp_zebra_withdraw (p, old_select, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1654 | } |
| 1655 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1656 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1657 | /* Reap old select bgp_info, if it has been removed */ |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1658 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1659 | bgp_info_reap (rn, old_select); |
| 1660 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1661 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1662 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1663 | } |
| 1664 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1665 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1666 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1667 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1668 | struct bgp_process_queue *pq = data; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1669 | struct bgp_table *table = bgp_node_table (pq->rn); |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1670 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1671 | bgp_unlock (pq->bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1672 | bgp_unlock_node (pq->rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1673 | bgp_table_unlock (table); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1674 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1675 | } |
| 1676 | |
| 1677 | static void |
| 1678 | bgp_process_queue_init (void) |
| 1679 | { |
| 1680 | bm->process_main_queue |
| 1681 | = work_queue_new (bm->master, "process_main_queue"); |
| 1682 | bm->process_rsclient_queue |
| 1683 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1684 | |
| 1685 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1686 | { |
| 1687 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1688 | exit (1); |
| 1689 | } |
| 1690 | |
| 1691 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1692 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1693 | bm->process_main_queue->spec.max_retries = 0; |
| 1694 | bm->process_main_queue->spec.hold = 50; |
| 1695 | |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1696 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
David Lamparter | d43f8b3 | 2015-03-03 08:54:54 +0100 | [diff] [blame] | 1697 | bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del; |
| 1698 | bm->process_rsclient_queue->spec.max_retries = 0; |
| 1699 | bm->process_rsclient_queue->spec.hold = 50; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1700 | } |
| 1701 | |
| 1702 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1703 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1704 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1705 | struct bgp_process_queue *pqnode; |
| 1706 | |
| 1707 | /* already scheduled for processing? */ |
| 1708 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1709 | return; |
| 1710 | |
Paul Jakma | 91b9e85 | 2015-12-01 14:32:11 +0000 | [diff] [blame] | 1711 | if (rn->info == NULL) |
| 1712 | { |
| 1713 | /* XXX: Perhaps remove before next release, after we've flushed out |
| 1714 | * any obvious cases |
| 1715 | */ |
| 1716 | assert (rn->info != NULL); |
| 1717 | char buf[PREFIX_STRLEN]; |
| 1718 | zlog_warn ("%s: Called for route_node %s with no routing entries!", |
| 1719 | __func__, |
| 1720 | prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf))); |
| 1721 | return; |
| 1722 | } |
| 1723 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1724 | if ( (bm->process_main_queue == NULL) || |
| 1725 | (bm->process_rsclient_queue == NULL) ) |
| 1726 | bgp_process_queue_init (); |
| 1727 | |
| 1728 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1729 | sizeof (struct bgp_process_queue)); |
| 1730 | if (!pqnode) |
| 1731 | return; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1732 | |
| 1733 | /* all unlocked in bgp_processq_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1734 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1735 | pqnode->rn = bgp_lock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1736 | pqnode->bgp = bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1737 | bgp_lock (bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1738 | pqnode->afi = afi; |
| 1739 | pqnode->safi = safi; |
| 1740 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1741 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1742 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1743 | case BGP_TABLE_MAIN: |
| 1744 | work_queue_add (bm->process_main_queue, pqnode); |
| 1745 | break; |
| 1746 | case BGP_TABLE_RSCLIENT: |
| 1747 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1748 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1749 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1750 | |
Stephen Hemminger | 07ff4dc | 2013-01-04 22:29:20 +0000 | [diff] [blame] | 1751 | SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1752 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1753 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1754 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1755 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1756 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1757 | { |
| 1758 | struct peer *peer; |
| 1759 | |
| 1760 | peer = THREAD_ARG (thread); |
| 1761 | peer->t_pmax_restart = NULL; |
| 1762 | |
| 1763 | if (BGP_DEBUG (events, EVENTS)) |
| 1764 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1765 | peer->host); |
| 1766 | |
| 1767 | peer_clear (peer); |
| 1768 | |
| 1769 | return 0; |
| 1770 | } |
| 1771 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1772 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1773 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1774 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1775 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1776 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1777 | return 0; |
| 1778 | |
| 1779 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1780 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1781 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1782 | && ! always) |
| 1783 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1784 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1785 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1786 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1787 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1788 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1789 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1790 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1791 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1792 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1793 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1794 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1795 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1796 | |
| 1797 | if (safi == SAFI_MPLS_VPN) |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 1798 | safi = SAFI_MPLS_LABELED_VPN; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1799 | |
| 1800 | ndata[0] = (afi >> 8); |
| 1801 | ndata[1] = afi; |
| 1802 | ndata[2] = safi; |
| 1803 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1804 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1805 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1806 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1807 | |
| 1808 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1809 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1810 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1811 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1812 | |
| 1813 | /* restart timer start */ |
| 1814 | if (peer->pmax_restart[afi][safi]) |
| 1815 | { |
| 1816 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1817 | |
| 1818 | if (BGP_DEBUG (events, EVENTS)) |
| 1819 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1820 | peer->host, peer->v_pmax_restart); |
| 1821 | |
| 1822 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1823 | peer->v_pmax_restart); |
| 1824 | } |
| 1825 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1826 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1827 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1828 | else |
| 1829 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1830 | |
| 1831 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1832 | { |
| 1833 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1834 | && ! always) |
| 1835 | return 0; |
| 1836 | |
| 1837 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1838 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1839 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1840 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1841 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1842 | } |
| 1843 | else |
| 1844 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1845 | return 0; |
| 1846 | } |
| 1847 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1848 | /* Unconditionally remove the route from the RIB, without taking |
| 1849 | * damping into consideration (eg, because the session went down) |
| 1850 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1851 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1852 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1853 | afi_t afi, safi_t safi) |
| 1854 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1855 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1856 | |
| 1857 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1858 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1859 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1860 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1861 | } |
| 1862 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1863 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1864 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1865 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1866 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1867 | int status = BGP_DAMP_NONE; |
| 1868 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1869 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1870 | * the bgp_info in the RIB for historical reference. |
| 1871 | */ |
| 1872 | 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] | 1873 | && peer->sort == BGP_PEER_EBGP) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1874 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1875 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1876 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1877 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1878 | return; |
| 1879 | } |
| 1880 | |
| 1881 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1882 | } |
| 1883 | |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 1884 | static struct bgp_info * |
| 1885 | info_make (int type, int sub_type, struct peer *peer, struct attr *attr, |
| 1886 | struct bgp_node *rn) |
| 1887 | { |
| 1888 | struct bgp_info *new; |
| 1889 | |
| 1890 | /* Make new BGP info. */ |
| 1891 | new = XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
| 1892 | new->type = type; |
| 1893 | new->sub_type = sub_type; |
| 1894 | new->peer = peer; |
| 1895 | new->attr = attr; |
| 1896 | new->uptime = bgp_clock (); |
| 1897 | new->net = rn; |
| 1898 | return new; |
| 1899 | } |
| 1900 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1901 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1902 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1903 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1904 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1905 | { |
| 1906 | struct bgp_node *rn; |
| 1907 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1908 | struct attr new_attr; |
| 1909 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1910 | struct attr *attr_new; |
| 1911 | struct attr *attr_new2; |
| 1912 | struct bgp_info *ri; |
| 1913 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1914 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1915 | char buf[SU_ADDRSTRLEN]; |
| 1916 | |
| 1917 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1918 | if (peer == rsclient) |
| 1919 | return; |
| 1920 | |
| 1921 | bgp = peer->bgp; |
| 1922 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1923 | |
| 1924 | /* Check previously received route. */ |
| 1925 | for (ri = rn->info; ri; ri = ri->next) |
| 1926 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1927 | break; |
| 1928 | |
| 1929 | /* AS path loop check. */ |
Milan Kocian | 000e157 | 2013-10-18 07:59:38 +0000 | [diff] [blame] | 1930 | if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1931 | { |
| 1932 | reason = "as-path contains our own AS;"; |
| 1933 | goto filtered; |
| 1934 | } |
| 1935 | |
| 1936 | /* Route reflector originator ID check. */ |
| 1937 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1938 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1939 | { |
| 1940 | reason = "originator is us;"; |
| 1941 | goto filtered; |
| 1942 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1943 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1944 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1945 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1946 | |
| 1947 | /* Apply export policy. */ |
| 1948 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1949 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1950 | { |
| 1951 | reason = "export-policy;"; |
| 1952 | goto filtered; |
| 1953 | } |
| 1954 | |
| 1955 | attr_new2 = bgp_attr_intern (&new_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1956 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1957 | /* Apply import policy. */ |
| 1958 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1959 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1960 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1961 | |
| 1962 | reason = "import-policy;"; |
| 1963 | goto filtered; |
| 1964 | } |
| 1965 | |
| 1966 | attr_new = bgp_attr_intern (&new_attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1967 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1968 | |
| 1969 | /* IPv4 unicast next hop check. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1970 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1971 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1972 | /* 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] | 1973 | if (new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1974 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1975 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1976 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1977 | |
| 1978 | reason = "martian next-hop;"; |
| 1979 | goto filtered; |
| 1980 | } |
| 1981 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1982 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1983 | /* If the update is implicit withdraw. */ |
| 1984 | if (ri) |
| 1985 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1986 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1987 | |
| 1988 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1989 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1990 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1991 | { |
| 1992 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1993 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1994 | |
| 1995 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1996 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1997 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1998 | peer->host, |
| 1999 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2000 | p->prefixlen, rsclient->host); |
| 2001 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2002 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2003 | bgp_attr_unintern (&attr_new); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2004 | bgp_attr_flush(&new_attr); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2005 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2006 | } |
| 2007 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2008 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2009 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2010 | bgp_info_restore (rn, ri); |
| 2011 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2012 | /* Received Logging. */ |
| 2013 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2014 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2015 | peer->host, |
| 2016 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2017 | p->prefixlen, rsclient->host); |
| 2018 | |
| 2019 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2020 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2021 | |
| 2022 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2023 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2024 | ri->attr = attr_new; |
| 2025 | |
| 2026 | /* Update MPLS tag. */ |
| 2027 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2028 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2029 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2030 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2031 | |
| 2032 | /* Process change. */ |
| 2033 | bgp_process (bgp, rn, afi, safi); |
| 2034 | bgp_unlock_node (rn); |
| 2035 | |
| 2036 | return; |
| 2037 | } |
| 2038 | |
| 2039 | /* Received Logging. */ |
| 2040 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2041 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2042 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2043 | peer->host, |
| 2044 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2045 | p->prefixlen, rsclient->host); |
| 2046 | } |
| 2047 | |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 2048 | new = info_make(type, sub_type, peer, attr_new, rn); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2049 | |
| 2050 | /* Update MPLS tag. */ |
| 2051 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2052 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2053 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2054 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2055 | |
| 2056 | /* Register new BGP information. */ |
| 2057 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2058 | |
| 2059 | /* route_node_get lock */ |
| 2060 | bgp_unlock_node (rn); |
| 2061 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2062 | /* Process change. */ |
| 2063 | bgp_process (bgp, rn, afi, safi); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2064 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2065 | return; |
| 2066 | |
| 2067 | filtered: |
| 2068 | |
| 2069 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2070 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2071 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2072 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 2073 | peer->host, |
| 2074 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2075 | p->prefixlen, rsclient->host, reason); |
| 2076 | |
| 2077 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2078 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2079 | |
| 2080 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2081 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2082 | return; |
| 2083 | } |
| 2084 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2085 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2086 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 2087 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 2088 | struct prefix_rd *prd, u_char *tag) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2089 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2090 | struct bgp_node *rn; |
| 2091 | struct bgp_info *ri; |
| 2092 | char buf[SU_ADDRSTRLEN]; |
| 2093 | |
| 2094 | if (rsclient == peer) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2095 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2096 | |
| 2097 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 2098 | |
| 2099 | /* Lookup withdrawn route. */ |
| 2100 | for (ri = rn->info; ri; ri = ri->next) |
| 2101 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2102 | break; |
| 2103 | |
| 2104 | /* Withdraw specified route from routing table. */ |
| 2105 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2106 | bgp_rib_withdraw (rn, ri, peer, afi, safi, prd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2107 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2108 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2109 | "%s Can't find the route %s/%d", peer->host, |
| 2110 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2111 | p->prefixlen); |
| 2112 | |
| 2113 | /* Unlock bgp_node_get() lock. */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2114 | bgp_unlock_node (rn); |
| 2115 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2116 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2117 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2118 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2119 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2120 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2121 | { |
| 2122 | int ret; |
| 2123 | int aspath_loop_count = 0; |
| 2124 | struct bgp_node *rn; |
| 2125 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2126 | struct attr new_attr; |
| 2127 | struct attr_extra new_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2128 | struct attr *attr_new; |
| 2129 | struct bgp_info *ri; |
| 2130 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2131 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2132 | char buf[SU_ADDRSTRLEN]; |
| 2133 | |
Lou Berger | 370b7e5 | 2016-02-04 21:29:49 -0500 | [diff] [blame] | 2134 | memset (&new_attr, 0, sizeof(struct attr)); |
| 2135 | memset (&new_extra, 0, sizeof(struct attr_extra)); |
| 2136 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2137 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2138 | 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] | 2139 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2140 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2141 | Adj-RIBs-In. */ |
Jorge Boncompte [DTI2] | 343aa82 | 2012-05-07 16:53:08 +0000 | [diff] [blame] | 2142 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2143 | && peer != bgp->peer_self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2144 | bgp_adj_in_set (rn, peer, attr); |
| 2145 | |
| 2146 | /* Check previously received route. */ |
| 2147 | for (ri = rn->info; ri; ri = ri->next) |
| 2148 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2149 | break; |
| 2150 | |
| 2151 | /* AS path local-as loop check. */ |
| 2152 | if (peer->change_local_as) |
| 2153 | { |
| 2154 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 2155 | aspath_loop_count = 1; |
| 2156 | |
| 2157 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 2158 | { |
| 2159 | reason = "as-path contains our own AS;"; |
| 2160 | goto filtered; |
| 2161 | } |
| 2162 | } |
| 2163 | |
| 2164 | /* AS path loop check. */ |
| 2165 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 2166 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2167 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2168 | > peer->allowas_in[afi][safi])) |
| 2169 | { |
| 2170 | reason = "as-path contains our own AS;"; |
| 2171 | goto filtered; |
| 2172 | } |
| 2173 | |
| 2174 | /* Route reflector originator ID check. */ |
| 2175 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2176 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2177 | { |
| 2178 | reason = "originator is us;"; |
| 2179 | goto filtered; |
| 2180 | } |
| 2181 | |
| 2182 | /* Route reflector cluster ID check. */ |
| 2183 | if (bgp_cluster_filter (peer, attr)) |
| 2184 | { |
| 2185 | reason = "reflected from the same cluster;"; |
| 2186 | goto filtered; |
| 2187 | } |
| 2188 | |
| 2189 | /* Apply incoming filter. */ |
| 2190 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2191 | { |
| 2192 | reason = "filter;"; |
| 2193 | goto filtered; |
| 2194 | } |
| 2195 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2196 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2197 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2198 | |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2199 | /* Apply incoming route-map. |
| 2200 | * NB: new_attr may now contain newly allocated values from route-map "set" |
| 2201 | * commands, so we need bgp_attr_flush in the error paths, until we intern |
| 2202 | * the attr (which takes over the memory references) */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2203 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2204 | { |
| 2205 | reason = "route-map;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2206 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2207 | goto filtered; |
| 2208 | } |
| 2209 | |
| 2210 | /* IPv4 unicast next hop check. */ |
| 2211 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2212 | { |
| 2213 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2214 | discard it. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2215 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 |
Denis Ovsienko | 8e80bdf | 2011-08-05 18:52:52 +0400 | [diff] [blame] | 2216 | && ! bgp_nexthop_onlink (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2217 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2218 | { |
| 2219 | reason = "non-connected next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2220 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2221 | goto filtered; |
| 2222 | } |
| 2223 | |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2224 | /* 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] | 2225 | must not be my own address. */ |
Jorge Boncompte [DTI2] | 10f9bf3 | 2012-05-07 16:52:52 +0000 | [diff] [blame] | 2226 | if (new_attr.nexthop.s_addr == 0 |
| 2227 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) |
| 2228 | || bgp_nexthop_self (&new_attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2229 | { |
| 2230 | reason = "martian next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2231 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2232 | goto filtered; |
| 2233 | } |
| 2234 | } |
| 2235 | |
| 2236 | attr_new = bgp_attr_intern (&new_attr); |
| 2237 | |
| 2238 | /* If the update is implicit withdraw. */ |
| 2239 | if (ri) |
| 2240 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2241 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2242 | |
| 2243 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2244 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2245 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2246 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2247 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2248 | |
| 2249 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2250 | && peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2251 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2252 | { |
| 2253 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2254 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2255 | peer->host, |
| 2256 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2257 | p->prefixlen); |
| 2258 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2259 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2260 | { |
| 2261 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2262 | bgp_process (bgp, rn, afi, safi); |
| 2263 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2264 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2265 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2266 | { |
| 2267 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2268 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2269 | "%s rcvd %s/%d...duplicate ignored", |
| 2270 | peer->host, |
| 2271 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2272 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2273 | |
| 2274 | /* graceful restart STALE flag unset. */ |
| 2275 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2276 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2277 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2278 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2279 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2280 | } |
| 2281 | |
| 2282 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2283 | bgp_attr_unintern (&attr_new); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2284 | bgp_attr_flush (&new_attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2285 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2286 | return 0; |
| 2287 | } |
| 2288 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2289 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2290 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2291 | { |
| 2292 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2293 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2294 | peer->host, |
| 2295 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2296 | p->prefixlen); |
| 2297 | bgp_info_restore (rn, ri); |
| 2298 | } |
| 2299 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2300 | /* Received Logging. */ |
| 2301 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2302 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2303 | peer->host, |
| 2304 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2305 | p->prefixlen); |
| 2306 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2307 | /* graceful restart STALE flag unset. */ |
| 2308 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2309 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2310 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2311 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2312 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2313 | |
| 2314 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2315 | * only if update is accepted, they'll increment below. |
| 2316 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2317 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2318 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2319 | /* Update bgp route dampening information. */ |
| 2320 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2321 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2322 | { |
| 2323 | /* This is implicit withdraw so we should update dampening |
| 2324 | information. */ |
| 2325 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2326 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2327 | } |
| 2328 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2329 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2330 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2331 | ri->attr = attr_new; |
| 2332 | |
| 2333 | /* Update MPLS tag. */ |
| 2334 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2335 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2336 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2337 | bgp_attr_flush (&new_attr); |
| 2338 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2339 | /* Update bgp route dampening information. */ |
| 2340 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2341 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2342 | { |
| 2343 | /* Now we do normal update dampening. */ |
| 2344 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2345 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2346 | { |
| 2347 | bgp_unlock_node (rn); |
| 2348 | return 0; |
| 2349 | } |
| 2350 | } |
| 2351 | |
| 2352 | /* Nexthop reachability check. */ |
| 2353 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2354 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2355 | && (peer->sort == BGP_PEER_IBGP |
| 2356 | || peer->sort == BGP_PEER_CONFED |
| 2357 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2358 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2359 | { |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 2360 | if (bgp_find_or_add_nexthop (afi, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2361 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2362 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2363 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2364 | } |
| 2365 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2366 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2367 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2368 | bgp_attr_flush (&new_attr); |
| 2369 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2370 | /* Process change. */ |
| 2371 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2372 | |
| 2373 | bgp_process (bgp, rn, afi, safi); |
| 2374 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2375 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2376 | return 0; |
| 2377 | } |
| 2378 | |
| 2379 | /* Received Logging. */ |
| 2380 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2381 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2382 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2383 | peer->host, |
| 2384 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2385 | p->prefixlen); |
| 2386 | } |
| 2387 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2388 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 2389 | new = info_make(type, sub_type, peer, attr_new, rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2390 | |
| 2391 | /* Update MPLS tag. */ |
| 2392 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2393 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2394 | |
| 2395 | /* Nexthop reachability check. */ |
| 2396 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2397 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2398 | && (peer->sort == BGP_PEER_IBGP |
| 2399 | || peer->sort == BGP_PEER_CONFED |
| 2400 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2401 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2402 | { |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 2403 | if (bgp_find_or_add_nexthop (afi, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2404 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2405 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2406 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2407 | } |
| 2408 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2409 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2410 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2411 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2412 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2413 | |
| 2414 | /* Register new BGP information. */ |
| 2415 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2416 | |
| 2417 | /* route_node_get lock */ |
| 2418 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2419 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2420 | bgp_attr_flush (&new_attr); |
| 2421 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2422 | /* If maximum prefix count is configured and current prefix |
| 2423 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2424 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2425 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2426 | |
| 2427 | /* Process change. */ |
| 2428 | bgp_process (bgp, rn, afi, safi); |
| 2429 | |
| 2430 | return 0; |
| 2431 | |
| 2432 | /* This BGP update is filtered. Log the reason then update BGP |
| 2433 | entry. */ |
| 2434 | filtered: |
| 2435 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2436 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2437 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2438 | peer->host, |
| 2439 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2440 | p->prefixlen, reason); |
| 2441 | |
| 2442 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2443 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2444 | |
| 2445 | bgp_unlock_node (rn); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2446 | bgp_attr_flush (&new_attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2447 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2448 | return 0; |
| 2449 | } |
| 2450 | |
| 2451 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2452 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2453 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2454 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2455 | { |
| 2456 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2457 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2458 | struct bgp *bgp; |
| 2459 | int ret; |
| 2460 | |
| 2461 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2462 | soft_reconfig); |
| 2463 | |
| 2464 | bgp = peer->bgp; |
| 2465 | |
| 2466 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2467 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2468 | { |
| 2469 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2470 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2471 | sub_type, prd, tag); |
| 2472 | } |
| 2473 | |
| 2474 | return ret; |
| 2475 | } |
| 2476 | |
| 2477 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2478 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2479 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2480 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2481 | { |
| 2482 | struct bgp *bgp; |
| 2483 | char buf[SU_ADDRSTRLEN]; |
| 2484 | struct bgp_node *rn; |
| 2485 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2486 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2487 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2488 | |
| 2489 | bgp = peer->bgp; |
| 2490 | |
David Lamparter | 4584c23 | 2015-04-13 09:50:00 +0200 | [diff] [blame] | 2491 | /* Lookup node. */ |
| 2492 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
| 2493 | |
| 2494 | /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all |
| 2495 | * routes that are filtered. This tanks out Quagga RS pretty badly due to |
| 2496 | * the iteration over all RS clients. |
| 2497 | * Since we need to remove the entry from adj_in anyway, do that first and |
| 2498 | * if there was no entry, we don't need to do anything more. */ |
| 2499 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2500 | && peer != bgp->peer_self) |
| 2501 | if (!bgp_adj_in_unset (rn, peer)) |
| 2502 | { |
| 2503 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2504 | zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d " |
| 2505 | "not in adj-in", peer->host, |
| 2506 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2507 | p->prefixlen); |
| 2508 | bgp_unlock_node (rn); |
| 2509 | return 0; |
| 2510 | } |
| 2511 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2512 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2513 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2514 | { |
| 2515 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2516 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2517 | } |
| 2518 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2519 | /* Logging. */ |
| 2520 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2521 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2522 | peer->host, |
| 2523 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2524 | p->prefixlen); |
| 2525 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2526 | /* Lookup withdrawn route. */ |
| 2527 | for (ri = rn->info; ri; ri = ri->next) |
| 2528 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2529 | break; |
| 2530 | |
| 2531 | /* Withdraw specified route from routing table. */ |
| 2532 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2533 | bgp_rib_withdraw (rn, ri, peer, afi, safi, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2534 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2535 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2536 | "%s Can't find the route %s/%d", peer->host, |
| 2537 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2538 | p->prefixlen); |
| 2539 | |
| 2540 | /* Unlock bgp_node_get() lock. */ |
| 2541 | bgp_unlock_node (rn); |
| 2542 | |
| 2543 | return 0; |
| 2544 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2545 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2546 | void |
| 2547 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2548 | { |
| 2549 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 2550 | struct attr attr; |
Jorge Boncompte [DTI2] | 577ac57 | 2012-05-07 16:53:06 +0000 | [diff] [blame] | 2551 | struct aspath *aspath; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2552 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2553 | struct peer *from; |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2554 | struct bgp_node *rn; |
| 2555 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2556 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2557 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2558 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2559 | return; |
| 2560 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2561 | bgp = peer->bgp; |
| 2562 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2563 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2564 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2565 | aspath = attr.aspath; |
| 2566 | attr.local_pref = bgp->default_local_pref; |
| 2567 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2568 | |
| 2569 | if (afi == AFI_IP) |
| 2570 | str2prefix ("0.0.0.0/0", &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2571 | else if (afi == AFI_IP6) |
| 2572 | { |
Jorge Boncompte [DTI2] | 6182d65 | 2012-05-07 16:53:02 +0000 | [diff] [blame] | 2573 | struct attr_extra *ae = attr.extra; |
| 2574 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2575 | str2prefix ("::/0", &p); |
| 2576 | |
| 2577 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2578 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
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 = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2581 | |
| 2582 | /* If the peer is on shared nextwork and we have link-local |
| 2583 | nexthop set it. */ |
| 2584 | if (peer->shared_network |
| 2585 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2586 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2587 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2588 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2589 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2590 | } |
| 2591 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2592 | |
| 2593 | if (peer->default_rmap[afi][safi].name) |
| 2594 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2595 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2596 | for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn)) |
| 2597 | { |
| 2598 | for (ri = rn->info; ri; ri = ri->next) |
| 2599 | { |
| 2600 | struct attr dummy_attr; |
| 2601 | struct attr_extra dummy_extra; |
| 2602 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2603 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2604 | /* Provide dummy so the route-map can't modify the attributes */ |
| 2605 | dummy_attr.extra = &dummy_extra; |
| 2606 | bgp_attr_dup(&dummy_attr, ri->attr); |
| 2607 | info.peer = ri->peer; |
| 2608 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2609 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2610 | ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p, |
| 2611 | RMAP_BGP, &info); |
| 2612 | |
| 2613 | /* The route map might have set attributes. If we don't flush them |
| 2614 | * here, they will be leaked. */ |
| 2615 | bgp_attr_flush(&dummy_attr); |
| 2616 | if (ret != RMAP_DENYMATCH) |
| 2617 | break; |
| 2618 | } |
| 2619 | if (ret != RMAP_DENYMATCH) |
| 2620 | break; |
| 2621 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2622 | bgp->peer_self->rmap_type = 0; |
| 2623 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2624 | if (ret == RMAP_DENYMATCH) |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2625 | withdraw = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2626 | } |
| 2627 | |
| 2628 | if (withdraw) |
| 2629 | { |
| 2630 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2631 | bgp_default_withdraw_send (peer, afi, safi); |
| 2632 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2633 | } |
| 2634 | else |
| 2635 | { |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2636 | if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2637 | { |
| 2638 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2639 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2640 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2641 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2642 | |
| 2643 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2644 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2645 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2646 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2647 | static void |
| 2648 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2649 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2650 | { |
| 2651 | struct bgp_node *rn; |
| 2652 | struct bgp_info *ri; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2653 | struct attr attr; |
| 2654 | struct attr_extra extra; |
| 2655 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2656 | memset(&extra, 0, sizeof(extra)); |
| 2657 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2658 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2659 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2660 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2661 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2662 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2663 | bgp_default_originate (peer, afi, safi, 0); |
| 2664 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2665 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 2666 | attr.extra = &extra; |
| 2667 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2668 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2669 | for (ri = rn->info; ri; ri = ri->next) |
| 2670 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2671 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2672 | if ( (rsclient) ? |
| 2673 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2674 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2675 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2676 | else |
| 2677 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2678 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2679 | |
| 2680 | bgp_attr_flush_encap(&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2681 | } |
| 2682 | |
| 2683 | void |
| 2684 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2685 | { |
| 2686 | struct bgp_node *rn; |
| 2687 | struct bgp_table *table; |
| 2688 | |
| 2689 | if (peer->status != Established) |
| 2690 | return; |
| 2691 | |
| 2692 | if (! peer->afc_nego[afi][safi]) |
| 2693 | return; |
| 2694 | |
| 2695 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2696 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2697 | return; |
| 2698 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2699 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2700 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2701 | else |
| 2702 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2703 | rn = bgp_route_next(rn)) |
| 2704 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2705 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2706 | |
| 2707 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2708 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2709 | } |
| 2710 | |
| 2711 | void |
| 2712 | bgp_announce_route_all (struct peer *peer) |
| 2713 | { |
| 2714 | afi_t afi; |
| 2715 | safi_t safi; |
| 2716 | |
| 2717 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2718 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2719 | bgp_announce_route (peer, afi, safi); |
| 2720 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2721 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2722 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2723 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2724 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2725 | { |
| 2726 | struct bgp_node *rn; |
| 2727 | struct bgp_adj_in *ain; |
| 2728 | |
| 2729 | if (! table) |
| 2730 | table = rsclient->bgp->rib[afi][safi]; |
| 2731 | |
| 2732 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2733 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2734 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2735 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2736 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2737 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2738 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2739 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2740 | } |
| 2741 | } |
| 2742 | |
| 2743 | void |
| 2744 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2745 | { |
| 2746 | struct bgp_table *table; |
| 2747 | struct bgp_node *rn; |
| 2748 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2749 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2750 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2751 | |
| 2752 | else |
| 2753 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2754 | rn = bgp_route_next (rn)) |
| 2755 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2756 | { |
| 2757 | struct prefix_rd prd; |
| 2758 | prd.family = AF_UNSPEC; |
| 2759 | prd.prefixlen = 64; |
| 2760 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2761 | |
| 2762 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); |
| 2763 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2764 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2765 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2766 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2767 | 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] | 2768 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2769 | { |
| 2770 | int ret; |
| 2771 | struct bgp_node *rn; |
| 2772 | struct bgp_adj_in *ain; |
| 2773 | |
| 2774 | if (! table) |
| 2775 | table = peer->bgp->rib[afi][safi]; |
| 2776 | |
| 2777 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2778 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2779 | { |
| 2780 | if (ain->peer == peer) |
| 2781 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2782 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2783 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2784 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2785 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2786 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2787 | prd, tag, 1); |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2788 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2789 | if (ret < 0) |
| 2790 | { |
| 2791 | bgp_unlock_node (rn); |
| 2792 | return; |
| 2793 | } |
| 2794 | continue; |
| 2795 | } |
| 2796 | } |
| 2797 | } |
| 2798 | |
| 2799 | void |
| 2800 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2801 | { |
| 2802 | struct bgp_node *rn; |
| 2803 | struct bgp_table *table; |
| 2804 | |
| 2805 | if (peer->status != Established) |
| 2806 | return; |
| 2807 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2808 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2809 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2810 | else |
| 2811 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2812 | rn = bgp_route_next (rn)) |
| 2813 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2814 | { |
| 2815 | struct prefix_rd prd; |
| 2816 | prd.family = AF_UNSPEC; |
| 2817 | prd.prefixlen = 64; |
| 2818 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2819 | |
| 2820 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); |
| 2821 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2822 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2823 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2824 | |
| 2825 | struct bgp_clear_node_queue |
| 2826 | { |
| 2827 | struct bgp_node *rn; |
| 2828 | enum bgp_clear_route_type purpose; |
| 2829 | }; |
| 2830 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2831 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2832 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2833 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2834 | struct bgp_clear_node_queue *cnq = data; |
| 2835 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2836 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2837 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2838 | afi_t afi = bgp_node_table (rn)->afi; |
| 2839 | safi_t safi = bgp_node_table (rn)->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2840 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2841 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2842 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2843 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2844 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2845 | { |
| 2846 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2847 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2848 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2849 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2850 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2851 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2852 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2853 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2854 | break; |
| 2855 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2856 | return WQ_SUCCESS; |
| 2857 | } |
| 2858 | |
| 2859 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2860 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2861 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2862 | struct bgp_clear_node_queue *cnq = data; |
| 2863 | struct bgp_node *rn = cnq->rn; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2864 | struct bgp_table *table = bgp_node_table (rn); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2865 | |
| 2866 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2867 | bgp_table_unlock (table); |
| 2868 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2869 | } |
| 2870 | |
| 2871 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2872 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2873 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2874 | struct peer *peer = wq->spec.data; |
| 2875 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2876 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2877 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2878 | |
| 2879 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2880 | } |
| 2881 | |
| 2882 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2883 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2884 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2885 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2886 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2887 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2888 | #undef CLEAR_QUEUE_NAME_LEN |
| 2889 | |
| 2890 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2891 | { |
| 2892 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2893 | exit (1); |
| 2894 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2895 | peer->clear_node_queue->spec.hold = 10; |
| 2896 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2897 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2898 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2899 | peer->clear_node_queue->spec.max_retries = 0; |
| 2900 | |
| 2901 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2902 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2903 | } |
| 2904 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2905 | static void |
| 2906 | 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] | 2907 | struct bgp_table *table, struct peer *rsclient, |
| 2908 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2909 | { |
| 2910 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2911 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2912 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2913 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2914 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2915 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2916 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2917 | if (! table) |
| 2918 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2919 | |
| 2920 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2921 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2922 | struct bgp_info *ri; |
| 2923 | struct bgp_adj_in *ain; |
| 2924 | struct bgp_adj_out *aout; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2925 | |
| 2926 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2927 | * queued for every clearing peer, regardless of whether it is |
| 2928 | * relevant to the peer at hand. |
| 2929 | * |
| 2930 | * Overview: There are 3 different indices which need to be |
| 2931 | * scrubbed, potentially, when a peer is removed: |
| 2932 | * |
| 2933 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2934 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2935 | * 3 other routes visible by the peer's adj-out index |
| 2936 | * |
| 2937 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2938 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2939 | * adj-outs at our leisure. |
| 2940 | * |
| 2941 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2942 | * invisible via RIB index before peer session is allowed to be |
| 2943 | * brought back up. So one needs to know when such a 'search' is |
| 2944 | * complete. |
| 2945 | * |
| 2946 | * Ideally: |
| 2947 | * |
| 2948 | * - there'd be a single global queue or a single RIB walker |
| 2949 | * - rather than tracking which route_nodes still need to be |
| 2950 | * examined on a peer basis, we'd track which peers still |
| 2951 | * aren't cleared |
| 2952 | * |
| 2953 | * Given that our per-peer prefix-counts now should be reliable, |
| 2954 | * this may actually be achievable. It doesn't seem to be a huge |
| 2955 | * problem at this time, |
| 2956 | */ |
Jorge Boncompte [DTI2] | 24e50f2 | 2012-05-07 15:17:33 +0000 | [diff] [blame] | 2957 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2958 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2959 | { |
| 2960 | bgp_adj_in_remove (rn, ain); |
| 2961 | bgp_unlock_node (rn); |
| 2962 | break; |
| 2963 | } |
| 2964 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2965 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2966 | { |
| 2967 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2968 | bgp_unlock_node (rn); |
| 2969 | break; |
| 2970 | } |
| 2971 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2972 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2973 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2974 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2975 | struct bgp_clear_node_queue *cnq; |
| 2976 | |
| 2977 | /* both unlocked in bgp_clear_node_queue_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2978 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2979 | bgp_lock_node (rn); |
| 2980 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2981 | sizeof (struct bgp_clear_node_queue)); |
| 2982 | cnq->rn = rn; |
| 2983 | cnq->purpose = purpose; |
| 2984 | work_queue_add (peer->clear_node_queue, cnq); |
| 2985 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2986 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2987 | } |
| 2988 | return; |
| 2989 | } |
| 2990 | |
| 2991 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2992 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2993 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2994 | { |
| 2995 | struct bgp_node *rn; |
| 2996 | struct bgp_table *table; |
| 2997 | struct peer *rsclient; |
| 2998 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2999 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3000 | if (peer->clear_node_queue == NULL) |
| 3001 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3002 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 3003 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 3004 | * Idle until it receives a Clearing_Completed event. This protects |
| 3005 | * against peers which flap faster than we can we clear, which could |
| 3006 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3007 | * |
| 3008 | * a) race with routes from the new session being installed before |
| 3009 | * clear_route_node visits the node (to delete the route of that |
| 3010 | * peer) |
| 3011 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 3012 | * on the process_main queue. Fast-flapping could cause that queue |
| 3013 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3014 | */ |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3015 | |
| 3016 | /* lock peer in assumption that clear-node-queue will get nodes; if so, |
| 3017 | * the unlock will happen upon work-queue completion; other wise, the |
| 3018 | * unlock happens at the end of this function. |
| 3019 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 3020 | if (!peer->clear_node_queue->thread) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3021 | peer_lock (peer); /* bgp_clear_node_complete */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3022 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3023 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3024 | case BGP_CLEAR_ROUTE_NORMAL: |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3025 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3026 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 3027 | else |
| 3028 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 3029 | rn = bgp_route_next (rn)) |
| 3030 | if ((table = rn->info) != NULL) |
| 3031 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 3032 | |
| 3033 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 3034 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 3035 | PEER_FLAG_RSERVER_CLIENT)) |
| 3036 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 3037 | break; |
| 3038 | |
| 3039 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3040 | /* |
| 3041 | * gpz 091009: TBD why don't we have special handling for |
| 3042 | * SAFI_MPLS_VPN here in the original quagga code? |
| 3043 | * (and, by extension, for SAFI_ENCAP) |
| 3044 | */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3045 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 3046 | break; |
| 3047 | |
| 3048 | default: |
| 3049 | assert (0); |
| 3050 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3051 | } |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3052 | |
| 3053 | /* unlock if no nodes got added to the clear-node-queue. */ |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 3054 | if (!peer->clear_node_queue->thread) |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3055 | peer_unlock (peer); |
| 3056 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3057 | } |
| 3058 | |
| 3059 | void |
| 3060 | bgp_clear_route_all (struct peer *peer) |
| 3061 | { |
| 3062 | afi_t afi; |
| 3063 | safi_t safi; |
| 3064 | |
| 3065 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3066 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3067 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3068 | } |
| 3069 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3070 | /* |
| 3071 | * Finish freeing things when exiting |
| 3072 | */ |
| 3073 | static void |
| 3074 | bgp_drain_workqueue_immediate (struct work_queue *wq) |
| 3075 | { |
| 3076 | if (!wq) |
| 3077 | return; |
| 3078 | |
| 3079 | if (!wq->thread) |
| 3080 | { |
| 3081 | /* |
| 3082 | * no thread implies no queued items |
| 3083 | */ |
| 3084 | assert(!wq->items->count); |
| 3085 | return; |
| 3086 | } |
| 3087 | |
| 3088 | while (wq->items->count) |
| 3089 | { |
| 3090 | if (wq->thread) |
| 3091 | thread_cancel(wq->thread); |
| 3092 | work_queue_run(wq->thread); |
| 3093 | } |
| 3094 | } |
| 3095 | |
| 3096 | /* |
| 3097 | * Special function to process clear node queue when bgpd is exiting |
| 3098 | * and the thread scheduler is no longer running. |
| 3099 | */ |
| 3100 | void |
| 3101 | bgp_peer_clear_node_queue_drain_immediate(struct peer *peer) |
| 3102 | { |
| 3103 | if (!peer) |
| 3104 | return; |
| 3105 | |
| 3106 | bgp_drain_workqueue_immediate(peer->clear_node_queue); |
| 3107 | } |
| 3108 | |
| 3109 | /* |
| 3110 | * The work queues are not specific to a BGP instance, but the |
| 3111 | * items in them refer to BGP instances, so this should be called |
| 3112 | * before each BGP instance is deleted. |
| 3113 | */ |
| 3114 | void |
| 3115 | bgp_process_queues_drain_immediate(void) |
| 3116 | { |
| 3117 | bgp_drain_workqueue_immediate(bm->process_main_queue); |
| 3118 | bgp_drain_workqueue_immediate(bm->process_rsclient_queue); |
| 3119 | } |
| 3120 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3121 | void |
| 3122 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 3123 | { |
| 3124 | struct bgp_table *table; |
| 3125 | struct bgp_node *rn; |
| 3126 | struct bgp_adj_in *ain; |
| 3127 | |
| 3128 | table = peer->bgp->rib[afi][safi]; |
| 3129 | |
| 3130 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3131 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 3132 | if (ain->peer == peer) |
| 3133 | { |
| 3134 | bgp_adj_in_remove (rn, ain); |
| 3135 | bgp_unlock_node (rn); |
| 3136 | break; |
| 3137 | } |
| 3138 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 3139 | |
| 3140 | void |
| 3141 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 3142 | { |
| 3143 | struct bgp_node *rn; |
| 3144 | struct bgp_info *ri; |
| 3145 | struct bgp_table *table; |
| 3146 | |
| 3147 | table = peer->bgp->rib[afi][safi]; |
| 3148 | |
| 3149 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3150 | { |
| 3151 | for (ri = rn->info; ri; ri = ri->next) |
| 3152 | if (ri->peer == peer) |
| 3153 | { |
| 3154 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 3155 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3156 | break; |
| 3157 | } |
| 3158 | } |
| 3159 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3160 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3161 | static void |
| 3162 | bgp_cleanup_table(struct bgp_table *table, safi_t safi) |
| 3163 | { |
| 3164 | struct bgp_node *rn; |
| 3165 | struct bgp_info *ri; |
| 3166 | struct bgp_info *next; |
| 3167 | |
| 3168 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3169 | for (ri = rn->info; ri; ri = next) |
| 3170 | { |
| 3171 | next = ri->next; |
| 3172 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3173 | && ri->type == ZEBRA_ROUTE_BGP |
| 3174 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 3175 | bgp_zebra_withdraw (&rn->p, ri, safi); |
| 3176 | } |
| 3177 | } |
| 3178 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3179 | /* Delete all kernel routes. */ |
| 3180 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3181 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3182 | { |
| 3183 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3184 | struct listnode *node, *nnode; |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3185 | afi_t afi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3186 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3187 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3188 | { |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3189 | for (afi = AFI_IP; afi < AFI_MAX; ++afi) |
| 3190 | { |
| 3191 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3192 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3193 | bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3194 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3195 | /* |
| 3196 | * VPN and ENCAP tables are two-level (RD is top level) |
| 3197 | */ |
| 3198 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn; |
| 3199 | rn = bgp_route_next (rn)) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3200 | { |
| 3201 | if (rn->info) |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3202 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3203 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN); |
| 3204 | bgp_table_finish ((struct bgp_table **)&(rn->info)); |
| 3205 | rn->info = NULL; |
| 3206 | bgp_unlock_node(rn); |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3207 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3208 | } |
| 3209 | |
| 3210 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn; |
| 3211 | rn = bgp_route_next (rn)) |
| 3212 | { |
| 3213 | if (rn->info) |
| 3214 | { |
| 3215 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP); |
| 3216 | bgp_table_finish ((struct bgp_table **)&(rn->info)); |
| 3217 | rn->info = NULL; |
| 3218 | bgp_unlock_node(rn); |
| 3219 | } |
| 3220 | } |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3221 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3222 | } |
| 3223 | } |
| 3224 | |
| 3225 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3226 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3227 | { |
| 3228 | vty_reset (); |
| 3229 | bgp_zclient_reset (); |
| 3230 | access_list_reset (); |
| 3231 | prefix_list_reset (); |
| 3232 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3233 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3234 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3235 | value. */ |
| 3236 | int |
Paul Jakma | 518a4b7 | 2016-02-04 13:27:04 +0000 | [diff] [blame] | 3237 | bgp_nlri_parse_ip (struct peer *peer, struct attr *attr, |
| 3238 | struct bgp_nlri *packet) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3239 | { |
| 3240 | u_char *pnt; |
| 3241 | u_char *lim; |
| 3242 | struct prefix p; |
| 3243 | int psize; |
| 3244 | int ret; |
| 3245 | |
| 3246 | /* Check peer status. */ |
| 3247 | if (peer->status != Established) |
| 3248 | return 0; |
| 3249 | |
| 3250 | pnt = packet->nlri; |
| 3251 | lim = pnt + packet->length; |
| 3252 | |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3253 | /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for |
| 3254 | syntactic validity. If the field is syntactically incorrect, |
| 3255 | then the Error Subcode is set to Invalid Network Field. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3256 | for (; pnt < lim; pnt += psize) |
| 3257 | { |
| 3258 | /* Clear prefix structure. */ |
| 3259 | memset (&p, 0, sizeof (struct prefix)); |
| 3260 | |
| 3261 | /* Fetch prefix length. */ |
| 3262 | p.prefixlen = *pnt++; |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3263 | /* afi/safi validity already verified by caller, bgp_update_receive */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3264 | p.family = afi2family (packet->afi); |
| 3265 | |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3266 | /* Prefix length check. */ |
| 3267 | if (p.prefixlen > prefix_blen (&p) * 8) |
| 3268 | { |
| 3269 | plog_err (peer->log, |
| 3270 | "%s [Error] Update packet error" |
| 3271 | " (wrong prefix length %u for afi %u)", |
| 3272 | peer->host, p.prefixlen, packet->afi); |
| 3273 | return -1; |
| 3274 | } |
| 3275 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3276 | /* Packet size overflow check. */ |
| 3277 | psize = PSIZE (p.prefixlen); |
| 3278 | |
| 3279 | /* When packet overflow occur return immediately. */ |
| 3280 | if (pnt + psize > lim) |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3281 | { |
| 3282 | plog_err (peer->log, |
| 3283 | "%s [Error] Update packet error" |
| 3284 | " (prefix length %u overflows packet)", |
| 3285 | peer->host, p.prefixlen); |
| 3286 | return -1; |
| 3287 | } |
| 3288 | |
| 3289 | /* Defensive coding, double-check the psize fits in a struct prefix */ |
| 3290 | if (psize > (ssize_t) sizeof(p.u)) |
| 3291 | { |
| 3292 | plog_err (peer->log, |
| 3293 | "%s [Error] Update packet error" |
| 3294 | " (prefix length %u too large for prefix storage %zu!?!!", |
| 3295 | peer->host, p.prefixlen, sizeof(p.u)); |
| 3296 | return -1; |
| 3297 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3298 | |
| 3299 | /* Fetch prefix from NLRI packet. */ |
| 3300 | memcpy (&p.u.prefix, pnt, psize); |
| 3301 | |
| 3302 | /* Check address. */ |
| 3303 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3304 | { |
| 3305 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3306 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3307 | /* |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3308 | * From RFC4271 Section 6.3: |
| 3309 | * |
| 3310 | * If a prefix in the NLRI field is semantically incorrect |
| 3311 | * (e.g., an unexpected multicast IP address), an error SHOULD |
| 3312 | * be logged locally, and the prefix SHOULD be ignored. |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3313 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3314 | zlog (peer->log, LOG_ERR, |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3315 | "%s: IPv4 unicast NLRI is multicast address %s, ignoring", |
| 3316 | peer->host, inet_ntoa (p.u.prefix4)); |
| 3317 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3318 | } |
| 3319 | } |
| 3320 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3321 | /* Check address. */ |
| 3322 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3323 | { |
| 3324 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3325 | { |
| 3326 | char buf[BUFSIZ]; |
| 3327 | |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3328 | zlog (peer->log, LOG_ERR, |
| 3329 | "%s: IPv6 unicast NLRI is link-local address %s, ignoring", |
| 3330 | peer->host, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3331 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3332 | continue; |
| 3333 | } |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3334 | if (IN6_IS_ADDR_MULTICAST (&p.u.prefix6)) |
| 3335 | { |
| 3336 | char buf[BUFSIZ]; |
| 3337 | |
| 3338 | zlog (peer->log, LOG_ERR, |
| 3339 | "%s: IPv6 unicast NLRI is multicast address %s, ignoring", |
| 3340 | peer->host, |
| 3341 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3342 | continue; |
| 3343 | } |
| 3344 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3345 | |
| 3346 | /* Normal process. */ |
| 3347 | if (attr) |
| 3348 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3349 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3350 | else |
| 3351 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3352 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3353 | |
| 3354 | /* Address family configuration mismatch or maximum-prefix count |
| 3355 | overflow. */ |
| 3356 | if (ret < 0) |
| 3357 | return -1; |
| 3358 | } |
| 3359 | |
| 3360 | /* Packet length consistency check. */ |
| 3361 | if (pnt != lim) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3362 | { |
| 3363 | plog_err (peer->log, |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3364 | "%s [Error] Update packet error" |
| 3365 | " (prefix length mismatch with total length)", |
| 3366 | peer->host); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3367 | return -1; |
| 3368 | } |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3369 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3370 | return 0; |
| 3371 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3372 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3373 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3374 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3375 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3376 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3377 | } |
| 3378 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3379 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3380 | bgp_static_free (struct bgp_static *bgp_static) |
| 3381 | { |
| 3382 | if (bgp_static->rmap.name) |
| 3383 | free (bgp_static->rmap.name); |
| 3384 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3385 | } |
| 3386 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3387 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3388 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3389 | struct prefix *p, afi_t afi, safi_t safi) |
| 3390 | { |
| 3391 | struct bgp_node *rn; |
| 3392 | struct bgp_info *ri; |
| 3393 | |
| 3394 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3395 | |
| 3396 | /* Check selected route and self inserted route. */ |
| 3397 | for (ri = rn->info; ri; ri = ri->next) |
| 3398 | if (ri->peer == bgp->peer_self |
| 3399 | && ri->type == ZEBRA_ROUTE_BGP |
| 3400 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3401 | break; |
| 3402 | |
| 3403 | /* Withdraw static BGP route from routing table. */ |
| 3404 | if (ri) |
| 3405 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3406 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3407 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3408 | } |
| 3409 | |
| 3410 | /* Unlock bgp_node_lookup. */ |
| 3411 | bgp_unlock_node (rn); |
| 3412 | } |
| 3413 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3414 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3415 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3416 | struct bgp_static *bgp_static, |
| 3417 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3418 | { |
| 3419 | struct bgp_node *rn; |
| 3420 | struct bgp_info *ri; |
| 3421 | struct bgp_info *new; |
| 3422 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3423 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3424 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3425 | struct attr new_attr; |
| 3426 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3427 | struct bgp *bgp; |
| 3428 | int ret; |
| 3429 | char buf[SU_ADDRSTRLEN]; |
| 3430 | |
| 3431 | bgp = rsclient->bgp; |
| 3432 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3433 | assert (bgp_static); |
| 3434 | if (!bgp_static) |
| 3435 | return; |
| 3436 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3437 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3438 | |
| 3439 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3440 | |
| 3441 | attr.nexthop = bgp_static->igpnexthop; |
| 3442 | attr.med = bgp_static->igpmetric; |
| 3443 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3444 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3445 | if (bgp_static->atomic) |
| 3446 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3447 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3448 | /* Apply network route-map for export to this rsclient. */ |
| 3449 | if (bgp_static->rmap.name) |
| 3450 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3451 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3452 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3453 | info.attr = &attr_tmp; |
| 3454 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3455 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3456 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3457 | |
| 3458 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3459 | |
| 3460 | rsclient->rmap_type = 0; |
| 3461 | |
| 3462 | if (ret == RMAP_DENYMATCH) |
| 3463 | { |
| 3464 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3465 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3466 | |
| 3467 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3468 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3469 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3470 | bgp_attr_extra_free (&attr); |
| 3471 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3472 | return; |
| 3473 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3474 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3475 | } |
| 3476 | else |
| 3477 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3478 | |
| 3479 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3480 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3481 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3482 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3483 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3484 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3485 | == RMAP_DENY) |
| 3486 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3487 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3488 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3489 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3490 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3491 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3492 | p->prefixlen, rsclient->host); |
| 3493 | |
| 3494 | bgp->peer_self->rmap_type = 0; |
| 3495 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3496 | bgp_attr_unintern (&attr_new); |
| 3497 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3498 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3499 | |
| 3500 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3501 | |
| 3502 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3503 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3504 | |
| 3505 | bgp->peer_self->rmap_type = 0; |
| 3506 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3507 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3508 | attr_new = bgp_attr_intern (&new_attr); |
| 3509 | |
| 3510 | for (ri = rn->info; ri; ri = ri->next) |
| 3511 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3512 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3513 | break; |
| 3514 | |
| 3515 | if (ri) |
| 3516 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3517 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3518 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3519 | { |
| 3520 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3521 | bgp_attr_unintern (&attr_new); |
| 3522 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3523 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3524 | return; |
| 3525 | } |
| 3526 | else |
| 3527 | { |
| 3528 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3529 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3530 | |
| 3531 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3532 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3533 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3534 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3535 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3536 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3537 | |
| 3538 | /* Process change. */ |
| 3539 | bgp_process (bgp, rn, afi, safi); |
| 3540 | bgp_unlock_node (rn); |
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 | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3543 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3544 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3545 | } |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3546 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3547 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3548 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, |
| 3549 | attr_new, rn); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3550 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3551 | |
| 3552 | /* Register new BGP information. */ |
| 3553 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3554 | |
| 3555 | /* route_node_get lock */ |
| 3556 | bgp_unlock_node (rn); |
| 3557 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3558 | /* Process change. */ |
| 3559 | bgp_process (bgp, rn, afi, safi); |
| 3560 | |
| 3561 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3562 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3563 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3564 | } |
| 3565 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3566 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3567 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3568 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3569 | { |
| 3570 | struct bgp_node *rn; |
| 3571 | struct bgp_info *ri; |
| 3572 | struct bgp_info *new; |
| 3573 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3574 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3575 | struct attr *attr_new; |
| 3576 | int ret; |
| 3577 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3578 | assert (bgp_static); |
| 3579 | if (!bgp_static) |
| 3580 | return; |
| 3581 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3582 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3583 | |
| 3584 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3585 | |
| 3586 | attr.nexthop = bgp_static->igpnexthop; |
| 3587 | attr.med = bgp_static->igpmetric; |
| 3588 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3589 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3590 | if (bgp_static->atomic) |
| 3591 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3592 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3593 | /* Apply route-map. */ |
| 3594 | if (bgp_static->rmap.name) |
| 3595 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3596 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3597 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3598 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3599 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3600 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3601 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3602 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3603 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3604 | bgp->peer_self->rmap_type = 0; |
| 3605 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3606 | if (ret == RMAP_DENYMATCH) |
| 3607 | { |
| 3608 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3609 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3610 | |
| 3611 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3612 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3613 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3614 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3615 | return; |
| 3616 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3617 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3618 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3619 | else |
| 3620 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3621 | |
| 3622 | for (ri = rn->info; ri; ri = ri->next) |
| 3623 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3624 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3625 | break; |
| 3626 | |
| 3627 | if (ri) |
| 3628 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3629 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3630 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3631 | { |
| 3632 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3633 | bgp_attr_unintern (&attr_new); |
| 3634 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3635 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3636 | return; |
| 3637 | } |
| 3638 | else |
| 3639 | { |
| 3640 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3641 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3642 | |
| 3643 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3644 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3645 | bgp_info_restore(rn, ri); |
| 3646 | else |
| 3647 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3648 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3649 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3650 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3651 | |
| 3652 | /* Process change. */ |
| 3653 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3654 | bgp_process (bgp, rn, afi, safi); |
| 3655 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3656 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3657 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3658 | return; |
| 3659 | } |
| 3660 | } |
| 3661 | |
| 3662 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3663 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, attr_new, |
| 3664 | rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3665 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3666 | |
| 3667 | /* Aggregate address increment. */ |
| 3668 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3669 | |
| 3670 | /* Register new BGP information. */ |
| 3671 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3672 | |
| 3673 | /* route_node_get lock */ |
| 3674 | bgp_unlock_node (rn); |
| 3675 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3676 | /* Process change. */ |
| 3677 | bgp_process (bgp, rn, afi, safi); |
| 3678 | |
| 3679 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3680 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3681 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3682 | } |
| 3683 | |
| 3684 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3685 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3686 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3687 | { |
| 3688 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3689 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3690 | |
| 3691 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3692 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3693 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3694 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3695 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3696 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3697 | } |
| 3698 | } |
| 3699 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3700 | void |
| 3701 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3702 | safi_t safi) |
| 3703 | { |
| 3704 | struct bgp_node *rn; |
| 3705 | struct bgp_info *ri; |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3706 | struct bgp_info *new; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3707 | |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3708 | /* Make new BGP info. */ |
| 3709 | rn = bgp_node_get (bgp->rib[afi][safi], p); |
| 3710 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, |
| 3711 | bgp_attr_default_intern(BGP_ORIGIN_IGP), rn); |
| 3712 | |
| 3713 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3714 | |
| 3715 | /* Check selected route and self inserted route. */ |
| 3716 | for (ri = rn->info; ri; ri = ri->next) |
| 3717 | if (ri->peer == bgp->peer_self |
| 3718 | && ri->type == ZEBRA_ROUTE_BGP |
| 3719 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3720 | break; |
| 3721 | |
| 3722 | /* Withdraw static BGP route from routing table. */ |
| 3723 | if (ri) |
| 3724 | { |
| 3725 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3726 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3727 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3728 | } |
| 3729 | |
| 3730 | /* Unlock bgp_node_lookup. */ |
| 3731 | bgp_unlock_node (rn); |
| 3732 | } |
| 3733 | |
| 3734 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3735 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3736 | { |
| 3737 | struct bgp_static *bgp_static; |
| 3738 | struct bgp *bgp; |
| 3739 | struct bgp_node *rn; |
| 3740 | struct prefix *p; |
| 3741 | |
| 3742 | bgp = rsclient->bgp; |
| 3743 | |
| 3744 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3745 | if ((bgp_static = rn->info) != NULL) |
| 3746 | { |
| 3747 | p = &rn->p; |
| 3748 | |
| 3749 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3750 | afi, safi); |
| 3751 | } |
| 3752 | } |
| 3753 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3754 | /* |
| 3755 | * Used for SAFI_MPLS_VPN and SAFI_ENCAP |
| 3756 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3757 | static void |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3758 | bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3759 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3760 | { |
| 3761 | struct bgp_node *rn; |
| 3762 | struct bgp_info *ri; |
| 3763 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3764 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3765 | |
| 3766 | /* Check selected route and self inserted route. */ |
| 3767 | for (ri = rn->info; ri; ri = ri->next) |
| 3768 | if (ri->peer == bgp->peer_self |
| 3769 | && ri->type == ZEBRA_ROUTE_BGP |
| 3770 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3771 | break; |
| 3772 | |
| 3773 | /* Withdraw static BGP route from routing table. */ |
| 3774 | if (ri) |
| 3775 | { |
| 3776 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3777 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3778 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3779 | } |
| 3780 | |
| 3781 | /* Unlock bgp_node_lookup. */ |
| 3782 | bgp_unlock_node (rn); |
| 3783 | } |
| 3784 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3785 | static void |
| 3786 | bgp_static_update_safi (struct bgp *bgp, struct prefix *p, |
| 3787 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3788 | { |
| 3789 | struct bgp_node *rn; |
| 3790 | struct bgp_info *new; |
| 3791 | struct attr *attr_new; |
| 3792 | struct attr attr = { 0 }; |
| 3793 | struct bgp_info *ri; |
| 3794 | |
| 3795 | assert (bgp_static); |
| 3796 | |
| 3797 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd); |
| 3798 | |
| 3799 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 3800 | |
| 3801 | attr.nexthop = bgp_static->igpnexthop; |
| 3802 | attr.med = bgp_static->igpmetric; |
| 3803 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 3804 | |
| 3805 | /* Apply route-map. */ |
| 3806 | if (bgp_static->rmap.name) |
| 3807 | { |
| 3808 | struct attr attr_tmp = attr; |
| 3809 | struct bgp_info info; |
| 3810 | int ret; |
| 3811 | |
| 3812 | info.peer = bgp->peer_self; |
| 3813 | info.attr = &attr_tmp; |
| 3814 | |
| 3815 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3816 | |
| 3817 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3818 | |
| 3819 | bgp->peer_self->rmap_type = 0; |
| 3820 | |
| 3821 | if (ret == RMAP_DENYMATCH) |
| 3822 | { |
| 3823 | /* Free uninterned attribute. */ |
| 3824 | bgp_attr_flush (&attr_tmp); |
| 3825 | |
| 3826 | /* Unintern original. */ |
| 3827 | aspath_unintern (&attr.aspath); |
| 3828 | bgp_attr_extra_free (&attr); |
| 3829 | bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd, |
| 3830 | bgp_static->tag); |
| 3831 | return; |
| 3832 | } |
| 3833 | |
| 3834 | attr_new = bgp_attr_intern (&attr_tmp); |
| 3835 | } |
| 3836 | else |
| 3837 | { |
| 3838 | attr_new = bgp_attr_intern (&attr); |
| 3839 | } |
| 3840 | |
| 3841 | for (ri = rn->info; ri; ri = ri->next) |
| 3842 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3843 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3844 | break; |
| 3845 | |
| 3846 | if (ri) |
| 3847 | { |
| 3848 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3849 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3850 | { |
| 3851 | bgp_unlock_node (rn); |
| 3852 | bgp_attr_unintern (&attr_new); |
| 3853 | aspath_unintern (&attr.aspath); |
| 3854 | bgp_attr_extra_free (&attr); |
| 3855 | return; |
| 3856 | } |
| 3857 | else |
| 3858 | { |
| 3859 | /* The attribute is changed. */ |
| 3860 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
| 3861 | |
| 3862 | /* Rewrite BGP route information. */ |
| 3863 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3864 | bgp_info_restore(rn, ri); |
| 3865 | else |
| 3866 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 3867 | bgp_attr_unintern (&ri->attr); |
| 3868 | ri->attr = attr_new; |
| 3869 | ri->uptime = bgp_clock (); |
| 3870 | |
| 3871 | /* Process change. */ |
| 3872 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3873 | bgp_process (bgp, rn, afi, safi); |
| 3874 | bgp_unlock_node (rn); |
| 3875 | aspath_unintern (&attr.aspath); |
| 3876 | bgp_attr_extra_free (&attr); |
| 3877 | return; |
| 3878 | } |
| 3879 | } |
| 3880 | |
| 3881 | |
| 3882 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3883 | new = info_make (ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, |
| 3884 | attr_new, rn); |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3885 | SET_FLAG (new->flags, BGP_INFO_VALID); |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3886 | new->extra = bgp_info_extra_new(); |
| 3887 | memcpy (new->extra->tag, bgp_static->tag, 3); |
| 3888 | |
| 3889 | /* Aggregate address increment. */ |
| 3890 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3891 | |
| 3892 | /* Register new BGP information. */ |
| 3893 | bgp_info_add (rn, new); |
| 3894 | |
| 3895 | /* route_node_get lock */ |
| 3896 | bgp_unlock_node (rn); |
| 3897 | |
| 3898 | /* Process change. */ |
| 3899 | bgp_process (bgp, rn, afi, safi); |
| 3900 | |
| 3901 | /* Unintern original. */ |
| 3902 | aspath_unintern (&attr.aspath); |
| 3903 | bgp_attr_extra_free (&attr); |
| 3904 | } |
| 3905 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3906 | /* Configure static BGP network. When user don't run zebra, static |
| 3907 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3908 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3909 | 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] | 3910 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3911 | { |
| 3912 | int ret; |
| 3913 | struct prefix p; |
| 3914 | struct bgp_static *bgp_static; |
| 3915 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3916 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3917 | |
| 3918 | /* Convert IP prefix string to struct prefix. */ |
| 3919 | ret = str2prefix (ip_str, &p); |
| 3920 | if (! ret) |
| 3921 | { |
| 3922 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3923 | return CMD_WARNING; |
| 3924 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3925 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3926 | { |
| 3927 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3928 | VTY_NEWLINE); |
| 3929 | return CMD_WARNING; |
| 3930 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3931 | |
| 3932 | apply_mask (&p); |
| 3933 | |
| 3934 | /* Set BGP static route configuration. */ |
| 3935 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3936 | |
| 3937 | if (rn->info) |
| 3938 | { |
| 3939 | /* Configuration change. */ |
| 3940 | bgp_static = rn->info; |
| 3941 | |
| 3942 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3943 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 3944 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3945 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3946 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3947 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3948 | if (rmap) |
| 3949 | { |
| 3950 | if (bgp_static->rmap.name) |
| 3951 | free (bgp_static->rmap.name); |
| 3952 | bgp_static->rmap.name = strdup (rmap); |
| 3953 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3954 | } |
| 3955 | else |
| 3956 | { |
| 3957 | if (bgp_static->rmap.name) |
| 3958 | free (bgp_static->rmap.name); |
| 3959 | bgp_static->rmap.name = NULL; |
| 3960 | bgp_static->rmap.map = NULL; |
| 3961 | bgp_static->valid = 0; |
| 3962 | } |
| 3963 | bgp_unlock_node (rn); |
| 3964 | } |
| 3965 | else |
| 3966 | { |
| 3967 | /* New configuration. */ |
| 3968 | bgp_static = bgp_static_new (); |
| 3969 | bgp_static->backdoor = backdoor; |
| 3970 | bgp_static->valid = 0; |
| 3971 | bgp_static->igpmetric = 0; |
| 3972 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3973 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3974 | if (rmap) |
| 3975 | { |
| 3976 | if (bgp_static->rmap.name) |
| 3977 | free (bgp_static->rmap.name); |
| 3978 | bgp_static->rmap.name = strdup (rmap); |
| 3979 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3980 | } |
| 3981 | rn->info = bgp_static; |
| 3982 | } |
| 3983 | |
| 3984 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3985 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3986 | { |
| 3987 | bgp_static->valid = 1; |
| 3988 | |
| 3989 | if (need_update) |
| 3990 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3991 | |
| 3992 | if (! bgp_static->backdoor) |
| 3993 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3994 | } |
| 3995 | |
| 3996 | return CMD_SUCCESS; |
| 3997 | } |
| 3998 | |
| 3999 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4000 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4001 | 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] | 4002 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4003 | { |
| 4004 | int ret; |
| 4005 | struct prefix p; |
| 4006 | struct bgp_static *bgp_static; |
| 4007 | struct bgp_node *rn; |
| 4008 | |
| 4009 | /* Convert IP prefix string to struct prefix. */ |
| 4010 | ret = str2prefix (ip_str, &p); |
| 4011 | if (! ret) |
| 4012 | { |
| 4013 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4014 | return CMD_WARNING; |
| 4015 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4016 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 4017 | { |
| 4018 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 4019 | VTY_NEWLINE); |
| 4020 | return CMD_WARNING; |
| 4021 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4022 | |
| 4023 | apply_mask (&p); |
| 4024 | |
| 4025 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 4026 | if (! rn) |
| 4027 | { |
| 4028 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 4029 | VTY_NEWLINE); |
| 4030 | return CMD_WARNING; |
| 4031 | } |
| 4032 | |
| 4033 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4034 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4035 | /* Update BGP RIB. */ |
| 4036 | if (! bgp_static->backdoor) |
| 4037 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 4038 | |
| 4039 | /* Clear configuration. */ |
| 4040 | bgp_static_free (bgp_static); |
| 4041 | rn->info = NULL; |
| 4042 | bgp_unlock_node (rn); |
| 4043 | bgp_unlock_node (rn); |
| 4044 | |
| 4045 | return CMD_SUCCESS; |
| 4046 | } |
| 4047 | |
| 4048 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 4049 | instance. */ |
| 4050 | void |
| 4051 | bgp_static_delete (struct bgp *bgp) |
| 4052 | { |
| 4053 | afi_t afi; |
| 4054 | safi_t safi; |
| 4055 | struct bgp_node *rn; |
| 4056 | struct bgp_node *rm; |
| 4057 | struct bgp_table *table; |
| 4058 | struct bgp_static *bgp_static; |
| 4059 | |
| 4060 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 4061 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 4062 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 4063 | if (rn->info != NULL) |
| 4064 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4065 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4066 | { |
| 4067 | table = rn->info; |
| 4068 | |
| 4069 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 4070 | { |
| 4071 | bgp_static = rn->info; |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4072 | bgp_static_withdraw_safi (bgp, &rm->p, |
| 4073 | AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4074 | (struct prefix_rd *)&rn->p, |
| 4075 | bgp_static->tag); |
| 4076 | bgp_static_free (bgp_static); |
| 4077 | rn->info = NULL; |
| 4078 | bgp_unlock_node (rn); |
| 4079 | } |
| 4080 | } |
| 4081 | else |
| 4082 | { |
| 4083 | bgp_static = rn->info; |
| 4084 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 4085 | bgp_static_free (bgp_static); |
| 4086 | rn->info = NULL; |
| 4087 | bgp_unlock_node (rn); |
| 4088 | } |
| 4089 | } |
| 4090 | } |
| 4091 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4092 | /* |
| 4093 | * gpz 110624 |
| 4094 | * Currently this is used to set static routes for VPN and ENCAP. |
| 4095 | * I think it can probably be factored with bgp_static_set. |
| 4096 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4097 | int |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4098 | bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str, |
| 4099 | const char *rd_str, const char *tag_str, |
| 4100 | const char *rmap_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4101 | { |
| 4102 | int ret; |
| 4103 | struct prefix p; |
| 4104 | struct prefix_rd prd; |
| 4105 | struct bgp *bgp; |
| 4106 | struct bgp_node *prn; |
| 4107 | struct bgp_node *rn; |
| 4108 | struct bgp_table *table; |
| 4109 | struct bgp_static *bgp_static; |
| 4110 | u_char tag[3]; |
| 4111 | |
| 4112 | bgp = vty->index; |
| 4113 | |
| 4114 | ret = str2prefix (ip_str, &p); |
| 4115 | if (! ret) |
| 4116 | { |
| 4117 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4118 | return CMD_WARNING; |
| 4119 | } |
| 4120 | apply_mask (&p); |
| 4121 | |
| 4122 | ret = str2prefix_rd (rd_str, &prd); |
| 4123 | if (! ret) |
| 4124 | { |
| 4125 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4126 | return CMD_WARNING; |
| 4127 | } |
| 4128 | |
| 4129 | ret = str2tag (tag_str, tag); |
| 4130 | if (! ret) |
| 4131 | { |
| 4132 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4133 | return CMD_WARNING; |
| 4134 | } |
| 4135 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4136 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4137 | (struct prefix *)&prd); |
| 4138 | if (prn->info == NULL) |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4139 | prn->info = bgp_table_init (AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4140 | else |
| 4141 | bgp_unlock_node (prn); |
| 4142 | table = prn->info; |
| 4143 | |
| 4144 | rn = bgp_node_get (table, &p); |
| 4145 | |
| 4146 | if (rn->info) |
| 4147 | { |
| 4148 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 4149 | bgp_unlock_node (rn); |
| 4150 | } |
| 4151 | else |
| 4152 | { |
| 4153 | /* New configuration. */ |
| 4154 | bgp_static = bgp_static_new (); |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4155 | bgp_static->backdoor = 0; |
| 4156 | bgp_static->valid = 0; |
| 4157 | bgp_static->igpmetric = 0; |
| 4158 | bgp_static->igpnexthop.s_addr = 0; |
| 4159 | memcpy(bgp_static->tag, tag, 3); |
| 4160 | bgp_static->prd = prd; |
| 4161 | |
| 4162 | if (rmap_str) |
| 4163 | { |
| 4164 | if (bgp_static->rmap.name) |
| 4165 | free (bgp_static->rmap.name); |
| 4166 | bgp_static->rmap.name = strdup (rmap_str); |
| 4167 | bgp_static->rmap.map = route_map_lookup_by_name (rmap_str); |
| 4168 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4169 | rn->info = bgp_static; |
| 4170 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4171 | bgp_static->valid = 1; |
| 4172 | bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4173 | } |
| 4174 | |
| 4175 | return CMD_SUCCESS; |
| 4176 | } |
| 4177 | |
| 4178 | /* Configure static BGP network. */ |
| 4179 | int |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4180 | bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str, |
| 4181 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4182 | { |
| 4183 | int ret; |
| 4184 | struct bgp *bgp; |
| 4185 | struct prefix p; |
| 4186 | struct prefix_rd prd; |
| 4187 | struct bgp_node *prn; |
| 4188 | struct bgp_node *rn; |
| 4189 | struct bgp_table *table; |
| 4190 | struct bgp_static *bgp_static; |
| 4191 | u_char tag[3]; |
| 4192 | |
| 4193 | bgp = vty->index; |
| 4194 | |
| 4195 | /* Convert IP prefix string to struct prefix. */ |
| 4196 | ret = str2prefix (ip_str, &p); |
| 4197 | if (! ret) |
| 4198 | { |
| 4199 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4200 | return CMD_WARNING; |
| 4201 | } |
| 4202 | apply_mask (&p); |
| 4203 | |
| 4204 | ret = str2prefix_rd (rd_str, &prd); |
| 4205 | if (! ret) |
| 4206 | { |
| 4207 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4208 | return CMD_WARNING; |
| 4209 | } |
| 4210 | |
| 4211 | ret = str2tag (tag_str, tag); |
| 4212 | if (! ret) |
| 4213 | { |
| 4214 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4215 | return CMD_WARNING; |
| 4216 | } |
| 4217 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4218 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4219 | (struct prefix *)&prd); |
| 4220 | if (prn->info == NULL) |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4221 | prn->info = bgp_table_init (AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4222 | else |
| 4223 | bgp_unlock_node (prn); |
| 4224 | table = prn->info; |
| 4225 | |
| 4226 | rn = bgp_node_lookup (table, &p); |
| 4227 | |
| 4228 | if (rn) |
| 4229 | { |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4230 | bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4231 | |
| 4232 | bgp_static = rn->info; |
| 4233 | bgp_static_free (bgp_static); |
| 4234 | rn->info = NULL; |
| 4235 | bgp_unlock_node (rn); |
| 4236 | bgp_unlock_node (rn); |
| 4237 | } |
| 4238 | else |
| 4239 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 4240 | |
| 4241 | return CMD_SUCCESS; |
| 4242 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4243 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4244 | DEFUN (bgp_network, |
| 4245 | bgp_network_cmd, |
| 4246 | "network A.B.C.D/M", |
| 4247 | "Specify a network to announce via BGP\n" |
| 4248 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4249 | { |
| 4250 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4251 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4252 | } |
| 4253 | |
| 4254 | DEFUN (bgp_network_route_map, |
| 4255 | bgp_network_route_map_cmd, |
| 4256 | "network A.B.C.D/M route-map WORD", |
| 4257 | "Specify a network to announce via BGP\n" |
| 4258 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4259 | "Route-map to modify the attributes\n" |
| 4260 | "Name of the route map\n") |
| 4261 | { |
| 4262 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4263 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4264 | } |
| 4265 | |
| 4266 | DEFUN (bgp_network_backdoor, |
| 4267 | bgp_network_backdoor_cmd, |
| 4268 | "network A.B.C.D/M backdoor", |
| 4269 | "Specify a network to announce via BGP\n" |
| 4270 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4271 | "Specify a BGP backdoor route\n") |
| 4272 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4273 | 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] | 4274 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4275 | } |
| 4276 | |
| 4277 | DEFUN (bgp_network_mask, |
| 4278 | bgp_network_mask_cmd, |
| 4279 | "network A.B.C.D mask A.B.C.D", |
| 4280 | "Specify a network to announce via BGP\n" |
| 4281 | "Network number\n" |
| 4282 | "Network mask\n" |
| 4283 | "Network mask\n") |
| 4284 | { |
| 4285 | int ret; |
| 4286 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4287 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4288 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4289 | if (! ret) |
| 4290 | { |
| 4291 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4292 | return CMD_WARNING; |
| 4293 | } |
| 4294 | |
| 4295 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4296 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4297 | } |
| 4298 | |
| 4299 | DEFUN (bgp_network_mask_route_map, |
| 4300 | bgp_network_mask_route_map_cmd, |
| 4301 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4302 | "Specify a network to announce via BGP\n" |
| 4303 | "Network number\n" |
| 4304 | "Network mask\n" |
| 4305 | "Network mask\n" |
| 4306 | "Route-map to modify the attributes\n" |
| 4307 | "Name of the route map\n") |
| 4308 | { |
| 4309 | int ret; |
| 4310 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4311 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4312 | ret = netmask_str2prefix_str (argv[0], argv[1], 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_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4320 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4321 | } |
| 4322 | |
| 4323 | DEFUN (bgp_network_mask_backdoor, |
| 4324 | bgp_network_mask_backdoor_cmd, |
| 4325 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4326 | "Specify a network to announce via BGP\n" |
| 4327 | "Network number\n" |
| 4328 | "Network mask\n" |
| 4329 | "Network mask\n" |
| 4330 | "Specify a BGP backdoor route\n") |
| 4331 | { |
| 4332 | int ret; |
| 4333 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4334 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4335 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4336 | if (! ret) |
| 4337 | { |
| 4338 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4339 | return CMD_WARNING; |
| 4340 | } |
| 4341 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4342 | 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] | 4343 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4344 | } |
| 4345 | |
| 4346 | DEFUN (bgp_network_mask_natural, |
| 4347 | bgp_network_mask_natural_cmd, |
| 4348 | "network A.B.C.D", |
| 4349 | "Specify a network to announce via BGP\n" |
| 4350 | "Network number\n") |
| 4351 | { |
| 4352 | int ret; |
| 4353 | char prefix_str[BUFSIZ]; |
| 4354 | |
| 4355 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4356 | if (! ret) |
| 4357 | { |
| 4358 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4359 | return CMD_WARNING; |
| 4360 | } |
| 4361 | |
| 4362 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4363 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4364 | } |
| 4365 | |
| 4366 | DEFUN (bgp_network_mask_natural_route_map, |
| 4367 | bgp_network_mask_natural_route_map_cmd, |
| 4368 | "network A.B.C.D route-map WORD", |
| 4369 | "Specify a network to announce via BGP\n" |
| 4370 | "Network number\n" |
| 4371 | "Route-map to modify the attributes\n" |
| 4372 | "Name of the route map\n") |
| 4373 | { |
| 4374 | int ret; |
| 4375 | char prefix_str[BUFSIZ]; |
| 4376 | |
| 4377 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4378 | if (! ret) |
| 4379 | { |
| 4380 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4381 | return CMD_WARNING; |
| 4382 | } |
| 4383 | |
| 4384 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4385 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4386 | } |
| 4387 | |
| 4388 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4389 | bgp_network_mask_natural_backdoor_cmd, |
| 4390 | "network A.B.C.D backdoor", |
| 4391 | "Specify a network to announce via BGP\n" |
| 4392 | "Network number\n" |
| 4393 | "Specify a BGP backdoor route\n") |
| 4394 | { |
| 4395 | int ret; |
| 4396 | char prefix_str[BUFSIZ]; |
| 4397 | |
| 4398 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4399 | if (! ret) |
| 4400 | { |
| 4401 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4402 | return CMD_WARNING; |
| 4403 | } |
| 4404 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4405 | 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] | 4406 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4407 | } |
| 4408 | |
| 4409 | DEFUN (no_bgp_network, |
| 4410 | no_bgp_network_cmd, |
| 4411 | "no network A.B.C.D/M", |
| 4412 | NO_STR |
| 4413 | "Specify a network to announce via BGP\n" |
| 4414 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4415 | { |
| 4416 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4417 | bgp_node_safi (vty)); |
| 4418 | } |
| 4419 | |
| 4420 | ALIAS (no_bgp_network, |
| 4421 | no_bgp_network_route_map_cmd, |
| 4422 | "no network A.B.C.D/M route-map WORD", |
| 4423 | NO_STR |
| 4424 | "Specify a network to announce via BGP\n" |
| 4425 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4426 | "Route-map to modify the attributes\n" |
| 4427 | "Name of the route map\n") |
| 4428 | |
| 4429 | ALIAS (no_bgp_network, |
| 4430 | no_bgp_network_backdoor_cmd, |
| 4431 | "no network A.B.C.D/M backdoor", |
| 4432 | NO_STR |
| 4433 | "Specify a network to announce via BGP\n" |
| 4434 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4435 | "Specify a BGP backdoor route\n") |
| 4436 | |
| 4437 | DEFUN (no_bgp_network_mask, |
| 4438 | no_bgp_network_mask_cmd, |
| 4439 | "no network A.B.C.D mask A.B.C.D", |
| 4440 | NO_STR |
| 4441 | "Specify a network to announce via BGP\n" |
| 4442 | "Network number\n" |
| 4443 | "Network mask\n" |
| 4444 | "Network mask\n") |
| 4445 | { |
| 4446 | int ret; |
| 4447 | char prefix_str[BUFSIZ]; |
| 4448 | |
| 4449 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4450 | if (! ret) |
| 4451 | { |
| 4452 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4453 | return CMD_WARNING; |
| 4454 | } |
| 4455 | |
| 4456 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4457 | bgp_node_safi (vty)); |
| 4458 | } |
| 4459 | |
| 4460 | ALIAS (no_bgp_network_mask, |
| 4461 | no_bgp_network_mask_route_map_cmd, |
| 4462 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4463 | NO_STR |
| 4464 | "Specify a network to announce via BGP\n" |
| 4465 | "Network number\n" |
| 4466 | "Network mask\n" |
| 4467 | "Network mask\n" |
| 4468 | "Route-map to modify the attributes\n" |
| 4469 | "Name of the route map\n") |
| 4470 | |
| 4471 | ALIAS (no_bgp_network_mask, |
| 4472 | no_bgp_network_mask_backdoor_cmd, |
| 4473 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4474 | NO_STR |
| 4475 | "Specify a network to announce via BGP\n" |
| 4476 | "Network number\n" |
| 4477 | "Network mask\n" |
| 4478 | "Network mask\n" |
| 4479 | "Specify a BGP backdoor route\n") |
| 4480 | |
| 4481 | DEFUN (no_bgp_network_mask_natural, |
| 4482 | no_bgp_network_mask_natural_cmd, |
| 4483 | "no network A.B.C.D", |
| 4484 | NO_STR |
| 4485 | "Specify a network to announce via BGP\n" |
| 4486 | "Network number\n") |
| 4487 | { |
| 4488 | int ret; |
| 4489 | char prefix_str[BUFSIZ]; |
| 4490 | |
| 4491 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4492 | if (! ret) |
| 4493 | { |
| 4494 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4495 | return CMD_WARNING; |
| 4496 | } |
| 4497 | |
| 4498 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4499 | bgp_node_safi (vty)); |
| 4500 | } |
| 4501 | |
| 4502 | ALIAS (no_bgp_network_mask_natural, |
| 4503 | no_bgp_network_mask_natural_route_map_cmd, |
| 4504 | "no network A.B.C.D route-map WORD", |
| 4505 | NO_STR |
| 4506 | "Specify a network to announce via BGP\n" |
| 4507 | "Network number\n" |
| 4508 | "Route-map to modify the attributes\n" |
| 4509 | "Name of the route map\n") |
| 4510 | |
| 4511 | ALIAS (no_bgp_network_mask_natural, |
| 4512 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4513 | "no network A.B.C.D backdoor", |
| 4514 | NO_STR |
| 4515 | "Specify a network to announce via BGP\n" |
| 4516 | "Network number\n" |
| 4517 | "Specify a BGP backdoor route\n") |
| 4518 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4519 | DEFUN (ipv6_bgp_network, |
| 4520 | ipv6_bgp_network_cmd, |
| 4521 | "network X:X::X:X/M", |
| 4522 | "Specify a network to announce via BGP\n" |
| 4523 | "IPv6 prefix <network>/<length>\n") |
| 4524 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4525 | 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] | 4526 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4527 | } |
| 4528 | |
| 4529 | DEFUN (ipv6_bgp_network_route_map, |
| 4530 | ipv6_bgp_network_route_map_cmd, |
| 4531 | "network X:X::X:X/M route-map WORD", |
| 4532 | "Specify a network to announce via BGP\n" |
| 4533 | "IPv6 prefix <network>/<length>\n" |
| 4534 | "Route-map to modify the attributes\n" |
| 4535 | "Name of the route map\n") |
| 4536 | { |
| 4537 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4538 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4539 | } |
| 4540 | |
| 4541 | DEFUN (no_ipv6_bgp_network, |
| 4542 | no_ipv6_bgp_network_cmd, |
| 4543 | "no network X:X::X:X/M", |
| 4544 | NO_STR |
| 4545 | "Specify a network to announce via BGP\n" |
| 4546 | "IPv6 prefix <network>/<length>\n") |
| 4547 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4548 | 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] | 4549 | } |
| 4550 | |
| 4551 | ALIAS (no_ipv6_bgp_network, |
| 4552 | no_ipv6_bgp_network_route_map_cmd, |
| 4553 | "no network X:X::X:X/M route-map WORD", |
| 4554 | NO_STR |
| 4555 | "Specify a network to announce via BGP\n" |
| 4556 | "IPv6 prefix <network>/<length>\n" |
| 4557 | "Route-map to modify the attributes\n" |
| 4558 | "Name of the route map\n") |
| 4559 | |
| 4560 | ALIAS (ipv6_bgp_network, |
| 4561 | old_ipv6_bgp_network_cmd, |
| 4562 | "ipv6 bgp network X:X::X:X/M", |
| 4563 | IPV6_STR |
| 4564 | BGP_STR |
| 4565 | "Specify a network to announce via BGP\n" |
| 4566 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4567 | |
| 4568 | ALIAS (no_ipv6_bgp_network, |
| 4569 | old_no_ipv6_bgp_network_cmd, |
| 4570 | "no ipv6 bgp network X:X::X:X/M", |
| 4571 | NO_STR |
| 4572 | IPV6_STR |
| 4573 | BGP_STR |
| 4574 | "Specify a network to announce via BGP\n" |
| 4575 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4576 | |
| 4577 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4578 | ALIAS_DEPRECATED (bgp_network, |
| 4579 | bgp_network_ttl_cmd, |
| 4580 | "network A.B.C.D/M pathlimit <0-255>", |
| 4581 | "Specify a network to announce via BGP\n" |
| 4582 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4583 | "AS-Path hopcount limit attribute\n" |
| 4584 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4585 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4586 | bgp_network_backdoor_ttl_cmd, |
| 4587 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4588 | "Specify a network to announce via BGP\n" |
| 4589 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4590 | "Specify a BGP backdoor route\n" |
| 4591 | "AS-Path hopcount limit attribute\n" |
| 4592 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4593 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4594 | bgp_network_mask_ttl_cmd, |
| 4595 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4596 | "Specify a network to announce via BGP\n" |
| 4597 | "Network number\n" |
| 4598 | "Network mask\n" |
| 4599 | "Network mask\n" |
| 4600 | "AS-Path hopcount limit attribute\n" |
| 4601 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4602 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4603 | bgp_network_mask_backdoor_ttl_cmd, |
| 4604 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4605 | "Specify a network to announce via BGP\n" |
| 4606 | "Network number\n" |
| 4607 | "Network mask\n" |
| 4608 | "Network mask\n" |
| 4609 | "Specify a BGP backdoor route\n" |
| 4610 | "AS-Path hopcount limit attribute\n" |
| 4611 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4612 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4613 | bgp_network_mask_natural_ttl_cmd, |
| 4614 | "network A.B.C.D pathlimit <0-255>", |
| 4615 | "Specify a network to announce via BGP\n" |
| 4616 | "Network number\n" |
| 4617 | "AS-Path hopcount limit attribute\n" |
| 4618 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4619 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4620 | bgp_network_mask_natural_backdoor_ttl_cmd, |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 4621 | "network A.B.C.D backdoor pathlimit <1-255>", |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4622 | "Specify a network to announce via BGP\n" |
| 4623 | "Network number\n" |
| 4624 | "Specify a BGP backdoor route\n" |
| 4625 | "AS-Path hopcount limit attribute\n" |
| 4626 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4627 | ALIAS_DEPRECATED (no_bgp_network, |
| 4628 | no_bgp_network_ttl_cmd, |
| 4629 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4630 | NO_STR |
| 4631 | "Specify a network to announce via BGP\n" |
| 4632 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4633 | "AS-Path hopcount limit attribute\n" |
| 4634 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4635 | ALIAS_DEPRECATED (no_bgp_network, |
| 4636 | no_bgp_network_backdoor_ttl_cmd, |
| 4637 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4638 | NO_STR |
| 4639 | "Specify a network to announce via BGP\n" |
| 4640 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4641 | "Specify a BGP backdoor route\n" |
| 4642 | "AS-Path hopcount limit attribute\n" |
| 4643 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4644 | ALIAS_DEPRECATED (no_bgp_network, |
| 4645 | no_bgp_network_mask_ttl_cmd, |
| 4646 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4647 | NO_STR |
| 4648 | "Specify a network to announce via BGP\n" |
| 4649 | "Network number\n" |
| 4650 | "Network mask\n" |
| 4651 | "Network mask\n" |
| 4652 | "AS-Path hopcount limit attribute\n" |
| 4653 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4654 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4655 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4656 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4657 | NO_STR |
| 4658 | "Specify a network to announce via BGP\n" |
| 4659 | "Network number\n" |
| 4660 | "Network mask\n" |
| 4661 | "Network mask\n" |
| 4662 | "Specify a BGP backdoor route\n" |
| 4663 | "AS-Path hopcount limit attribute\n" |
| 4664 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4665 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4666 | no_bgp_network_mask_natural_ttl_cmd, |
| 4667 | "no network A.B.C.D pathlimit <0-255>", |
| 4668 | NO_STR |
| 4669 | "Specify a network to announce via BGP\n" |
| 4670 | "Network number\n" |
| 4671 | "AS-Path hopcount limit attribute\n" |
| 4672 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4673 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4674 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4675 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4676 | NO_STR |
| 4677 | "Specify a network to announce via BGP\n" |
| 4678 | "Network number\n" |
| 4679 | "Specify a BGP backdoor route\n" |
| 4680 | "AS-Path hopcount limit attribute\n" |
| 4681 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4682 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4683 | ipv6_bgp_network_ttl_cmd, |
| 4684 | "network X:X::X:X/M pathlimit <0-255>", |
| 4685 | "Specify a network to announce via BGP\n" |
| 4686 | "IPv6 prefix <network>/<length>\n" |
| 4687 | "AS-Path hopcount limit attribute\n" |
| 4688 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4689 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4690 | no_ipv6_bgp_network_ttl_cmd, |
| 4691 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4692 | NO_STR |
| 4693 | "Specify a network to announce via BGP\n" |
| 4694 | "IPv6 prefix <network>/<length>\n" |
| 4695 | "AS-Path hopcount limit attribute\n" |
| 4696 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4697 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4698 | /* Aggreagete address: |
| 4699 | |
| 4700 | advertise-map Set condition to advertise attribute |
| 4701 | as-set Generate AS set path information |
| 4702 | attribute-map Set attributes of aggregate |
| 4703 | route-map Set parameters of aggregate |
| 4704 | summary-only Filter more specific routes from updates |
| 4705 | suppress-map Conditionally filter more specific routes from updates |
| 4706 | <cr> |
| 4707 | */ |
| 4708 | struct bgp_aggregate |
| 4709 | { |
| 4710 | /* Summary-only flag. */ |
| 4711 | u_char summary_only; |
| 4712 | |
| 4713 | /* AS set generation. */ |
| 4714 | u_char as_set; |
| 4715 | |
| 4716 | /* Route-map for aggregated route. */ |
| 4717 | struct route_map *map; |
| 4718 | |
| 4719 | /* Suppress-count. */ |
| 4720 | unsigned long count; |
| 4721 | |
| 4722 | /* SAFI configuration. */ |
| 4723 | safi_t safi; |
| 4724 | }; |
| 4725 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4726 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4727 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4728 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4729 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4730 | } |
| 4731 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4732 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4733 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4734 | { |
| 4735 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4736 | } |
| 4737 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 4738 | /* Update an aggregate as routes are added/removed from the BGP table */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4739 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4740 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4741 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4742 | struct bgp_aggregate *aggregate) |
| 4743 | { |
| 4744 | struct bgp_table *table; |
| 4745 | struct bgp_node *top; |
| 4746 | struct bgp_node *rn; |
| 4747 | u_char origin; |
| 4748 | struct aspath *aspath = NULL; |
| 4749 | struct aspath *asmerge = NULL; |
| 4750 | struct community *community = NULL; |
| 4751 | struct community *commerge = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4752 | struct bgp_info *ri; |
| 4753 | struct bgp_info *new; |
| 4754 | int first = 1; |
| 4755 | unsigned long match = 0; |
| 4756 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4757 | /* ORIGIN attribute: If at least one route among routes that are |
| 4758 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4759 | aggregated route must have the ORIGIN attribute with the value |
| 4760 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4761 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4762 | route must have the origin attribute with the value EGP. In all |
| 4763 | other case the value of the ORIGIN attribute of the aggregated |
| 4764 | route is INTERNAL. */ |
| 4765 | origin = BGP_ORIGIN_IGP; |
| 4766 | |
| 4767 | table = bgp->rib[afi][safi]; |
| 4768 | |
| 4769 | top = bgp_node_get (table, p); |
| 4770 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4771 | if (rn->p.prefixlen > p->prefixlen) |
| 4772 | { |
| 4773 | match = 0; |
| 4774 | |
| 4775 | for (ri = rn->info; ri; ri = ri->next) |
| 4776 | { |
| 4777 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4778 | continue; |
| 4779 | |
| 4780 | if (del && ri == del) |
| 4781 | continue; |
| 4782 | |
| 4783 | if (! rinew && first) |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 4784 | first = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4785 | |
| 4786 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4787 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4788 | || ri->attr->med != med) |
| 4789 | { |
| 4790 | if (aspath) |
| 4791 | aspath_free (aspath); |
| 4792 | if (community) |
| 4793 | community_free (community); |
| 4794 | bgp_unlock_node (rn); |
| 4795 | bgp_unlock_node (top); |
| 4796 | return; |
| 4797 | } |
| 4798 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4799 | |
| 4800 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4801 | { |
| 4802 | if (aggregate->summary_only) |
| 4803 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4804 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4805 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4806 | match++; |
| 4807 | } |
| 4808 | |
| 4809 | aggregate->count++; |
| 4810 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 4811 | if (origin < ri->attr->origin) |
| 4812 | origin = ri->attr->origin; |
| 4813 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4814 | if (aggregate->as_set) |
| 4815 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4816 | if (aspath) |
| 4817 | { |
| 4818 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4819 | aspath_free (aspath); |
| 4820 | aspath = asmerge; |
| 4821 | } |
| 4822 | else |
| 4823 | aspath = aspath_dup (ri->attr->aspath); |
| 4824 | |
| 4825 | if (ri->attr->community) |
| 4826 | { |
| 4827 | if (community) |
| 4828 | { |
| 4829 | commerge = community_merge (community, |
| 4830 | ri->attr->community); |
| 4831 | community = community_uniq_sort (commerge); |
| 4832 | community_free (commerge); |
| 4833 | } |
| 4834 | else |
| 4835 | community = community_dup (ri->attr->community); |
| 4836 | } |
| 4837 | } |
| 4838 | } |
| 4839 | } |
| 4840 | if (match) |
| 4841 | bgp_process (bgp, rn, afi, safi); |
| 4842 | } |
| 4843 | bgp_unlock_node (top); |
| 4844 | |
| 4845 | if (rinew) |
| 4846 | { |
| 4847 | aggregate->count++; |
| 4848 | |
| 4849 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4850 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4851 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 4852 | if (origin < rinew->attr->origin) |
| 4853 | origin = rinew->attr->origin; |
| 4854 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4855 | if (aggregate->as_set) |
| 4856 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4857 | if (aspath) |
| 4858 | { |
| 4859 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4860 | aspath_free (aspath); |
| 4861 | aspath = asmerge; |
| 4862 | } |
| 4863 | else |
| 4864 | aspath = aspath_dup (rinew->attr->aspath); |
| 4865 | |
| 4866 | if (rinew->attr->community) |
| 4867 | { |
| 4868 | if (community) |
| 4869 | { |
| 4870 | commerge = community_merge (community, |
| 4871 | rinew->attr->community); |
| 4872 | community = community_uniq_sort (commerge); |
| 4873 | community_free (commerge); |
| 4874 | } |
| 4875 | else |
| 4876 | community = community_dup (rinew->attr->community); |
| 4877 | } |
| 4878 | } |
| 4879 | } |
| 4880 | |
| 4881 | if (aggregate->count > 0) |
| 4882 | { |
| 4883 | rn = bgp_node_get (table, p); |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 4884 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self, |
| 4885 | bgp_attr_aggregate_intern(bgp, origin, aspath, community, |
| 4886 | aggregate->as_set), rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4887 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4888 | |
| 4889 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4890 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4891 | bgp_process (bgp, rn, afi, safi); |
| 4892 | } |
| 4893 | else |
| 4894 | { |
| 4895 | if (aspath) |
| 4896 | aspath_free (aspath); |
| 4897 | if (community) |
| 4898 | community_free (community); |
| 4899 | } |
| 4900 | } |
| 4901 | |
| 4902 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4903 | struct bgp_aggregate *); |
| 4904 | |
| 4905 | void |
| 4906 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4907 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4908 | { |
| 4909 | struct bgp_node *child; |
| 4910 | struct bgp_node *rn; |
| 4911 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4912 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4913 | |
| 4914 | /* MPLS-VPN aggregation is not yet supported. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4915 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4916 | return; |
| 4917 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4918 | table = bgp->aggregate[afi][safi]; |
| 4919 | |
| 4920 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4921 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4922 | return; |
| 4923 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4924 | if (p->prefixlen == 0) |
| 4925 | return; |
| 4926 | |
| 4927 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4928 | return; |
| 4929 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4930 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4931 | |
| 4932 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4933 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4934 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4935 | { |
| 4936 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4937 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4938 | } |
| 4939 | bgp_unlock_node (child); |
| 4940 | } |
| 4941 | |
| 4942 | void |
| 4943 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4944 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4945 | { |
| 4946 | struct bgp_node *child; |
| 4947 | struct bgp_node *rn; |
| 4948 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4949 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4950 | |
| 4951 | /* MPLS-VPN aggregation is not yet supported. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4952 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4953 | return; |
| 4954 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4955 | table = bgp->aggregate[afi][safi]; |
| 4956 | |
| 4957 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4958 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4959 | return; |
| 4960 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4961 | if (p->prefixlen == 0) |
| 4962 | return; |
| 4963 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4964 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4965 | |
| 4966 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4967 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4968 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4969 | { |
| 4970 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4971 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4972 | } |
| 4973 | bgp_unlock_node (child); |
| 4974 | } |
| 4975 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 4976 | /* Called via bgp_aggregate_set when the user configures aggregate-address */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4977 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4978 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4979 | struct bgp_aggregate *aggregate) |
| 4980 | { |
| 4981 | struct bgp_table *table; |
| 4982 | struct bgp_node *top; |
| 4983 | struct bgp_node *rn; |
| 4984 | struct bgp_info *new; |
| 4985 | struct bgp_info *ri; |
| 4986 | unsigned long match; |
| 4987 | u_char origin = BGP_ORIGIN_IGP; |
| 4988 | struct aspath *aspath = NULL; |
| 4989 | struct aspath *asmerge = NULL; |
| 4990 | struct community *community = NULL; |
| 4991 | struct community *commerge = NULL; |
| 4992 | |
| 4993 | table = bgp->rib[afi][safi]; |
| 4994 | |
| 4995 | /* Sanity check. */ |
| 4996 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4997 | return; |
| 4998 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4999 | return; |
| 5000 | |
| 5001 | /* If routes exists below this node, generate aggregate routes. */ |
| 5002 | top = bgp_node_get (table, p); |
| 5003 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 5004 | if (rn->p.prefixlen > p->prefixlen) |
| 5005 | { |
| 5006 | match = 0; |
| 5007 | |
| 5008 | for (ri = rn->info; ri; ri = ri->next) |
| 5009 | { |
| 5010 | if (BGP_INFO_HOLDDOWN (ri)) |
| 5011 | continue; |
| 5012 | |
| 5013 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 5014 | { |
| 5015 | /* summary-only aggregate route suppress aggregated |
| 5016 | route announcement. */ |
| 5017 | if (aggregate->summary_only) |
| 5018 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5019 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5020 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5021 | match++; |
| 5022 | } |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 5023 | |
| 5024 | /* If at least one route among routes that are aggregated has |
| 5025 | * ORIGIN with the value INCOMPLETE, then the aggregated route |
| 5026 | * MUST have the ORIGIN attribute with the value INCOMPLETE. |
| 5027 | * Otherwise, if at least one route among routes that are |
| 5028 | * aggregated has ORIGIN with the value EGP, then the aggregated |
| 5029 | * route MUST have the ORIGIN attribute with the value EGP. |
| 5030 | */ |
| 5031 | if (origin < ri->attr->origin) |
| 5032 | origin = ri->attr->origin; |
| 5033 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5034 | /* as-set aggregate route generate origin, as path, |
| 5035 | community aggregation. */ |
| 5036 | if (aggregate->as_set) |
| 5037 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5038 | if (aspath) |
| 5039 | { |
| 5040 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 5041 | aspath_free (aspath); |
| 5042 | aspath = asmerge; |
| 5043 | } |
| 5044 | else |
| 5045 | aspath = aspath_dup (ri->attr->aspath); |
| 5046 | |
| 5047 | if (ri->attr->community) |
| 5048 | { |
| 5049 | if (community) |
| 5050 | { |
| 5051 | commerge = community_merge (community, |
| 5052 | ri->attr->community); |
| 5053 | community = community_uniq_sort (commerge); |
| 5054 | community_free (commerge); |
| 5055 | } |
| 5056 | else |
| 5057 | community = community_dup (ri->attr->community); |
| 5058 | } |
| 5059 | } |
| 5060 | aggregate->count++; |
| 5061 | } |
| 5062 | } |
| 5063 | |
| 5064 | /* If this node is suppressed, process the change. */ |
| 5065 | if (match) |
| 5066 | bgp_process (bgp, rn, afi, safi); |
| 5067 | } |
| 5068 | bgp_unlock_node (top); |
| 5069 | |
| 5070 | /* Add aggregate route to BGP table. */ |
| 5071 | if (aggregate->count) |
| 5072 | { |
| 5073 | rn = bgp_node_get (table, p); |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 5074 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self, |
| 5075 | bgp_attr_aggregate_intern(bgp, origin, aspath, community, |
| 5076 | aggregate->as_set), rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5077 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5078 | |
| 5079 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5080 | bgp_unlock_node (rn); |
| 5081 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5082 | /* Process change. */ |
| 5083 | bgp_process (bgp, rn, afi, safi); |
| 5084 | } |
Denil Vira | e2a9258 | 2015-08-11 13:34:59 -0700 | [diff] [blame] | 5085 | else |
| 5086 | { |
| 5087 | if (aspath) |
| 5088 | aspath_free (aspath); |
| 5089 | if (community) |
| 5090 | community_free (community); |
| 5091 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5092 | } |
| 5093 | |
| 5094 | void |
| 5095 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 5096 | safi_t safi, struct bgp_aggregate *aggregate) |
| 5097 | { |
| 5098 | struct bgp_table *table; |
| 5099 | struct bgp_node *top; |
| 5100 | struct bgp_node *rn; |
| 5101 | struct bgp_info *ri; |
| 5102 | unsigned long match; |
| 5103 | |
| 5104 | table = bgp->rib[afi][safi]; |
| 5105 | |
| 5106 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 5107 | return; |
| 5108 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 5109 | return; |
| 5110 | |
| 5111 | /* If routes exists below this node, generate aggregate routes. */ |
| 5112 | top = bgp_node_get (table, p); |
| 5113 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 5114 | if (rn->p.prefixlen > p->prefixlen) |
| 5115 | { |
| 5116 | match = 0; |
| 5117 | |
| 5118 | for (ri = rn->info; ri; ri = ri->next) |
| 5119 | { |
| 5120 | if (BGP_INFO_HOLDDOWN (ri)) |
| 5121 | continue; |
| 5122 | |
| 5123 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 5124 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5125 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5126 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5127 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5128 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5129 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5130 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5131 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5132 | match++; |
| 5133 | } |
| 5134 | } |
| 5135 | aggregate->count--; |
| 5136 | } |
| 5137 | } |
| 5138 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5139 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5140 | if (match) |
| 5141 | bgp_process (bgp, rn, afi, safi); |
| 5142 | } |
| 5143 | bgp_unlock_node (top); |
| 5144 | |
| 5145 | /* Delete aggregate route from BGP table. */ |
| 5146 | rn = bgp_node_get (table, p); |
| 5147 | |
| 5148 | for (ri = rn->info; ri; ri = ri->next) |
| 5149 | if (ri->peer == bgp->peer_self |
| 5150 | && ri->type == ZEBRA_ROUTE_BGP |
| 5151 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 5152 | break; |
| 5153 | |
| 5154 | /* Withdraw static BGP route from routing table. */ |
| 5155 | if (ri) |
| 5156 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5157 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5158 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5159 | } |
| 5160 | |
| 5161 | /* Unlock bgp_node_lookup. */ |
| 5162 | bgp_unlock_node (rn); |
| 5163 | } |
| 5164 | |
| 5165 | /* Aggregate route attribute. */ |
| 5166 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 5167 | #define AGGREGATE_AS_SET 1 |
| 5168 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5169 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5170 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 5171 | afi_t afi, safi_t safi) |
| 5172 | { |
| 5173 | int ret; |
| 5174 | struct prefix p; |
| 5175 | struct bgp_node *rn; |
| 5176 | struct bgp *bgp; |
| 5177 | struct bgp_aggregate *aggregate; |
| 5178 | |
| 5179 | /* Convert string to prefix structure. */ |
| 5180 | ret = str2prefix (prefix_str, &p); |
| 5181 | if (!ret) |
| 5182 | { |
| 5183 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5184 | return CMD_WARNING; |
| 5185 | } |
| 5186 | apply_mask (&p); |
| 5187 | |
| 5188 | /* Get BGP structure. */ |
| 5189 | bgp = vty->index; |
| 5190 | |
| 5191 | /* Old configuration check. */ |
| 5192 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 5193 | if (! rn) |
| 5194 | { |
| 5195 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 5196 | VTY_NEWLINE); |
| 5197 | return CMD_WARNING; |
| 5198 | } |
| 5199 | |
| 5200 | aggregate = rn->info; |
| 5201 | if (aggregate->safi & SAFI_UNICAST) |
| 5202 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5203 | if (aggregate->safi & SAFI_MULTICAST) |
| 5204 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5205 | |
| 5206 | /* Unlock aggregate address configuration. */ |
| 5207 | rn->info = NULL; |
| 5208 | bgp_aggregate_free (aggregate); |
| 5209 | bgp_unlock_node (rn); |
| 5210 | bgp_unlock_node (rn); |
| 5211 | |
| 5212 | return CMD_SUCCESS; |
| 5213 | } |
| 5214 | |
| 5215 | static int |
| 5216 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5217 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5218 | u_char summary_only, u_char as_set) |
| 5219 | { |
| 5220 | int ret; |
| 5221 | struct prefix p; |
| 5222 | struct bgp_node *rn; |
| 5223 | struct bgp *bgp; |
| 5224 | struct bgp_aggregate *aggregate; |
| 5225 | |
| 5226 | /* Convert string to prefix structure. */ |
| 5227 | ret = str2prefix (prefix_str, &p); |
| 5228 | if (!ret) |
| 5229 | { |
| 5230 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5231 | return CMD_WARNING; |
| 5232 | } |
| 5233 | apply_mask (&p); |
| 5234 | |
| 5235 | /* Get BGP structure. */ |
| 5236 | bgp = vty->index; |
| 5237 | |
| 5238 | /* Old configuration check. */ |
| 5239 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 5240 | |
| 5241 | if (rn->info) |
| 5242 | { |
| 5243 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5244 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5245 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 5246 | if (ret) |
| 5247 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5248 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 5249 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5250 | return CMD_WARNING; |
| 5251 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5252 | } |
| 5253 | |
| 5254 | /* Make aggregate address structure. */ |
| 5255 | aggregate = bgp_aggregate_new (); |
| 5256 | aggregate->summary_only = summary_only; |
| 5257 | aggregate->as_set = as_set; |
| 5258 | aggregate->safi = safi; |
| 5259 | rn->info = aggregate; |
| 5260 | |
| 5261 | /* Aggregate address insert into BGP routing table. */ |
| 5262 | if (safi & SAFI_UNICAST) |
| 5263 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5264 | if (safi & SAFI_MULTICAST) |
| 5265 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5266 | |
| 5267 | return CMD_SUCCESS; |
| 5268 | } |
| 5269 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5270 | DEFUN (aggregate_address, |
| 5271 | aggregate_address_cmd, |
| 5272 | "aggregate-address A.B.C.D/M", |
| 5273 | "Configure BGP aggregate entries\n" |
| 5274 | "Aggregate prefix\n") |
| 5275 | { |
| 5276 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5277 | } |
| 5278 | |
| 5279 | DEFUN (aggregate_address_mask, |
| 5280 | aggregate_address_mask_cmd, |
| 5281 | "aggregate-address A.B.C.D A.B.C.D", |
| 5282 | "Configure BGP aggregate entries\n" |
| 5283 | "Aggregate address\n" |
| 5284 | "Aggregate mask\n") |
| 5285 | { |
| 5286 | int ret; |
| 5287 | char prefix_str[BUFSIZ]; |
| 5288 | |
| 5289 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5290 | |
| 5291 | if (! ret) |
| 5292 | { |
| 5293 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5294 | return CMD_WARNING; |
| 5295 | } |
| 5296 | |
| 5297 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5298 | 0, 0); |
| 5299 | } |
| 5300 | |
| 5301 | DEFUN (aggregate_address_summary_only, |
| 5302 | aggregate_address_summary_only_cmd, |
| 5303 | "aggregate-address A.B.C.D/M summary-only", |
| 5304 | "Configure BGP aggregate entries\n" |
| 5305 | "Aggregate prefix\n" |
| 5306 | "Filter more specific routes from updates\n") |
| 5307 | { |
| 5308 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5309 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5310 | } |
| 5311 | |
| 5312 | DEFUN (aggregate_address_mask_summary_only, |
| 5313 | aggregate_address_mask_summary_only_cmd, |
| 5314 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5315 | "Configure BGP aggregate entries\n" |
| 5316 | "Aggregate address\n" |
| 5317 | "Aggregate mask\n" |
| 5318 | "Filter more specific routes from updates\n") |
| 5319 | { |
| 5320 | int ret; |
| 5321 | char prefix_str[BUFSIZ]; |
| 5322 | |
| 5323 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5324 | |
| 5325 | if (! ret) |
| 5326 | { |
| 5327 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5328 | return CMD_WARNING; |
| 5329 | } |
| 5330 | |
| 5331 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5332 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5333 | } |
| 5334 | |
| 5335 | DEFUN (aggregate_address_as_set, |
| 5336 | aggregate_address_as_set_cmd, |
| 5337 | "aggregate-address A.B.C.D/M as-set", |
| 5338 | "Configure BGP aggregate entries\n" |
| 5339 | "Aggregate prefix\n" |
| 5340 | "Generate AS set path information\n") |
| 5341 | { |
| 5342 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5343 | 0, AGGREGATE_AS_SET); |
| 5344 | } |
| 5345 | |
| 5346 | DEFUN (aggregate_address_mask_as_set, |
| 5347 | aggregate_address_mask_as_set_cmd, |
| 5348 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5349 | "Configure BGP aggregate entries\n" |
| 5350 | "Aggregate address\n" |
| 5351 | "Aggregate mask\n" |
| 5352 | "Generate AS set path information\n") |
| 5353 | { |
| 5354 | int ret; |
| 5355 | char prefix_str[BUFSIZ]; |
| 5356 | |
| 5357 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5358 | |
| 5359 | if (! ret) |
| 5360 | { |
| 5361 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5362 | return CMD_WARNING; |
| 5363 | } |
| 5364 | |
| 5365 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5366 | 0, AGGREGATE_AS_SET); |
| 5367 | } |
| 5368 | |
| 5369 | |
| 5370 | DEFUN (aggregate_address_as_set_summary, |
| 5371 | aggregate_address_as_set_summary_cmd, |
| 5372 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5373 | "Configure BGP aggregate entries\n" |
| 5374 | "Aggregate prefix\n" |
| 5375 | "Generate AS set path information\n" |
| 5376 | "Filter more specific routes from updates\n") |
| 5377 | { |
| 5378 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5379 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5380 | } |
| 5381 | |
| 5382 | ALIAS (aggregate_address_as_set_summary, |
| 5383 | aggregate_address_summary_as_set_cmd, |
| 5384 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5385 | "Configure BGP aggregate entries\n" |
| 5386 | "Aggregate prefix\n" |
| 5387 | "Filter more specific routes from updates\n" |
| 5388 | "Generate AS set path information\n") |
| 5389 | |
| 5390 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5391 | aggregate_address_mask_as_set_summary_cmd, |
| 5392 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5393 | "Configure BGP aggregate entries\n" |
| 5394 | "Aggregate address\n" |
| 5395 | "Aggregate mask\n" |
| 5396 | "Generate AS set path information\n" |
| 5397 | "Filter more specific routes from updates\n") |
| 5398 | { |
| 5399 | int ret; |
| 5400 | char prefix_str[BUFSIZ]; |
| 5401 | |
| 5402 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5403 | |
| 5404 | if (! ret) |
| 5405 | { |
| 5406 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5407 | return CMD_WARNING; |
| 5408 | } |
| 5409 | |
| 5410 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5411 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5412 | } |
| 5413 | |
| 5414 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5415 | aggregate_address_mask_summary_as_set_cmd, |
| 5416 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5417 | "Configure BGP aggregate entries\n" |
| 5418 | "Aggregate address\n" |
| 5419 | "Aggregate mask\n" |
| 5420 | "Filter more specific routes from updates\n" |
| 5421 | "Generate AS set path information\n") |
| 5422 | |
| 5423 | DEFUN (no_aggregate_address, |
| 5424 | no_aggregate_address_cmd, |
| 5425 | "no aggregate-address A.B.C.D/M", |
| 5426 | NO_STR |
| 5427 | "Configure BGP aggregate entries\n" |
| 5428 | "Aggregate prefix\n") |
| 5429 | { |
| 5430 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5431 | } |
| 5432 | |
| 5433 | ALIAS (no_aggregate_address, |
| 5434 | no_aggregate_address_summary_only_cmd, |
| 5435 | "no aggregate-address A.B.C.D/M summary-only", |
| 5436 | NO_STR |
| 5437 | "Configure BGP aggregate entries\n" |
| 5438 | "Aggregate prefix\n" |
| 5439 | "Filter more specific routes from updates\n") |
| 5440 | |
| 5441 | ALIAS (no_aggregate_address, |
| 5442 | no_aggregate_address_as_set_cmd, |
| 5443 | "no aggregate-address A.B.C.D/M as-set", |
| 5444 | NO_STR |
| 5445 | "Configure BGP aggregate entries\n" |
| 5446 | "Aggregate prefix\n" |
| 5447 | "Generate AS set path information\n") |
| 5448 | |
| 5449 | ALIAS (no_aggregate_address, |
| 5450 | no_aggregate_address_as_set_summary_cmd, |
| 5451 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5452 | NO_STR |
| 5453 | "Configure BGP aggregate entries\n" |
| 5454 | "Aggregate prefix\n" |
| 5455 | "Generate AS set path information\n" |
| 5456 | "Filter more specific routes from updates\n") |
| 5457 | |
| 5458 | ALIAS (no_aggregate_address, |
| 5459 | no_aggregate_address_summary_as_set_cmd, |
| 5460 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5461 | NO_STR |
| 5462 | "Configure BGP aggregate entries\n" |
| 5463 | "Aggregate prefix\n" |
| 5464 | "Filter more specific routes from updates\n" |
| 5465 | "Generate AS set path information\n") |
| 5466 | |
| 5467 | DEFUN (no_aggregate_address_mask, |
| 5468 | no_aggregate_address_mask_cmd, |
| 5469 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5470 | NO_STR |
| 5471 | "Configure BGP aggregate entries\n" |
| 5472 | "Aggregate address\n" |
| 5473 | "Aggregate mask\n") |
| 5474 | { |
| 5475 | int ret; |
| 5476 | char prefix_str[BUFSIZ]; |
| 5477 | |
| 5478 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5479 | |
| 5480 | if (! ret) |
| 5481 | { |
| 5482 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5483 | return CMD_WARNING; |
| 5484 | } |
| 5485 | |
| 5486 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5487 | } |
| 5488 | |
| 5489 | ALIAS (no_aggregate_address_mask, |
| 5490 | no_aggregate_address_mask_summary_only_cmd, |
| 5491 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5492 | NO_STR |
| 5493 | "Configure BGP aggregate entries\n" |
| 5494 | "Aggregate address\n" |
| 5495 | "Aggregate mask\n" |
| 5496 | "Filter more specific routes from updates\n") |
| 5497 | |
| 5498 | ALIAS (no_aggregate_address_mask, |
| 5499 | no_aggregate_address_mask_as_set_cmd, |
| 5500 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5501 | NO_STR |
| 5502 | "Configure BGP aggregate entries\n" |
| 5503 | "Aggregate address\n" |
| 5504 | "Aggregate mask\n" |
| 5505 | "Generate AS set path information\n") |
| 5506 | |
| 5507 | ALIAS (no_aggregate_address_mask, |
| 5508 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5509 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5510 | NO_STR |
| 5511 | "Configure BGP aggregate entries\n" |
| 5512 | "Aggregate address\n" |
| 5513 | "Aggregate mask\n" |
| 5514 | "Generate AS set path information\n" |
| 5515 | "Filter more specific routes from updates\n") |
| 5516 | |
| 5517 | ALIAS (no_aggregate_address_mask, |
| 5518 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5519 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5520 | NO_STR |
| 5521 | "Configure BGP aggregate entries\n" |
| 5522 | "Aggregate address\n" |
| 5523 | "Aggregate mask\n" |
| 5524 | "Filter more specific routes from updates\n" |
| 5525 | "Generate AS set path information\n") |
| 5526 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5527 | DEFUN (ipv6_aggregate_address, |
| 5528 | ipv6_aggregate_address_cmd, |
| 5529 | "aggregate-address X:X::X:X/M", |
| 5530 | "Configure BGP aggregate entries\n" |
| 5531 | "Aggregate prefix\n") |
| 5532 | { |
| 5533 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5534 | } |
| 5535 | |
| 5536 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5537 | ipv6_aggregate_address_summary_only_cmd, |
| 5538 | "aggregate-address X:X::X:X/M summary-only", |
| 5539 | "Configure BGP aggregate entries\n" |
| 5540 | "Aggregate prefix\n" |
| 5541 | "Filter more specific routes from updates\n") |
| 5542 | { |
| 5543 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5544 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5545 | } |
| 5546 | |
| 5547 | DEFUN (no_ipv6_aggregate_address, |
| 5548 | no_ipv6_aggregate_address_cmd, |
| 5549 | "no aggregate-address X:X::X:X/M", |
| 5550 | NO_STR |
| 5551 | "Configure BGP aggregate entries\n" |
| 5552 | "Aggregate prefix\n") |
| 5553 | { |
| 5554 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5555 | } |
| 5556 | |
| 5557 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5558 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5559 | "no aggregate-address X:X::X:X/M summary-only", |
| 5560 | NO_STR |
| 5561 | "Configure BGP aggregate entries\n" |
| 5562 | "Aggregate prefix\n" |
| 5563 | "Filter more specific routes from updates\n") |
| 5564 | { |
| 5565 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5566 | } |
| 5567 | |
| 5568 | ALIAS (ipv6_aggregate_address, |
| 5569 | old_ipv6_aggregate_address_cmd, |
| 5570 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5571 | IPV6_STR |
| 5572 | BGP_STR |
| 5573 | "Configure BGP aggregate entries\n" |
| 5574 | "Aggregate prefix\n") |
| 5575 | |
| 5576 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5577 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5578 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5579 | IPV6_STR |
| 5580 | BGP_STR |
| 5581 | "Configure BGP aggregate entries\n" |
| 5582 | "Aggregate prefix\n" |
| 5583 | "Filter more specific routes from updates\n") |
| 5584 | |
| 5585 | ALIAS (no_ipv6_aggregate_address, |
| 5586 | old_no_ipv6_aggregate_address_cmd, |
| 5587 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5588 | NO_STR |
| 5589 | IPV6_STR |
| 5590 | BGP_STR |
| 5591 | "Configure BGP aggregate entries\n" |
| 5592 | "Aggregate prefix\n") |
| 5593 | |
| 5594 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5595 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5596 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5597 | NO_STR |
| 5598 | IPV6_STR |
| 5599 | BGP_STR |
| 5600 | "Configure BGP aggregate entries\n" |
| 5601 | "Aggregate prefix\n" |
| 5602 | "Filter more specific routes from updates\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5603 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5604 | /* Redistribute route treatment. */ |
| 5605 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5606 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5607 | const struct in6_addr *nexthop6, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5608 | u_int32_t metric, u_char type) |
| 5609 | { |
| 5610 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5611 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5612 | struct bgp_info *new; |
| 5613 | struct bgp_info *bi; |
| 5614 | struct bgp_info info; |
| 5615 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5616 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5617 | struct attr *new_attr; |
| 5618 | afi_t afi; |
| 5619 | int ret; |
| 5620 | |
| 5621 | /* Make default attribute. */ |
| 5622 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5623 | if (nexthop) |
| 5624 | attr.nexthop = *nexthop; |
| 5625 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5626 | if (nexthop6) |
| 5627 | { |
| 5628 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5629 | extra->mp_nexthop_global = *nexthop6; |
| 5630 | extra->mp_nexthop_len = 16; |
| 5631 | } |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5632 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5633 | attr.med = metric; |
| 5634 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5635 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5636 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5637 | { |
| 5638 | afi = family2afi (p->family); |
| 5639 | |
| 5640 | if (bgp->redist[afi][type]) |
| 5641 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5642 | struct attr attr_new; |
| 5643 | struct attr_extra extra_new; |
| 5644 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5645 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5646 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5647 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5648 | |
| 5649 | if (bgp->redist_metric_flag[afi][type]) |
| 5650 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5651 | |
| 5652 | /* Apply route-map. */ |
Daniel Walton | 1994dc8 | 2015-09-17 10:15:59 -0400 | [diff] [blame] | 5653 | if (bgp->rmap[afi][type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5654 | { |
| 5655 | info.peer = bgp->peer_self; |
| 5656 | info.attr = &attr_new; |
| 5657 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5658 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5659 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5660 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5661 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5662 | |
| 5663 | bgp->peer_self->rmap_type = 0; |
| 5664 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5665 | if (ret == RMAP_DENYMATCH) |
| 5666 | { |
| 5667 | /* Free uninterned attribute. */ |
| 5668 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5669 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5670 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5671 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5672 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5673 | bgp_redistribute_delete (p, type); |
| 5674 | return; |
| 5675 | } |
| 5676 | } |
| 5677 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5678 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5679 | afi, SAFI_UNICAST, p, NULL); |
| 5680 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5681 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5682 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5683 | for (bi = bn->info; bi; bi = bi->next) |
| 5684 | if (bi->peer == bgp->peer_self |
| 5685 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5686 | break; |
| 5687 | |
| 5688 | if (bi) |
| 5689 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5690 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5691 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5692 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5693 | bgp_attr_unintern (&new_attr); |
| 5694 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5695 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5696 | bgp_unlock_node (bn); |
| 5697 | return; |
| 5698 | } |
| 5699 | else |
| 5700 | { |
| 5701 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5702 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5703 | |
| 5704 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5705 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5706 | bgp_info_restore(bn, bi); |
| 5707 | else |
| 5708 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5709 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5710 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5711 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5712 | |
| 5713 | /* Process change. */ |
| 5714 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5715 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5716 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5717 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5718 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5719 | return; |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 5720 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5721 | } |
| 5722 | |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 5723 | new = info_make(type, BGP_ROUTE_REDISTRIBUTE, bgp->peer_self, |
| 5724 | new_attr, bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5725 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5726 | |
| 5727 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5728 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5729 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5730 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5731 | } |
| 5732 | } |
| 5733 | |
| 5734 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5735 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5736 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5737 | } |
| 5738 | |
| 5739 | void |
| 5740 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5741 | { |
| 5742 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5743 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5744 | afi_t afi; |
| 5745 | struct bgp_node *rn; |
| 5746 | struct bgp_info *ri; |
| 5747 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5748 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5749 | { |
| 5750 | afi = family2afi (p->family); |
| 5751 | |
| 5752 | if (bgp->redist[afi][type]) |
| 5753 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5754 | 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] | 5755 | |
| 5756 | for (ri = rn->info; ri; ri = ri->next) |
| 5757 | if (ri->peer == bgp->peer_self |
| 5758 | && ri->type == type) |
| 5759 | break; |
| 5760 | |
| 5761 | if (ri) |
| 5762 | { |
| 5763 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5764 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5765 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5766 | } |
| 5767 | bgp_unlock_node (rn); |
| 5768 | } |
| 5769 | } |
| 5770 | } |
| 5771 | |
| 5772 | /* Withdraw specified route type's route. */ |
| 5773 | void |
| 5774 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5775 | { |
| 5776 | struct bgp_node *rn; |
| 5777 | struct bgp_info *ri; |
| 5778 | struct bgp_table *table; |
| 5779 | |
| 5780 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5781 | |
| 5782 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5783 | { |
| 5784 | for (ri = rn->info; ri; ri = ri->next) |
| 5785 | if (ri->peer == bgp->peer_self |
| 5786 | && ri->type == type) |
| 5787 | break; |
| 5788 | |
| 5789 | if (ri) |
| 5790 | { |
| 5791 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5792 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5793 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5794 | } |
| 5795 | } |
| 5796 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5797 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5798 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5799 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5800 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5801 | { |
| 5802 | int len; |
| 5803 | u_int32_t destination; |
| 5804 | char buf[BUFSIZ]; |
| 5805 | |
| 5806 | if (p->family == AF_INET) |
| 5807 | { |
| 5808 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5809 | destination = ntohl (p->u.prefix4.s_addr); |
| 5810 | |
| 5811 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5812 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5813 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5814 | || p->u.prefix4.s_addr == 0) |
| 5815 | { |
| 5816 | /* When mask is natural, mask is not displayed. */ |
| 5817 | } |
| 5818 | else |
| 5819 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5820 | } |
| 5821 | else |
| 5822 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5823 | p->prefixlen); |
| 5824 | |
| 5825 | len = 17 - len; |
| 5826 | if (len < 1) |
| 5827 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5828 | else |
| 5829 | vty_out (vty, "%*s", len, " "); |
| 5830 | } |
| 5831 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5832 | enum bgp_display_type |
| 5833 | { |
| 5834 | normal_list, |
| 5835 | }; |
| 5836 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5837 | /* Print the short form route status for a bgp_info */ |
| 5838 | static void |
| 5839 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5840 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5841 | /* Route status display. */ |
| 5842 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5843 | vty_out (vty, "R"); |
| 5844 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5845 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5846 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5847 | vty_out (vty, "s"); |
Daniel Walton | e2a0ebf | 2015-05-19 18:03:43 -0700 | [diff] [blame^] | 5848 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_VALID) && |
| 5849 | ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5850 | vty_out (vty, "*"); |
| 5851 | else |
| 5852 | vty_out (vty, " "); |
| 5853 | |
| 5854 | /* Selected */ |
| 5855 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5856 | vty_out (vty, "h"); |
| 5857 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5858 | vty_out (vty, "d"); |
| 5859 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5860 | vty_out (vty, ">"); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 5861 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
| 5862 | vty_out (vty, "="); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5863 | else |
| 5864 | vty_out (vty, " "); |
| 5865 | |
| 5866 | /* Internal route. */ |
| 5867 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5868 | vty_out (vty, "i"); |
| 5869 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5870 | vty_out (vty, " "); |
| 5871 | } |
| 5872 | |
| 5873 | /* called from terminal list command */ |
| 5874 | void |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5875 | route_vty_out( |
| 5876 | struct vty *vty, |
| 5877 | struct prefix *p, |
| 5878 | struct bgp_info *binfo, |
| 5879 | int display, |
| 5880 | safi_t safi) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5881 | { |
| 5882 | struct attr *attr; |
| 5883 | |
| 5884 | /* short status lead text */ |
| 5885 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5886 | |
| 5887 | /* print prefix and mask */ |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5888 | if (!display) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5889 | route_vty_out_route (p, vty); |
| 5890 | else |
| 5891 | vty_out (vty, "%*s", 17, " "); |
| 5892 | |
| 5893 | /* Print attribute */ |
| 5894 | attr = binfo->attr; |
| 5895 | if (attr) |
| 5896 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5897 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5898 | /* |
| 5899 | * NEXTHOP start |
| 5900 | */ |
| 5901 | |
| 5902 | /* |
| 5903 | * For ENCAP routes, nexthop address family is not |
| 5904 | * neccessarily the same as the prefix address family. |
| 5905 | * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field |
| 5906 | */ |
| 5907 | if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) { |
| 5908 | if (attr->extra) { |
| 5909 | char buf[BUFSIZ]; |
| 5910 | int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len); |
| 5911 | |
| 5912 | switch (af) { |
| 5913 | case AF_INET: |
| 5914 | vty_out (vty, "%s", inet_ntop(af, |
| 5915 | &attr->extra->mp_nexthop_global_in, buf, BUFSIZ)); |
| 5916 | break; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5917 | case AF_INET6: |
| 5918 | vty_out (vty, "%s", inet_ntop(af, |
| 5919 | &attr->extra->mp_nexthop_global, buf, BUFSIZ)); |
| 5920 | break; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5921 | default: |
| 5922 | vty_out(vty, "?"); |
| 5923 | } |
| 5924 | } else { |
| 5925 | vty_out(vty, "?"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5926 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5927 | } else { |
| 5928 | |
| 5929 | if (p->family == AF_INET) |
| 5930 | { |
| 5931 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5932 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5933 | else if (p->family == AF_INET6) |
| 5934 | { |
| 5935 | int len; |
| 5936 | char buf[BUFSIZ]; |
| 5937 | |
| 5938 | len = vty_out (vty, "%s", |
| 5939 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5940 | buf, BUFSIZ)); |
| 5941 | len = 16 - len; |
| 5942 | if (len < 1) |
| 5943 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5944 | else |
| 5945 | vty_out (vty, "%*s", len, " "); |
| 5946 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5947 | else |
| 5948 | { |
| 5949 | vty_out(vty, "?"); |
| 5950 | } |
| 5951 | } |
| 5952 | |
| 5953 | /* |
| 5954 | * NEXTHOP end |
| 5955 | */ |
| 5956 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5957 | |
| 5958 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5959 | vty_out (vty, "%10u ", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5960 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5961 | vty_out (vty, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5962 | |
| 5963 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5964 | vty_out (vty, "%7u ", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5965 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5966 | vty_out (vty, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5967 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5968 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5969 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5970 | /* Print aspath */ |
| 5971 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5972 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5973 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5974 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5975 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5976 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5977 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5978 | } |
| 5979 | |
| 5980 | /* called from terminal list command */ |
| 5981 | void |
| 5982 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5983 | struct attr *attr, safi_t safi) |
| 5984 | { |
| 5985 | /* Route status display. */ |
| 5986 | vty_out (vty, "*"); |
| 5987 | vty_out (vty, ">"); |
| 5988 | vty_out (vty, " "); |
| 5989 | |
| 5990 | /* print prefix and mask */ |
| 5991 | route_vty_out_route (p, vty); |
| 5992 | |
| 5993 | /* Print attribute */ |
| 5994 | if (attr) |
| 5995 | { |
| 5996 | if (p->family == AF_INET) |
| 5997 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5998 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5999 | vty_out (vty, "%-16s", |
| 6000 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6001 | else |
| 6002 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6003 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6004 | else if (p->family == AF_INET6) |
| 6005 | { |
| 6006 | int len; |
| 6007 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6008 | |
| 6009 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6010 | |
| 6011 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6012 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6013 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6014 | len = 16 - len; |
| 6015 | if (len < 1) |
| 6016 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 6017 | else |
| 6018 | vty_out (vty, "%*s", len, " "); |
| 6019 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6020 | |
| 6021 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6022 | vty_out (vty, "%10u ", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6023 | else |
| 6024 | vty_out (vty, " "); |
| 6025 | |
| 6026 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6027 | vty_out (vty, "%7u ", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6028 | else |
| 6029 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6030 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6031 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6032 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6033 | /* Print aspath */ |
| 6034 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6035 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6036 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6037 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6038 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6039 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6040 | |
| 6041 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6042 | } |
| 6043 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6044 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6045 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 6046 | struct bgp_info *binfo, int display, safi_t safi) |
| 6047 | { |
| 6048 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6049 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6050 | |
| 6051 | if (!binfo->extra) |
| 6052 | return; |
| 6053 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6054 | /* short status lead text */ |
| 6055 | route_vty_short_status_out (vty, binfo); |
| 6056 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6057 | /* print prefix and mask */ |
| 6058 | if (! display) |
| 6059 | route_vty_out_route (p, vty); |
| 6060 | else |
| 6061 | vty_out (vty, "%*s", 17, " "); |
| 6062 | |
| 6063 | /* Print attribute */ |
| 6064 | attr = binfo->attr; |
| 6065 | if (attr) |
| 6066 | { |
| 6067 | if (p->family == AF_INET) |
| 6068 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6069 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6070 | vty_out (vty, "%-16s", |
| 6071 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6072 | else |
| 6073 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6074 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6075 | else if (p->family == AF_INET6) |
| 6076 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6077 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6078 | char buf[BUFSIZ]; |
| 6079 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6080 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6081 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6082 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6083 | buf, BUFSIZ)); |
| 6084 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6085 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6086 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6087 | buf, BUFSIZ), |
| 6088 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 6089 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6090 | |
| 6091 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6092 | } |
| 6093 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6094 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6095 | |
| 6096 | vty_out (vty, "notag/%d", label); |
| 6097 | |
| 6098 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6099 | } |
| 6100 | |
| 6101 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6102 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6103 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 6104 | struct bgp_info *binfo, int display, safi_t safi) |
| 6105 | { |
| 6106 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6107 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6108 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6109 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6110 | /* short status lead text */ |
| 6111 | route_vty_short_status_out (vty, binfo); |
| 6112 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6113 | /* print prefix and mask */ |
| 6114 | if (! display) |
| 6115 | route_vty_out_route (p, vty); |
| 6116 | else |
| 6117 | vty_out (vty, "%*s", 17, " "); |
| 6118 | |
| 6119 | len = vty_out (vty, "%s", binfo->peer->host); |
| 6120 | len = 17 - len; |
| 6121 | if (len < 1) |
| 6122 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 6123 | else |
| 6124 | vty_out (vty, "%*s", len, " "); |
| 6125 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6126 | 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] | 6127 | |
| 6128 | /* Print attribute */ |
| 6129 | attr = binfo->attr; |
| 6130 | if (attr) |
| 6131 | { |
| 6132 | /* Print aspath */ |
| 6133 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6134 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6135 | |
| 6136 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6137 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6138 | } |
| 6139 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6140 | } |
| 6141 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6142 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6143 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6144 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 6145 | struct bgp_info *binfo, int display, safi_t safi) |
| 6146 | { |
| 6147 | struct attr *attr; |
| 6148 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6149 | char timebuf[BGP_UPTIME_LEN]; |
| 6150 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6151 | |
| 6152 | if (!binfo->extra) |
| 6153 | return; |
| 6154 | |
| 6155 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6156 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6157 | /* short status lead text */ |
| 6158 | route_vty_short_status_out (vty, binfo); |
| 6159 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6160 | /* print prefix and mask */ |
| 6161 | if (! display) |
| 6162 | route_vty_out_route (p, vty); |
| 6163 | else |
| 6164 | vty_out (vty, "%*s", 17, " "); |
| 6165 | |
| 6166 | len = vty_out (vty, "%s", binfo->peer->host); |
| 6167 | len = 16 - len; |
| 6168 | if (len < 1) |
| 6169 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 6170 | else |
| 6171 | vty_out (vty, "%*s", len, " "); |
| 6172 | |
| 6173 | len = vty_out (vty, "%d", bdi->flap); |
| 6174 | len = 5 - len; |
| 6175 | if (len < 1) |
| 6176 | vty_out (vty, " "); |
| 6177 | else |
| 6178 | vty_out (vty, "%*s ", len, " "); |
| 6179 | |
| 6180 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 6181 | timebuf, BGP_UPTIME_LEN)); |
| 6182 | |
| 6183 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 6184 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6185 | 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] | 6186 | else |
| 6187 | vty_out (vty, "%*s ", 8, " "); |
| 6188 | |
| 6189 | /* Print attribute */ |
| 6190 | attr = binfo->attr; |
| 6191 | if (attr) |
| 6192 | { |
| 6193 | /* Print aspath */ |
| 6194 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6195 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6196 | |
| 6197 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6198 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6199 | } |
| 6200 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6201 | } |
| 6202 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6203 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6204 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 6205 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 6206 | { |
| 6207 | char buf[INET6_ADDRSTRLEN]; |
| 6208 | char buf1[BUFSIZ]; |
| 6209 | struct attr *attr; |
| 6210 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6211 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6212 | time_t tbuf; |
| 6213 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6214 | |
| 6215 | attr = binfo->attr; |
| 6216 | |
| 6217 | if (attr) |
| 6218 | { |
| 6219 | /* Line1 display AS-path, Aggregator */ |
| 6220 | if (attr->aspath) |
| 6221 | { |
| 6222 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 6223 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6224 | vty_out (vty, "Local"); |
| 6225 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6226 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6227 | } |
| 6228 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6229 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 6230 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6231 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 6232 | vty_out (vty, ", (stale)"); |
| 6233 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 6234 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6235 | attr->extra->aggregator_as, |
| 6236 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6237 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 6238 | vty_out (vty, ", (Received from a RR-client)"); |
| 6239 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 6240 | vty_out (vty, ", (Received from a RS-client)"); |
| 6241 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6242 | vty_out (vty, ", (history entry)"); |
| 6243 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 6244 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6245 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6246 | |
| 6247 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 6248 | if (p->family == AF_INET) |
| 6249 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6250 | vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6251 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6252 | inet_ntoa (attr->nexthop)); |
| 6253 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6254 | else |
| 6255 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6256 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6257 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6258 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6259 | buf, INET6_ADDRSTRLEN)); |
| 6260 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6261 | |
| 6262 | if (binfo->peer == bgp->peer_self) |
| 6263 | { |
| 6264 | vty_out (vty, " from %s ", |
| 6265 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 6266 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 6267 | } |
| 6268 | else |
| 6269 | { |
| 6270 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6271 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6272 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 6273 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6274 | if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) { |
| 6275 | buf[0] = '?'; |
| 6276 | buf[1] = 0; |
| 6277 | } |
| 6278 | vty_out (vty, " from %s", buf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6279 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6280 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6281 | else |
| 6282 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 6283 | } |
| 6284 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6285 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6286 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6287 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6288 | { |
| 6289 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6290 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6291 | buf, INET6_ADDRSTRLEN), |
| 6292 | VTY_NEWLINE); |
| 6293 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6294 | |
| 6295 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 6296 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 6297 | |
| 6298 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6299 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6300 | |
| 6301 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6302 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6303 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6304 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6305 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6306 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6307 | vty_out (vty, ", weight %u", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6308 | |
Daniel Walton | e2a0ebf | 2015-05-19 18:03:43 -0700 | [diff] [blame^] | 6309 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6310 | vty_out (vty, ", invalid"); |
| 6311 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6312 | vty_out (vty, ", valid"); |
| 6313 | |
| 6314 | if (binfo->peer != bgp->peer_self) |
| 6315 | { |
| 6316 | if (binfo->peer->as == binfo->peer->local_as) |
| 6317 | vty_out (vty, ", internal"); |
| 6318 | else |
| 6319 | vty_out (vty, ", %s", |
| 6320 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6321 | } |
| 6322 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6323 | vty_out (vty, ", aggregated, local"); |
| 6324 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6325 | vty_out (vty, ", sourced"); |
| 6326 | else |
| 6327 | vty_out (vty, ", sourced, local"); |
| 6328 | |
| 6329 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6330 | vty_out (vty, ", atomic-aggregate"); |
| 6331 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6332 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6333 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6334 | bgp_info_mpath_count (binfo))) |
| 6335 | vty_out (vty, ", multipath"); |
| 6336 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6337 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6338 | vty_out (vty, ", best"); |
| 6339 | |
| 6340 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6341 | |
| 6342 | /* Line 4 display Community */ |
| 6343 | if (attr->community) |
| 6344 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6345 | VTY_NEWLINE); |
| 6346 | |
| 6347 | /* Line 5 display Extended-community */ |
| 6348 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6349 | vty_out (vty, " Extended Community: %s%s", |
| 6350 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6351 | |
| 6352 | /* Line 6 display Originator, Cluster-id */ |
| 6353 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6354 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6355 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6356 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6357 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6358 | vty_out (vty, " Originator: %s", |
| 6359 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6360 | |
| 6361 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6362 | { |
| 6363 | int i; |
| 6364 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6365 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6366 | vty_out (vty, "%s ", |
| 6367 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6368 | } |
| 6369 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6370 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6371 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6372 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6373 | bgp_damp_info_vty (vty, binfo); |
| 6374 | |
| 6375 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6376 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6377 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6378 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6379 | #else |
| 6380 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6381 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6382 | } |
| 6383 | vty_out (vty, "%s", VTY_NEWLINE); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 6384 | } |
| 6385 | |
| 6386 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\ |
| 6387 | "h history, * valid, > best, = multipath,%s"\ |
| 6388 | " i internal, r RIB-failure, S Stale, R Removed%s" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6389 | #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] | 6390 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6391 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6392 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6393 | |
| 6394 | enum bgp_show_type |
| 6395 | { |
| 6396 | bgp_show_type_normal, |
| 6397 | bgp_show_type_regexp, |
| 6398 | bgp_show_type_prefix_list, |
| 6399 | bgp_show_type_filter_list, |
| 6400 | bgp_show_type_route_map, |
| 6401 | bgp_show_type_neighbor, |
| 6402 | bgp_show_type_cidr_only, |
| 6403 | bgp_show_type_prefix_longer, |
| 6404 | bgp_show_type_community_all, |
| 6405 | bgp_show_type_community, |
| 6406 | bgp_show_type_community_exact, |
| 6407 | bgp_show_type_community_list, |
| 6408 | bgp_show_type_community_list_exact, |
| 6409 | bgp_show_type_flap_statistics, |
| 6410 | bgp_show_type_flap_address, |
| 6411 | bgp_show_type_flap_prefix, |
| 6412 | bgp_show_type_flap_cidr_only, |
| 6413 | bgp_show_type_flap_regexp, |
| 6414 | bgp_show_type_flap_filter_list, |
| 6415 | bgp_show_type_flap_prefix_list, |
| 6416 | bgp_show_type_flap_prefix_longer, |
| 6417 | bgp_show_type_flap_route_map, |
| 6418 | bgp_show_type_flap_neighbor, |
| 6419 | bgp_show_type_dampend_paths, |
| 6420 | bgp_show_type_damp_neighbor |
| 6421 | }; |
| 6422 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6423 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6424 | 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] | 6425 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6426 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6427 | struct bgp_info *ri; |
| 6428 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6429 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6430 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6431 | unsigned long output_count; |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6432 | unsigned long total_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6433 | |
| 6434 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6435 | output_count = 0; |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6436 | total_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6437 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6438 | /* Start processing of routes. */ |
| 6439 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6440 | if (rn->info != NULL) |
| 6441 | { |
| 6442 | display = 0; |
| 6443 | |
| 6444 | for (ri = rn->info; ri; ri = ri->next) |
| 6445 | { |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6446 | total_count++; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6447 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6448 | || type == bgp_show_type_flap_address |
| 6449 | || type == bgp_show_type_flap_prefix |
| 6450 | || type == bgp_show_type_flap_cidr_only |
| 6451 | || type == bgp_show_type_flap_regexp |
| 6452 | || type == bgp_show_type_flap_filter_list |
| 6453 | || type == bgp_show_type_flap_prefix_list |
| 6454 | || type == bgp_show_type_flap_prefix_longer |
| 6455 | || type == bgp_show_type_flap_route_map |
| 6456 | || type == bgp_show_type_flap_neighbor |
| 6457 | || type == bgp_show_type_dampend_paths |
| 6458 | || type == bgp_show_type_damp_neighbor) |
| 6459 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6460 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6461 | continue; |
| 6462 | } |
| 6463 | if (type == bgp_show_type_regexp |
| 6464 | || type == bgp_show_type_flap_regexp) |
| 6465 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6466 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6467 | |
| 6468 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6469 | continue; |
| 6470 | } |
| 6471 | if (type == bgp_show_type_prefix_list |
| 6472 | || type == bgp_show_type_flap_prefix_list) |
| 6473 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6474 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6475 | |
| 6476 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6477 | continue; |
| 6478 | } |
| 6479 | if (type == bgp_show_type_filter_list |
| 6480 | || type == bgp_show_type_flap_filter_list) |
| 6481 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6482 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6483 | |
| 6484 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6485 | continue; |
| 6486 | } |
| 6487 | if (type == bgp_show_type_route_map |
| 6488 | || type == bgp_show_type_flap_route_map) |
| 6489 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6490 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6491 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6492 | struct attr dummy_attr; |
| 6493 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6494 | int ret; |
| 6495 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6496 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6497 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6498 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6499 | binfo.peer = ri->peer; |
| 6500 | binfo.attr = &dummy_attr; |
| 6501 | |
| 6502 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6503 | if (ret == RMAP_DENYMATCH) |
| 6504 | continue; |
| 6505 | } |
| 6506 | if (type == bgp_show_type_neighbor |
| 6507 | || type == bgp_show_type_flap_neighbor |
| 6508 | || type == bgp_show_type_damp_neighbor) |
| 6509 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6510 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6511 | |
| 6512 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6513 | continue; |
| 6514 | } |
| 6515 | if (type == bgp_show_type_cidr_only |
| 6516 | || type == bgp_show_type_flap_cidr_only) |
| 6517 | { |
| 6518 | u_int32_t destination; |
| 6519 | |
| 6520 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6521 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6522 | continue; |
| 6523 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6524 | continue; |
| 6525 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6526 | continue; |
| 6527 | } |
| 6528 | if (type == bgp_show_type_prefix_longer |
| 6529 | || type == bgp_show_type_flap_prefix_longer) |
| 6530 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6531 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6532 | |
| 6533 | if (! prefix_match (p, &rn->p)) |
| 6534 | continue; |
| 6535 | } |
| 6536 | if (type == bgp_show_type_community_all) |
| 6537 | { |
| 6538 | if (! ri->attr->community) |
| 6539 | continue; |
| 6540 | } |
| 6541 | if (type == bgp_show_type_community) |
| 6542 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6543 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6544 | |
| 6545 | if (! ri->attr->community || |
| 6546 | ! community_match (ri->attr->community, com)) |
| 6547 | continue; |
| 6548 | } |
| 6549 | if (type == bgp_show_type_community_exact) |
| 6550 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6551 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6552 | |
| 6553 | if (! ri->attr->community || |
| 6554 | ! community_cmp (ri->attr->community, com)) |
| 6555 | continue; |
| 6556 | } |
| 6557 | if (type == bgp_show_type_community_list) |
| 6558 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6559 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6560 | |
| 6561 | if (! community_list_match (ri->attr->community, list)) |
| 6562 | continue; |
| 6563 | } |
| 6564 | if (type == bgp_show_type_community_list_exact) |
| 6565 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6566 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6567 | |
| 6568 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6569 | continue; |
| 6570 | } |
| 6571 | if (type == bgp_show_type_flap_address |
| 6572 | || type == bgp_show_type_flap_prefix) |
| 6573 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6574 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6575 | |
| 6576 | if (! prefix_match (&rn->p, p)) |
| 6577 | continue; |
| 6578 | |
| 6579 | if (type == bgp_show_type_flap_prefix) |
| 6580 | if (p->prefixlen != rn->p.prefixlen) |
| 6581 | continue; |
| 6582 | } |
| 6583 | if (type == bgp_show_type_dampend_paths |
| 6584 | || type == bgp_show_type_damp_neighbor) |
| 6585 | { |
| 6586 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6587 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6588 | continue; |
| 6589 | } |
| 6590 | |
| 6591 | if (header) |
| 6592 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6593 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6594 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6595 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6596 | if (type == bgp_show_type_dampend_paths |
| 6597 | || type == bgp_show_type_damp_neighbor) |
| 6598 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6599 | else if (type == bgp_show_type_flap_statistics |
| 6600 | || type == bgp_show_type_flap_address |
| 6601 | || type == bgp_show_type_flap_prefix |
| 6602 | || type == bgp_show_type_flap_cidr_only |
| 6603 | || type == bgp_show_type_flap_regexp |
| 6604 | || type == bgp_show_type_flap_filter_list |
| 6605 | || type == bgp_show_type_flap_prefix_list |
| 6606 | || type == bgp_show_type_flap_prefix_longer |
| 6607 | || type == bgp_show_type_flap_route_map |
| 6608 | || type == bgp_show_type_flap_neighbor) |
| 6609 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6610 | else |
| 6611 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6612 | header = 0; |
| 6613 | } |
| 6614 | |
| 6615 | if (type == bgp_show_type_dampend_paths |
| 6616 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6617 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6618 | else if (type == bgp_show_type_flap_statistics |
| 6619 | || type == bgp_show_type_flap_address |
| 6620 | || type == bgp_show_type_flap_prefix |
| 6621 | || type == bgp_show_type_flap_cidr_only |
| 6622 | || type == bgp_show_type_flap_regexp |
| 6623 | || type == bgp_show_type_flap_filter_list |
| 6624 | || type == bgp_show_type_flap_prefix_list |
| 6625 | || type == bgp_show_type_flap_prefix_longer |
| 6626 | || type == bgp_show_type_flap_route_map |
| 6627 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6628 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6629 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6630 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6631 | display++; |
| 6632 | } |
| 6633 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6634 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6635 | } |
| 6636 | |
| 6637 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6638 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6639 | { |
| 6640 | if (type == bgp_show_type_normal) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6641 | vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6642 | } |
| 6643 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6644 | vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s", |
| 6645 | VTY_NEWLINE, output_count, total_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6646 | |
| 6647 | return CMD_SUCCESS; |
| 6648 | } |
| 6649 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6650 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6651 | 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] | 6652 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6653 | { |
| 6654 | struct bgp_table *table; |
| 6655 | |
| 6656 | if (bgp == NULL) { |
| 6657 | bgp = bgp_get_default (); |
| 6658 | } |
| 6659 | |
| 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 | table = bgp->rib[afi][safi]; |
| 6668 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6669 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6670 | } |
| 6671 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6672 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6673 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6674 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6675 | struct bgp_node *rn, |
| 6676 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6677 | { |
| 6678 | struct bgp_info *ri; |
| 6679 | struct prefix *p; |
| 6680 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6681 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6682 | char buf1[INET6_ADDRSTRLEN]; |
| 6683 | char buf2[INET6_ADDRSTRLEN]; |
| 6684 | int count = 0; |
| 6685 | int best = 0; |
| 6686 | int suppress = 0; |
| 6687 | int no_export = 0; |
| 6688 | int no_advertise = 0; |
| 6689 | int local_as = 0; |
| 6690 | int first = 0; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6691 | int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6692 | |
| 6693 | p = &rn->p; |
| 6694 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6695 | (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6696 | printrd ? ":" : "", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6697 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6698 | p->prefixlen, VTY_NEWLINE); |
| 6699 | |
| 6700 | for (ri = rn->info; ri; ri = ri->next) |
| 6701 | { |
| 6702 | count++; |
| 6703 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6704 | { |
| 6705 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6706 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6707 | suppress = 1; |
| 6708 | if (ri->attr->community != NULL) |
| 6709 | { |
| 6710 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6711 | no_advertise = 1; |
| 6712 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6713 | no_export = 1; |
| 6714 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6715 | local_as = 1; |
| 6716 | } |
| 6717 | } |
| 6718 | } |
| 6719 | |
| 6720 | vty_out (vty, "Paths: (%d available", count); |
| 6721 | if (best) |
| 6722 | { |
| 6723 | vty_out (vty, ", best #%d", best); |
| 6724 | if (safi == SAFI_UNICAST) |
| 6725 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6726 | } |
| 6727 | else |
| 6728 | vty_out (vty, ", no best path"); |
| 6729 | if (no_advertise) |
| 6730 | vty_out (vty, ", not advertised to any peer"); |
| 6731 | else if (no_export) |
| 6732 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6733 | else if (local_as) |
| 6734 | vty_out (vty, ", not advertised outside local AS"); |
| 6735 | if (suppress) |
| 6736 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6737 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6738 | |
| 6739 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6740 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6741 | { |
| 6742 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6743 | { |
| 6744 | if (! first) |
| 6745 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6746 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6747 | first = 1; |
| 6748 | } |
| 6749 | } |
| 6750 | if (! first) |
| 6751 | vty_out (vty, " Not advertised to any peer"); |
| 6752 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6753 | } |
| 6754 | |
| 6755 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6756 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6757 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6758 | struct bgp_table *rib, const char *ip_str, |
| 6759 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6760 | int prefix_check, enum bgp_path_type pathtype) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6761 | { |
| 6762 | int ret; |
| 6763 | int header; |
| 6764 | int display = 0; |
| 6765 | struct prefix match; |
| 6766 | struct bgp_node *rn; |
| 6767 | struct bgp_node *rm; |
| 6768 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6769 | struct bgp_table *table; |
| 6770 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 6771 | memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6772 | /* Check IP address argument. */ |
| 6773 | ret = str2prefix (ip_str, &match); |
| 6774 | if (! ret) |
| 6775 | { |
| 6776 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6777 | return CMD_WARNING; |
| 6778 | } |
| 6779 | |
| 6780 | match.family = afi2family (afi); |
| 6781 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6782 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6783 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6784 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6785 | { |
| 6786 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6787 | continue; |
| 6788 | |
| 6789 | if ((table = rn->info) != NULL) |
| 6790 | { |
| 6791 | header = 1; |
| 6792 | |
| 6793 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6794 | { |
| 6795 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6796 | { |
| 6797 | bgp_unlock_node (rm); |
| 6798 | continue; |
| 6799 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6800 | |
| 6801 | for (ri = rm->info; ri; ri = ri->next) |
| 6802 | { |
| 6803 | if (header) |
| 6804 | { |
| 6805 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6806 | AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6807 | |
| 6808 | header = 0; |
| 6809 | } |
| 6810 | display++; |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6811 | |
| 6812 | if (pathtype == BGP_PATH_ALL || |
| 6813 | (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) || |
| 6814 | (pathtype == BGP_PATH_MULTIPATH && |
| 6815 | (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)))) |
| 6816 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6817 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6818 | |
| 6819 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6820 | } |
| 6821 | } |
| 6822 | } |
| 6823 | } |
| 6824 | else |
| 6825 | { |
| 6826 | header = 1; |
| 6827 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6828 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6829 | { |
| 6830 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6831 | { |
| 6832 | for (ri = rn->info; ri; ri = ri->next) |
| 6833 | { |
| 6834 | if (header) |
| 6835 | { |
| 6836 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6837 | header = 0; |
| 6838 | } |
| 6839 | display++; |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6840 | |
| 6841 | if (pathtype == BGP_PATH_ALL || |
| 6842 | (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) || |
| 6843 | (pathtype == BGP_PATH_MULTIPATH && |
| 6844 | (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)))) |
| 6845 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6846 | } |
| 6847 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6848 | |
| 6849 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6850 | } |
| 6851 | } |
| 6852 | |
| 6853 | if (! display) |
| 6854 | { |
| 6855 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6856 | return CMD_WARNING; |
| 6857 | } |
| 6858 | |
| 6859 | return CMD_SUCCESS; |
| 6860 | } |
| 6861 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6862 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6863 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6864 | 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] | 6865 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6866 | int prefix_check, enum bgp_path_type pathtype) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6867 | { |
| 6868 | struct bgp *bgp; |
| 6869 | |
| 6870 | /* BGP structure lookup. */ |
| 6871 | if (view_name) |
| 6872 | { |
| 6873 | bgp = bgp_lookup_by_name (view_name); |
| 6874 | if (bgp == NULL) |
| 6875 | { |
| 6876 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6877 | return CMD_WARNING; |
| 6878 | } |
| 6879 | } |
| 6880 | else |
| 6881 | { |
| 6882 | bgp = bgp_get_default (); |
| 6883 | if (bgp == NULL) |
| 6884 | { |
| 6885 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6886 | return CMD_WARNING; |
| 6887 | } |
| 6888 | } |
| 6889 | |
| 6890 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6891 | afi, safi, prd, prefix_check, pathtype); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6892 | } |
| 6893 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6894 | /* BGP route print out function. */ |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 6895 | DEFUN (show_ip_bgp, |
| 6896 | show_ip_bgp_cmd, |
| 6897 | "show ip bgp", |
| 6898 | SHOW_STR |
| 6899 | IP_STR |
| 6900 | BGP_STR) |
| 6901 | { |
| 6902 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6903 | } |
| 6904 | |
| 6905 | DEFUN (show_ip_bgp_ipv4, |
| 6906 | show_ip_bgp_ipv4_cmd, |
| 6907 | "show ip bgp ipv4 (unicast|multicast)", |
| 6908 | SHOW_STR |
| 6909 | IP_STR |
| 6910 | BGP_STR |
| 6911 | "Address family\n" |
| 6912 | "Address Family modifier\n" |
| 6913 | "Address Family modifier\n") |
| 6914 | { |
| 6915 | if (strncmp (argv[0], "m", 1) == 0) |
| 6916 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6917 | NULL); |
| 6918 | |
| 6919 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6920 | } |
| 6921 | |
| 6922 | DEFUN (show_ip_bgp_route, |
| 6923 | show_ip_bgp_route_cmd, |
| 6924 | "show ip bgp A.B.C.D", |
| 6925 | SHOW_STR |
| 6926 | IP_STR |
| 6927 | BGP_STR |
| 6928 | "Network in the BGP routing table to display\n") |
| 6929 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6930 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
| 6931 | } |
| 6932 | |
| 6933 | DEFUN (show_ip_bgp_route_pathtype, |
| 6934 | show_ip_bgp_route_pathtype_cmd, |
| 6935 | "show ip bgp A.B.C.D (bestpath|multipath)", |
| 6936 | SHOW_STR |
| 6937 | IP_STR |
| 6938 | BGP_STR |
| 6939 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 6940 | "Display only the bestpath\n" |
| 6941 | "Display only multipaths\n") |
| 6942 | { |
| 6943 | if (strncmp (argv[1], "b", 1) == 0) |
| 6944 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 6945 | else |
| 6946 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH); |
| 6947 | } |
| 6948 | |
| 6949 | DEFUN (show_bgp_ipv4_safi_route_pathtype, |
| 6950 | show_bgp_ipv4_safi_route_pathtype_cmd, |
| 6951 | "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath)", |
| 6952 | SHOW_STR |
| 6953 | BGP_STR |
| 6954 | "Address family\n" |
| 6955 | "Address Family modifier\n" |
| 6956 | "Address Family modifier\n" |
| 6957 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 6958 | "Display only the bestpath\n" |
| 6959 | "Display only multipaths\n") |
| 6960 | { |
| 6961 | if (strncmp (argv[0], "m", 1) == 0) |
| 6962 | if (strncmp (argv[2], "b", 1) == 0) |
| 6963 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 6964 | else |
| 6965 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH); |
| 6966 | else |
| 6967 | if (strncmp (argv[2], "b", 1) == 0) |
| 6968 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 6969 | else |
| 6970 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 6971 | } |
| 6972 | |
| 6973 | DEFUN (show_ip_bgp_ipv4_route, |
| 6974 | show_ip_bgp_ipv4_route_cmd, |
| 6975 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6976 | SHOW_STR |
| 6977 | IP_STR |
| 6978 | BGP_STR |
| 6979 | "Address family\n" |
| 6980 | "Address Family modifier\n" |
| 6981 | "Address Family modifier\n" |
| 6982 | "Network in the BGP routing table to display\n") |
| 6983 | { |
| 6984 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6985 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 6986 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6987 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 6988 | } |
| 6989 | |
| 6990 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6991 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6992 | "show ip bgp vpnv4 all A.B.C.D", |
| 6993 | SHOW_STR |
| 6994 | IP_STR |
| 6995 | BGP_STR |
| 6996 | "Display VPNv4 NLRI specific information\n" |
| 6997 | "Display information about all VPNv4 NLRIs\n" |
| 6998 | "Network in the BGP routing table to display\n") |
| 6999 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7000 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7001 | } |
| 7002 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7003 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7004 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 7005 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 7006 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 7007 | SHOW_STR |
| 7008 | IP_STR |
| 7009 | BGP_STR |
| 7010 | "Display VPNv4 NLRI specific information\n" |
| 7011 | "Display information for a route distinguisher\n" |
| 7012 | "VPN Route Distinguisher\n" |
| 7013 | "Network in the BGP routing table to display\n") |
| 7014 | { |
| 7015 | int ret; |
| 7016 | struct prefix_rd prd; |
| 7017 | |
| 7018 | ret = str2prefix_rd (argv[0], &prd); |
| 7019 | if (! ret) |
| 7020 | { |
| 7021 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7022 | return CMD_WARNING; |
| 7023 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7024 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7025 | } |
| 7026 | |
| 7027 | DEFUN (show_ip_bgp_prefix, |
| 7028 | show_ip_bgp_prefix_cmd, |
| 7029 | "show ip bgp A.B.C.D/M", |
| 7030 | SHOW_STR |
| 7031 | IP_STR |
| 7032 | BGP_STR |
| 7033 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7034 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7035 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
| 7036 | } |
| 7037 | |
| 7038 | DEFUN (show_ip_bgp_prefix_pathtype, |
| 7039 | show_ip_bgp_prefix_pathtype_cmd, |
| 7040 | "show ip bgp A.B.C.D/M (bestpath|multipath)", |
| 7041 | SHOW_STR |
| 7042 | IP_STR |
| 7043 | BGP_STR |
| 7044 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7045 | "Display only the bestpath\n" |
| 7046 | "Display only multipaths\n") |
| 7047 | { |
| 7048 | if (strncmp (argv[1], "b", 1) == 0) |
| 7049 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7050 | else |
| 7051 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7052 | } |
| 7053 | |
| 7054 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 7055 | show_ip_bgp_ipv4_prefix_cmd, |
| 7056 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 7057 | SHOW_STR |
| 7058 | IP_STR |
| 7059 | BGP_STR |
| 7060 | "Address family\n" |
| 7061 | "Address Family modifier\n" |
| 7062 | "Address Family modifier\n" |
| 7063 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7064 | { |
| 7065 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7066 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7067 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7068 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7069 | } |
| 7070 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7071 | DEFUN (show_ip_bgp_ipv4_prefix_pathtype, |
| 7072 | show_ip_bgp_ipv4_prefix_pathtype_cmd, |
| 7073 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath)", |
| 7074 | SHOW_STR |
| 7075 | IP_STR |
| 7076 | BGP_STR |
| 7077 | "Address family\n" |
| 7078 | "Address Family modifier\n" |
| 7079 | "Address Family modifier\n" |
| 7080 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7081 | "Display only the bestpath\n" |
| 7082 | "Display only multipaths\n") |
| 7083 | { |
| 7084 | if (strncmp (argv[0], "m", 1) == 0) |
| 7085 | if (strncmp (argv[2], "b", 1) == 0) |
| 7086 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7087 | else |
| 7088 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH); |
| 7089 | else |
| 7090 | if (strncmp (argv[2], "b", 1) == 0) |
| 7091 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7092 | else |
| 7093 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH); |
| 7094 | } |
| 7095 | |
| 7096 | ALIAS (show_ip_bgp_ipv4_prefix_pathtype, |
| 7097 | show_bgp_ipv4_safi_prefix_pathtype_cmd, |
| 7098 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath)", |
| 7099 | SHOW_STR |
| 7100 | BGP_STR |
| 7101 | "Address family\n" |
| 7102 | "Address Family modifier\n" |
| 7103 | "Address Family modifier\n" |
| 7104 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7105 | "Display only the bestpath\n" |
| 7106 | "Display only multipaths\n") |
| 7107 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7108 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 7109 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 7110 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 7111 | SHOW_STR |
| 7112 | IP_STR |
| 7113 | BGP_STR |
| 7114 | "Display VPNv4 NLRI specific information\n" |
| 7115 | "Display information about all VPNv4 NLRIs\n" |
| 7116 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7117 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7118 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7119 | } |
| 7120 | |
| 7121 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 7122 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 7123 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 7124 | SHOW_STR |
| 7125 | IP_STR |
| 7126 | BGP_STR |
| 7127 | "Display VPNv4 NLRI specific information\n" |
| 7128 | "Display information for a route distinguisher\n" |
| 7129 | "VPN Route Distinguisher\n" |
| 7130 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7131 | { |
| 7132 | int ret; |
| 7133 | struct prefix_rd prd; |
| 7134 | |
| 7135 | ret = str2prefix_rd (argv[0], &prd); |
| 7136 | if (! ret) |
| 7137 | { |
| 7138 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7139 | return CMD_WARNING; |
| 7140 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7141 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7142 | } |
| 7143 | |
| 7144 | DEFUN (show_ip_bgp_view, |
| 7145 | show_ip_bgp_view_cmd, |
| 7146 | "show ip bgp view WORD", |
| 7147 | SHOW_STR |
| 7148 | IP_STR |
| 7149 | BGP_STR |
| 7150 | "BGP view\n" |
| 7151 | "View name\n") |
| 7152 | { |
| 7153 | struct bgp *bgp; |
| 7154 | |
| 7155 | /* BGP structure lookup. */ |
| 7156 | bgp = bgp_lookup_by_name (argv[0]); |
| 7157 | if (bgp == NULL) |
| 7158 | { |
| 7159 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7160 | return CMD_WARNING; |
| 7161 | } |
| 7162 | |
| 7163 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 7164 | } |
| 7165 | |
| 7166 | DEFUN (show_ip_bgp_view_route, |
| 7167 | show_ip_bgp_view_route_cmd, |
| 7168 | "show ip bgp view WORD A.B.C.D", |
| 7169 | SHOW_STR |
| 7170 | IP_STR |
| 7171 | BGP_STR |
| 7172 | "BGP view\n" |
| 7173 | "View name\n" |
| 7174 | "Network in the BGP routing table to display\n") |
| 7175 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7176 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7177 | } |
| 7178 | |
| 7179 | DEFUN (show_ip_bgp_view_prefix, |
| 7180 | show_ip_bgp_view_prefix_cmd, |
| 7181 | "show ip bgp view WORD A.B.C.D/M", |
| 7182 | SHOW_STR |
| 7183 | IP_STR |
| 7184 | BGP_STR |
| 7185 | "BGP view\n" |
| 7186 | "View name\n" |
| 7187 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7188 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7189 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7190 | } |
| 7191 | |
| 7192 | DEFUN (show_bgp, |
| 7193 | show_bgp_cmd, |
| 7194 | "show bgp", |
| 7195 | SHOW_STR |
| 7196 | BGP_STR) |
| 7197 | { |
| 7198 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 7199 | NULL); |
| 7200 | } |
| 7201 | |
| 7202 | ALIAS (show_bgp, |
| 7203 | show_bgp_ipv6_cmd, |
| 7204 | "show bgp ipv6", |
| 7205 | SHOW_STR |
| 7206 | BGP_STR |
| 7207 | "Address family\n") |
| 7208 | |
| 7209 | /* old command */ |
| 7210 | DEFUN (show_ipv6_bgp, |
| 7211 | show_ipv6_bgp_cmd, |
| 7212 | "show ipv6 bgp", |
| 7213 | SHOW_STR |
| 7214 | IP_STR |
| 7215 | BGP_STR) |
| 7216 | { |
| 7217 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 7218 | NULL); |
| 7219 | } |
| 7220 | |
| 7221 | DEFUN (show_bgp_route, |
| 7222 | show_bgp_route_cmd, |
| 7223 | "show bgp X:X::X:X", |
| 7224 | SHOW_STR |
| 7225 | BGP_STR |
| 7226 | "Network in the BGP routing table to display\n") |
| 7227 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7228 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7229 | } |
| 7230 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7231 | DEFUN (show_bgp_ipv4_safi, |
| 7232 | show_bgp_ipv4_safi_cmd, |
| 7233 | "show bgp ipv4 (unicast|multicast)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7234 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7235 | BGP_STR |
| 7236 | "Address family\n" |
| 7237 | "Address Family modifier\n" |
| 7238 | "Address Family modifier\n") |
| 7239 | { |
| 7240 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7241 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 7242 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7243 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7244 | 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] | 7245 | } |
| 7246 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7247 | DEFUN (show_bgp_ipv4_safi_route, |
| 7248 | show_bgp_ipv4_safi_route_cmd, |
| 7249 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7250 | SHOW_STR |
| 7251 | BGP_STR |
| 7252 | "Address family\n" |
| 7253 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7254 | "Address Family modifier\n" |
| 7255 | "Network in the BGP routing table to display\n") |
| 7256 | { |
| 7257 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7258 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7259 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7260 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
| 7261 | } |
| 7262 | |
| 7263 | DEFUN (show_bgp_route_pathtype, |
| 7264 | show_bgp_route_pathtype_cmd, |
| 7265 | "show bgp X:X::X:X (bestpath|multipath)", |
| 7266 | SHOW_STR |
| 7267 | BGP_STR |
| 7268 | "Network in the BGP routing table to display\n" |
| 7269 | "Display only the bestpath\n" |
| 7270 | "Display only multipaths\n") |
| 7271 | { |
| 7272 | if (strncmp (argv[1], "b", 1) == 0) |
| 7273 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 7274 | else |
| 7275 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH); |
| 7276 | } |
| 7277 | |
| 7278 | ALIAS (show_bgp_route_pathtype, |
| 7279 | show_bgp_ipv6_route_pathtype_cmd, |
| 7280 | "show bgp ipv6 X:X::X:X (bestpath|multipath)", |
| 7281 | SHOW_STR |
| 7282 | BGP_STR |
| 7283 | "Address family\n" |
| 7284 | "Network in the BGP routing table to display\n" |
| 7285 | "Display only the bestpath\n" |
| 7286 | "Display only multipaths\n") |
| 7287 | |
| 7288 | DEFUN (show_bgp_ipv6_safi_route_pathtype, |
| 7289 | show_bgp_ipv6_safi_route_pathtype_cmd, |
| 7290 | "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath)", |
| 7291 | SHOW_STR |
| 7292 | BGP_STR |
| 7293 | "Address family\n" |
| 7294 | "Address Family modifier\n" |
| 7295 | "Address Family modifier\n" |
| 7296 | "Network in the BGP routing table to display\n" |
| 7297 | "Display only the bestpath\n" |
| 7298 | "Display only multipaths\n") |
| 7299 | { |
| 7300 | if (strncmp (argv[0], "m", 1) == 0) |
| 7301 | if (strncmp (argv[2], "b", 1) == 0) |
| 7302 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 7303 | else |
| 7304 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH); |
| 7305 | else |
| 7306 | if (strncmp (argv[2], "b", 1) == 0) |
| 7307 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 7308 | else |
| 7309 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7310 | } |
| 7311 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7312 | DEFUN (show_bgp_ipv4_vpn_route, |
| 7313 | show_bgp_ipv4_vpn_route_cmd, |
| 7314 | "show bgp ipv4 vpn A.B.C.D", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7315 | SHOW_STR |
| 7316 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7317 | "Address Family\n" |
| 7318 | "Display VPN NLRI specific information\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7319 | "Network in the BGP routing table to display\n") |
| 7320 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7321 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7322 | } |
| 7323 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7324 | DEFUN (show_bgp_ipv6_vpn_route, |
| 7325 | show_bgp_ipv6_vpn_route_cmd, |
| 7326 | "show bgp ipv6 vpn X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7327 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7328 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7329 | "Address Family\n" |
| 7330 | "Display VPN NLRI specific information\n" |
| 7331 | "Network in the BGP routing table to display\n") |
| 7332 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7333 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL); |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7334 | } |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7335 | |
| 7336 | DEFUN (show_bgp_ipv4_vpn_rd_route, |
| 7337 | show_bgp_ipv4_vpn_rd_route_cmd, |
| 7338 | "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 7339 | SHOW_STR |
| 7340 | BGP_STR |
| 7341 | IP_STR |
| 7342 | "Display VPN NLRI specific information\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7343 | "Display information for a route distinguisher\n" |
| 7344 | "VPN Route Distinguisher\n" |
| 7345 | "Network in the BGP routing table to display\n") |
| 7346 | { |
| 7347 | int ret; |
| 7348 | struct prefix_rd prd; |
| 7349 | |
| 7350 | ret = str2prefix_rd (argv[0], &prd); |
| 7351 | if (! ret) |
| 7352 | { |
| 7353 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7354 | return CMD_WARNING; |
| 7355 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7356 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7357 | } |
| 7358 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7359 | DEFUN (show_bgp_ipv6_vpn_rd_route, |
| 7360 | show_bgp_ipv6_vpn_rd_route_cmd, |
| 7361 | "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7362 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7363 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7364 | "Address Family\n" |
| 7365 | "Display VPN NLRI specific information\n" |
| 7366 | "Display information for a route distinguisher\n" |
| 7367 | "VPN Route Distinguisher\n" |
| 7368 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7369 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7370 | int ret; |
| 7371 | struct prefix_rd prd; |
| 7372 | |
| 7373 | ret = str2prefix_rd (argv[0], &prd); |
| 7374 | if (! ret) |
| 7375 | { |
| 7376 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7377 | return CMD_WARNING; |
| 7378 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7379 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL); |
| 7380 | } |
| 7381 | |
| 7382 | DEFUN (show_bgp_prefix_pathtype, |
| 7383 | show_bgp_prefix_pathtype_cmd, |
| 7384 | "show bgp X:X::X:X/M (bestpath|multipath)", |
| 7385 | SHOW_STR |
| 7386 | BGP_STR |
| 7387 | "IPv6 prefix <network>/<length>\n" |
| 7388 | "Display only the bestpath\n" |
| 7389 | "Display only multipaths\n") |
| 7390 | { |
| 7391 | if (strncmp (argv[1], "b", 1) == 0) |
| 7392 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7393 | else |
| 7394 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH); |
| 7395 | } |
| 7396 | |
| 7397 | ALIAS (show_bgp_prefix_pathtype, |
| 7398 | show_bgp_ipv6_prefix_pathtype_cmd, |
| 7399 | "show bgp ipv6 X:X::X:X/M (bestpath|multipath)", |
| 7400 | SHOW_STR |
| 7401 | BGP_STR |
| 7402 | "Address family\n" |
| 7403 | "IPv6 prefix <network>/<length>\n" |
| 7404 | "Display only the bestpath\n" |
| 7405 | "Display only multipaths\n") |
| 7406 | |
| 7407 | DEFUN (show_bgp_ipv6_safi_prefix_pathtype, |
| 7408 | show_bgp_ipv6_safi_prefix_pathtype_cmd, |
| 7409 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath)", |
| 7410 | SHOW_STR |
| 7411 | BGP_STR |
| 7412 | "Address family\n" |
| 7413 | "Address Family modifier\n" |
| 7414 | "Address Family modifier\n" |
| 7415 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 7416 | "Display only the bestpath\n" |
| 7417 | "Display only multipaths\n") |
| 7418 | { |
| 7419 | if (strncmp (argv[0], "m", 1) == 0) |
| 7420 | if (strncmp (argv[2], "b", 1) == 0) |
| 7421 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7422 | else |
| 7423 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH); |
| 7424 | else |
| 7425 | if (strncmp (argv[2], "b", 1) == 0) |
| 7426 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7427 | else |
| 7428 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7429 | } |
| 7430 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7431 | DEFUN (show_bgp_ipv4_encap_route, |
| 7432 | show_bgp_ipv4_encap_route_cmd, |
| 7433 | "show bgp ipv4 encap A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7434 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7435 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7436 | IP_STR |
| 7437 | "Display ENCAP NLRI specific information\n" |
| 7438 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7439 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7440 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7441 | } |
| 7442 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7443 | DEFUN (show_bgp_ipv6_encap_route, |
| 7444 | show_bgp_ipv6_encap_route_cmd, |
| 7445 | "show bgp ipv6 encap X:X::X:X", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7446 | SHOW_STR |
| 7447 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7448 | IP6_STR |
| 7449 | "Display ENCAP NLRI specific information\n" |
| 7450 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7451 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7452 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7453 | } |
| 7454 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7455 | DEFUN (show_bgp_ipv4_safi_rd_route, |
| 7456 | show_bgp_ipv4_safi_rd_route_cmd, |
| 7457 | "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7458 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7459 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7460 | "Address Family\n" |
| 7461 | "Address Family Modifier\n" |
| 7462 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7463 | "Display information for a route distinguisher\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7464 | "ENCAP Route Distinguisher\n" |
| 7465 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7466 | { |
| 7467 | int ret; |
| 7468 | struct prefix_rd prd; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7469 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7470 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7471 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7472 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7473 | return CMD_WARNING; |
| 7474 | } |
| 7475 | ret = str2prefix_rd (argv[1], &prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7476 | if (! ret) |
| 7477 | { |
| 7478 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7479 | return CMD_WARNING; |
| 7480 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7481 | return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7482 | } |
| 7483 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7484 | DEFUN (show_bgp_ipv6_safi_rd_route, |
| 7485 | show_bgp_ipv6_safi_rd_route_cmd, |
| 7486 | "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7487 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7488 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7489 | "Address Family\n" |
| 7490 | "Address Family Modifier\n" |
| 7491 | "Address Family Modifier\n" |
| 7492 | "Display information for a route distinguisher\n" |
| 7493 | "ENCAP Route Distinguisher\n" |
| 7494 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7495 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7496 | int ret; |
| 7497 | struct prefix_rd prd; |
| 7498 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7499 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7500 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7501 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7502 | return CMD_WARNING; |
| 7503 | } |
| 7504 | ret = str2prefix_rd (argv[1], &prd); |
| 7505 | if (! ret) |
| 7506 | { |
| 7507 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7508 | return CMD_WARNING; |
| 7509 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7510 | return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7511 | } |
| 7512 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7513 | DEFUN (show_bgp_ipv4_prefix, |
| 7514 | show_bgp_ipv4_prefix_cmd, |
| 7515 | "show bgp ipv4 A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7516 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7517 | BGP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7518 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7519 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7520 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7521 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7522 | } |
| 7523 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7524 | DEFUN (show_bgp_ipv4_safi_prefix, |
| 7525 | show_bgp_ipv4_safi_prefix_cmd, |
| 7526 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7527 | SHOW_STR |
| 7528 | BGP_STR |
| 7529 | "Address family\n" |
| 7530 | "Address Family modifier\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7531 | "Address Family modifier\n" |
| 7532 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7533 | { |
| 7534 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7535 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7536 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7537 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7538 | } |
| 7539 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7540 | DEFUN (show_bgp_ipv4_vpn_prefix, |
| 7541 | show_bgp_ipv4_vpn_prefix_cmd, |
| 7542 | "show bgp ipv4 vpn A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7543 | SHOW_STR |
| 7544 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7545 | IP_STR |
| 7546 | "Display VPN NLRI specific information\n" |
| 7547 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7548 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7549 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7550 | } |
| 7551 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7552 | DEFUN (show_bgp_ipv6_vpn_prefix, |
| 7553 | show_bgp_ipv6_vpn_prefix_cmd, |
| 7554 | "show bgp ipv6 vpn X:X::X:X/M", |
| 7555 | SHOW_STR |
| 7556 | BGP_STR |
| 7557 | "Address Family\n" |
| 7558 | "Display VPN NLRI specific information\n" |
| 7559 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7560 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7561 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL); |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7562 | } |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7563 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7564 | DEFUN (show_bgp_ipv4_encap_prefix, |
| 7565 | show_bgp_ipv4_encap_prefix_cmd, |
| 7566 | "show bgp ipv4 encap A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7567 | SHOW_STR |
| 7568 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7569 | IP_STR |
| 7570 | "Display ENCAP NLRI specific information\n" |
| 7571 | "Display information about ENCAP NLRIs\n" |
| 7572 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7573 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7574 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1, BGP_PATH_ALL); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7575 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7576 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7577 | DEFUN (show_bgp_ipv6_encap_prefix, |
| 7578 | show_bgp_ipv6_encap_prefix_cmd, |
| 7579 | "show bgp ipv6 encap X:X::X:X/M", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7580 | SHOW_STR |
| 7581 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7582 | IP_STR |
| 7583 | "Display ENCAP NLRI specific information\n" |
| 7584 | "Display information about ENCAP NLRIs\n" |
| 7585 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7586 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7587 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1, BGP_PATH_ALL); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7588 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7589 | |
| 7590 | DEFUN (show_bgp_ipv4_safi_rd_prefix, |
| 7591 | show_bgp_ipv4_safi_rd_prefix_cmd, |
| 7592 | "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 7593 | SHOW_STR |
| 7594 | BGP_STR |
| 7595 | "Address Family\n" |
| 7596 | "Address Family Modifier\n" |
| 7597 | "Address Family Modifier\n" |
| 7598 | "Display information for a route distinguisher\n" |
| 7599 | "ENCAP Route Distinguisher\n" |
| 7600 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7601 | { |
| 7602 | int ret; |
| 7603 | struct prefix_rd prd; |
| 7604 | safi_t safi; |
| 7605 | |
| 7606 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7607 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7608 | return CMD_WARNING; |
| 7609 | } |
| 7610 | |
| 7611 | ret = str2prefix_rd (argv[1], &prd); |
| 7612 | if (! ret) |
| 7613 | { |
| 7614 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7615 | return CMD_WARNING; |
| 7616 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7617 | return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1, BGP_PATH_ALL); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7618 | } |
| 7619 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7620 | DEFUN (show_bgp_ipv6_safi_rd_prefix, |
| 7621 | show_bgp_ipv6_safi_rd_prefix_cmd, |
| 7622 | "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M", |
| 7623 | SHOW_STR |
| 7624 | BGP_STR |
| 7625 | "Address Family\n" |
| 7626 | "Address Family Modifier\n" |
| 7627 | "Address Family Modifier\n" |
| 7628 | "Display information for a route distinguisher\n" |
| 7629 | "ENCAP Route Distinguisher\n" |
| 7630 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7631 | { |
| 7632 | int ret; |
| 7633 | struct prefix_rd prd; |
| 7634 | safi_t safi; |
| 7635 | |
| 7636 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7637 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7638 | return CMD_WARNING; |
| 7639 | } |
| 7640 | |
| 7641 | ret = str2prefix_rd (argv[1], &prd); |
| 7642 | if (! ret) |
| 7643 | { |
| 7644 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7645 | return CMD_WARNING; |
| 7646 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7647 | return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1, BGP_PATH_ALL); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7648 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7649 | |
| 7650 | DEFUN (show_bgp_afi_safi_view, |
| 7651 | show_bgp_afi_safi_view_cmd, |
| 7652 | "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)", |
| 7653 | SHOW_STR |
| 7654 | BGP_STR |
| 7655 | "BGP view\n" |
| 7656 | "BGP view name\n" |
| 7657 | "Address Family\n" |
| 7658 | "Address Family\n" |
| 7659 | "Address Family Modifier\n" |
| 7660 | "Address Family Modifier\n" |
| 7661 | "Address Family Modifier\n" |
| 7662 | "Address Family Modifier\n" |
| 7663 | ) |
| 7664 | { |
| 7665 | struct bgp *bgp; |
| 7666 | safi_t safi; |
| 7667 | afi_t afi; |
| 7668 | |
| 7669 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7670 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7671 | return CMD_WARNING; |
| 7672 | } |
| 7673 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7674 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7675 | return CMD_WARNING; |
| 7676 | } |
| 7677 | |
| 7678 | /* BGP structure lookup. */ |
| 7679 | bgp = bgp_lookup_by_name (argv[0]); |
| 7680 | if (bgp == NULL) |
| 7681 | { |
| 7682 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7683 | return CMD_WARNING; |
| 7684 | } |
| 7685 | |
| 7686 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL); |
| 7687 | } |
| 7688 | |
| 7689 | DEFUN (show_bgp_view_afi_safi_route, |
| 7690 | show_bgp_view_afi_safi_route_cmd, |
| 7691 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D", |
| 7692 | SHOW_STR |
| 7693 | BGP_STR |
| 7694 | "BGP view\n" |
| 7695 | "View name\n" |
| 7696 | "Address Family\n" |
| 7697 | "Address Family\n" |
| 7698 | "Address Family Modifier\n" |
| 7699 | "Address Family Modifier\n" |
| 7700 | "Address Family Modifier\n" |
| 7701 | "Address Family Modifier\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7702 | "Network in the BGP routing table to display\n") |
| 7703 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7704 | safi_t safi; |
| 7705 | afi_t afi; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7706 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7707 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7708 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7709 | return CMD_WARNING; |
| 7710 | } |
| 7711 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7712 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7713 | return CMD_WARNING; |
| 7714 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7715 | return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0, BGP_PATH_ALL); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7716 | } |
| 7717 | |
| 7718 | DEFUN (show_bgp_view_afi_safi_prefix, |
| 7719 | show_bgp_view_afi_safi_prefix_cmd, |
| 7720 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M", |
| 7721 | SHOW_STR |
| 7722 | BGP_STR |
| 7723 | "BGP view\n" |
| 7724 | "View name\n" |
| 7725 | "Address Family\n" |
| 7726 | "Address Family\n" |
| 7727 | "Address Family Modifier\n" |
| 7728 | "Address Family Modifier\n" |
| 7729 | "Address Family Modifier\n" |
| 7730 | "Address Family Modifier\n" |
| 7731 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7732 | { |
| 7733 | safi_t safi; |
| 7734 | afi_t afi; |
| 7735 | |
| 7736 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7737 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7738 | return CMD_WARNING; |
| 7739 | } |
| 7740 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7741 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7742 | return CMD_WARNING; |
| 7743 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7744 | return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1, BGP_PATH_ALL); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7745 | } |
| 7746 | |
| 7747 | /* new001 */ |
| 7748 | DEFUN (show_bgp_afi, |
| 7749 | show_bgp_afi_cmd, |
| 7750 | "show bgp (ipv4|ipv6)", |
| 7751 | SHOW_STR |
| 7752 | BGP_STR |
| 7753 | "Address family\n" |
| 7754 | "Address family\n") |
| 7755 | { |
| 7756 | afi_t afi; |
| 7757 | |
| 7758 | if (bgp_parse_afi(argv[0], &afi)) { |
| 7759 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7760 | return CMD_WARNING; |
| 7761 | } |
| 7762 | return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal, |
| 7763 | NULL); |
| 7764 | } |
| 7765 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7766 | DEFUN (show_bgp_ipv6_safi, |
| 7767 | show_bgp_ipv6_safi_cmd, |
| 7768 | "show bgp ipv6 (unicast|multicast)", |
| 7769 | SHOW_STR |
| 7770 | BGP_STR |
| 7771 | "Address family\n" |
| 7772 | "Address Family modifier\n" |
| 7773 | "Address Family modifier\n") |
| 7774 | { |
| 7775 | if (strncmp (argv[0], "m", 1) == 0) |
| 7776 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7777 | NULL); |
| 7778 | |
| 7779 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7780 | } |
| 7781 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7782 | DEFUN (show_bgp_ipv6_route, |
| 7783 | show_bgp_ipv6_route_cmd, |
| 7784 | "show bgp ipv6 X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7785 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7786 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7787 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7788 | "Network in the BGP routing table to display\n") |
| 7789 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7790 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7791 | } |
| 7792 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7793 | DEFUN (show_bgp_ipv6_safi_route, |
| 7794 | show_bgp_ipv6_safi_route_cmd, |
| 7795 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7796 | SHOW_STR |
| 7797 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7798 | "Address family\n" |
| 7799 | "Address Family modifier\n" |
| 7800 | "Address Family modifier\n" |
| 7801 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7802 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7803 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7804 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7805 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7806 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7807 | } |
| 7808 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7809 | /* old command */ |
| 7810 | DEFUN (show_ipv6_bgp_route, |
| 7811 | show_ipv6_bgp_route_cmd, |
| 7812 | "show ipv6 bgp X:X::X:X", |
| 7813 | SHOW_STR |
| 7814 | IP_STR |
| 7815 | BGP_STR |
| 7816 | "Network in the BGP routing table to display\n") |
| 7817 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7818 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7819 | } |
| 7820 | |
| 7821 | DEFUN (show_bgp_prefix, |
| 7822 | show_bgp_prefix_cmd, |
| 7823 | "show bgp X:X::X:X/M", |
| 7824 | SHOW_STR |
| 7825 | BGP_STR |
| 7826 | "IPv6 prefix <network>/<length>\n") |
| 7827 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7828 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7829 | } |
| 7830 | |
| 7831 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7832 | /* new002 */ |
| 7833 | DEFUN (show_bgp_ipv6_prefix, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7834 | show_bgp_ipv6_prefix_cmd, |
| 7835 | "show bgp ipv6 X:X::X:X/M", |
| 7836 | SHOW_STR |
| 7837 | BGP_STR |
| 7838 | "Address family\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7839 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7840 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7841 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7842 | } |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7843 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 7844 | show_bgp_ipv6_safi_prefix_cmd, |
| 7845 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 7846 | SHOW_STR |
| 7847 | BGP_STR |
| 7848 | "Address family\n" |
| 7849 | "Address Family modifier\n" |
| 7850 | "Address Family modifier\n" |
| 7851 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7852 | { |
| 7853 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7854 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7855 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7856 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7857 | } |
| 7858 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7859 | /* old command */ |
| 7860 | DEFUN (show_ipv6_bgp_prefix, |
| 7861 | show_ipv6_bgp_prefix_cmd, |
| 7862 | "show ipv6 bgp X:X::X:X/M", |
| 7863 | SHOW_STR |
| 7864 | IP_STR |
| 7865 | BGP_STR |
| 7866 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7867 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7868 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7869 | } |
| 7870 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7871 | DEFUN (show_bgp_view, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7872 | show_bgp_view_cmd, |
| 7873 | "show bgp view WORD", |
| 7874 | SHOW_STR |
| 7875 | BGP_STR |
| 7876 | "BGP view\n" |
| 7877 | "View name\n") |
| 7878 | { |
| 7879 | struct bgp *bgp; |
| 7880 | |
| 7881 | /* BGP structure lookup. */ |
| 7882 | bgp = bgp_lookup_by_name (argv[0]); |
| 7883 | if (bgp == NULL) |
| 7884 | { |
| 7885 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7886 | return CMD_WARNING; |
| 7887 | } |
| 7888 | |
| 7889 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 7890 | } |
| 7891 | |
| 7892 | DEFUN (show_bgp_view_ipv6, |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7893 | show_bgp_view_ipv6_cmd, |
| 7894 | "show bgp view WORD ipv6", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7895 | SHOW_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7896 | BGP_STR |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7897 | "BGP view\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7898 | "View name\n" |
| 7899 | "Address family\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7900 | { |
| 7901 | struct bgp *bgp; |
| 7902 | |
| 7903 | /* BGP structure lookup. */ |
| 7904 | bgp = bgp_lookup_by_name (argv[0]); |
| 7905 | if (bgp == NULL) |
| 7906 | { |
| 7907 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7908 | return CMD_WARNING; |
| 7909 | } |
| 7910 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7911 | 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] | 7912 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7913 | |
| 7914 | DEFUN (show_bgp_view_route, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7915 | show_bgp_view_route_cmd, |
| 7916 | "show bgp view WORD X:X::X:X", |
| 7917 | SHOW_STR |
| 7918 | BGP_STR |
| 7919 | "BGP view\n" |
| 7920 | "View name\n" |
| 7921 | "Network in the BGP routing table to display\n") |
| 7922 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7923 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7924 | } |
| 7925 | |
| 7926 | DEFUN (show_bgp_view_ipv6_route, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7927 | show_bgp_view_ipv6_route_cmd, |
| 7928 | "show bgp view WORD ipv6 X:X::X:X", |
| 7929 | SHOW_STR |
| 7930 | BGP_STR |
| 7931 | "BGP view\n" |
| 7932 | "View name\n" |
| 7933 | "Address family\n" |
| 7934 | "Network in the BGP routing table to display\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7935 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7936 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7937 | } |
| 7938 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7939 | /* old command */ |
| 7940 | DEFUN (show_ipv6_mbgp, |
| 7941 | show_ipv6_mbgp_cmd, |
| 7942 | "show ipv6 mbgp", |
| 7943 | SHOW_STR |
| 7944 | IP_STR |
| 7945 | MBGP_STR) |
| 7946 | { |
| 7947 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7948 | NULL); |
| 7949 | } |
| 7950 | |
| 7951 | /* old command */ |
| 7952 | DEFUN (show_ipv6_mbgp_route, |
| 7953 | show_ipv6_mbgp_route_cmd, |
| 7954 | "show ipv6 mbgp X:X::X:X", |
| 7955 | SHOW_STR |
| 7956 | IP_STR |
| 7957 | MBGP_STR |
| 7958 | "Network in the MBGP routing table to display\n") |
| 7959 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7960 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7961 | } |
| 7962 | |
| 7963 | /* old command */ |
| 7964 | DEFUN (show_ipv6_mbgp_prefix, |
| 7965 | show_ipv6_mbgp_prefix_cmd, |
| 7966 | "show ipv6 mbgp X:X::X:X/M", |
| 7967 | SHOW_STR |
| 7968 | IP_STR |
| 7969 | MBGP_STR |
| 7970 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7971 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7972 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7973 | } |
| 7974 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7975 | DEFUN (show_bgp_view_prefix, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7976 | show_bgp_view_prefix_cmd, |
| 7977 | "show bgp view WORD X:X::X:X/M", |
| 7978 | SHOW_STR |
| 7979 | BGP_STR |
| 7980 | "BGP view\n" |
| 7981 | "View name\n" |
| 7982 | "IPv6 prefix <network>/<length>\n") |
| 7983 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7984 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7985 | } |
| 7986 | |
| 7987 | DEFUN (show_bgp_view_ipv6_prefix, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7988 | show_bgp_view_ipv6_prefix_cmd, |
| 7989 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 7990 | SHOW_STR |
| 7991 | BGP_STR |
| 7992 | "BGP view\n" |
| 7993 | "View name\n" |
| 7994 | "Address family\n" |
| 7995 | "IPv6 prefix <network>/<length>\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7996 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7997 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7998 | } |
| 7999 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8000 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8001 | 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] | 8002 | safi_t safi, enum bgp_show_type type) |
| 8003 | { |
| 8004 | int i; |
| 8005 | struct buffer *b; |
| 8006 | char *regstr; |
| 8007 | int first; |
| 8008 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8009 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8010 | |
| 8011 | first = 0; |
| 8012 | b = buffer_new (1024); |
| 8013 | for (i = 0; i < argc; i++) |
| 8014 | { |
| 8015 | if (first) |
| 8016 | buffer_putc (b, ' '); |
| 8017 | else |
| 8018 | { |
| 8019 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 8020 | continue; |
| 8021 | first = 1; |
| 8022 | } |
| 8023 | |
| 8024 | buffer_putstr (b, argv[i]); |
| 8025 | } |
| 8026 | buffer_putc (b, '\0'); |
| 8027 | |
| 8028 | regstr = buffer_getstr (b); |
| 8029 | buffer_free (b); |
| 8030 | |
| 8031 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 8032 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8033 | if (! regex) |
| 8034 | { |
| 8035 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 8036 | VTY_NEWLINE); |
| 8037 | return CMD_WARNING; |
| 8038 | } |
| 8039 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8040 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 8041 | bgp_regex_free (regex); |
| 8042 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8043 | } |
| 8044 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8045 | |
| 8046 | DEFUN (show_ip_bgp_regexp, |
| 8047 | show_ip_bgp_regexp_cmd, |
| 8048 | "show ip bgp regexp .LINE", |
| 8049 | SHOW_STR |
| 8050 | IP_STR |
| 8051 | BGP_STR |
| 8052 | "Display routes matching the AS path regular expression\n" |
| 8053 | "A regular-expression to match the BGP AS paths\n") |
| 8054 | { |
| 8055 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 8056 | bgp_show_type_regexp); |
| 8057 | } |
| 8058 | |
| 8059 | DEFUN (show_ip_bgp_flap_regexp, |
| 8060 | show_ip_bgp_flap_regexp_cmd, |
| 8061 | "show ip bgp flap-statistics regexp .LINE", |
| 8062 | SHOW_STR |
| 8063 | IP_STR |
| 8064 | BGP_STR |
| 8065 | "Display flap statistics of routes\n" |
| 8066 | "Display routes matching the AS path regular expression\n" |
| 8067 | "A regular-expression to match the BGP AS paths\n") |
| 8068 | { |
| 8069 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 8070 | bgp_show_type_flap_regexp); |
| 8071 | } |
| 8072 | |
| 8073 | ALIAS (show_ip_bgp_flap_regexp, |
| 8074 | show_ip_bgp_damp_flap_regexp_cmd, |
| 8075 | "show ip bgp dampening flap-statistics regexp .LINE", |
| 8076 | SHOW_STR |
| 8077 | IP_STR |
| 8078 | BGP_STR |
| 8079 | "Display detailed information about dampening\n" |
| 8080 | "Display flap statistics of routes\n" |
| 8081 | "Display routes matching the AS path regular expression\n" |
| 8082 | "A regular-expression to match the BGP AS paths\n") |
| 8083 | |
| 8084 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 8085 | show_ip_bgp_ipv4_regexp_cmd, |
| 8086 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 8087 | SHOW_STR |
| 8088 | IP_STR |
| 8089 | BGP_STR |
| 8090 | "Address family\n" |
| 8091 | "Address Family modifier\n" |
| 8092 | "Address Family modifier\n" |
| 8093 | "Display routes matching the AS path regular expression\n" |
| 8094 | "A regular-expression to match the BGP AS paths\n") |
| 8095 | { |
| 8096 | if (strncmp (argv[0], "m", 1) == 0) |
| 8097 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 8098 | bgp_show_type_regexp); |
| 8099 | |
| 8100 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 8101 | bgp_show_type_regexp); |
| 8102 | } |
| 8103 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8104 | DEFUN (show_bgp_regexp, |
| 8105 | show_bgp_regexp_cmd, |
| 8106 | "show bgp regexp .LINE", |
| 8107 | SHOW_STR |
| 8108 | BGP_STR |
| 8109 | "Display routes matching the AS path regular expression\n" |
| 8110 | "A regular-expression to match the BGP AS paths\n") |
| 8111 | { |
| 8112 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 8113 | bgp_show_type_regexp); |
| 8114 | } |
| 8115 | |
| 8116 | /* old command */ |
| 8117 | DEFUN (show_ipv6_bgp_regexp, |
| 8118 | show_ipv6_bgp_regexp_cmd, |
| 8119 | "show ipv6 bgp regexp .LINE", |
| 8120 | SHOW_STR |
| 8121 | IP_STR |
| 8122 | BGP_STR |
| 8123 | "Display routes matching the AS path regular expression\n" |
| 8124 | "A regular-expression to match the BGP AS paths\n") |
| 8125 | { |
| 8126 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 8127 | bgp_show_type_regexp); |
| 8128 | } |
| 8129 | |
| 8130 | /* old command */ |
| 8131 | DEFUN (show_ipv6_mbgp_regexp, |
| 8132 | show_ipv6_mbgp_regexp_cmd, |
| 8133 | "show ipv6 mbgp regexp .LINE", |
| 8134 | SHOW_STR |
| 8135 | IP_STR |
| 8136 | BGP_STR |
| 8137 | "Display routes matching the AS path regular expression\n" |
| 8138 | "A regular-expression to match the MBGP AS paths\n") |
| 8139 | { |
| 8140 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 8141 | bgp_show_type_regexp); |
| 8142 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8143 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8144 | DEFUN (show_bgp_ipv4_safi_flap_regexp, |
| 8145 | show_bgp_ipv4_safi_flap_regexp_cmd, |
| 8146 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8147 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8148 | BGP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8149 | IP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8150 | "Address Family Modifier\n" |
| 8151 | "Address Family Modifier\n" |
| 8152 | "Address Family Modifier\n" |
| 8153 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8154 | "Display flap statistics of routes\n" |
| 8155 | "Display routes matching the AS path regular expression\n" |
| 8156 | "A regular-expression to match the BGP AS paths\n") |
| 8157 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8158 | safi_t safi; |
| 8159 | |
| 8160 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8161 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 8162 | return CMD_WARNING; |
| 8163 | } |
| 8164 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi, |
| 8165 | bgp_show_type_flap_regexp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8166 | } |
| 8167 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8168 | ALIAS (show_bgp_ipv4_safi_flap_regexp, |
| 8169 | show_bgp_ipv4_safi_damp_flap_regexp_cmd, |
| 8170 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8171 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8172 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8173 | IP_STR |
| 8174 | "Address Family Modifier\n" |
| 8175 | "Address Family Modifier\n" |
| 8176 | "Address Family Modifier\n" |
| 8177 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8178 | "Display detailed information about dampening\n" |
| 8179 | "Display flap statistics of routes\n" |
| 8180 | "Display routes matching the AS path regular expression\n" |
| 8181 | "A regular-expression to match the BGP AS paths\n") |
| 8182 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8183 | DEFUN (show_bgp_ipv6_safi_flap_regexp, |
| 8184 | show_bgp_ipv6_safi_flap_regexp_cmd, |
| 8185 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8186 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8187 | BGP_STR |
| 8188 | IPV6_STR |
| 8189 | "Address Family Modifier\n" |
| 8190 | "Address Family Modifier\n" |
| 8191 | "Address Family Modifier\n" |
| 8192 | "Address Family Modifier\n" |
| 8193 | "Display flap statistics of routes\n" |
| 8194 | "Display routes matching the AS path regular expression\n" |
| 8195 | "A regular-expression to match the BGP AS paths\n") |
| 8196 | { |
| 8197 | safi_t safi; |
| 8198 | |
| 8199 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8200 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 8201 | return CMD_WARNING; |
| 8202 | } |
| 8203 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi, |
| 8204 | bgp_show_type_flap_regexp); |
| 8205 | } |
| 8206 | |
| 8207 | ALIAS (show_bgp_ipv6_safi_flap_regexp, |
| 8208 | show_bgp_ipv6_safi_damp_flap_regexp_cmd, |
| 8209 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE", |
| 8210 | SHOW_STR |
| 8211 | BGP_STR |
| 8212 | IPV6_STR |
| 8213 | "Address Family Modifier\n" |
| 8214 | "Address Family Modifier\n" |
| 8215 | "Address Family Modifier\n" |
| 8216 | "Address Family Modifier\n" |
| 8217 | "Display detailed information about dampening\n" |
| 8218 | "Display flap statistics of routes\n" |
| 8219 | "Display routes matching the AS path regular expression\n" |
| 8220 | "A regular-expression to match the BGP AS paths\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8221 | |
| 8222 | DEFUN (show_bgp_ipv4_safi_regexp, |
| 8223 | show_bgp_ipv4_safi_regexp_cmd, |
| 8224 | "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE", |
| 8225 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8226 | BGP_STR |
| 8227 | "Address family\n" |
| 8228 | "Address Family modifier\n" |
| 8229 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8230 | "Address Family modifier\n" |
| 8231 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8232 | "Display routes matching the AS path regular expression\n" |
| 8233 | "A regular-expression to match the BGP AS paths\n") |
| 8234 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8235 | safi_t safi; |
| 8236 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8237 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8238 | return CMD_WARNING; |
| 8239 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8240 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8241 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8242 | bgp_show_type_regexp); |
| 8243 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8244 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8245 | DEFUN (show_bgp_ipv6_safi_regexp, |
| 8246 | show_bgp_ipv6_safi_regexp_cmd, |
| 8247 | "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8248 | SHOW_STR |
| 8249 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8250 | "Address family\n" |
| 8251 | "Address Family modifier\n" |
| 8252 | "Address Family modifier\n" |
| 8253 | "Address Family modifier\n" |
| 8254 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8255 | "Display routes matching the AS path regular expression\n" |
| 8256 | "A regular-expression to match the BGP AS paths\n") |
| 8257 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8258 | safi_t safi; |
| 8259 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8260 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8261 | return CMD_WARNING; |
| 8262 | } |
| 8263 | |
| 8264 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8265 | bgp_show_type_regexp); |
| 8266 | } |
| 8267 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8268 | DEFUN (show_bgp_ipv6_regexp, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8269 | show_bgp_ipv6_regexp_cmd, |
| 8270 | "show bgp ipv6 regexp .LINE", |
| 8271 | SHOW_STR |
| 8272 | BGP_STR |
| 8273 | "Address family\n" |
| 8274 | "Display routes matching the AS path regular expression\n" |
| 8275 | "A regular-expression to match the BGP AS paths\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8276 | { |
| 8277 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 8278 | bgp_show_type_regexp); |
| 8279 | } |
| 8280 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8281 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8282 | 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] | 8283 | safi_t safi, enum bgp_show_type type) |
| 8284 | { |
| 8285 | struct prefix_list *plist; |
| 8286 | |
| 8287 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 8288 | if (plist == NULL) |
| 8289 | { |
| 8290 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 8291 | prefix_list_str, VTY_NEWLINE); |
| 8292 | return CMD_WARNING; |
| 8293 | } |
| 8294 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8295 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8296 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8297 | DEFUN (show_ip_bgp_prefix_list, |
| 8298 | show_ip_bgp_prefix_list_cmd, |
| 8299 | "show ip bgp prefix-list WORD", |
| 8300 | SHOW_STR |
| 8301 | IP_STR |
| 8302 | BGP_STR |
| 8303 | "Display routes conforming to the prefix-list\n" |
| 8304 | "IP prefix-list name\n") |
| 8305 | { |
| 8306 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8307 | bgp_show_type_prefix_list); |
| 8308 | } |
| 8309 | |
| 8310 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 8311 | show_ip_bgp_flap_prefix_list_cmd, |
| 8312 | "show ip bgp flap-statistics prefix-list WORD", |
| 8313 | SHOW_STR |
| 8314 | IP_STR |
| 8315 | BGP_STR |
| 8316 | "Display flap statistics of routes\n" |
| 8317 | "Display routes conforming to the prefix-list\n" |
| 8318 | "IP prefix-list name\n") |
| 8319 | { |
| 8320 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8321 | bgp_show_type_flap_prefix_list); |
| 8322 | } |
| 8323 | |
| 8324 | ALIAS (show_ip_bgp_flap_prefix_list, |
| 8325 | show_ip_bgp_damp_flap_prefix_list_cmd, |
| 8326 | "show ip bgp dampening flap-statistics prefix-list WORD", |
| 8327 | SHOW_STR |
| 8328 | IP_STR |
| 8329 | BGP_STR |
| 8330 | "Display detailed information about dampening\n" |
| 8331 | "Display flap statistics of routes\n" |
| 8332 | "Display routes conforming to the prefix-list\n" |
| 8333 | "IP prefix-list name\n") |
| 8334 | |
| 8335 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 8336 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 8337 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 8338 | SHOW_STR |
| 8339 | IP_STR |
| 8340 | BGP_STR |
| 8341 | "Address family\n" |
| 8342 | "Address Family modifier\n" |
| 8343 | "Address Family modifier\n" |
| 8344 | "Display routes conforming to the prefix-list\n" |
| 8345 | "IP prefix-list name\n") |
| 8346 | { |
| 8347 | if (strncmp (argv[0], "m", 1) == 0) |
| 8348 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8349 | bgp_show_type_prefix_list); |
| 8350 | |
| 8351 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8352 | bgp_show_type_prefix_list); |
| 8353 | } |
| 8354 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8355 | DEFUN (show_bgp_prefix_list, |
| 8356 | show_bgp_prefix_list_cmd, |
| 8357 | "show bgp prefix-list WORD", |
| 8358 | SHOW_STR |
| 8359 | BGP_STR |
| 8360 | "Display routes conforming to the prefix-list\n" |
| 8361 | "IPv6 prefix-list name\n") |
| 8362 | { |
| 8363 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8364 | bgp_show_type_prefix_list); |
| 8365 | } |
| 8366 | |
| 8367 | ALIAS (show_bgp_prefix_list, |
| 8368 | show_bgp_ipv6_prefix_list_cmd, |
| 8369 | "show bgp ipv6 prefix-list WORD", |
| 8370 | SHOW_STR |
| 8371 | BGP_STR |
| 8372 | "Address family\n" |
| 8373 | "Display routes conforming to the prefix-list\n" |
| 8374 | "IPv6 prefix-list name\n") |
| 8375 | |
| 8376 | /* old command */ |
| 8377 | DEFUN (show_ipv6_bgp_prefix_list, |
| 8378 | show_ipv6_bgp_prefix_list_cmd, |
| 8379 | "show ipv6 bgp prefix-list WORD", |
| 8380 | SHOW_STR |
| 8381 | IPV6_STR |
| 8382 | BGP_STR |
| 8383 | "Display routes matching the prefix-list\n" |
| 8384 | "IPv6 prefix-list name\n") |
| 8385 | { |
| 8386 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8387 | bgp_show_type_prefix_list); |
| 8388 | } |
| 8389 | |
| 8390 | /* old command */ |
| 8391 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 8392 | show_ipv6_mbgp_prefix_list_cmd, |
| 8393 | "show ipv6 mbgp prefix-list WORD", |
| 8394 | SHOW_STR |
| 8395 | IPV6_STR |
| 8396 | MBGP_STR |
| 8397 | "Display routes matching the prefix-list\n" |
| 8398 | "IPv6 prefix-list name\n") |
| 8399 | { |
| 8400 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8401 | bgp_show_type_prefix_list); |
| 8402 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8403 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8404 | DEFUN (show_bgp_ipv4_prefix_list, |
| 8405 | show_bgp_ipv4_prefix_list_cmd, |
| 8406 | "show bgp ipv4 prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8407 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8408 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8409 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8410 | "Display routes conforming to the prefix-list\n" |
| 8411 | "IP prefix-list name\n") |
| 8412 | { |
| 8413 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8414 | bgp_show_type_prefix_list); |
| 8415 | } |
| 8416 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8417 | DEFUN (show_bgp_ipv4_safi_flap_prefix_list, |
| 8418 | show_bgp_ipv4_safi_flap_prefix_list_cmd, |
| 8419 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8420 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8421 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8422 | IP_STR |
| 8423 | "Address Family Modifier\n" |
| 8424 | "Address Family Modifier\n" |
| 8425 | "Address Family Modifier\n" |
| 8426 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8427 | "Display flap statistics of routes\n" |
| 8428 | "Display routes conforming to the prefix-list\n" |
| 8429 | "IP prefix-list name\n") |
| 8430 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8431 | safi_t safi; |
| 8432 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8433 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8434 | return CMD_WARNING; |
| 8435 | } |
| 8436 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8437 | bgp_show_type_flap_prefix_list); |
| 8438 | } |
| 8439 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8440 | ALIAS (show_bgp_ipv4_safi_flap_prefix_list, |
| 8441 | show_bgp_ipv4_safi_damp_flap_prefix_list_cmd, |
| 8442 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8443 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8444 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8445 | IP_STR |
| 8446 | "Address Family Modifier\n" |
| 8447 | "Address Family Modifier\n" |
| 8448 | "Address Family Modifier\n" |
| 8449 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8450 | "Display detailed information about dampening\n" |
| 8451 | "Display flap statistics of routes\n" |
| 8452 | "Display routes conforming to the prefix-list\n" |
| 8453 | "IP prefix-list name\n") |
| 8454 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8455 | DEFUN (show_bgp_ipv6_safi_flap_prefix_list, |
| 8456 | show_bgp_ipv6_safi_flap_prefix_list_cmd, |
| 8457 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8458 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8459 | BGP_STR |
| 8460 | IPV6_STR |
| 8461 | "Address Family Modifier\n" |
| 8462 | "Address Family Modifier\n" |
| 8463 | "Address Family Modifier\n" |
| 8464 | "Address Family Modifier\n" |
| 8465 | "Display flap statistics of routes\n" |
| 8466 | "Display routes conforming to the prefix-list\n" |
| 8467 | "IP prefix-list name\n") |
| 8468 | { |
| 8469 | safi_t safi; |
| 8470 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8471 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8472 | return CMD_WARNING; |
| 8473 | } |
| 8474 | return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi, |
| 8475 | bgp_show_type_flap_prefix_list); |
| 8476 | } |
| 8477 | ALIAS (show_bgp_ipv6_safi_flap_prefix_list, |
| 8478 | show_bgp_ipv6_safi_damp_flap_prefix_list_cmd, |
| 8479 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD", |
| 8480 | SHOW_STR |
| 8481 | BGP_STR |
| 8482 | IPV6_STR |
| 8483 | "Address Family Modifier\n" |
| 8484 | "Address Family Modifier\n" |
| 8485 | "Address Family Modifier\n" |
| 8486 | "Address Family Modifier\n" |
| 8487 | "Display detailed information about dampening\n" |
| 8488 | "Display flap statistics of routes\n" |
| 8489 | "Display routes conforming to the prefix-list\n" |
| 8490 | "IP prefix-list name\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8491 | |
| 8492 | DEFUN (show_bgp_ipv4_safi_prefix_list, |
| 8493 | show_bgp_ipv4_safi_prefix_list_cmd, |
| 8494 | "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD", |
| 8495 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8496 | BGP_STR |
| 8497 | "Address family\n" |
| 8498 | "Address Family modifier\n" |
| 8499 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8500 | "Address Family modifier\n" |
| 8501 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8502 | "Display routes conforming to the prefix-list\n" |
| 8503 | "IP prefix-list name\n") |
| 8504 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8505 | safi_t safi; |
| 8506 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8507 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8508 | return CMD_WARNING; |
| 8509 | } |
| 8510 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8511 | bgp_show_type_prefix_list); |
| 8512 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8513 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8514 | DEFUN (show_bgp_ipv6_safi_prefix_list, |
| 8515 | show_bgp_ipv6_safi_prefix_list_cmd, |
| 8516 | "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8517 | SHOW_STR |
| 8518 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8519 | "Address family\n" |
| 8520 | "Address Family modifier\n" |
| 8521 | "Address Family modifier\n" |
| 8522 | "Address Family modifier\n" |
| 8523 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8524 | "Display routes conforming to the prefix-list\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8525 | "IP prefix-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8526 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8527 | safi_t safi; |
| 8528 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8529 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8530 | return CMD_WARNING; |
| 8531 | } |
| 8532 | return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8533 | bgp_show_type_prefix_list); |
| 8534 | } |
| 8535 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8536 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8537 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8538 | safi_t safi, enum bgp_show_type type) |
| 8539 | { |
| 8540 | struct as_list *as_list; |
| 8541 | |
| 8542 | as_list = as_list_lookup (filter); |
| 8543 | if (as_list == NULL) |
| 8544 | { |
| 8545 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 8546 | return CMD_WARNING; |
| 8547 | } |
| 8548 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8549 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8550 | } |
| 8551 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8552 | DEFUN (show_ip_bgp_filter_list, |
| 8553 | show_ip_bgp_filter_list_cmd, |
| 8554 | "show ip bgp filter-list WORD", |
| 8555 | SHOW_STR |
| 8556 | IP_STR |
| 8557 | BGP_STR |
| 8558 | "Display routes conforming to the filter-list\n" |
| 8559 | "Regular expression access list name\n") |
| 8560 | { |
| 8561 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8562 | bgp_show_type_filter_list); |
| 8563 | } |
| 8564 | |
| 8565 | DEFUN (show_ip_bgp_flap_filter_list, |
| 8566 | show_ip_bgp_flap_filter_list_cmd, |
| 8567 | "show ip bgp flap-statistics filter-list WORD", |
| 8568 | SHOW_STR |
| 8569 | IP_STR |
| 8570 | BGP_STR |
| 8571 | "Display flap statistics of routes\n" |
| 8572 | "Display routes conforming to the filter-list\n" |
| 8573 | "Regular expression access list name\n") |
| 8574 | { |
| 8575 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8576 | bgp_show_type_flap_filter_list); |
| 8577 | } |
| 8578 | |
| 8579 | ALIAS (show_ip_bgp_flap_filter_list, |
| 8580 | show_ip_bgp_damp_flap_filter_list_cmd, |
| 8581 | "show ip bgp dampening flap-statistics filter-list WORD", |
| 8582 | SHOW_STR |
| 8583 | IP_STR |
| 8584 | BGP_STR |
| 8585 | "Display detailed information about dampening\n" |
| 8586 | "Display flap statistics of routes\n" |
| 8587 | "Display routes conforming to the filter-list\n" |
| 8588 | "Regular expression access list name\n") |
| 8589 | |
| 8590 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 8591 | show_ip_bgp_ipv4_filter_list_cmd, |
| 8592 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 8593 | SHOW_STR |
| 8594 | IP_STR |
| 8595 | BGP_STR |
| 8596 | "Address family\n" |
| 8597 | "Address Family modifier\n" |
| 8598 | "Address Family modifier\n" |
| 8599 | "Display routes conforming to the filter-list\n" |
| 8600 | "Regular expression access list name\n") |
| 8601 | { |
| 8602 | if (strncmp (argv[0], "m", 1) == 0) |
| 8603 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8604 | bgp_show_type_filter_list); |
| 8605 | |
| 8606 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8607 | bgp_show_type_filter_list); |
| 8608 | } |
| 8609 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8610 | DEFUN (show_bgp_filter_list, |
| 8611 | show_bgp_filter_list_cmd, |
| 8612 | "show bgp filter-list WORD", |
| 8613 | SHOW_STR |
| 8614 | BGP_STR |
| 8615 | "Display routes conforming to the filter-list\n" |
| 8616 | "Regular expression access list name\n") |
| 8617 | { |
| 8618 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8619 | bgp_show_type_filter_list); |
| 8620 | } |
| 8621 | |
| 8622 | /* old command */ |
| 8623 | DEFUN (show_ipv6_bgp_filter_list, |
| 8624 | show_ipv6_bgp_filter_list_cmd, |
| 8625 | "show ipv6 bgp filter-list WORD", |
| 8626 | SHOW_STR |
| 8627 | IPV6_STR |
| 8628 | BGP_STR |
| 8629 | "Display routes conforming to the filter-list\n" |
| 8630 | "Regular expression access list name\n") |
| 8631 | { |
| 8632 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8633 | bgp_show_type_filter_list); |
| 8634 | } |
| 8635 | |
| 8636 | /* old command */ |
| 8637 | DEFUN (show_ipv6_mbgp_filter_list, |
| 8638 | show_ipv6_mbgp_filter_list_cmd, |
| 8639 | "show ipv6 mbgp filter-list WORD", |
| 8640 | SHOW_STR |
| 8641 | IPV6_STR |
| 8642 | MBGP_STR |
| 8643 | "Display routes conforming to the filter-list\n" |
| 8644 | "Regular expression access list name\n") |
| 8645 | { |
| 8646 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8647 | bgp_show_type_filter_list); |
| 8648 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8649 | |
| 8650 | DEFUN (show_ip_bgp_dampening_info, |
| 8651 | show_ip_bgp_dampening_params_cmd, |
| 8652 | "show ip bgp dampening parameters", |
| 8653 | SHOW_STR |
| 8654 | IP_STR |
| 8655 | BGP_STR |
| 8656 | "Display detailed information about dampening\n" |
| 8657 | "Display detail of configured dampening parameters\n") |
| 8658 | { |
| 8659 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); |
| 8660 | } |
| 8661 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8662 | DEFUN (show_bgp_ipv4_filter_list, |
| 8663 | show_bgp_ipv4_filter_list_cmd, |
| 8664 | "show bgp ipv4 filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8665 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8666 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8667 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8668 | "Display routes conforming to the filter-list\n" |
| 8669 | "Regular expression access list name\n") |
| 8670 | { |
| 8671 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8672 | bgp_show_type_filter_list); |
| 8673 | } |
| 8674 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8675 | DEFUN (show_bgp_ipv4_safi_flap_filter_list, |
| 8676 | show_bgp_ipv4_safi_flap_filter_list_cmd, |
| 8677 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8678 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8679 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8680 | IP_STR |
| 8681 | "Address Family modifier\n" |
| 8682 | "Address Family modifier\n" |
| 8683 | "Address Family modifier\n" |
| 8684 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8685 | "Display flap statistics of routes\n" |
| 8686 | "Display routes conforming to the filter-list\n" |
| 8687 | "Regular expression access list name\n") |
| 8688 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8689 | safi_t safi; |
| 8690 | |
| 8691 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8692 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8693 | return CMD_WARNING; |
| 8694 | } |
| 8695 | return bgp_show_filter_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8696 | bgp_show_type_flap_filter_list); |
| 8697 | } |
| 8698 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8699 | ALIAS (show_bgp_ipv4_safi_flap_filter_list, |
| 8700 | show_bgp_ipv4_safi_damp_flap_filter_list_cmd, |
| 8701 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8702 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8703 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8704 | IP_STR |
| 8705 | "Address Family modifier\n" |
| 8706 | "Address Family modifier\n" |
| 8707 | "Address Family modifier\n" |
| 8708 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8709 | "Display detailed information about dampening\n" |
| 8710 | "Display flap statistics of routes\n" |
| 8711 | "Display routes conforming to the filter-list\n" |
| 8712 | "Regular expression access list name\n") |
| 8713 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8714 | DEFUN (show_bgp_ipv6_safi_flap_filter_list, |
| 8715 | show_bgp_ipv6_safi_flap_filter_list_cmd, |
| 8716 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8717 | SHOW_STR |
| 8718 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8719 | IPV6_STR |
| 8720 | "Address Family modifier\n" |
| 8721 | "Address Family modifier\n" |
| 8722 | "Address Family modifier\n" |
| 8723 | "Address Family modifier\n" |
| 8724 | "Display flap statistics of routes\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8725 | "Display routes conforming to the filter-list\n" |
| 8726 | "Regular expression access list name\n") |
| 8727 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8728 | safi_t safi; |
| 8729 | |
| 8730 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8731 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8732 | return CMD_WARNING; |
| 8733 | } |
| 8734 | return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi, |
| 8735 | bgp_show_type_flap_filter_list); |
| 8736 | } |
| 8737 | ALIAS (show_bgp_ipv6_safi_flap_filter_list, |
| 8738 | show_bgp_ipv6_safi_damp_flap_filter_list_cmd, |
| 8739 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD", |
| 8740 | SHOW_STR |
| 8741 | BGP_STR |
| 8742 | IPV6_STR |
| 8743 | "Address Family modifier\n" |
| 8744 | "Address Family modifier\n" |
| 8745 | "Address Family modifier\n" |
| 8746 | "Address Family modifier\n" |
| 8747 | "Display detailed information about dampening\n" |
| 8748 | "Display flap statistics of routes\n" |
| 8749 | "Display routes conforming to the filter-list\n" |
| 8750 | "Regular expression access list name\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8751 | |
| 8752 | DEFUN (show_bgp_ipv4_safi_filter_list, |
| 8753 | show_bgp_ipv4_safi_filter_list_cmd, |
| 8754 | "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD", |
| 8755 | SHOW_STR |
| 8756 | BGP_STR |
| 8757 | "Address Family modifier\n" |
| 8758 | "Address Family modifier\n" |
| 8759 | "Address Family modifier\n" |
| 8760 | "Address Family modifier\n" |
| 8761 | "Display routes conforming to the filter-list\n" |
| 8762 | "Regular expression access list name\n") |
| 8763 | { |
| 8764 | safi_t safi; |
| 8765 | |
| 8766 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8767 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8768 | return CMD_WARNING; |
| 8769 | } |
| 8770 | return bgp_show_filter_list (vty, argv[1], AFI_IP, safi, |
| 8771 | bgp_show_type_filter_list); |
| 8772 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8773 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8774 | DEFUN (show_bgp_ipv6_safi_filter_list, |
| 8775 | show_bgp_ipv6_safi_filter_list_cmd, |
| 8776 | "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD", |
| 8777 | SHOW_STR |
| 8778 | BGP_STR |
| 8779 | "Address Family modifier\n" |
| 8780 | "Address Family modifier\n" |
| 8781 | "Address Family modifier\n" |
| 8782 | "Address Family modifier\n" |
| 8783 | "Display routes conforming to the filter-list\n" |
| 8784 | "Regular expression access list name\n") |
| 8785 | { |
| 8786 | safi_t safi; |
| 8787 | |
| 8788 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8789 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8790 | return CMD_WARNING; |
| 8791 | } |
| 8792 | return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi, |
| 8793 | bgp_show_type_filter_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8794 | } |
| 8795 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8796 | DEFUN (show_bgp_ipv6_filter_list, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8797 | show_bgp_ipv6_filter_list_cmd, |
| 8798 | "show bgp ipv6 filter-list WORD", |
| 8799 | SHOW_STR |
| 8800 | BGP_STR |
| 8801 | "Address family\n" |
| 8802 | "Display routes conforming to the filter-list\n" |
| 8803 | "Regular expression access list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8804 | { |
| 8805 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8806 | bgp_show_type_filter_list); |
| 8807 | } |
| 8808 | |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 8809 | |
| 8810 | DEFUN (show_ip_bgp_ipv4_dampening_parameters, |
| 8811 | show_ip_bgp_ipv4_dampening_parameters_cmd, |
| 8812 | "show ip bgp ipv4 (unicast|multicast) dampening parameters", |
| 8813 | SHOW_STR |
| 8814 | IP_STR |
| 8815 | BGP_STR |
| 8816 | "Address family\n" |
| 8817 | "Address Family modifier\n" |
| 8818 | "Address Family modifier\n" |
| 8819 | "Display detailed information about dampening\n" |
| 8820 | "Display detail of configured dampening parameters\n") |
| 8821 | { |
| 8822 | if (strncmp(argv[0], "m", 1) == 0) |
| 8823 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST); |
| 8824 | |
| 8825 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); |
| 8826 | } |
| 8827 | |
| 8828 | |
| 8829 | DEFUN (show_ip_bgp_ipv4_dampening_flap_stats, |
| 8830 | show_ip_bgp_ipv4_dampening_flap_stats_cmd, |
| 8831 | "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics", |
| 8832 | SHOW_STR |
| 8833 | IP_STR |
| 8834 | BGP_STR |
| 8835 | "Address family\n" |
| 8836 | "Address Family modifier\n" |
| 8837 | "Address Family modifier\n" |
| 8838 | "Display detailed information about dampening\n" |
| 8839 | "Display flap statistics of routes\n") |
| 8840 | { |
| 8841 | if (strncmp(argv[0], "m", 1) == 0) |
| 8842 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8843 | bgp_show_type_flap_statistics, NULL); |
| 8844 | |
| 8845 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8846 | bgp_show_type_flap_statistics, NULL); |
| 8847 | } |
| 8848 | |
| 8849 | DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths, |
| 8850 | show_ip_bgp_ipv4_dampening_dampd_paths_cmd, |
| 8851 | "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths", |
| 8852 | SHOW_STR |
| 8853 | IP_STR |
| 8854 | BGP_STR |
| 8855 | "Address family\n" |
| 8856 | "Address Family modifier\n" |
| 8857 | "Address Family modifier\n" |
| 8858 | "Display detailed information about dampening\n" |
| 8859 | "Display paths suppressed due to dampening\n") |
| 8860 | { |
| 8861 | if (strncmp(argv[0], "m", 1) == 0) |
| 8862 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8863 | bgp_show_type_dampend_paths, NULL); |
| 8864 | |
| 8865 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8866 | bgp_show_type_dampend_paths, NULL); |
| 8867 | } |
| 8868 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8869 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8870 | 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] | 8871 | safi_t safi, enum bgp_show_type type) |
| 8872 | { |
| 8873 | struct route_map *rmap; |
| 8874 | |
| 8875 | rmap = route_map_lookup_by_name (rmap_str); |
| 8876 | if (! rmap) |
| 8877 | { |
| 8878 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 8879 | rmap_str, VTY_NEWLINE); |
| 8880 | return CMD_WARNING; |
| 8881 | } |
| 8882 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8883 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8884 | } |
| 8885 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8886 | DEFUN (show_ip_bgp_route_map, |
| 8887 | show_ip_bgp_route_map_cmd, |
| 8888 | "show ip bgp route-map WORD", |
| 8889 | SHOW_STR |
| 8890 | IP_STR |
| 8891 | BGP_STR |
| 8892 | "Display routes matching the route-map\n" |
| 8893 | "A route-map to match on\n") |
| 8894 | { |
| 8895 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8896 | bgp_show_type_route_map); |
| 8897 | } |
| 8898 | |
| 8899 | DEFUN (show_ip_bgp_flap_route_map, |
| 8900 | show_ip_bgp_flap_route_map_cmd, |
| 8901 | "show ip bgp flap-statistics route-map WORD", |
| 8902 | SHOW_STR |
| 8903 | IP_STR |
| 8904 | BGP_STR |
| 8905 | "Display flap statistics of routes\n" |
| 8906 | "Display routes matching the route-map\n" |
| 8907 | "A route-map to match on\n") |
| 8908 | { |
| 8909 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8910 | bgp_show_type_flap_route_map); |
| 8911 | } |
| 8912 | |
| 8913 | ALIAS (show_ip_bgp_flap_route_map, |
| 8914 | show_ip_bgp_damp_flap_route_map_cmd, |
| 8915 | "show ip bgp dampening flap-statistics route-map WORD", |
| 8916 | SHOW_STR |
| 8917 | IP_STR |
| 8918 | BGP_STR |
| 8919 | "Display detailed information about dampening\n" |
| 8920 | "Display flap statistics of routes\n" |
| 8921 | "Display routes matching the route-map\n" |
| 8922 | "A route-map to match on\n") |
| 8923 | |
| 8924 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 8925 | show_ip_bgp_ipv4_route_map_cmd, |
| 8926 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 8927 | SHOW_STR |
| 8928 | IP_STR |
| 8929 | BGP_STR |
| 8930 | "Address family\n" |
| 8931 | "Address Family modifier\n" |
| 8932 | "Address Family modifier\n" |
| 8933 | "Display routes matching the route-map\n" |
| 8934 | "A route-map to match on\n") |
| 8935 | { |
| 8936 | if (strncmp (argv[0], "m", 1) == 0) |
| 8937 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8938 | bgp_show_type_route_map); |
| 8939 | |
| 8940 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8941 | bgp_show_type_route_map); |
| 8942 | } |
| 8943 | |
| 8944 | DEFUN (show_bgp_route_map, |
| 8945 | show_bgp_route_map_cmd, |
| 8946 | "show bgp route-map WORD", |
| 8947 | SHOW_STR |
| 8948 | BGP_STR |
| 8949 | "Display routes matching the route-map\n" |
| 8950 | "A route-map to match on\n") |
| 8951 | { |
| 8952 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8953 | bgp_show_type_route_map); |
| 8954 | } |
| 8955 | |
| 8956 | DEFUN (show_ip_bgp_cidr_only, |
| 8957 | show_ip_bgp_cidr_only_cmd, |
| 8958 | "show ip bgp cidr-only", |
| 8959 | SHOW_STR |
| 8960 | IP_STR |
| 8961 | BGP_STR |
| 8962 | "Display only routes with non-natural netmasks\n") |
| 8963 | { |
| 8964 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 8965 | bgp_show_type_cidr_only, NULL); |
| 8966 | } |
| 8967 | |
| 8968 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 8969 | show_ip_bgp_flap_cidr_only_cmd, |
| 8970 | "show ip bgp flap-statistics cidr-only", |
| 8971 | SHOW_STR |
| 8972 | IP_STR |
| 8973 | BGP_STR |
| 8974 | "Display flap statistics of routes\n" |
| 8975 | "Display only routes with non-natural netmasks\n") |
| 8976 | { |
| 8977 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 8978 | bgp_show_type_flap_cidr_only, NULL); |
| 8979 | } |
| 8980 | |
| 8981 | ALIAS (show_ip_bgp_flap_cidr_only, |
| 8982 | show_ip_bgp_damp_flap_cidr_only_cmd, |
| 8983 | "show ip bgp dampening flap-statistics cidr-only", |
| 8984 | SHOW_STR |
| 8985 | IP_STR |
| 8986 | BGP_STR |
| 8987 | "Display detailed information about dampening\n" |
| 8988 | "Display flap statistics of routes\n" |
| 8989 | "Display only routes with non-natural netmasks\n") |
| 8990 | |
| 8991 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 8992 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 8993 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 8994 | SHOW_STR |
| 8995 | IP_STR |
| 8996 | BGP_STR |
| 8997 | "Address family\n" |
| 8998 | "Address Family modifier\n" |
| 8999 | "Address Family modifier\n" |
| 9000 | "Display only routes with non-natural netmasks\n") |
| 9001 | { |
| 9002 | if (strncmp (argv[0], "m", 1) == 0) |
| 9003 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 9004 | bgp_show_type_cidr_only, NULL); |
| 9005 | |
| 9006 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 9007 | bgp_show_type_cidr_only, NULL); |
| 9008 | } |
| 9009 | |
| 9010 | DEFUN (show_ip_bgp_community_all, |
| 9011 | show_ip_bgp_community_all_cmd, |
| 9012 | "show ip bgp community", |
| 9013 | SHOW_STR |
| 9014 | IP_STR |
| 9015 | BGP_STR |
| 9016 | "Display routes matching the communities\n") |
| 9017 | { |
| 9018 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 9019 | bgp_show_type_community_all, NULL); |
| 9020 | } |
| 9021 | |
| 9022 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 9023 | show_ip_bgp_ipv4_community_all_cmd, |
| 9024 | "show ip bgp ipv4 (unicast|multicast) community", |
| 9025 | SHOW_STR |
| 9026 | IP_STR |
| 9027 | BGP_STR |
| 9028 | "Address family\n" |
| 9029 | "Address Family modifier\n" |
| 9030 | "Address Family modifier\n" |
| 9031 | "Display routes matching the communities\n") |
| 9032 | { |
| 9033 | if (strncmp (argv[0], "m", 1) == 0) |
| 9034 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 9035 | bgp_show_type_community_all, NULL); |
| 9036 | |
| 9037 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 9038 | bgp_show_type_community_all, NULL); |
| 9039 | } |
| 9040 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9041 | DEFUN (show_bgp_community_all, |
| 9042 | show_bgp_community_all_cmd, |
| 9043 | "show bgp community", |
| 9044 | SHOW_STR |
| 9045 | BGP_STR |
| 9046 | "Display routes matching the communities\n") |
| 9047 | { |
| 9048 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
| 9049 | bgp_show_type_community_all, NULL); |
| 9050 | } |
| 9051 | |
| 9052 | ALIAS (show_bgp_community_all, |
| 9053 | show_bgp_ipv6_community_all_cmd, |
| 9054 | "show bgp ipv6 community", |
| 9055 | SHOW_STR |
| 9056 | BGP_STR |
| 9057 | "Address family\n" |
| 9058 | "Display routes matching the communities\n") |
| 9059 | |
| 9060 | /* old command */ |
| 9061 | DEFUN (show_ipv6_bgp_community_all, |
| 9062 | show_ipv6_bgp_community_all_cmd, |
| 9063 | "show ipv6 bgp community", |
| 9064 | SHOW_STR |
| 9065 | IPV6_STR |
| 9066 | BGP_STR |
| 9067 | "Display routes matching the communities\n") |
| 9068 | { |
| 9069 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
| 9070 | bgp_show_type_community_all, NULL); |
| 9071 | } |
| 9072 | |
| 9073 | /* old command */ |
| 9074 | DEFUN (show_ipv6_mbgp_community_all, |
| 9075 | show_ipv6_mbgp_community_all_cmd, |
| 9076 | "show ipv6 mbgp community", |
| 9077 | SHOW_STR |
| 9078 | IPV6_STR |
| 9079 | MBGP_STR |
| 9080 | "Display routes matching the communities\n") |
| 9081 | { |
| 9082 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
| 9083 | bgp_show_type_community_all, NULL); |
| 9084 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9085 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9086 | DEFUN (show_bgp_ipv4_route_map, |
| 9087 | show_bgp_ipv4_route_map_cmd, |
| 9088 | "show bgp ipv4 route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9089 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9090 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9091 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9092 | "Display routes matching the route-map\n" |
| 9093 | "A route-map to match on\n") |
| 9094 | { |
| 9095 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9096 | bgp_show_type_route_map); |
| 9097 | } |
| 9098 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9099 | DEFUN (show_bgp_ipv4_safi_flap_route_map, |
| 9100 | show_bgp_ipv4_safi_flap_route_map_cmd, |
| 9101 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9102 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9103 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9104 | IP_STR |
| 9105 | "Address Family Modifier\n" |
| 9106 | "Address Family Modifier\n" |
| 9107 | "Address Family Modifier\n" |
| 9108 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9109 | "Display flap statistics of routes\n" |
| 9110 | "Display routes matching the route-map\n" |
| 9111 | "A route-map to match on\n") |
| 9112 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9113 | safi_t safi; |
| 9114 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9115 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9116 | return CMD_WARNING; |
| 9117 | } |
| 9118 | return bgp_show_route_map (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9119 | bgp_show_type_flap_route_map); |
| 9120 | } |
| 9121 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9122 | ALIAS (show_bgp_ipv4_safi_flap_route_map, |
| 9123 | show_bgp_ipv4_safi_damp_flap_route_map_cmd, |
| 9124 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9125 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9126 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9127 | IP_STR |
| 9128 | "Address Family Modifier\n" |
| 9129 | "Address Family Modifier\n" |
| 9130 | "Address Family Modifier\n" |
| 9131 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9132 | "Display detailed information about dampening\n" |
| 9133 | "Display flap statistics of routes\n" |
| 9134 | "Display routes matching the route-map\n" |
| 9135 | "A route-map to match on\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 9136 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9137 | DEFUN (show_bgp_ipv6_safi_flap_route_map, |
| 9138 | show_bgp_ipv6_safi_flap_route_map_cmd, |
| 9139 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9140 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9141 | BGP_STR |
| 9142 | IPV6_STR |
| 9143 | "Address Family Modifier\n" |
| 9144 | "Address Family Modifier\n" |
| 9145 | "Address Family Modifier\n" |
| 9146 | "Address Family Modifier\n" |
| 9147 | "Display flap statistics of routes\n" |
| 9148 | "Display routes matching the route-map\n" |
| 9149 | "A route-map to match on\n") |
| 9150 | { |
| 9151 | safi_t safi; |
| 9152 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9153 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9154 | return CMD_WARNING; |
| 9155 | } |
| 9156 | return bgp_show_route_map (vty, argv[1], AFI_IP6, safi, |
| 9157 | bgp_show_type_flap_route_map); |
| 9158 | } |
| 9159 | ALIAS (show_bgp_ipv6_safi_flap_route_map, |
| 9160 | show_bgp_ipv6_safi_damp_flap_route_map_cmd, |
| 9161 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD", |
| 9162 | SHOW_STR |
| 9163 | BGP_STR |
| 9164 | IPV6_STR |
| 9165 | "Address Family Modifier\n" |
| 9166 | "Address Family Modifier\n" |
| 9167 | "Address Family Modifier\n" |
| 9168 | "Address Family Modifier\n" |
| 9169 | "Display detailed information about dampening\n" |
| 9170 | "Display flap statistics of routes\n" |
| 9171 | "Display routes matching the route-map\n" |
| 9172 | "A route-map to match on\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9173 | |
| 9174 | DEFUN (show_bgp_ipv4_safi_route_map, |
| 9175 | show_bgp_ipv4_safi_route_map_cmd, |
| 9176 | "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD", |
| 9177 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9178 | BGP_STR |
| 9179 | "Address family\n" |
| 9180 | "Address Family modifier\n" |
| 9181 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9182 | "Address Family modifier\n" |
| 9183 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9184 | "Display routes matching the route-map\n" |
| 9185 | "A route-map to match on\n") |
| 9186 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9187 | safi_t safi; |
| 9188 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9189 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9190 | return CMD_WARNING; |
| 9191 | } |
| 9192 | return bgp_show_route_map (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9193 | bgp_show_type_route_map); |
| 9194 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 9195 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9196 | DEFUN (show_bgp_ipv6_safi_route_map, |
| 9197 | show_bgp_ipv6_safi_route_map_cmd, |
| 9198 | "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9199 | SHOW_STR |
| 9200 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9201 | "Address family\n" |
| 9202 | "Address Family modifier\n" |
| 9203 | "Address Family modifier\n" |
| 9204 | "Address Family modifier\n" |
| 9205 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9206 | "Display routes matching the route-map\n" |
| 9207 | "A route-map to match on\n") |
| 9208 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9209 | safi_t safi; |
| 9210 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9211 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9212 | return CMD_WARNING; |
| 9213 | } |
| 9214 | return bgp_show_route_map (vty, argv[1], AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9215 | bgp_show_type_route_map); |
| 9216 | } |
| 9217 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9218 | DEFUN (show_bgp_ipv6_route_map, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9219 | show_bgp_ipv6_route_map_cmd, |
| 9220 | "show bgp ipv6 route-map WORD", |
| 9221 | SHOW_STR |
| 9222 | BGP_STR |
| 9223 | "Address family\n" |
| 9224 | "Display routes matching the route-map\n" |
| 9225 | "A route-map to match on\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9226 | { |
| 9227 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9228 | bgp_show_type_route_map); |
| 9229 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9230 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9231 | DEFUN (show_bgp_ipv4_cidr_only, |
| 9232 | show_bgp_ipv4_cidr_only_cmd, |
| 9233 | "show bgp ipv4 cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9234 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9235 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9236 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9237 | "Display only routes with non-natural netmasks\n") |
| 9238 | { |
| 9239 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9240 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9241 | } |
| 9242 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9243 | DEFUN (show_bgp_ipv4_safi_flap_cidr_only, |
| 9244 | show_bgp_ipv4_safi_flap_cidr_only_cmd, |
| 9245 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9246 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9247 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9248 | "Address Family\n" |
| 9249 | "Address Family Modifier\n" |
| 9250 | "Address Family Modifier\n" |
| 9251 | "Address Family Modifier\n" |
| 9252 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9253 | "Display flap statistics of routes\n" |
| 9254 | "Display only routes with non-natural netmasks\n") |
| 9255 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9256 | safi_t safi; |
| 9257 | |
| 9258 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9259 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9260 | return CMD_WARNING; |
| 9261 | } |
| 9262 | return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9263 | } |
| 9264 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9265 | ALIAS (show_bgp_ipv4_safi_flap_cidr_only, |
| 9266 | show_bgp_ipv4_safi_damp_flap_cidr_only_cmd, |
| 9267 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9268 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9269 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9270 | "Address Family\n" |
| 9271 | "Address Family Modifier\n" |
| 9272 | "Address Family Modifier\n" |
| 9273 | "Address Family Modifier\n" |
| 9274 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9275 | "Display detailed information about dampening\n" |
| 9276 | "Display flap statistics of routes\n" |
| 9277 | "Display only routes with non-natural netmasks\n") |
| 9278 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9279 | DEFUN (show_bgp_ipv4_safi_cidr_only, |
| 9280 | show_bgp_ipv4_safi_cidr_only_cmd, |
| 9281 | "show bgp ipv4 (unicast|multicast) cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9282 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9283 | BGP_STR |
| 9284 | "Address family\n" |
| 9285 | "Address Family modifier\n" |
| 9286 | "Address Family modifier\n" |
| 9287 | "Display only routes with non-natural netmasks\n") |
| 9288 | { |
| 9289 | if (strncmp (argv[0], "m", 1) == 0) |
| 9290 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9291 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9292 | |
| 9293 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9294 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9295 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9296 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9297 | /* new046 */ |
| 9298 | DEFUN (show_bgp_afi_safi_community_all, |
| 9299 | show_bgp_afi_safi_community_all_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9300 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9301 | SHOW_STR |
| 9302 | BGP_STR |
| 9303 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9304 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9305 | "Address Family modifier\n" |
| 9306 | "Address Family modifier\n" |
| 9307 | "Address Family modifier\n" |
| 9308 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9309 | "Display routes matching the communities\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9310 | { |
| 9311 | safi_t safi; |
| 9312 | afi_t afi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9313 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9314 | if (bgp_parse_afi(argv[0], &afi)) { |
| 9315 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 9316 | return CMD_WARNING; |
| 9317 | } |
| 9318 | if (bgp_parse_safi(argv[1], &safi)) { |
| 9319 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 9320 | return CMD_WARNING; |
| 9321 | } |
| 9322 | |
| 9323 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL); |
| 9324 | } |
| 9325 | DEFUN (show_bgp_afi_community_all, |
| 9326 | show_bgp_afi_community_all_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9327 | "show bgp (ipv4|ipv6) community", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9328 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9329 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9330 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9331 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9332 | "Display routes matching the communities\n") |
| 9333 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9334 | afi_t afi; |
| 9335 | safi_t safi = SAFI_UNICAST; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9336 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9337 | if (bgp_parse_afi(argv[0], &afi)) { |
| 9338 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 9339 | return CMD_WARNING; |
| 9340 | } |
| 9341 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9342 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9343 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9344 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9345 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 9346 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9347 | { |
| 9348 | struct community *com; |
| 9349 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9350 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9351 | int i; |
| 9352 | char *str; |
| 9353 | int first = 0; |
| 9354 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9355 | /* BGP structure lookup */ |
| 9356 | if (view_name) |
| 9357 | { |
| 9358 | bgp = bgp_lookup_by_name (view_name); |
| 9359 | if (bgp == NULL) |
| 9360 | { |
| 9361 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9362 | return CMD_WARNING; |
| 9363 | } |
| 9364 | } |
| 9365 | else |
| 9366 | { |
| 9367 | bgp = bgp_get_default (); |
| 9368 | if (bgp == NULL) |
| 9369 | { |
| 9370 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9371 | return CMD_WARNING; |
| 9372 | } |
| 9373 | } |
| 9374 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9375 | b = buffer_new (1024); |
| 9376 | for (i = 0; i < argc; i++) |
| 9377 | { |
| 9378 | if (first) |
| 9379 | buffer_putc (b, ' '); |
| 9380 | else |
| 9381 | { |
| 9382 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 9383 | continue; |
| 9384 | first = 1; |
| 9385 | } |
| 9386 | |
| 9387 | buffer_putstr (b, argv[i]); |
| 9388 | } |
| 9389 | buffer_putc (b, '\0'); |
| 9390 | |
| 9391 | str = buffer_getstr (b); |
| 9392 | buffer_free (b); |
| 9393 | |
| 9394 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 9395 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9396 | if (! com) |
| 9397 | { |
| 9398 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 9399 | return CMD_WARNING; |
| 9400 | } |
| 9401 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9402 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9403 | (exact ? bgp_show_type_community_exact : |
| 9404 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9405 | } |
| 9406 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9407 | DEFUN (show_ip_bgp_community, |
| 9408 | show_ip_bgp_community_cmd, |
| 9409 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9410 | SHOW_STR |
| 9411 | IP_STR |
| 9412 | BGP_STR |
| 9413 | "Display routes matching the communities\n" |
| 9414 | "community number\n" |
| 9415 | "Do not send outside local AS (well-known community)\n" |
| 9416 | "Do not advertise to any peer (well-known community)\n" |
| 9417 | "Do not export to next AS (well-known community)\n") |
| 9418 | { |
| 9419 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 9420 | } |
| 9421 | |
| 9422 | ALIAS (show_ip_bgp_community, |
| 9423 | show_ip_bgp_community2_cmd, |
| 9424 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9425 | SHOW_STR |
| 9426 | IP_STR |
| 9427 | BGP_STR |
| 9428 | "Display routes matching the communities\n" |
| 9429 | "community number\n" |
| 9430 | "Do not send outside local AS (well-known community)\n" |
| 9431 | "Do not advertise to any peer (well-known community)\n" |
| 9432 | "Do not export to next AS (well-known community)\n" |
| 9433 | "community number\n" |
| 9434 | "Do not send outside local AS (well-known community)\n" |
| 9435 | "Do not advertise to any peer (well-known community)\n" |
| 9436 | "Do not export to next AS (well-known community)\n") |
| 9437 | |
| 9438 | ALIAS (show_ip_bgp_community, |
| 9439 | show_ip_bgp_community3_cmd, |
| 9440 | "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)", |
| 9441 | SHOW_STR |
| 9442 | IP_STR |
| 9443 | BGP_STR |
| 9444 | "Display routes matching the communities\n" |
| 9445 | "community number\n" |
| 9446 | "Do not send outside local AS (well-known community)\n" |
| 9447 | "Do not advertise to any peer (well-known community)\n" |
| 9448 | "Do not export to next AS (well-known community)\n" |
| 9449 | "community number\n" |
| 9450 | "Do not send outside local AS (well-known community)\n" |
| 9451 | "Do not advertise to any peer (well-known community)\n" |
| 9452 | "Do not export to next AS (well-known community)\n" |
| 9453 | "community number\n" |
| 9454 | "Do not send outside local AS (well-known community)\n" |
| 9455 | "Do not advertise to any peer (well-known community)\n" |
| 9456 | "Do not export to next AS (well-known community)\n") |
| 9457 | |
| 9458 | ALIAS (show_ip_bgp_community, |
| 9459 | show_ip_bgp_community4_cmd, |
| 9460 | "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)", |
| 9461 | SHOW_STR |
| 9462 | IP_STR |
| 9463 | BGP_STR |
| 9464 | "Display routes matching the communities\n" |
| 9465 | "community number\n" |
| 9466 | "Do not send outside local AS (well-known community)\n" |
| 9467 | "Do not advertise to any peer (well-known community)\n" |
| 9468 | "Do not export to next AS (well-known community)\n" |
| 9469 | "community number\n" |
| 9470 | "Do not send outside local AS (well-known community)\n" |
| 9471 | "Do not advertise to any peer (well-known community)\n" |
| 9472 | "Do not export to next AS (well-known community)\n" |
| 9473 | "community number\n" |
| 9474 | "Do not send outside local AS (well-known community)\n" |
| 9475 | "Do not advertise to any peer (well-known community)\n" |
| 9476 | "Do not export to next AS (well-known community)\n" |
| 9477 | "community number\n" |
| 9478 | "Do not send outside local AS (well-known community)\n" |
| 9479 | "Do not advertise to any peer (well-known community)\n" |
| 9480 | "Do not export to next AS (well-known community)\n") |
| 9481 | |
| 9482 | DEFUN (show_ip_bgp_ipv4_community, |
| 9483 | show_ip_bgp_ipv4_community_cmd, |
| 9484 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 9485 | SHOW_STR |
| 9486 | IP_STR |
| 9487 | BGP_STR |
| 9488 | "Address family\n" |
| 9489 | "Address Family modifier\n" |
| 9490 | "Address Family modifier\n" |
| 9491 | "Display routes matching the communities\n" |
| 9492 | "community number\n" |
| 9493 | "Do not send outside local AS (well-known community)\n" |
| 9494 | "Do not advertise to any peer (well-known community)\n" |
| 9495 | "Do not export to next AS (well-known community)\n") |
| 9496 | { |
| 9497 | if (strncmp (argv[0], "m", 1) == 0) |
| 9498 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 9499 | |
| 9500 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 9501 | } |
| 9502 | |
| 9503 | ALIAS (show_ip_bgp_ipv4_community, |
| 9504 | show_ip_bgp_ipv4_community2_cmd, |
| 9505 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9506 | SHOW_STR |
| 9507 | IP_STR |
| 9508 | BGP_STR |
| 9509 | "Address family\n" |
| 9510 | "Address Family modifier\n" |
| 9511 | "Address Family modifier\n" |
| 9512 | "Display routes matching the communities\n" |
| 9513 | "community number\n" |
| 9514 | "Do not send outside local AS (well-known community)\n" |
| 9515 | "Do not advertise to any peer (well-known community)\n" |
| 9516 | "Do not export to next AS (well-known community)\n" |
| 9517 | "community number\n" |
| 9518 | "Do not send outside local AS (well-known community)\n" |
| 9519 | "Do not advertise to any peer (well-known community)\n" |
| 9520 | "Do not export to next AS (well-known community)\n") |
| 9521 | |
| 9522 | ALIAS (show_ip_bgp_ipv4_community, |
| 9523 | show_ip_bgp_ipv4_community3_cmd, |
| 9524 | "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)", |
| 9525 | SHOW_STR |
| 9526 | IP_STR |
| 9527 | BGP_STR |
| 9528 | "Address family\n" |
| 9529 | "Address Family modifier\n" |
| 9530 | "Address Family modifier\n" |
| 9531 | "Display routes matching the communities\n" |
| 9532 | "community number\n" |
| 9533 | "Do not send outside local AS (well-known community)\n" |
| 9534 | "Do not advertise to any peer (well-known community)\n" |
| 9535 | "Do not export to next AS (well-known community)\n" |
| 9536 | "community number\n" |
| 9537 | "Do not send outside local AS (well-known community)\n" |
| 9538 | "Do not advertise to any peer (well-known community)\n" |
| 9539 | "Do not export to next AS (well-known community)\n" |
| 9540 | "community number\n" |
| 9541 | "Do not send outside local AS (well-known community)\n" |
| 9542 | "Do not advertise to any peer (well-known community)\n" |
| 9543 | "Do not export to next AS (well-known community)\n") |
| 9544 | |
| 9545 | ALIAS (show_ip_bgp_ipv4_community, |
| 9546 | show_ip_bgp_ipv4_community4_cmd, |
| 9547 | "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)", |
| 9548 | SHOW_STR |
| 9549 | IP_STR |
| 9550 | BGP_STR |
| 9551 | "Address family\n" |
| 9552 | "Address Family modifier\n" |
| 9553 | "Address Family modifier\n" |
| 9554 | "Display routes matching the communities\n" |
| 9555 | "community number\n" |
| 9556 | "Do not send outside local AS (well-known community)\n" |
| 9557 | "Do not advertise to any peer (well-known community)\n" |
| 9558 | "Do not export to next AS (well-known community)\n" |
| 9559 | "community number\n" |
| 9560 | "Do not send outside local AS (well-known community)\n" |
| 9561 | "Do not advertise to any peer (well-known community)\n" |
| 9562 | "Do not export to next AS (well-known community)\n" |
| 9563 | "community number\n" |
| 9564 | "Do not send outside local AS (well-known community)\n" |
| 9565 | "Do not advertise to any peer (well-known community)\n" |
| 9566 | "Do not export to next AS (well-known community)\n" |
| 9567 | "community number\n" |
| 9568 | "Do not send outside local AS (well-known community)\n" |
| 9569 | "Do not advertise to any peer (well-known community)\n" |
| 9570 | "Do not export to next AS (well-known community)\n") |
| 9571 | |
| 9572 | DEFUN (show_ip_bgp_community_exact, |
| 9573 | show_ip_bgp_community_exact_cmd, |
| 9574 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9575 | SHOW_STR |
| 9576 | IP_STR |
| 9577 | BGP_STR |
| 9578 | "Display routes matching the communities\n" |
| 9579 | "community number\n" |
| 9580 | "Do not send outside local AS (well-known community)\n" |
| 9581 | "Do not advertise to any peer (well-known community)\n" |
| 9582 | "Do not export to next AS (well-known community)\n" |
| 9583 | "Exact match of the communities") |
| 9584 | { |
| 9585 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 9586 | } |
| 9587 | |
| 9588 | ALIAS (show_ip_bgp_community_exact, |
| 9589 | show_ip_bgp_community2_exact_cmd, |
| 9590 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9591 | SHOW_STR |
| 9592 | IP_STR |
| 9593 | BGP_STR |
| 9594 | "Display routes matching the communities\n" |
| 9595 | "community number\n" |
| 9596 | "Do not send outside local AS (well-known community)\n" |
| 9597 | "Do not advertise to any peer (well-known community)\n" |
| 9598 | "Do not export to next AS (well-known community)\n" |
| 9599 | "community number\n" |
| 9600 | "Do not send outside local AS (well-known community)\n" |
| 9601 | "Do not advertise to any peer (well-known community)\n" |
| 9602 | "Do not export to next AS (well-known community)\n" |
| 9603 | "Exact match of the communities") |
| 9604 | |
| 9605 | ALIAS (show_ip_bgp_community_exact, |
| 9606 | show_ip_bgp_community3_exact_cmd, |
| 9607 | "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", |
| 9608 | SHOW_STR |
| 9609 | IP_STR |
| 9610 | BGP_STR |
| 9611 | "Display routes matching the communities\n" |
| 9612 | "community number\n" |
| 9613 | "Do not send outside local AS (well-known community)\n" |
| 9614 | "Do not advertise to any peer (well-known community)\n" |
| 9615 | "Do not export to next AS (well-known community)\n" |
| 9616 | "community number\n" |
| 9617 | "Do not send outside local AS (well-known community)\n" |
| 9618 | "Do not advertise to any peer (well-known community)\n" |
| 9619 | "Do not export to next AS (well-known community)\n" |
| 9620 | "community number\n" |
| 9621 | "Do not send outside local AS (well-known community)\n" |
| 9622 | "Do not advertise to any peer (well-known community)\n" |
| 9623 | "Do not export to next AS (well-known community)\n" |
| 9624 | "Exact match of the communities") |
| 9625 | |
| 9626 | ALIAS (show_ip_bgp_community_exact, |
| 9627 | show_ip_bgp_community4_exact_cmd, |
| 9628 | "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", |
| 9629 | SHOW_STR |
| 9630 | IP_STR |
| 9631 | BGP_STR |
| 9632 | "Display routes matching the communities\n" |
| 9633 | "community number\n" |
| 9634 | "Do not send outside local AS (well-known community)\n" |
| 9635 | "Do not advertise to any peer (well-known community)\n" |
| 9636 | "Do not export to next AS (well-known community)\n" |
| 9637 | "community number\n" |
| 9638 | "Do not send outside local AS (well-known community)\n" |
| 9639 | "Do not advertise to any peer (well-known community)\n" |
| 9640 | "Do not export to next AS (well-known community)\n" |
| 9641 | "community number\n" |
| 9642 | "Do not send outside local AS (well-known community)\n" |
| 9643 | "Do not advertise to any peer (well-known community)\n" |
| 9644 | "Do not export to next AS (well-known community)\n" |
| 9645 | "community number\n" |
| 9646 | "Do not send outside local AS (well-known community)\n" |
| 9647 | "Do not advertise to any peer (well-known community)\n" |
| 9648 | "Do not export to next AS (well-known community)\n" |
| 9649 | "Exact match of the communities") |
| 9650 | |
| 9651 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 9652 | show_ip_bgp_ipv4_community_exact_cmd, |
| 9653 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9654 | SHOW_STR |
| 9655 | IP_STR |
| 9656 | BGP_STR |
| 9657 | "Address family\n" |
| 9658 | "Address Family modifier\n" |
| 9659 | "Address Family modifier\n" |
| 9660 | "Display routes matching the communities\n" |
| 9661 | "community number\n" |
| 9662 | "Do not send outside local AS (well-known community)\n" |
| 9663 | "Do not advertise to any peer (well-known community)\n" |
| 9664 | "Do not export to next AS (well-known community)\n" |
| 9665 | "Exact match of the communities") |
| 9666 | { |
| 9667 | if (strncmp (argv[0], "m", 1) == 0) |
| 9668 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 9669 | |
| 9670 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 9671 | } |
| 9672 | |
| 9673 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9674 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 9675 | "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", |
| 9676 | SHOW_STR |
| 9677 | IP_STR |
| 9678 | BGP_STR |
| 9679 | "Address family\n" |
| 9680 | "Address Family modifier\n" |
| 9681 | "Address Family modifier\n" |
| 9682 | "Display routes matching the communities\n" |
| 9683 | "community number\n" |
| 9684 | "Do not send outside local AS (well-known community)\n" |
| 9685 | "Do not advertise to any peer (well-known community)\n" |
| 9686 | "Do not export to next AS (well-known community)\n" |
| 9687 | "community number\n" |
| 9688 | "Do not send outside local AS (well-known community)\n" |
| 9689 | "Do not advertise to any peer (well-known community)\n" |
| 9690 | "Do not export to next AS (well-known community)\n" |
| 9691 | "Exact match of the communities") |
| 9692 | |
| 9693 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9694 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 9695 | "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", |
| 9696 | SHOW_STR |
| 9697 | IP_STR |
| 9698 | BGP_STR |
| 9699 | "Address family\n" |
| 9700 | "Address Family modifier\n" |
| 9701 | "Address Family modifier\n" |
| 9702 | "Display routes matching the communities\n" |
| 9703 | "community number\n" |
| 9704 | "Do not send outside local AS (well-known community)\n" |
| 9705 | "Do not advertise to any peer (well-known community)\n" |
| 9706 | "Do not export to next AS (well-known community)\n" |
| 9707 | "community number\n" |
| 9708 | "Do not send outside local AS (well-known community)\n" |
| 9709 | "Do not advertise to any peer (well-known community)\n" |
| 9710 | "Do not export to next AS (well-known community)\n" |
| 9711 | "community number\n" |
| 9712 | "Do not send outside local AS (well-known community)\n" |
| 9713 | "Do not advertise to any peer (well-known community)\n" |
| 9714 | "Do not export to next AS (well-known community)\n" |
| 9715 | "Exact match of the communities") |
| 9716 | |
| 9717 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9718 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 9719 | "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", |
| 9720 | SHOW_STR |
| 9721 | IP_STR |
| 9722 | BGP_STR |
| 9723 | "Address family\n" |
| 9724 | "Address Family modifier\n" |
| 9725 | "Address Family modifier\n" |
| 9726 | "Display routes matching the communities\n" |
| 9727 | "community number\n" |
| 9728 | "Do not send outside local AS (well-known community)\n" |
| 9729 | "Do not advertise to any peer (well-known community)\n" |
| 9730 | "Do not export to next AS (well-known community)\n" |
| 9731 | "community number\n" |
| 9732 | "Do not send outside local AS (well-known community)\n" |
| 9733 | "Do not advertise to any peer (well-known community)\n" |
| 9734 | "Do not export to next AS (well-known community)\n" |
| 9735 | "community number\n" |
| 9736 | "Do not send outside local AS (well-known community)\n" |
| 9737 | "Do not advertise to any peer (well-known community)\n" |
| 9738 | "Do not export to next AS (well-known community)\n" |
| 9739 | "community number\n" |
| 9740 | "Do not send outside local AS (well-known community)\n" |
| 9741 | "Do not advertise to any peer (well-known community)\n" |
| 9742 | "Do not export to next AS (well-known community)\n" |
| 9743 | "Exact match of the communities") |
| 9744 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9745 | DEFUN (show_bgp_community, |
| 9746 | show_bgp_community_cmd, |
| 9747 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9748 | SHOW_STR |
| 9749 | BGP_STR |
| 9750 | "Display routes matching the communities\n" |
| 9751 | "community number\n" |
| 9752 | "Do not send outside local AS (well-known community)\n" |
| 9753 | "Do not advertise to any peer (well-known community)\n" |
| 9754 | "Do not export to next AS (well-known community)\n") |
| 9755 | { |
| 9756 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 9757 | } |
| 9758 | |
| 9759 | ALIAS (show_bgp_community, |
| 9760 | show_bgp_ipv6_community_cmd, |
| 9761 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 9762 | SHOW_STR |
| 9763 | BGP_STR |
| 9764 | "Address family\n" |
| 9765 | "Display routes matching the communities\n" |
| 9766 | "community number\n" |
| 9767 | "Do not send outside local AS (well-known community)\n" |
| 9768 | "Do not advertise to any peer (well-known community)\n" |
| 9769 | "Do not export to next AS (well-known community)\n") |
| 9770 | |
| 9771 | ALIAS (show_bgp_community, |
| 9772 | show_bgp_community2_cmd, |
| 9773 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9774 | SHOW_STR |
| 9775 | BGP_STR |
| 9776 | "Display routes matching the communities\n" |
| 9777 | "community number\n" |
| 9778 | "Do not send outside local AS (well-known community)\n" |
| 9779 | "Do not advertise to any peer (well-known community)\n" |
| 9780 | "Do not export to next AS (well-known community)\n" |
| 9781 | "community number\n" |
| 9782 | "Do not send outside local AS (well-known community)\n" |
| 9783 | "Do not advertise to any peer (well-known community)\n" |
| 9784 | "Do not export to next AS (well-known community)\n") |
| 9785 | |
| 9786 | ALIAS (show_bgp_community, |
| 9787 | show_bgp_ipv6_community2_cmd, |
| 9788 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9789 | SHOW_STR |
| 9790 | BGP_STR |
| 9791 | "Address family\n" |
| 9792 | "Display routes matching the communities\n" |
| 9793 | "community number\n" |
| 9794 | "Do not send outside local AS (well-known community)\n" |
| 9795 | "Do not advertise to any peer (well-known community)\n" |
| 9796 | "Do not export to next AS (well-known community)\n" |
| 9797 | "community number\n" |
| 9798 | "Do not send outside local AS (well-known community)\n" |
| 9799 | "Do not advertise to any peer (well-known community)\n" |
| 9800 | "Do not export to next AS (well-known community)\n") |
| 9801 | |
| 9802 | ALIAS (show_bgp_community, |
| 9803 | show_bgp_community3_cmd, |
| 9804 | "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)", |
| 9805 | SHOW_STR |
| 9806 | BGP_STR |
| 9807 | "Display routes matching the communities\n" |
| 9808 | "community number\n" |
| 9809 | "Do not send outside local AS (well-known community)\n" |
| 9810 | "Do not advertise to any peer (well-known community)\n" |
| 9811 | "Do not export to next AS (well-known community)\n" |
| 9812 | "community number\n" |
| 9813 | "Do not send outside local AS (well-known community)\n" |
| 9814 | "Do not advertise to any peer (well-known community)\n" |
| 9815 | "Do not export to next AS (well-known community)\n" |
| 9816 | "community number\n" |
| 9817 | "Do not send outside local AS (well-known community)\n" |
| 9818 | "Do not advertise to any peer (well-known community)\n" |
| 9819 | "Do not export to next AS (well-known community)\n") |
| 9820 | |
| 9821 | ALIAS (show_bgp_community, |
| 9822 | show_bgp_ipv6_community3_cmd, |
| 9823 | "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)", |
| 9824 | SHOW_STR |
| 9825 | BGP_STR |
| 9826 | "Address family\n" |
| 9827 | "Display routes matching the communities\n" |
| 9828 | "community number\n" |
| 9829 | "Do not send outside local AS (well-known community)\n" |
| 9830 | "Do not advertise to any peer (well-known community)\n" |
| 9831 | "Do not export to next AS (well-known community)\n" |
| 9832 | "community number\n" |
| 9833 | "Do not send outside local AS (well-known community)\n" |
| 9834 | "Do not advertise to any peer (well-known community)\n" |
| 9835 | "Do not export to next AS (well-known community)\n" |
| 9836 | "community number\n" |
| 9837 | "Do not send outside local AS (well-known community)\n" |
| 9838 | "Do not advertise to any peer (well-known community)\n" |
| 9839 | "Do not export to next AS (well-known community)\n") |
| 9840 | |
| 9841 | ALIAS (show_bgp_community, |
| 9842 | show_bgp_community4_cmd, |
| 9843 | "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)", |
| 9844 | SHOW_STR |
| 9845 | BGP_STR |
| 9846 | "Display routes matching the communities\n" |
| 9847 | "community number\n" |
| 9848 | "Do not send outside local AS (well-known community)\n" |
| 9849 | "Do not advertise to any peer (well-known community)\n" |
| 9850 | "Do not export to next AS (well-known community)\n" |
| 9851 | "community number\n" |
| 9852 | "Do not send outside local AS (well-known community)\n" |
| 9853 | "Do not advertise to any peer (well-known community)\n" |
| 9854 | "Do not export to next AS (well-known community)\n" |
| 9855 | "community number\n" |
| 9856 | "Do not send outside local AS (well-known community)\n" |
| 9857 | "Do not advertise to any peer (well-known community)\n" |
| 9858 | "Do not export to next AS (well-known community)\n" |
| 9859 | "community number\n" |
| 9860 | "Do not send outside local AS (well-known community)\n" |
| 9861 | "Do not advertise to any peer (well-known community)\n" |
| 9862 | "Do not export to next AS (well-known community)\n") |
| 9863 | |
| 9864 | ALIAS (show_bgp_community, |
| 9865 | show_bgp_ipv6_community4_cmd, |
| 9866 | "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)", |
| 9867 | SHOW_STR |
| 9868 | BGP_STR |
| 9869 | "Address family\n" |
| 9870 | "Display routes matching the communities\n" |
| 9871 | "community number\n" |
| 9872 | "Do not send outside local AS (well-known community)\n" |
| 9873 | "Do not advertise to any peer (well-known community)\n" |
| 9874 | "Do not export to next AS (well-known community)\n" |
| 9875 | "community number\n" |
| 9876 | "Do not send outside local AS (well-known community)\n" |
| 9877 | "Do not advertise to any peer (well-known community)\n" |
| 9878 | "Do not export to next AS (well-known community)\n" |
| 9879 | "community number\n" |
| 9880 | "Do not send outside local AS (well-known community)\n" |
| 9881 | "Do not advertise to any peer (well-known community)\n" |
| 9882 | "Do not export to next AS (well-known community)\n" |
| 9883 | "community number\n" |
| 9884 | "Do not send outside local AS (well-known community)\n" |
| 9885 | "Do not advertise to any peer (well-known community)\n" |
| 9886 | "Do not export to next AS (well-known community)\n") |
| 9887 | |
| 9888 | /* old command */ |
| 9889 | DEFUN (show_ipv6_bgp_community, |
| 9890 | show_ipv6_bgp_community_cmd, |
| 9891 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9892 | SHOW_STR |
| 9893 | IPV6_STR |
| 9894 | BGP_STR |
| 9895 | "Display routes matching the communities\n" |
| 9896 | "community number\n" |
| 9897 | "Do not send outside local AS (well-known community)\n" |
| 9898 | "Do not advertise to any peer (well-known community)\n" |
| 9899 | "Do not export to next AS (well-known community)\n") |
| 9900 | { |
| 9901 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 9902 | } |
| 9903 | |
| 9904 | /* old command */ |
| 9905 | ALIAS (show_ipv6_bgp_community, |
| 9906 | show_ipv6_bgp_community2_cmd, |
| 9907 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9908 | SHOW_STR |
| 9909 | IPV6_STR |
| 9910 | BGP_STR |
| 9911 | "Display routes matching the communities\n" |
| 9912 | "community number\n" |
| 9913 | "Do not send outside local AS (well-known community)\n" |
| 9914 | "Do not advertise to any peer (well-known community)\n" |
| 9915 | "Do not export to next AS (well-known community)\n" |
| 9916 | "community number\n" |
| 9917 | "Do not send outside local AS (well-known community)\n" |
| 9918 | "Do not advertise to any peer (well-known community)\n" |
| 9919 | "Do not export to next AS (well-known community)\n") |
| 9920 | |
| 9921 | /* old command */ |
| 9922 | ALIAS (show_ipv6_bgp_community, |
| 9923 | show_ipv6_bgp_community3_cmd, |
| 9924 | "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)", |
| 9925 | SHOW_STR |
| 9926 | IPV6_STR |
| 9927 | BGP_STR |
| 9928 | "Display routes matching the communities\n" |
| 9929 | "community number\n" |
| 9930 | "Do not send outside local AS (well-known community)\n" |
| 9931 | "Do not advertise to any peer (well-known community)\n" |
| 9932 | "Do not export to next AS (well-known community)\n" |
| 9933 | "community number\n" |
| 9934 | "Do not send outside local AS (well-known community)\n" |
| 9935 | "Do not advertise to any peer (well-known community)\n" |
| 9936 | "Do not export to next AS (well-known community)\n" |
| 9937 | "community number\n" |
| 9938 | "Do not send outside local AS (well-known community)\n" |
| 9939 | "Do not advertise to any peer (well-known community)\n" |
| 9940 | "Do not export to next AS (well-known community)\n") |
| 9941 | |
| 9942 | /* old command */ |
| 9943 | ALIAS (show_ipv6_bgp_community, |
| 9944 | show_ipv6_bgp_community4_cmd, |
| 9945 | "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)", |
| 9946 | SHOW_STR |
| 9947 | IPV6_STR |
| 9948 | BGP_STR |
| 9949 | "Display routes matching the communities\n" |
| 9950 | "community number\n" |
| 9951 | "Do not send outside local AS (well-known community)\n" |
| 9952 | "Do not advertise to any peer (well-known community)\n" |
| 9953 | "Do not export to next AS (well-known community)\n" |
| 9954 | "community number\n" |
| 9955 | "Do not send outside local AS (well-known community)\n" |
| 9956 | "Do not advertise to any peer (well-known community)\n" |
| 9957 | "Do not export to next AS (well-known community)\n" |
| 9958 | "community number\n" |
| 9959 | "Do not send outside local AS (well-known community)\n" |
| 9960 | "Do not advertise to any peer (well-known community)\n" |
| 9961 | "Do not export to next AS (well-known community)\n" |
| 9962 | "community number\n" |
| 9963 | "Do not send outside local AS (well-known community)\n" |
| 9964 | "Do not advertise to any peer (well-known community)\n" |
| 9965 | "Do not export to next AS (well-known community)\n") |
| 9966 | |
| 9967 | DEFUN (show_bgp_community_exact, |
| 9968 | show_bgp_community_exact_cmd, |
| 9969 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9970 | SHOW_STR |
| 9971 | BGP_STR |
| 9972 | "Display routes matching the communities\n" |
| 9973 | "community number\n" |
| 9974 | "Do not send outside local AS (well-known community)\n" |
| 9975 | "Do not advertise to any peer (well-known community)\n" |
| 9976 | "Do not export to next AS (well-known community)\n" |
| 9977 | "Exact match of the communities") |
| 9978 | { |
| 9979 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 9980 | } |
| 9981 | |
| 9982 | ALIAS (show_bgp_community_exact, |
| 9983 | show_bgp_ipv6_community_exact_cmd, |
| 9984 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9985 | SHOW_STR |
| 9986 | BGP_STR |
| 9987 | "Address family\n" |
| 9988 | "Display routes matching the communities\n" |
| 9989 | "community number\n" |
| 9990 | "Do not send outside local AS (well-known community)\n" |
| 9991 | "Do not advertise to any peer (well-known community)\n" |
| 9992 | "Do not export to next AS (well-known community)\n" |
| 9993 | "Exact match of the communities") |
| 9994 | |
| 9995 | ALIAS (show_bgp_community_exact, |
| 9996 | show_bgp_community2_exact_cmd, |
| 9997 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9998 | SHOW_STR |
| 9999 | BGP_STR |
| 10000 | "Display routes matching the communities\n" |
| 10001 | "community number\n" |
| 10002 | "Do not send outside local AS (well-known community)\n" |
| 10003 | "Do not advertise to any peer (well-known community)\n" |
| 10004 | "Do not export to next AS (well-known community)\n" |
| 10005 | "community number\n" |
| 10006 | "Do not send outside local AS (well-known community)\n" |
| 10007 | "Do not advertise to any peer (well-known community)\n" |
| 10008 | "Do not export to next AS (well-known community)\n" |
| 10009 | "Exact match of the communities") |
| 10010 | |
| 10011 | ALIAS (show_bgp_community_exact, |
| 10012 | show_bgp_ipv6_community2_exact_cmd, |
| 10013 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10014 | SHOW_STR |
| 10015 | BGP_STR |
| 10016 | "Address family\n" |
| 10017 | "Display routes matching the communities\n" |
| 10018 | "community number\n" |
| 10019 | "Do not send outside local AS (well-known community)\n" |
| 10020 | "Do not advertise to any peer (well-known community)\n" |
| 10021 | "Do not export to next AS (well-known community)\n" |
| 10022 | "community number\n" |
| 10023 | "Do not send outside local AS (well-known community)\n" |
| 10024 | "Do not advertise to any peer (well-known community)\n" |
| 10025 | "Do not export to next AS (well-known community)\n" |
| 10026 | "Exact match of the communities") |
| 10027 | |
| 10028 | ALIAS (show_bgp_community_exact, |
| 10029 | show_bgp_community3_exact_cmd, |
| 10030 | "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", |
| 10031 | SHOW_STR |
| 10032 | BGP_STR |
| 10033 | "Display routes matching the communities\n" |
| 10034 | "community number\n" |
| 10035 | "Do not send outside local AS (well-known community)\n" |
| 10036 | "Do not advertise to any peer (well-known community)\n" |
| 10037 | "Do not export to next AS (well-known community)\n" |
| 10038 | "community number\n" |
| 10039 | "Do not send outside local AS (well-known community)\n" |
| 10040 | "Do not advertise to any peer (well-known community)\n" |
| 10041 | "Do not export to next AS (well-known community)\n" |
| 10042 | "community number\n" |
| 10043 | "Do not send outside local AS (well-known community)\n" |
| 10044 | "Do not advertise to any peer (well-known community)\n" |
| 10045 | "Do not export to next AS (well-known community)\n" |
| 10046 | "Exact match of the communities") |
| 10047 | |
| 10048 | ALIAS (show_bgp_community_exact, |
| 10049 | show_bgp_ipv6_community3_exact_cmd, |
| 10050 | "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", |
| 10051 | SHOW_STR |
| 10052 | BGP_STR |
| 10053 | "Address family\n" |
| 10054 | "Display routes matching the communities\n" |
| 10055 | "community number\n" |
| 10056 | "Do not send outside local AS (well-known community)\n" |
| 10057 | "Do not advertise to any peer (well-known community)\n" |
| 10058 | "Do not export to next AS (well-known community)\n" |
| 10059 | "community number\n" |
| 10060 | "Do not send outside local AS (well-known community)\n" |
| 10061 | "Do not advertise to any peer (well-known community)\n" |
| 10062 | "Do not export to next AS (well-known community)\n" |
| 10063 | "community number\n" |
| 10064 | "Do not send outside local AS (well-known community)\n" |
| 10065 | "Do not advertise to any peer (well-known community)\n" |
| 10066 | "Do not export to next AS (well-known community)\n" |
| 10067 | "Exact match of the communities") |
| 10068 | |
| 10069 | ALIAS (show_bgp_community_exact, |
| 10070 | show_bgp_community4_exact_cmd, |
| 10071 | "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", |
| 10072 | SHOW_STR |
| 10073 | BGP_STR |
| 10074 | "Display routes matching the communities\n" |
| 10075 | "community number\n" |
| 10076 | "Do not send outside local AS (well-known community)\n" |
| 10077 | "Do not advertise to any peer (well-known community)\n" |
| 10078 | "Do not export to next AS (well-known community)\n" |
| 10079 | "community number\n" |
| 10080 | "Do not send outside local AS (well-known community)\n" |
| 10081 | "Do not advertise to any peer (well-known community)\n" |
| 10082 | "Do not export to next AS (well-known community)\n" |
| 10083 | "community number\n" |
| 10084 | "Do not send outside local AS (well-known community)\n" |
| 10085 | "Do not advertise to any peer (well-known community)\n" |
| 10086 | "Do not export to next AS (well-known community)\n" |
| 10087 | "community number\n" |
| 10088 | "Do not send outside local AS (well-known community)\n" |
| 10089 | "Do not advertise to any peer (well-known community)\n" |
| 10090 | "Do not export to next AS (well-known community)\n" |
| 10091 | "Exact match of the communities") |
| 10092 | |
| 10093 | ALIAS (show_bgp_community_exact, |
| 10094 | show_bgp_ipv6_community4_exact_cmd, |
| 10095 | "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", |
| 10096 | SHOW_STR |
| 10097 | BGP_STR |
| 10098 | "Address family\n" |
| 10099 | "Display routes matching the communities\n" |
| 10100 | "community number\n" |
| 10101 | "Do not send outside local AS (well-known community)\n" |
| 10102 | "Do not advertise to any peer (well-known community)\n" |
| 10103 | "Do not export to next AS (well-known community)\n" |
| 10104 | "community number\n" |
| 10105 | "Do not send outside local AS (well-known community)\n" |
| 10106 | "Do not advertise to any peer (well-known community)\n" |
| 10107 | "Do not export to next AS (well-known community)\n" |
| 10108 | "community number\n" |
| 10109 | "Do not send outside local AS (well-known community)\n" |
| 10110 | "Do not advertise to any peer (well-known community)\n" |
| 10111 | "Do not export to next AS (well-known community)\n" |
| 10112 | "community number\n" |
| 10113 | "Do not send outside local AS (well-known community)\n" |
| 10114 | "Do not advertise to any peer (well-known community)\n" |
| 10115 | "Do not export to next AS (well-known community)\n" |
| 10116 | "Exact match of the communities") |
| 10117 | |
| 10118 | /* old command */ |
| 10119 | DEFUN (show_ipv6_bgp_community_exact, |
| 10120 | show_ipv6_bgp_community_exact_cmd, |
| 10121 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10122 | SHOW_STR |
| 10123 | IPV6_STR |
| 10124 | BGP_STR |
| 10125 | "Display routes matching the communities\n" |
| 10126 | "community number\n" |
| 10127 | "Do not send outside local AS (well-known community)\n" |
| 10128 | "Do not advertise to any peer (well-known community)\n" |
| 10129 | "Do not export to next AS (well-known community)\n" |
| 10130 | "Exact match of the communities") |
| 10131 | { |
| 10132 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 10133 | } |
| 10134 | |
| 10135 | /* old command */ |
| 10136 | ALIAS (show_ipv6_bgp_community_exact, |
| 10137 | show_ipv6_bgp_community2_exact_cmd, |
| 10138 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10139 | SHOW_STR |
| 10140 | IPV6_STR |
| 10141 | BGP_STR |
| 10142 | "Display routes matching the communities\n" |
| 10143 | "community number\n" |
| 10144 | "Do not send outside local AS (well-known community)\n" |
| 10145 | "Do not advertise to any peer (well-known community)\n" |
| 10146 | "Do not export to next AS (well-known community)\n" |
| 10147 | "community number\n" |
| 10148 | "Do not send outside local AS (well-known community)\n" |
| 10149 | "Do not advertise to any peer (well-known community)\n" |
| 10150 | "Do not export to next AS (well-known community)\n" |
| 10151 | "Exact match of the communities") |
| 10152 | |
| 10153 | /* old command */ |
| 10154 | ALIAS (show_ipv6_bgp_community_exact, |
| 10155 | show_ipv6_bgp_community3_exact_cmd, |
| 10156 | "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", |
| 10157 | SHOW_STR |
| 10158 | IPV6_STR |
| 10159 | BGP_STR |
| 10160 | "Display routes matching the communities\n" |
| 10161 | "community number\n" |
| 10162 | "Do not send outside local AS (well-known community)\n" |
| 10163 | "Do not advertise to any peer (well-known community)\n" |
| 10164 | "Do not export to next AS (well-known community)\n" |
| 10165 | "community number\n" |
| 10166 | "Do not send outside local AS (well-known community)\n" |
| 10167 | "Do not advertise to any peer (well-known community)\n" |
| 10168 | "Do not export to next AS (well-known community)\n" |
| 10169 | "community number\n" |
| 10170 | "Do not send outside local AS (well-known community)\n" |
| 10171 | "Do not advertise to any peer (well-known community)\n" |
| 10172 | "Do not export to next AS (well-known community)\n" |
| 10173 | "Exact match of the communities") |
| 10174 | |
| 10175 | /* old command */ |
| 10176 | ALIAS (show_ipv6_bgp_community_exact, |
| 10177 | show_ipv6_bgp_community4_exact_cmd, |
| 10178 | "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", |
| 10179 | SHOW_STR |
| 10180 | IPV6_STR |
| 10181 | BGP_STR |
| 10182 | "Display routes matching the communities\n" |
| 10183 | "community number\n" |
| 10184 | "Do not send outside local AS (well-known community)\n" |
| 10185 | "Do not advertise to any peer (well-known community)\n" |
| 10186 | "Do not export to next AS (well-known community)\n" |
| 10187 | "community number\n" |
| 10188 | "Do not send outside local AS (well-known community)\n" |
| 10189 | "Do not advertise to any peer (well-known community)\n" |
| 10190 | "Do not export to next AS (well-known community)\n" |
| 10191 | "community number\n" |
| 10192 | "Do not send outside local AS (well-known community)\n" |
| 10193 | "Do not advertise to any peer (well-known community)\n" |
| 10194 | "Do not export to next AS (well-known community)\n" |
| 10195 | "community number\n" |
| 10196 | "Do not send outside local AS (well-known community)\n" |
| 10197 | "Do not advertise to any peer (well-known community)\n" |
| 10198 | "Do not export to next AS (well-known community)\n" |
| 10199 | "Exact match of the communities") |
| 10200 | |
| 10201 | /* old command */ |
| 10202 | DEFUN (show_ipv6_mbgp_community, |
| 10203 | show_ipv6_mbgp_community_cmd, |
| 10204 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 10205 | SHOW_STR |
| 10206 | IPV6_STR |
| 10207 | MBGP_STR |
| 10208 | "Display routes matching the communities\n" |
| 10209 | "community number\n" |
| 10210 | "Do not send outside local AS (well-known community)\n" |
| 10211 | "Do not advertise to any peer (well-known community)\n" |
| 10212 | "Do not export to next AS (well-known community)\n") |
| 10213 | { |
| 10214 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 10215 | } |
| 10216 | |
| 10217 | /* old command */ |
| 10218 | ALIAS (show_ipv6_mbgp_community, |
| 10219 | show_ipv6_mbgp_community2_cmd, |
| 10220 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 10221 | SHOW_STR |
| 10222 | IPV6_STR |
| 10223 | MBGP_STR |
| 10224 | "Display routes matching the communities\n" |
| 10225 | "community number\n" |
| 10226 | "Do not send outside local AS (well-known community)\n" |
| 10227 | "Do not advertise to any peer (well-known community)\n" |
| 10228 | "Do not export to next AS (well-known community)\n" |
| 10229 | "community number\n" |
| 10230 | "Do not send outside local AS (well-known community)\n" |
| 10231 | "Do not advertise to any peer (well-known community)\n" |
| 10232 | "Do not export to next AS (well-known community)\n") |
| 10233 | |
| 10234 | /* old command */ |
| 10235 | ALIAS (show_ipv6_mbgp_community, |
| 10236 | show_ipv6_mbgp_community3_cmd, |
| 10237 | "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)", |
| 10238 | SHOW_STR |
| 10239 | IPV6_STR |
| 10240 | MBGP_STR |
| 10241 | "Display routes matching the communities\n" |
| 10242 | "community number\n" |
| 10243 | "Do not send outside local AS (well-known community)\n" |
| 10244 | "Do not advertise to any peer (well-known community)\n" |
| 10245 | "Do not export to next AS (well-known community)\n" |
| 10246 | "community number\n" |
| 10247 | "Do not send outside local AS (well-known community)\n" |
| 10248 | "Do not advertise to any peer (well-known community)\n" |
| 10249 | "Do not export to next AS (well-known community)\n" |
| 10250 | "community number\n" |
| 10251 | "Do not send outside local AS (well-known community)\n" |
| 10252 | "Do not advertise to any peer (well-known community)\n" |
| 10253 | "Do not export to next AS (well-known community)\n") |
| 10254 | |
| 10255 | /* old command */ |
| 10256 | ALIAS (show_ipv6_mbgp_community, |
| 10257 | show_ipv6_mbgp_community4_cmd, |
| 10258 | "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)", |
| 10259 | SHOW_STR |
| 10260 | IPV6_STR |
| 10261 | MBGP_STR |
| 10262 | "Display routes matching the communities\n" |
| 10263 | "community number\n" |
| 10264 | "Do not send outside local AS (well-known community)\n" |
| 10265 | "Do not advertise to any peer (well-known community)\n" |
| 10266 | "Do not export to next AS (well-known community)\n" |
| 10267 | "community number\n" |
| 10268 | "Do not send outside local AS (well-known community)\n" |
| 10269 | "Do not advertise to any peer (well-known community)\n" |
| 10270 | "Do not export to next AS (well-known community)\n" |
| 10271 | "community number\n" |
| 10272 | "Do not send outside local AS (well-known community)\n" |
| 10273 | "Do not advertise to any peer (well-known community)\n" |
| 10274 | "Do not export to next AS (well-known community)\n" |
| 10275 | "community number\n" |
| 10276 | "Do not send outside local AS (well-known community)\n" |
| 10277 | "Do not advertise to any peer (well-known community)\n" |
| 10278 | "Do not export to next AS (well-known community)\n") |
| 10279 | |
| 10280 | /* old command */ |
| 10281 | DEFUN (show_ipv6_mbgp_community_exact, |
| 10282 | show_ipv6_mbgp_community_exact_cmd, |
| 10283 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10284 | SHOW_STR |
| 10285 | IPV6_STR |
| 10286 | MBGP_STR |
| 10287 | "Display routes matching the communities\n" |
| 10288 | "community number\n" |
| 10289 | "Do not send outside local AS (well-known community)\n" |
| 10290 | "Do not advertise to any peer (well-known community)\n" |
| 10291 | "Do not export to next AS (well-known community)\n" |
| 10292 | "Exact match of the communities") |
| 10293 | { |
| 10294 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 10295 | } |
| 10296 | |
| 10297 | /* old command */ |
| 10298 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10299 | show_ipv6_mbgp_community2_exact_cmd, |
| 10300 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10301 | SHOW_STR |
| 10302 | IPV6_STR |
| 10303 | MBGP_STR |
| 10304 | "Display routes matching the communities\n" |
| 10305 | "community number\n" |
| 10306 | "Do not send outside local AS (well-known community)\n" |
| 10307 | "Do not advertise to any peer (well-known community)\n" |
| 10308 | "Do not export to next AS (well-known community)\n" |
| 10309 | "community number\n" |
| 10310 | "Do not send outside local AS (well-known community)\n" |
| 10311 | "Do not advertise to any peer (well-known community)\n" |
| 10312 | "Do not export to next AS (well-known community)\n" |
| 10313 | "Exact match of the communities") |
| 10314 | |
| 10315 | /* old command */ |
| 10316 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10317 | show_ipv6_mbgp_community3_exact_cmd, |
| 10318 | "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", |
| 10319 | SHOW_STR |
| 10320 | IPV6_STR |
| 10321 | MBGP_STR |
| 10322 | "Display routes matching the communities\n" |
| 10323 | "community number\n" |
| 10324 | "Do not send outside local AS (well-known community)\n" |
| 10325 | "Do not advertise to any peer (well-known community)\n" |
| 10326 | "Do not export to next AS (well-known community)\n" |
| 10327 | "community number\n" |
| 10328 | "Do not send outside local AS (well-known community)\n" |
| 10329 | "Do not advertise to any peer (well-known community)\n" |
| 10330 | "Do not export to next AS (well-known community)\n" |
| 10331 | "community number\n" |
| 10332 | "Do not send outside local AS (well-known community)\n" |
| 10333 | "Do not advertise to any peer (well-known community)\n" |
| 10334 | "Do not export to next AS (well-known community)\n" |
| 10335 | "Exact match of the communities") |
| 10336 | |
| 10337 | /* old command */ |
| 10338 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10339 | show_ipv6_mbgp_community4_exact_cmd, |
| 10340 | "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", |
| 10341 | SHOW_STR |
| 10342 | IPV6_STR |
| 10343 | MBGP_STR |
| 10344 | "Display routes matching the communities\n" |
| 10345 | "community number\n" |
| 10346 | "Do not send outside local AS (well-known community)\n" |
| 10347 | "Do not advertise to any peer (well-known community)\n" |
| 10348 | "Do not export to next AS (well-known community)\n" |
| 10349 | "community number\n" |
| 10350 | "Do not send outside local AS (well-known community)\n" |
| 10351 | "Do not advertise to any peer (well-known community)\n" |
| 10352 | "Do not export to next AS (well-known community)\n" |
| 10353 | "community number\n" |
| 10354 | "Do not send outside local AS (well-known community)\n" |
| 10355 | "Do not advertise to any peer (well-known community)\n" |
| 10356 | "Do not export to next AS (well-known community)\n" |
| 10357 | "community number\n" |
| 10358 | "Do not send outside local AS (well-known community)\n" |
| 10359 | "Do not advertise to any peer (well-known community)\n" |
| 10360 | "Do not export to next AS (well-known community)\n" |
| 10361 | "Exact match of the communities") |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10362 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10363 | DEFUN (show_bgp_ipv4_community, |
| 10364 | show_bgp_ipv4_community_cmd, |
| 10365 | "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10366 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10367 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10368 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10369 | "Display routes matching the communities\n" |
| 10370 | "community number\n" |
| 10371 | "Do not send outside local AS (well-known community)\n" |
| 10372 | "Do not advertise to any peer (well-known community)\n" |
| 10373 | "Do not export to next AS (well-known community)\n") |
| 10374 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10375 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10376 | } |
| 10377 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10378 | ALIAS (show_bgp_ipv4_community, |
| 10379 | show_bgp_ipv4_community2_cmd, |
| 10380 | "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10381 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10382 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10383 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10384 | "Display routes matching the communities\n" |
| 10385 | "community number\n" |
| 10386 | "Do not send outside local AS (well-known community)\n" |
| 10387 | "Do not advertise to any peer (well-known community)\n" |
| 10388 | "Do not export to next AS (well-known community)\n" |
| 10389 | "community number\n" |
| 10390 | "Do not send outside local AS (well-known community)\n" |
| 10391 | "Do not advertise to any peer (well-known community)\n" |
| 10392 | "Do not export to next AS (well-known community)\n") |
| 10393 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10394 | ALIAS (show_bgp_ipv4_community, |
| 10395 | show_bgp_ipv4_community3_cmd, |
| 10396 | "show bgp ipv4 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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10397 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10398 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10399 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10400 | "Display routes matching the communities\n" |
| 10401 | "community number\n" |
| 10402 | "Do not send outside local AS (well-known community)\n" |
| 10403 | "Do not advertise to any peer (well-known community)\n" |
| 10404 | "Do not export to next AS (well-known community)\n" |
| 10405 | "community number\n" |
| 10406 | "Do not send outside local AS (well-known community)\n" |
| 10407 | "Do not advertise to any peer (well-known community)\n" |
| 10408 | "Do not export to next AS (well-known community)\n" |
| 10409 | "community number\n" |
| 10410 | "Do not send outside local AS (well-known community)\n" |
| 10411 | "Do not advertise to any peer (well-known community)\n" |
| 10412 | "Do not export to next AS (well-known community)\n") |
| 10413 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10414 | ALIAS (show_bgp_ipv4_community, |
| 10415 | show_bgp_ipv4_community4_cmd, |
| 10416 | "show bgp ipv4 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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10417 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10418 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10419 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10420 | "Display routes matching the communities\n" |
| 10421 | "community number\n" |
| 10422 | "Do not send outside local AS (well-known community)\n" |
| 10423 | "Do not advertise to any peer (well-known community)\n" |
| 10424 | "Do not export to next AS (well-known community)\n" |
| 10425 | "community number\n" |
| 10426 | "Do not send outside local AS (well-known community)\n" |
| 10427 | "Do not advertise to any peer (well-known community)\n" |
| 10428 | "Do not export to next AS (well-known community)\n" |
| 10429 | "community number\n" |
| 10430 | "Do not send outside local AS (well-known community)\n" |
| 10431 | "Do not advertise to any peer (well-known community)\n" |
| 10432 | "Do not export to next AS (well-known community)\n" |
| 10433 | "community number\n" |
| 10434 | "Do not send outside local AS (well-known community)\n" |
| 10435 | "Do not advertise to any peer (well-known community)\n" |
| 10436 | "Do not export to next AS (well-known community)\n") |
| 10437 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10438 | DEFUN (show_bgp_ipv4_safi_community, |
| 10439 | show_bgp_ipv4_safi_community_cmd, |
| 10440 | "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10441 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10442 | BGP_STR |
| 10443 | "Address family\n" |
| 10444 | "Address Family modifier\n" |
| 10445 | "Address Family modifier\n" |
| 10446 | "Display routes matching the communities\n" |
| 10447 | "community number\n" |
| 10448 | "Do not send outside local AS (well-known community)\n" |
| 10449 | "Do not advertise to any peer (well-known community)\n" |
| 10450 | "Do not export to next AS (well-known community)\n") |
| 10451 | { |
| 10452 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10453 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10454 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10455 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10456 | } |
| 10457 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10458 | ALIAS (show_bgp_ipv4_safi_community, |
| 10459 | show_bgp_ipv4_safi_community2_cmd, |
| 10460 | "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10461 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10462 | BGP_STR |
| 10463 | "Address family\n" |
| 10464 | "Address Family modifier\n" |
| 10465 | "Address Family modifier\n" |
| 10466 | "Display routes matching the communities\n" |
| 10467 | "community number\n" |
| 10468 | "Do not send outside local AS (well-known community)\n" |
| 10469 | "Do not advertise to any peer (well-known community)\n" |
| 10470 | "Do not export to next AS (well-known community)\n" |
| 10471 | "community number\n" |
| 10472 | "Do not send outside local AS (well-known community)\n" |
| 10473 | "Do not advertise to any peer (well-known community)\n" |
| 10474 | "Do not export to next AS (well-known community)\n") |
| 10475 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10476 | ALIAS (show_bgp_ipv4_safi_community, |
| 10477 | show_bgp_ipv4_safi_community3_cmd, |
| 10478 | "show 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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10479 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10480 | BGP_STR |
| 10481 | "Address family\n" |
| 10482 | "Address Family modifier\n" |
| 10483 | "Address Family modifier\n" |
| 10484 | "Display routes matching the communities\n" |
| 10485 | "community number\n" |
| 10486 | "Do not send outside local AS (well-known community)\n" |
| 10487 | "Do not advertise to any peer (well-known community)\n" |
| 10488 | "Do not export to next AS (well-known community)\n" |
| 10489 | "community number\n" |
| 10490 | "Do not send outside local AS (well-known community)\n" |
| 10491 | "Do not advertise to any peer (well-known community)\n" |
| 10492 | "Do not export to next AS (well-known community)\n" |
| 10493 | "community number\n" |
| 10494 | "Do not send outside local AS (well-known community)\n" |
| 10495 | "Do not advertise to any peer (well-known community)\n" |
| 10496 | "Do not export to next AS (well-known community)\n") |
| 10497 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10498 | ALIAS (show_bgp_ipv4_safi_community, |
| 10499 | show_bgp_ipv4_safi_community4_cmd, |
| 10500 | "show 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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10501 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10502 | BGP_STR |
| 10503 | "Address family\n" |
| 10504 | "Address Family modifier\n" |
| 10505 | "Address Family modifier\n" |
| 10506 | "Display routes matching the communities\n" |
| 10507 | "community number\n" |
| 10508 | "Do not send outside local AS (well-known community)\n" |
| 10509 | "Do not advertise to any peer (well-known community)\n" |
| 10510 | "Do not export to next AS (well-known community)\n" |
| 10511 | "community number\n" |
| 10512 | "Do not send outside local AS (well-known community)\n" |
| 10513 | "Do not advertise to any peer (well-known community)\n" |
| 10514 | "Do not export to next AS (well-known community)\n" |
| 10515 | "community number\n" |
| 10516 | "Do not send outside local AS (well-known community)\n" |
| 10517 | "Do not advertise to any peer (well-known community)\n" |
| 10518 | "Do not export to next AS (well-known community)\n" |
| 10519 | "community number\n" |
| 10520 | "Do not send outside local AS (well-known community)\n" |
| 10521 | "Do not advertise to any peer (well-known community)\n" |
| 10522 | "Do not export to next AS (well-known community)\n") |
| 10523 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10524 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 10525 | show_bgp_view_afi_safi_community_all_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10526 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10527 | SHOW_STR |
| 10528 | BGP_STR |
| 10529 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10530 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10531 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10532 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10533 | "Address Family modifier\n" |
| 10534 | "Address Family modifier\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10535 | "Display routes matching the communities\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10536 | { |
| 10537 | int afi; |
| 10538 | int safi; |
| 10539 | struct bgp *bgp; |
| 10540 | |
| 10541 | /* BGP structure lookup. */ |
| 10542 | bgp = bgp_lookup_by_name (argv[0]); |
| 10543 | if (bgp == NULL) |
| 10544 | { |
| 10545 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10546 | return CMD_WARNING; |
| 10547 | } |
| 10548 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10549 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10550 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10551 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 10552 | } |
| 10553 | |
| 10554 | DEFUN (show_bgp_view_afi_safi_community, |
| 10555 | show_bgp_view_afi_safi_community_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10556 | "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] | 10557 | SHOW_STR |
| 10558 | BGP_STR |
| 10559 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10560 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10561 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10562 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10563 | "Address family modifier\n" |
| 10564 | "Address family modifier\n" |
| 10565 | "Display routes matching the communities\n" |
| 10566 | "community number\n" |
| 10567 | "Do not send outside local AS (well-known community)\n" |
| 10568 | "Do not advertise to any peer (well-known community)\n" |
| 10569 | "Do not export to next AS (well-known community)\n") |
| 10570 | { |
| 10571 | int afi; |
| 10572 | int safi; |
| 10573 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10574 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10575 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10576 | 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] | 10577 | } |
| 10578 | |
| 10579 | ALIAS (show_bgp_view_afi_safi_community, |
| 10580 | show_bgp_view_afi_safi_community2_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10581 | "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] | 10582 | SHOW_STR |
| 10583 | BGP_STR |
| 10584 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10585 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10586 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10587 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10588 | "Address family modifier\n" |
| 10589 | "Address family modifier\n" |
| 10590 | "Display routes matching the communities\n" |
| 10591 | "community number\n" |
| 10592 | "Do not send outside local AS (well-known community)\n" |
| 10593 | "Do not advertise to any peer (well-known community)\n" |
| 10594 | "Do not export to next AS (well-known community)\n" |
| 10595 | "community number\n" |
| 10596 | "Do not send outside local AS (well-known community)\n" |
| 10597 | "Do not advertise to any peer (well-known community)\n" |
| 10598 | "Do not export to next AS (well-known community)\n") |
| 10599 | |
| 10600 | ALIAS (show_bgp_view_afi_safi_community, |
| 10601 | show_bgp_view_afi_safi_community3_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10602 | "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] | 10603 | SHOW_STR |
| 10604 | BGP_STR |
| 10605 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10606 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10607 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10608 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10609 | "Address family modifier\n" |
| 10610 | "Address family modifier\n" |
| 10611 | "Display routes matching the communities\n" |
| 10612 | "community number\n" |
| 10613 | "Do not send outside local AS (well-known community)\n" |
| 10614 | "Do not advertise to any peer (well-known community)\n" |
| 10615 | "Do not export to next AS (well-known community)\n" |
| 10616 | "community number\n" |
| 10617 | "Do not send outside local AS (well-known community)\n" |
| 10618 | "Do not advertise to any peer (well-known community)\n" |
| 10619 | "Do not export to next AS (well-known community)\n" |
| 10620 | "community number\n" |
| 10621 | "Do not send outside local AS (well-known community)\n" |
| 10622 | "Do not advertise to any peer (well-known community)\n" |
| 10623 | "Do not export to next AS (well-known community)\n") |
| 10624 | |
| 10625 | ALIAS (show_bgp_view_afi_safi_community, |
| 10626 | show_bgp_view_afi_safi_community4_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10627 | "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] | 10628 | SHOW_STR |
| 10629 | BGP_STR |
| 10630 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10631 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10632 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10633 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10634 | "Address family modifier\n" |
| 10635 | "Address family modifier\n" |
| 10636 | "Display routes matching the communities\n" |
| 10637 | "community number\n" |
| 10638 | "Do not send outside local AS (well-known community)\n" |
| 10639 | "Do not advertise to any peer (well-known community)\n" |
| 10640 | "Do not export to next AS (well-known community)\n" |
| 10641 | "community number\n" |
| 10642 | "Do not send outside local AS (well-known community)\n" |
| 10643 | "Do not advertise to any peer (well-known community)\n" |
| 10644 | "Do not export to next AS (well-known community)\n" |
| 10645 | "community number\n" |
| 10646 | "Do not send outside local AS (well-known community)\n" |
| 10647 | "Do not advertise to any peer (well-known community)\n" |
| 10648 | "Do not export to next AS (well-known community)\n" |
| 10649 | "community number\n" |
| 10650 | "Do not send outside local AS (well-known community)\n" |
| 10651 | "Do not advertise to any peer (well-known community)\n" |
| 10652 | "Do not export to next AS (well-known community)\n") |
| 10653 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10654 | DEFUN (show_bgp_ipv4_community_exact, |
| 10655 | show_bgp_ipv4_community_exact_cmd, |
| 10656 | "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10657 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10658 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10659 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10660 | "Display routes matching the communities\n" |
| 10661 | "community number\n" |
| 10662 | "Do not send outside local AS (well-known community)\n" |
| 10663 | "Do not advertise to any peer (well-known community)\n" |
| 10664 | "Do not export to next AS (well-known community)\n" |
| 10665 | "Exact match of the communities") |
| 10666 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10667 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10668 | } |
| 10669 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10670 | ALIAS (show_bgp_ipv4_community_exact, |
| 10671 | show_bgp_ipv4_community2_exact_cmd, |
| 10672 | "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10673 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10674 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10675 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10676 | "Display routes matching the communities\n" |
| 10677 | "community number\n" |
| 10678 | "Do not send outside local AS (well-known community)\n" |
| 10679 | "Do not advertise to any peer (well-known community)\n" |
| 10680 | "Do not export to next AS (well-known community)\n" |
| 10681 | "community number\n" |
| 10682 | "Do not send outside local AS (well-known community)\n" |
| 10683 | "Do not advertise to any peer (well-known community)\n" |
| 10684 | "Do not export to next AS (well-known community)\n" |
| 10685 | "Exact match of the communities") |
| 10686 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10687 | ALIAS (show_bgp_ipv4_community_exact, |
| 10688 | show_bgp_ipv4_community3_exact_cmd, |
| 10689 | "show bgp ipv4 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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10690 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10691 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10692 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10693 | "Display routes matching the communities\n" |
| 10694 | "community number\n" |
| 10695 | "Do not send outside local AS (well-known community)\n" |
| 10696 | "Do not advertise to any peer (well-known community)\n" |
| 10697 | "Do not export to next AS (well-known community)\n" |
| 10698 | "community number\n" |
| 10699 | "Do not send outside local AS (well-known community)\n" |
| 10700 | "Do not advertise to any peer (well-known community)\n" |
| 10701 | "Do not export to next AS (well-known community)\n" |
| 10702 | "community number\n" |
| 10703 | "Do not send outside local AS (well-known community)\n" |
| 10704 | "Do not advertise to any peer (well-known community)\n" |
| 10705 | "Do not export to next AS (well-known community)\n" |
| 10706 | "Exact match of the communities") |
| 10707 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10708 | ALIAS (show_bgp_ipv4_community_exact, |
| 10709 | show_bgp_ipv4_community4_exact_cmd, |
| 10710 | "show bgp ipv4 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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10711 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10712 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10713 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10714 | "Display routes matching the communities\n" |
| 10715 | "community number\n" |
| 10716 | "Do not send outside local AS (well-known community)\n" |
| 10717 | "Do not advertise to any peer (well-known community)\n" |
| 10718 | "Do not export to next AS (well-known community)\n" |
| 10719 | "community number\n" |
| 10720 | "Do not send outside local AS (well-known community)\n" |
| 10721 | "Do not advertise to any peer (well-known community)\n" |
| 10722 | "Do not export to next AS (well-known community)\n" |
| 10723 | "community number\n" |
| 10724 | "Do not send outside local AS (well-known community)\n" |
| 10725 | "Do not advertise to any peer (well-known community)\n" |
| 10726 | "Do not export to next AS (well-known community)\n" |
| 10727 | "community number\n" |
| 10728 | "Do not send outside local AS (well-known community)\n" |
| 10729 | "Do not advertise to any peer (well-known community)\n" |
| 10730 | "Do not export to next AS (well-known community)\n" |
| 10731 | "Exact match of the communities") |
| 10732 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10733 | DEFUN (show_bgp_ipv4_safi_community4_exact, |
| 10734 | show_bgp_ipv4_safi_community_exact_cmd, |
| 10735 | "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10736 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10737 | BGP_STR |
| 10738 | "Address family\n" |
| 10739 | "Address Family modifier\n" |
| 10740 | "Address Family modifier\n" |
| 10741 | "Display routes matching the communities\n" |
| 10742 | "community number\n" |
| 10743 | "Do not send outside local AS (well-known community)\n" |
| 10744 | "Do not advertise to any peer (well-known community)\n" |
| 10745 | "Do not export to next AS (well-known community)\n" |
| 10746 | "Exact match of the communities") |
| 10747 | { |
| 10748 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10749 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10750 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10751 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10752 | } |
| 10753 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10754 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10755 | show_bgp_ipv4_safi_community2_exact_cmd, |
| 10756 | "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10757 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10758 | BGP_STR |
| 10759 | "Address family\n" |
| 10760 | "Address Family modifier\n" |
| 10761 | "Address Family modifier\n" |
| 10762 | "Display routes matching the communities\n" |
| 10763 | "community number\n" |
| 10764 | "Do not send outside local AS (well-known community)\n" |
| 10765 | "Do not advertise to any peer (well-known community)\n" |
| 10766 | "Do not export to next AS (well-known community)\n" |
| 10767 | "community number\n" |
| 10768 | "Do not send outside local AS (well-known community)\n" |
| 10769 | "Do not advertise to any peer (well-known community)\n" |
| 10770 | "Do not export to next AS (well-known community)\n" |
| 10771 | "Exact match of the communities") |
| 10772 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10773 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10774 | show_bgp_ipv4_safi_community3_exact_cmd, |
| 10775 | "show 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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10776 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10777 | BGP_STR |
| 10778 | "Address family\n" |
| 10779 | "Address Family modifier\n" |
| 10780 | "Address Family modifier\n" |
| 10781 | "Display routes matching the communities\n" |
| 10782 | "community number\n" |
| 10783 | "Do not send outside local AS (well-known community)\n" |
| 10784 | "Do not advertise to any peer (well-known community)\n" |
| 10785 | "Do not export to next AS (well-known community)\n" |
| 10786 | "community number\n" |
| 10787 | "Do not send outside local AS (well-known community)\n" |
| 10788 | "Do not advertise to any peer (well-known community)\n" |
| 10789 | "Do not export to next AS (well-known community)\n" |
| 10790 | "community number\n" |
| 10791 | "Do not send outside local AS (well-known community)\n" |
| 10792 | "Do not advertise to any peer (well-known community)\n" |
| 10793 | "Do not export to next AS (well-known community)\n" |
| 10794 | "Exact match of the communities") |
| 10795 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10796 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10797 | show_bgp_ipv4_safi_community4_exact_cmd, |
| 10798 | "show 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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10799 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10800 | BGP_STR |
| 10801 | "Address family\n" |
| 10802 | "Address Family modifier\n" |
| 10803 | "Address Family modifier\n" |
| 10804 | "Display routes matching the communities\n" |
| 10805 | "community number\n" |
| 10806 | "Do not send outside local AS (well-known community)\n" |
| 10807 | "Do not advertise to any peer (well-known community)\n" |
| 10808 | "Do not export to next AS (well-known community)\n" |
| 10809 | "community number\n" |
| 10810 | "Do not send outside local AS (well-known community)\n" |
| 10811 | "Do not advertise to any peer (well-known community)\n" |
| 10812 | "Do not export to next AS (well-known community)\n" |
| 10813 | "community number\n" |
| 10814 | "Do not send outside local AS (well-known community)\n" |
| 10815 | "Do not advertise to any peer (well-known community)\n" |
| 10816 | "Do not export to next AS (well-known community)\n" |
| 10817 | "community number\n" |
| 10818 | "Do not send outside local AS (well-known community)\n" |
| 10819 | "Do not advertise to any peer (well-known community)\n" |
| 10820 | "Do not export to next AS (well-known community)\n" |
| 10821 | "Exact match of the communities") |
| 10822 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10823 | DEFUN (show_bgp_ipv6_safi_community, |
| 10824 | show_bgp_ipv6_safi_community_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10825 | "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10826 | SHOW_STR |
| 10827 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10828 | "Address family\n" |
| 10829 | "Address family modifier\n" |
| 10830 | "Address family modifier\n" |
| 10831 | "Address family modifier\n" |
| 10832 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10833 | "Display routes matching the communities\n" |
| 10834 | "community number\n" |
| 10835 | "Do not send outside local AS (well-known community)\n" |
| 10836 | "Do not advertise to any peer (well-known community)\n" |
| 10837 | "Do not export to next AS (well-known community)\n") |
| 10838 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10839 | safi_t safi; |
| 10840 | |
| 10841 | if (bgp_parse_safi(argv[0], &safi)) { |
| 10842 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 10843 | return CMD_WARNING; |
| 10844 | } |
| 10845 | return bgp_show_community (vty, NULL, argc-1, argv+1, 0, AFI_IP6, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10846 | } |
| 10847 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10848 | ALIAS (show_bgp_ipv6_safi_community, |
| 10849 | show_bgp_ipv6_safi_community2_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10850 | "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10851 | SHOW_STR |
| 10852 | BGP_STR |
| 10853 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10854 | "Address family modifier\n" |
| 10855 | "Address family modifier\n" |
| 10856 | "Address family modifier\n" |
| 10857 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10858 | "Display routes matching the communities\n" |
| 10859 | "community number\n" |
| 10860 | "Do not send outside local AS (well-known community)\n" |
| 10861 | "Do not advertise to any peer (well-known community)\n" |
| 10862 | "Do not export to next AS (well-known community)\n" |
| 10863 | "community number\n" |
| 10864 | "Do not send outside local AS (well-known community)\n" |
| 10865 | "Do not advertise to any peer (well-known community)\n" |
| 10866 | "Do not export to next AS (well-known community)\n") |
| 10867 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10868 | ALIAS (show_bgp_ipv6_safi_community, |
| 10869 | show_bgp_ipv6_safi_community3_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10870 | "show bgp ipv6 (encap|multicast|unicast|vpn) 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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10871 | SHOW_STR |
| 10872 | BGP_STR |
| 10873 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10874 | "Address family modifier\n" |
| 10875 | "Address family modifier\n" |
| 10876 | "Address family modifier\n" |
| 10877 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10878 | "Display routes matching the communities\n" |
| 10879 | "community number\n" |
| 10880 | "Do not send outside local AS (well-known community)\n" |
| 10881 | "Do not advertise to any peer (well-known community)\n" |
| 10882 | "Do not export to next AS (well-known community)\n" |
| 10883 | "community number\n" |
| 10884 | "Do not send outside local AS (well-known community)\n" |
| 10885 | "Do not advertise to any peer (well-known community)\n" |
| 10886 | "Do not export to next AS (well-known community)\n" |
| 10887 | "community number\n" |
| 10888 | "Do not send outside local AS (well-known community)\n" |
| 10889 | "Do not advertise to any peer (well-known community)\n" |
| 10890 | "Do not export to next AS (well-known community)\n") |
| 10891 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10892 | ALIAS (show_bgp_ipv6_safi_community, |
| 10893 | show_bgp_ipv6_safi_community4_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10894 | "show bgp ipv6 (encap|multicast|unicast|vpn) 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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10895 | SHOW_STR |
| 10896 | BGP_STR |
| 10897 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10898 | "Address family modifier\n" |
| 10899 | "Address family modifier\n" |
| 10900 | "Address family modifier\n" |
| 10901 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10902 | "Display routes matching the communities\n" |
| 10903 | "community number\n" |
| 10904 | "Do not send outside local AS (well-known community)\n" |
| 10905 | "Do not advertise to any peer (well-known community)\n" |
| 10906 | "Do not export to next AS (well-known community)\n" |
| 10907 | "community number\n" |
| 10908 | "Do not send outside local AS (well-known community)\n" |
| 10909 | "Do not advertise to any peer (well-known community)\n" |
| 10910 | "Do not export to next AS (well-known community)\n" |
| 10911 | "community number\n" |
| 10912 | "Do not send outside local AS (well-known community)\n" |
| 10913 | "Do not advertise to any peer (well-known community)\n" |
| 10914 | "Do not export to next AS (well-known community)\n" |
| 10915 | "community number\n" |
| 10916 | "Do not send outside local AS (well-known community)\n" |
| 10917 | "Do not advertise to any peer (well-known community)\n" |
| 10918 | "Do not export to next AS (well-known community)\n") |
| 10919 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10920 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10921 | DEFUN (show_bgp_ipv6_safi_community_exact, |
| 10922 | show_bgp_ipv6_safi_community_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10923 | "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10924 | SHOW_STR |
| 10925 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10926 | "Address family\n" |
| 10927 | "Address family modifier\n" |
| 10928 | "Address family modifier\n" |
| 10929 | "Address family modifier\n" |
| 10930 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10931 | "Display routes matching the communities\n" |
| 10932 | "community number\n" |
| 10933 | "Do not send outside local AS (well-known community)\n" |
| 10934 | "Do not advertise to any peer (well-known community)\n" |
| 10935 | "Do not export to next AS (well-known community)\n" |
| 10936 | "Exact match of the communities") |
| 10937 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10938 | safi_t safi; |
| 10939 | |
| 10940 | if (bgp_parse_safi(argv[0], &safi)) { |
| 10941 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 10942 | return CMD_WARNING; |
| 10943 | } |
| 10944 | return bgp_show_community (vty, NULL, argc-1, argv+1, 1, AFI_IP6, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10945 | } |
| 10946 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10947 | |
| 10948 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10949 | show_bgp_ipv6_safi_community2_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10950 | "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10951 | SHOW_STR |
| 10952 | BGP_STR |
| 10953 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10954 | "Address family modifier\n" |
| 10955 | "Address family modifier\n" |
| 10956 | "Address family modifier\n" |
| 10957 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10958 | "Display routes matching the communities\n" |
| 10959 | "community number\n" |
| 10960 | "Do not send outside local AS (well-known community)\n" |
| 10961 | "Do not advertise to any peer (well-known community)\n" |
| 10962 | "Do not export to next AS (well-known community)\n" |
| 10963 | "community number\n" |
| 10964 | "Do not send outside local AS (well-known community)\n" |
| 10965 | "Do not advertise to any peer (well-known community)\n" |
| 10966 | "Do not export to next AS (well-known community)\n" |
| 10967 | "Exact match of the communities") |
| 10968 | |
| 10969 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10970 | show_bgp_ipv6_safi_community3_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10971 | "show bgp ipv6 (encap|multicast|unicast|vpn) 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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10972 | SHOW_STR |
| 10973 | BGP_STR |
| 10974 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10975 | "Address family modifier\n" |
| 10976 | "Address family modifier\n" |
| 10977 | "Address family modifier\n" |
| 10978 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10979 | "Display routes matching the communities\n" |
| 10980 | "community number\n" |
| 10981 | "Do not send outside local AS (well-known community)\n" |
| 10982 | "Do not advertise to any peer (well-known community)\n" |
| 10983 | "Do not export to next AS (well-known community)\n" |
| 10984 | "community number\n" |
| 10985 | "Do not send outside local AS (well-known community)\n" |
| 10986 | "Do not advertise to any peer (well-known community)\n" |
| 10987 | "Do not export to next AS (well-known community)\n" |
| 10988 | "community number\n" |
| 10989 | "Do not send outside local AS (well-known community)\n" |
| 10990 | "Do not advertise to any peer (well-known community)\n" |
| 10991 | "Do not export to next AS (well-known community)\n" |
| 10992 | "Exact match of the communities") |
| 10993 | |
| 10994 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10995 | show_bgp_ipv6_safi_community4_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10996 | "show bgp ipv6 (encap|multicast|unicast|vpn) 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", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10997 | SHOW_STR |
| 10998 | BGP_STR |
| 10999 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11000 | "Address family modifier\n" |
| 11001 | "Address family modifier\n" |
| 11002 | "Address family modifier\n" |
| 11003 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11004 | "Display routes matching the communities\n" |
| 11005 | "community number\n" |
| 11006 | "Do not send outside local AS (well-known community)\n" |
| 11007 | "Do not advertise to any peer (well-known community)\n" |
| 11008 | "Do not export to next AS (well-known community)\n" |
| 11009 | "community number\n" |
| 11010 | "Do not send outside local AS (well-known community)\n" |
| 11011 | "Do not advertise to any peer (well-known community)\n" |
| 11012 | "Do not export to next AS (well-known community)\n" |
| 11013 | "community number\n" |
| 11014 | "Do not send outside local AS (well-known community)\n" |
| 11015 | "Do not advertise to any peer (well-known community)\n" |
| 11016 | "Do not export to next AS (well-known community)\n" |
| 11017 | "community number\n" |
| 11018 | "Do not send outside local AS (well-known community)\n" |
| 11019 | "Do not advertise to any peer (well-known community)\n" |
| 11020 | "Do not export to next AS (well-known community)\n" |
| 11021 | "Exact match of the communities") |
| 11022 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11023 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11024 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 11025 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11026 | { |
| 11027 | struct community_list *list; |
| 11028 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11029 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11030 | if (list == NULL) |
| 11031 | { |
| 11032 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 11033 | VTY_NEWLINE); |
| 11034 | return CMD_WARNING; |
| 11035 | } |
| 11036 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11037 | return bgp_show (vty, NULL, afi, safi, |
| 11038 | (exact ? bgp_show_type_community_list_exact : |
| 11039 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11040 | } |
| 11041 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11042 | DEFUN (show_ip_bgp_community_list, |
| 11043 | show_ip_bgp_community_list_cmd, |
| 11044 | "show ip bgp community-list (<1-500>|WORD)", |
| 11045 | SHOW_STR |
| 11046 | IP_STR |
| 11047 | BGP_STR |
| 11048 | "Display routes matching the community-list\n" |
| 11049 | "community-list number\n" |
| 11050 | "community-list name\n") |
| 11051 | { |
| 11052 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 11053 | } |
| 11054 | |
| 11055 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 11056 | show_ip_bgp_ipv4_community_list_cmd, |
| 11057 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
| 11058 | SHOW_STR |
| 11059 | IP_STR |
| 11060 | BGP_STR |
| 11061 | "Address family\n" |
| 11062 | "Address Family modifier\n" |
| 11063 | "Address Family modifier\n" |
| 11064 | "Display routes matching the community-list\n" |
| 11065 | "community-list number\n" |
| 11066 | "community-list name\n") |
| 11067 | { |
| 11068 | if (strncmp (argv[0], "m", 1) == 0) |
| 11069 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 11070 | |
| 11071 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 11072 | } |
| 11073 | |
| 11074 | DEFUN (show_ip_bgp_community_list_exact, |
| 11075 | show_ip_bgp_community_list_exact_cmd, |
| 11076 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
| 11077 | SHOW_STR |
| 11078 | IP_STR |
| 11079 | BGP_STR |
| 11080 | "Display routes matching the community-list\n" |
| 11081 | "community-list number\n" |
| 11082 | "community-list name\n" |
| 11083 | "Exact match of the communities\n") |
| 11084 | { |
| 11085 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 11086 | } |
| 11087 | |
| 11088 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 11089 | show_ip_bgp_ipv4_community_list_exact_cmd, |
| 11090 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
| 11091 | SHOW_STR |
| 11092 | IP_STR |
| 11093 | BGP_STR |
| 11094 | "Address family\n" |
| 11095 | "Address Family modifier\n" |
| 11096 | "Address Family modifier\n" |
| 11097 | "Display routes matching the community-list\n" |
| 11098 | "community-list number\n" |
| 11099 | "community-list name\n" |
| 11100 | "Exact match of the communities\n") |
| 11101 | { |
| 11102 | if (strncmp (argv[0], "m", 1) == 0) |
| 11103 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 11104 | |
| 11105 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 11106 | } |
| 11107 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11108 | DEFUN (show_bgp_community_list, |
| 11109 | show_bgp_community_list_cmd, |
| 11110 | "show bgp community-list (<1-500>|WORD)", |
| 11111 | SHOW_STR |
| 11112 | BGP_STR |
| 11113 | "Display routes matching the community-list\n" |
| 11114 | "community-list number\n" |
| 11115 | "community-list name\n") |
| 11116 | { |
| 11117 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 11118 | } |
| 11119 | |
| 11120 | ALIAS (show_bgp_community_list, |
| 11121 | show_bgp_ipv6_community_list_cmd, |
| 11122 | "show bgp ipv6 community-list (<1-500>|WORD)", |
| 11123 | SHOW_STR |
| 11124 | BGP_STR |
| 11125 | "Address family\n" |
| 11126 | "Display routes matching the community-list\n" |
| 11127 | "community-list number\n" |
| 11128 | "community-list name\n") |
| 11129 | |
| 11130 | /* old command */ |
| 11131 | DEFUN (show_ipv6_bgp_community_list, |
| 11132 | show_ipv6_bgp_community_list_cmd, |
| 11133 | "show ipv6 bgp community-list WORD", |
| 11134 | SHOW_STR |
| 11135 | IPV6_STR |
| 11136 | BGP_STR |
| 11137 | "Display routes matching the community-list\n" |
| 11138 | "community-list name\n") |
| 11139 | { |
| 11140 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 11141 | } |
| 11142 | |
| 11143 | /* old command */ |
| 11144 | DEFUN (show_ipv6_mbgp_community_list, |
| 11145 | show_ipv6_mbgp_community_list_cmd, |
| 11146 | "show ipv6 mbgp community-list WORD", |
| 11147 | SHOW_STR |
| 11148 | IPV6_STR |
| 11149 | MBGP_STR |
| 11150 | "Display routes matching the community-list\n" |
| 11151 | "community-list name\n") |
| 11152 | { |
| 11153 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 11154 | } |
| 11155 | |
| 11156 | DEFUN (show_bgp_community_list_exact, |
| 11157 | show_bgp_community_list_exact_cmd, |
| 11158 | "show bgp community-list (<1-500>|WORD) exact-match", |
| 11159 | SHOW_STR |
| 11160 | BGP_STR |
| 11161 | "Display routes matching the community-list\n" |
| 11162 | "community-list number\n" |
| 11163 | "community-list name\n" |
| 11164 | "Exact match of the communities\n") |
| 11165 | { |
| 11166 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 11167 | } |
| 11168 | |
| 11169 | ALIAS (show_bgp_community_list_exact, |
| 11170 | show_bgp_ipv6_community_list_exact_cmd, |
| 11171 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
| 11172 | SHOW_STR |
| 11173 | BGP_STR |
| 11174 | "Address family\n" |
| 11175 | "Display routes matching the community-list\n" |
| 11176 | "community-list number\n" |
| 11177 | "community-list name\n" |
| 11178 | "Exact match of the communities\n") |
| 11179 | |
| 11180 | /* old command */ |
| 11181 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 11182 | show_ipv6_bgp_community_list_exact_cmd, |
| 11183 | "show ipv6 bgp community-list WORD exact-match", |
| 11184 | SHOW_STR |
| 11185 | IPV6_STR |
| 11186 | BGP_STR |
| 11187 | "Display routes matching the community-list\n" |
| 11188 | "community-list name\n" |
| 11189 | "Exact match of the communities\n") |
| 11190 | { |
| 11191 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 11192 | } |
| 11193 | |
| 11194 | /* old command */ |
| 11195 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 11196 | show_ipv6_mbgp_community_list_exact_cmd, |
| 11197 | "show ipv6 mbgp community-list WORD exact-match", |
| 11198 | SHOW_STR |
| 11199 | IPV6_STR |
| 11200 | MBGP_STR |
| 11201 | "Display routes matching the community-list\n" |
| 11202 | "community-list name\n" |
| 11203 | "Exact match of the communities\n") |
| 11204 | { |
| 11205 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 11206 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11207 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11208 | DEFUN (show_bgp_ipv4_community_list, |
| 11209 | show_bgp_ipv4_community_list_cmd, |
| 11210 | "show bgp ipv4 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11211 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11212 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11213 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11214 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11215 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11216 | "community-list name\n") |
| 11217 | { |
| 11218 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 11219 | } |
| 11220 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11221 | DEFUN (show_bgp_ipv4_safi_community_list, |
| 11222 | show_bgp_ipv4_safi_community_list_cmd, |
| 11223 | "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11224 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11225 | BGP_STR |
| 11226 | "Address family\n" |
| 11227 | "Address Family modifier\n" |
| 11228 | "Address Family modifier\n" |
| 11229 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11230 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11231 | "community-list name\n") |
| 11232 | { |
| 11233 | if (strncmp (argv[0], "m", 1) == 0) |
| 11234 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 11235 | |
| 11236 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 11237 | } |
| 11238 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11239 | DEFUN (show_bgp_ipv4_community_list_exact, |
| 11240 | show_bgp_ipv4_community_list_exact_cmd, |
| 11241 | "show bgp ipv4 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11242 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11243 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11244 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11245 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11246 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11247 | "community-list name\n" |
| 11248 | "Exact match of the communities\n") |
| 11249 | { |
| 11250 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 11251 | } |
| 11252 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11253 | DEFUN (show_bgp_ipv4_safi_community_list_exact, |
| 11254 | show_bgp_ipv4_safi_community_list_exact_cmd, |
| 11255 | "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11256 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11257 | BGP_STR |
| 11258 | "Address family\n" |
| 11259 | "Address Family modifier\n" |
| 11260 | "Address Family modifier\n" |
| 11261 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11262 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11263 | "community-list name\n" |
| 11264 | "Exact match of the communities\n") |
| 11265 | { |
| 11266 | if (strncmp (argv[0], "m", 1) == 0) |
| 11267 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 11268 | |
| 11269 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 11270 | } |
| 11271 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11272 | DEFUN (show_bgp_ipv6_safi_community_list, |
| 11273 | show_bgp_ipv6_safi_community_list_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11274 | "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11275 | SHOW_STR |
| 11276 | BGP_STR |
| 11277 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11278 | "Address family modifier\n" |
| 11279 | "Address family modifier\n" |
| 11280 | "Address family modifier\n" |
| 11281 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11282 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11283 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 11284 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11285 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11286 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11287 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11288 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11289 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11290 | return CMD_WARNING; |
| 11291 | } |
| 11292 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11293 | } |
| 11294 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11295 | DEFUN (show_bgp_ipv6_safi_community_list_exact, |
| 11296 | show_bgp_ipv6_safi_community_list_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11297 | "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11298 | SHOW_STR |
| 11299 | BGP_STR |
| 11300 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11301 | "Address family modifier\n" |
| 11302 | "Address family modifier\n" |
| 11303 | "Address family modifier\n" |
| 11304 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11305 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11306 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11307 | "community-list name\n" |
| 11308 | "Exact match of the communities\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11309 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11310 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11311 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11312 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11313 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11314 | return CMD_WARNING; |
| 11315 | } |
| 11316 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11317 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11318 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11319 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11320 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11321 | safi_t safi, enum bgp_show_type type) |
| 11322 | { |
| 11323 | int ret; |
| 11324 | struct prefix *p; |
| 11325 | |
| 11326 | p = prefix_new(); |
| 11327 | |
| 11328 | ret = str2prefix (prefix, p); |
| 11329 | if (! ret) |
| 11330 | { |
| 11331 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 11332 | return CMD_WARNING; |
| 11333 | } |
| 11334 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11335 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 11336 | prefix_free(p); |
| 11337 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11338 | } |
| 11339 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11340 | DEFUN (show_ip_bgp_prefix_longer, |
| 11341 | show_ip_bgp_prefix_longer_cmd, |
| 11342 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 11343 | SHOW_STR |
| 11344 | IP_STR |
| 11345 | BGP_STR |
| 11346 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11347 | "Display route and more specific routes\n") |
| 11348 | { |
| 11349 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11350 | bgp_show_type_prefix_longer); |
| 11351 | } |
| 11352 | |
| 11353 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 11354 | show_ip_bgp_flap_prefix_longer_cmd, |
| 11355 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 11356 | SHOW_STR |
| 11357 | IP_STR |
| 11358 | BGP_STR |
| 11359 | "Display flap statistics of routes\n" |
| 11360 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11361 | "Display route and more specific routes\n") |
| 11362 | { |
| 11363 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11364 | bgp_show_type_flap_prefix_longer); |
| 11365 | } |
| 11366 | |
| 11367 | ALIAS (show_ip_bgp_flap_prefix_longer, |
| 11368 | show_ip_bgp_damp_flap_prefix_longer_cmd, |
| 11369 | "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes", |
| 11370 | SHOW_STR |
| 11371 | IP_STR |
| 11372 | BGP_STR |
| 11373 | "Display detailed information about dampening\n" |
| 11374 | "Display flap statistics of routes\n" |
| 11375 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11376 | "Display route and more specific routes\n") |
| 11377 | |
| 11378 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 11379 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 11380 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 11381 | SHOW_STR |
| 11382 | IP_STR |
| 11383 | BGP_STR |
| 11384 | "Address family\n" |
| 11385 | "Address Family modifier\n" |
| 11386 | "Address Family modifier\n" |
| 11387 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11388 | "Display route and more specific routes\n") |
| 11389 | { |
| 11390 | if (strncmp (argv[0], "m", 1) == 0) |
| 11391 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 11392 | bgp_show_type_prefix_longer); |
| 11393 | |
| 11394 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 11395 | bgp_show_type_prefix_longer); |
| 11396 | } |
| 11397 | |
| 11398 | DEFUN (show_ip_bgp_flap_address, |
| 11399 | show_ip_bgp_flap_address_cmd, |
| 11400 | "show ip bgp flap-statistics A.B.C.D", |
| 11401 | SHOW_STR |
| 11402 | IP_STR |
| 11403 | BGP_STR |
| 11404 | "Display flap statistics of routes\n" |
| 11405 | "Network in the BGP routing table to display\n") |
| 11406 | { |
| 11407 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11408 | bgp_show_type_flap_address); |
| 11409 | } |
| 11410 | |
| 11411 | ALIAS (show_ip_bgp_flap_address, |
| 11412 | show_ip_bgp_damp_flap_address_cmd, |
| 11413 | "show ip bgp dampening flap-statistics A.B.C.D", |
| 11414 | SHOW_STR |
| 11415 | IP_STR |
| 11416 | BGP_STR |
| 11417 | "Display detailed information about dampening\n" |
| 11418 | "Display flap statistics of routes\n" |
| 11419 | "Network in the BGP routing table to display\n") |
| 11420 | |
| 11421 | DEFUN (show_ip_bgp_flap_prefix, |
| 11422 | show_ip_bgp_flap_prefix_cmd, |
| 11423 | "show ip bgp flap-statistics A.B.C.D/M", |
| 11424 | SHOW_STR |
| 11425 | IP_STR |
| 11426 | BGP_STR |
| 11427 | "Display flap statistics of routes\n" |
| 11428 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11429 | { |
| 11430 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11431 | bgp_show_type_flap_prefix); |
| 11432 | } |
| 11433 | |
| 11434 | ALIAS (show_ip_bgp_flap_prefix, |
| 11435 | show_ip_bgp_damp_flap_prefix_cmd, |
| 11436 | "show ip bgp dampening flap-statistics A.B.C.D/M", |
| 11437 | SHOW_STR |
| 11438 | IP_STR |
| 11439 | BGP_STR |
| 11440 | "Display detailed information about dampening\n" |
| 11441 | "Display flap statistics of routes\n" |
| 11442 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11443 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11444 | DEFUN (show_bgp_prefix_longer, |
| 11445 | show_bgp_prefix_longer_cmd, |
| 11446 | "show bgp X:X::X:X/M longer-prefixes", |
| 11447 | SHOW_STR |
| 11448 | BGP_STR |
| 11449 | "IPv6 prefix <network>/<length>\n" |
| 11450 | "Display route and more specific routes\n") |
| 11451 | { |
| 11452 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11453 | bgp_show_type_prefix_longer); |
| 11454 | } |
| 11455 | |
| 11456 | /* old command */ |
| 11457 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 11458 | show_ipv6_bgp_prefix_longer_cmd, |
| 11459 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 11460 | SHOW_STR |
| 11461 | IPV6_STR |
| 11462 | BGP_STR |
| 11463 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 11464 | "Display route and more specific routes\n") |
| 11465 | { |
| 11466 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11467 | bgp_show_type_prefix_longer); |
| 11468 | } |
| 11469 | |
| 11470 | /* old command */ |
| 11471 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 11472 | show_ipv6_mbgp_prefix_longer_cmd, |
| 11473 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 11474 | SHOW_STR |
| 11475 | IPV6_STR |
| 11476 | MBGP_STR |
| 11477 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 11478 | "Display route and more specific routes\n") |
| 11479 | { |
| 11480 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 11481 | bgp_show_type_prefix_longer); |
| 11482 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11483 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11484 | DEFUN (show_bgp_ipv4_prefix_longer, |
| 11485 | show_bgp_ipv4_prefix_longer_cmd, |
| 11486 | "show bgp ipv4 A.B.C.D/M longer-prefixes", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11487 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11488 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11489 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11490 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11491 | "Display route and more specific routes\n") |
| 11492 | { |
| 11493 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11494 | bgp_show_type_prefix_longer); |
| 11495 | } |
| 11496 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11497 | DEFUN (show_bgp_ipv4_safi_flap_prefix_longer, |
| 11498 | show_bgp_ipv4_safi_flap_prefix_longer_cmd, |
| 11499 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M longer-prefixes", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11500 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11501 | BGP_STR |
| 11502 | "Address family\n" |
| 11503 | "Address Family modifier\n" |
| 11504 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11505 | "Address Family modifier\n" |
| 11506 | "Address Family modifier\n" |
| 11507 | "Display flap statistics of routes\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11508 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11509 | "Display route and more specific routes\n") |
| 11510 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11511 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11512 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11513 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11514 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11515 | return CMD_WARNING; |
| 11516 | } |
| 11517 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11518 | bgp_show_type_flap_prefix_longer); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11519 | } |
| 11520 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11521 | ALIAS (show_bgp_ipv4_safi_flap_prefix_longer, |
| 11522 | show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd, |
| 11523 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M longer-prefixes", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11524 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11525 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11526 | "Address family\n" |
| 11527 | "Address Family modifier\n" |
| 11528 | "Address Family modifier\n" |
| 11529 | "Address Family modifier\n" |
| 11530 | "Address Family modifier\n" |
| 11531 | "Display detailed information about dampening\n" |
| 11532 | "Display flap statistics of routes\n" |
| 11533 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11534 | "Display route and more specific routes\n") |
| 11535 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11536 | DEFUN (show_bgp_ipv6_safi_flap_prefix_longer, |
| 11537 | show_bgp_ipv6_safi_flap_prefix_longer_cmd, |
| 11538 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes", |
| 11539 | SHOW_STR |
| 11540 | BGP_STR |
| 11541 | "Address family\n" |
| 11542 | "Address Family modifier\n" |
| 11543 | "Address Family modifier\n" |
| 11544 | "Address Family modifier\n" |
| 11545 | "Address Family modifier\n" |
| 11546 | "Display flap statistics of routes\n" |
| 11547 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11548 | "Display route and more specific routes\n") |
| 11549 | { |
| 11550 | safi_t safi; |
| 11551 | |
| 11552 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11553 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11554 | return CMD_WARNING; |
| 11555 | } |
| 11556 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi, |
| 11557 | bgp_show_type_flap_prefix_longer); |
| 11558 | } |
| 11559 | ALIAS (show_bgp_ipv6_safi_flap_prefix_longer, |
| 11560 | show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd, |
| 11561 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes", |
| 11562 | SHOW_STR |
| 11563 | BGP_STR |
| 11564 | "Address family\n" |
| 11565 | "Address Family modifier\n" |
| 11566 | "Address Family modifier\n" |
| 11567 | "Address Family modifier\n" |
| 11568 | "Address Family modifier\n" |
| 11569 | "Display detailed information about dampening\n" |
| 11570 | "Display flap statistics of routes\n" |
| 11571 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11572 | "Display route and more specific routes\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11573 | |
| 11574 | DEFUN (show_bgp_ipv4_safi_prefix_longer, |
| 11575 | show_bgp_ipv4_safi_prefix_longer_cmd, |
| 11576 | "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes", |
| 11577 | SHOW_STR |
| 11578 | BGP_STR |
| 11579 | "Address family\n" |
| 11580 | "Address Family modifier\n" |
| 11581 | "Address Family modifier\n" |
| 11582 | "Address Family modifier\n" |
| 11583 | "Address Family modifier\n" |
| 11584 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11585 | "Display route and more specific routes\n") |
| 11586 | { |
| 11587 | safi_t safi; |
| 11588 | |
| 11589 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11590 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11591 | return CMD_WARNING; |
| 11592 | } |
| 11593 | |
| 11594 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11595 | bgp_show_type_prefix_longer); |
| 11596 | } |
| 11597 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11598 | DEFUN (show_bgp_ipv6_safi_prefix_longer, |
| 11599 | show_bgp_ipv6_safi_prefix_longer_cmd, |
| 11600 | "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes", |
| 11601 | SHOW_STR |
| 11602 | BGP_STR |
| 11603 | "Address family\n" |
| 11604 | "Address Family modifier\n" |
| 11605 | "Address Family modifier\n" |
| 11606 | "Address Family modifier\n" |
| 11607 | "Address Family modifier\n" |
| 11608 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11609 | "Display route and more specific routes\n") |
| 11610 | { |
| 11611 | safi_t safi; |
| 11612 | |
| 11613 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11614 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11615 | return CMD_WARNING; |
| 11616 | } |
| 11617 | |
| 11618 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi, |
| 11619 | bgp_show_type_prefix_longer); |
| 11620 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11621 | |
| 11622 | DEFUN (show_bgp_ipv4_safi_flap_address, |
| 11623 | show_bgp_ipv4_safi_flap_address_cmd, |
| 11624 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D", |
| 11625 | SHOW_STR |
| 11626 | BGP_STR |
| 11627 | "Address family\n" |
| 11628 | "Address Family modifier\n" |
| 11629 | "Address Family modifier\n" |
| 11630 | "Address Family modifier\n" |
| 11631 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11632 | "Display flap statistics of routes\n" |
| 11633 | "Network in the BGP routing table to display\n") |
| 11634 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11635 | safi_t safi; |
| 11636 | |
| 11637 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11638 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11639 | return CMD_WARNING; |
| 11640 | } |
| 11641 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11642 | bgp_show_type_flap_address); |
| 11643 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11644 | ALIAS (show_bgp_ipv4_safi_flap_address, |
| 11645 | show_bgp_ipv4_safi_damp_flap_address_cmd, |
| 11646 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11647 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11648 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11649 | "Address family\n" |
| 11650 | "Address Family modifier\n" |
| 11651 | "Address Family modifier\n" |
| 11652 | "Address Family modifier\n" |
| 11653 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11654 | "Display detailed information about dampening\n" |
| 11655 | "Display flap statistics of routes\n" |
| 11656 | "Network in the BGP routing table to display\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 11657 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11658 | DEFUN (show_bgp_ipv6_flap_address, |
| 11659 | show_bgp_ipv6_flap_address_cmd, |
| 11660 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11661 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11662 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11663 | "Address family\n" |
| 11664 | "Address Family modifier\n" |
| 11665 | "Address Family modifier\n" |
| 11666 | "Address Family modifier\n" |
| 11667 | "Address Family modifier\n" |
| 11668 | "Display flap statistics of routes\n" |
| 11669 | "Network in the BGP routing table to display\n") |
| 11670 | { |
| 11671 | safi_t safi; |
| 11672 | |
| 11673 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11674 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11675 | return CMD_WARNING; |
| 11676 | } |
| 11677 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11678 | bgp_show_type_flap_address); |
| 11679 | } |
| 11680 | ALIAS (show_bgp_ipv6_flap_address, |
| 11681 | show_bgp_ipv6_damp_flap_address_cmd, |
| 11682 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D", |
| 11683 | SHOW_STR |
| 11684 | BGP_STR |
| 11685 | "Address family\n" |
| 11686 | "Address Family modifier\n" |
| 11687 | "Address Family modifier\n" |
| 11688 | "Address Family modifier\n" |
| 11689 | "Address Family modifier\n" |
| 11690 | "Display detailed information about dampening\n" |
| 11691 | "Display flap statistics of routes\n" |
| 11692 | "Network in the BGP routing table to display\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11693 | |
| 11694 | DEFUN (show_bgp_ipv4_safi_flap_prefix, |
| 11695 | show_bgp_ipv4_safi_flap_prefix_cmd, |
| 11696 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M", |
| 11697 | SHOW_STR |
| 11698 | BGP_STR |
| 11699 | "Address family\n" |
| 11700 | "Address Family modifier\n" |
| 11701 | "Address Family modifier\n" |
| 11702 | "Address Family modifier\n" |
| 11703 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11704 | "Display flap statistics of routes\n" |
| 11705 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11706 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11707 | safi_t safi; |
| 11708 | |
| 11709 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11710 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11711 | return CMD_WARNING; |
| 11712 | } |
| 11713 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11714 | bgp_show_type_flap_prefix); |
| 11715 | } |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11716 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11717 | ALIAS (show_bgp_ipv4_safi_flap_prefix, |
| 11718 | show_bgp_ipv4_safi_damp_flap_prefix_cmd, |
| 11719 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11720 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11721 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11722 | "Address family\n" |
| 11723 | "Address Family modifier\n" |
| 11724 | "Address Family modifier\n" |
| 11725 | "Address Family modifier\n" |
| 11726 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11727 | "Display detailed information about dampening\n" |
| 11728 | "Display flap statistics of routes\n" |
| 11729 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11730 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11731 | DEFUN (show_bgp_ipv6_safi_flap_prefix, |
| 11732 | show_bgp_ipv6_safi_flap_prefix_cmd, |
| 11733 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11734 | SHOW_STR |
| 11735 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11736 | "Address family\n" |
| 11737 | "Address Family modifier\n" |
| 11738 | "Address Family modifier\n" |
| 11739 | "Address Family modifier\n" |
| 11740 | "Address Family modifier\n" |
| 11741 | "Display flap statistics of routes\n" |
| 11742 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11743 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11744 | safi_t safi; |
| 11745 | |
| 11746 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11747 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11748 | return CMD_WARNING; |
| 11749 | } |
| 11750 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi, |
| 11751 | bgp_show_type_flap_prefix); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11752 | } |
| 11753 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11754 | ALIAS (show_bgp_ipv6_safi_flap_prefix, |
| 11755 | show_bgp_ipv6_safi_damp_flap_prefix_cmd, |
| 11756 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M", |
| 11757 | SHOW_STR |
| 11758 | BGP_STR |
| 11759 | "Address family\n" |
| 11760 | "Address Family modifier\n" |
| 11761 | "Address Family modifier\n" |
| 11762 | "Address Family modifier\n" |
| 11763 | "Address Family modifier\n" |
| 11764 | "Display detailed information about dampening\n" |
| 11765 | "Display flap statistics of routes\n" |
| 11766 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11767 | |
| 11768 | DEFUN (show_bgp_ipv6_prefix_longer, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11769 | show_bgp_ipv6_prefix_longer_cmd, |
| 11770 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 11771 | SHOW_STR |
| 11772 | BGP_STR |
| 11773 | "Address family\n" |
| 11774 | "IPv6 prefix <network>/<length>\n" |
| 11775 | "Display route and more specific routes\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11776 | { |
| 11777 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11778 | bgp_show_type_prefix_longer); |
| 11779 | } |
| 11780 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11781 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11782 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 11783 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11784 | { |
| 11785 | int ret; |
| 11786 | struct bgp *bgp; |
| 11787 | struct peer *peer; |
| 11788 | union sockunion su; |
| 11789 | |
| 11790 | /* BGP structure lookup. */ |
| 11791 | if (view_name) |
| 11792 | { |
| 11793 | bgp = bgp_lookup_by_name (view_name); |
| 11794 | if (! bgp) |
| 11795 | { |
| 11796 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 11797 | return NULL; |
| 11798 | } |
| 11799 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 11800 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11801 | { |
| 11802 | bgp = bgp_get_default (); |
| 11803 | if (! bgp) |
| 11804 | { |
| 11805 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11806 | return NULL; |
| 11807 | } |
| 11808 | } |
| 11809 | |
| 11810 | /* Get peer sockunion. */ |
| 11811 | ret = str2sockunion (ip_str, &su); |
| 11812 | if (ret < 0) |
| 11813 | { |
| 11814 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 11815 | return NULL; |
| 11816 | } |
| 11817 | |
| 11818 | /* Peer structure lookup. */ |
| 11819 | peer = peer_lookup (bgp, &su); |
| 11820 | if (! peer) |
| 11821 | { |
| 11822 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 11823 | return NULL; |
| 11824 | } |
| 11825 | |
| 11826 | return peer; |
| 11827 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11828 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11829 | enum bgp_stats |
| 11830 | { |
| 11831 | BGP_STATS_MAXBITLEN = 0, |
| 11832 | BGP_STATS_RIB, |
| 11833 | BGP_STATS_PREFIXES, |
| 11834 | BGP_STATS_TOTPLEN, |
| 11835 | BGP_STATS_UNAGGREGATEABLE, |
| 11836 | BGP_STATS_MAX_AGGREGATEABLE, |
| 11837 | BGP_STATS_AGGREGATES, |
| 11838 | BGP_STATS_SPACE, |
| 11839 | BGP_STATS_ASPATH_COUNT, |
| 11840 | BGP_STATS_ASPATH_MAXHOPS, |
| 11841 | BGP_STATS_ASPATH_TOTHOPS, |
| 11842 | BGP_STATS_ASPATH_MAXSIZE, |
| 11843 | BGP_STATS_ASPATH_TOTSIZE, |
| 11844 | BGP_STATS_ASN_HIGHEST, |
| 11845 | BGP_STATS_MAX, |
| 11846 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11847 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11848 | static const char *table_stats_strs[] = |
| 11849 | { |
| 11850 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 11851 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 11852 | [BGP_STATS_RIB] = "Total Advertisements", |
| 11853 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 11854 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 11855 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 11856 | [BGP_STATS_SPACE] = "Address space advertised", |
| 11857 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 11858 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 11859 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 11860 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 11861 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 11862 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 11863 | [BGP_STATS_MAX] = NULL, |
| 11864 | }; |
| 11865 | |
| 11866 | struct bgp_table_stats |
| 11867 | { |
| 11868 | struct bgp_table *table; |
| 11869 | unsigned long long counts[BGP_STATS_MAX]; |
| 11870 | }; |
| 11871 | |
| 11872 | #if 0 |
| 11873 | #define TALLY_SIGFIG 100000 |
| 11874 | static unsigned long |
| 11875 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 11876 | { |
| 11877 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 11878 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 11879 | unsigned long ret = newtot / count; |
| 11880 | |
| 11881 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 11882 | return ret + 1; |
| 11883 | else |
| 11884 | return ret; |
| 11885 | } |
| 11886 | #endif |
| 11887 | |
| 11888 | static int |
| 11889 | bgp_table_stats_walker (struct thread *t) |
| 11890 | { |
| 11891 | struct bgp_node *rn; |
| 11892 | struct bgp_node *top; |
| 11893 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 11894 | unsigned int space = 0; |
| 11895 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 11896 | if (!(top = bgp_table_top (ts->table))) |
| 11897 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11898 | |
| 11899 | switch (top->p.family) |
| 11900 | { |
| 11901 | case AF_INET: |
| 11902 | space = IPV4_MAX_BITLEN; |
| 11903 | break; |
| 11904 | case AF_INET6: |
| 11905 | space = IPV6_MAX_BITLEN; |
| 11906 | break; |
| 11907 | } |
| 11908 | |
| 11909 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 11910 | |
| 11911 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 11912 | { |
| 11913 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 11914 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11915 | unsigned int rinum = 0; |
| 11916 | |
| 11917 | if (rn == top) |
| 11918 | continue; |
| 11919 | |
| 11920 | if (!rn->info) |
| 11921 | continue; |
| 11922 | |
| 11923 | ts->counts[BGP_STATS_PREFIXES]++; |
| 11924 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 11925 | |
| 11926 | #if 0 |
| 11927 | ts->counts[BGP_STATS_AVGPLEN] |
| 11928 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 11929 | ts->counts[BGP_STATS_AVGPLEN], |
| 11930 | rn->p.prefixlen); |
| 11931 | #endif |
| 11932 | |
| 11933 | /* check if the prefix is included by any other announcements */ |
| 11934 | while (prn && !prn->info) |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 11935 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11936 | |
| 11937 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 11938 | { |
| 11939 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 11940 | /* announced address space */ |
| 11941 | if (space) |
| 11942 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 11943 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11944 | else if (prn->info) |
| 11945 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 11946 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11947 | for (ri = rn->info; ri; ri = ri->next) |
| 11948 | { |
| 11949 | rinum++; |
| 11950 | ts->counts[BGP_STATS_RIB]++; |
| 11951 | |
| 11952 | if (ri->attr && |
| 11953 | (CHECK_FLAG (ri->attr->flag, |
| 11954 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 11955 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 11956 | |
| 11957 | /* as-path stats */ |
| 11958 | if (ri->attr && ri->attr->aspath) |
| 11959 | { |
| 11960 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 11961 | unsigned int size = aspath_size (ri->attr->aspath); |
| 11962 | as_t highest = aspath_highest (ri->attr->aspath); |
| 11963 | |
| 11964 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 11965 | |
| 11966 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 11967 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 11968 | |
| 11969 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 11970 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 11971 | |
| 11972 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 11973 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 11974 | #if 0 |
| 11975 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 11976 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 11977 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 11978 | hops); |
| 11979 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 11980 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 11981 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 11982 | size); |
| 11983 | #endif |
| 11984 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 11985 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 11986 | } |
| 11987 | } |
| 11988 | } |
| 11989 | return 0; |
| 11990 | } |
| 11991 | |
| 11992 | static int |
| 11993 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 11994 | { |
| 11995 | struct bgp_table_stats ts; |
| 11996 | unsigned int i; |
| 11997 | |
| 11998 | if (!bgp->rib[afi][safi]) |
| 11999 | { |
Donald Sharp | 3c96404 | 2016-01-25 23:38:53 -0500 | [diff] [blame] | 12000 | vty_out (vty, "%% No RIB exists for the specified AFI(%d)/SAFI(%d) %s", |
| 12001 | afi, safi, VTY_NEWLINE); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12002 | return CMD_WARNING; |
| 12003 | } |
| 12004 | |
| 12005 | memset (&ts, 0, sizeof (ts)); |
| 12006 | ts.table = bgp->rib[afi][safi]; |
| 12007 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 12008 | |
| 12009 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 12010 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 12011 | |
| 12012 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 12013 | { |
| 12014 | if (!table_stats_strs[i]) |
| 12015 | continue; |
| 12016 | |
| 12017 | switch (i) |
| 12018 | { |
| 12019 | #if 0 |
| 12020 | case BGP_STATS_ASPATH_AVGHOPS: |
| 12021 | case BGP_STATS_ASPATH_AVGSIZE: |
| 12022 | case BGP_STATS_AVGPLEN: |
| 12023 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12024 | vty_out (vty, "%12.2f", |
| 12025 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 12026 | break; |
| 12027 | #endif |
| 12028 | case BGP_STATS_ASPATH_TOTHOPS: |
| 12029 | case BGP_STATS_ASPATH_TOTSIZE: |
| 12030 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12031 | vty_out (vty, "%12.2f", |
| 12032 | ts.counts[i] ? |
| 12033 | (float)ts.counts[i] / |
| 12034 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 12035 | : 0); |
| 12036 | break; |
| 12037 | case BGP_STATS_TOTPLEN: |
| 12038 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12039 | vty_out (vty, "%12.2f", |
| 12040 | ts.counts[i] ? |
| 12041 | (float)ts.counts[i] / |
| 12042 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 12043 | : 0); |
| 12044 | break; |
| 12045 | case BGP_STATS_SPACE: |
| 12046 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12047 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 12048 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 12049 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 12050 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12051 | vty_out (vty, "%12.2f%s", |
| 12052 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 12053 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12054 | VTY_NEWLINE); |
| 12055 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 12056 | vty_out (vty, "%12.2f%s", |
| 12057 | (float)ts.counts[BGP_STATS_SPACE] / |
| 12058 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 12059 | VTY_NEWLINE); |
| 12060 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 12061 | break; |
| 12062 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 12063 | vty_out (vty, "%12.2f", |
| 12064 | (float)ts.counts[BGP_STATS_SPACE] / |
| 12065 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 12066 | break; |
| 12067 | default: |
| 12068 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12069 | vty_out (vty, "%12llu", ts.counts[i]); |
| 12070 | } |
| 12071 | |
| 12072 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12073 | } |
| 12074 | return CMD_SUCCESS; |
| 12075 | } |
| 12076 | |
| 12077 | static int |
| 12078 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 12079 | const char *afi_str, const char *safi_str) |
| 12080 | { |
| 12081 | struct bgp *bgp; |
| 12082 | afi_t afi; |
| 12083 | safi_t safi; |
| 12084 | |
| 12085 | if (name) |
| 12086 | bgp = bgp_lookup_by_name (name); |
| 12087 | else |
| 12088 | bgp = bgp_get_default (); |
| 12089 | |
| 12090 | if (!bgp) |
| 12091 | { |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 12092 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12093 | return CMD_WARNING; |
| 12094 | } |
| 12095 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 12096 | { |
| 12097 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 12098 | afi = AFI_IP; |
| 12099 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 12100 | afi = AFI_IP6; |
| 12101 | else |
| 12102 | { |
| 12103 | vty_out (vty, "%% Invalid address family %s%s", |
| 12104 | afi_str, VTY_NEWLINE); |
| 12105 | return CMD_WARNING; |
| 12106 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12107 | switch (safi_str[0]) { |
| 12108 | case 'm': |
| 12109 | safi = SAFI_MULTICAST; |
| 12110 | break; |
| 12111 | case 'u': |
| 12112 | safi = SAFI_UNICAST; |
| 12113 | break; |
| 12114 | case 'v': |
Donald Sharp | 3c96404 | 2016-01-25 23:38:53 -0500 | [diff] [blame] | 12115 | safi = SAFI_MPLS_VPN; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12116 | break; |
| 12117 | case 'e': |
| 12118 | safi = SAFI_ENCAP; |
| 12119 | break; |
| 12120 | default: |
| 12121 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12122 | safi_str, VTY_NEWLINE); |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12123 | return CMD_WARNING; |
| 12124 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12125 | } |
| 12126 | else |
| 12127 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12128 | vty_out (vty, "%% Invalid address family \"%s\"%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12129 | afi_str, VTY_NEWLINE); |
| 12130 | return CMD_WARNING; |
| 12131 | } |
| 12132 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12133 | return bgp_table_stats (vty, bgp, afi, safi); |
| 12134 | } |
| 12135 | |
| 12136 | DEFUN (show_bgp_statistics, |
| 12137 | show_bgp_statistics_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12138 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12139 | SHOW_STR |
| 12140 | BGP_STR |
| 12141 | "Address family\n" |
| 12142 | "Address family\n" |
| 12143 | "Address Family modifier\n" |
| 12144 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12145 | "Address Family modifier\n" |
| 12146 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12147 | "BGP RIB advertisement statistics\n") |
| 12148 | { |
| 12149 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 12150 | } |
| 12151 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12152 | ALIAS (show_bgp_statistics, |
| 12153 | show_bgp_statistics_vpnv4_cmd, |
| 12154 | "show bgp (ipv4) (vpnv4) statistics", |
| 12155 | SHOW_STR |
| 12156 | BGP_STR |
| 12157 | "Address family\n" |
| 12158 | "Address Family modifier\n" |
| 12159 | "BGP RIB advertisement statistics\n") |
| 12160 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12161 | DEFUN (show_bgp_statistics_view, |
| 12162 | show_bgp_statistics_view_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12163 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12164 | SHOW_STR |
| 12165 | BGP_STR |
| 12166 | "BGP view\n" |
| 12167 | "Address family\n" |
| 12168 | "Address family\n" |
| 12169 | "Address Family modifier\n" |
| 12170 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12171 | "Address Family modifier\n" |
| 12172 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12173 | "BGP RIB advertisement statistics\n") |
| 12174 | { |
| 12175 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 12176 | } |
| 12177 | |
| 12178 | ALIAS (show_bgp_statistics_view, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12179 | show_bgp_statistics_view_vpnv4_cmd, |
| 12180 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12181 | SHOW_STR |
| 12182 | BGP_STR |
| 12183 | "BGP view\n" |
| 12184 | "Address family\n" |
| 12185 | "Address Family modifier\n" |
| 12186 | "BGP RIB advertisement statistics\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12187 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12188 | enum bgp_pcounts |
| 12189 | { |
| 12190 | PCOUNT_ADJ_IN = 0, |
| 12191 | PCOUNT_DAMPED, |
| 12192 | PCOUNT_REMOVED, |
| 12193 | PCOUNT_HISTORY, |
| 12194 | PCOUNT_STALE, |
| 12195 | PCOUNT_VALID, |
| 12196 | PCOUNT_ALL, |
| 12197 | PCOUNT_COUNTED, |
| 12198 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 12199 | PCOUNT_MAX, |
| 12200 | }; |
| 12201 | |
| 12202 | static const char *pcount_strs[] = |
| 12203 | { |
| 12204 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 12205 | [PCOUNT_DAMPED] = "Damped", |
| 12206 | [PCOUNT_REMOVED] = "Removed", |
| 12207 | [PCOUNT_HISTORY] = "History", |
| 12208 | [PCOUNT_STALE] = "Stale", |
| 12209 | [PCOUNT_VALID] = "Valid", |
| 12210 | [PCOUNT_ALL] = "All RIB", |
| 12211 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 12212 | [PCOUNT_PFCNT] = "Useable", |
| 12213 | [PCOUNT_MAX] = NULL, |
| 12214 | }; |
| 12215 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12216 | struct peer_pcounts |
| 12217 | { |
| 12218 | unsigned int count[PCOUNT_MAX]; |
| 12219 | const struct peer *peer; |
| 12220 | const struct bgp_table *table; |
| 12221 | }; |
| 12222 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12223 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12224 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12225 | { |
| 12226 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12227 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 12228 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12229 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12230 | 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] | 12231 | { |
| 12232 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12233 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12234 | |
| 12235 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 12236 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12237 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12238 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12239 | for (ri = rn->info; ri; ri = ri->next) |
| 12240 | { |
| 12241 | char buf[SU_ADDRSTRLEN]; |
| 12242 | |
| 12243 | if (ri->peer != peer) |
| 12244 | continue; |
| 12245 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12246 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12247 | |
| 12248 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12249 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12250 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12251 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12252 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12253 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12254 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12255 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12256 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12257 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12258 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12259 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12260 | |
| 12261 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 12262 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12263 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12264 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12265 | plog_warn (peer->log, |
| 12266 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 12267 | peer->host, |
| 12268 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 12269 | buf, SU_ADDRSTRLEN), |
| 12270 | rn->p.prefixlen, |
| 12271 | ri->flags); |
| 12272 | } |
| 12273 | else |
| 12274 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12275 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12276 | plog_warn (peer->log, |
| 12277 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 12278 | peer->host, |
| 12279 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 12280 | buf, SU_ADDRSTRLEN), |
| 12281 | rn->p.prefixlen, |
| 12282 | ri->flags); |
| 12283 | } |
| 12284 | } |
| 12285 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12286 | return 0; |
| 12287 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12288 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12289 | static int |
| 12290 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 12291 | { |
| 12292 | struct peer_pcounts pcounts = { .peer = peer }; |
| 12293 | unsigned int i; |
| 12294 | |
| 12295 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 12296 | || !peer->bgp->rib[afi][safi]) |
| 12297 | { |
| 12298 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 12299 | return CMD_WARNING; |
| 12300 | } |
| 12301 | |
| 12302 | memset (&pcounts, 0, sizeof(pcounts)); |
| 12303 | pcounts.peer = peer; |
| 12304 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 12305 | |
| 12306 | /* in-place call via thread subsystem so as to record execution time |
| 12307 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 12308 | * on just vty_read()). |
| 12309 | */ |
| 12310 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 12311 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12312 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 12313 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 12314 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 12315 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 12316 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 12317 | |
| 12318 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12319 | vty_out (vty, "%20s: %-10d%s", |
| 12320 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12321 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12322 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12323 | { |
| 12324 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 12325 | peer->host, VTY_NEWLINE); |
| 12326 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 12327 | VTY_NEWLINE); |
| 12328 | } |
| 12329 | |
| 12330 | return CMD_SUCCESS; |
| 12331 | } |
| 12332 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12333 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 12334 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 12335 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12336 | SHOW_STR |
| 12337 | IP_STR |
| 12338 | BGP_STR |
| 12339 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12340 | "Neighbor to display information about\n" |
| 12341 | "Neighbor to display information about\n" |
| 12342 | "Display detailed prefix count information\n") |
| 12343 | { |
| 12344 | struct peer *peer; |
| 12345 | |
| 12346 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12347 | if (! peer) |
| 12348 | return CMD_WARNING; |
| 12349 | |
| 12350 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 12351 | } |
| 12352 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12353 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 12354 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 12355 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12356 | SHOW_STR |
| 12357 | BGP_STR |
| 12358 | "Address family\n" |
| 12359 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12360 | "Neighbor to display information about\n" |
| 12361 | "Neighbor to display information about\n" |
| 12362 | "Display detailed prefix count information\n") |
| 12363 | { |
| 12364 | struct peer *peer; |
| 12365 | |
| 12366 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12367 | if (! peer) |
| 12368 | return CMD_WARNING; |
| 12369 | |
| 12370 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 12371 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12372 | |
| 12373 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 12374 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 12375 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12376 | SHOW_STR |
| 12377 | IP_STR |
| 12378 | BGP_STR |
| 12379 | "Address family\n" |
| 12380 | "Address Family modifier\n" |
| 12381 | "Address Family modifier\n" |
| 12382 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12383 | "Neighbor to display information about\n" |
| 12384 | "Neighbor to display information about\n" |
| 12385 | "Display detailed prefix count information\n") |
| 12386 | { |
| 12387 | struct peer *peer; |
| 12388 | |
| 12389 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12390 | if (! peer) |
| 12391 | return CMD_WARNING; |
| 12392 | |
| 12393 | if (strncmp (argv[0], "m", 1) == 0) |
| 12394 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 12395 | |
| 12396 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 12397 | } |
| 12398 | |
| 12399 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 12400 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 12401 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12402 | SHOW_STR |
| 12403 | IP_STR |
| 12404 | BGP_STR |
| 12405 | "Address family\n" |
| 12406 | "Address Family modifier\n" |
| 12407 | "Address Family modifier\n" |
| 12408 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12409 | "Neighbor to display information about\n" |
| 12410 | "Neighbor to display information about\n" |
| 12411 | "Display detailed prefix count information\n") |
| 12412 | { |
| 12413 | struct peer *peer; |
| 12414 | |
| 12415 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12416 | if (! peer) |
| 12417 | return CMD_WARNING; |
| 12418 | |
| 12419 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 12420 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12421 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12422 | DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts, |
| 12423 | show_bgp_ipv4_safi_neighbor_prefix_counts_cmd, |
| 12424 | "show bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12425 | SHOW_STR |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12426 | BGP_STR |
| 12427 | "Address family\n" |
| 12428 | "Address Family modifier\n" |
| 12429 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12430 | "Address Family modifier\n" |
| 12431 | "Address Family modifier\n" |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12432 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12433 | "Neighbor to display information about\n" |
| 12434 | "Neighbor to display information about\n" |
| 12435 | "Display detailed prefix count information\n") |
| 12436 | { |
| 12437 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12438 | safi_t safi; |
| 12439 | |
| 12440 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12441 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12442 | return CMD_WARNING; |
| 12443 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12444 | |
| 12445 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12446 | if (! peer) |
| 12447 | return CMD_WARNING; |
| 12448 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12449 | return bgp_peer_counts (vty, peer, AFI_IP, safi); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12450 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 12451 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12452 | DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts, |
| 12453 | show_bgp_ipv6_safi_neighbor_prefix_counts_cmd, |
| 12454 | "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12455 | SHOW_STR |
| 12456 | BGP_STR |
| 12457 | "Address family\n" |
| 12458 | "Address Family modifier\n" |
| 12459 | "Address Family modifier\n" |
| 12460 | "Address Family modifier\n" |
| 12461 | "Address Family modifier\n" |
| 12462 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12463 | "Neighbor to display information about\n" |
| 12464 | "Neighbor to display information about\n" |
| 12465 | "Display detailed prefix count information\n") |
| 12466 | { |
| 12467 | struct peer *peer; |
| 12468 | safi_t safi; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12469 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12470 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12471 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12472 | return CMD_WARNING; |
| 12473 | } |
| 12474 | |
| 12475 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12476 | if (! peer) |
| 12477 | return CMD_WARNING; |
| 12478 | |
| 12479 | return bgp_peer_counts (vty, peer, AFI_IP6, safi); |
| 12480 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12481 | |
| 12482 | DEFUN (show_ip_bgp_encap_neighbor_prefix_counts, |
| 12483 | show_ip_bgp_encap_neighbor_prefix_counts_cmd, |
| 12484 | "show ip bgp encap all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12485 | SHOW_STR |
| 12486 | IP_STR |
| 12487 | BGP_STR |
| 12488 | "Address family\n" |
| 12489 | "Address Family modifier\n" |
| 12490 | "Address Family modifier\n" |
| 12491 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12492 | "Neighbor to display information about\n" |
| 12493 | "Neighbor to display information about\n" |
| 12494 | "Display detailed prefix count information\n") |
| 12495 | { |
| 12496 | struct peer *peer; |
| 12497 | |
| 12498 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12499 | if (! peer) |
| 12500 | return CMD_WARNING; |
| 12501 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12502 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12503 | } |
| 12504 | |
| 12505 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12506 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12507 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 12508 | int in) |
| 12509 | { |
| 12510 | struct bgp_table *table; |
| 12511 | struct bgp_adj_in *ain; |
| 12512 | struct bgp_adj_out *adj; |
| 12513 | unsigned long output_count; |
| 12514 | struct bgp_node *rn; |
| 12515 | int header1 = 1; |
| 12516 | struct bgp *bgp; |
| 12517 | int header2 = 1; |
| 12518 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12519 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12520 | |
| 12521 | if (! bgp) |
| 12522 | return; |
| 12523 | |
| 12524 | table = bgp->rib[afi][safi]; |
| 12525 | |
| 12526 | output_count = 0; |
| 12527 | |
| 12528 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 12529 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 12530 | { |
| 12531 | 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] | 12532 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12533 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12534 | |
| 12535 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 12536 | VTY_NEWLINE, VTY_NEWLINE); |
| 12537 | header1 = 0; |
| 12538 | } |
| 12539 | |
| 12540 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12541 | if (in) |
| 12542 | { |
| 12543 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 12544 | if (ain->peer == peer) |
| 12545 | { |
| 12546 | if (header1) |
| 12547 | { |
| 12548 | 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] | 12549 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12550 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12551 | header1 = 0; |
| 12552 | } |
| 12553 | if (header2) |
| 12554 | { |
| 12555 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 12556 | header2 = 0; |
| 12557 | } |
| 12558 | if (ain->attr) |
| 12559 | { |
| 12560 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 12561 | output_count++; |
| 12562 | } |
| 12563 | } |
| 12564 | } |
| 12565 | else |
| 12566 | { |
| 12567 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 12568 | if (adj->peer == peer) |
| 12569 | { |
| 12570 | if (header1) |
| 12571 | { |
| 12572 | 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] | 12573 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12574 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12575 | header1 = 0; |
| 12576 | } |
| 12577 | if (header2) |
| 12578 | { |
| 12579 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 12580 | header2 = 0; |
| 12581 | } |
| 12582 | if (adj->attr) |
| 12583 | { |
| 12584 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 12585 | output_count++; |
| 12586 | } |
| 12587 | } |
| 12588 | } |
| 12589 | |
| 12590 | if (output_count != 0) |
| 12591 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 12592 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 12593 | } |
| 12594 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12595 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12596 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 12597 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12598 | if (! peer || ! peer->afc[afi][safi]) |
| 12599 | { |
| 12600 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 12601 | return CMD_WARNING; |
| 12602 | } |
| 12603 | |
| 12604 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 12605 | { |
| 12606 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 12607 | VTY_NEWLINE); |
| 12608 | return CMD_WARNING; |
| 12609 | } |
| 12610 | |
| 12611 | show_adj_route (vty, peer, afi, safi, in); |
| 12612 | |
| 12613 | return CMD_SUCCESS; |
| 12614 | } |
| 12615 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12616 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 12617 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 12618 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12619 | SHOW_STR |
| 12620 | IP_STR |
| 12621 | BGP_STR |
| 12622 | "BGP view\n" |
| 12623 | "View name\n" |
| 12624 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12625 | "Neighbor to display information about\n" |
| 12626 | "Neighbor to display information about\n" |
| 12627 | "Display the routes advertised to a BGP neighbor\n") |
| 12628 | { |
| 12629 | struct peer *peer; |
| 12630 | |
| 12631 | if (argc == 2) |
| 12632 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12633 | else |
| 12634 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12635 | |
| 12636 | if (! peer) |
| 12637 | return CMD_WARNING; |
| 12638 | |
| 12639 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 12640 | } |
| 12641 | |
| 12642 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
| 12643 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 12644 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12645 | SHOW_STR |
| 12646 | IP_STR |
| 12647 | BGP_STR |
| 12648 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12649 | "Neighbor to display information about\n" |
| 12650 | "Neighbor to display information about\n" |
| 12651 | "Display the routes advertised to a BGP neighbor\n") |
| 12652 | |
| 12653 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 12654 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 12655 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12656 | SHOW_STR |
| 12657 | IP_STR |
| 12658 | BGP_STR |
| 12659 | "Address family\n" |
| 12660 | "Address Family modifier\n" |
| 12661 | "Address Family modifier\n" |
| 12662 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12663 | "Neighbor to display information about\n" |
| 12664 | "Neighbor to display information about\n" |
| 12665 | "Display the routes advertised to a BGP neighbor\n") |
| 12666 | { |
| 12667 | struct peer *peer; |
| 12668 | |
| 12669 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12670 | if (! peer) |
| 12671 | return CMD_WARNING; |
| 12672 | |
| 12673 | if (strncmp (argv[0], "m", 1) == 0) |
| 12674 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 12675 | |
| 12676 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 12677 | } |
| 12678 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12679 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 12680 | show_bgp_view_neighbor_advertised_route_cmd, |
| 12681 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12682 | SHOW_STR |
| 12683 | BGP_STR |
| 12684 | "BGP view\n" |
| 12685 | "View name\n" |
| 12686 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12687 | "Neighbor to display information about\n" |
| 12688 | "Neighbor to display information about\n" |
| 12689 | "Display the routes advertised to a BGP neighbor\n") |
| 12690 | { |
| 12691 | struct peer *peer; |
| 12692 | |
| 12693 | if (argc == 2) |
| 12694 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12695 | else |
| 12696 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12697 | |
| 12698 | if (! peer) |
| 12699 | return CMD_WARNING; |
| 12700 | |
| 12701 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 12702 | } |
| 12703 | |
| 12704 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 12705 | show_bgp_view_neighbor_received_routes_cmd, |
| 12706 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12707 | SHOW_STR |
| 12708 | BGP_STR |
| 12709 | "BGP view\n" |
| 12710 | "View name\n" |
| 12711 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12712 | "Neighbor to display information about\n" |
| 12713 | "Neighbor to display information about\n" |
| 12714 | "Display the received routes from neighbor\n") |
| 12715 | { |
| 12716 | struct peer *peer; |
| 12717 | |
| 12718 | if (argc == 2) |
| 12719 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12720 | else |
| 12721 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12722 | |
| 12723 | if (! peer) |
| 12724 | return CMD_WARNING; |
| 12725 | |
| 12726 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 12727 | } |
| 12728 | |
| 12729 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12730 | show_bgp_neighbor_advertised_route_cmd, |
| 12731 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12732 | SHOW_STR |
| 12733 | BGP_STR |
| 12734 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12735 | "Neighbor to display information about\n" |
| 12736 | "Neighbor to display information about\n" |
| 12737 | "Display the routes advertised to a BGP neighbor\n") |
| 12738 | |
| 12739 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12740 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 12741 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12742 | SHOW_STR |
| 12743 | BGP_STR |
| 12744 | "Address family\n" |
| 12745 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12746 | "Neighbor to display information about\n" |
| 12747 | "Neighbor to display information about\n" |
| 12748 | "Display the routes advertised to a BGP neighbor\n") |
| 12749 | |
| 12750 | /* old command */ |
| 12751 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12752 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 12753 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12754 | SHOW_STR |
| 12755 | IPV6_STR |
| 12756 | BGP_STR |
| 12757 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12758 | "Neighbor to display information about\n" |
| 12759 | "Neighbor to display information about\n" |
| 12760 | "Display the routes advertised to a BGP neighbor\n") |
| 12761 | |
| 12762 | /* old command */ |
| 12763 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 12764 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 12765 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12766 | SHOW_STR |
| 12767 | IPV6_STR |
| 12768 | MBGP_STR |
| 12769 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12770 | "Neighbor to display information about\n" |
| 12771 | "Neighbor to display information about\n" |
| 12772 | "Display the routes advertised to a BGP neighbor\n") |
| 12773 | { |
| 12774 | struct peer *peer; |
| 12775 | |
| 12776 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12777 | if (! peer) |
| 12778 | return CMD_WARNING; |
| 12779 | |
| 12780 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
| 12781 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12782 | |
| 12783 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 12784 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 12785 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12786 | SHOW_STR |
| 12787 | IP_STR |
| 12788 | BGP_STR |
| 12789 | "BGP view\n" |
| 12790 | "View name\n" |
| 12791 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12792 | "Neighbor to display information about\n" |
| 12793 | "Neighbor to display information about\n" |
| 12794 | "Display the received routes from neighbor\n") |
| 12795 | { |
| 12796 | struct peer *peer; |
| 12797 | |
| 12798 | if (argc == 2) |
| 12799 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12800 | else |
| 12801 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12802 | |
| 12803 | if (! peer) |
| 12804 | return CMD_WARNING; |
| 12805 | |
| 12806 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 12807 | } |
| 12808 | |
| 12809 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
| 12810 | show_ip_bgp_neighbor_received_routes_cmd, |
| 12811 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12812 | SHOW_STR |
| 12813 | IP_STR |
| 12814 | BGP_STR |
| 12815 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12816 | "Neighbor to display information about\n" |
| 12817 | "Neighbor to display information about\n" |
| 12818 | "Display the received routes from neighbor\n") |
| 12819 | |
| 12820 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 12821 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 12822 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12823 | SHOW_STR |
| 12824 | BGP_STR |
| 12825 | "Address family\n" |
| 12826 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12827 | "Neighbor to display information about\n" |
| 12828 | "Neighbor to display information about\n" |
| 12829 | "Display the received routes from neighbor\n") |
| 12830 | |
| 12831 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 12832 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 12833 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12834 | SHOW_STR |
| 12835 | BGP_STR |
| 12836 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12837 | "Neighbor to display information about\n" |
| 12838 | "Neighbor to display information about\n" |
| 12839 | "Display information received from a BGP neighbor\n" |
| 12840 | "Display the prefixlist filter\n") |
| 12841 | { |
| 12842 | char name[BUFSIZ]; |
| 12843 | union sockunion su; |
| 12844 | struct peer *peer; |
| 12845 | int count, ret; |
| 12846 | |
| 12847 | ret = str2sockunion (argv[0], &su); |
| 12848 | if (ret < 0) |
| 12849 | { |
| 12850 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 12851 | return CMD_WARNING; |
| 12852 | } |
| 12853 | |
| 12854 | peer = peer_lookup (NULL, &su); |
| 12855 | if (! peer) |
| 12856 | return CMD_WARNING; |
| 12857 | |
| 12858 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 12859 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 12860 | if (count) |
| 12861 | { |
| 12862 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 12863 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 12864 | } |
| 12865 | |
| 12866 | return CMD_SUCCESS; |
| 12867 | } |
| 12868 | |
| 12869 | /* old command */ |
| 12870 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 12871 | ipv6_bgp_neighbor_received_routes_cmd, |
| 12872 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12873 | SHOW_STR |
| 12874 | IPV6_STR |
| 12875 | BGP_STR |
| 12876 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12877 | "Neighbor to display information about\n" |
| 12878 | "Neighbor to display information about\n" |
| 12879 | "Display the received routes from neighbor\n") |
| 12880 | |
| 12881 | /* old command */ |
| 12882 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 12883 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 12884 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12885 | SHOW_STR |
| 12886 | IPV6_STR |
| 12887 | MBGP_STR |
| 12888 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12889 | "Neighbor to display information about\n" |
| 12890 | "Neighbor to display information about\n" |
| 12891 | "Display the received routes from neighbor\n") |
| 12892 | { |
| 12893 | struct peer *peer; |
| 12894 | |
| 12895 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12896 | if (! peer) |
| 12897 | return CMD_WARNING; |
| 12898 | |
| 12899 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
| 12900 | } |
| 12901 | |
| 12902 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 12903 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 12904 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12905 | SHOW_STR |
| 12906 | BGP_STR |
| 12907 | "BGP view\n" |
| 12908 | "View name\n" |
| 12909 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12910 | "Neighbor to display information about\n" |
| 12911 | "Neighbor to display information about\n" |
| 12912 | "Display information received from a BGP neighbor\n" |
| 12913 | "Display the prefixlist filter\n") |
| 12914 | { |
| 12915 | char name[BUFSIZ]; |
| 12916 | union sockunion su; |
| 12917 | struct peer *peer; |
| 12918 | struct bgp *bgp; |
| 12919 | int count, ret; |
| 12920 | |
| 12921 | /* BGP structure lookup. */ |
| 12922 | bgp = bgp_lookup_by_name (argv[0]); |
| 12923 | if (bgp == NULL) |
| 12924 | { |
| 12925 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 12926 | return CMD_WARNING; |
| 12927 | } |
| 12928 | |
| 12929 | ret = str2sockunion (argv[1], &su); |
| 12930 | if (ret < 0) |
| 12931 | { |
| 12932 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 12933 | return CMD_WARNING; |
| 12934 | } |
| 12935 | |
| 12936 | peer = peer_lookup (bgp, &su); |
| 12937 | if (! peer) |
| 12938 | return CMD_WARNING; |
| 12939 | |
| 12940 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 12941 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 12942 | if (count) |
| 12943 | { |
| 12944 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 12945 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 12946 | } |
| 12947 | |
| 12948 | return CMD_SUCCESS; |
| 12949 | } |
| 12950 | |
| 12951 | |
| 12952 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 12953 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 12954 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12955 | SHOW_STR |
| 12956 | IP_STR |
| 12957 | BGP_STR |
| 12958 | "Address family\n" |
| 12959 | "Address Family modifier\n" |
| 12960 | "Address Family modifier\n" |
| 12961 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12962 | "Neighbor to display information about\n" |
| 12963 | "Neighbor to display information about\n" |
| 12964 | "Display the received routes from neighbor\n") |
| 12965 | { |
| 12966 | struct peer *peer; |
| 12967 | |
| 12968 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12969 | if (! peer) |
| 12970 | return CMD_WARNING; |
| 12971 | |
| 12972 | if (strncmp (argv[0], "m", 1) == 0) |
| 12973 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 12974 | |
| 12975 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 12976 | } |
| 12977 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12978 | DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route, |
| 12979 | show_bgp_ipv4_safi_neighbor_advertised_route_cmd, |
| 12980 | "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12981 | SHOW_STR |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12982 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12983 | "Address Family modifier\n" |
| 12984 | "Address Family modifier\n" |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12985 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12986 | "Neighbor to display information about\n" |
| 12987 | "Neighbor to display information about\n" |
| 12988 | "Display the routes advertised to a BGP neighbor\n") |
| 12989 | { |
| 12990 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12991 | safi_t safi; |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12992 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12993 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12994 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12995 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12996 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12997 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12998 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12999 | if (! peer) |
| 13000 | return CMD_WARNING; |
| 13001 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13002 | return peer_adj_routes (vty, peer, AFI_IP, safi, 0); |
| 13003 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13004 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13005 | DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route, |
| 13006 | show_bgp_ipv6_safi_neighbor_advertised_route_cmd, |
| 13007 | "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 13008 | SHOW_STR |
| 13009 | BGP_STR |
| 13010 | "Address Family modifier\n" |
| 13011 | "Address Family modifier\n" |
| 13012 | "Address Family modifier\n" |
| 13013 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13014 | "Neighbor to display information about\n" |
| 13015 | "Neighbor to display information about\n" |
| 13016 | "Display the routes advertised to a BGP neighbor\n") |
| 13017 | { |
| 13018 | struct peer *peer; |
| 13019 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13020 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13021 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13022 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13023 | return CMD_WARNING; |
| 13024 | } |
| 13025 | |
| 13026 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13027 | if (! peer) |
| 13028 | return CMD_WARNING; |
| 13029 | |
| 13030 | return peer_adj_routes (vty, peer, AFI_IP6, safi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13031 | } |
| 13032 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13033 | DEFUN (show_bgp_view_ipv6_neighbor_advertised_route, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13034 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 13035 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13036 | SHOW_STR |
| 13037 | BGP_STR |
| 13038 | "BGP view\n" |
| 13039 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13040 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13041 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13042 | "Neighbor to display information about\n" |
| 13043 | "Neighbor to display information about\n" |
| 13044 | "Display the routes advertised to a BGP neighbor\n") |
| 13045 | { |
| 13046 | struct peer *peer; |
| 13047 | |
| 13048 | if (argc == 2) |
| 13049 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13050 | else |
| 13051 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13052 | |
| 13053 | if (! peer) |
| 13054 | return CMD_WARNING; |
| 13055 | |
| 13056 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 13057 | } |
| 13058 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13059 | DEFUN (show_bgp_view_ipv6_neighbor_received_routes, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13060 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 13061 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13062 | SHOW_STR |
| 13063 | BGP_STR |
| 13064 | "BGP view\n" |
| 13065 | "View name\n" |
| 13066 | "Address family\n" |
| 13067 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13068 | "Neighbor to display information about\n" |
| 13069 | "Neighbor to display information about\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13070 | "Display the received routes from neighbor\n") |
| 13071 | { |
| 13072 | struct peer *peer; |
| 13073 | |
| 13074 | if (argc == 2) |
| 13075 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13076 | else |
| 13077 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13078 | |
| 13079 | if (! peer) |
| 13080 | return CMD_WARNING; |
| 13081 | |
| 13082 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 13083 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13084 | |
| 13085 | DEFUN (show_bgp_ipv4_safi_neighbor_received_routes, |
| 13086 | show_bgp_ipv4_safi_neighbor_received_routes_cmd, |
| 13087 | "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes", |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13088 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13089 | BGP_STR |
| 13090 | "Address family\n" |
| 13091 | "Address Family modifier\n" |
| 13092 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13093 | "Address Family modifier\n" |
| 13094 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13095 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13096 | "Neighbor to display information about\n" |
| 13097 | "Neighbor to display information about\n" |
| 13098 | "Display the received routes from neighbor\n") |
| 13099 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13100 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13101 | safi_t safi; |
| 13102 | |
| 13103 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13104 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13105 | return CMD_WARNING; |
| 13106 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13107 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13108 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13109 | if (! peer) |
| 13110 | return CMD_WARNING; |
| 13111 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13112 | return peer_adj_routes (vty, peer, AFI_IP, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13113 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13114 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13115 | DEFUN (show_bgp_ipv6_safi_neighbor_received_routes, |
| 13116 | show_bgp_ipv6_safi_neighbor_received_routes_cmd, |
| 13117 | "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 13118 | SHOW_STR |
| 13119 | BGP_STR |
| 13120 | "Address family\n" |
| 13121 | "Address Family modifier\n" |
| 13122 | "Address Family modifier\n" |
| 13123 | "Address Family modifier\n" |
| 13124 | "Address Family modifier\n" |
| 13125 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13126 | "Neighbor to display information about\n" |
| 13127 | "Neighbor to display information about\n" |
| 13128 | "Display the received routes from neighbor\n") |
| 13129 | { |
| 13130 | struct peer *peer; |
| 13131 | safi_t safi; |
| 13132 | |
| 13133 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13134 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13135 | return CMD_WARNING; |
| 13136 | } |
| 13137 | |
| 13138 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13139 | if (! peer) |
| 13140 | return CMD_WARNING; |
| 13141 | |
| 13142 | return peer_adj_routes (vty, peer, AFI_IP6, safi, 1); |
| 13143 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13144 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13145 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 13146 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13147 | "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] | 13148 | SHOW_STR |
| 13149 | BGP_STR |
| 13150 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 13151 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13152 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13153 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13154 | "Address family modifier\n" |
| 13155 | "Address family modifier\n" |
| 13156 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13157 | "Neighbor to display information about\n" |
| 13158 | "Neighbor to display information about\n" |
| 13159 | "Display the advertised routes to neighbor\n" |
| 13160 | "Display the received routes from neighbor\n") |
| 13161 | { |
| 13162 | int afi; |
| 13163 | int safi; |
| 13164 | int in; |
| 13165 | struct peer *peer; |
| 13166 | |
David Lamparter | 94bad67 | 2015-03-03 08:52:22 +0100 | [diff] [blame] | 13167 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13168 | |
| 13169 | if (! peer) |
| 13170 | return CMD_WARNING; |
| 13171 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13172 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 13173 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13174 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13175 | |
| 13176 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 13177 | } |
| 13178 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13179 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 13180 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 13181 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 13182 | SHOW_STR |
| 13183 | IP_STR |
| 13184 | BGP_STR |
| 13185 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13186 | "Neighbor to display information about\n" |
| 13187 | "Neighbor to display information about\n" |
| 13188 | "Display information received from a BGP neighbor\n" |
| 13189 | "Display the prefixlist filter\n") |
| 13190 | { |
| 13191 | char name[BUFSIZ]; |
| 13192 | union sockunion su; |
| 13193 | struct peer *peer; |
| 13194 | int count, ret; |
| 13195 | |
| 13196 | ret = str2sockunion (argv[0], &su); |
| 13197 | if (ret < 0) |
| 13198 | { |
| 13199 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 13200 | return CMD_WARNING; |
| 13201 | } |
| 13202 | |
| 13203 | peer = peer_lookup (NULL, &su); |
| 13204 | if (! peer) |
| 13205 | return CMD_WARNING; |
| 13206 | |
| 13207 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 13208 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13209 | if (count) |
| 13210 | { |
| 13211 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 13212 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13213 | } |
| 13214 | |
| 13215 | return CMD_SUCCESS; |
| 13216 | } |
| 13217 | |
| 13218 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 13219 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 13220 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 13221 | SHOW_STR |
| 13222 | IP_STR |
| 13223 | BGP_STR |
| 13224 | "Address family\n" |
| 13225 | "Address Family modifier\n" |
| 13226 | "Address Family modifier\n" |
| 13227 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13228 | "Neighbor to display information about\n" |
| 13229 | "Neighbor to display information about\n" |
| 13230 | "Display information received from a BGP neighbor\n" |
| 13231 | "Display the prefixlist filter\n") |
| 13232 | { |
| 13233 | char name[BUFSIZ]; |
| 13234 | union sockunion su; |
| 13235 | struct peer *peer; |
| 13236 | int count, ret; |
| 13237 | |
| 13238 | ret = str2sockunion (argv[1], &su); |
| 13239 | if (ret < 0) |
| 13240 | { |
| 13241 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13242 | return CMD_WARNING; |
| 13243 | } |
| 13244 | |
| 13245 | peer = peer_lookup (NULL, &su); |
| 13246 | if (! peer) |
| 13247 | return CMD_WARNING; |
| 13248 | |
| 13249 | if (strncmp (argv[0], "m", 1) == 0) |
| 13250 | { |
| 13251 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 13252 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13253 | if (count) |
| 13254 | { |
| 13255 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 13256 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13257 | } |
| 13258 | } |
| 13259 | else |
| 13260 | { |
| 13261 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 13262 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13263 | if (count) |
| 13264 | { |
| 13265 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 13266 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13267 | } |
| 13268 | } |
| 13269 | |
| 13270 | return CMD_SUCCESS; |
| 13271 | } |
| 13272 | |
| 13273 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 13274 | show_bgp_neighbor_received_routes_cmd, |
| 13275 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 13276 | SHOW_STR |
| 13277 | BGP_STR |
| 13278 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13279 | "Neighbor to display information about\n" |
| 13280 | "Neighbor to display information about\n" |
| 13281 | "Display the received routes from neighbor\n") |
| 13282 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13283 | DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter, |
| 13284 | show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd, |
| 13285 | "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13286 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13287 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13288 | IP_STR |
| 13289 | "Address Family modifier\n" |
| 13290 | "Address Family modifier\n" |
| 13291 | "Address Family modifier\n" |
| 13292 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13293 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13294 | "Neighbor to display information about\n" |
| 13295 | "Neighbor to display information about\n" |
| 13296 | "Display information received from a BGP neighbor\n" |
| 13297 | "Display the prefixlist filter\n") |
| 13298 | { |
| 13299 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13300 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13301 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13302 | int count, ret; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13303 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13304 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13305 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13306 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13307 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13308 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13309 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13310 | ret = str2sockunion (argv[1], &su); |
| 13311 | if (ret < 0) |
| 13312 | { |
| 13313 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13314 | return CMD_WARNING; |
| 13315 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13316 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13317 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13318 | if (! peer) |
| 13319 | return CMD_WARNING; |
| 13320 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13321 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi); |
| 13322 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13323 | if (count) { |
| 13324 | vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE); |
| 13325 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13326 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13327 | |
| 13328 | return CMD_SUCCESS; |
| 13329 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13330 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13331 | DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter, |
| 13332 | show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd, |
| 13333 | "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13334 | SHOW_STR |
| 13335 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13336 | IP_STR |
| 13337 | "Address Family modifier\n" |
| 13338 | "Address Family modifier\n" |
| 13339 | "Address Family modifier\n" |
| 13340 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13341 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13342 | "Neighbor to display information about\n" |
| 13343 | "Neighbor to display information about\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13344 | "Display information received from a BGP neighbor\n" |
| 13345 | "Display the prefixlist filter\n") |
| 13346 | { |
| 13347 | char name[BUFSIZ]; |
| 13348 | union sockunion su; |
| 13349 | struct peer *peer; |
| 13350 | int count, ret; |
| 13351 | safi_t safi; |
| 13352 | |
| 13353 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13354 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13355 | return CMD_WARNING; |
| 13356 | } |
| 13357 | |
| 13358 | ret = str2sockunion (argv[1], &su); |
| 13359 | if (ret < 0) |
| 13360 | { |
| 13361 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13362 | return CMD_WARNING; |
| 13363 | } |
| 13364 | |
| 13365 | peer = peer_lookup (NULL, &su); |
| 13366 | if (! peer) |
| 13367 | return CMD_WARNING; |
| 13368 | |
| 13369 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi); |
| 13370 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13371 | if (count) { |
| 13372 | vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE); |
| 13373 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13374 | } |
| 13375 | |
| 13376 | return CMD_SUCCESS; |
| 13377 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13378 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13379 | DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13380 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 13381 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13382 | SHOW_STR |
| 13383 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13384 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13385 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13386 | "Neighbor to display information about\n" |
| 13387 | "Neighbor to display information about\n" |
| 13388 | "Display information received from a BGP neighbor\n" |
| 13389 | "Display the prefixlist filter\n") |
| 13390 | { |
| 13391 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13392 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13393 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13394 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13395 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13396 | ret = str2sockunion (argv[0], &su); |
| 13397 | if (ret < 0) |
| 13398 | { |
| 13399 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 13400 | return CMD_WARNING; |
| 13401 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13402 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13403 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13404 | if (! peer) |
| 13405 | return CMD_WARNING; |
| 13406 | |
| 13407 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 13408 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13409 | if (count) |
| 13410 | { |
| 13411 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 13412 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13413 | } |
| 13414 | |
| 13415 | return CMD_SUCCESS; |
| 13416 | } |
| 13417 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13418 | DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13419 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 13420 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13421 | SHOW_STR |
| 13422 | BGP_STR |
| 13423 | "BGP view\n" |
| 13424 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13425 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13426 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13427 | "Neighbor to display information about\n" |
| 13428 | "Neighbor to display information about\n" |
| 13429 | "Display information received from a BGP neighbor\n" |
| 13430 | "Display the prefixlist filter\n") |
| 13431 | { |
| 13432 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13433 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13434 | struct peer *peer; |
| 13435 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13436 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13437 | |
| 13438 | /* BGP structure lookup. */ |
| 13439 | bgp = bgp_lookup_by_name (argv[0]); |
| 13440 | if (bgp == NULL) |
| 13441 | { |
| 13442 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13443 | return CMD_WARNING; |
| 13444 | } |
| 13445 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13446 | ret = str2sockunion (argv[1], &su); |
| 13447 | if (ret < 0) |
| 13448 | { |
| 13449 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13450 | return CMD_WARNING; |
| 13451 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13452 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13453 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13454 | if (! peer) |
| 13455 | return CMD_WARNING; |
| 13456 | |
| 13457 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 13458 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13459 | if (count) |
| 13460 | { |
| 13461 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 13462 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13463 | } |
| 13464 | |
| 13465 | return CMD_SUCCESS; |
| 13466 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 13467 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 13468 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13469 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13470 | safi_t safi, enum bgp_show_type type) |
| 13471 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13472 | if (! peer || ! peer->afc[afi][safi]) |
| 13473 | { |
| 13474 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13475 | return CMD_WARNING; |
| 13476 | } |
| 13477 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 13478 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13479 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13480 | DEFUN (show_ip_bgp_neighbor_routes, |
| 13481 | show_ip_bgp_neighbor_routes_cmd, |
| 13482 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 13483 | SHOW_STR |
| 13484 | IP_STR |
| 13485 | BGP_STR |
| 13486 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13487 | "Neighbor to display information about\n" |
| 13488 | "Neighbor to display information about\n" |
| 13489 | "Display routes learned from neighbor\n") |
| 13490 | { |
| 13491 | struct peer *peer; |
| 13492 | |
| 13493 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13494 | if (! peer) |
| 13495 | return CMD_WARNING; |
| 13496 | |
| 13497 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13498 | bgp_show_type_neighbor); |
| 13499 | } |
| 13500 | |
| 13501 | DEFUN (show_ip_bgp_neighbor_flap, |
| 13502 | show_ip_bgp_neighbor_flap_cmd, |
| 13503 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 13504 | SHOW_STR |
| 13505 | IP_STR |
| 13506 | BGP_STR |
| 13507 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13508 | "Neighbor to display information about\n" |
| 13509 | "Neighbor to display information about\n" |
| 13510 | "Display flap statistics of the routes learned from neighbor\n") |
| 13511 | { |
| 13512 | struct peer *peer; |
| 13513 | |
| 13514 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13515 | if (! peer) |
| 13516 | return CMD_WARNING; |
| 13517 | |
| 13518 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13519 | bgp_show_type_flap_neighbor); |
| 13520 | } |
| 13521 | |
| 13522 | DEFUN (show_ip_bgp_neighbor_damp, |
| 13523 | show_ip_bgp_neighbor_damp_cmd, |
| 13524 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 13525 | SHOW_STR |
| 13526 | IP_STR |
| 13527 | BGP_STR |
| 13528 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13529 | "Neighbor to display information about\n" |
| 13530 | "Neighbor to display information about\n" |
| 13531 | "Display the dampened routes received from neighbor\n") |
| 13532 | { |
| 13533 | struct peer *peer; |
| 13534 | |
| 13535 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13536 | if (! peer) |
| 13537 | return CMD_WARNING; |
| 13538 | |
| 13539 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13540 | bgp_show_type_damp_neighbor); |
| 13541 | } |
| 13542 | |
| 13543 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 13544 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 13545 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 13546 | SHOW_STR |
| 13547 | IP_STR |
| 13548 | BGP_STR |
| 13549 | "Address family\n" |
| 13550 | "Address Family modifier\n" |
| 13551 | "Address Family modifier\n" |
| 13552 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13553 | "Neighbor to display information about\n" |
| 13554 | "Neighbor to display information about\n" |
| 13555 | "Display routes learned from neighbor\n") |
| 13556 | { |
| 13557 | struct peer *peer; |
| 13558 | |
| 13559 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13560 | if (! peer) |
| 13561 | return CMD_WARNING; |
| 13562 | |
| 13563 | if (strncmp (argv[0], "m", 1) == 0) |
| 13564 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
| 13565 | bgp_show_type_neighbor); |
| 13566 | |
| 13567 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13568 | bgp_show_type_neighbor); |
| 13569 | } |
| 13570 | |
| 13571 | DEFUN (show_ip_bgp_view_rsclient, |
| 13572 | show_ip_bgp_view_rsclient_cmd, |
| 13573 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 13574 | SHOW_STR |
| 13575 | IP_STR |
| 13576 | BGP_STR |
| 13577 | "BGP view\n" |
| 13578 | "View name\n" |
| 13579 | "Information about Route Server Client\n" |
| 13580 | NEIGHBOR_ADDR_STR) |
| 13581 | { |
| 13582 | struct bgp_table *table; |
| 13583 | struct peer *peer; |
| 13584 | |
| 13585 | if (argc == 2) |
| 13586 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13587 | else |
| 13588 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13589 | |
| 13590 | if (! peer) |
| 13591 | return CMD_WARNING; |
| 13592 | |
| 13593 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 13594 | { |
| 13595 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13596 | VTY_NEWLINE); |
| 13597 | return CMD_WARNING; |
| 13598 | } |
| 13599 | |
| 13600 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 13601 | PEER_FLAG_RSERVER_CLIENT)) |
| 13602 | { |
| 13603 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13604 | VTY_NEWLINE); |
| 13605 | return CMD_WARNING; |
| 13606 | } |
| 13607 | |
| 13608 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 13609 | |
| 13610 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 13611 | } |
| 13612 | |
| 13613 | ALIAS (show_ip_bgp_view_rsclient, |
| 13614 | show_ip_bgp_rsclient_cmd, |
| 13615 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 13616 | SHOW_STR |
| 13617 | IP_STR |
| 13618 | BGP_STR |
| 13619 | "Information about Route Server Client\n" |
| 13620 | NEIGHBOR_ADDR_STR) |
| 13621 | |
| 13622 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 13623 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 13624 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 13625 | SHOW_STR |
| 13626 | BGP_STR |
| 13627 | "BGP view\n" |
| 13628 | "View name\n" |
| 13629 | "Address family\n" |
| 13630 | "Address Family modifier\n" |
| 13631 | "Address Family modifier\n" |
| 13632 | "Information about Route Server Client\n" |
| 13633 | NEIGHBOR_ADDR_STR) |
| 13634 | { |
| 13635 | struct bgp_table *table; |
| 13636 | struct peer *peer; |
| 13637 | safi_t safi; |
| 13638 | |
| 13639 | if (argc == 3) { |
| 13640 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 13641 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13642 | } else { |
| 13643 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13644 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13645 | } |
| 13646 | |
| 13647 | if (! peer) |
| 13648 | return CMD_WARNING; |
| 13649 | |
| 13650 | if (! peer->afc[AFI_IP][safi]) |
| 13651 | { |
| 13652 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13653 | VTY_NEWLINE); |
| 13654 | return CMD_WARNING; |
| 13655 | } |
| 13656 | |
| 13657 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 13658 | PEER_FLAG_RSERVER_CLIENT)) |
| 13659 | { |
| 13660 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13661 | VTY_NEWLINE); |
| 13662 | return CMD_WARNING; |
| 13663 | } |
| 13664 | |
| 13665 | table = peer->rib[AFI_IP][safi]; |
| 13666 | |
| 13667 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 13668 | } |
| 13669 | |
| 13670 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 13671 | show_bgp_ipv4_safi_rsclient_cmd, |
| 13672 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 13673 | SHOW_STR |
| 13674 | BGP_STR |
| 13675 | "Address family\n" |
| 13676 | "Address Family modifier\n" |
| 13677 | "Address Family modifier\n" |
| 13678 | "Information about Route Server Client\n" |
| 13679 | NEIGHBOR_ADDR_STR) |
| 13680 | |
| 13681 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 13682 | show_ip_bgp_view_rsclient_route_cmd, |
| 13683 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13684 | SHOW_STR |
| 13685 | IP_STR |
| 13686 | BGP_STR |
| 13687 | "BGP view\n" |
| 13688 | "View name\n" |
| 13689 | "Information about Route Server Client\n" |
| 13690 | NEIGHBOR_ADDR_STR |
| 13691 | "Network in the BGP routing table to display\n") |
| 13692 | { |
| 13693 | struct bgp *bgp; |
| 13694 | struct peer *peer; |
| 13695 | |
| 13696 | /* BGP structure lookup. */ |
| 13697 | if (argc == 3) |
| 13698 | { |
| 13699 | bgp = bgp_lookup_by_name (argv[0]); |
| 13700 | if (bgp == NULL) |
| 13701 | { |
| 13702 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13703 | return CMD_WARNING; |
| 13704 | } |
| 13705 | } |
| 13706 | else |
| 13707 | { |
| 13708 | bgp = bgp_get_default (); |
| 13709 | if (bgp == NULL) |
| 13710 | { |
| 13711 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 13712 | return CMD_WARNING; |
| 13713 | } |
| 13714 | } |
| 13715 | |
| 13716 | if (argc == 3) |
| 13717 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13718 | else |
| 13719 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13720 | |
| 13721 | if (! peer) |
| 13722 | return CMD_WARNING; |
| 13723 | |
| 13724 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 13725 | { |
| 13726 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13727 | VTY_NEWLINE); |
| 13728 | return CMD_WARNING; |
| 13729 | } |
| 13730 | |
| 13731 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 13732 | PEER_FLAG_RSERVER_CLIENT)) |
| 13733 | { |
| 13734 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13735 | VTY_NEWLINE); |
| 13736 | return CMD_WARNING; |
| 13737 | } |
| 13738 | |
| 13739 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 13740 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 13741 | AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13742 | } |
| 13743 | |
| 13744 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 13745 | show_ip_bgp_rsclient_route_cmd, |
| 13746 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13747 | SHOW_STR |
| 13748 | IP_STR |
| 13749 | BGP_STR |
| 13750 | "Information about Route Server Client\n" |
| 13751 | NEIGHBOR_ADDR_STR |
| 13752 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13753 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13754 | DEFUN (show_bgp_ipv4_safi_neighbor_flap, |
| 13755 | show_bgp_ipv4_safi_neighbor_flap_cmd, |
| 13756 | "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13757 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13758 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13759 | "Address Family Modifier\n" |
| 13760 | "Address Family Modifier\n" |
| 13761 | "Address Family Modifier\n" |
| 13762 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13763 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13764 | "Neighbor to display information about\n" |
| 13765 | "Neighbor to display information about\n" |
| 13766 | "Display flap statistics of the routes learned from neighbor\n") |
| 13767 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13768 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13769 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13770 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13771 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13772 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13773 | return CMD_WARNING; |
| 13774 | } |
| 13775 | |
| 13776 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13777 | if (! peer) |
| 13778 | return CMD_WARNING; |
| 13779 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13780 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13781 | bgp_show_type_flap_neighbor); |
| 13782 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13783 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13784 | DEFUN (show_bgp_ipv6_safi_neighbor_flap, |
| 13785 | show_bgp_ipv6_safi_neighbor_flap_cmd, |
| 13786 | "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13787 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13788 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13789 | "Address Family Modifier\n" |
| 13790 | "Address Family Modifier\n" |
| 13791 | "Address Family Modifier\n" |
| 13792 | "Address Family Modifier\n" |
| 13793 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13794 | "Neighbor to display information about\n" |
| 13795 | "Neighbor to display information about\n" |
| 13796 | "Display flap statistics of the routes learned from neighbor\n") |
| 13797 | { |
| 13798 | struct peer *peer; |
| 13799 | safi_t safi; |
| 13800 | |
| 13801 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13802 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13803 | return CMD_WARNING; |
| 13804 | } |
| 13805 | |
| 13806 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13807 | if (! peer) |
| 13808 | return CMD_WARNING; |
| 13809 | |
| 13810 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13811 | bgp_show_type_flap_neighbor); |
| 13812 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13813 | |
| 13814 | DEFUN (show_bgp_ipv4_safi_neighbor_damp, |
| 13815 | show_bgp_ipv4_safi_neighbor_damp_cmd, |
| 13816 | "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 13817 | SHOW_STR |
| 13818 | BGP_STR |
| 13819 | "Address Family Modifier\n" |
| 13820 | "Address Family Modifier\n" |
| 13821 | "Address Family Modifier\n" |
| 13822 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13823 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13824 | "Neighbor to display information about\n" |
| 13825 | "Neighbor to display information about\n" |
| 13826 | "Display the dampened routes received from neighbor\n") |
| 13827 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13828 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13829 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13830 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13831 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13832 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13833 | return CMD_WARNING; |
| 13834 | } |
| 13835 | |
| 13836 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13837 | if (! peer) |
| 13838 | return CMD_WARNING; |
| 13839 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13840 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13841 | bgp_show_type_damp_neighbor); |
| 13842 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13843 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13844 | DEFUN (show_bgp_ipv6_safi_neighbor_damp, |
| 13845 | show_bgp_ipv6_safi_neighbor_damp_cmd, |
| 13846 | "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13847 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13848 | BGP_STR |
| 13849 | "Address Family Modifier\n" |
| 13850 | "Address Family Modifier\n" |
| 13851 | "Address Family Modifier\n" |
| 13852 | "Address Family Modifier\n" |
| 13853 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13854 | "Neighbor to display information about\n" |
| 13855 | "Neighbor to display information about\n" |
| 13856 | "Display the dampened routes received from neighbor\n") |
| 13857 | { |
| 13858 | struct peer *peer; |
| 13859 | safi_t safi; |
| 13860 | |
| 13861 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13862 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13863 | return CMD_WARNING; |
| 13864 | } |
| 13865 | |
| 13866 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13867 | if (! peer) |
| 13868 | return CMD_WARNING; |
| 13869 | |
| 13870 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13871 | bgp_show_type_damp_neighbor); |
| 13872 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13873 | |
| 13874 | DEFUN (show_bgp_ipv4_safi_neighbor_routes, |
| 13875 | show_bgp_ipv4_safi_neighbor_routes_cmd, |
| 13876 | "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 13877 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13878 | BGP_STR |
| 13879 | "Address family\n" |
| 13880 | "Address Family modifier\n" |
| 13881 | "Address Family modifier\n" |
| 13882 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13883 | "Neighbor to display information about\n" |
| 13884 | "Neighbor to display information about\n" |
| 13885 | "Display routes learned from neighbor\n") |
| 13886 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13887 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13888 | safi_t safi; |
| 13889 | |
| 13890 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13891 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13892 | return CMD_WARNING; |
| 13893 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13894 | |
| 13895 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13896 | if (! peer) |
| 13897 | return CMD_WARNING; |
| 13898 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13899 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13900 | bgp_show_type_neighbor); |
| 13901 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13902 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13903 | DEFUN (show_bgp_ipv6_safi_neighbor_routes, |
| 13904 | show_bgp_ipv6_safi_neighbor_routes_cmd, |
| 13905 | "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13906 | SHOW_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13907 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13908 | "Address family\n" |
| 13909 | "Address Family modifier\n" |
| 13910 | "Address Family modifier\n" |
| 13911 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13912 | NEIGHBOR_ADDR_STR |
| 13913 | NEIGHBOR_ADDR_STR |
| 13914 | "Display routes learned from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13915 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13916 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13917 | safi_t safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13918 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13919 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13920 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13921 | return CMD_WARNING; |
| 13922 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13923 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13924 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13925 | if (! peer) |
| 13926 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13927 | |
| 13928 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13929 | bgp_show_type_neighbor); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13930 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13931 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13932 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 13933 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 13934 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13935 | SHOW_STR |
| 13936 | BGP_STR |
| 13937 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 13938 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13939 | "Address family\n" |
| 13940 | "Address Family modifier\n" |
| 13941 | "Address Family modifier\n" |
| 13942 | "Information about Route Server Client\n" |
| 13943 | NEIGHBOR_ADDR_STR |
| 13944 | "Network in the BGP routing table to display\n") |
| 13945 | { |
| 13946 | struct bgp *bgp; |
| 13947 | struct peer *peer; |
| 13948 | safi_t safi; |
| 13949 | |
| 13950 | /* BGP structure lookup. */ |
| 13951 | if (argc == 4) |
| 13952 | { |
| 13953 | bgp = bgp_lookup_by_name (argv[0]); |
| 13954 | if (bgp == NULL) |
| 13955 | { |
| 13956 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13957 | return CMD_WARNING; |
| 13958 | } |
| 13959 | } |
| 13960 | else |
| 13961 | { |
| 13962 | bgp = bgp_get_default (); |
| 13963 | if (bgp == NULL) |
| 13964 | { |
| 13965 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 13966 | return CMD_WARNING; |
| 13967 | } |
| 13968 | } |
| 13969 | |
| 13970 | if (argc == 4) { |
| 13971 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 13972 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13973 | } else { |
| 13974 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13975 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13976 | } |
| 13977 | |
| 13978 | if (! peer) |
| 13979 | return CMD_WARNING; |
| 13980 | |
| 13981 | if (! peer->afc[AFI_IP][safi]) |
| 13982 | { |
| 13983 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13984 | VTY_NEWLINE); |
| 13985 | return CMD_WARNING; |
| 13986 | } |
| 13987 | |
| 13988 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 13989 | PEER_FLAG_RSERVER_CLIENT)) |
| 13990 | { |
| 13991 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13992 | VTY_NEWLINE); |
| 13993 | return CMD_WARNING; |
| 13994 | } |
| 13995 | |
| 13996 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 13997 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 13998 | AFI_IP, safi, NULL, 0, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13999 | } |
| 14000 | |
| 14001 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 14002 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 14003 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 14004 | SHOW_STR |
| 14005 | BGP_STR |
| 14006 | "Address family\n" |
| 14007 | "Address Family modifier\n" |
| 14008 | "Address Family modifier\n" |
| 14009 | "Information about Route Server Client\n" |
| 14010 | NEIGHBOR_ADDR_STR |
| 14011 | "Network in the BGP routing table to display\n") |
| 14012 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14013 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14014 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 14015 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 14016 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14017 | SHOW_STR |
| 14018 | BGP_STR |
| 14019 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14020 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14021 | "Address family\n" |
| 14022 | "Address Family modifier\n" |
| 14023 | "Address Family modifier\n" |
| 14024 | "Information about Route Server Client\n" |
| 14025 | NEIGHBOR_ADDR_STR |
| 14026 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 14027 | { |
| 14028 | struct bgp *bgp; |
| 14029 | struct peer *peer; |
| 14030 | safi_t safi; |
| 14031 | |
| 14032 | /* BGP structure lookup. */ |
| 14033 | if (argc == 4) |
| 14034 | { |
| 14035 | bgp = bgp_lookup_by_name (argv[0]); |
| 14036 | if (bgp == NULL) |
| 14037 | { |
| 14038 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14039 | return CMD_WARNING; |
| 14040 | } |
| 14041 | } |
| 14042 | else |
| 14043 | { |
| 14044 | bgp = bgp_get_default (); |
| 14045 | if (bgp == NULL) |
| 14046 | { |
| 14047 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14048 | return CMD_WARNING; |
| 14049 | } |
| 14050 | } |
| 14051 | |
| 14052 | if (argc == 4) { |
| 14053 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14054 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14055 | } else { |
| 14056 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14057 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14058 | } |
| 14059 | |
| 14060 | if (! peer) |
| 14061 | return CMD_WARNING; |
| 14062 | |
| 14063 | if (! peer->afc[AFI_IP][safi]) |
| 14064 | { |
| 14065 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14066 | VTY_NEWLINE); |
| 14067 | return CMD_WARNING; |
| 14068 | } |
| 14069 | |
| 14070 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 14071 | PEER_FLAG_RSERVER_CLIENT)) |
| 14072 | { |
| 14073 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14074 | VTY_NEWLINE); |
| 14075 | return CMD_WARNING; |
| 14076 | } |
| 14077 | |
| 14078 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 14079 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14080 | AFI_IP, safi, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14081 | } |
| 14082 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14083 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 14084 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 14085 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14086 | SHOW_STR |
| 14087 | IP_STR |
| 14088 | BGP_STR |
| 14089 | "BGP view\n" |
| 14090 | "View name\n" |
| 14091 | "Information about Route Server Client\n" |
| 14092 | NEIGHBOR_ADDR_STR |
| 14093 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 14094 | { |
| 14095 | struct bgp *bgp; |
| 14096 | struct peer *peer; |
| 14097 | |
| 14098 | /* BGP structure lookup. */ |
| 14099 | if (argc == 3) |
| 14100 | { |
| 14101 | bgp = bgp_lookup_by_name (argv[0]); |
| 14102 | if (bgp == NULL) |
| 14103 | { |
| 14104 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14105 | return CMD_WARNING; |
| 14106 | } |
| 14107 | } |
| 14108 | else |
| 14109 | { |
| 14110 | bgp = bgp_get_default (); |
| 14111 | if (bgp == NULL) |
| 14112 | { |
| 14113 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14114 | return CMD_WARNING; |
| 14115 | } |
| 14116 | } |
| 14117 | |
| 14118 | if (argc == 3) |
| 14119 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14120 | else |
| 14121 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14122 | |
| 14123 | if (! peer) |
| 14124 | return CMD_WARNING; |
| 14125 | |
| 14126 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 14127 | { |
| 14128 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14129 | VTY_NEWLINE); |
| 14130 | return CMD_WARNING; |
| 14131 | } |
| 14132 | |
| 14133 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 14134 | PEER_FLAG_RSERVER_CLIENT)) |
| 14135 | { |
| 14136 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14137 | VTY_NEWLINE); |
| 14138 | return CMD_WARNING; |
| 14139 | } |
| 14140 | |
| 14141 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 14142 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14143 | AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14144 | } |
| 14145 | |
| 14146 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 14147 | show_ip_bgp_rsclient_prefix_cmd, |
| 14148 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14149 | SHOW_STR |
| 14150 | IP_STR |
| 14151 | BGP_STR |
| 14152 | "Information about Route Server Client\n" |
| 14153 | NEIGHBOR_ADDR_STR |
| 14154 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 14155 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14156 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 14157 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 14158 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14159 | SHOW_STR |
| 14160 | BGP_STR |
| 14161 | "Address family\n" |
| 14162 | "Address Family modifier\n" |
| 14163 | "Address Family modifier\n" |
| 14164 | "Information about Route Server Client\n" |
| 14165 | NEIGHBOR_ADDR_STR |
| 14166 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14167 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14168 | DEFUN (show_bgp_view_ipv6_neighbor_routes, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14169 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 14170 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14171 | SHOW_STR |
| 14172 | BGP_STR |
| 14173 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14174 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14175 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14176 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14177 | "Neighbor to display information about\n" |
| 14178 | "Neighbor to display information about\n" |
| 14179 | "Display routes learned from neighbor\n") |
| 14180 | { |
| 14181 | struct peer *peer; |
| 14182 | |
| 14183 | if (argc == 2) |
| 14184 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14185 | else |
| 14186 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14187 | |
| 14188 | if (! peer) |
| 14189 | return CMD_WARNING; |
| 14190 | |
| 14191 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14192 | bgp_show_type_neighbor); |
| 14193 | } |
| 14194 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14195 | DEFUN (show_bgp_view_neighbor_damp, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14196 | show_bgp_view_neighbor_damp_cmd, |
| 14197 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14198 | SHOW_STR |
| 14199 | BGP_STR |
| 14200 | "BGP view\n" |
| 14201 | "View name\n" |
| 14202 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14203 | "Neighbor to display information about\n" |
| 14204 | "Neighbor to display information about\n" |
| 14205 | "Display the dampened routes received from neighbor\n") |
| 14206 | { |
| 14207 | struct peer *peer; |
| 14208 | |
| 14209 | if (argc == 2) |
| 14210 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14211 | else |
| 14212 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14213 | |
| 14214 | if (! peer) |
| 14215 | return CMD_WARNING; |
| 14216 | |
| 14217 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14218 | bgp_show_type_damp_neighbor); |
| 14219 | } |
| 14220 | |
| 14221 | DEFUN (show_bgp_view_ipv6_neighbor_damp, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14222 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 14223 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14224 | SHOW_STR |
| 14225 | BGP_STR |
| 14226 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14227 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14228 | "Address family\n" |
| 14229 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14230 | "Neighbor to display information about\n" |
| 14231 | "Neighbor to display information about\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14232 | "Display the dampened routes received from neighbor\n") |
| 14233 | { |
| 14234 | struct peer *peer; |
| 14235 | |
| 14236 | if (argc == 2) |
| 14237 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14238 | else |
| 14239 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14240 | |
| 14241 | if (! peer) |
| 14242 | return CMD_WARNING; |
| 14243 | |
| 14244 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14245 | bgp_show_type_damp_neighbor); |
| 14246 | } |
| 14247 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14248 | DEFUN (show_bgp_view_ipv6_neighbor_flap, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14249 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 14250 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14251 | SHOW_STR |
| 14252 | BGP_STR |
| 14253 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14254 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14255 | "Address family\n" |
| 14256 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14257 | "Neighbor to display information about\n" |
| 14258 | "Neighbor to display information about\n" |
| 14259 | "Display the dampened routes received from neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14260 | { |
| 14261 | struct peer *peer; |
| 14262 | |
| 14263 | if (argc == 2) |
| 14264 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14265 | else |
| 14266 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14267 | |
| 14268 | if (! peer) |
| 14269 | return CMD_WARNING; |
| 14270 | |
| 14271 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14272 | bgp_show_type_flap_neighbor); |
| 14273 | } |
| 14274 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14275 | DEFUN (show_bgp_view_neighbor_flap, |
| 14276 | show_bgp_view_neighbor_flap_cmd, |
| 14277 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14278 | SHOW_STR |
| 14279 | BGP_STR |
| 14280 | "BGP view\n" |
| 14281 | "View name\n" |
| 14282 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14283 | "Neighbor to display information about\n" |
| 14284 | "Neighbor to display information about\n" |
| 14285 | "Display flap statistics of the routes learned from neighbor\n") |
| 14286 | { |
| 14287 | struct peer *peer; |
| 14288 | |
| 14289 | if (argc == 2) |
| 14290 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14291 | else |
| 14292 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14293 | |
| 14294 | if (! peer) |
| 14295 | return CMD_WARNING; |
| 14296 | |
| 14297 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14298 | bgp_show_type_flap_neighbor); |
| 14299 | } |
| 14300 | |
| 14301 | ALIAS (show_bgp_view_neighbor_flap, |
| 14302 | show_bgp_neighbor_flap_cmd, |
| 14303 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14304 | SHOW_STR |
| 14305 | BGP_STR |
| 14306 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14307 | "Neighbor to display information about\n" |
| 14308 | "Neighbor to display information about\n" |
| 14309 | "Display flap statistics of the routes learned from neighbor\n") |
| 14310 | |
| 14311 | ALIAS (show_bgp_view_neighbor_damp, |
| 14312 | show_bgp_neighbor_damp_cmd, |
| 14313 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14314 | SHOW_STR |
| 14315 | BGP_STR |
| 14316 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14317 | "Neighbor to display information about\n" |
| 14318 | "Neighbor to display information about\n" |
| 14319 | "Display the dampened routes received from neighbor\n") |
| 14320 | |
| 14321 | DEFUN (show_bgp_view_neighbor_routes, |
| 14322 | show_bgp_view_neighbor_routes_cmd, |
| 14323 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 14324 | SHOW_STR |
| 14325 | BGP_STR |
| 14326 | "BGP view\n" |
| 14327 | "View name\n" |
| 14328 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14329 | "Neighbor to display information about\n" |
| 14330 | "Neighbor to display information about\n" |
| 14331 | "Display routes learned from neighbor\n") |
| 14332 | { |
| 14333 | struct peer *peer; |
| 14334 | |
| 14335 | if (argc == 2) |
| 14336 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14337 | else |
| 14338 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14339 | |
| 14340 | if (! peer) |
| 14341 | return CMD_WARNING; |
| 14342 | |
| 14343 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14344 | bgp_show_type_neighbor); |
| 14345 | } |
| 14346 | |
| 14347 | ALIAS (show_bgp_view_neighbor_routes, |
| 14348 | show_bgp_neighbor_routes_cmd, |
| 14349 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14350 | SHOW_STR |
| 14351 | BGP_STR |
| 14352 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14353 | "Neighbor to display information about\n" |
| 14354 | "Neighbor to display information about\n" |
| 14355 | "Display routes learned from neighbor\n") |
| 14356 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14357 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14358 | show_bgp_ipv6_neighbor_routes_cmd, |
| 14359 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 14360 | SHOW_STR |
| 14361 | BGP_STR |
| 14362 | "Address family\n" |
| 14363 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14364 | "Neighbor to display information about\n" |
| 14365 | "Neighbor to display information about\n" |
| 14366 | "Display routes learned from neighbor\n") |
| 14367 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14368 | /* old command */ |
| 14369 | ALIAS (show_bgp_view_neighbor_routes, |
| 14370 | ipv6_bgp_neighbor_routes_cmd, |
| 14371 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14372 | SHOW_STR |
| 14373 | IPV6_STR |
| 14374 | BGP_STR |
| 14375 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14376 | "Neighbor to display information about\n" |
| 14377 | "Neighbor to display information about\n" |
| 14378 | "Display routes learned from neighbor\n") |
| 14379 | |
| 14380 | /* old command */ |
| 14381 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 14382 | ipv6_mbgp_neighbor_routes_cmd, |
| 14383 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14384 | SHOW_STR |
| 14385 | IPV6_STR |
| 14386 | MBGP_STR |
| 14387 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14388 | "Neighbor to display information about\n" |
| 14389 | "Neighbor to display information about\n" |
| 14390 | "Display routes learned from neighbor\n") |
| 14391 | { |
| 14392 | struct peer *peer; |
| 14393 | |
| 14394 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14395 | if (! peer) |
| 14396 | return CMD_WARNING; |
| 14397 | |
| 14398 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
| 14399 | bgp_show_type_neighbor); |
| 14400 | } |
| 14401 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14402 | ALIAS (show_bgp_view_neighbor_flap, |
| 14403 | show_bgp_ipv6_neighbor_flap_cmd, |
| 14404 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14405 | SHOW_STR |
| 14406 | BGP_STR |
| 14407 | "Address family\n" |
| 14408 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14409 | "Neighbor to display information about\n" |
| 14410 | "Neighbor to display information about\n" |
| 14411 | "Display flap statistics of the routes learned from neighbor\n") |
| 14412 | |
| 14413 | ALIAS (show_bgp_view_neighbor_damp, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14414 | show_bgp_ipv6_neighbor_damp_cmd, |
| 14415 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14416 | SHOW_STR |
| 14417 | BGP_STR |
| 14418 | "Address family\n" |
| 14419 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14420 | "Neighbor to display information about\n" |
| 14421 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 14422 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14423 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14424 | DEFUN (show_bgp_view_rsclient, |
| 14425 | show_bgp_view_rsclient_cmd, |
| 14426 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 14427 | SHOW_STR |
| 14428 | BGP_STR |
| 14429 | "BGP view\n" |
| 14430 | "View name\n" |
| 14431 | "Information about Route Server Client\n" |
| 14432 | NEIGHBOR_ADDR_STR) |
| 14433 | { |
| 14434 | struct bgp_table *table; |
| 14435 | struct peer *peer; |
| 14436 | |
| 14437 | if (argc == 2) |
| 14438 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14439 | else |
| 14440 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14441 | |
| 14442 | if (! peer) |
| 14443 | return CMD_WARNING; |
| 14444 | |
| 14445 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14446 | { |
| 14447 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14448 | VTY_NEWLINE); |
| 14449 | return CMD_WARNING; |
| 14450 | } |
| 14451 | |
| 14452 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14453 | PEER_FLAG_RSERVER_CLIENT)) |
| 14454 | { |
| 14455 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14456 | VTY_NEWLINE); |
| 14457 | return CMD_WARNING; |
| 14458 | } |
| 14459 | |
| 14460 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 14461 | |
| 14462 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14463 | } |
| 14464 | |
| 14465 | ALIAS (show_bgp_view_rsclient, |
| 14466 | show_bgp_rsclient_cmd, |
| 14467 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 14468 | SHOW_STR |
| 14469 | BGP_STR |
| 14470 | "Information about Route Server Client\n" |
| 14471 | NEIGHBOR_ADDR_STR) |
| 14472 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14473 | DEFUN (show_bgp_view_ipv4_rsclient, |
| 14474 | show_bgp_view_ipv4_rsclient_cmd, |
| 14475 | "show bgp view WORD ipv4 rsclient (A.B.C.D|X:X::X:X)", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14476 | SHOW_STR |
| 14477 | BGP_STR |
| 14478 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14479 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14480 | "Address Family\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14481 | "Information about Route Server Client\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14482 | NEIGHBOR_ADDR_STR2) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14483 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14484 | struct bgp_table *table; |
| 14485 | struct peer *peer; |
| 14486 | |
| 14487 | if (argc == 2) |
| 14488 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14489 | else |
| 14490 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14491 | |
| 14492 | if (! peer) |
| 14493 | return CMD_WARNING; |
| 14494 | |
| 14495 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 14496 | { |
| 14497 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14498 | VTY_NEWLINE); |
| 14499 | return CMD_WARNING; |
| 14500 | } |
| 14501 | |
| 14502 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 14503 | PEER_FLAG_RSERVER_CLIENT)) |
| 14504 | { |
| 14505 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14506 | VTY_NEWLINE); |
| 14507 | return CMD_WARNING; |
| 14508 | } |
| 14509 | |
| 14510 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 14511 | |
| 14512 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14513 | } |
| 14514 | DEFUN (show_bgp_view_ipv6_rsclient, |
| 14515 | show_bgp_view_ipv6_rsclient_cmd, |
| 14516 | "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)", |
| 14517 | SHOW_STR |
| 14518 | BGP_STR |
| 14519 | "BGP view\n" |
| 14520 | "BGP view name\n" |
| 14521 | "Address Family\n" |
| 14522 | "Information about Route Server Client\n" |
| 14523 | NEIGHBOR_ADDR_STR2) |
| 14524 | { |
| 14525 | struct bgp_table *table; |
| 14526 | struct peer *peer; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14527 | |
| 14528 | if (argc == 2) |
| 14529 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14530 | else |
| 14531 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14532 | |
| 14533 | if (! peer) |
| 14534 | return CMD_WARNING; |
| 14535 | |
| 14536 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14537 | { |
| 14538 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14539 | VTY_NEWLINE); |
| 14540 | return CMD_WARNING; |
| 14541 | } |
| 14542 | |
| 14543 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14544 | PEER_FLAG_RSERVER_CLIENT)) |
| 14545 | { |
| 14546 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14547 | VTY_NEWLINE); |
| 14548 | return CMD_WARNING; |
| 14549 | } |
| 14550 | |
| 14551 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 14552 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 14553 | 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] | 14554 | } |
| 14555 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14556 | ALIAS (show_bgp_view_ipv4_rsclient, |
| 14557 | show_bgp_ipv4_rsclient_cmd, |
| 14558 | "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14559 | SHOW_STR |
| 14560 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14561 | "Address Family\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14562 | "Information about Route Server Client\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14563 | NEIGHBOR_ADDR_STR2) |
| 14564 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14565 | ALIAS (show_bgp_view_ipv6_rsclient, |
| 14566 | show_bgp_ipv6_rsclient_cmd, |
| 14567 | "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)", |
| 14568 | SHOW_STR |
| 14569 | BGP_STR |
| 14570 | "Address Family\n" |
| 14571 | "Information about Route Server Client\n" |
| 14572 | NEIGHBOR_ADDR_STR2) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14573 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14574 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 14575 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 14576 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 14577 | SHOW_STR |
| 14578 | BGP_STR |
| 14579 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14580 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14581 | "Address family\n" |
| 14582 | "Address Family modifier\n" |
| 14583 | "Address Family modifier\n" |
| 14584 | "Information about Route Server Client\n" |
| 14585 | NEIGHBOR_ADDR_STR) |
| 14586 | { |
| 14587 | struct bgp_table *table; |
| 14588 | struct peer *peer; |
| 14589 | safi_t safi; |
| 14590 | |
| 14591 | if (argc == 3) { |
| 14592 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14593 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14594 | } else { |
| 14595 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14596 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14597 | } |
| 14598 | |
| 14599 | if (! peer) |
| 14600 | return CMD_WARNING; |
| 14601 | |
| 14602 | if (! peer->afc[AFI_IP6][safi]) |
| 14603 | { |
| 14604 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14605 | VTY_NEWLINE); |
| 14606 | return CMD_WARNING; |
| 14607 | } |
| 14608 | |
| 14609 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 14610 | PEER_FLAG_RSERVER_CLIENT)) |
| 14611 | { |
| 14612 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14613 | VTY_NEWLINE); |
| 14614 | return CMD_WARNING; |
| 14615 | } |
| 14616 | |
| 14617 | table = peer->rib[AFI_IP6][safi]; |
| 14618 | |
| 14619 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14620 | } |
| 14621 | |
| 14622 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 14623 | show_bgp_ipv6_safi_rsclient_cmd, |
| 14624 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 14625 | SHOW_STR |
| 14626 | BGP_STR |
| 14627 | "Address family\n" |
| 14628 | "Address Family modifier\n" |
| 14629 | "Address Family modifier\n" |
| 14630 | "Information about Route Server Client\n" |
| 14631 | NEIGHBOR_ADDR_STR) |
| 14632 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14633 | DEFUN (show_bgp_view_rsclient_route, |
| 14634 | show_bgp_view_rsclient_route_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14635 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14636 | SHOW_STR |
| 14637 | BGP_STR |
| 14638 | "BGP view\n" |
| 14639 | "View name\n" |
| 14640 | "Information about Route Server Client\n" |
| 14641 | NEIGHBOR_ADDR_STR |
| 14642 | "Network in the BGP routing table to display\n") |
| 14643 | { |
| 14644 | struct bgp *bgp; |
| 14645 | struct peer *peer; |
| 14646 | |
| 14647 | /* BGP structure lookup. */ |
| 14648 | if (argc == 3) |
| 14649 | { |
| 14650 | bgp = bgp_lookup_by_name (argv[0]); |
| 14651 | if (bgp == NULL) |
| 14652 | { |
| 14653 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14654 | return CMD_WARNING; |
| 14655 | } |
| 14656 | } |
| 14657 | else |
| 14658 | { |
| 14659 | bgp = bgp_get_default (); |
| 14660 | if (bgp == NULL) |
| 14661 | { |
| 14662 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14663 | return CMD_WARNING; |
| 14664 | } |
| 14665 | } |
| 14666 | |
| 14667 | if (argc == 3) |
| 14668 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14669 | else |
| 14670 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14671 | |
| 14672 | if (! peer) |
| 14673 | return CMD_WARNING; |
| 14674 | |
| 14675 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14676 | { |
| 14677 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14678 | VTY_NEWLINE); |
| 14679 | return CMD_WARNING; |
| 14680 | } |
| 14681 | |
| 14682 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14683 | PEER_FLAG_RSERVER_CLIENT)) |
| 14684 | { |
| 14685 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14686 | VTY_NEWLINE); |
| 14687 | return CMD_WARNING; |
| 14688 | } |
| 14689 | |
| 14690 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14691 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14692 | AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14693 | } |
| 14694 | |
| 14695 | DEFUN (show_bgp_view_ipv6_rsclient_route, |
| 14696 | show_bgp_view_ipv6_rsclient_route_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14697 | "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14698 | SHOW_STR |
| 14699 | BGP_STR |
| 14700 | "BGP view\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14701 | "BGP view name\n" |
| 14702 | "IP6_STR" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14703 | "Information about Route Server Client\n" |
| 14704 | NEIGHBOR_ADDR_STR |
| 14705 | "Network in the BGP routing table to display\n") |
| 14706 | { |
| 14707 | struct bgp *bgp; |
| 14708 | struct peer *peer; |
| 14709 | |
| 14710 | /* BGP structure lookup. */ |
| 14711 | if (argc == 3) |
| 14712 | { |
| 14713 | bgp = bgp_lookup_by_name (argv[0]); |
| 14714 | if (bgp == NULL) |
| 14715 | { |
| 14716 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14717 | return CMD_WARNING; |
| 14718 | } |
| 14719 | } |
| 14720 | else |
| 14721 | { |
| 14722 | bgp = bgp_get_default (); |
| 14723 | if (bgp == NULL) |
| 14724 | { |
| 14725 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14726 | return CMD_WARNING; |
| 14727 | } |
| 14728 | } |
| 14729 | |
| 14730 | if (argc == 3) |
| 14731 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14732 | else |
| 14733 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14734 | |
| 14735 | if (! peer) |
| 14736 | return CMD_WARNING; |
| 14737 | |
| 14738 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14739 | { |
| 14740 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14741 | VTY_NEWLINE); |
| 14742 | return CMD_WARNING; |
| 14743 | } |
| 14744 | |
| 14745 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14746 | PEER_FLAG_RSERVER_CLIENT)) |
| 14747 | { |
| 14748 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14749 | VTY_NEWLINE); |
| 14750 | return CMD_WARNING; |
| 14751 | } |
| 14752 | |
| 14753 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14754 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14755 | AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14756 | } |
| 14757 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14758 | ALIAS (show_bgp_view_ipv6_rsclient_route, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14759 | show_bgp_rsclient_route_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14760 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14761 | SHOW_STR |
| 14762 | BGP_STR |
| 14763 | "Information about Route Server Client\n" |
| 14764 | NEIGHBOR_ADDR_STR |
| 14765 | "Network in the BGP routing table to display\n") |
| 14766 | |
| 14767 | ALIAS (show_bgp_view_ipv6_rsclient_route, |
| 14768 | show_bgp_ipv6_rsclient_route_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14769 | "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14770 | SHOW_STR |
| 14771 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14772 | IP6_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14773 | "Information about Route Server Client\n" |
| 14774 | NEIGHBOR_ADDR_STR |
| 14775 | "Network in the BGP routing table to display\n") |
| 14776 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14777 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 14778 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 14779 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14780 | SHOW_STR |
| 14781 | BGP_STR |
| 14782 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14783 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14784 | "Address family\n" |
| 14785 | "Address Family modifier\n" |
| 14786 | "Address Family modifier\n" |
| 14787 | "Information about Route Server Client\n" |
| 14788 | NEIGHBOR_ADDR_STR |
| 14789 | "Network in the BGP routing table to display\n") |
| 14790 | { |
| 14791 | struct bgp *bgp; |
| 14792 | struct peer *peer; |
| 14793 | safi_t safi; |
| 14794 | |
| 14795 | /* BGP structure lookup. */ |
| 14796 | if (argc == 4) |
| 14797 | { |
| 14798 | bgp = bgp_lookup_by_name (argv[0]); |
| 14799 | if (bgp == NULL) |
| 14800 | { |
| 14801 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14802 | return CMD_WARNING; |
| 14803 | } |
| 14804 | } |
| 14805 | else |
| 14806 | { |
| 14807 | bgp = bgp_get_default (); |
| 14808 | if (bgp == NULL) |
| 14809 | { |
| 14810 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14811 | return CMD_WARNING; |
| 14812 | } |
| 14813 | } |
| 14814 | |
| 14815 | if (argc == 4) { |
| 14816 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14817 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14818 | } else { |
| 14819 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14820 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14821 | } |
| 14822 | |
| 14823 | if (! peer) |
| 14824 | return CMD_WARNING; |
| 14825 | |
| 14826 | if (! peer->afc[AFI_IP6][safi]) |
| 14827 | { |
| 14828 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14829 | VTY_NEWLINE); |
| 14830 | return CMD_WARNING; |
| 14831 | } |
| 14832 | |
| 14833 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 14834 | PEER_FLAG_RSERVER_CLIENT)) |
| 14835 | { |
| 14836 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14837 | VTY_NEWLINE); |
| 14838 | return CMD_WARNING; |
| 14839 | } |
| 14840 | |
| 14841 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 14842 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14843 | AFI_IP6, safi, NULL, 0, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14844 | } |
| 14845 | |
| 14846 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 14847 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 14848 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14849 | SHOW_STR |
| 14850 | BGP_STR |
| 14851 | "Address family\n" |
| 14852 | "Address Family modifier\n" |
| 14853 | "Address Family modifier\n" |
| 14854 | "Information about Route Server Client\n" |
| 14855 | NEIGHBOR_ADDR_STR |
| 14856 | "Network in the BGP routing table to display\n") |
| 14857 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14858 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14859 | DEFUN (show_bgp_view_rsclient_prefix, |
| 14860 | show_bgp_view_rsclient_prefix_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14861 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 14862 | SHOW_STR |
| 14863 | BGP_STR |
| 14864 | "BGP view\n" |
| 14865 | "View name\n" |
| 14866 | "Information about Route Server Client\n" |
| 14867 | NEIGHBOR_ADDR_STR |
| 14868 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14869 | { |
| 14870 | struct bgp *bgp; |
| 14871 | struct peer *peer; |
| 14872 | |
| 14873 | /* BGP structure lookup. */ |
| 14874 | if (argc == 3) |
| 14875 | { |
| 14876 | bgp = bgp_lookup_by_name (argv[0]); |
| 14877 | if (bgp == NULL) |
| 14878 | { |
| 14879 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14880 | return CMD_WARNING; |
| 14881 | } |
| 14882 | } |
| 14883 | else |
| 14884 | { |
| 14885 | bgp = bgp_get_default (); |
| 14886 | if (bgp == NULL) |
| 14887 | { |
| 14888 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14889 | return CMD_WARNING; |
| 14890 | } |
| 14891 | } |
| 14892 | |
| 14893 | if (argc == 3) |
| 14894 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14895 | else |
| 14896 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14897 | |
| 14898 | if (! peer) |
| 14899 | return CMD_WARNING; |
| 14900 | |
| 14901 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14902 | { |
| 14903 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14904 | VTY_NEWLINE); |
| 14905 | return CMD_WARNING; |
| 14906 | } |
| 14907 | |
| 14908 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14909 | PEER_FLAG_RSERVER_CLIENT)) |
| 14910 | { |
| 14911 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14912 | VTY_NEWLINE); |
| 14913 | return CMD_WARNING; |
| 14914 | } |
| 14915 | |
| 14916 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14917 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14918 | AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14919 | } |
| 14920 | |
| 14921 | DEFUN (show_bgp_view_ipv6_rsclient_prefix, |
| 14922 | show_bgp_view_ipv6_rsclient_prefix_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14923 | "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14924 | SHOW_STR |
| 14925 | BGP_STR |
| 14926 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14927 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14928 | IP6_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14929 | "Information about Route Server Client\n" |
| 14930 | NEIGHBOR_ADDR_STR |
| 14931 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14932 | { |
| 14933 | struct bgp *bgp; |
| 14934 | struct peer *peer; |
| 14935 | |
| 14936 | /* BGP structure lookup. */ |
| 14937 | if (argc == 3) |
| 14938 | { |
| 14939 | bgp = bgp_lookup_by_name (argv[0]); |
| 14940 | if (bgp == NULL) |
| 14941 | { |
| 14942 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14943 | return CMD_WARNING; |
| 14944 | } |
| 14945 | } |
| 14946 | else |
| 14947 | { |
| 14948 | bgp = bgp_get_default (); |
| 14949 | if (bgp == NULL) |
| 14950 | { |
| 14951 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14952 | return CMD_WARNING; |
| 14953 | } |
| 14954 | } |
| 14955 | |
| 14956 | if (argc == 3) |
| 14957 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14958 | else |
| 14959 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14960 | |
| 14961 | if (! peer) |
| 14962 | return CMD_WARNING; |
| 14963 | |
| 14964 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14965 | { |
| 14966 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14967 | VTY_NEWLINE); |
| 14968 | return CMD_WARNING; |
| 14969 | } |
| 14970 | |
| 14971 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14972 | PEER_FLAG_RSERVER_CLIENT)) |
| 14973 | { |
| 14974 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14975 | VTY_NEWLINE); |
| 14976 | return CMD_WARNING; |
| 14977 | } |
| 14978 | |
| 14979 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14980 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14981 | AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14982 | } |
| 14983 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14984 | ALIAS (show_bgp_view_ipv6_rsclient_prefix, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14985 | show_bgp_rsclient_prefix_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14986 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 14987 | SHOW_STR |
| 14988 | BGP_STR |
| 14989 | "Information about Route Server Client\n" |
| 14990 | NEIGHBOR_ADDR_STR |
| 14991 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14992 | |
| 14993 | ALIAS (show_bgp_view_ipv6_rsclient_prefix, |
| 14994 | show_bgp_ipv6_rsclient_prefix_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14995 | "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14996 | SHOW_STR |
| 14997 | BGP_STR |
| 14998 | "Information about Route Server Client\n" |
| 14999 | NEIGHBOR_ADDR_STR |
| 15000 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15001 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15002 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 15003 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 15004 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 15005 | SHOW_STR |
| 15006 | BGP_STR |
| 15007 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15008 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15009 | "Address family\n" |
| 15010 | "Address Family modifier\n" |
| 15011 | "Address Family modifier\n" |
| 15012 | "Information about Route Server Client\n" |
| 15013 | NEIGHBOR_ADDR_STR |
| 15014 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15015 | { |
| 15016 | struct bgp *bgp; |
| 15017 | struct peer *peer; |
| 15018 | safi_t safi; |
| 15019 | |
| 15020 | /* BGP structure lookup. */ |
| 15021 | if (argc == 4) |
| 15022 | { |
| 15023 | bgp = bgp_lookup_by_name (argv[0]); |
| 15024 | if (bgp == NULL) |
| 15025 | { |
| 15026 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 15027 | return CMD_WARNING; |
| 15028 | } |
| 15029 | } |
| 15030 | else |
| 15031 | { |
| 15032 | bgp = bgp_get_default (); |
| 15033 | if (bgp == NULL) |
| 15034 | { |
| 15035 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 15036 | return CMD_WARNING; |
| 15037 | } |
| 15038 | } |
| 15039 | |
| 15040 | if (argc == 4) { |
| 15041 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 15042 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 15043 | } else { |
| 15044 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 15045 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 15046 | } |
| 15047 | |
| 15048 | if (! peer) |
| 15049 | return CMD_WARNING; |
| 15050 | |
| 15051 | if (! peer->afc[AFI_IP6][safi]) |
| 15052 | { |
| 15053 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 15054 | VTY_NEWLINE); |
| 15055 | return CMD_WARNING; |
| 15056 | } |
| 15057 | |
| 15058 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 15059 | PEER_FLAG_RSERVER_CLIENT)) |
| 15060 | { |
| 15061 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 15062 | VTY_NEWLINE); |
| 15063 | return CMD_WARNING; |
| 15064 | } |
| 15065 | |
| 15066 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 15067 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 15068 | AFI_IP6, safi, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15069 | } |
| 15070 | |
| 15071 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 15072 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 15073 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 15074 | SHOW_STR |
| 15075 | BGP_STR |
| 15076 | "Address family\n" |
| 15077 | "Address Family modifier\n" |
| 15078 | "Address Family modifier\n" |
| 15079 | "Information about Route Server Client\n" |
| 15080 | NEIGHBOR_ADDR_STR |
| 15081 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15082 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15083 | struct bgp_table *bgp_distance_table; |
| 15084 | |
| 15085 | struct bgp_distance |
| 15086 | { |
| 15087 | /* Distance value for the IP source prefix. */ |
| 15088 | u_char distance; |
| 15089 | |
| 15090 | /* Name of the access-list to be matched. */ |
| 15091 | char *access_list; |
| 15092 | }; |
| 15093 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15094 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 15095 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15096 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 15097 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15098 | } |
| 15099 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15100 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15101 | bgp_distance_free (struct bgp_distance *bdistance) |
| 15102 | { |
| 15103 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 15104 | } |
| 15105 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15106 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 15107 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 15108 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15109 | { |
| 15110 | int ret; |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15111 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15112 | u_char distance; |
| 15113 | struct bgp_node *rn; |
| 15114 | struct bgp_distance *bdistance; |
| 15115 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15116 | ret = str2prefix (ip_str, &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15117 | if (ret == 0) |
| 15118 | { |
| 15119 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 15120 | return CMD_WARNING; |
| 15121 | } |
| 15122 | |
| 15123 | distance = atoi (distance_str); |
| 15124 | |
| 15125 | /* Get BGP distance node. */ |
| 15126 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 15127 | if (rn->info) |
| 15128 | { |
| 15129 | bdistance = rn->info; |
| 15130 | bgp_unlock_node (rn); |
| 15131 | } |
| 15132 | else |
| 15133 | { |
| 15134 | bdistance = bgp_distance_new (); |
| 15135 | rn->info = bdistance; |
| 15136 | } |
| 15137 | |
| 15138 | /* Set distance value. */ |
| 15139 | bdistance->distance = distance; |
| 15140 | |
| 15141 | /* Reset access-list configuration. */ |
| 15142 | if (bdistance->access_list) |
| 15143 | { |
| 15144 | free (bdistance->access_list); |
| 15145 | bdistance->access_list = NULL; |
| 15146 | } |
| 15147 | if (access_list_str) |
| 15148 | bdistance->access_list = strdup (access_list_str); |
| 15149 | |
| 15150 | return CMD_SUCCESS; |
| 15151 | } |
| 15152 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15153 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 15154 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 15155 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15156 | { |
| 15157 | int ret; |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15158 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15159 | u_char distance; |
| 15160 | struct bgp_node *rn; |
| 15161 | struct bgp_distance *bdistance; |
| 15162 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15163 | ret = str2prefix (ip_str, &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15164 | if (ret == 0) |
| 15165 | { |
| 15166 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 15167 | return CMD_WARNING; |
| 15168 | } |
| 15169 | |
| 15170 | distance = atoi (distance_str); |
| 15171 | |
| 15172 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 15173 | if (! rn) |
| 15174 | { |
| 15175 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 15176 | return CMD_WARNING; |
| 15177 | } |
| 15178 | |
| 15179 | bdistance = rn->info; |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 15180 | |
| 15181 | if (bdistance->distance != distance) |
| 15182 | { |
| 15183 | vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); |
| 15184 | return CMD_WARNING; |
| 15185 | } |
| 15186 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15187 | if (bdistance->access_list) |
| 15188 | free (bdistance->access_list); |
| 15189 | bgp_distance_free (bdistance); |
| 15190 | |
| 15191 | rn->info = NULL; |
| 15192 | bgp_unlock_node (rn); |
| 15193 | bgp_unlock_node (rn); |
| 15194 | |
| 15195 | return CMD_SUCCESS; |
| 15196 | } |
| 15197 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15198 | /* Apply BGP information to distance method. */ |
| 15199 | u_char |
| 15200 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 15201 | { |
| 15202 | struct bgp_node *rn; |
| 15203 | struct prefix_ipv4 q; |
| 15204 | struct peer *peer; |
| 15205 | struct bgp_distance *bdistance; |
| 15206 | struct access_list *alist; |
| 15207 | struct bgp_static *bgp_static; |
| 15208 | |
| 15209 | if (! bgp) |
| 15210 | return 0; |
| 15211 | |
| 15212 | if (p->family != AF_INET) |
| 15213 | return 0; |
| 15214 | |
| 15215 | peer = rinfo->peer; |
| 15216 | |
| 15217 | if (peer->su.sa.sa_family != AF_INET) |
| 15218 | return 0; |
| 15219 | |
| 15220 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 15221 | q.family = AF_INET; |
| 15222 | q.prefix = peer->su.sin.sin_addr; |
| 15223 | q.prefixlen = IPV4_MAX_BITLEN; |
| 15224 | |
| 15225 | /* Check source address. */ |
| 15226 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 15227 | if (rn) |
| 15228 | { |
| 15229 | bdistance = rn->info; |
| 15230 | bgp_unlock_node (rn); |
| 15231 | |
| 15232 | if (bdistance->access_list) |
| 15233 | { |
| 15234 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 15235 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 15236 | return bdistance->distance; |
| 15237 | } |
| 15238 | else |
| 15239 | return bdistance->distance; |
| 15240 | } |
| 15241 | |
| 15242 | /* Backdoor check. */ |
| 15243 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 15244 | if (rn) |
| 15245 | { |
| 15246 | bgp_static = rn->info; |
| 15247 | bgp_unlock_node (rn); |
| 15248 | |
| 15249 | if (bgp_static->backdoor) |
| 15250 | { |
| 15251 | if (bgp->distance_local) |
| 15252 | return bgp->distance_local; |
| 15253 | else |
| 15254 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15255 | } |
| 15256 | } |
| 15257 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 15258 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15259 | { |
| 15260 | if (bgp->distance_ebgp) |
| 15261 | return bgp->distance_ebgp; |
| 15262 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 15263 | } |
| 15264 | else |
| 15265 | { |
| 15266 | if (bgp->distance_ibgp) |
| 15267 | return bgp->distance_ibgp; |
| 15268 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15269 | } |
| 15270 | } |
| 15271 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15272 | #ifdef HAVE_IPV6 |
| 15273 | /* Apply BGP information to ipv6 distance method. */ |
| 15274 | u_char |
| 15275 | ipv6_bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 15276 | { |
| 15277 | struct bgp_node *rn; |
| 15278 | struct prefix_ipv6 q; |
| 15279 | struct peer *peer; |
| 15280 | struct bgp_distance *bdistance; |
| 15281 | struct access_list *alist; |
| 15282 | struct bgp_static *bgp_static; |
| 15283 | |
| 15284 | if (! bgp) |
| 15285 | return 0; |
| 15286 | |
| 15287 | if (p->family != AF_INET6) |
| 15288 | return 0; |
| 15289 | |
| 15290 | peer = rinfo->peer; |
| 15291 | |
| 15292 | if (peer->su.sa.sa_family != AF_INET6) |
| 15293 | return 0; |
| 15294 | |
| 15295 | memset (&q, 0, sizeof (struct prefix_ipv6)); |
| 15296 | q.family = AF_INET; |
| 15297 | q.prefix = peer->su.sin6.sin6_addr; |
| 15298 | q.prefixlen = IPV6_MAX_BITLEN; |
| 15299 | |
| 15300 | /* Check source address. */ |
| 15301 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 15302 | if (rn) |
| 15303 | { |
| 15304 | bdistance = rn->info; |
| 15305 | bgp_unlock_node (rn); |
| 15306 | |
| 15307 | if (bdistance->access_list) |
| 15308 | { |
| 15309 | alist = access_list_lookup (AFI_IP6, bdistance->access_list); |
| 15310 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 15311 | return bdistance->distance; |
| 15312 | } |
| 15313 | else |
| 15314 | return bdistance->distance; |
| 15315 | } |
| 15316 | /* Backdoor check. */ |
| 15317 | rn = bgp_node_lookup (bgp->route[AFI_IP6][SAFI_UNICAST], p); |
| 15318 | if (rn) |
| 15319 | { |
| 15320 | bgp_static = rn->info; |
| 15321 | bgp_unlock_node (rn); |
| 15322 | |
| 15323 | if (bgp_static->backdoor) |
| 15324 | { |
| 15325 | if (bgp->ipv6_distance_local) |
| 15326 | return bgp->ipv6_distance_local; |
| 15327 | else |
| 15328 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15329 | } |
| 15330 | } |
| 15331 | |
| 15332 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 15333 | { |
| 15334 | if (bgp->ipv6_distance_ebgp) |
| 15335 | return bgp->ipv6_distance_ebgp; |
| 15336 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 15337 | } |
| 15338 | else |
| 15339 | { |
| 15340 | if (bgp->ipv6_distance_ibgp) |
| 15341 | return bgp->ipv6_distance_ibgp; |
| 15342 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15343 | } |
| 15344 | } |
| 15345 | #endif /* HAVE_IPV6 */ |
| 15346 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15347 | DEFUN (bgp_distance, |
| 15348 | bgp_distance_cmd, |
| 15349 | "distance bgp <1-255> <1-255> <1-255>", |
| 15350 | "Define an administrative distance\n" |
| 15351 | "BGP distance\n" |
| 15352 | "Distance for routes external to the AS\n" |
| 15353 | "Distance for routes internal to the AS\n" |
| 15354 | "Distance for local routes\n") |
| 15355 | { |
| 15356 | struct bgp *bgp; |
| 15357 | |
| 15358 | bgp = vty->index; |
| 15359 | |
| 15360 | bgp->distance_ebgp = atoi (argv[0]); |
| 15361 | bgp->distance_ibgp = atoi (argv[1]); |
| 15362 | bgp->distance_local = atoi (argv[2]); |
| 15363 | return CMD_SUCCESS; |
| 15364 | } |
| 15365 | |
| 15366 | DEFUN (no_bgp_distance, |
| 15367 | no_bgp_distance_cmd, |
| 15368 | "no distance bgp <1-255> <1-255> <1-255>", |
| 15369 | NO_STR |
| 15370 | "Define an administrative distance\n" |
| 15371 | "BGP distance\n" |
| 15372 | "Distance for routes external to the AS\n" |
| 15373 | "Distance for routes internal to the AS\n" |
| 15374 | "Distance for local routes\n") |
| 15375 | { |
| 15376 | struct bgp *bgp; |
| 15377 | |
| 15378 | bgp = vty->index; |
| 15379 | |
| 15380 | bgp->distance_ebgp= 0; |
| 15381 | bgp->distance_ibgp = 0; |
| 15382 | bgp->distance_local = 0; |
| 15383 | return CMD_SUCCESS; |
| 15384 | } |
| 15385 | |
| 15386 | ALIAS (no_bgp_distance, |
| 15387 | no_bgp_distance2_cmd, |
| 15388 | "no distance bgp", |
| 15389 | NO_STR |
| 15390 | "Define an administrative distance\n" |
| 15391 | "BGP distance\n") |
| 15392 | |
| 15393 | DEFUN (bgp_distance_source, |
| 15394 | bgp_distance_source_cmd, |
| 15395 | "distance <1-255> A.B.C.D/M", |
| 15396 | "Define an administrative distance\n" |
| 15397 | "Administrative distance\n" |
| 15398 | "IP source prefix\n") |
| 15399 | { |
| 15400 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 15401 | return CMD_SUCCESS; |
| 15402 | } |
| 15403 | |
| 15404 | DEFUN (no_bgp_distance_source, |
| 15405 | no_bgp_distance_source_cmd, |
| 15406 | "no distance <1-255> A.B.C.D/M", |
| 15407 | NO_STR |
| 15408 | "Define an administrative distance\n" |
| 15409 | "Administrative distance\n" |
| 15410 | "IP source prefix\n") |
| 15411 | { |
| 15412 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 15413 | return CMD_SUCCESS; |
| 15414 | } |
| 15415 | |
| 15416 | DEFUN (bgp_distance_source_access_list, |
| 15417 | bgp_distance_source_access_list_cmd, |
| 15418 | "distance <1-255> A.B.C.D/M WORD", |
| 15419 | "Define an administrative distance\n" |
| 15420 | "Administrative distance\n" |
| 15421 | "IP source prefix\n" |
| 15422 | "Access list name\n") |
| 15423 | { |
| 15424 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 15425 | return CMD_SUCCESS; |
| 15426 | } |
| 15427 | |
| 15428 | DEFUN (no_bgp_distance_source_access_list, |
| 15429 | no_bgp_distance_source_access_list_cmd, |
| 15430 | "no distance <1-255> A.B.C.D/M WORD", |
| 15431 | NO_STR |
| 15432 | "Define an administrative distance\n" |
| 15433 | "Administrative distance\n" |
| 15434 | "IP source prefix\n" |
| 15435 | "Access list name\n") |
| 15436 | { |
| 15437 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 15438 | return CMD_SUCCESS; |
| 15439 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15440 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15441 | #ifdef HAVE_IPV6 |
| 15442 | DEFUN (ipv6_bgp_distance, |
| 15443 | ipv6_bgp_distance_cmd, |
| 15444 | "distance bgp <1-255> <1-255> <1-255>", |
| 15445 | "Define an administrative distance\n" |
| 15446 | "BGP distance\n" |
| 15447 | "Distance for routes external to the AS\n" |
| 15448 | "Distance for routes internal to the AS\n" |
| 15449 | "Distance for local routes\n") |
| 15450 | { |
| 15451 | struct bgp *bgp; |
| 15452 | |
| 15453 | bgp = vty->index; |
| 15454 | |
| 15455 | bgp->ipv6_distance_ebgp = atoi (argv[0]); |
| 15456 | bgp->ipv6_distance_ibgp = atoi (argv[1]); |
| 15457 | bgp->ipv6_distance_local = atoi (argv[2]); |
| 15458 | return CMD_SUCCESS; |
| 15459 | } |
| 15460 | |
| 15461 | DEFUN (no_ipv6_bgp_distance, |
| 15462 | no_ipv6_bgp_distance_cmd, |
| 15463 | "no distance bgp <1-255> <1-255> <1-255>", |
| 15464 | NO_STR |
| 15465 | "Define an administrative distance\n" |
| 15466 | "BGP distance\n" |
| 15467 | "Distance for routes external to the AS\n" |
| 15468 | "Distance for routes internal to the AS\n" |
| 15469 | "Distance for local routes\n") |
| 15470 | { |
| 15471 | struct bgp *bgp; |
| 15472 | |
| 15473 | bgp = vty->index; |
| 15474 | |
| 15475 | bgp->ipv6_distance_ebgp= 0; |
| 15476 | bgp->ipv6_distance_ibgp = 0; |
| 15477 | bgp->ipv6_distance_local = 0; |
| 15478 | return CMD_SUCCESS; |
| 15479 | } |
| 15480 | |
| 15481 | ALIAS (no_ipv6_bgp_distance, |
| 15482 | no_ipv6_bgp_distance2_cmd, |
| 15483 | "no distance bgp", |
| 15484 | NO_STR |
| 15485 | "Define an administrative distance\n" |
| 15486 | "BGP distance\n") |
| 15487 | |
| 15488 | DEFUN (ipv6_bgp_distance_source, |
| 15489 | ipv6_bgp_distance_source_cmd, |
| 15490 | "distance <1-255> X:X::X:X/M", |
| 15491 | "Define an administrative distance\n" |
| 15492 | "Administrative distance\n" |
| 15493 | "IP source prefix\n") |
| 15494 | { |
| 15495 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 15496 | return CMD_SUCCESS; |
| 15497 | } |
| 15498 | |
| 15499 | DEFUN (no_ipv6_bgp_distance_source, |
| 15500 | no_ipv6_bgp_distance_source_cmd, |
| 15501 | "no distance <1-255> X:X::X:X/M", |
| 15502 | NO_STR |
| 15503 | "Define an administrative distance\n" |
| 15504 | "Administrative distance\n" |
| 15505 | "IP source prefix\n") |
| 15506 | { |
| 15507 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 15508 | return CMD_SUCCESS; |
| 15509 | } |
| 15510 | |
| 15511 | DEFUN (ipv6_bgp_distance_source_access_list, |
| 15512 | ipv6_bgp_distance_source_access_list_cmd, |
| 15513 | "distance <1-255> X:X::X:X/M WORD", |
| 15514 | "Define an administrative distance\n" |
| 15515 | "Administrative distance\n" |
| 15516 | "IP source prefix\n" |
| 15517 | "Access list name\n") |
| 15518 | { |
| 15519 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 15520 | return CMD_SUCCESS; |
| 15521 | } |
| 15522 | |
| 15523 | DEFUN (no_ipv6_bgp_distance_source_access_list, |
| 15524 | no_ipv6_bgp_distance_source_access_list_cmd, |
| 15525 | "no distance <1-255> X:X::X:X/M WORD", |
| 15526 | NO_STR |
| 15527 | "Define an administrative distance\n" |
| 15528 | "Administrative distance\n" |
| 15529 | "IP source prefix\n" |
| 15530 | "Access list name\n") |
| 15531 | { |
| 15532 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 15533 | return CMD_SUCCESS; |
| 15534 | } |
| 15535 | #endif |
| 15536 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15537 | DEFUN (bgp_damp_set, |
| 15538 | bgp_damp_set_cmd, |
| 15539 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 15540 | "BGP Specific commands\n" |
| 15541 | "Enable route-flap dampening\n" |
| 15542 | "Half-life time for the penalty\n" |
| 15543 | "Value to start reusing a route\n" |
| 15544 | "Value to start suppressing a route\n" |
| 15545 | "Maximum duration to suppress a stable route\n") |
| 15546 | { |
| 15547 | struct bgp *bgp; |
| 15548 | int half = DEFAULT_HALF_LIFE * 60; |
| 15549 | int reuse = DEFAULT_REUSE; |
| 15550 | int suppress = DEFAULT_SUPPRESS; |
| 15551 | int max = 4 * half; |
| 15552 | |
| 15553 | if (argc == 4) |
| 15554 | { |
| 15555 | half = atoi (argv[0]) * 60; |
| 15556 | reuse = atoi (argv[1]); |
| 15557 | suppress = atoi (argv[2]); |
| 15558 | max = atoi (argv[3]) * 60; |
| 15559 | } |
| 15560 | else if (argc == 1) |
| 15561 | { |
| 15562 | half = atoi (argv[0]) * 60; |
| 15563 | max = 4 * half; |
| 15564 | } |
| 15565 | |
| 15566 | bgp = vty->index; |
Balaji | aa7dbb1 | 2015-03-16 16:55:26 +0000 | [diff] [blame] | 15567 | |
| 15568 | if (suppress < reuse) |
| 15569 | { |
| 15570 | vty_out (vty, "Suppress value cannot be less than reuse value %s", |
| 15571 | VTY_NEWLINE); |
| 15572 | return 0; |
| 15573 | } |
| 15574 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15575 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 15576 | half, reuse, suppress, max); |
| 15577 | } |
| 15578 | |
| 15579 | ALIAS (bgp_damp_set, |
| 15580 | bgp_damp_set2_cmd, |
| 15581 | "bgp dampening <1-45>", |
| 15582 | "BGP Specific commands\n" |
| 15583 | "Enable route-flap dampening\n" |
| 15584 | "Half-life time for the penalty\n") |
| 15585 | |
| 15586 | ALIAS (bgp_damp_set, |
| 15587 | bgp_damp_set3_cmd, |
| 15588 | "bgp dampening", |
| 15589 | "BGP Specific commands\n" |
| 15590 | "Enable route-flap dampening\n") |
| 15591 | |
| 15592 | DEFUN (bgp_damp_unset, |
| 15593 | bgp_damp_unset_cmd, |
| 15594 | "no bgp dampening", |
| 15595 | NO_STR |
| 15596 | "BGP Specific commands\n" |
| 15597 | "Enable route-flap dampening\n") |
| 15598 | { |
| 15599 | struct bgp *bgp; |
| 15600 | |
| 15601 | bgp = vty->index; |
| 15602 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 15603 | } |
| 15604 | |
| 15605 | ALIAS (bgp_damp_unset, |
| 15606 | bgp_damp_unset2_cmd, |
| 15607 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 15608 | NO_STR |
| 15609 | "BGP Specific commands\n" |
| 15610 | "Enable route-flap dampening\n" |
| 15611 | "Half-life time for the penalty\n" |
| 15612 | "Value to start reusing a route\n" |
| 15613 | "Value to start suppressing a route\n" |
| 15614 | "Maximum duration to suppress a stable route\n") |
| 15615 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15616 | DEFUN (show_ip_bgp_dampened_paths, |
| 15617 | show_ip_bgp_dampened_paths_cmd, |
| 15618 | "show ip bgp dampened-paths", |
| 15619 | SHOW_STR |
| 15620 | IP_STR |
| 15621 | BGP_STR |
| 15622 | "Display paths suppressed due to dampening\n") |
| 15623 | { |
| 15624 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 15625 | NULL); |
| 15626 | } |
| 15627 | |
| 15628 | ALIAS (show_ip_bgp_dampened_paths, |
| 15629 | show_ip_bgp_damp_dampened_paths_cmd, |
| 15630 | "show ip bgp dampening dampened-paths", |
| 15631 | SHOW_STR |
| 15632 | IP_STR |
| 15633 | BGP_STR |
| 15634 | "Display detailed information about dampening\n" |
| 15635 | "Display paths suppressed due to dampening\n") |
| 15636 | |
| 15637 | DEFUN (show_ip_bgp_flap_statistics, |
| 15638 | show_ip_bgp_flap_statistics_cmd, |
| 15639 | "show ip bgp flap-statistics", |
| 15640 | SHOW_STR |
| 15641 | IP_STR |
| 15642 | BGP_STR |
| 15643 | "Display flap statistics of routes\n") |
| 15644 | { |
| 15645 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 15646 | bgp_show_type_flap_statistics, NULL); |
| 15647 | } |
| 15648 | |
| 15649 | ALIAS (show_ip_bgp_flap_statistics, |
| 15650 | show_ip_bgp_damp_flap_statistics_cmd, |
| 15651 | "show ip bgp dampening flap-statistics", |
| 15652 | SHOW_STR |
| 15653 | IP_STR |
| 15654 | BGP_STR |
| 15655 | "Display detailed information about dampening\n" |
| 15656 | "Display flap statistics of routes\n") |
| 15657 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15658 | DEFUN (show_bgp_ipv4_safi_dampened_paths, |
| 15659 | show_bgp_ipv4_safi_dampened_paths_cmd, |
| 15660 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15661 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15662 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15663 | IP_STR |
| 15664 | "Address Family modifier\n" |
| 15665 | "Address Family modifier\n" |
| 15666 | "Address Family modifier\n" |
| 15667 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15668 | "Display paths suppressed due to dampening\n") |
| 15669 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15670 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15671 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15672 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15673 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15674 | return CMD_WARNING; |
| 15675 | } |
| 15676 | |
| 15677 | return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL); |
| 15678 | } |
| 15679 | ALIAS (show_bgp_ipv4_safi_dampened_paths, |
| 15680 | show_bgp_ipv4_safi_damp_dampened_paths_cmd, |
| 15681 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15682 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15683 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15684 | IP_STR |
| 15685 | "Address Family modifier\n" |
| 15686 | "Address Family modifier\n" |
| 15687 | "Address Family modifier\n" |
| 15688 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15689 | "Display detailed information about dampening\n" |
| 15690 | "Display paths suppressed due to dampening\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 15691 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15692 | DEFUN (show_bgp_ipv6_safi_dampened_paths, |
| 15693 | show_bgp_ipv6_safi_dampened_paths_cmd, |
| 15694 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15695 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15696 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15697 | IPV6_STR |
| 15698 | "Address Family modifier\n" |
| 15699 | "Address Family modifier\n" |
| 15700 | "Address Family modifier\n" |
| 15701 | "Address Family modifier\n" |
| 15702 | "Display paths suppressed due to dampening\n") |
| 15703 | { |
| 15704 | safi_t safi; |
| 15705 | |
| 15706 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15707 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15708 | return CMD_WARNING; |
| 15709 | } |
| 15710 | |
| 15711 | return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL); |
| 15712 | } |
| 15713 | ALIAS (show_bgp_ipv6_safi_dampened_paths, |
| 15714 | show_bgp_ipv6_safi_damp_dampened_paths_cmd, |
| 15715 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths", |
| 15716 | SHOW_STR |
| 15717 | BGP_STR |
| 15718 | IPV6_STR |
| 15719 | "Address Family modifier\n" |
| 15720 | "Address Family modifier\n" |
| 15721 | "Address Family modifier\n" |
| 15722 | "Address Family modifier\n" |
| 15723 | "Display detailed information about dampening\n" |
| 15724 | "Display paths suppressed due to dampening\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15725 | |
| 15726 | DEFUN (show_bgp_ipv4_safi_flap_statistics, |
| 15727 | show_bgp_ipv4_safi_flap_statistics_cmd, |
| 15728 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics", |
| 15729 | SHOW_STR |
| 15730 | BGP_STR |
| 15731 | "Address Family\n" |
| 15732 | "Address Family modifier\n" |
| 15733 | "Address Family modifier\n" |
| 15734 | "Address Family modifier\n" |
| 15735 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15736 | "Display flap statistics of routes\n") |
| 15737 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15738 | safi_t safi; |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15739 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15740 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15741 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15742 | return CMD_WARNING; |
| 15743 | } |
| 15744 | |
| 15745 | return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL); |
| 15746 | } |
| 15747 | ALIAS (show_bgp_ipv4_safi_flap_statistics, |
| 15748 | show_bgp_ipv4_safi_damp_flap_statistics_cmd, |
| 15749 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15750 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15751 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15752 | "Address Family\n" |
| 15753 | "Address Family modifier\n" |
| 15754 | "Address Family modifier\n" |
| 15755 | "Address Family modifier\n" |
| 15756 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15757 | "Display detailed information about dampening\n" |
| 15758 | "Display flap statistics of routes\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 15759 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15760 | DEFUN (show_bgp_ipv6_safi_flap_statistics, |
| 15761 | show_bgp_ipv6_safi_flap_statistics_cmd, |
| 15762 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics", |
| 15763 | SHOW_STR |
| 15764 | BGP_STR |
| 15765 | "Address Family\n" |
| 15766 | "Address Family modifier\n" |
| 15767 | "Address Family modifier\n" |
| 15768 | "Address Family modifier\n" |
| 15769 | "Address Family modifier\n" |
| 15770 | "Display flap statistics of routes\n") |
| 15771 | { |
| 15772 | safi_t safi; |
| 15773 | |
| 15774 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15775 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15776 | return CMD_WARNING; |
| 15777 | } |
| 15778 | |
| 15779 | return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL); |
| 15780 | } |
| 15781 | ALIAS (show_bgp_ipv6_safi_flap_statistics, |
| 15782 | show_bgp_ipv6_safi_damp_flap_statistics_cmd, |
| 15783 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics", |
| 15784 | SHOW_STR |
| 15785 | BGP_STR |
| 15786 | "Address Family\n" |
| 15787 | "Address Family modifier\n" |
| 15788 | "Address Family modifier\n" |
| 15789 | "Address Family modifier\n" |
| 15790 | "Address Family modifier\n" |
| 15791 | "Display detailed information about dampening\n" |
| 15792 | "Display flap statistics of routes\n") |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15793 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15794 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15795 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 15796 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 15797 | const char *ip_str, afi_t afi, safi_t safi, |
| 15798 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15799 | { |
| 15800 | int ret; |
| 15801 | struct prefix match; |
| 15802 | struct bgp_node *rn; |
| 15803 | struct bgp_node *rm; |
| 15804 | struct bgp_info *ri; |
| 15805 | struct bgp_info *ri_temp; |
| 15806 | struct bgp *bgp; |
| 15807 | struct bgp_table *table; |
| 15808 | |
| 15809 | /* BGP structure lookup. */ |
| 15810 | if (view_name) |
| 15811 | { |
| 15812 | bgp = bgp_lookup_by_name (view_name); |
| 15813 | if (bgp == NULL) |
| 15814 | { |
| 15815 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 15816 | return CMD_WARNING; |
| 15817 | } |
| 15818 | } |
| 15819 | else |
| 15820 | { |
| 15821 | bgp = bgp_get_default (); |
| 15822 | if (bgp == NULL) |
| 15823 | { |
| 15824 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 15825 | return CMD_WARNING; |
| 15826 | } |
| 15827 | } |
| 15828 | |
| 15829 | /* Check IP address argument. */ |
| 15830 | ret = str2prefix (ip_str, &match); |
| 15831 | if (! ret) |
| 15832 | { |
| 15833 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 15834 | return CMD_WARNING; |
| 15835 | } |
| 15836 | |
| 15837 | match.family = afi2family (afi); |
| 15838 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15839 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15840 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15841 | for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15842 | { |
| 15843 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 15844 | continue; |
| 15845 | |
| 15846 | if ((table = rn->info) != NULL) |
| 15847 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 15848 | { |
| 15849 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 15850 | { |
| 15851 | ri = rm->info; |
| 15852 | while (ri) |
| 15853 | { |
| 15854 | if (ri->extra && ri->extra->damp_info) |
| 15855 | { |
| 15856 | ri_temp = ri->next; |
| 15857 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 15858 | ri = ri_temp; |
| 15859 | } |
| 15860 | else |
| 15861 | ri = ri->next; |
| 15862 | } |
| 15863 | } |
| 15864 | |
| 15865 | bgp_unlock_node (rm); |
| 15866 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15867 | } |
| 15868 | } |
| 15869 | else |
| 15870 | { |
| 15871 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 15872 | { |
| 15873 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 15874 | { |
| 15875 | ri = rn->info; |
| 15876 | while (ri) |
| 15877 | { |
| 15878 | if (ri->extra && ri->extra->damp_info) |
| 15879 | { |
| 15880 | ri_temp = ri->next; |
| 15881 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 15882 | ri = ri_temp; |
| 15883 | } |
| 15884 | else |
| 15885 | ri = ri->next; |
| 15886 | } |
| 15887 | } |
| 15888 | |
| 15889 | bgp_unlock_node (rn); |
| 15890 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15891 | } |
| 15892 | |
| 15893 | return CMD_SUCCESS; |
| 15894 | } |
| 15895 | |
| 15896 | DEFUN (clear_ip_bgp_dampening, |
| 15897 | clear_ip_bgp_dampening_cmd, |
| 15898 | "clear ip bgp dampening", |
| 15899 | CLEAR_STR |
| 15900 | IP_STR |
| 15901 | BGP_STR |
| 15902 | "Clear route flap dampening information\n") |
| 15903 | { |
| 15904 | bgp_damp_info_clean (); |
| 15905 | return CMD_SUCCESS; |
| 15906 | } |
| 15907 | |
| 15908 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 15909 | clear_ip_bgp_dampening_prefix_cmd, |
| 15910 | "clear ip bgp dampening A.B.C.D/M", |
| 15911 | CLEAR_STR |
| 15912 | IP_STR |
| 15913 | BGP_STR |
| 15914 | "Clear route flap dampening information\n" |
| 15915 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 15916 | { |
| 15917 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 15918 | SAFI_UNICAST, NULL, 1); |
| 15919 | } |
| 15920 | |
| 15921 | DEFUN (clear_ip_bgp_dampening_address, |
| 15922 | clear_ip_bgp_dampening_address_cmd, |
| 15923 | "clear ip bgp dampening A.B.C.D", |
| 15924 | CLEAR_STR |
| 15925 | IP_STR |
| 15926 | BGP_STR |
| 15927 | "Clear route flap dampening information\n" |
| 15928 | "Network to clear damping information\n") |
| 15929 | { |
| 15930 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 15931 | SAFI_UNICAST, NULL, 0); |
| 15932 | } |
| 15933 | |
| 15934 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 15935 | clear_ip_bgp_dampening_address_mask_cmd, |
| 15936 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 15937 | CLEAR_STR |
| 15938 | IP_STR |
| 15939 | BGP_STR |
| 15940 | "Clear route flap dampening information\n" |
| 15941 | "Network to clear damping information\n" |
| 15942 | "Network mask\n") |
| 15943 | { |
| 15944 | int ret; |
| 15945 | char prefix_str[BUFSIZ]; |
| 15946 | |
| 15947 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 15948 | if (! ret) |
| 15949 | { |
| 15950 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 15951 | return CMD_WARNING; |
| 15952 | } |
| 15953 | |
| 15954 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 15955 | SAFI_UNICAST, NULL, 0); |
| 15956 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15957 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15958 | /* also used for encap safi */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15959 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15960 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 15961 | afi_t afi, safi_t safi, int *write) |
| 15962 | { |
| 15963 | struct bgp_node *prn; |
| 15964 | struct bgp_node *rn; |
| 15965 | struct bgp_table *table; |
| 15966 | struct prefix *p; |
| 15967 | struct prefix_rd *prd; |
| 15968 | struct bgp_static *bgp_static; |
| 15969 | u_int32_t label; |
| 15970 | char buf[SU_ADDRSTRLEN]; |
| 15971 | char rdbuf[RD_ADDRSTRLEN]; |
| 15972 | |
| 15973 | /* Network configuration. */ |
| 15974 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 15975 | if ((table = prn->info) != NULL) |
| 15976 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 15977 | if ((bgp_static = rn->info) != NULL) |
| 15978 | { |
| 15979 | p = &rn->p; |
| 15980 | prd = (struct prefix_rd *) &prn->p; |
| 15981 | |
| 15982 | /* "address-family" display. */ |
| 15983 | bgp_config_write_family_header (vty, afi, safi, write); |
| 15984 | |
| 15985 | /* "network" configuration display. */ |
| 15986 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 15987 | label = decode_label (bgp_static->tag); |
| 15988 | |
| 15989 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 15990 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 15991 | p->prefixlen, |
| 15992 | rdbuf, label); |
| 15993 | vty_out (vty, "%s", VTY_NEWLINE); |
| 15994 | } |
| 15995 | return 0; |
| 15996 | } |
| 15997 | |
| 15998 | /* Configuration of static route announcement and aggregate |
| 15999 | information. */ |
| 16000 | int |
| 16001 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 16002 | afi_t afi, safi_t safi, int *write) |
| 16003 | { |
| 16004 | struct bgp_node *rn; |
| 16005 | struct prefix *p; |
| 16006 | struct bgp_static *bgp_static; |
| 16007 | struct bgp_aggregate *bgp_aggregate; |
| 16008 | char buf[SU_ADDRSTRLEN]; |
| 16009 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 16010 | if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16011 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 16012 | |
| 16013 | /* Network configuration. */ |
| 16014 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 16015 | if ((bgp_static = rn->info) != NULL) |
| 16016 | { |
| 16017 | p = &rn->p; |
| 16018 | |
| 16019 | /* "address-family" display. */ |
| 16020 | bgp_config_write_family_header (vty, afi, safi, write); |
| 16021 | |
| 16022 | /* "network" configuration display. */ |
| 16023 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 16024 | { |
| 16025 | u_int32_t destination; |
| 16026 | struct in_addr netmask; |
| 16027 | |
| 16028 | destination = ntohl (p->u.prefix4.s_addr); |
| 16029 | masklen2ip (p->prefixlen, &netmask); |
| 16030 | vty_out (vty, " network %s", |
| 16031 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 16032 | |
| 16033 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 16034 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 16035 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 16036 | || p->u.prefix4.s_addr == 0) |
| 16037 | { |
| 16038 | /* Natural mask is not display. */ |
| 16039 | } |
| 16040 | else |
| 16041 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 16042 | } |
| 16043 | else |
| 16044 | { |
| 16045 | vty_out (vty, " network %s/%d", |
| 16046 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16047 | p->prefixlen); |
| 16048 | } |
| 16049 | |
| 16050 | if (bgp_static->rmap.name) |
| 16051 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 16052 | else |
| 16053 | { |
| 16054 | if (bgp_static->backdoor) |
| 16055 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 16056 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16057 | |
| 16058 | vty_out (vty, "%s", VTY_NEWLINE); |
| 16059 | } |
| 16060 | |
| 16061 | /* Aggregate-address configuration. */ |
| 16062 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 16063 | if ((bgp_aggregate = rn->info) != NULL) |
| 16064 | { |
| 16065 | p = &rn->p; |
| 16066 | |
| 16067 | /* "address-family" display. */ |
| 16068 | bgp_config_write_family_header (vty, afi, safi, write); |
| 16069 | |
| 16070 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 16071 | { |
| 16072 | struct in_addr netmask; |
| 16073 | |
| 16074 | masklen2ip (p->prefixlen, &netmask); |
| 16075 | vty_out (vty, " aggregate-address %s %s", |
| 16076 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16077 | inet_ntoa (netmask)); |
| 16078 | } |
| 16079 | else |
| 16080 | { |
| 16081 | vty_out (vty, " aggregate-address %s/%d", |
| 16082 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16083 | p->prefixlen); |
| 16084 | } |
| 16085 | |
| 16086 | if (bgp_aggregate->as_set) |
| 16087 | vty_out (vty, " as-set"); |
| 16088 | |
| 16089 | if (bgp_aggregate->summary_only) |
| 16090 | vty_out (vty, " summary-only"); |
| 16091 | |
| 16092 | vty_out (vty, "%s", VTY_NEWLINE); |
| 16093 | } |
| 16094 | |
| 16095 | return 0; |
| 16096 | } |
| 16097 | |
| 16098 | int |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16099 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp, |
| 16100 | afi_t afi, safi_t safi, int *write) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16101 | { |
| 16102 | struct bgp_node *rn; |
| 16103 | struct bgp_distance *bdistance; |
| 16104 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16105 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 16106 | { |
| 16107 | /* Distance configuration. */ |
| 16108 | if (bgp->distance_ebgp |
| 16109 | && bgp->distance_ibgp |
| 16110 | && bgp->distance_local |
| 16111 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 16112 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 16113 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 16114 | vty_out (vty, " distance bgp %d %d %d%s", |
| 16115 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 16116 | VTY_NEWLINE); |
| 16117 | |
| 16118 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 16119 | if ((bdistance = rn->info) != NULL) |
| 16120 | { |
| 16121 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 16122 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 16123 | bdistance->access_list ? bdistance->access_list : "", |
| 16124 | VTY_NEWLINE); |
| 16125 | } |
| 16126 | } |
| 16127 | |
| 16128 | #ifdef HAVE_IPV6 |
| 16129 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
| 16130 | { |
| 16131 | bgp_config_write_family_header (vty, afi, safi, write); |
| 16132 | if (bgp->ipv6_distance_ebgp |
| 16133 | && bgp->ipv6_distance_ibgp |
| 16134 | && bgp->ipv6_distance_local |
| 16135 | && (bgp->ipv6_distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 16136 | || bgp->ipv6_distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 16137 | || bgp->ipv6_distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 16138 | vty_out (vty, " distance bgp %d %d %d%s", |
| 16139 | bgp->ipv6_distance_ebgp, bgp->ipv6_distance_ibgp, bgp->ipv6_distance_local, |
| 16140 | VTY_NEWLINE); |
| 16141 | |
| 16142 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 16143 | if ((bdistance = rn->info) != NULL) |
| 16144 | { |
| 16145 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 16146 | inet6_ntoa (rn->p.u.prefix6), rn->p.prefixlen, |
| 16147 | bdistance->access_list ? bdistance->access_list : "", |
| 16148 | VTY_NEWLINE); |
| 16149 | } |
| 16150 | } |
| 16151 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16152 | |
| 16153 | return 0; |
| 16154 | } |
| 16155 | |
| 16156 | /* Allocate routing table structure and install commands. */ |
| 16157 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 16158 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16159 | { |
| 16160 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 16161 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16162 | |
| 16163 | /* IPv4 BGP commands. */ |
| 16164 | install_element (BGP_NODE, &bgp_network_cmd); |
| 16165 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 16166 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 16167 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 16168 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 16169 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 16170 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 16171 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 16172 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 16173 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 16174 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 16175 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 16176 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 16177 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 16178 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 16179 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 16180 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 16181 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 16182 | |
| 16183 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 16184 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 16185 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 16186 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 16187 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 16188 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 16189 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 16190 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 16191 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 16192 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 16193 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 16194 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 16195 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 16196 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 16197 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 16198 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 16199 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 16200 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 16201 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 16202 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16203 | |
| 16204 | /* IPv4 unicast configuration. */ |
| 16205 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 16206 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 16207 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 16208 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 16209 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 16210 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16211 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16212 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 16213 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 16214 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 16215 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 16216 | 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] | 16217 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16218 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 16219 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 16220 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 16221 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 16222 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 16223 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 16224 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 16225 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 16226 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 16227 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 16228 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 16229 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 16230 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 16231 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 16232 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 16233 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 16234 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 16235 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 16236 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 16237 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16238 | |
| 16239 | /* IPv4 multicast configuration. */ |
| 16240 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 16241 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 16242 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 16243 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 16244 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 16245 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 16246 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 16247 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 16248 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 16249 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 16250 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 16251 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 16252 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 16253 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 16254 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 16255 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 16256 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 16257 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 16258 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 16259 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 16260 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 16261 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 16262 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 16263 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 16264 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 16265 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 16266 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 16267 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 16268 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 16269 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 16270 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 16271 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16272 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16273 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16274 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16275 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd); |
| 16276 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd); |
| 16277 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); |
| 16278 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); |
| 16279 | install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd); |
| 16280 | install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd); |
| 16281 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd); |
| 16282 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd); |
| 16283 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16284 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16285 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd); |
| 16286 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd); |
| 16287 | install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd); |
| 16288 | install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd); |
| 16289 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); |
| 16290 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); |
| 16291 | install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd); |
| 16292 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd); |
| 16293 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd); |
| 16294 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd); |
| 16295 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd); |
| 16296 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd); |
| 16297 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd); |
| 16298 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd); |
| 16299 | install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd); |
| 16300 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd); |
| 16301 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd); |
| 16302 | install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd); |
| 16303 | install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd); |
| 16304 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd); |
| 16305 | install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd); |
| 16306 | install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd); |
| 16307 | install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd); |
| 16308 | install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd); |
| 16309 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd); |
| 16310 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd); |
| 16311 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd); |
| 16312 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16313 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 16314 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 16315 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 16316 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 16317 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16318 | install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd); |
| 16319 | install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd); |
| 16320 | install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd); |
| 16321 | install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd); |
| 16322 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd); |
| 16323 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd); |
| 16324 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd); |
| 16325 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd); |
| 16326 | install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd); |
| 16327 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd); |
| 16328 | install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd); |
| 16329 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd); |
| 16330 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd); |
| 16331 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd); |
| 16332 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd); |
| 16333 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd); |
| 16334 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd); |
| 16335 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd); |
| 16336 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16337 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16338 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd); |
| 16339 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd); |
| 16340 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd); |
| 16341 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd); |
| 16342 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd); |
| 16343 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd); |
| 16344 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd); |
| 16345 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd); |
| 16346 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd); |
| 16347 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd); |
| 16348 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd); |
| 16349 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd); |
| 16350 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd); |
| 16351 | install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd); |
| 16352 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd); |
| 16353 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd); |
| 16354 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd); |
| 16355 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd); |
| 16356 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd); |
| 16357 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd); |
| 16358 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd); |
| 16359 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd); |
| 16360 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd); |
| 16361 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd); |
| 16362 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd); |
| 16363 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd); |
| 16364 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd); |
| 16365 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd); |
| 16366 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd); |
| 16367 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd); |
| 16368 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd); |
| 16369 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd); |
| 16370 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd); |
| 16371 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd); |
| 16372 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd); |
| 16373 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd); |
| 16374 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd); |
| 16375 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd); |
| 16376 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd); |
| 16377 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd); |
| 16378 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd); |
| 16379 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd); |
| 16380 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd); |
| 16381 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd); |
| 16382 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16383 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16384 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16385 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16386 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16387 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16388 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16389 | |
| 16390 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16391 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16392 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); |
| 16393 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); |
| 16394 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd); |
| 16395 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd); |
| 16396 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16397 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16398 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd); |
| 16399 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd); |
| 16400 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd); |
| 16401 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd); |
| 16402 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); |
| 16403 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); |
| 16404 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd); |
| 16405 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd); |
| 16406 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd); |
| 16407 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd); |
| 16408 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd); |
| 16409 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd); |
| 16410 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd); |
| 16411 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd); |
| 16412 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd); |
| 16413 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16414 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 16415 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 16416 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 16417 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 16418 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16419 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd); |
| 16420 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd); |
| 16421 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd); |
| 16422 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd); |
| 16423 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd); |
| 16424 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd); |
| 16425 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd); |
| 16426 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16427 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16428 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16429 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16430 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16431 | |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16432 | /* BGP dampening clear commands */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16433 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 16434 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 16435 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 16436 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 16437 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16438 | /* New config IPv6 BGP commands. */ |
| 16439 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 16440 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 16441 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 16442 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 16443 | |
| 16444 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 16445 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 16446 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 16447 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 16448 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 16449 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 16450 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 16451 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16452 | /* Old config IPv6 BGP commands. */ |
| 16453 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 16454 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 16455 | |
| 16456 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 16457 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 16458 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 16459 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 16460 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16461 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16462 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16463 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16464 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16465 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16466 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16467 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16468 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16469 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16470 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd); |
| 16471 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd); |
| 16472 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd); |
| 16473 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd); |
| 16474 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd); |
| 16475 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd); |
| 16476 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd); |
| 16477 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16478 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16479 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16480 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16481 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16482 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16483 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16484 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16485 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16486 | install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd); |
| 16487 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16488 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16489 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16490 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16491 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16492 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16493 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16494 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16495 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16496 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16497 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16498 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16499 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16500 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16501 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16502 | install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd); |
| 16503 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16504 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16505 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16506 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16507 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16508 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16509 | |
| 16510 | /* Restricted: |
| 16511 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 16512 | */ |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16513 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16514 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16515 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16516 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16517 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd); |
| 16518 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd); |
| 16519 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd); |
| 16520 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd); |
| 16521 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd); |
| 16522 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd); |
| 16523 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd); |
| 16524 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd); |
| 16525 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16526 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16527 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16528 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16529 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16530 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16531 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16532 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16533 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16534 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16535 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16536 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 16537 | /* Statistics */ |
| 16538 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16539 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16540 | |
| 16541 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 16542 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 16543 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 16544 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 16545 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 16546 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 16547 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16548 | #ifdef HAVE_IPV6 |
| 16549 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_cmd); |
| 16550 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_cmd); |
| 16551 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance2_cmd); |
| 16552 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_cmd); |
| 16553 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_cmd); |
| 16554 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_access_list_cmd); |
| 16555 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_access_list_cmd); |
| 16556 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16557 | |
| 16558 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 16559 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 16560 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 16561 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 16562 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 16563 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 16564 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 16565 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 16566 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 16567 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Balaji | 9145f0e | 2016-01-20 22:59:27 +0530 | [diff] [blame] | 16568 | |
| 16569 | /* IPv4 Multicast Mode */ |
| 16570 | install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd); |
| 16571 | install_element (BGP_IPV4M_NODE, &bgp_damp_set2_cmd); |
| 16572 | install_element (BGP_IPV4M_NODE, &bgp_damp_set3_cmd); |
| 16573 | install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd); |
| 16574 | install_element (BGP_IPV4M_NODE, &bgp_damp_unset2_cmd); |
| 16575 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16576 | |
| 16577 | /* Deprecated AS-Pathlimit commands */ |
| 16578 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 16579 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 16580 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16581 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16582 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16583 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16584 | |
| 16585 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 16586 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16587 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16588 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16589 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16590 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16591 | |
| 16592 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 16593 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 16594 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16595 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16596 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16597 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16598 | |
| 16599 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 16600 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16601 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16602 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16603 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16604 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16605 | |
| 16606 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 16607 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 16608 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16609 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16610 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16611 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16612 | |
| 16613 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 16614 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16615 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16616 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16617 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16618 | 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] | 16619 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16620 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 16621 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16622 | |
| 16623 | /* old style commands */ |
| 16624 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 16625 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 16626 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16627 | install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd); |
| 16628 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16629 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 16630 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 16631 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 16632 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 16633 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16634 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
| 16635 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); |
| 16636 | install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16637 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 16638 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 16639 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 16640 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 16641 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 16642 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 16643 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 16644 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 16645 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 16646 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 16647 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 16648 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 16649 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 16650 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 16651 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 16652 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 16653 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 16654 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 16655 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 16656 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 16657 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 16658 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 16659 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 16660 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 16661 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 16662 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 16663 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 16664 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 16665 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 16666 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 16667 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 16668 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 16669 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 16670 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 16671 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 16672 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 16673 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 16674 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 16675 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 16676 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 16677 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 16678 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 16679 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 16680 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 16681 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 16682 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 16683 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 16684 | install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 16685 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16686 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 16687 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd); |
| 16688 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16689 | install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
| 16690 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 16691 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
| 16692 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 16693 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd); |
| 16694 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 16695 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 16696 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
| 16697 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 16698 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 16699 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
| 16700 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 16701 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
| 16702 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 16703 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
| 16704 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 16705 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
| 16706 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 16707 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
| 16708 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
| 16709 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 16710 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 16711 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 16712 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
| 16713 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 16714 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 16715 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16716 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16717 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16718 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd); |
| 16719 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16720 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 16721 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 16722 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 16723 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16724 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
| 16725 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); |
| 16726 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16727 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 16728 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 16729 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 16730 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 16731 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 16732 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 16733 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 16734 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 16735 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 16736 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 16737 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 16738 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 16739 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 16740 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 16741 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 16742 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 16743 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 16744 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 16745 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 16746 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 16747 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 16748 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 16749 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 16750 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16751 | |
| 16752 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 16753 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 16754 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16755 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16756 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 16757 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 16758 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 16759 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16760 | install_element (VIEW_NODE, &show_bgp_route_pathtype_cmd); |
| 16761 | install_element (VIEW_NODE, &show_bgp_ipv6_route_pathtype_cmd); |
| 16762 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); |
| 16763 | install_element (VIEW_NODE, &show_bgp_prefix_pathtype_cmd); |
| 16764 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); |
| 16765 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16766 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 16767 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 16768 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 16769 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 16770 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 16771 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 16772 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 16773 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 16774 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 16775 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 16776 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 16777 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 16778 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 16779 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 16780 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd); |
| 16781 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 16782 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd); |
| 16783 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 16784 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 16785 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 16786 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 16787 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 16788 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 16789 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 16790 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
| 16791 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 16792 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 16793 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 16794 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 16795 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 16796 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 16797 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 16798 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 16799 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 16800 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16801 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16802 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 16803 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16804 | install_element (RESTRICTED_NODE, &show_bgp_route_pathtype_cmd); |
| 16805 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_pathtype_cmd); |
| 16806 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); |
| 16807 | install_element (RESTRICTED_NODE, &show_bgp_prefix_pathtype_cmd); |
| 16808 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); |
| 16809 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16810 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 16811 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 16812 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 16813 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 16814 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 16815 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 16816 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 16817 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 16818 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 16819 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 16820 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16821 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16822 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 16823 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16824 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16825 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 16826 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 16827 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 16828 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 16829 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 16830 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 16831 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 16832 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 16833 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 16834 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 16835 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 16836 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 16837 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 16838 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 16839 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 16840 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 16841 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 16842 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 16843 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 16844 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 16845 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 16846 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 16847 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 16848 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 16849 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 16850 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 16851 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 16852 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 16853 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 16854 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 16855 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 16856 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 16857 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 16858 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 16859 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 16860 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16861 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16862 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16863 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16864 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16865 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16866 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16867 | /* old with name safi collision */ |
| 16868 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 16869 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 16870 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 16871 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 16872 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 16873 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 16874 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 16875 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 16876 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 16877 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 16878 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 16879 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 16880 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 16881 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 16882 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 16883 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16884 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16885 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 16886 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16887 | |
| 16888 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
| 16889 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
| 16890 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
| 16891 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16892 | |
| 16893 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
| 16894 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
| 16895 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
| 16896 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16897 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 16898 | |
| 16899 | void |
| 16900 | bgp_route_finish (void) |
| 16901 | { |
| 16902 | bgp_table_unlock (bgp_distance_table); |
| 16903 | bgp_distance_table = NULL; |
| 16904 | } |