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" |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 58 | #include "bgpd/bgp_nht.h" |
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 | |
Daniel Walton | e25a974 | 2015-11-09 20:21:50 -0500 | [diff] [blame] | 250 | if (!BGP_INFO_COUNTABLE (ri) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 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 | } |
Daniel Walton | e25a974 | 2015-11-09 20:21:50 -0500 | [diff] [blame] | 267 | else if (BGP_INFO_COUNTABLE (ri) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 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 | |
Daniel Walton | e25a974 | 2015-11-09 20:21:50 -0500 | [diff] [blame] | 284 | /* early bath if we know it's not a flag that changes countability state */ |
| 285 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_HISTORY|BGP_INFO_REMOVED)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 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 | |
Daniel Walton | e25a974 | 2015-11-09 20:21:50 -0500 | [diff] [blame] | 296 | /* early bath if we know it's not a flag that changes countability state */ |
| 297 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_HISTORY|BGP_INFO_REMOVED)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 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 |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 1001 | && (bgp_multiaccess_check_v4 (attr->nexthop, peer) == 0))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1993 | |
| 1994 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1995 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1996 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1997 | peer->host, |
| 1998 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1999 | p->prefixlen, rsclient->host); |
| 2000 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2001 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2002 | bgp_attr_unintern (&attr_new); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2003 | bgp_attr_flush(&new_attr); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2004 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2005 | } |
| 2006 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2007 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2008 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2009 | bgp_info_restore (rn, ri); |
| 2010 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2011 | /* Received Logging. */ |
| 2012 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2013 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2014 | peer->host, |
| 2015 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2016 | p->prefixlen, rsclient->host); |
| 2017 | |
| 2018 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2019 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2020 | |
| 2021 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2022 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2023 | ri->attr = attr_new; |
| 2024 | |
| 2025 | /* Update MPLS tag. */ |
| 2026 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2027 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2028 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2029 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2030 | |
| 2031 | /* Process change. */ |
| 2032 | bgp_process (bgp, rn, afi, safi); |
| 2033 | bgp_unlock_node (rn); |
| 2034 | |
| 2035 | return; |
| 2036 | } |
| 2037 | |
| 2038 | /* Received Logging. */ |
| 2039 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2040 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2041 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2042 | peer->host, |
| 2043 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2044 | p->prefixlen, rsclient->host); |
| 2045 | } |
| 2046 | |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 2047 | new = info_make(type, sub_type, peer, attr_new, rn); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2048 | |
| 2049 | /* Update MPLS tag. */ |
| 2050 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2051 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2052 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2053 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2054 | |
| 2055 | /* Register new BGP information. */ |
| 2056 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2057 | |
| 2058 | /* route_node_get lock */ |
| 2059 | bgp_unlock_node (rn); |
| 2060 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2061 | /* Process change. */ |
| 2062 | bgp_process (bgp, rn, afi, safi); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2063 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2064 | return; |
| 2065 | |
| 2066 | filtered: |
| 2067 | |
| 2068 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2069 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2070 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2071 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 2072 | peer->host, |
| 2073 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2074 | p->prefixlen, rsclient->host, reason); |
| 2075 | |
| 2076 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2077 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2078 | |
| 2079 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2080 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2081 | return; |
| 2082 | } |
| 2083 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2084 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2085 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 2086 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 2087 | struct prefix_rd *prd, u_char *tag) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2088 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2089 | struct bgp_node *rn; |
| 2090 | struct bgp_info *ri; |
| 2091 | char buf[SU_ADDRSTRLEN]; |
| 2092 | |
| 2093 | if (rsclient == peer) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2094 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2095 | |
| 2096 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 2097 | |
| 2098 | /* Lookup withdrawn route. */ |
| 2099 | for (ri = rn->info; ri; ri = ri->next) |
| 2100 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2101 | break; |
| 2102 | |
| 2103 | /* Withdraw specified route from routing table. */ |
| 2104 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2105 | bgp_rib_withdraw (rn, ri, peer, afi, safi, prd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2106 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2107 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2108 | "%s Can't find the route %s/%d", peer->host, |
| 2109 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2110 | p->prefixlen); |
| 2111 | |
| 2112 | /* Unlock bgp_node_get() lock. */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2113 | bgp_unlock_node (rn); |
| 2114 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2115 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2116 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2117 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2118 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2119 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2120 | { |
| 2121 | int ret; |
| 2122 | int aspath_loop_count = 0; |
| 2123 | struct bgp_node *rn; |
| 2124 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2125 | struct attr new_attr; |
| 2126 | struct attr_extra new_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2127 | struct attr *attr_new; |
| 2128 | struct bgp_info *ri; |
| 2129 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2130 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2131 | char buf[SU_ADDRSTRLEN]; |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2132 | int connected = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2213 | /* 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] | 2214 | must not be my own address. */ |
Jorge Boncompte [DTI2] | 10f9bf3 | 2012-05-07 16:52:52 +0000 | [diff] [blame] | 2215 | if (new_attr.nexthop.s_addr == 0 |
| 2216 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) |
| 2217 | || bgp_nexthop_self (&new_attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2218 | { |
| 2219 | reason = "martian 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 | } |
| 2224 | |
| 2225 | attr_new = bgp_attr_intern (&new_attr); |
| 2226 | |
| 2227 | /* If the update is implicit withdraw. */ |
| 2228 | if (ri) |
| 2229 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2230 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2231 | |
| 2232 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2233 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2234 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2235 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2236 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2237 | && peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2238 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2239 | { |
| 2240 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2241 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2242 | peer->host, |
| 2243 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2244 | p->prefixlen); |
| 2245 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2246 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2247 | { |
| 2248 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2249 | bgp_process (bgp, rn, afi, safi); |
| 2250 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2251 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2252 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2253 | { |
| 2254 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2255 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2256 | "%s rcvd %s/%d...duplicate ignored", |
| 2257 | peer->host, |
| 2258 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2259 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2260 | |
| 2261 | /* graceful restart STALE flag unset. */ |
| 2262 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2263 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2264 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2265 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2266 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2267 | } |
| 2268 | |
| 2269 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2270 | bgp_attr_unintern (&attr_new); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2271 | bgp_attr_flush (&new_attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2272 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2273 | return 0; |
| 2274 | } |
| 2275 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2276 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2277 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2278 | { |
| 2279 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2280 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2281 | peer->host, |
| 2282 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2283 | p->prefixlen); |
| 2284 | bgp_info_restore (rn, ri); |
| 2285 | } |
| 2286 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2287 | /* Received Logging. */ |
| 2288 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2289 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2290 | peer->host, |
| 2291 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2292 | p->prefixlen); |
| 2293 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2294 | /* graceful restart STALE flag unset. */ |
| 2295 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2296 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2297 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2298 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2299 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2300 | |
| 2301 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2302 | * only if update is accepted, they'll increment below. |
| 2303 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2304 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2305 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2306 | /* Update bgp route dampening information. */ |
| 2307 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2308 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2309 | { |
| 2310 | /* This is implicit withdraw so we should update dampening |
| 2311 | information. */ |
| 2312 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2313 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2314 | } |
| 2315 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2316 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2317 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2318 | ri->attr = attr_new; |
| 2319 | |
| 2320 | /* Update MPLS tag. */ |
| 2321 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2322 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2323 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2324 | bgp_attr_flush (&new_attr); |
| 2325 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2326 | /* Update bgp route dampening information. */ |
| 2327 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2328 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2329 | { |
| 2330 | /* Now we do normal update dampening. */ |
| 2331 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2332 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2333 | { |
| 2334 | bgp_unlock_node (rn); |
| 2335 | return 0; |
| 2336 | } |
| 2337 | } |
| 2338 | |
| 2339 | /* Nexthop reachability check. */ |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2340 | if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2341 | { |
Timo Teräs | e3443a2 | 2016-10-19 16:02:34 +0300 | [diff] [blame] | 2342 | if (peer->sort == BGP_PEER_EBGP && peer_ttl (peer) == 1 && |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2343 | ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
| 2344 | connected = 1; |
| 2345 | else |
| 2346 | connected = 0; |
| 2347 | |
| 2348 | if (bgp_find_or_add_nexthop (afi, ri, NULL, connected)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2349 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2350 | else |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2351 | { |
| 2352 | if (BGP_DEBUG(nht, NHT)) |
| 2353 | { |
| 2354 | char buf1[INET6_ADDRSTRLEN]; |
| 2355 | inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN); |
| 2356 | zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1); |
| 2357 | } |
| 2358 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
| 2359 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2360 | } |
| 2361 | else |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2362 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2363 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2364 | bgp_attr_flush (&new_attr); |
| 2365 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2366 | /* Process change. */ |
| 2367 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2368 | |
| 2369 | bgp_process (bgp, rn, afi, safi); |
| 2370 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2371 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2372 | return 0; |
| 2373 | } |
| 2374 | |
| 2375 | /* Received Logging. */ |
| 2376 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2377 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2378 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2379 | peer->host, |
| 2380 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2381 | p->prefixlen); |
| 2382 | } |
| 2383 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2384 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 2385 | new = info_make(type, sub_type, peer, attr_new, rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2386 | |
| 2387 | /* Update MPLS tag. */ |
| 2388 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2389 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2390 | |
| 2391 | /* Nexthop reachability check. */ |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2392 | if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2393 | { |
Timo Teräs | e3443a2 | 2016-10-19 16:02:34 +0300 | [diff] [blame] | 2394 | if (peer->sort == BGP_PEER_EBGP && peer_ttl (peer) == 1 && |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2395 | ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
| 2396 | connected = 1; |
| 2397 | else |
| 2398 | connected = 0; |
| 2399 | |
| 2400 | if (bgp_find_or_add_nexthop (afi, new, NULL, connected)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2401 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2402 | else |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 2403 | { |
| 2404 | if (BGP_DEBUG(nht, NHT)) |
| 2405 | { |
| 2406 | char buf1[INET6_ADDRSTRLEN]; |
| 2407 | inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN); |
| 2408 | zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1); |
| 2409 | } |
| 2410 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
| 2411 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2412 | } |
| 2413 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2414 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2415 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2416 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2417 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2418 | |
| 2419 | /* Register new BGP information. */ |
| 2420 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2421 | |
| 2422 | /* route_node_get lock */ |
| 2423 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2424 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2425 | bgp_attr_flush (&new_attr); |
| 2426 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2427 | /* If maximum prefix count is configured and current prefix |
| 2428 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2429 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2430 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2431 | |
| 2432 | /* Process change. */ |
| 2433 | bgp_process (bgp, rn, afi, safi); |
| 2434 | |
| 2435 | return 0; |
| 2436 | |
| 2437 | /* This BGP update is filtered. Log the reason then update BGP |
| 2438 | entry. */ |
| 2439 | filtered: |
| 2440 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2441 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2442 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2443 | peer->host, |
| 2444 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2445 | p->prefixlen, reason); |
| 2446 | |
| 2447 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2448 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2449 | |
| 2450 | bgp_unlock_node (rn); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2451 | bgp_attr_flush (&new_attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2452 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2453 | return 0; |
| 2454 | } |
| 2455 | |
| 2456 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2457 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2458 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2459 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2460 | { |
| 2461 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2462 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2463 | struct bgp *bgp; |
| 2464 | int ret; |
| 2465 | |
| 2466 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2467 | soft_reconfig); |
| 2468 | |
| 2469 | bgp = peer->bgp; |
| 2470 | |
| 2471 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2472 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2473 | { |
| 2474 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2475 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2476 | sub_type, prd, tag); |
| 2477 | } |
| 2478 | |
| 2479 | return ret; |
| 2480 | } |
| 2481 | |
| 2482 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2483 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2484 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2485 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2486 | { |
| 2487 | struct bgp *bgp; |
| 2488 | char buf[SU_ADDRSTRLEN]; |
| 2489 | struct bgp_node *rn; |
| 2490 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2491 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2492 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2493 | |
| 2494 | bgp = peer->bgp; |
| 2495 | |
David Lamparter | 4584c23 | 2015-04-13 09:50:00 +0200 | [diff] [blame] | 2496 | /* Lookup node. */ |
| 2497 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
| 2498 | |
| 2499 | /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all |
| 2500 | * routes that are filtered. This tanks out Quagga RS pretty badly due to |
| 2501 | * the iteration over all RS clients. |
| 2502 | * Since we need to remove the entry from adj_in anyway, do that first and |
| 2503 | * if there was no entry, we don't need to do anything more. */ |
| 2504 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2505 | && peer != bgp->peer_self) |
| 2506 | if (!bgp_adj_in_unset (rn, peer)) |
| 2507 | { |
| 2508 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2509 | zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d " |
| 2510 | "not in adj-in", peer->host, |
| 2511 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2512 | p->prefixlen); |
| 2513 | bgp_unlock_node (rn); |
| 2514 | return 0; |
| 2515 | } |
| 2516 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2517 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2518 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2519 | { |
| 2520 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2521 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2522 | } |
| 2523 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2524 | /* Logging. */ |
| 2525 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2526 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2527 | peer->host, |
| 2528 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2529 | p->prefixlen); |
| 2530 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2531 | /* Lookup withdrawn route. */ |
| 2532 | for (ri = rn->info; ri; ri = ri->next) |
| 2533 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2534 | break; |
| 2535 | |
| 2536 | /* Withdraw specified route from routing table. */ |
| 2537 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2538 | bgp_rib_withdraw (rn, ri, peer, afi, safi, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2539 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2540 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2541 | "%s Can't find the route %s/%d", peer->host, |
| 2542 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2543 | p->prefixlen); |
| 2544 | |
| 2545 | /* Unlock bgp_node_get() lock. */ |
| 2546 | bgp_unlock_node (rn); |
| 2547 | |
| 2548 | return 0; |
| 2549 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2550 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2551 | void |
| 2552 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2553 | { |
| 2554 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 2555 | struct attr attr; |
Jorge Boncompte [DTI2] | 577ac57 | 2012-05-07 16:53:06 +0000 | [diff] [blame] | 2556 | struct aspath *aspath; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2557 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2558 | struct peer *from; |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2559 | struct bgp_node *rn; |
| 2560 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2561 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2562 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2563 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2564 | return; |
| 2565 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2566 | bgp = peer->bgp; |
| 2567 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2568 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2569 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2570 | aspath = attr.aspath; |
| 2571 | attr.local_pref = bgp->default_local_pref; |
| 2572 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2573 | |
| 2574 | if (afi == AFI_IP) |
| 2575 | str2prefix ("0.0.0.0/0", &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2576 | else if (afi == AFI_IP6) |
| 2577 | { |
Jorge Boncompte [DTI2] | 6182d65 | 2012-05-07 16:53:02 +0000 | [diff] [blame] | 2578 | struct attr_extra *ae = attr.extra; |
| 2579 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2580 | str2prefix ("::/0", &p); |
| 2581 | |
| 2582 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2583 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2584 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2585 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2586 | |
| 2587 | /* If the peer is on shared nextwork and we have link-local |
| 2588 | nexthop set it. */ |
| 2589 | if (peer->shared_network |
| 2590 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2591 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2592 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2593 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2594 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2595 | } |
| 2596 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2597 | |
| 2598 | if (peer->default_rmap[afi][safi].name) |
| 2599 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2600 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2601 | for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn)) |
| 2602 | { |
| 2603 | for (ri = rn->info; ri; ri = ri->next) |
| 2604 | { |
| 2605 | struct attr dummy_attr; |
| 2606 | struct attr_extra dummy_extra; |
| 2607 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2608 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2609 | /* Provide dummy so the route-map can't modify the attributes */ |
| 2610 | dummy_attr.extra = &dummy_extra; |
| 2611 | bgp_attr_dup(&dummy_attr, ri->attr); |
| 2612 | info.peer = ri->peer; |
| 2613 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2614 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2615 | ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p, |
| 2616 | RMAP_BGP, &info); |
| 2617 | |
| 2618 | /* The route map might have set attributes. If we don't flush them |
| 2619 | * here, they will be leaked. */ |
| 2620 | bgp_attr_flush(&dummy_attr); |
| 2621 | if (ret != RMAP_DENYMATCH) |
| 2622 | break; |
| 2623 | } |
| 2624 | if (ret != RMAP_DENYMATCH) |
| 2625 | break; |
| 2626 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2627 | bgp->peer_self->rmap_type = 0; |
| 2628 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2629 | if (ret == RMAP_DENYMATCH) |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2630 | withdraw = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2631 | } |
| 2632 | |
| 2633 | if (withdraw) |
| 2634 | { |
| 2635 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2636 | bgp_default_withdraw_send (peer, afi, safi); |
| 2637 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2638 | } |
| 2639 | else |
| 2640 | { |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2641 | if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2642 | { |
| 2643 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2644 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2645 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2646 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2647 | |
| 2648 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2649 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2650 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2651 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2652 | static void |
| 2653 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2654 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2655 | { |
| 2656 | struct bgp_node *rn; |
| 2657 | struct bgp_info *ri; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2658 | struct attr attr; |
| 2659 | struct attr_extra extra; |
| 2660 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2661 | memset(&extra, 0, sizeof(extra)); |
| 2662 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2663 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2664 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2665 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2666 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2667 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2668 | bgp_default_originate (peer, afi, safi, 0); |
| 2669 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2670 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 2671 | attr.extra = &extra; |
| 2672 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2673 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2674 | for (ri = rn->info; ri; ri = ri->next) |
| 2675 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2676 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2677 | if ( (rsclient) ? |
| 2678 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2679 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2680 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2681 | else |
| 2682 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2683 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2684 | |
| 2685 | bgp_attr_flush_encap(&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2686 | } |
| 2687 | |
| 2688 | void |
| 2689 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2690 | { |
| 2691 | struct bgp_node *rn; |
| 2692 | struct bgp_table *table; |
| 2693 | |
| 2694 | if (peer->status != Established) |
| 2695 | return; |
| 2696 | |
| 2697 | if (! peer->afc_nego[afi][safi]) |
| 2698 | return; |
| 2699 | |
| 2700 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2701 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2702 | return; |
| 2703 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2704 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2705 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2706 | else |
| 2707 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2708 | rn = bgp_route_next(rn)) |
| 2709 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2710 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2711 | |
| 2712 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2713 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2714 | } |
| 2715 | |
| 2716 | void |
| 2717 | bgp_announce_route_all (struct peer *peer) |
| 2718 | { |
| 2719 | afi_t afi; |
| 2720 | safi_t safi; |
| 2721 | |
| 2722 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2723 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2724 | bgp_announce_route (peer, afi, safi); |
| 2725 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2726 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2727 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2728 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2729 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2730 | { |
| 2731 | struct bgp_node *rn; |
| 2732 | struct bgp_adj_in *ain; |
| 2733 | |
| 2734 | if (! table) |
| 2735 | table = rsclient->bgp->rib[afi][safi]; |
| 2736 | |
| 2737 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2738 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2739 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2740 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2741 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2742 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2743 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2744 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2745 | } |
| 2746 | } |
| 2747 | |
| 2748 | void |
| 2749 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2750 | { |
| 2751 | struct bgp_table *table; |
| 2752 | struct bgp_node *rn; |
| 2753 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2754 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2755 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2756 | |
| 2757 | else |
| 2758 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2759 | rn = bgp_route_next (rn)) |
| 2760 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2761 | { |
| 2762 | struct prefix_rd prd; |
| 2763 | prd.family = AF_UNSPEC; |
| 2764 | prd.prefixlen = 64; |
| 2765 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2766 | |
| 2767 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); |
| 2768 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2769 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2770 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2771 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2772 | 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] | 2773 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2774 | { |
| 2775 | int ret; |
| 2776 | struct bgp_node *rn; |
| 2777 | struct bgp_adj_in *ain; |
| 2778 | |
| 2779 | if (! table) |
| 2780 | table = peer->bgp->rib[afi][safi]; |
| 2781 | |
| 2782 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2783 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2784 | { |
| 2785 | if (ain->peer == peer) |
| 2786 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2787 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2788 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2789 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2790 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2791 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2792 | prd, tag, 1); |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2793 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2794 | if (ret < 0) |
| 2795 | { |
| 2796 | bgp_unlock_node (rn); |
| 2797 | return; |
| 2798 | } |
| 2799 | continue; |
| 2800 | } |
| 2801 | } |
| 2802 | } |
| 2803 | |
| 2804 | void |
| 2805 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2806 | { |
| 2807 | struct bgp_node *rn; |
| 2808 | struct bgp_table *table; |
| 2809 | |
| 2810 | if (peer->status != Established) |
| 2811 | return; |
| 2812 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2813 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2814 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2815 | else |
| 2816 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2817 | rn = bgp_route_next (rn)) |
| 2818 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2819 | { |
| 2820 | struct prefix_rd prd; |
| 2821 | prd.family = AF_UNSPEC; |
| 2822 | prd.prefixlen = 64; |
| 2823 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2824 | |
| 2825 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); |
| 2826 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2827 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2828 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2829 | |
| 2830 | struct bgp_clear_node_queue |
| 2831 | { |
| 2832 | struct bgp_node *rn; |
| 2833 | enum bgp_clear_route_type purpose; |
| 2834 | }; |
| 2835 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2836 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2837 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2838 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2839 | struct bgp_clear_node_queue *cnq = data; |
| 2840 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2841 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2842 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2843 | afi_t afi = bgp_node_table (rn)->afi; |
| 2844 | safi_t safi = bgp_node_table (rn)->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2845 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2846 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2847 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2848 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2849 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2850 | { |
| 2851 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2852 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2853 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2854 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2855 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2856 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2857 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2858 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2859 | break; |
| 2860 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2861 | return WQ_SUCCESS; |
| 2862 | } |
| 2863 | |
| 2864 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2865 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2866 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2867 | struct bgp_clear_node_queue *cnq = data; |
| 2868 | struct bgp_node *rn = cnq->rn; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2869 | struct bgp_table *table = bgp_node_table (rn); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2870 | |
| 2871 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2872 | bgp_table_unlock (table); |
| 2873 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2874 | } |
| 2875 | |
| 2876 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2877 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2878 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2879 | struct peer *peer = wq->spec.data; |
| 2880 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2881 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2882 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2883 | |
| 2884 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2885 | } |
| 2886 | |
| 2887 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2888 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2889 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2890 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2891 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2892 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2893 | #undef CLEAR_QUEUE_NAME_LEN |
| 2894 | |
| 2895 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2896 | { |
| 2897 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2898 | exit (1); |
| 2899 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2900 | peer->clear_node_queue->spec.hold = 10; |
| 2901 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2902 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2903 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2904 | peer->clear_node_queue->spec.max_retries = 0; |
| 2905 | |
| 2906 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2907 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2908 | } |
| 2909 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2910 | static void |
| 2911 | 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] | 2912 | struct bgp_table *table, struct peer *rsclient, |
| 2913 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2914 | { |
| 2915 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2916 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2917 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2918 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2919 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2920 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2921 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2922 | if (! table) |
| 2923 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2924 | |
| 2925 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2926 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2927 | struct bgp_info *ri; |
| 2928 | struct bgp_adj_in *ain; |
| 2929 | struct bgp_adj_out *aout; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2930 | |
| 2931 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2932 | * queued for every clearing peer, regardless of whether it is |
| 2933 | * relevant to the peer at hand. |
| 2934 | * |
| 2935 | * Overview: There are 3 different indices which need to be |
| 2936 | * scrubbed, potentially, when a peer is removed: |
| 2937 | * |
| 2938 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2939 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2940 | * 3 other routes visible by the peer's adj-out index |
| 2941 | * |
| 2942 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2943 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2944 | * adj-outs at our leisure. |
| 2945 | * |
| 2946 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2947 | * invisible via RIB index before peer session is allowed to be |
| 2948 | * brought back up. So one needs to know when such a 'search' is |
| 2949 | * complete. |
| 2950 | * |
| 2951 | * Ideally: |
| 2952 | * |
| 2953 | * - there'd be a single global queue or a single RIB walker |
| 2954 | * - rather than tracking which route_nodes still need to be |
| 2955 | * examined on a peer basis, we'd track which peers still |
| 2956 | * aren't cleared |
| 2957 | * |
| 2958 | * Given that our per-peer prefix-counts now should be reliable, |
| 2959 | * this may actually be achievable. It doesn't seem to be a huge |
| 2960 | * problem at this time, |
| 2961 | */ |
Jorge Boncompte [DTI2] | 24e50f2 | 2012-05-07 15:17:33 +0000 | [diff] [blame] | 2962 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2963 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2964 | { |
| 2965 | bgp_adj_in_remove (rn, ain); |
| 2966 | bgp_unlock_node (rn); |
| 2967 | break; |
| 2968 | } |
| 2969 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2970 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2971 | { |
| 2972 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2973 | bgp_unlock_node (rn); |
| 2974 | break; |
| 2975 | } |
| 2976 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2977 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2978 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2979 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2980 | struct bgp_clear_node_queue *cnq; |
| 2981 | |
| 2982 | /* both unlocked in bgp_clear_node_queue_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2983 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2984 | bgp_lock_node (rn); |
| 2985 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2986 | sizeof (struct bgp_clear_node_queue)); |
| 2987 | cnq->rn = rn; |
| 2988 | cnq->purpose = purpose; |
| 2989 | work_queue_add (peer->clear_node_queue, cnq); |
| 2990 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2991 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2992 | } |
| 2993 | return; |
| 2994 | } |
| 2995 | |
| 2996 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2997 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2998 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2999 | { |
| 3000 | struct bgp_node *rn; |
| 3001 | struct bgp_table *table; |
| 3002 | struct peer *rsclient; |
| 3003 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 3004 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3005 | if (peer->clear_node_queue == NULL) |
| 3006 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3007 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 3008 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 3009 | * Idle until it receives a Clearing_Completed event. This protects |
| 3010 | * against peers which flap faster than we can we clear, which could |
| 3011 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3012 | * |
| 3013 | * a) race with routes from the new session being installed before |
| 3014 | * clear_route_node visits the node (to delete the route of that |
| 3015 | * peer) |
| 3016 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 3017 | * on the process_main queue. Fast-flapping could cause that queue |
| 3018 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3019 | */ |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3020 | |
| 3021 | /* lock peer in assumption that clear-node-queue will get nodes; if so, |
| 3022 | * the unlock will happen upon work-queue completion; other wise, the |
| 3023 | * unlock happens at the end of this function. |
| 3024 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 3025 | if (!peer->clear_node_queue->thread) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3026 | peer_lock (peer); /* bgp_clear_node_complete */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3027 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3028 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3029 | case BGP_CLEAR_ROUTE_NORMAL: |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3030 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3031 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 3032 | else |
| 3033 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 3034 | rn = bgp_route_next (rn)) |
| 3035 | if ((table = rn->info) != NULL) |
| 3036 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 3037 | |
| 3038 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 3039 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 3040 | PEER_FLAG_RSERVER_CLIENT)) |
| 3041 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 3042 | break; |
| 3043 | |
| 3044 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3045 | /* |
| 3046 | * gpz 091009: TBD why don't we have special handling for |
| 3047 | * SAFI_MPLS_VPN here in the original quagga code? |
| 3048 | * (and, by extension, for SAFI_ENCAP) |
| 3049 | */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3050 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 3051 | break; |
| 3052 | |
| 3053 | default: |
| 3054 | assert (0); |
| 3055 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3056 | } |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3057 | |
| 3058 | /* unlock if no nodes got added to the clear-node-queue. */ |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 3059 | if (!peer->clear_node_queue->thread) |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3060 | peer_unlock (peer); |
| 3061 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3062 | } |
| 3063 | |
| 3064 | void |
| 3065 | bgp_clear_route_all (struct peer *peer) |
| 3066 | { |
| 3067 | afi_t afi; |
| 3068 | safi_t safi; |
| 3069 | |
| 3070 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3071 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3072 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3073 | } |
| 3074 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3075 | /* |
| 3076 | * Finish freeing things when exiting |
| 3077 | */ |
| 3078 | static void |
| 3079 | bgp_drain_workqueue_immediate (struct work_queue *wq) |
| 3080 | { |
| 3081 | if (!wq) |
| 3082 | return; |
| 3083 | |
| 3084 | if (!wq->thread) |
| 3085 | { |
| 3086 | /* |
| 3087 | * no thread implies no queued items |
| 3088 | */ |
| 3089 | assert(!wq->items->count); |
| 3090 | return; |
| 3091 | } |
| 3092 | |
| 3093 | while (wq->items->count) |
| 3094 | { |
| 3095 | if (wq->thread) |
| 3096 | thread_cancel(wq->thread); |
| 3097 | work_queue_run(wq->thread); |
| 3098 | } |
| 3099 | } |
| 3100 | |
| 3101 | /* |
| 3102 | * Special function to process clear node queue when bgpd is exiting |
| 3103 | * and the thread scheduler is no longer running. |
| 3104 | */ |
| 3105 | void |
| 3106 | bgp_peer_clear_node_queue_drain_immediate(struct peer *peer) |
| 3107 | { |
| 3108 | if (!peer) |
| 3109 | return; |
| 3110 | |
| 3111 | bgp_drain_workqueue_immediate(peer->clear_node_queue); |
| 3112 | } |
| 3113 | |
| 3114 | /* |
| 3115 | * The work queues are not specific to a BGP instance, but the |
| 3116 | * items in them refer to BGP instances, so this should be called |
| 3117 | * before each BGP instance is deleted. |
| 3118 | */ |
| 3119 | void |
| 3120 | bgp_process_queues_drain_immediate(void) |
| 3121 | { |
| 3122 | bgp_drain_workqueue_immediate(bm->process_main_queue); |
| 3123 | bgp_drain_workqueue_immediate(bm->process_rsclient_queue); |
| 3124 | } |
| 3125 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3126 | void |
| 3127 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 3128 | { |
| 3129 | struct bgp_table *table; |
| 3130 | struct bgp_node *rn; |
| 3131 | struct bgp_adj_in *ain; |
| 3132 | |
| 3133 | table = peer->bgp->rib[afi][safi]; |
| 3134 | |
| 3135 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3136 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 3137 | if (ain->peer == peer) |
| 3138 | { |
| 3139 | bgp_adj_in_remove (rn, ain); |
| 3140 | bgp_unlock_node (rn); |
| 3141 | break; |
| 3142 | } |
| 3143 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 3144 | |
| 3145 | void |
| 3146 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 3147 | { |
| 3148 | struct bgp_node *rn; |
| 3149 | struct bgp_info *ri; |
| 3150 | struct bgp_table *table; |
| 3151 | |
| 3152 | table = peer->bgp->rib[afi][safi]; |
| 3153 | |
| 3154 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3155 | { |
| 3156 | for (ri = rn->info; ri; ri = ri->next) |
| 3157 | if (ri->peer == peer) |
| 3158 | { |
| 3159 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 3160 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3161 | break; |
| 3162 | } |
| 3163 | } |
| 3164 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3165 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3166 | static void |
| 3167 | bgp_cleanup_table(struct bgp_table *table, safi_t safi) |
| 3168 | { |
| 3169 | struct bgp_node *rn; |
| 3170 | struct bgp_info *ri; |
| 3171 | struct bgp_info *next; |
| 3172 | |
| 3173 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3174 | for (ri = rn->info; ri; ri = next) |
| 3175 | { |
| 3176 | next = ri->next; |
| 3177 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3178 | && ri->type == ZEBRA_ROUTE_BGP |
| 3179 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 3180 | bgp_zebra_withdraw (&rn->p, ri, safi); |
| 3181 | } |
| 3182 | } |
| 3183 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3184 | /* Delete all kernel routes. */ |
| 3185 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3186 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3187 | { |
| 3188 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3189 | struct listnode *node, *nnode; |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3190 | afi_t afi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3191 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3192 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3193 | { |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3194 | for (afi = AFI_IP; afi < AFI_MAX; ++afi) |
| 3195 | { |
| 3196 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3197 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3198 | bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3199 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3200 | /* |
| 3201 | * VPN and ENCAP tables are two-level (RD is top level) |
| 3202 | */ |
| 3203 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn; |
| 3204 | rn = bgp_route_next (rn)) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3205 | { |
| 3206 | if (rn->info) |
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 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN); |
| 3209 | bgp_table_finish ((struct bgp_table **)&(rn->info)); |
| 3210 | rn->info = NULL; |
| 3211 | bgp_unlock_node(rn); |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3212 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3213 | } |
| 3214 | |
| 3215 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn; |
| 3216 | rn = bgp_route_next (rn)) |
| 3217 | { |
| 3218 | if (rn->info) |
| 3219 | { |
| 3220 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP); |
| 3221 | bgp_table_finish ((struct bgp_table **)&(rn->info)); |
| 3222 | rn->info = NULL; |
| 3223 | bgp_unlock_node(rn); |
| 3224 | } |
| 3225 | } |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3226 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3227 | } |
| 3228 | } |
| 3229 | |
| 3230 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3231 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3232 | { |
| 3233 | vty_reset (); |
| 3234 | bgp_zclient_reset (); |
| 3235 | access_list_reset (); |
| 3236 | prefix_list_reset (); |
| 3237 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3238 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3239 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3240 | value. */ |
| 3241 | int |
Paul Jakma | 518a4b7 | 2016-02-04 13:27:04 +0000 | [diff] [blame] | 3242 | bgp_nlri_parse_ip (struct peer *peer, struct attr *attr, |
| 3243 | struct bgp_nlri *packet) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3244 | { |
| 3245 | u_char *pnt; |
| 3246 | u_char *lim; |
| 3247 | struct prefix p; |
| 3248 | int psize; |
| 3249 | int ret; |
| 3250 | |
| 3251 | /* Check peer status. */ |
| 3252 | if (peer->status != Established) |
| 3253 | return 0; |
| 3254 | |
| 3255 | pnt = packet->nlri; |
| 3256 | lim = pnt + packet->length; |
| 3257 | |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3258 | /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for |
| 3259 | syntactic validity. If the field is syntactically incorrect, |
| 3260 | then the Error Subcode is set to Invalid Network Field. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3261 | for (; pnt < lim; pnt += psize) |
| 3262 | { |
| 3263 | /* Clear prefix structure. */ |
| 3264 | memset (&p, 0, sizeof (struct prefix)); |
| 3265 | |
| 3266 | /* Fetch prefix length. */ |
| 3267 | p.prefixlen = *pnt++; |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3268 | /* afi/safi validity already verified by caller, bgp_update_receive */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3269 | p.family = afi2family (packet->afi); |
| 3270 | |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3271 | /* Prefix length check. */ |
| 3272 | if (p.prefixlen > prefix_blen (&p) * 8) |
| 3273 | { |
| 3274 | plog_err (peer->log, |
| 3275 | "%s [Error] Update packet error" |
| 3276 | " (wrong prefix length %u for afi %u)", |
| 3277 | peer->host, p.prefixlen, packet->afi); |
| 3278 | return -1; |
| 3279 | } |
| 3280 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3281 | /* Packet size overflow check. */ |
| 3282 | psize = PSIZE (p.prefixlen); |
| 3283 | |
| 3284 | /* When packet overflow occur return immediately. */ |
| 3285 | if (pnt + psize > lim) |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3286 | { |
| 3287 | plog_err (peer->log, |
| 3288 | "%s [Error] Update packet error" |
| 3289 | " (prefix length %u overflows packet)", |
| 3290 | peer->host, p.prefixlen); |
| 3291 | return -1; |
| 3292 | } |
| 3293 | |
| 3294 | /* Defensive coding, double-check the psize fits in a struct prefix */ |
| 3295 | if (psize > (ssize_t) sizeof(p.u)) |
| 3296 | { |
| 3297 | plog_err (peer->log, |
| 3298 | "%s [Error] Update packet error" |
| 3299 | " (prefix length %u too large for prefix storage %zu!?!!", |
| 3300 | peer->host, p.prefixlen, sizeof(p.u)); |
| 3301 | return -1; |
| 3302 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3303 | |
| 3304 | /* Fetch prefix from NLRI packet. */ |
| 3305 | memcpy (&p.u.prefix, pnt, psize); |
| 3306 | |
| 3307 | /* Check address. */ |
| 3308 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3309 | { |
| 3310 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3311 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3312 | /* |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3313 | * From RFC4271 Section 6.3: |
| 3314 | * |
| 3315 | * If a prefix in the NLRI field is semantically incorrect |
| 3316 | * (e.g., an unexpected multicast IP address), an error SHOULD |
| 3317 | * be logged locally, and the prefix SHOULD be ignored. |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3318 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3319 | zlog (peer->log, LOG_ERR, |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3320 | "%s: IPv4 unicast NLRI is multicast address %s, ignoring", |
| 3321 | peer->host, inet_ntoa (p.u.prefix4)); |
| 3322 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3323 | } |
| 3324 | } |
| 3325 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3326 | /* Check address. */ |
| 3327 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3328 | { |
| 3329 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3330 | { |
| 3331 | char buf[BUFSIZ]; |
| 3332 | |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3333 | zlog (peer->log, LOG_ERR, |
| 3334 | "%s: IPv6 unicast NLRI is link-local address %s, ignoring", |
| 3335 | peer->host, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3336 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3337 | continue; |
| 3338 | } |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3339 | if (IN6_IS_ADDR_MULTICAST (&p.u.prefix6)) |
| 3340 | { |
| 3341 | char buf[BUFSIZ]; |
| 3342 | |
| 3343 | zlog (peer->log, LOG_ERR, |
| 3344 | "%s: IPv6 unicast NLRI is multicast address %s, ignoring", |
| 3345 | peer->host, |
| 3346 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3347 | continue; |
| 3348 | } |
| 3349 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3350 | |
| 3351 | /* Normal process. */ |
| 3352 | if (attr) |
| 3353 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3354 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3355 | else |
| 3356 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3357 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3358 | |
| 3359 | /* Address family configuration mismatch or maximum-prefix count |
| 3360 | overflow. */ |
| 3361 | if (ret < 0) |
| 3362 | return -1; |
| 3363 | } |
| 3364 | |
| 3365 | /* Packet length consistency check. */ |
| 3366 | if (pnt != lim) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3367 | { |
| 3368 | plog_err (peer->log, |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3369 | "%s [Error] Update packet error" |
| 3370 | " (prefix length mismatch with total length)", |
| 3371 | peer->host); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3372 | return -1; |
| 3373 | } |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3374 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3375 | return 0; |
| 3376 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3377 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3378 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3379 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3380 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3381 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3382 | } |
| 3383 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3384 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3385 | bgp_static_free (struct bgp_static *bgp_static) |
| 3386 | { |
| 3387 | if (bgp_static->rmap.name) |
| 3388 | free (bgp_static->rmap.name); |
| 3389 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3390 | } |
| 3391 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3392 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3393 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3394 | struct prefix *p, afi_t afi, safi_t safi) |
| 3395 | { |
| 3396 | struct bgp_node *rn; |
| 3397 | struct bgp_info *ri; |
| 3398 | |
| 3399 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3400 | |
| 3401 | /* Check selected route and self inserted route. */ |
| 3402 | for (ri = rn->info; ri; ri = ri->next) |
| 3403 | if (ri->peer == bgp->peer_self |
| 3404 | && ri->type == ZEBRA_ROUTE_BGP |
| 3405 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3406 | break; |
| 3407 | |
| 3408 | /* Withdraw static BGP route from routing table. */ |
| 3409 | if (ri) |
| 3410 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3411 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3412 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3413 | } |
| 3414 | |
| 3415 | /* Unlock bgp_node_lookup. */ |
| 3416 | bgp_unlock_node (rn); |
| 3417 | } |
| 3418 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3419 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3420 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3421 | struct bgp_static *bgp_static, |
| 3422 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3423 | { |
| 3424 | struct bgp_node *rn; |
| 3425 | struct bgp_info *ri; |
| 3426 | struct bgp_info *new; |
| 3427 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3428 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3429 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3430 | struct attr new_attr; |
| 3431 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3432 | struct bgp *bgp; |
| 3433 | int ret; |
| 3434 | char buf[SU_ADDRSTRLEN]; |
| 3435 | |
| 3436 | bgp = rsclient->bgp; |
| 3437 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3438 | assert (bgp_static); |
| 3439 | if (!bgp_static) |
| 3440 | return; |
| 3441 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3442 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3443 | |
| 3444 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3445 | |
| 3446 | attr.nexthop = bgp_static->igpnexthop; |
| 3447 | attr.med = bgp_static->igpmetric; |
| 3448 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3449 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3450 | if (bgp_static->atomic) |
| 3451 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3452 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3453 | /* Apply network route-map for export to this rsclient. */ |
| 3454 | if (bgp_static->rmap.name) |
| 3455 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3456 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3457 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3458 | info.attr = &attr_tmp; |
| 3459 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3460 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3461 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3462 | |
| 3463 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3464 | |
| 3465 | rsclient->rmap_type = 0; |
| 3466 | |
| 3467 | if (ret == RMAP_DENYMATCH) |
| 3468 | { |
| 3469 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3470 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3471 | |
| 3472 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3473 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3474 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3475 | bgp_attr_extra_free (&attr); |
| 3476 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3477 | return; |
| 3478 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3479 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3480 | } |
| 3481 | else |
| 3482 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3483 | |
| 3484 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3485 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3486 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3487 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3488 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3489 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3490 | == RMAP_DENY) |
| 3491 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3492 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3493 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3494 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3495 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3496 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3497 | p->prefixlen, rsclient->host); |
| 3498 | |
| 3499 | bgp->peer_self->rmap_type = 0; |
| 3500 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3501 | bgp_attr_unintern (&attr_new); |
| 3502 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3503 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3504 | |
| 3505 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3506 | |
| 3507 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3508 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3509 | |
| 3510 | bgp->peer_self->rmap_type = 0; |
| 3511 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3512 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3513 | attr_new = bgp_attr_intern (&new_attr); |
| 3514 | |
| 3515 | for (ri = rn->info; ri; ri = ri->next) |
| 3516 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3517 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3518 | break; |
| 3519 | |
| 3520 | if (ri) |
| 3521 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3522 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3523 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3524 | { |
| 3525 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3526 | bgp_attr_unintern (&attr_new); |
| 3527 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3528 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3529 | return; |
| 3530 | } |
| 3531 | else |
| 3532 | { |
| 3533 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3534 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3535 | |
| 3536 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3537 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3538 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3539 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3540 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3541 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3542 | |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3543 | /* Nexthop reachability check. */ |
| 3544 | if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3545 | { |
| 3546 | if (bgp_find_or_add_nexthop (afi, ri, NULL, 0)) |
| 3547 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
| 3548 | else |
| 3549 | { |
| 3550 | if (BGP_DEBUG(nht, NHT)) |
| 3551 | { |
| 3552 | char buf1[INET6_ADDRSTRLEN]; |
| 3553 | inet_ntop(AF_INET, (const void *)&attr_new->nexthop, |
| 3554 | buf1, INET6_ADDRSTRLEN); |
| 3555 | zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1); |
| 3556 | } |
| 3557 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
| 3558 | } |
| 3559 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3560 | /* Process change. */ |
| 3561 | bgp_process (bgp, rn, afi, safi); |
| 3562 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3563 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3564 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3565 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3566 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3567 | } |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3568 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3569 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3570 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, |
| 3571 | attr_new, rn); |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3572 | /* Nexthop reachability check. */ |
| 3573 | if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3574 | { |
| 3575 | if (bgp_find_or_add_nexthop (afi, new, NULL, 0)) |
| 3576 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
| 3577 | else |
| 3578 | { |
| 3579 | if (BGP_DEBUG(nht, NHT)) |
| 3580 | { |
| 3581 | char buf1[INET6_ADDRSTRLEN]; |
| 3582 | inet_ntop(AF_INET, (const void *)&attr_new->nexthop, |
| 3583 | buf1, INET6_ADDRSTRLEN); |
| 3584 | zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1); |
| 3585 | } |
| 3586 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
| 3587 | } |
| 3588 | } |
| 3589 | else |
| 3590 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3591 | |
| 3592 | /* Register new BGP information. */ |
| 3593 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3594 | |
| 3595 | /* route_node_get lock */ |
| 3596 | bgp_unlock_node (rn); |
| 3597 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3598 | /* Process change. */ |
| 3599 | bgp_process (bgp, rn, afi, safi); |
| 3600 | |
| 3601 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3602 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3603 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3604 | } |
| 3605 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3606 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3607 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3608 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3609 | { |
| 3610 | struct bgp_node *rn; |
| 3611 | struct bgp_info *ri; |
| 3612 | struct bgp_info *new; |
| 3613 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3614 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3615 | struct attr *attr_new; |
| 3616 | int ret; |
| 3617 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3618 | assert (bgp_static); |
| 3619 | if (!bgp_static) |
| 3620 | return; |
| 3621 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3622 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3623 | |
| 3624 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3625 | |
| 3626 | attr.nexthop = bgp_static->igpnexthop; |
| 3627 | attr.med = bgp_static->igpmetric; |
| 3628 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3629 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3630 | if (bgp_static->atomic) |
| 3631 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3632 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3633 | /* Apply route-map. */ |
| 3634 | if (bgp_static->rmap.name) |
| 3635 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3636 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3637 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3638 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3639 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3640 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3641 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3642 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3643 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3644 | bgp->peer_self->rmap_type = 0; |
| 3645 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3646 | if (ret == RMAP_DENYMATCH) |
| 3647 | { |
| 3648 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3649 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3650 | |
| 3651 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3652 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3653 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3654 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3655 | return; |
| 3656 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3657 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3658 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3659 | else |
| 3660 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3661 | |
| 3662 | for (ri = rn->info; ri; ri = ri->next) |
| 3663 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3664 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3665 | break; |
| 3666 | |
| 3667 | if (ri) |
| 3668 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3669 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3670 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3671 | { |
| 3672 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3673 | bgp_attr_unintern (&attr_new); |
| 3674 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3675 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3676 | return; |
| 3677 | } |
| 3678 | else |
| 3679 | { |
| 3680 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3681 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3682 | |
| 3683 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3684 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3685 | bgp_info_restore(rn, ri); |
| 3686 | else |
| 3687 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3688 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3689 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3690 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3691 | |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3692 | /* Nexthop reachability check. */ |
| 3693 | if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3694 | { |
| 3695 | if (bgp_find_or_add_nexthop (afi, ri, NULL, 0)) |
| 3696 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
| 3697 | else |
| 3698 | { |
| 3699 | if (BGP_DEBUG(nht, NHT)) |
| 3700 | { |
| 3701 | char buf1[INET6_ADDRSTRLEN]; |
| 3702 | inet_ntop(AF_INET, (const void *)&attr_new->nexthop, |
| 3703 | buf1, INET6_ADDRSTRLEN); |
| 3704 | zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1); |
| 3705 | } |
| 3706 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
| 3707 | } |
| 3708 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3709 | /* Process change. */ |
| 3710 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3711 | bgp_process (bgp, rn, afi, safi); |
| 3712 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3713 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3714 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3715 | return; |
| 3716 | } |
| 3717 | } |
| 3718 | |
| 3719 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3720 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, attr_new, |
| 3721 | rn); |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3722 | /* Nexthop reachability check. */ |
| 3723 | if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3724 | { |
| 3725 | if (bgp_find_or_add_nexthop (afi, new, NULL, 0)) |
| 3726 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
| 3727 | else |
| 3728 | { |
| 3729 | if (BGP_DEBUG(nht, NHT)) |
| 3730 | { |
| 3731 | char buf1[INET6_ADDRSTRLEN]; |
| 3732 | inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, |
| 3733 | INET6_ADDRSTRLEN); |
| 3734 | zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1); |
| 3735 | } |
| 3736 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
| 3737 | } |
| 3738 | } |
| 3739 | else |
| 3740 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3741 | |
| 3742 | /* Aggregate address increment. */ |
| 3743 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3744 | |
| 3745 | /* Register new BGP information. */ |
| 3746 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3747 | |
| 3748 | /* route_node_get lock */ |
| 3749 | bgp_unlock_node (rn); |
| 3750 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3751 | /* Process change. */ |
| 3752 | bgp_process (bgp, rn, afi, safi); |
| 3753 | |
| 3754 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3755 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3756 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3757 | } |
| 3758 | |
| 3759 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3760 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3761 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3762 | { |
| 3763 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3764 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3765 | |
| 3766 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3767 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3768 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3769 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3770 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3771 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3772 | } |
| 3773 | } |
| 3774 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3775 | void |
| 3776 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3777 | safi_t safi) |
| 3778 | { |
| 3779 | struct bgp_node *rn; |
| 3780 | struct bgp_info *ri; |
| 3781 | |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3782 | /* Make new BGP info. */ |
| 3783 | rn = bgp_node_get (bgp->rib[afi][safi], p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3784 | |
| 3785 | /* Check selected route and self inserted route. */ |
| 3786 | for (ri = rn->info; ri; ri = ri->next) |
| 3787 | if (ri->peer == bgp->peer_self |
| 3788 | && ri->type == ZEBRA_ROUTE_BGP |
| 3789 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3790 | break; |
| 3791 | |
| 3792 | /* Withdraw static BGP route from routing table. */ |
| 3793 | if (ri) |
| 3794 | { |
| 3795 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 3796 | bgp_unlink_nexthop(ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3797 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3798 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3799 | } |
| 3800 | |
| 3801 | /* Unlock bgp_node_lookup. */ |
| 3802 | bgp_unlock_node (rn); |
| 3803 | } |
| 3804 | |
| 3805 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3806 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3807 | { |
| 3808 | struct bgp_static *bgp_static; |
| 3809 | struct bgp *bgp; |
| 3810 | struct bgp_node *rn; |
| 3811 | struct prefix *p; |
| 3812 | |
| 3813 | bgp = rsclient->bgp; |
| 3814 | |
| 3815 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3816 | if ((bgp_static = rn->info) != NULL) |
| 3817 | { |
| 3818 | p = &rn->p; |
| 3819 | |
| 3820 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3821 | afi, safi); |
| 3822 | } |
| 3823 | } |
| 3824 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3825 | /* |
| 3826 | * Used for SAFI_MPLS_VPN and SAFI_ENCAP |
| 3827 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3828 | static void |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3829 | bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3830 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3831 | { |
| 3832 | struct bgp_node *rn; |
| 3833 | struct bgp_info *ri; |
| 3834 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3835 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3836 | |
| 3837 | /* Check selected route and self inserted route. */ |
| 3838 | for (ri = rn->info; ri; ri = ri->next) |
| 3839 | if (ri->peer == bgp->peer_self |
| 3840 | && ri->type == ZEBRA_ROUTE_BGP |
| 3841 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3842 | break; |
| 3843 | |
| 3844 | /* Withdraw static BGP route from routing table. */ |
| 3845 | if (ri) |
| 3846 | { |
| 3847 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3848 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3849 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3850 | } |
| 3851 | |
| 3852 | /* Unlock bgp_node_lookup. */ |
| 3853 | bgp_unlock_node (rn); |
| 3854 | } |
| 3855 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3856 | static void |
| 3857 | bgp_static_update_safi (struct bgp *bgp, struct prefix *p, |
| 3858 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3859 | { |
| 3860 | struct bgp_node *rn; |
| 3861 | struct bgp_info *new; |
| 3862 | struct attr *attr_new; |
| 3863 | struct attr attr = { 0 }; |
| 3864 | struct bgp_info *ri; |
| 3865 | |
| 3866 | assert (bgp_static); |
| 3867 | |
| 3868 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd); |
| 3869 | |
| 3870 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 3871 | |
| 3872 | attr.nexthop = bgp_static->igpnexthop; |
| 3873 | attr.med = bgp_static->igpmetric; |
| 3874 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 3875 | |
| 3876 | /* Apply route-map. */ |
| 3877 | if (bgp_static->rmap.name) |
| 3878 | { |
| 3879 | struct attr attr_tmp = attr; |
| 3880 | struct bgp_info info; |
| 3881 | int ret; |
| 3882 | |
| 3883 | info.peer = bgp->peer_self; |
| 3884 | info.attr = &attr_tmp; |
| 3885 | |
| 3886 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3887 | |
| 3888 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3889 | |
| 3890 | bgp->peer_self->rmap_type = 0; |
| 3891 | |
| 3892 | if (ret == RMAP_DENYMATCH) |
| 3893 | { |
| 3894 | /* Free uninterned attribute. */ |
| 3895 | bgp_attr_flush (&attr_tmp); |
| 3896 | |
| 3897 | /* Unintern original. */ |
| 3898 | aspath_unintern (&attr.aspath); |
| 3899 | bgp_attr_extra_free (&attr); |
| 3900 | bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd, |
| 3901 | bgp_static->tag); |
| 3902 | return; |
| 3903 | } |
| 3904 | |
| 3905 | attr_new = bgp_attr_intern (&attr_tmp); |
| 3906 | } |
| 3907 | else |
| 3908 | { |
| 3909 | attr_new = bgp_attr_intern (&attr); |
| 3910 | } |
| 3911 | |
| 3912 | for (ri = rn->info; ri; ri = ri->next) |
| 3913 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3914 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3915 | break; |
| 3916 | |
| 3917 | if (ri) |
| 3918 | { |
| 3919 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3920 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3921 | { |
| 3922 | bgp_unlock_node (rn); |
| 3923 | bgp_attr_unintern (&attr_new); |
| 3924 | aspath_unintern (&attr.aspath); |
| 3925 | bgp_attr_extra_free (&attr); |
| 3926 | return; |
| 3927 | } |
| 3928 | else |
| 3929 | { |
| 3930 | /* The attribute is changed. */ |
| 3931 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
| 3932 | |
| 3933 | /* Rewrite BGP route information. */ |
| 3934 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3935 | bgp_info_restore(rn, ri); |
| 3936 | else |
| 3937 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 3938 | bgp_attr_unintern (&ri->attr); |
| 3939 | ri->attr = attr_new; |
| 3940 | ri->uptime = bgp_clock (); |
| 3941 | |
| 3942 | /* Process change. */ |
| 3943 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3944 | bgp_process (bgp, rn, afi, safi); |
| 3945 | bgp_unlock_node (rn); |
| 3946 | aspath_unintern (&attr.aspath); |
| 3947 | bgp_attr_extra_free (&attr); |
| 3948 | return; |
| 3949 | } |
| 3950 | } |
| 3951 | |
| 3952 | |
| 3953 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3954 | new = info_make (ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, |
| 3955 | attr_new, rn); |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3956 | SET_FLAG (new->flags, BGP_INFO_VALID); |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3957 | new->extra = bgp_info_extra_new(); |
| 3958 | memcpy (new->extra->tag, bgp_static->tag, 3); |
| 3959 | |
| 3960 | /* Aggregate address increment. */ |
| 3961 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3962 | |
| 3963 | /* Register new BGP information. */ |
| 3964 | bgp_info_add (rn, new); |
| 3965 | |
| 3966 | /* route_node_get lock */ |
| 3967 | bgp_unlock_node (rn); |
| 3968 | |
| 3969 | /* Process change. */ |
| 3970 | bgp_process (bgp, rn, afi, safi); |
| 3971 | |
| 3972 | /* Unintern original. */ |
| 3973 | aspath_unintern (&attr.aspath); |
| 3974 | bgp_attr_extra_free (&attr); |
| 3975 | } |
| 3976 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3977 | /* Configure static BGP network. When user don't run zebra, static |
| 3978 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3979 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3980 | 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] | 3981 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3982 | { |
| 3983 | int ret; |
| 3984 | struct prefix p; |
| 3985 | struct bgp_static *bgp_static; |
| 3986 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3987 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3988 | |
| 3989 | /* Convert IP prefix string to struct prefix. */ |
| 3990 | ret = str2prefix (ip_str, &p); |
| 3991 | if (! ret) |
| 3992 | { |
| 3993 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3994 | return CMD_WARNING; |
| 3995 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3996 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3997 | { |
| 3998 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3999 | VTY_NEWLINE); |
| 4000 | return CMD_WARNING; |
| 4001 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4002 | |
| 4003 | apply_mask (&p); |
| 4004 | |
| 4005 | /* Set BGP static route configuration. */ |
| 4006 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 4007 | |
| 4008 | if (rn->info) |
| 4009 | { |
| 4010 | /* Configuration change. */ |
| 4011 | bgp_static = rn->info; |
| 4012 | |
| 4013 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4014 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 4015 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4016 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4017 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4018 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4019 | if (rmap) |
| 4020 | { |
| 4021 | if (bgp_static->rmap.name) |
| 4022 | free (bgp_static->rmap.name); |
| 4023 | bgp_static->rmap.name = strdup (rmap); |
| 4024 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 4025 | } |
| 4026 | else |
| 4027 | { |
| 4028 | if (bgp_static->rmap.name) |
| 4029 | free (bgp_static->rmap.name); |
| 4030 | bgp_static->rmap.name = NULL; |
| 4031 | bgp_static->rmap.map = NULL; |
| 4032 | bgp_static->valid = 0; |
| 4033 | } |
| 4034 | bgp_unlock_node (rn); |
| 4035 | } |
| 4036 | else |
| 4037 | { |
| 4038 | /* New configuration. */ |
| 4039 | bgp_static = bgp_static_new (); |
| 4040 | bgp_static->backdoor = backdoor; |
| 4041 | bgp_static->valid = 0; |
| 4042 | bgp_static->igpmetric = 0; |
| 4043 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4044 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4045 | if (rmap) |
| 4046 | { |
| 4047 | if (bgp_static->rmap.name) |
| 4048 | free (bgp_static->rmap.name); |
| 4049 | bgp_static->rmap.name = strdup (rmap); |
| 4050 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 4051 | } |
| 4052 | rn->info = bgp_static; |
| 4053 | } |
| 4054 | |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 4055 | bgp_static->valid = 1; |
| 4056 | if (need_update) |
| 4057 | bgp_static_withdraw (bgp, &p, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4058 | |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 4059 | if (! bgp_static->backdoor) |
| 4060 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4061 | |
| 4062 | return CMD_SUCCESS; |
| 4063 | } |
| 4064 | |
| 4065 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4066 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4067 | 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] | 4068 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4069 | { |
| 4070 | int ret; |
| 4071 | struct prefix p; |
| 4072 | struct bgp_static *bgp_static; |
| 4073 | struct bgp_node *rn; |
| 4074 | |
| 4075 | /* Convert IP prefix string to struct prefix. */ |
| 4076 | ret = str2prefix (ip_str, &p); |
| 4077 | if (! ret) |
| 4078 | { |
| 4079 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4080 | return CMD_WARNING; |
| 4081 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4082 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 4083 | { |
| 4084 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 4085 | VTY_NEWLINE); |
| 4086 | return CMD_WARNING; |
| 4087 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4088 | |
| 4089 | apply_mask (&p); |
| 4090 | |
| 4091 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 4092 | if (! rn) |
| 4093 | { |
| 4094 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 4095 | VTY_NEWLINE); |
| 4096 | return CMD_WARNING; |
| 4097 | } |
| 4098 | |
| 4099 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4100 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4101 | /* Update BGP RIB. */ |
| 4102 | if (! bgp_static->backdoor) |
| 4103 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 4104 | |
| 4105 | /* Clear configuration. */ |
| 4106 | bgp_static_free (bgp_static); |
| 4107 | rn->info = NULL; |
| 4108 | bgp_unlock_node (rn); |
| 4109 | bgp_unlock_node (rn); |
| 4110 | |
| 4111 | return CMD_SUCCESS; |
| 4112 | } |
| 4113 | |
| 4114 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 4115 | instance. */ |
| 4116 | void |
| 4117 | bgp_static_delete (struct bgp *bgp) |
| 4118 | { |
| 4119 | afi_t afi; |
| 4120 | safi_t safi; |
| 4121 | struct bgp_node *rn; |
| 4122 | struct bgp_node *rm; |
| 4123 | struct bgp_table *table; |
| 4124 | struct bgp_static *bgp_static; |
| 4125 | |
| 4126 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 4127 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 4128 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 4129 | if (rn->info != NULL) |
| 4130 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4131 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4132 | { |
| 4133 | table = rn->info; |
| 4134 | |
| 4135 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 4136 | { |
| 4137 | bgp_static = rn->info; |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4138 | bgp_static_withdraw_safi (bgp, &rm->p, |
| 4139 | AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4140 | (struct prefix_rd *)&rn->p, |
| 4141 | bgp_static->tag); |
| 4142 | bgp_static_free (bgp_static); |
| 4143 | rn->info = NULL; |
| 4144 | bgp_unlock_node (rn); |
| 4145 | } |
| 4146 | } |
| 4147 | else |
| 4148 | { |
| 4149 | bgp_static = rn->info; |
| 4150 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 4151 | bgp_static_free (bgp_static); |
| 4152 | rn->info = NULL; |
| 4153 | bgp_unlock_node (rn); |
| 4154 | } |
| 4155 | } |
| 4156 | } |
| 4157 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4158 | /* |
| 4159 | * gpz 110624 |
| 4160 | * Currently this is used to set static routes for VPN and ENCAP. |
| 4161 | * I think it can probably be factored with bgp_static_set. |
| 4162 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4163 | int |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4164 | bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str, |
| 4165 | const char *rd_str, const char *tag_str, |
| 4166 | const char *rmap_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4167 | { |
| 4168 | int ret; |
| 4169 | struct prefix p; |
| 4170 | struct prefix_rd prd; |
| 4171 | struct bgp *bgp; |
| 4172 | struct bgp_node *prn; |
| 4173 | struct bgp_node *rn; |
| 4174 | struct bgp_table *table; |
| 4175 | struct bgp_static *bgp_static; |
| 4176 | u_char tag[3]; |
| 4177 | |
| 4178 | bgp = vty->index; |
| 4179 | |
| 4180 | ret = str2prefix (ip_str, &p); |
| 4181 | if (! ret) |
| 4182 | { |
| 4183 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4184 | return CMD_WARNING; |
| 4185 | } |
| 4186 | apply_mask (&p); |
| 4187 | |
| 4188 | ret = str2prefix_rd (rd_str, &prd); |
| 4189 | if (! ret) |
| 4190 | { |
| 4191 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4192 | return CMD_WARNING; |
| 4193 | } |
| 4194 | |
| 4195 | ret = str2tag (tag_str, tag); |
| 4196 | if (! ret) |
| 4197 | { |
| 4198 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4199 | return CMD_WARNING; |
| 4200 | } |
| 4201 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4202 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4203 | (struct prefix *)&prd); |
| 4204 | if (prn->info == NULL) |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4205 | prn->info = bgp_table_init (AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4206 | else |
| 4207 | bgp_unlock_node (prn); |
| 4208 | table = prn->info; |
| 4209 | |
| 4210 | rn = bgp_node_get (table, &p); |
| 4211 | |
| 4212 | if (rn->info) |
| 4213 | { |
| 4214 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 4215 | bgp_unlock_node (rn); |
| 4216 | } |
| 4217 | else |
| 4218 | { |
| 4219 | /* New configuration. */ |
| 4220 | bgp_static = bgp_static_new (); |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4221 | bgp_static->backdoor = 0; |
| 4222 | bgp_static->valid = 0; |
| 4223 | bgp_static->igpmetric = 0; |
| 4224 | bgp_static->igpnexthop.s_addr = 0; |
| 4225 | memcpy(bgp_static->tag, tag, 3); |
| 4226 | bgp_static->prd = prd; |
| 4227 | |
| 4228 | if (rmap_str) |
| 4229 | { |
| 4230 | if (bgp_static->rmap.name) |
| 4231 | free (bgp_static->rmap.name); |
| 4232 | bgp_static->rmap.name = strdup (rmap_str); |
| 4233 | bgp_static->rmap.map = route_map_lookup_by_name (rmap_str); |
| 4234 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4235 | rn->info = bgp_static; |
| 4236 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4237 | bgp_static->valid = 1; |
| 4238 | bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4239 | } |
| 4240 | |
| 4241 | return CMD_SUCCESS; |
| 4242 | } |
| 4243 | |
| 4244 | /* Configure static BGP network. */ |
| 4245 | int |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4246 | bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str, |
| 4247 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4248 | { |
| 4249 | int ret; |
| 4250 | struct bgp *bgp; |
| 4251 | struct prefix p; |
| 4252 | struct prefix_rd prd; |
| 4253 | struct bgp_node *prn; |
| 4254 | struct bgp_node *rn; |
| 4255 | struct bgp_table *table; |
| 4256 | struct bgp_static *bgp_static; |
| 4257 | u_char tag[3]; |
| 4258 | |
| 4259 | bgp = vty->index; |
| 4260 | |
| 4261 | /* Convert IP prefix string to struct prefix. */ |
| 4262 | ret = str2prefix (ip_str, &p); |
| 4263 | if (! ret) |
| 4264 | { |
| 4265 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4266 | return CMD_WARNING; |
| 4267 | } |
| 4268 | apply_mask (&p); |
| 4269 | |
| 4270 | ret = str2prefix_rd (rd_str, &prd); |
| 4271 | if (! ret) |
| 4272 | { |
| 4273 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4274 | return CMD_WARNING; |
| 4275 | } |
| 4276 | |
| 4277 | ret = str2tag (tag_str, tag); |
| 4278 | if (! ret) |
| 4279 | { |
| 4280 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4281 | return CMD_WARNING; |
| 4282 | } |
| 4283 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4284 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4285 | (struct prefix *)&prd); |
| 4286 | if (prn->info == NULL) |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4287 | prn->info = bgp_table_init (AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4288 | else |
| 4289 | bgp_unlock_node (prn); |
| 4290 | table = prn->info; |
| 4291 | |
| 4292 | rn = bgp_node_lookup (table, &p); |
| 4293 | |
| 4294 | if (rn) |
| 4295 | { |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4296 | bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4297 | |
| 4298 | bgp_static = rn->info; |
| 4299 | bgp_static_free (bgp_static); |
| 4300 | rn->info = NULL; |
| 4301 | bgp_unlock_node (rn); |
| 4302 | bgp_unlock_node (rn); |
| 4303 | } |
| 4304 | else |
| 4305 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 4306 | |
| 4307 | return CMD_SUCCESS; |
| 4308 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4309 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4310 | DEFUN (bgp_network, |
| 4311 | bgp_network_cmd, |
| 4312 | "network A.B.C.D/M", |
| 4313 | "Specify a network to announce via BGP\n" |
| 4314 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4315 | { |
| 4316 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4317 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4318 | } |
| 4319 | |
| 4320 | DEFUN (bgp_network_route_map, |
| 4321 | bgp_network_route_map_cmd, |
| 4322 | "network A.B.C.D/M route-map WORD", |
| 4323 | "Specify a network to announce via BGP\n" |
| 4324 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4325 | "Route-map to modify the attributes\n" |
| 4326 | "Name of the route map\n") |
| 4327 | { |
| 4328 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4329 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4330 | } |
| 4331 | |
| 4332 | DEFUN (bgp_network_backdoor, |
| 4333 | bgp_network_backdoor_cmd, |
| 4334 | "network A.B.C.D/M backdoor", |
| 4335 | "Specify a network to announce via BGP\n" |
| 4336 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4337 | "Specify a BGP backdoor route\n") |
| 4338 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4339 | 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] | 4340 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4341 | } |
| 4342 | |
| 4343 | DEFUN (bgp_network_mask, |
| 4344 | bgp_network_mask_cmd, |
| 4345 | "network A.B.C.D mask A.B.C.D", |
| 4346 | "Specify a network to announce via BGP\n" |
| 4347 | "Network number\n" |
| 4348 | "Network mask\n" |
| 4349 | "Network mask\n") |
| 4350 | { |
| 4351 | int ret; |
| 4352 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4353 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4354 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4355 | if (! ret) |
| 4356 | { |
| 4357 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4358 | return CMD_WARNING; |
| 4359 | } |
| 4360 | |
| 4361 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4362 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4363 | } |
| 4364 | |
| 4365 | DEFUN (bgp_network_mask_route_map, |
| 4366 | bgp_network_mask_route_map_cmd, |
| 4367 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4368 | "Specify a network to announce via BGP\n" |
| 4369 | "Network number\n" |
| 4370 | "Network mask\n" |
| 4371 | "Network mask\n" |
| 4372 | "Route-map to modify the attributes\n" |
| 4373 | "Name of the route map\n") |
| 4374 | { |
| 4375 | int ret; |
| 4376 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4377 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4378 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4379 | if (! ret) |
| 4380 | { |
| 4381 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4382 | return CMD_WARNING; |
| 4383 | } |
| 4384 | |
| 4385 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4386 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4387 | } |
| 4388 | |
| 4389 | DEFUN (bgp_network_mask_backdoor, |
| 4390 | bgp_network_mask_backdoor_cmd, |
| 4391 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4392 | "Specify a network to announce via BGP\n" |
| 4393 | "Network number\n" |
| 4394 | "Network mask\n" |
| 4395 | "Network mask\n" |
| 4396 | "Specify a BGP backdoor route\n") |
| 4397 | { |
| 4398 | int ret; |
| 4399 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4400 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4401 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4402 | if (! ret) |
| 4403 | { |
| 4404 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4405 | return CMD_WARNING; |
| 4406 | } |
| 4407 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4408 | 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] | 4409 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4410 | } |
| 4411 | |
| 4412 | DEFUN (bgp_network_mask_natural, |
| 4413 | bgp_network_mask_natural_cmd, |
| 4414 | "network A.B.C.D", |
| 4415 | "Specify a network to announce via BGP\n" |
| 4416 | "Network number\n") |
| 4417 | { |
| 4418 | int ret; |
| 4419 | char prefix_str[BUFSIZ]; |
| 4420 | |
| 4421 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4422 | if (! ret) |
| 4423 | { |
| 4424 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4425 | return CMD_WARNING; |
| 4426 | } |
| 4427 | |
| 4428 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4429 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4430 | } |
| 4431 | |
| 4432 | DEFUN (bgp_network_mask_natural_route_map, |
| 4433 | bgp_network_mask_natural_route_map_cmd, |
| 4434 | "network A.B.C.D route-map WORD", |
| 4435 | "Specify a network to announce via BGP\n" |
| 4436 | "Network number\n" |
| 4437 | "Route-map to modify the attributes\n" |
| 4438 | "Name of the route map\n") |
| 4439 | { |
| 4440 | int ret; |
| 4441 | char prefix_str[BUFSIZ]; |
| 4442 | |
| 4443 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4444 | if (! ret) |
| 4445 | { |
| 4446 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4447 | return CMD_WARNING; |
| 4448 | } |
| 4449 | |
| 4450 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4451 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4452 | } |
| 4453 | |
| 4454 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4455 | bgp_network_mask_natural_backdoor_cmd, |
| 4456 | "network A.B.C.D backdoor", |
| 4457 | "Specify a network to announce via BGP\n" |
| 4458 | "Network number\n" |
| 4459 | "Specify a BGP backdoor route\n") |
| 4460 | { |
| 4461 | int ret; |
| 4462 | char prefix_str[BUFSIZ]; |
| 4463 | |
| 4464 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4465 | if (! ret) |
| 4466 | { |
| 4467 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4468 | return CMD_WARNING; |
| 4469 | } |
| 4470 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4471 | 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] | 4472 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4473 | } |
| 4474 | |
| 4475 | DEFUN (no_bgp_network, |
| 4476 | no_bgp_network_cmd, |
| 4477 | "no network A.B.C.D/M", |
| 4478 | NO_STR |
| 4479 | "Specify a network to announce via BGP\n" |
| 4480 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4481 | { |
| 4482 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4483 | bgp_node_safi (vty)); |
| 4484 | } |
| 4485 | |
| 4486 | ALIAS (no_bgp_network, |
| 4487 | no_bgp_network_route_map_cmd, |
| 4488 | "no network A.B.C.D/M route-map WORD", |
| 4489 | NO_STR |
| 4490 | "Specify a network to announce via BGP\n" |
| 4491 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4492 | "Route-map to modify the attributes\n" |
| 4493 | "Name of the route map\n") |
| 4494 | |
| 4495 | ALIAS (no_bgp_network, |
| 4496 | no_bgp_network_backdoor_cmd, |
| 4497 | "no network A.B.C.D/M backdoor", |
| 4498 | NO_STR |
| 4499 | "Specify a network to announce via BGP\n" |
| 4500 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4501 | "Specify a BGP backdoor route\n") |
| 4502 | |
| 4503 | DEFUN (no_bgp_network_mask, |
| 4504 | no_bgp_network_mask_cmd, |
| 4505 | "no network A.B.C.D mask A.B.C.D", |
| 4506 | NO_STR |
| 4507 | "Specify a network to announce via BGP\n" |
| 4508 | "Network number\n" |
| 4509 | "Network mask\n" |
| 4510 | "Network mask\n") |
| 4511 | { |
| 4512 | int ret; |
| 4513 | char prefix_str[BUFSIZ]; |
| 4514 | |
| 4515 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4516 | if (! ret) |
| 4517 | { |
| 4518 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4519 | return CMD_WARNING; |
| 4520 | } |
| 4521 | |
| 4522 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4523 | bgp_node_safi (vty)); |
| 4524 | } |
| 4525 | |
| 4526 | ALIAS (no_bgp_network_mask, |
| 4527 | no_bgp_network_mask_route_map_cmd, |
| 4528 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4529 | NO_STR |
| 4530 | "Specify a network to announce via BGP\n" |
| 4531 | "Network number\n" |
| 4532 | "Network mask\n" |
| 4533 | "Network mask\n" |
| 4534 | "Route-map to modify the attributes\n" |
| 4535 | "Name of the route map\n") |
| 4536 | |
| 4537 | ALIAS (no_bgp_network_mask, |
| 4538 | no_bgp_network_mask_backdoor_cmd, |
| 4539 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4540 | NO_STR |
| 4541 | "Specify a network to announce via BGP\n" |
| 4542 | "Network number\n" |
| 4543 | "Network mask\n" |
| 4544 | "Network mask\n" |
| 4545 | "Specify a BGP backdoor route\n") |
| 4546 | |
| 4547 | DEFUN (no_bgp_network_mask_natural, |
| 4548 | no_bgp_network_mask_natural_cmd, |
| 4549 | "no network A.B.C.D", |
| 4550 | NO_STR |
| 4551 | "Specify a network to announce via BGP\n" |
| 4552 | "Network number\n") |
| 4553 | { |
| 4554 | int ret; |
| 4555 | char prefix_str[BUFSIZ]; |
| 4556 | |
| 4557 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4558 | if (! ret) |
| 4559 | { |
| 4560 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4561 | return CMD_WARNING; |
| 4562 | } |
| 4563 | |
| 4564 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4565 | bgp_node_safi (vty)); |
| 4566 | } |
| 4567 | |
| 4568 | ALIAS (no_bgp_network_mask_natural, |
| 4569 | no_bgp_network_mask_natural_route_map_cmd, |
| 4570 | "no network A.B.C.D route-map WORD", |
| 4571 | NO_STR |
| 4572 | "Specify a network to announce via BGP\n" |
| 4573 | "Network number\n" |
| 4574 | "Route-map to modify the attributes\n" |
| 4575 | "Name of the route map\n") |
| 4576 | |
| 4577 | ALIAS (no_bgp_network_mask_natural, |
| 4578 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4579 | "no network A.B.C.D backdoor", |
| 4580 | NO_STR |
| 4581 | "Specify a network to announce via BGP\n" |
| 4582 | "Network number\n" |
| 4583 | "Specify a BGP backdoor route\n") |
| 4584 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4585 | DEFUN (ipv6_bgp_network, |
| 4586 | ipv6_bgp_network_cmd, |
| 4587 | "network X:X::X:X/M", |
| 4588 | "Specify a network to announce via BGP\n" |
| 4589 | "IPv6 prefix <network>/<length>\n") |
| 4590 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4591 | 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] | 4592 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4593 | } |
| 4594 | |
| 4595 | DEFUN (ipv6_bgp_network_route_map, |
| 4596 | ipv6_bgp_network_route_map_cmd, |
| 4597 | "network X:X::X:X/M route-map WORD", |
| 4598 | "Specify a network to announce via BGP\n" |
| 4599 | "IPv6 prefix <network>/<length>\n" |
| 4600 | "Route-map to modify the attributes\n" |
| 4601 | "Name of the route map\n") |
| 4602 | { |
| 4603 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4604 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4605 | } |
| 4606 | |
| 4607 | DEFUN (no_ipv6_bgp_network, |
| 4608 | no_ipv6_bgp_network_cmd, |
| 4609 | "no network X:X::X:X/M", |
| 4610 | NO_STR |
| 4611 | "Specify a network to announce via BGP\n" |
| 4612 | "IPv6 prefix <network>/<length>\n") |
| 4613 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4614 | 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] | 4615 | } |
| 4616 | |
| 4617 | ALIAS (no_ipv6_bgp_network, |
| 4618 | no_ipv6_bgp_network_route_map_cmd, |
| 4619 | "no network X:X::X:X/M route-map WORD", |
| 4620 | NO_STR |
| 4621 | "Specify a network to announce via BGP\n" |
| 4622 | "IPv6 prefix <network>/<length>\n" |
| 4623 | "Route-map to modify the attributes\n" |
| 4624 | "Name of the route map\n") |
| 4625 | |
| 4626 | ALIAS (ipv6_bgp_network, |
| 4627 | old_ipv6_bgp_network_cmd, |
| 4628 | "ipv6 bgp network X:X::X:X/M", |
| 4629 | IPV6_STR |
| 4630 | BGP_STR |
| 4631 | "Specify a network to announce via BGP\n" |
| 4632 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4633 | |
| 4634 | ALIAS (no_ipv6_bgp_network, |
| 4635 | old_no_ipv6_bgp_network_cmd, |
| 4636 | "no ipv6 bgp network X:X::X:X/M", |
| 4637 | NO_STR |
| 4638 | IPV6_STR |
| 4639 | BGP_STR |
| 4640 | "Specify a network to announce via BGP\n" |
| 4641 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4642 | |
| 4643 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4644 | ALIAS_DEPRECATED (bgp_network, |
| 4645 | bgp_network_ttl_cmd, |
| 4646 | "network A.B.C.D/M pathlimit <0-255>", |
| 4647 | "Specify a network to announce via BGP\n" |
| 4648 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4649 | "AS-Path hopcount limit attribute\n" |
| 4650 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4651 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4652 | bgp_network_backdoor_ttl_cmd, |
| 4653 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4654 | "Specify a network to announce via BGP\n" |
| 4655 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4656 | "Specify a BGP backdoor route\n" |
| 4657 | "AS-Path hopcount limit attribute\n" |
| 4658 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4659 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4660 | bgp_network_mask_ttl_cmd, |
| 4661 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4662 | "Specify a network to announce via BGP\n" |
| 4663 | "Network number\n" |
| 4664 | "Network mask\n" |
| 4665 | "Network mask\n" |
| 4666 | "AS-Path hopcount limit attribute\n" |
| 4667 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4668 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4669 | bgp_network_mask_backdoor_ttl_cmd, |
| 4670 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4671 | "Specify a network to announce via BGP\n" |
| 4672 | "Network number\n" |
| 4673 | "Network mask\n" |
| 4674 | "Network mask\n" |
| 4675 | "Specify a BGP backdoor route\n" |
| 4676 | "AS-Path hopcount limit attribute\n" |
| 4677 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4678 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4679 | bgp_network_mask_natural_ttl_cmd, |
| 4680 | "network A.B.C.D pathlimit <0-255>", |
| 4681 | "Specify a network to announce via BGP\n" |
| 4682 | "Network number\n" |
| 4683 | "AS-Path hopcount limit attribute\n" |
| 4684 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4685 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4686 | bgp_network_mask_natural_backdoor_ttl_cmd, |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 4687 | "network A.B.C.D backdoor pathlimit <1-255>", |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4688 | "Specify a network to announce via BGP\n" |
| 4689 | "Network number\n" |
| 4690 | "Specify a BGP backdoor route\n" |
| 4691 | "AS-Path hopcount limit attribute\n" |
| 4692 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4693 | ALIAS_DEPRECATED (no_bgp_network, |
| 4694 | no_bgp_network_ttl_cmd, |
| 4695 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4696 | NO_STR |
| 4697 | "Specify a network to announce via BGP\n" |
| 4698 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4699 | "AS-Path hopcount limit attribute\n" |
| 4700 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4701 | ALIAS_DEPRECATED (no_bgp_network, |
| 4702 | no_bgp_network_backdoor_ttl_cmd, |
| 4703 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4704 | NO_STR |
| 4705 | "Specify a network to announce via BGP\n" |
| 4706 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4707 | "Specify a BGP backdoor route\n" |
| 4708 | "AS-Path hopcount limit attribute\n" |
| 4709 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4710 | ALIAS_DEPRECATED (no_bgp_network, |
| 4711 | no_bgp_network_mask_ttl_cmd, |
| 4712 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4713 | NO_STR |
| 4714 | "Specify a network to announce via BGP\n" |
| 4715 | "Network number\n" |
| 4716 | "Network mask\n" |
| 4717 | "Network mask\n" |
| 4718 | "AS-Path hopcount limit attribute\n" |
| 4719 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4720 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4721 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4722 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4723 | NO_STR |
| 4724 | "Specify a network to announce via BGP\n" |
| 4725 | "Network number\n" |
| 4726 | "Network mask\n" |
| 4727 | "Network mask\n" |
| 4728 | "Specify a BGP backdoor route\n" |
| 4729 | "AS-Path hopcount limit attribute\n" |
| 4730 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4731 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4732 | no_bgp_network_mask_natural_ttl_cmd, |
| 4733 | "no network A.B.C.D pathlimit <0-255>", |
| 4734 | NO_STR |
| 4735 | "Specify a network to announce via BGP\n" |
| 4736 | "Network number\n" |
| 4737 | "AS-Path hopcount limit attribute\n" |
| 4738 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4739 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4740 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4741 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4742 | NO_STR |
| 4743 | "Specify a network to announce via BGP\n" |
| 4744 | "Network number\n" |
| 4745 | "Specify a BGP backdoor route\n" |
| 4746 | "AS-Path hopcount limit attribute\n" |
| 4747 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4748 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4749 | ipv6_bgp_network_ttl_cmd, |
| 4750 | "network X:X::X:X/M pathlimit <0-255>", |
| 4751 | "Specify a network to announce via BGP\n" |
| 4752 | "IPv6 prefix <network>/<length>\n" |
| 4753 | "AS-Path hopcount limit attribute\n" |
| 4754 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4755 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4756 | no_ipv6_bgp_network_ttl_cmd, |
| 4757 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4758 | NO_STR |
| 4759 | "Specify a network to announce via BGP\n" |
| 4760 | "IPv6 prefix <network>/<length>\n" |
| 4761 | "AS-Path hopcount limit attribute\n" |
| 4762 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4763 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4764 | /* Aggreagete address: |
| 4765 | |
| 4766 | advertise-map Set condition to advertise attribute |
| 4767 | as-set Generate AS set path information |
| 4768 | attribute-map Set attributes of aggregate |
| 4769 | route-map Set parameters of aggregate |
| 4770 | summary-only Filter more specific routes from updates |
| 4771 | suppress-map Conditionally filter more specific routes from updates |
| 4772 | <cr> |
| 4773 | */ |
| 4774 | struct bgp_aggregate |
| 4775 | { |
| 4776 | /* Summary-only flag. */ |
| 4777 | u_char summary_only; |
| 4778 | |
| 4779 | /* AS set generation. */ |
| 4780 | u_char as_set; |
| 4781 | |
| 4782 | /* Route-map for aggregated route. */ |
| 4783 | struct route_map *map; |
| 4784 | |
| 4785 | /* Suppress-count. */ |
| 4786 | unsigned long count; |
| 4787 | |
| 4788 | /* SAFI configuration. */ |
| 4789 | safi_t safi; |
| 4790 | }; |
| 4791 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4792 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4793 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4794 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4795 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4796 | } |
| 4797 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4798 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4799 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4800 | { |
| 4801 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4802 | } |
| 4803 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 4804 | /* Update an aggregate as routes are added/removed from the BGP table */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4805 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4806 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4807 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4808 | struct bgp_aggregate *aggregate) |
| 4809 | { |
| 4810 | struct bgp_table *table; |
| 4811 | struct bgp_node *top; |
| 4812 | struct bgp_node *rn; |
| 4813 | u_char origin; |
| 4814 | struct aspath *aspath = NULL; |
| 4815 | struct aspath *asmerge = NULL; |
| 4816 | struct community *community = NULL; |
| 4817 | struct community *commerge = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4818 | struct bgp_info *ri; |
| 4819 | struct bgp_info *new; |
| 4820 | int first = 1; |
| 4821 | unsigned long match = 0; |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 4822 | u_char atomic_aggregate = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4823 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4824 | /* ORIGIN attribute: If at least one route among routes that are |
| 4825 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4826 | aggregated route must have the ORIGIN attribute with the value |
| 4827 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4828 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4829 | route must have the origin attribute with the value EGP. In all |
| 4830 | other case the value of the ORIGIN attribute of the aggregated |
| 4831 | route is INTERNAL. */ |
| 4832 | origin = BGP_ORIGIN_IGP; |
| 4833 | |
| 4834 | table = bgp->rib[afi][safi]; |
| 4835 | |
| 4836 | top = bgp_node_get (table, p); |
| 4837 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4838 | if (rn->p.prefixlen > p->prefixlen) |
| 4839 | { |
| 4840 | match = 0; |
| 4841 | |
| 4842 | for (ri = rn->info; ri; ri = ri->next) |
| 4843 | { |
| 4844 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4845 | continue; |
| 4846 | |
| 4847 | if (del && ri == del) |
| 4848 | continue; |
| 4849 | |
| 4850 | if (! rinew && first) |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 4851 | first = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4852 | |
| 4853 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4854 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4855 | || ri->attr->med != med) |
| 4856 | { |
| 4857 | if (aspath) |
| 4858 | aspath_free (aspath); |
| 4859 | if (community) |
| 4860 | community_free (community); |
| 4861 | bgp_unlock_node (rn); |
| 4862 | bgp_unlock_node (top); |
| 4863 | return; |
| 4864 | } |
| 4865 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4866 | |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 4867 | if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 4868 | atomic_aggregate = 1; |
| 4869 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4870 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4871 | { |
| 4872 | if (aggregate->summary_only) |
| 4873 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4874 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4875 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4876 | match++; |
| 4877 | } |
| 4878 | |
| 4879 | aggregate->count++; |
| 4880 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 4881 | if (origin < ri->attr->origin) |
| 4882 | origin = ri->attr->origin; |
| 4883 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4884 | if (aggregate->as_set) |
| 4885 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4886 | if (aspath) |
| 4887 | { |
| 4888 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4889 | aspath_free (aspath); |
| 4890 | aspath = asmerge; |
| 4891 | } |
| 4892 | else |
| 4893 | aspath = aspath_dup (ri->attr->aspath); |
| 4894 | |
| 4895 | if (ri->attr->community) |
| 4896 | { |
| 4897 | if (community) |
| 4898 | { |
| 4899 | commerge = community_merge (community, |
| 4900 | ri->attr->community); |
| 4901 | community = community_uniq_sort (commerge); |
| 4902 | community_free (commerge); |
| 4903 | } |
| 4904 | else |
| 4905 | community = community_dup (ri->attr->community); |
| 4906 | } |
| 4907 | } |
| 4908 | } |
| 4909 | } |
| 4910 | if (match) |
| 4911 | bgp_process (bgp, rn, afi, safi); |
| 4912 | } |
| 4913 | bgp_unlock_node (top); |
| 4914 | |
| 4915 | if (rinew) |
| 4916 | { |
| 4917 | aggregate->count++; |
| 4918 | |
| 4919 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4920 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4921 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 4922 | if (origin < rinew->attr->origin) |
| 4923 | origin = rinew->attr->origin; |
| 4924 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4925 | if (aggregate->as_set) |
| 4926 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4927 | if (aspath) |
| 4928 | { |
| 4929 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4930 | aspath_free (aspath); |
| 4931 | aspath = asmerge; |
| 4932 | } |
| 4933 | else |
| 4934 | aspath = aspath_dup (rinew->attr->aspath); |
| 4935 | |
| 4936 | if (rinew->attr->community) |
| 4937 | { |
| 4938 | if (community) |
| 4939 | { |
| 4940 | commerge = community_merge (community, |
| 4941 | rinew->attr->community); |
| 4942 | community = community_uniq_sort (commerge); |
| 4943 | community_free (commerge); |
| 4944 | } |
| 4945 | else |
| 4946 | community = community_dup (rinew->attr->community); |
| 4947 | } |
| 4948 | } |
| 4949 | } |
| 4950 | |
| 4951 | if (aggregate->count > 0) |
| 4952 | { |
| 4953 | rn = bgp_node_get (table, p); |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 4954 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self, |
| 4955 | bgp_attr_aggregate_intern(bgp, origin, aspath, community, |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 4956 | aggregate->as_set, |
| 4957 | atomic_aggregate), rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4958 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4959 | |
| 4960 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4961 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4962 | bgp_process (bgp, rn, afi, safi); |
| 4963 | } |
| 4964 | else |
| 4965 | { |
| 4966 | if (aspath) |
| 4967 | aspath_free (aspath); |
| 4968 | if (community) |
| 4969 | community_free (community); |
| 4970 | } |
| 4971 | } |
| 4972 | |
| 4973 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4974 | struct bgp_aggregate *); |
| 4975 | |
| 4976 | void |
| 4977 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4978 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4979 | { |
| 4980 | struct bgp_node *child; |
| 4981 | struct bgp_node *rn; |
| 4982 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4983 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4984 | |
| 4985 | /* MPLS-VPN aggregation is not yet supported. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4986 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4987 | return; |
| 4988 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4989 | table = bgp->aggregate[afi][safi]; |
| 4990 | |
| 4991 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4992 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4993 | return; |
| 4994 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4995 | if (p->prefixlen == 0) |
| 4996 | return; |
| 4997 | |
| 4998 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4999 | return; |
| 5000 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 5001 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5002 | |
| 5003 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 5004 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5005 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 5006 | { |
| 5007 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 5008 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5009 | } |
| 5010 | bgp_unlock_node (child); |
| 5011 | } |
| 5012 | |
| 5013 | void |
| 5014 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 5015 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 5016 | { |
| 5017 | struct bgp_node *child; |
| 5018 | struct bgp_node *rn; |
| 5019 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 5020 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5021 | |
| 5022 | /* MPLS-VPN aggregation is not yet supported. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5023 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5024 | return; |
| 5025 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 5026 | table = bgp->aggregate[afi][safi]; |
| 5027 | |
| 5028 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 5029 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 5030 | return; |
| 5031 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5032 | if (p->prefixlen == 0) |
| 5033 | return; |
| 5034 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 5035 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5036 | |
| 5037 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 5038 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5039 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 5040 | { |
| 5041 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 5042 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5043 | } |
| 5044 | bgp_unlock_node (child); |
| 5045 | } |
| 5046 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 5047 | /* Called via bgp_aggregate_set when the user configures aggregate-address */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5048 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5049 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 5050 | struct bgp_aggregate *aggregate) |
| 5051 | { |
| 5052 | struct bgp_table *table; |
| 5053 | struct bgp_node *top; |
| 5054 | struct bgp_node *rn; |
| 5055 | struct bgp_info *new; |
| 5056 | struct bgp_info *ri; |
| 5057 | unsigned long match; |
| 5058 | u_char origin = BGP_ORIGIN_IGP; |
| 5059 | struct aspath *aspath = NULL; |
| 5060 | struct aspath *asmerge = NULL; |
| 5061 | struct community *community = NULL; |
| 5062 | struct community *commerge = NULL; |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 5063 | u_char atomic_aggregate = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5064 | |
| 5065 | table = bgp->rib[afi][safi]; |
| 5066 | |
| 5067 | /* Sanity check. */ |
| 5068 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 5069 | return; |
| 5070 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 5071 | return; |
| 5072 | |
| 5073 | /* If routes exists below this node, generate aggregate routes. */ |
| 5074 | top = bgp_node_get (table, p); |
| 5075 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 5076 | if (rn->p.prefixlen > p->prefixlen) |
| 5077 | { |
| 5078 | match = 0; |
| 5079 | |
| 5080 | for (ri = rn->info; ri; ri = ri->next) |
| 5081 | { |
| 5082 | if (BGP_INFO_HOLDDOWN (ri)) |
| 5083 | continue; |
| 5084 | |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 5085 | if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 5086 | atomic_aggregate = 1; |
| 5087 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5088 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 5089 | { |
| 5090 | /* summary-only aggregate route suppress aggregated |
| 5091 | route announcement. */ |
| 5092 | if (aggregate->summary_only) |
| 5093 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5094 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5095 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5096 | match++; |
| 5097 | } |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 5098 | |
| 5099 | /* If at least one route among routes that are aggregated has |
| 5100 | * ORIGIN with the value INCOMPLETE, then the aggregated route |
| 5101 | * MUST have the ORIGIN attribute with the value INCOMPLETE. |
| 5102 | * Otherwise, if at least one route among routes that are |
| 5103 | * aggregated has ORIGIN with the value EGP, then the aggregated |
| 5104 | * route MUST have the ORIGIN attribute with the value EGP. |
| 5105 | */ |
| 5106 | if (origin < ri->attr->origin) |
| 5107 | origin = ri->attr->origin; |
| 5108 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5109 | /* as-set aggregate route generate origin, as path, |
| 5110 | community aggregation. */ |
| 5111 | if (aggregate->as_set) |
| 5112 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5113 | if (aspath) |
| 5114 | { |
| 5115 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 5116 | aspath_free (aspath); |
| 5117 | aspath = asmerge; |
| 5118 | } |
| 5119 | else |
| 5120 | aspath = aspath_dup (ri->attr->aspath); |
| 5121 | |
| 5122 | if (ri->attr->community) |
| 5123 | { |
| 5124 | if (community) |
| 5125 | { |
| 5126 | commerge = community_merge (community, |
| 5127 | ri->attr->community); |
| 5128 | community = community_uniq_sort (commerge); |
| 5129 | community_free (commerge); |
| 5130 | } |
| 5131 | else |
| 5132 | community = community_dup (ri->attr->community); |
| 5133 | } |
| 5134 | } |
| 5135 | aggregate->count++; |
| 5136 | } |
| 5137 | } |
| 5138 | |
| 5139 | /* If this node is suppressed, process the change. */ |
| 5140 | if (match) |
| 5141 | bgp_process (bgp, rn, afi, safi); |
| 5142 | } |
| 5143 | bgp_unlock_node (top); |
| 5144 | |
| 5145 | /* Add aggregate route to BGP table. */ |
| 5146 | if (aggregate->count) |
| 5147 | { |
| 5148 | rn = bgp_node_get (table, p); |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 5149 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self, |
| 5150 | bgp_attr_aggregate_intern(bgp, origin, aspath, community, |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 5151 | aggregate->as_set, |
| 5152 | atomic_aggregate), rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5153 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5154 | |
| 5155 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5156 | bgp_unlock_node (rn); |
| 5157 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5158 | /* Process change. */ |
| 5159 | bgp_process (bgp, rn, afi, safi); |
| 5160 | } |
Denil Vira | e2a9258 | 2015-08-11 13:34:59 -0700 | [diff] [blame] | 5161 | else |
| 5162 | { |
| 5163 | if (aspath) |
| 5164 | aspath_free (aspath); |
| 5165 | if (community) |
| 5166 | community_free (community); |
| 5167 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5168 | } |
| 5169 | |
| 5170 | void |
| 5171 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 5172 | safi_t safi, struct bgp_aggregate *aggregate) |
| 5173 | { |
| 5174 | struct bgp_table *table; |
| 5175 | struct bgp_node *top; |
| 5176 | struct bgp_node *rn; |
| 5177 | struct bgp_info *ri; |
| 5178 | unsigned long match; |
| 5179 | |
| 5180 | table = bgp->rib[afi][safi]; |
| 5181 | |
| 5182 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 5183 | return; |
| 5184 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 5185 | return; |
| 5186 | |
| 5187 | /* If routes exists below this node, generate aggregate routes. */ |
| 5188 | top = bgp_node_get (table, p); |
| 5189 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 5190 | if (rn->p.prefixlen > p->prefixlen) |
| 5191 | { |
| 5192 | match = 0; |
| 5193 | |
| 5194 | for (ri = rn->info; ri; ri = ri->next) |
| 5195 | { |
| 5196 | if (BGP_INFO_HOLDDOWN (ri)) |
| 5197 | continue; |
| 5198 | |
| 5199 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 5200 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5201 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5202 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5203 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5204 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5205 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5206 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5207 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5208 | match++; |
| 5209 | } |
| 5210 | } |
| 5211 | aggregate->count--; |
| 5212 | } |
| 5213 | } |
| 5214 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5215 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5216 | if (match) |
| 5217 | bgp_process (bgp, rn, afi, safi); |
| 5218 | } |
| 5219 | bgp_unlock_node (top); |
| 5220 | |
| 5221 | /* Delete aggregate route from BGP table. */ |
| 5222 | rn = bgp_node_get (table, p); |
| 5223 | |
| 5224 | for (ri = rn->info; ri; ri = ri->next) |
| 5225 | if (ri->peer == bgp->peer_self |
| 5226 | && ri->type == ZEBRA_ROUTE_BGP |
| 5227 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 5228 | break; |
| 5229 | |
| 5230 | /* Withdraw static BGP route from routing table. */ |
| 5231 | if (ri) |
| 5232 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5233 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5234 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5235 | } |
| 5236 | |
| 5237 | /* Unlock bgp_node_lookup. */ |
| 5238 | bgp_unlock_node (rn); |
| 5239 | } |
| 5240 | |
| 5241 | /* Aggregate route attribute. */ |
| 5242 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 5243 | #define AGGREGATE_AS_SET 1 |
| 5244 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5245 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5246 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 5247 | afi_t afi, safi_t safi) |
| 5248 | { |
| 5249 | int ret; |
| 5250 | struct prefix p; |
| 5251 | struct bgp_node *rn; |
| 5252 | struct bgp *bgp; |
| 5253 | struct bgp_aggregate *aggregate; |
| 5254 | |
| 5255 | /* Convert string to prefix structure. */ |
| 5256 | ret = str2prefix (prefix_str, &p); |
| 5257 | if (!ret) |
| 5258 | { |
| 5259 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5260 | return CMD_WARNING; |
| 5261 | } |
| 5262 | apply_mask (&p); |
| 5263 | |
| 5264 | /* Get BGP structure. */ |
| 5265 | bgp = vty->index; |
| 5266 | |
| 5267 | /* Old configuration check. */ |
| 5268 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 5269 | if (! rn) |
| 5270 | { |
| 5271 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 5272 | VTY_NEWLINE); |
| 5273 | return CMD_WARNING; |
| 5274 | } |
| 5275 | |
| 5276 | aggregate = rn->info; |
| 5277 | if (aggregate->safi & SAFI_UNICAST) |
| 5278 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5279 | if (aggregate->safi & SAFI_MULTICAST) |
| 5280 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5281 | |
| 5282 | /* Unlock aggregate address configuration. */ |
| 5283 | rn->info = NULL; |
| 5284 | bgp_aggregate_free (aggregate); |
| 5285 | bgp_unlock_node (rn); |
| 5286 | bgp_unlock_node (rn); |
| 5287 | |
| 5288 | return CMD_SUCCESS; |
| 5289 | } |
| 5290 | |
| 5291 | static int |
| 5292 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5293 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5294 | u_char summary_only, u_char as_set) |
| 5295 | { |
| 5296 | int ret; |
| 5297 | struct prefix p; |
| 5298 | struct bgp_node *rn; |
| 5299 | struct bgp *bgp; |
| 5300 | struct bgp_aggregate *aggregate; |
| 5301 | |
| 5302 | /* Convert string to prefix structure. */ |
| 5303 | ret = str2prefix (prefix_str, &p); |
| 5304 | if (!ret) |
| 5305 | { |
| 5306 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5307 | return CMD_WARNING; |
| 5308 | } |
| 5309 | apply_mask (&p); |
| 5310 | |
| 5311 | /* Get BGP structure. */ |
| 5312 | bgp = vty->index; |
| 5313 | |
| 5314 | /* Old configuration check. */ |
| 5315 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 5316 | |
| 5317 | if (rn->info) |
| 5318 | { |
| 5319 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5320 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5321 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 5322 | if (ret) |
| 5323 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5324 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 5325 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5326 | return CMD_WARNING; |
| 5327 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5328 | } |
| 5329 | |
| 5330 | /* Make aggregate address structure. */ |
| 5331 | aggregate = bgp_aggregate_new (); |
| 5332 | aggregate->summary_only = summary_only; |
| 5333 | aggregate->as_set = as_set; |
| 5334 | aggregate->safi = safi; |
| 5335 | rn->info = aggregate; |
| 5336 | |
| 5337 | /* Aggregate address insert into BGP routing table. */ |
| 5338 | if (safi & SAFI_UNICAST) |
| 5339 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5340 | if (safi & SAFI_MULTICAST) |
| 5341 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5342 | |
| 5343 | return CMD_SUCCESS; |
| 5344 | } |
| 5345 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5346 | DEFUN (aggregate_address, |
| 5347 | aggregate_address_cmd, |
| 5348 | "aggregate-address A.B.C.D/M", |
| 5349 | "Configure BGP aggregate entries\n" |
| 5350 | "Aggregate prefix\n") |
| 5351 | { |
| 5352 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5353 | } |
| 5354 | |
| 5355 | DEFUN (aggregate_address_mask, |
| 5356 | aggregate_address_mask_cmd, |
| 5357 | "aggregate-address A.B.C.D A.B.C.D", |
| 5358 | "Configure BGP aggregate entries\n" |
| 5359 | "Aggregate address\n" |
| 5360 | "Aggregate mask\n") |
| 5361 | { |
| 5362 | int ret; |
| 5363 | char prefix_str[BUFSIZ]; |
| 5364 | |
| 5365 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5366 | |
| 5367 | if (! ret) |
| 5368 | { |
| 5369 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5370 | return CMD_WARNING; |
| 5371 | } |
| 5372 | |
| 5373 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5374 | 0, 0); |
| 5375 | } |
| 5376 | |
| 5377 | DEFUN (aggregate_address_summary_only, |
| 5378 | aggregate_address_summary_only_cmd, |
| 5379 | "aggregate-address A.B.C.D/M summary-only", |
| 5380 | "Configure BGP aggregate entries\n" |
| 5381 | "Aggregate prefix\n" |
| 5382 | "Filter more specific routes from updates\n") |
| 5383 | { |
| 5384 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5385 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5386 | } |
| 5387 | |
| 5388 | DEFUN (aggregate_address_mask_summary_only, |
| 5389 | aggregate_address_mask_summary_only_cmd, |
| 5390 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5391 | "Configure BGP aggregate entries\n" |
| 5392 | "Aggregate address\n" |
| 5393 | "Aggregate mask\n" |
| 5394 | "Filter more specific routes from updates\n") |
| 5395 | { |
| 5396 | int ret; |
| 5397 | char prefix_str[BUFSIZ]; |
| 5398 | |
| 5399 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5400 | |
| 5401 | if (! ret) |
| 5402 | { |
| 5403 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5404 | return CMD_WARNING; |
| 5405 | } |
| 5406 | |
| 5407 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5408 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5409 | } |
| 5410 | |
| 5411 | DEFUN (aggregate_address_as_set, |
| 5412 | aggregate_address_as_set_cmd, |
| 5413 | "aggregate-address A.B.C.D/M as-set", |
| 5414 | "Configure BGP aggregate entries\n" |
| 5415 | "Aggregate prefix\n" |
| 5416 | "Generate AS set path information\n") |
| 5417 | { |
| 5418 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5419 | 0, AGGREGATE_AS_SET); |
| 5420 | } |
| 5421 | |
| 5422 | DEFUN (aggregate_address_mask_as_set, |
| 5423 | aggregate_address_mask_as_set_cmd, |
| 5424 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5425 | "Configure BGP aggregate entries\n" |
| 5426 | "Aggregate address\n" |
| 5427 | "Aggregate mask\n" |
| 5428 | "Generate AS set path information\n") |
| 5429 | { |
| 5430 | int ret; |
| 5431 | char prefix_str[BUFSIZ]; |
| 5432 | |
| 5433 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5434 | |
| 5435 | if (! ret) |
| 5436 | { |
| 5437 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5438 | return CMD_WARNING; |
| 5439 | } |
| 5440 | |
| 5441 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5442 | 0, AGGREGATE_AS_SET); |
| 5443 | } |
| 5444 | |
| 5445 | |
| 5446 | DEFUN (aggregate_address_as_set_summary, |
| 5447 | aggregate_address_as_set_summary_cmd, |
| 5448 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5449 | "Configure BGP aggregate entries\n" |
| 5450 | "Aggregate prefix\n" |
| 5451 | "Generate AS set path information\n" |
| 5452 | "Filter more specific routes from updates\n") |
| 5453 | { |
| 5454 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5455 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5456 | } |
| 5457 | |
| 5458 | ALIAS (aggregate_address_as_set_summary, |
| 5459 | aggregate_address_summary_as_set_cmd, |
| 5460 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5461 | "Configure BGP aggregate entries\n" |
| 5462 | "Aggregate prefix\n" |
| 5463 | "Filter more specific routes from updates\n" |
| 5464 | "Generate AS set path information\n") |
| 5465 | |
| 5466 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5467 | aggregate_address_mask_as_set_summary_cmd, |
| 5468 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5469 | "Configure BGP aggregate entries\n" |
| 5470 | "Aggregate address\n" |
| 5471 | "Aggregate mask\n" |
| 5472 | "Generate AS set path information\n" |
| 5473 | "Filter more specific routes from updates\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_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5487 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5488 | } |
| 5489 | |
| 5490 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5491 | aggregate_address_mask_summary_as_set_cmd, |
| 5492 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5493 | "Configure BGP aggregate entries\n" |
| 5494 | "Aggregate address\n" |
| 5495 | "Aggregate mask\n" |
| 5496 | "Filter more specific routes from updates\n" |
| 5497 | "Generate AS set path information\n") |
| 5498 | |
| 5499 | DEFUN (no_aggregate_address, |
| 5500 | no_aggregate_address_cmd, |
| 5501 | "no aggregate-address A.B.C.D/M", |
| 5502 | NO_STR |
| 5503 | "Configure BGP aggregate entries\n" |
| 5504 | "Aggregate prefix\n") |
| 5505 | { |
| 5506 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5507 | } |
| 5508 | |
| 5509 | ALIAS (no_aggregate_address, |
| 5510 | no_aggregate_address_summary_only_cmd, |
| 5511 | "no aggregate-address A.B.C.D/M summary-only", |
| 5512 | NO_STR |
| 5513 | "Configure BGP aggregate entries\n" |
| 5514 | "Aggregate prefix\n" |
| 5515 | "Filter more specific routes from updates\n") |
| 5516 | |
| 5517 | ALIAS (no_aggregate_address, |
| 5518 | no_aggregate_address_as_set_cmd, |
| 5519 | "no aggregate-address A.B.C.D/M as-set", |
| 5520 | NO_STR |
| 5521 | "Configure BGP aggregate entries\n" |
| 5522 | "Aggregate prefix\n" |
| 5523 | "Generate AS set path information\n") |
| 5524 | |
| 5525 | ALIAS (no_aggregate_address, |
| 5526 | no_aggregate_address_as_set_summary_cmd, |
| 5527 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5528 | NO_STR |
| 5529 | "Configure BGP aggregate entries\n" |
| 5530 | "Aggregate prefix\n" |
| 5531 | "Generate AS set path information\n" |
| 5532 | "Filter more specific routes from updates\n") |
| 5533 | |
| 5534 | ALIAS (no_aggregate_address, |
| 5535 | no_aggregate_address_summary_as_set_cmd, |
| 5536 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5537 | NO_STR |
| 5538 | "Configure BGP aggregate entries\n" |
| 5539 | "Aggregate prefix\n" |
| 5540 | "Filter more specific routes from updates\n" |
| 5541 | "Generate AS set path information\n") |
| 5542 | |
| 5543 | DEFUN (no_aggregate_address_mask, |
| 5544 | no_aggregate_address_mask_cmd, |
| 5545 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5546 | NO_STR |
| 5547 | "Configure BGP aggregate entries\n" |
| 5548 | "Aggregate address\n" |
| 5549 | "Aggregate mask\n") |
| 5550 | { |
| 5551 | int ret; |
| 5552 | char prefix_str[BUFSIZ]; |
| 5553 | |
| 5554 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5555 | |
| 5556 | if (! ret) |
| 5557 | { |
| 5558 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5559 | return CMD_WARNING; |
| 5560 | } |
| 5561 | |
| 5562 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5563 | } |
| 5564 | |
| 5565 | ALIAS (no_aggregate_address_mask, |
| 5566 | no_aggregate_address_mask_summary_only_cmd, |
| 5567 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5568 | NO_STR |
| 5569 | "Configure BGP aggregate entries\n" |
| 5570 | "Aggregate address\n" |
| 5571 | "Aggregate mask\n" |
| 5572 | "Filter more specific routes from updates\n") |
| 5573 | |
| 5574 | ALIAS (no_aggregate_address_mask, |
| 5575 | no_aggregate_address_mask_as_set_cmd, |
| 5576 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5577 | NO_STR |
| 5578 | "Configure BGP aggregate entries\n" |
| 5579 | "Aggregate address\n" |
| 5580 | "Aggregate mask\n" |
| 5581 | "Generate AS set path information\n") |
| 5582 | |
| 5583 | ALIAS (no_aggregate_address_mask, |
| 5584 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5585 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5586 | NO_STR |
| 5587 | "Configure BGP aggregate entries\n" |
| 5588 | "Aggregate address\n" |
| 5589 | "Aggregate mask\n" |
| 5590 | "Generate AS set path information\n" |
| 5591 | "Filter more specific routes from updates\n") |
| 5592 | |
| 5593 | ALIAS (no_aggregate_address_mask, |
| 5594 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5595 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5596 | NO_STR |
| 5597 | "Configure BGP aggregate entries\n" |
| 5598 | "Aggregate address\n" |
| 5599 | "Aggregate mask\n" |
| 5600 | "Filter more specific routes from updates\n" |
| 5601 | "Generate AS set path information\n") |
| 5602 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5603 | DEFUN (ipv6_aggregate_address, |
| 5604 | ipv6_aggregate_address_cmd, |
| 5605 | "aggregate-address X:X::X:X/M", |
| 5606 | "Configure BGP aggregate entries\n" |
| 5607 | "Aggregate prefix\n") |
| 5608 | { |
| 5609 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5610 | } |
| 5611 | |
| 5612 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5613 | ipv6_aggregate_address_summary_only_cmd, |
| 5614 | "aggregate-address X:X::X:X/M summary-only", |
| 5615 | "Configure BGP aggregate entries\n" |
| 5616 | "Aggregate prefix\n" |
| 5617 | "Filter more specific routes from updates\n") |
| 5618 | { |
| 5619 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5620 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5621 | } |
| 5622 | |
| 5623 | DEFUN (no_ipv6_aggregate_address, |
| 5624 | no_ipv6_aggregate_address_cmd, |
| 5625 | "no aggregate-address X:X::X:X/M", |
| 5626 | NO_STR |
| 5627 | "Configure BGP aggregate entries\n" |
| 5628 | "Aggregate prefix\n") |
| 5629 | { |
| 5630 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5631 | } |
| 5632 | |
| 5633 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5634 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5635 | "no aggregate-address X:X::X:X/M summary-only", |
| 5636 | NO_STR |
| 5637 | "Configure BGP aggregate entries\n" |
| 5638 | "Aggregate prefix\n" |
| 5639 | "Filter more specific routes from updates\n") |
| 5640 | { |
| 5641 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5642 | } |
| 5643 | |
| 5644 | ALIAS (ipv6_aggregate_address, |
| 5645 | old_ipv6_aggregate_address_cmd, |
| 5646 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5647 | IPV6_STR |
| 5648 | BGP_STR |
| 5649 | "Configure BGP aggregate entries\n" |
| 5650 | "Aggregate prefix\n") |
| 5651 | |
| 5652 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5653 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5654 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5655 | IPV6_STR |
| 5656 | BGP_STR |
| 5657 | "Configure BGP aggregate entries\n" |
| 5658 | "Aggregate prefix\n" |
| 5659 | "Filter more specific routes from updates\n") |
| 5660 | |
| 5661 | ALIAS (no_ipv6_aggregate_address, |
| 5662 | old_no_ipv6_aggregate_address_cmd, |
| 5663 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5664 | NO_STR |
| 5665 | IPV6_STR |
| 5666 | BGP_STR |
| 5667 | "Configure BGP aggregate entries\n" |
| 5668 | "Aggregate prefix\n") |
| 5669 | |
| 5670 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5671 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5672 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5673 | NO_STR |
| 5674 | IPV6_STR |
| 5675 | BGP_STR |
| 5676 | "Configure BGP aggregate entries\n" |
| 5677 | "Aggregate prefix\n" |
| 5678 | "Filter more specific routes from updates\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5679 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5680 | /* Redistribute route treatment. */ |
| 5681 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5682 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5683 | const struct in6_addr *nexthop6, |
Paul Jakma | 96d1060 | 2016-07-01 14:23:45 +0100 | [diff] [blame] | 5684 | u_int32_t metric, u_char type, route_tag_t tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5685 | { |
| 5686 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5687 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5688 | struct bgp_info *new; |
| 5689 | struct bgp_info *bi; |
| 5690 | struct bgp_info info; |
| 5691 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5692 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5693 | struct attr *new_attr; |
| 5694 | afi_t afi; |
| 5695 | int ret; |
| 5696 | |
| 5697 | /* Make default attribute. */ |
| 5698 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5699 | if (nexthop) |
| 5700 | attr.nexthop = *nexthop; |
| 5701 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5702 | if (nexthop6) |
| 5703 | { |
| 5704 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5705 | extra->mp_nexthop_global = *nexthop6; |
| 5706 | extra->mp_nexthop_len = 16; |
| 5707 | } |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5708 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5709 | attr.med = metric; |
| 5710 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Piotr Chytła | 605aa33 | 2015-12-01 10:03:54 -0500 | [diff] [blame] | 5711 | attr.extra->tag = tag; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5712 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5713 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5714 | { |
| 5715 | afi = family2afi (p->family); |
| 5716 | |
| 5717 | if (bgp->redist[afi][type]) |
| 5718 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5719 | struct attr attr_new; |
| 5720 | struct attr_extra extra_new; |
| 5721 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5722 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5723 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5724 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5725 | |
| 5726 | if (bgp->redist_metric_flag[afi][type]) |
| 5727 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5728 | |
| 5729 | /* Apply route-map. */ |
Daniel Walton | 1994dc8 | 2015-09-17 10:15:59 -0400 | [diff] [blame] | 5730 | if (bgp->rmap[afi][type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5731 | { |
| 5732 | info.peer = bgp->peer_self; |
| 5733 | info.attr = &attr_new; |
| 5734 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5735 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5736 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5737 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5738 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5739 | |
| 5740 | bgp->peer_self->rmap_type = 0; |
| 5741 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5742 | if (ret == RMAP_DENYMATCH) |
| 5743 | { |
| 5744 | /* Free uninterned attribute. */ |
| 5745 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5746 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5747 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5748 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5749 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5750 | bgp_redistribute_delete (p, type); |
| 5751 | return; |
| 5752 | } |
| 5753 | } |
| 5754 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5755 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5756 | afi, SAFI_UNICAST, p, NULL); |
| 5757 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5758 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5759 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5760 | for (bi = bn->info; bi; bi = bi->next) |
| 5761 | if (bi->peer == bgp->peer_self |
| 5762 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5763 | break; |
| 5764 | |
| 5765 | if (bi) |
| 5766 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5767 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5768 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5769 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5770 | bgp_attr_unintern (&new_attr); |
| 5771 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5772 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5773 | bgp_unlock_node (bn); |
| 5774 | return; |
| 5775 | } |
| 5776 | else |
| 5777 | { |
| 5778 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5779 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5780 | |
| 5781 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5782 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5783 | bgp_info_restore(bn, bi); |
| 5784 | else |
| 5785 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5786 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5787 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5788 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5789 | |
| 5790 | /* Process change. */ |
| 5791 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5792 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5793 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5794 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5795 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5796 | return; |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 5797 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5798 | } |
| 5799 | |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 5800 | new = info_make(type, BGP_ROUTE_REDISTRIBUTE, bgp->peer_self, |
| 5801 | new_attr, bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5802 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5803 | |
| 5804 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5805 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5806 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5807 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5808 | } |
| 5809 | } |
| 5810 | |
| 5811 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5812 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5813 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5814 | } |
| 5815 | |
| 5816 | void |
| 5817 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5818 | { |
| 5819 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5820 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5821 | afi_t afi; |
| 5822 | struct bgp_node *rn; |
| 5823 | struct bgp_info *ri; |
| 5824 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5825 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5826 | { |
| 5827 | afi = family2afi (p->family); |
| 5828 | |
| 5829 | if (bgp->redist[afi][type]) |
| 5830 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5831 | 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] | 5832 | |
| 5833 | for (ri = rn->info; ri; ri = ri->next) |
| 5834 | if (ri->peer == bgp->peer_self |
| 5835 | && ri->type == type) |
| 5836 | break; |
| 5837 | |
| 5838 | if (ri) |
| 5839 | { |
| 5840 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5841 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5842 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5843 | } |
| 5844 | bgp_unlock_node (rn); |
| 5845 | } |
| 5846 | } |
| 5847 | } |
| 5848 | |
| 5849 | /* Withdraw specified route type's route. */ |
| 5850 | void |
| 5851 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5852 | { |
| 5853 | struct bgp_node *rn; |
| 5854 | struct bgp_info *ri; |
| 5855 | struct bgp_table *table; |
| 5856 | |
| 5857 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5858 | |
| 5859 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5860 | { |
| 5861 | for (ri = rn->info; ri; ri = ri->next) |
| 5862 | if (ri->peer == bgp->peer_self |
| 5863 | && ri->type == type) |
| 5864 | break; |
| 5865 | |
| 5866 | if (ri) |
| 5867 | { |
| 5868 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5869 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5870 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5871 | } |
| 5872 | } |
| 5873 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5874 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5875 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5876 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5877 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5878 | { |
| 5879 | int len; |
| 5880 | u_int32_t destination; |
| 5881 | char buf[BUFSIZ]; |
| 5882 | |
| 5883 | if (p->family == AF_INET) |
| 5884 | { |
| 5885 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5886 | destination = ntohl (p->u.prefix4.s_addr); |
| 5887 | |
| 5888 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5889 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5890 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5891 | || p->u.prefix4.s_addr == 0) |
| 5892 | { |
| 5893 | /* When mask is natural, mask is not displayed. */ |
| 5894 | } |
| 5895 | else |
| 5896 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5897 | } |
| 5898 | else |
| 5899 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5900 | p->prefixlen); |
| 5901 | |
| 5902 | len = 17 - len; |
| 5903 | if (len < 1) |
| 5904 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5905 | else |
| 5906 | vty_out (vty, "%*s", len, " "); |
| 5907 | } |
| 5908 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5909 | enum bgp_display_type |
| 5910 | { |
| 5911 | normal_list, |
| 5912 | }; |
| 5913 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5914 | /* Print the short form route status for a bgp_info */ |
| 5915 | static void |
| 5916 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5917 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5918 | /* Route status display. */ |
| 5919 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5920 | vty_out (vty, "R"); |
| 5921 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5922 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5923 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5924 | vty_out (vty, "s"); |
Daniel Walton | e2a0ebf | 2015-05-19 18:03:43 -0700 | [diff] [blame] | 5925 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_VALID) && |
| 5926 | ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5927 | vty_out (vty, "*"); |
| 5928 | else |
| 5929 | vty_out (vty, " "); |
| 5930 | |
| 5931 | /* Selected */ |
| 5932 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5933 | vty_out (vty, "h"); |
| 5934 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5935 | vty_out (vty, "d"); |
| 5936 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5937 | vty_out (vty, ">"); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 5938 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
| 5939 | vty_out (vty, "="); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5940 | else |
| 5941 | vty_out (vty, " "); |
| 5942 | |
| 5943 | /* Internal route. */ |
| 5944 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5945 | vty_out (vty, "i"); |
| 5946 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5947 | vty_out (vty, " "); |
| 5948 | } |
| 5949 | |
| 5950 | /* called from terminal list command */ |
| 5951 | void |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5952 | route_vty_out( |
| 5953 | struct vty *vty, |
| 5954 | struct prefix *p, |
| 5955 | struct bgp_info *binfo, |
| 5956 | int display, |
| 5957 | safi_t safi) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5958 | { |
| 5959 | struct attr *attr; |
| 5960 | |
| 5961 | /* short status lead text */ |
| 5962 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5963 | |
| 5964 | /* print prefix and mask */ |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5965 | if (!display) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5966 | route_vty_out_route (p, vty); |
| 5967 | else |
| 5968 | vty_out (vty, "%*s", 17, " "); |
| 5969 | |
| 5970 | /* Print attribute */ |
| 5971 | attr = binfo->attr; |
| 5972 | if (attr) |
| 5973 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5974 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5975 | /* |
| 5976 | * NEXTHOP start |
| 5977 | */ |
| 5978 | |
| 5979 | /* |
| 5980 | * For ENCAP routes, nexthop address family is not |
| 5981 | * neccessarily the same as the prefix address family. |
| 5982 | * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field |
| 5983 | */ |
| 5984 | if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) { |
| 5985 | if (attr->extra) { |
| 5986 | char buf[BUFSIZ]; |
| 5987 | int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len); |
| 5988 | |
| 5989 | switch (af) { |
| 5990 | case AF_INET: |
| 5991 | vty_out (vty, "%s", inet_ntop(af, |
| 5992 | &attr->extra->mp_nexthop_global_in, buf, BUFSIZ)); |
| 5993 | break; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5994 | case AF_INET6: |
| 5995 | vty_out (vty, "%s", inet_ntop(af, |
| 5996 | &attr->extra->mp_nexthop_global, buf, BUFSIZ)); |
| 5997 | break; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5998 | default: |
| 5999 | vty_out(vty, "?"); |
| 6000 | } |
| 6001 | } else { |
| 6002 | vty_out(vty, "?"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6003 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6004 | } else { |
| 6005 | |
| 6006 | if (p->family == AF_INET) |
| 6007 | { |
| 6008 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6009 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6010 | else if (p->family == AF_INET6) |
| 6011 | { |
| 6012 | int len; |
| 6013 | char buf[BUFSIZ]; |
| 6014 | |
| 6015 | len = vty_out (vty, "%s", |
| 6016 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6017 | buf, BUFSIZ)); |
| 6018 | len = 16 - len; |
| 6019 | if (len < 1) |
| 6020 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 6021 | else |
| 6022 | vty_out (vty, "%*s", len, " "); |
| 6023 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6024 | else |
| 6025 | { |
| 6026 | vty_out(vty, "?"); |
| 6027 | } |
| 6028 | } |
| 6029 | |
| 6030 | /* |
| 6031 | * NEXTHOP end |
| 6032 | */ |
| 6033 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6034 | |
| 6035 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6036 | vty_out (vty, "%10u ", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6037 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6038 | vty_out (vty, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6039 | |
| 6040 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6041 | vty_out (vty, "%7u ", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6042 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6043 | vty_out (vty, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6044 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6045 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6046 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6047 | /* Print aspath */ |
| 6048 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6049 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6050 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6051 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6052 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6053 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6054 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6055 | } |
| 6056 | |
| 6057 | /* called from terminal list command */ |
| 6058 | void |
| 6059 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 6060 | struct attr *attr, safi_t safi) |
| 6061 | { |
| 6062 | /* Route status display. */ |
| 6063 | vty_out (vty, "*"); |
| 6064 | vty_out (vty, ">"); |
| 6065 | vty_out (vty, " "); |
| 6066 | |
| 6067 | /* print prefix and mask */ |
| 6068 | route_vty_out_route (p, vty); |
| 6069 | |
| 6070 | /* Print attribute */ |
| 6071 | if (attr) |
| 6072 | { |
| 6073 | if (p->family == AF_INET) |
| 6074 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6075 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6076 | vty_out (vty, "%-16s", |
| 6077 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6078 | else |
| 6079 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6080 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6081 | else if (p->family == AF_INET6) |
| 6082 | { |
| 6083 | int len; |
| 6084 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6085 | |
| 6086 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6087 | |
| 6088 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6089 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6090 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6091 | len = 16 - len; |
| 6092 | if (len < 1) |
| 6093 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 6094 | else |
| 6095 | vty_out (vty, "%*s", len, " "); |
| 6096 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6097 | |
| 6098 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6099 | vty_out (vty, "%10u ", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6100 | else |
| 6101 | vty_out (vty, " "); |
| 6102 | |
| 6103 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6104 | vty_out (vty, "%7u ", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6105 | else |
| 6106 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6107 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6108 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6109 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6110 | /* Print aspath */ |
| 6111 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6112 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6113 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6114 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6115 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6116 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6117 | |
| 6118 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6119 | } |
| 6120 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6121 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6122 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 6123 | struct bgp_info *binfo, int display, safi_t safi) |
| 6124 | { |
| 6125 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6126 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6127 | |
| 6128 | if (!binfo->extra) |
| 6129 | return; |
| 6130 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6131 | /* short status lead text */ |
| 6132 | route_vty_short_status_out (vty, binfo); |
| 6133 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6134 | /* print prefix and mask */ |
| 6135 | if (! display) |
| 6136 | route_vty_out_route (p, vty); |
| 6137 | else |
| 6138 | vty_out (vty, "%*s", 17, " "); |
| 6139 | |
| 6140 | /* Print attribute */ |
| 6141 | attr = binfo->attr; |
| 6142 | if (attr) |
| 6143 | { |
| 6144 | if (p->family == AF_INET) |
| 6145 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6146 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6147 | vty_out (vty, "%-16s", |
| 6148 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6149 | else |
| 6150 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6151 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6152 | else if (p->family == AF_INET6) |
| 6153 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6154 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6155 | char buf[BUFSIZ]; |
| 6156 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6157 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6158 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6159 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6160 | buf, BUFSIZ)); |
| 6161 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6162 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6163 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6164 | buf, BUFSIZ), |
| 6165 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 6166 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6167 | |
| 6168 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6169 | } |
| 6170 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6171 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6172 | |
| 6173 | vty_out (vty, "notag/%d", label); |
| 6174 | |
| 6175 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6176 | } |
| 6177 | |
| 6178 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6179 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6180 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 6181 | struct bgp_info *binfo, int display, safi_t safi) |
| 6182 | { |
| 6183 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6184 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6185 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6186 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6187 | /* short status lead text */ |
| 6188 | route_vty_short_status_out (vty, binfo); |
| 6189 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6190 | /* print prefix and mask */ |
| 6191 | if (! display) |
| 6192 | route_vty_out_route (p, vty); |
| 6193 | else |
| 6194 | vty_out (vty, "%*s", 17, " "); |
| 6195 | |
| 6196 | len = vty_out (vty, "%s", binfo->peer->host); |
| 6197 | len = 17 - len; |
| 6198 | if (len < 1) |
| 6199 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 6200 | else |
| 6201 | vty_out (vty, "%*s", len, " "); |
| 6202 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6203 | 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] | 6204 | |
| 6205 | /* Print attribute */ |
| 6206 | attr = binfo->attr; |
| 6207 | if (attr) |
| 6208 | { |
| 6209 | /* Print aspath */ |
| 6210 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6211 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6212 | |
| 6213 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6214 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6215 | } |
| 6216 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6217 | } |
| 6218 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6219 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6220 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6221 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 6222 | struct bgp_info *binfo, int display, safi_t safi) |
| 6223 | { |
| 6224 | struct attr *attr; |
| 6225 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6226 | char timebuf[BGP_UPTIME_LEN]; |
| 6227 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6228 | |
| 6229 | if (!binfo->extra) |
| 6230 | return; |
| 6231 | |
| 6232 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6233 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6234 | /* short status lead text */ |
| 6235 | route_vty_short_status_out (vty, binfo); |
| 6236 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6237 | /* print prefix and mask */ |
| 6238 | if (! display) |
| 6239 | route_vty_out_route (p, vty); |
| 6240 | else |
| 6241 | vty_out (vty, "%*s", 17, " "); |
| 6242 | |
| 6243 | len = vty_out (vty, "%s", binfo->peer->host); |
| 6244 | len = 16 - len; |
| 6245 | if (len < 1) |
| 6246 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 6247 | else |
| 6248 | vty_out (vty, "%*s", len, " "); |
| 6249 | |
| 6250 | len = vty_out (vty, "%d", bdi->flap); |
| 6251 | len = 5 - len; |
| 6252 | if (len < 1) |
| 6253 | vty_out (vty, " "); |
| 6254 | else |
| 6255 | vty_out (vty, "%*s ", len, " "); |
| 6256 | |
| 6257 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 6258 | timebuf, BGP_UPTIME_LEN)); |
| 6259 | |
| 6260 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 6261 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6262 | 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] | 6263 | else |
| 6264 | vty_out (vty, "%*s ", 8, " "); |
| 6265 | |
| 6266 | /* Print attribute */ |
| 6267 | attr = binfo->attr; |
| 6268 | if (attr) |
| 6269 | { |
| 6270 | /* Print aspath */ |
| 6271 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6272 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6273 | |
| 6274 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6275 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6276 | } |
| 6277 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6278 | } |
| 6279 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6280 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6281 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 6282 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 6283 | { |
| 6284 | char buf[INET6_ADDRSTRLEN]; |
| 6285 | char buf1[BUFSIZ]; |
| 6286 | struct attr *attr; |
| 6287 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6288 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6289 | time_t tbuf; |
| 6290 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6291 | |
| 6292 | attr = binfo->attr; |
| 6293 | |
| 6294 | if (attr) |
| 6295 | { |
| 6296 | /* Line1 display AS-path, Aggregator */ |
| 6297 | if (attr->aspath) |
| 6298 | { |
| 6299 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 6300 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6301 | vty_out (vty, "Local"); |
| 6302 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6303 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6304 | } |
| 6305 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6306 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 6307 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6308 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 6309 | vty_out (vty, ", (stale)"); |
| 6310 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 6311 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6312 | attr->extra->aggregator_as, |
| 6313 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6314 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 6315 | vty_out (vty, ", (Received from a RR-client)"); |
| 6316 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 6317 | vty_out (vty, ", (Received from a RS-client)"); |
| 6318 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6319 | vty_out (vty, ", (history entry)"); |
| 6320 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 6321 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6322 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6323 | |
| 6324 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 6325 | if (p->family == AF_INET) |
| 6326 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6327 | vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6328 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6329 | inet_ntoa (attr->nexthop)); |
| 6330 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6331 | else |
| 6332 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6333 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6334 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6335 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6336 | buf, INET6_ADDRSTRLEN)); |
| 6337 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6338 | |
| 6339 | if (binfo->peer == bgp->peer_self) |
| 6340 | { |
| 6341 | vty_out (vty, " from %s ", |
| 6342 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 6343 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 6344 | } |
| 6345 | else |
| 6346 | { |
| 6347 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6348 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6349 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 6350 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6351 | if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) { |
| 6352 | buf[0] = '?'; |
| 6353 | buf[1] = 0; |
| 6354 | } |
| 6355 | vty_out (vty, " from %s", buf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6356 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6357 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6358 | else |
| 6359 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 6360 | } |
| 6361 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6362 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6363 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6364 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6365 | { |
| 6366 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6367 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6368 | buf, INET6_ADDRSTRLEN), |
| 6369 | VTY_NEWLINE); |
| 6370 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6371 | |
Piotr Chytła | 605aa33 | 2015-12-01 10:03:54 -0500 | [diff] [blame] | 6372 | /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6373 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 6374 | |
| 6375 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6376 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6377 | |
| 6378 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6379 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6380 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6381 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6382 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6383 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6384 | vty_out (vty, ", weight %u", attr->extra->weight); |
Piotr Chytła | 605aa33 | 2015-12-01 10:03:54 -0500 | [diff] [blame] | 6385 | |
| 6386 | if (attr->extra && attr->extra->tag != 0) |
| 6387 | vty_out (vty, ", tag %d", attr->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6388 | |
Daniel Walton | e2a0ebf | 2015-05-19 18:03:43 -0700 | [diff] [blame] | 6389 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6390 | vty_out (vty, ", invalid"); |
| 6391 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6392 | vty_out (vty, ", valid"); |
| 6393 | |
| 6394 | if (binfo->peer != bgp->peer_self) |
| 6395 | { |
| 6396 | if (binfo->peer->as == binfo->peer->local_as) |
| 6397 | vty_out (vty, ", internal"); |
| 6398 | else |
| 6399 | vty_out (vty, ", %s", |
| 6400 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6401 | } |
| 6402 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6403 | vty_out (vty, ", aggregated, local"); |
| 6404 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6405 | vty_out (vty, ", sourced"); |
| 6406 | else |
| 6407 | vty_out (vty, ", sourced, local"); |
| 6408 | |
| 6409 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6410 | vty_out (vty, ", atomic-aggregate"); |
| 6411 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6412 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6413 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6414 | bgp_info_mpath_count (binfo))) |
| 6415 | vty_out (vty, ", multipath"); |
| 6416 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6417 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6418 | vty_out (vty, ", best"); |
| 6419 | |
| 6420 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6421 | |
| 6422 | /* Line 4 display Community */ |
| 6423 | if (attr->community) |
| 6424 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6425 | VTY_NEWLINE); |
| 6426 | |
| 6427 | /* Line 5 display Extended-community */ |
| 6428 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6429 | vty_out (vty, " Extended Community: %s%s", |
| 6430 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6431 | |
| 6432 | /* Line 6 display Originator, Cluster-id */ |
| 6433 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6434 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6435 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6436 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6437 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6438 | vty_out (vty, " Originator: %s", |
| 6439 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6440 | |
| 6441 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6442 | { |
| 6443 | int i; |
| 6444 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6445 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6446 | vty_out (vty, "%s ", |
| 6447 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6448 | } |
| 6449 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6450 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6451 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6452 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6453 | bgp_damp_info_vty (vty, binfo); |
| 6454 | |
| 6455 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6456 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6457 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6458 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6459 | #else |
| 6460 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6461 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6462 | } |
| 6463 | vty_out (vty, "%s", VTY_NEWLINE); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 6464 | } |
| 6465 | |
| 6466 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\ |
| 6467 | "h history, * valid, > best, = multipath,%s"\ |
| 6468 | " i internal, r RIB-failure, S Stale, R Removed%s" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6469 | #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] | 6470 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6471 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6472 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6473 | |
| 6474 | enum bgp_show_type |
| 6475 | { |
| 6476 | bgp_show_type_normal, |
| 6477 | bgp_show_type_regexp, |
| 6478 | bgp_show_type_prefix_list, |
| 6479 | bgp_show_type_filter_list, |
| 6480 | bgp_show_type_route_map, |
| 6481 | bgp_show_type_neighbor, |
| 6482 | bgp_show_type_cidr_only, |
| 6483 | bgp_show_type_prefix_longer, |
| 6484 | bgp_show_type_community_all, |
| 6485 | bgp_show_type_community, |
| 6486 | bgp_show_type_community_exact, |
| 6487 | bgp_show_type_community_list, |
| 6488 | bgp_show_type_community_list_exact, |
| 6489 | bgp_show_type_flap_statistics, |
| 6490 | bgp_show_type_flap_address, |
| 6491 | bgp_show_type_flap_prefix, |
| 6492 | bgp_show_type_flap_cidr_only, |
| 6493 | bgp_show_type_flap_regexp, |
| 6494 | bgp_show_type_flap_filter_list, |
| 6495 | bgp_show_type_flap_prefix_list, |
| 6496 | bgp_show_type_flap_prefix_longer, |
| 6497 | bgp_show_type_flap_route_map, |
| 6498 | bgp_show_type_flap_neighbor, |
| 6499 | bgp_show_type_dampend_paths, |
| 6500 | bgp_show_type_damp_neighbor |
| 6501 | }; |
| 6502 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6503 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6504 | 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] | 6505 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6506 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6507 | struct bgp_info *ri; |
| 6508 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6509 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6510 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6511 | unsigned long output_count; |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6512 | unsigned long total_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6513 | |
| 6514 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6515 | output_count = 0; |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6516 | total_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6517 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6518 | /* Start processing of routes. */ |
| 6519 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6520 | if (rn->info != NULL) |
| 6521 | { |
| 6522 | display = 0; |
| 6523 | |
| 6524 | for (ri = rn->info; ri; ri = ri->next) |
| 6525 | { |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6526 | total_count++; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6527 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6528 | || type == bgp_show_type_flap_address |
| 6529 | || type == bgp_show_type_flap_prefix |
| 6530 | || type == bgp_show_type_flap_cidr_only |
| 6531 | || type == bgp_show_type_flap_regexp |
| 6532 | || type == bgp_show_type_flap_filter_list |
| 6533 | || type == bgp_show_type_flap_prefix_list |
| 6534 | || type == bgp_show_type_flap_prefix_longer |
| 6535 | || type == bgp_show_type_flap_route_map |
| 6536 | || type == bgp_show_type_flap_neighbor |
| 6537 | || type == bgp_show_type_dampend_paths |
| 6538 | || type == bgp_show_type_damp_neighbor) |
| 6539 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6540 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6541 | continue; |
| 6542 | } |
| 6543 | if (type == bgp_show_type_regexp |
| 6544 | || type == bgp_show_type_flap_regexp) |
| 6545 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6546 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6547 | |
| 6548 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6549 | continue; |
| 6550 | } |
| 6551 | if (type == bgp_show_type_prefix_list |
| 6552 | || type == bgp_show_type_flap_prefix_list) |
| 6553 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6554 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6555 | |
| 6556 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6557 | continue; |
| 6558 | } |
| 6559 | if (type == bgp_show_type_filter_list |
| 6560 | || type == bgp_show_type_flap_filter_list) |
| 6561 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6562 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6563 | |
| 6564 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6565 | continue; |
| 6566 | } |
| 6567 | if (type == bgp_show_type_route_map |
| 6568 | || type == bgp_show_type_flap_route_map) |
| 6569 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6570 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6571 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6572 | struct attr dummy_attr; |
| 6573 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6574 | int ret; |
| 6575 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6576 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6577 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6578 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6579 | binfo.peer = ri->peer; |
| 6580 | binfo.attr = &dummy_attr; |
| 6581 | |
| 6582 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6583 | if (ret == RMAP_DENYMATCH) |
| 6584 | continue; |
| 6585 | } |
| 6586 | if (type == bgp_show_type_neighbor |
| 6587 | || type == bgp_show_type_flap_neighbor |
| 6588 | || type == bgp_show_type_damp_neighbor) |
| 6589 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6590 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6591 | |
| 6592 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6593 | continue; |
| 6594 | } |
| 6595 | if (type == bgp_show_type_cidr_only |
| 6596 | || type == bgp_show_type_flap_cidr_only) |
| 6597 | { |
| 6598 | u_int32_t destination; |
| 6599 | |
| 6600 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6601 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6602 | continue; |
| 6603 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6604 | continue; |
| 6605 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6606 | continue; |
| 6607 | } |
| 6608 | if (type == bgp_show_type_prefix_longer |
| 6609 | || type == bgp_show_type_flap_prefix_longer) |
| 6610 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6611 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6612 | |
| 6613 | if (! prefix_match (p, &rn->p)) |
| 6614 | continue; |
| 6615 | } |
| 6616 | if (type == bgp_show_type_community_all) |
| 6617 | { |
| 6618 | if (! ri->attr->community) |
| 6619 | continue; |
| 6620 | } |
| 6621 | if (type == bgp_show_type_community) |
| 6622 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6623 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6624 | |
| 6625 | if (! ri->attr->community || |
| 6626 | ! community_match (ri->attr->community, com)) |
| 6627 | continue; |
| 6628 | } |
| 6629 | if (type == bgp_show_type_community_exact) |
| 6630 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6631 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6632 | |
| 6633 | if (! ri->attr->community || |
| 6634 | ! community_cmp (ri->attr->community, com)) |
| 6635 | continue; |
| 6636 | } |
| 6637 | if (type == bgp_show_type_community_list) |
| 6638 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6639 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6640 | |
| 6641 | if (! community_list_match (ri->attr->community, list)) |
| 6642 | continue; |
| 6643 | } |
| 6644 | if (type == bgp_show_type_community_list_exact) |
| 6645 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6646 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6647 | |
| 6648 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6649 | continue; |
| 6650 | } |
| 6651 | if (type == bgp_show_type_flap_address |
| 6652 | || type == bgp_show_type_flap_prefix) |
| 6653 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6654 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6655 | |
| 6656 | if (! prefix_match (&rn->p, p)) |
| 6657 | continue; |
| 6658 | |
| 6659 | if (type == bgp_show_type_flap_prefix) |
| 6660 | if (p->prefixlen != rn->p.prefixlen) |
| 6661 | continue; |
| 6662 | } |
| 6663 | if (type == bgp_show_type_dampend_paths |
| 6664 | || type == bgp_show_type_damp_neighbor) |
| 6665 | { |
| 6666 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6667 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6668 | continue; |
| 6669 | } |
| 6670 | |
| 6671 | if (header) |
| 6672 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6673 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6674 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6675 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6676 | if (type == bgp_show_type_dampend_paths |
| 6677 | || type == bgp_show_type_damp_neighbor) |
| 6678 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6679 | else if (type == bgp_show_type_flap_statistics |
| 6680 | || type == bgp_show_type_flap_address |
| 6681 | || type == bgp_show_type_flap_prefix |
| 6682 | || type == bgp_show_type_flap_cidr_only |
| 6683 | || type == bgp_show_type_flap_regexp |
| 6684 | || type == bgp_show_type_flap_filter_list |
| 6685 | || type == bgp_show_type_flap_prefix_list |
| 6686 | || type == bgp_show_type_flap_prefix_longer |
| 6687 | || type == bgp_show_type_flap_route_map |
| 6688 | || type == bgp_show_type_flap_neighbor) |
| 6689 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6690 | else |
| 6691 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6692 | header = 0; |
| 6693 | } |
| 6694 | |
| 6695 | if (type == bgp_show_type_dampend_paths |
| 6696 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6697 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6698 | else if (type == bgp_show_type_flap_statistics |
| 6699 | || type == bgp_show_type_flap_address |
| 6700 | || type == bgp_show_type_flap_prefix |
| 6701 | || type == bgp_show_type_flap_cidr_only |
| 6702 | || type == bgp_show_type_flap_regexp |
| 6703 | || type == bgp_show_type_flap_filter_list |
| 6704 | || type == bgp_show_type_flap_prefix_list |
| 6705 | || type == bgp_show_type_flap_prefix_longer |
| 6706 | || type == bgp_show_type_flap_route_map |
| 6707 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6708 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6709 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6710 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6711 | display++; |
| 6712 | } |
| 6713 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6714 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6715 | } |
| 6716 | |
| 6717 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6718 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6719 | { |
| 6720 | if (type == bgp_show_type_normal) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6721 | 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] | 6722 | } |
| 6723 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6724 | vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s", |
| 6725 | VTY_NEWLINE, output_count, total_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6726 | |
| 6727 | return CMD_SUCCESS; |
| 6728 | } |
| 6729 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6730 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6731 | 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] | 6732 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6733 | { |
| 6734 | struct bgp_table *table; |
| 6735 | |
| 6736 | if (bgp == NULL) { |
| 6737 | bgp = bgp_get_default (); |
| 6738 | } |
| 6739 | |
| 6740 | if (bgp == NULL) |
| 6741 | { |
| 6742 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6743 | return CMD_WARNING; |
| 6744 | } |
| 6745 | |
| 6746 | |
| 6747 | table = bgp->rib[afi][safi]; |
| 6748 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6749 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6750 | } |
| 6751 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6752 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6753 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6754 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6755 | struct bgp_node *rn, |
| 6756 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6757 | { |
| 6758 | struct bgp_info *ri; |
| 6759 | struct prefix *p; |
| 6760 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6761 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6762 | char buf1[INET6_ADDRSTRLEN]; |
| 6763 | char buf2[INET6_ADDRSTRLEN]; |
| 6764 | int count = 0; |
| 6765 | int best = 0; |
| 6766 | int suppress = 0; |
| 6767 | int no_export = 0; |
| 6768 | int no_advertise = 0; |
| 6769 | int local_as = 0; |
| 6770 | int first = 0; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6771 | int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6772 | |
| 6773 | p = &rn->p; |
| 6774 | 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] | 6775 | (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6776 | printrd ? ":" : "", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6777 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6778 | p->prefixlen, VTY_NEWLINE); |
| 6779 | |
| 6780 | for (ri = rn->info; ri; ri = ri->next) |
| 6781 | { |
| 6782 | count++; |
| 6783 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6784 | { |
| 6785 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6786 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6787 | suppress = 1; |
| 6788 | if (ri->attr->community != NULL) |
| 6789 | { |
| 6790 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6791 | no_advertise = 1; |
| 6792 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6793 | no_export = 1; |
| 6794 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6795 | local_as = 1; |
| 6796 | } |
| 6797 | } |
| 6798 | } |
| 6799 | |
| 6800 | vty_out (vty, "Paths: (%d available", count); |
| 6801 | if (best) |
| 6802 | { |
| 6803 | vty_out (vty, ", best #%d", best); |
| 6804 | if (safi == SAFI_UNICAST) |
| 6805 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6806 | } |
| 6807 | else |
| 6808 | vty_out (vty, ", no best path"); |
| 6809 | if (no_advertise) |
| 6810 | vty_out (vty, ", not advertised to any peer"); |
| 6811 | else if (no_export) |
| 6812 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6813 | else if (local_as) |
| 6814 | vty_out (vty, ", not advertised outside local AS"); |
| 6815 | if (suppress) |
| 6816 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6817 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6818 | |
| 6819 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6820 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6821 | { |
| 6822 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6823 | { |
| 6824 | if (! first) |
| 6825 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6826 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6827 | first = 1; |
| 6828 | } |
| 6829 | } |
| 6830 | if (! first) |
| 6831 | vty_out (vty, " Not advertised to any peer"); |
| 6832 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6833 | } |
| 6834 | |
| 6835 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6836 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6837 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6838 | struct bgp_table *rib, const char *ip_str, |
| 6839 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6840 | int prefix_check, enum bgp_path_type pathtype) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6841 | { |
| 6842 | int ret; |
| 6843 | int header; |
| 6844 | int display = 0; |
| 6845 | struct prefix match; |
| 6846 | struct bgp_node *rn; |
| 6847 | struct bgp_node *rm; |
| 6848 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6849 | struct bgp_table *table; |
| 6850 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 6851 | memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6852 | /* Check IP address argument. */ |
| 6853 | ret = str2prefix (ip_str, &match); |
| 6854 | if (! ret) |
| 6855 | { |
| 6856 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6857 | return CMD_WARNING; |
| 6858 | } |
| 6859 | |
| 6860 | match.family = afi2family (afi); |
| 6861 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6862 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6863 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6864 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6865 | { |
| 6866 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6867 | continue; |
| 6868 | |
| 6869 | if ((table = rn->info) != NULL) |
| 6870 | { |
| 6871 | header = 1; |
| 6872 | |
| 6873 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6874 | { |
| 6875 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6876 | { |
| 6877 | bgp_unlock_node (rm); |
| 6878 | continue; |
| 6879 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6880 | |
| 6881 | for (ri = rm->info; ri; ri = ri->next) |
| 6882 | { |
| 6883 | if (header) |
| 6884 | { |
| 6885 | 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] | 6886 | AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6887 | |
| 6888 | header = 0; |
| 6889 | } |
| 6890 | display++; |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6891 | |
| 6892 | if (pathtype == BGP_PATH_ALL || |
| 6893 | (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) || |
| 6894 | (pathtype == BGP_PATH_MULTIPATH && |
| 6895 | (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)))) |
| 6896 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6897 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6898 | |
| 6899 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6900 | } |
| 6901 | } |
| 6902 | } |
| 6903 | } |
| 6904 | else |
| 6905 | { |
| 6906 | header = 1; |
| 6907 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6908 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6909 | { |
| 6910 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6911 | { |
| 6912 | for (ri = rn->info; ri; ri = ri->next) |
| 6913 | { |
| 6914 | if (header) |
| 6915 | { |
| 6916 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6917 | header = 0; |
| 6918 | } |
| 6919 | display++; |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6920 | |
| 6921 | if (pathtype == BGP_PATH_ALL || |
| 6922 | (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) || |
| 6923 | (pathtype == BGP_PATH_MULTIPATH && |
| 6924 | (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)))) |
| 6925 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6926 | } |
| 6927 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6928 | |
| 6929 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6930 | } |
| 6931 | } |
| 6932 | |
| 6933 | if (! display) |
| 6934 | { |
| 6935 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6936 | return CMD_WARNING; |
| 6937 | } |
| 6938 | |
| 6939 | return CMD_SUCCESS; |
| 6940 | } |
| 6941 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6942 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6943 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6944 | 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] | 6945 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6946 | int prefix_check, enum bgp_path_type pathtype) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6947 | { |
| 6948 | struct bgp *bgp; |
| 6949 | |
| 6950 | /* BGP structure lookup. */ |
| 6951 | if (view_name) |
| 6952 | { |
| 6953 | bgp = bgp_lookup_by_name (view_name); |
| 6954 | if (bgp == NULL) |
| 6955 | { |
| 6956 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6957 | return CMD_WARNING; |
| 6958 | } |
| 6959 | } |
| 6960 | else |
| 6961 | { |
| 6962 | bgp = bgp_get_default (); |
| 6963 | if (bgp == NULL) |
| 6964 | { |
| 6965 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6966 | return CMD_WARNING; |
| 6967 | } |
| 6968 | } |
| 6969 | |
| 6970 | 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] | 6971 | afi, safi, prd, prefix_check, pathtype); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6972 | } |
| 6973 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6974 | /* BGP route print out function. */ |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 6975 | DEFUN (show_ip_bgp, |
| 6976 | show_ip_bgp_cmd, |
| 6977 | "show ip bgp", |
| 6978 | SHOW_STR |
| 6979 | IP_STR |
| 6980 | BGP_STR) |
| 6981 | { |
| 6982 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6983 | } |
| 6984 | |
| 6985 | DEFUN (show_ip_bgp_ipv4, |
| 6986 | show_ip_bgp_ipv4_cmd, |
| 6987 | "show ip bgp ipv4 (unicast|multicast)", |
| 6988 | SHOW_STR |
| 6989 | IP_STR |
| 6990 | BGP_STR |
| 6991 | "Address family\n" |
| 6992 | "Address Family modifier\n" |
| 6993 | "Address Family modifier\n") |
| 6994 | { |
| 6995 | if (strncmp (argv[0], "m", 1) == 0) |
| 6996 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6997 | NULL); |
| 6998 | |
| 6999 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 7000 | } |
| 7001 | |
| 7002 | DEFUN (show_ip_bgp_route, |
| 7003 | show_ip_bgp_route_cmd, |
| 7004 | "show ip bgp A.B.C.D", |
| 7005 | SHOW_STR |
| 7006 | IP_STR |
| 7007 | BGP_STR |
| 7008 | "Network in the BGP routing table to display\n") |
| 7009 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7010 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
| 7011 | } |
| 7012 | |
| 7013 | DEFUN (show_ip_bgp_route_pathtype, |
| 7014 | show_ip_bgp_route_pathtype_cmd, |
| 7015 | "show ip bgp A.B.C.D (bestpath|multipath)", |
| 7016 | SHOW_STR |
| 7017 | IP_STR |
| 7018 | BGP_STR |
| 7019 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7020 | "Display only the bestpath\n" |
| 7021 | "Display only multipaths\n") |
| 7022 | { |
| 7023 | if (strncmp (argv[1], "b", 1) == 0) |
| 7024 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 7025 | else |
| 7026 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH); |
| 7027 | } |
| 7028 | |
| 7029 | DEFUN (show_bgp_ipv4_safi_route_pathtype, |
| 7030 | show_bgp_ipv4_safi_route_pathtype_cmd, |
| 7031 | "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath)", |
| 7032 | SHOW_STR |
| 7033 | BGP_STR |
| 7034 | "Address family\n" |
| 7035 | "Address Family modifier\n" |
| 7036 | "Address Family modifier\n" |
| 7037 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7038 | "Display only the bestpath\n" |
| 7039 | "Display only multipaths\n") |
| 7040 | { |
| 7041 | if (strncmp (argv[0], "m", 1) == 0) |
| 7042 | if (strncmp (argv[2], "b", 1) == 0) |
| 7043 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 7044 | else |
| 7045 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH); |
| 7046 | else |
| 7047 | if (strncmp (argv[2], "b", 1) == 0) |
| 7048 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 7049 | else |
| 7050 | 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] | 7051 | } |
| 7052 | |
| 7053 | DEFUN (show_ip_bgp_ipv4_route, |
| 7054 | show_ip_bgp_ipv4_route_cmd, |
| 7055 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 7056 | SHOW_STR |
| 7057 | IP_STR |
| 7058 | BGP_STR |
| 7059 | "Address family\n" |
| 7060 | "Address Family modifier\n" |
| 7061 | "Address Family modifier\n" |
| 7062 | "Network in the BGP routing table to display\n") |
| 7063 | { |
| 7064 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7065 | 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] | 7066 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7067 | 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] | 7068 | } |
| 7069 | |
| 7070 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 7071 | show_ip_bgp_vpnv4_all_route_cmd, |
| 7072 | "show ip bgp vpnv4 all A.B.C.D", |
| 7073 | SHOW_STR |
| 7074 | IP_STR |
| 7075 | BGP_STR |
| 7076 | "Display VPNv4 NLRI specific information\n" |
| 7077 | "Display information about all VPNv4 NLRIs\n" |
| 7078 | "Network in the BGP routing table to display\n") |
| 7079 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7080 | 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] | 7081 | } |
| 7082 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7083 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7084 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 7085 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 7086 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 7087 | SHOW_STR |
| 7088 | IP_STR |
| 7089 | BGP_STR |
| 7090 | "Display VPNv4 NLRI specific information\n" |
| 7091 | "Display information for a route distinguisher\n" |
| 7092 | "VPN Route Distinguisher\n" |
| 7093 | "Network in the BGP routing table to display\n") |
| 7094 | { |
| 7095 | int ret; |
| 7096 | struct prefix_rd prd; |
| 7097 | |
| 7098 | ret = str2prefix_rd (argv[0], &prd); |
| 7099 | if (! ret) |
| 7100 | { |
| 7101 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7102 | return CMD_WARNING; |
| 7103 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7104 | 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] | 7105 | } |
| 7106 | |
| 7107 | DEFUN (show_ip_bgp_prefix, |
| 7108 | show_ip_bgp_prefix_cmd, |
| 7109 | "show ip bgp A.B.C.D/M", |
| 7110 | SHOW_STR |
| 7111 | IP_STR |
| 7112 | BGP_STR |
| 7113 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7114 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7115 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
| 7116 | } |
| 7117 | |
| 7118 | DEFUN (show_ip_bgp_prefix_pathtype, |
| 7119 | show_ip_bgp_prefix_pathtype_cmd, |
| 7120 | "show ip bgp A.B.C.D/M (bestpath|multipath)", |
| 7121 | SHOW_STR |
| 7122 | IP_STR |
| 7123 | BGP_STR |
| 7124 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7125 | "Display only the bestpath\n" |
| 7126 | "Display only multipaths\n") |
| 7127 | { |
| 7128 | if (strncmp (argv[1], "b", 1) == 0) |
| 7129 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7130 | else |
| 7131 | 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] | 7132 | } |
| 7133 | |
| 7134 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 7135 | show_ip_bgp_ipv4_prefix_cmd, |
| 7136 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 7137 | SHOW_STR |
| 7138 | IP_STR |
| 7139 | BGP_STR |
| 7140 | "Address family\n" |
| 7141 | "Address Family modifier\n" |
| 7142 | "Address Family modifier\n" |
| 7143 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7144 | { |
| 7145 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7146 | 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] | 7147 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7148 | 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] | 7149 | } |
| 7150 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7151 | DEFUN (show_ip_bgp_ipv4_prefix_pathtype, |
| 7152 | show_ip_bgp_ipv4_prefix_pathtype_cmd, |
| 7153 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath)", |
| 7154 | SHOW_STR |
| 7155 | IP_STR |
| 7156 | BGP_STR |
| 7157 | "Address family\n" |
| 7158 | "Address Family modifier\n" |
| 7159 | "Address Family modifier\n" |
| 7160 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7161 | "Display only the bestpath\n" |
| 7162 | "Display only multipaths\n") |
| 7163 | { |
| 7164 | if (strncmp (argv[0], "m", 1) == 0) |
| 7165 | if (strncmp (argv[2], "b", 1) == 0) |
| 7166 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7167 | else |
| 7168 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH); |
| 7169 | else |
| 7170 | if (strncmp (argv[2], "b", 1) == 0) |
| 7171 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7172 | else |
| 7173 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH); |
| 7174 | } |
| 7175 | |
| 7176 | ALIAS (show_ip_bgp_ipv4_prefix_pathtype, |
| 7177 | show_bgp_ipv4_safi_prefix_pathtype_cmd, |
| 7178 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath)", |
| 7179 | SHOW_STR |
| 7180 | BGP_STR |
| 7181 | "Address family\n" |
| 7182 | "Address Family modifier\n" |
| 7183 | "Address Family modifier\n" |
| 7184 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7185 | "Display only the bestpath\n" |
| 7186 | "Display only multipaths\n") |
| 7187 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7188 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 7189 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 7190 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 7191 | SHOW_STR |
| 7192 | IP_STR |
| 7193 | BGP_STR |
| 7194 | "Display VPNv4 NLRI specific information\n" |
| 7195 | "Display information about all VPNv4 NLRIs\n" |
| 7196 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7197 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7198 | 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] | 7199 | } |
| 7200 | |
| 7201 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 7202 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 7203 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 7204 | SHOW_STR |
| 7205 | IP_STR |
| 7206 | BGP_STR |
| 7207 | "Display VPNv4 NLRI specific information\n" |
| 7208 | "Display information for a route distinguisher\n" |
| 7209 | "VPN Route Distinguisher\n" |
| 7210 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7211 | { |
| 7212 | int ret; |
| 7213 | struct prefix_rd prd; |
| 7214 | |
| 7215 | ret = str2prefix_rd (argv[0], &prd); |
| 7216 | if (! ret) |
| 7217 | { |
| 7218 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7219 | return CMD_WARNING; |
| 7220 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7221 | 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] | 7222 | } |
| 7223 | |
| 7224 | DEFUN (show_ip_bgp_view, |
| 7225 | show_ip_bgp_view_cmd, |
| 7226 | "show ip bgp view WORD", |
| 7227 | SHOW_STR |
| 7228 | IP_STR |
| 7229 | BGP_STR |
| 7230 | "BGP view\n" |
| 7231 | "View name\n") |
| 7232 | { |
| 7233 | struct bgp *bgp; |
| 7234 | |
| 7235 | /* BGP structure lookup. */ |
| 7236 | bgp = bgp_lookup_by_name (argv[0]); |
| 7237 | if (bgp == NULL) |
| 7238 | { |
| 7239 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7240 | return CMD_WARNING; |
| 7241 | } |
| 7242 | |
| 7243 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 7244 | } |
| 7245 | |
| 7246 | DEFUN (show_ip_bgp_view_route, |
| 7247 | show_ip_bgp_view_route_cmd, |
| 7248 | "show ip bgp view WORD A.B.C.D", |
| 7249 | SHOW_STR |
| 7250 | IP_STR |
| 7251 | BGP_STR |
| 7252 | "BGP view\n" |
| 7253 | "View name\n" |
| 7254 | "Network in the BGP routing table to display\n") |
| 7255 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7256 | 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] | 7257 | } |
| 7258 | |
| 7259 | DEFUN (show_ip_bgp_view_prefix, |
| 7260 | show_ip_bgp_view_prefix_cmd, |
| 7261 | "show ip bgp view WORD A.B.C.D/M", |
| 7262 | SHOW_STR |
| 7263 | IP_STR |
| 7264 | BGP_STR |
| 7265 | "BGP view\n" |
| 7266 | "View name\n" |
| 7267 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7268 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7269 | 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] | 7270 | } |
| 7271 | |
| 7272 | DEFUN (show_bgp, |
| 7273 | show_bgp_cmd, |
| 7274 | "show bgp", |
| 7275 | SHOW_STR |
| 7276 | BGP_STR) |
| 7277 | { |
| 7278 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 7279 | NULL); |
| 7280 | } |
| 7281 | |
| 7282 | ALIAS (show_bgp, |
| 7283 | show_bgp_ipv6_cmd, |
| 7284 | "show bgp ipv6", |
| 7285 | SHOW_STR |
| 7286 | BGP_STR |
| 7287 | "Address family\n") |
| 7288 | |
| 7289 | /* old command */ |
| 7290 | DEFUN (show_ipv6_bgp, |
| 7291 | show_ipv6_bgp_cmd, |
| 7292 | "show ipv6 bgp", |
| 7293 | SHOW_STR |
| 7294 | IP_STR |
| 7295 | BGP_STR) |
| 7296 | { |
| 7297 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 7298 | NULL); |
| 7299 | } |
| 7300 | |
| 7301 | DEFUN (show_bgp_route, |
| 7302 | show_bgp_route_cmd, |
| 7303 | "show bgp X:X::X:X", |
| 7304 | SHOW_STR |
| 7305 | BGP_STR |
| 7306 | "Network in the BGP routing table to display\n") |
| 7307 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7308 | 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] | 7309 | } |
| 7310 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7311 | DEFUN (show_bgp_ipv4_safi, |
| 7312 | show_bgp_ipv4_safi_cmd, |
| 7313 | "show bgp ipv4 (unicast|multicast)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7314 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7315 | BGP_STR |
| 7316 | "Address family\n" |
| 7317 | "Address Family modifier\n" |
| 7318 | "Address Family modifier\n") |
| 7319 | { |
| 7320 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7321 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 7322 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7323 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7324 | 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] | 7325 | } |
| 7326 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7327 | DEFUN (show_bgp_ipv4_safi_route, |
| 7328 | show_bgp_ipv4_safi_route_cmd, |
| 7329 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7330 | SHOW_STR |
| 7331 | BGP_STR |
| 7332 | "Address family\n" |
| 7333 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7334 | "Address Family modifier\n" |
| 7335 | "Network in the BGP routing table to display\n") |
| 7336 | { |
| 7337 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7338 | 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] | 7339 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7340 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
| 7341 | } |
| 7342 | |
| 7343 | DEFUN (show_bgp_route_pathtype, |
| 7344 | show_bgp_route_pathtype_cmd, |
| 7345 | "show bgp X:X::X:X (bestpath|multipath)", |
| 7346 | SHOW_STR |
| 7347 | BGP_STR |
| 7348 | "Network in the BGP routing table to display\n" |
| 7349 | "Display only the bestpath\n" |
| 7350 | "Display only multipaths\n") |
| 7351 | { |
| 7352 | if (strncmp (argv[1], "b", 1) == 0) |
| 7353 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 7354 | else |
| 7355 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH); |
| 7356 | } |
| 7357 | |
| 7358 | ALIAS (show_bgp_route_pathtype, |
| 7359 | show_bgp_ipv6_route_pathtype_cmd, |
| 7360 | "show bgp ipv6 X:X::X:X (bestpath|multipath)", |
| 7361 | SHOW_STR |
| 7362 | BGP_STR |
| 7363 | "Address family\n" |
| 7364 | "Network in the BGP routing table to display\n" |
| 7365 | "Display only the bestpath\n" |
| 7366 | "Display only multipaths\n") |
| 7367 | |
| 7368 | DEFUN (show_bgp_ipv6_safi_route_pathtype, |
| 7369 | show_bgp_ipv6_safi_route_pathtype_cmd, |
| 7370 | "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath)", |
| 7371 | SHOW_STR |
| 7372 | BGP_STR |
| 7373 | "Address family\n" |
| 7374 | "Address Family modifier\n" |
| 7375 | "Address Family modifier\n" |
| 7376 | "Network in the BGP routing table to display\n" |
| 7377 | "Display only the bestpath\n" |
| 7378 | "Display only multipaths\n") |
| 7379 | { |
| 7380 | if (strncmp (argv[0], "m", 1) == 0) |
| 7381 | if (strncmp (argv[2], "b", 1) == 0) |
| 7382 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 7383 | else |
| 7384 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH); |
| 7385 | else |
| 7386 | if (strncmp (argv[2], "b", 1) == 0) |
| 7387 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 7388 | else |
| 7389 | 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] | 7390 | } |
| 7391 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7392 | DEFUN (show_bgp_ipv4_vpn_route, |
| 7393 | show_bgp_ipv4_vpn_route_cmd, |
| 7394 | "show bgp ipv4 vpn A.B.C.D", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7395 | SHOW_STR |
| 7396 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7397 | "Address Family\n" |
| 7398 | "Display VPN NLRI specific information\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7399 | "Network in the BGP routing table to display\n") |
| 7400 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7401 | 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] | 7402 | } |
| 7403 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7404 | DEFUN (show_bgp_ipv6_vpn_route, |
| 7405 | show_bgp_ipv6_vpn_route_cmd, |
| 7406 | "show bgp ipv6 vpn X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7407 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7408 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7409 | "Address Family\n" |
| 7410 | "Display VPN NLRI specific information\n" |
| 7411 | "Network in the BGP routing table to display\n") |
| 7412 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7413 | 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] | 7414 | } |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7415 | |
| 7416 | DEFUN (show_bgp_ipv4_vpn_rd_route, |
| 7417 | show_bgp_ipv4_vpn_rd_route_cmd, |
| 7418 | "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 7419 | SHOW_STR |
| 7420 | BGP_STR |
| 7421 | IP_STR |
| 7422 | "Display VPN NLRI specific information\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7423 | "Display information for a route distinguisher\n" |
| 7424 | "VPN Route Distinguisher\n" |
| 7425 | "Network in the BGP routing table to display\n") |
| 7426 | { |
| 7427 | int ret; |
| 7428 | struct prefix_rd prd; |
| 7429 | |
| 7430 | ret = str2prefix_rd (argv[0], &prd); |
| 7431 | if (! ret) |
| 7432 | { |
| 7433 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7434 | return CMD_WARNING; |
| 7435 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7436 | 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] | 7437 | } |
| 7438 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7439 | DEFUN (show_bgp_ipv6_vpn_rd_route, |
| 7440 | show_bgp_ipv6_vpn_rd_route_cmd, |
| 7441 | "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] | 7442 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7443 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7444 | "Address Family\n" |
| 7445 | "Display VPN NLRI specific information\n" |
| 7446 | "Display information for a route distinguisher\n" |
| 7447 | "VPN Route Distinguisher\n" |
| 7448 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7449 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7450 | int ret; |
| 7451 | struct prefix_rd prd; |
| 7452 | |
| 7453 | ret = str2prefix_rd (argv[0], &prd); |
| 7454 | if (! ret) |
| 7455 | { |
| 7456 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7457 | return CMD_WARNING; |
| 7458 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7459 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL); |
| 7460 | } |
| 7461 | |
| 7462 | DEFUN (show_bgp_prefix_pathtype, |
| 7463 | show_bgp_prefix_pathtype_cmd, |
| 7464 | "show bgp X:X::X:X/M (bestpath|multipath)", |
| 7465 | SHOW_STR |
| 7466 | BGP_STR |
| 7467 | "IPv6 prefix <network>/<length>\n" |
| 7468 | "Display only the bestpath\n" |
| 7469 | "Display only multipaths\n") |
| 7470 | { |
| 7471 | if (strncmp (argv[1], "b", 1) == 0) |
| 7472 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7473 | else |
| 7474 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH); |
| 7475 | } |
| 7476 | |
| 7477 | ALIAS (show_bgp_prefix_pathtype, |
| 7478 | show_bgp_ipv6_prefix_pathtype_cmd, |
| 7479 | "show bgp ipv6 X:X::X:X/M (bestpath|multipath)", |
| 7480 | SHOW_STR |
| 7481 | BGP_STR |
| 7482 | "Address family\n" |
| 7483 | "IPv6 prefix <network>/<length>\n" |
| 7484 | "Display only the bestpath\n" |
| 7485 | "Display only multipaths\n") |
| 7486 | |
| 7487 | DEFUN (show_bgp_ipv6_safi_prefix_pathtype, |
| 7488 | show_bgp_ipv6_safi_prefix_pathtype_cmd, |
| 7489 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath)", |
| 7490 | SHOW_STR |
| 7491 | BGP_STR |
| 7492 | "Address family\n" |
| 7493 | "Address Family modifier\n" |
| 7494 | "Address Family modifier\n" |
| 7495 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 7496 | "Display only the bestpath\n" |
| 7497 | "Display only multipaths\n") |
| 7498 | { |
| 7499 | if (strncmp (argv[0], "m", 1) == 0) |
| 7500 | if (strncmp (argv[2], "b", 1) == 0) |
| 7501 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7502 | else |
| 7503 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH); |
| 7504 | else |
| 7505 | if (strncmp (argv[2], "b", 1) == 0) |
| 7506 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7507 | else |
| 7508 | 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] | 7509 | } |
| 7510 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7511 | DEFUN (show_bgp_ipv4_encap_route, |
| 7512 | show_bgp_ipv4_encap_route_cmd, |
| 7513 | "show bgp ipv4 encap A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7514 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7515 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7516 | IP_STR |
| 7517 | "Display ENCAP NLRI specific information\n" |
| 7518 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7519 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7520 | 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] | 7521 | } |
| 7522 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7523 | DEFUN (show_bgp_ipv6_encap_route, |
| 7524 | show_bgp_ipv6_encap_route_cmd, |
| 7525 | "show bgp ipv6 encap X:X::X:X", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7526 | SHOW_STR |
| 7527 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7528 | IP6_STR |
| 7529 | "Display ENCAP NLRI specific information\n" |
| 7530 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7531 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7532 | 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] | 7533 | } |
| 7534 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7535 | DEFUN (show_bgp_ipv4_safi_rd_route, |
| 7536 | show_bgp_ipv4_safi_rd_route_cmd, |
| 7537 | "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] | 7538 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7539 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7540 | "Address Family\n" |
| 7541 | "Address Family Modifier\n" |
| 7542 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7543 | "Display information for a route distinguisher\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7544 | "ENCAP Route Distinguisher\n" |
| 7545 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7546 | { |
| 7547 | int ret; |
| 7548 | struct prefix_rd prd; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7549 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7550 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7551 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7552 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7553 | return CMD_WARNING; |
| 7554 | } |
| 7555 | ret = str2prefix_rd (argv[1], &prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7556 | if (! ret) |
| 7557 | { |
| 7558 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7559 | return CMD_WARNING; |
| 7560 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7561 | 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] | 7562 | } |
| 7563 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7564 | DEFUN (show_bgp_ipv6_safi_rd_route, |
| 7565 | show_bgp_ipv6_safi_rd_route_cmd, |
| 7566 | "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] | 7567 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7568 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7569 | "Address Family\n" |
| 7570 | "Address Family Modifier\n" |
| 7571 | "Address Family Modifier\n" |
| 7572 | "Display information for a route distinguisher\n" |
| 7573 | "ENCAP Route Distinguisher\n" |
| 7574 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7575 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7576 | int ret; |
| 7577 | struct prefix_rd prd; |
| 7578 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7579 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7580 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7581 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7582 | return CMD_WARNING; |
| 7583 | } |
| 7584 | ret = str2prefix_rd (argv[1], &prd); |
| 7585 | if (! ret) |
| 7586 | { |
| 7587 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7588 | return CMD_WARNING; |
| 7589 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7590 | 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] | 7591 | } |
| 7592 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7593 | DEFUN (show_bgp_ipv4_prefix, |
| 7594 | show_bgp_ipv4_prefix_cmd, |
| 7595 | "show bgp ipv4 A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7596 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7597 | BGP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7598 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7599 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7600 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7601 | 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] | 7602 | } |
| 7603 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7604 | DEFUN (show_bgp_ipv4_safi_prefix, |
| 7605 | show_bgp_ipv4_safi_prefix_cmd, |
| 7606 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7607 | SHOW_STR |
| 7608 | BGP_STR |
| 7609 | "Address family\n" |
| 7610 | "Address Family modifier\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7611 | "Address Family modifier\n" |
| 7612 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7613 | { |
| 7614 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7615 | 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] | 7616 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7617 | 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] | 7618 | } |
| 7619 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7620 | DEFUN (show_bgp_ipv4_vpn_prefix, |
| 7621 | show_bgp_ipv4_vpn_prefix_cmd, |
| 7622 | "show bgp ipv4 vpn A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7623 | SHOW_STR |
| 7624 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7625 | IP_STR |
| 7626 | "Display VPN NLRI specific information\n" |
| 7627 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7628 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7629 | 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] | 7630 | } |
| 7631 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7632 | DEFUN (show_bgp_ipv6_vpn_prefix, |
| 7633 | show_bgp_ipv6_vpn_prefix_cmd, |
| 7634 | "show bgp ipv6 vpn X:X::X:X/M", |
| 7635 | SHOW_STR |
| 7636 | BGP_STR |
| 7637 | "Address Family\n" |
| 7638 | "Display VPN NLRI specific information\n" |
| 7639 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7640 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7641 | 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] | 7642 | } |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7643 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7644 | DEFUN (show_bgp_ipv4_encap_prefix, |
| 7645 | show_bgp_ipv4_encap_prefix_cmd, |
| 7646 | "show bgp ipv4 encap A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7647 | SHOW_STR |
| 7648 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7649 | IP_STR |
| 7650 | "Display ENCAP NLRI specific information\n" |
| 7651 | "Display information about ENCAP NLRIs\n" |
| 7652 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7653 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7654 | 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] | 7655 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7656 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7657 | DEFUN (show_bgp_ipv6_encap_prefix, |
| 7658 | show_bgp_ipv6_encap_prefix_cmd, |
| 7659 | "show bgp ipv6 encap X:X::X:X/M", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7660 | SHOW_STR |
| 7661 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7662 | IP_STR |
| 7663 | "Display ENCAP NLRI specific information\n" |
| 7664 | "Display information about ENCAP NLRIs\n" |
| 7665 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7666 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7667 | 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] | 7668 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7669 | |
| 7670 | DEFUN (show_bgp_ipv4_safi_rd_prefix, |
| 7671 | show_bgp_ipv4_safi_rd_prefix_cmd, |
| 7672 | "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 7673 | SHOW_STR |
| 7674 | BGP_STR |
| 7675 | "Address Family\n" |
| 7676 | "Address Family Modifier\n" |
| 7677 | "Address Family Modifier\n" |
| 7678 | "Display information for a route distinguisher\n" |
| 7679 | "ENCAP Route Distinguisher\n" |
| 7680 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7681 | { |
| 7682 | int ret; |
| 7683 | struct prefix_rd prd; |
| 7684 | safi_t safi; |
| 7685 | |
| 7686 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7687 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7688 | return CMD_WARNING; |
| 7689 | } |
| 7690 | |
| 7691 | ret = str2prefix_rd (argv[1], &prd); |
| 7692 | if (! ret) |
| 7693 | { |
| 7694 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7695 | return CMD_WARNING; |
| 7696 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7697 | 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] | 7698 | } |
| 7699 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7700 | DEFUN (show_bgp_ipv6_safi_rd_prefix, |
| 7701 | show_bgp_ipv6_safi_rd_prefix_cmd, |
| 7702 | "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M", |
| 7703 | SHOW_STR |
| 7704 | BGP_STR |
| 7705 | "Address Family\n" |
| 7706 | "Address Family Modifier\n" |
| 7707 | "Address Family Modifier\n" |
| 7708 | "Display information for a route distinguisher\n" |
| 7709 | "ENCAP Route Distinguisher\n" |
| 7710 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7711 | { |
| 7712 | int ret; |
| 7713 | struct prefix_rd prd; |
| 7714 | safi_t safi; |
| 7715 | |
| 7716 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7717 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7718 | return CMD_WARNING; |
| 7719 | } |
| 7720 | |
| 7721 | ret = str2prefix_rd (argv[1], &prd); |
| 7722 | if (! ret) |
| 7723 | { |
| 7724 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7725 | return CMD_WARNING; |
| 7726 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7727 | 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] | 7728 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7729 | |
| 7730 | DEFUN (show_bgp_afi_safi_view, |
| 7731 | show_bgp_afi_safi_view_cmd, |
| 7732 | "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)", |
| 7733 | SHOW_STR |
| 7734 | BGP_STR |
| 7735 | "BGP view\n" |
| 7736 | "BGP view name\n" |
| 7737 | "Address Family\n" |
| 7738 | "Address Family\n" |
| 7739 | "Address Family Modifier\n" |
| 7740 | "Address Family Modifier\n" |
| 7741 | "Address Family Modifier\n" |
| 7742 | "Address Family Modifier\n" |
| 7743 | ) |
| 7744 | { |
| 7745 | struct bgp *bgp; |
| 7746 | safi_t safi; |
| 7747 | afi_t afi; |
| 7748 | |
| 7749 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7750 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7751 | return CMD_WARNING; |
| 7752 | } |
| 7753 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7754 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7755 | return CMD_WARNING; |
| 7756 | } |
| 7757 | |
| 7758 | /* BGP structure lookup. */ |
| 7759 | bgp = bgp_lookup_by_name (argv[0]); |
| 7760 | if (bgp == NULL) |
| 7761 | { |
| 7762 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7763 | return CMD_WARNING; |
| 7764 | } |
| 7765 | |
| 7766 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL); |
| 7767 | } |
| 7768 | |
| 7769 | DEFUN (show_bgp_view_afi_safi_route, |
| 7770 | show_bgp_view_afi_safi_route_cmd, |
| 7771 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D", |
| 7772 | SHOW_STR |
| 7773 | BGP_STR |
| 7774 | "BGP view\n" |
| 7775 | "View name\n" |
| 7776 | "Address Family\n" |
| 7777 | "Address Family\n" |
| 7778 | "Address Family Modifier\n" |
| 7779 | "Address Family Modifier\n" |
| 7780 | "Address Family Modifier\n" |
| 7781 | "Address Family Modifier\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7782 | "Network in the BGP routing table to display\n") |
| 7783 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7784 | safi_t safi; |
| 7785 | afi_t afi; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7786 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7787 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7788 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7789 | return CMD_WARNING; |
| 7790 | } |
| 7791 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7792 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7793 | return CMD_WARNING; |
| 7794 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7795 | 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] | 7796 | } |
| 7797 | |
| 7798 | DEFUN (show_bgp_view_afi_safi_prefix, |
| 7799 | show_bgp_view_afi_safi_prefix_cmd, |
| 7800 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M", |
| 7801 | SHOW_STR |
| 7802 | BGP_STR |
| 7803 | "BGP view\n" |
| 7804 | "View name\n" |
| 7805 | "Address Family\n" |
| 7806 | "Address Family\n" |
| 7807 | "Address Family Modifier\n" |
| 7808 | "Address Family Modifier\n" |
| 7809 | "Address Family Modifier\n" |
| 7810 | "Address Family Modifier\n" |
| 7811 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7812 | { |
| 7813 | safi_t safi; |
| 7814 | afi_t afi; |
| 7815 | |
| 7816 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7817 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7818 | return CMD_WARNING; |
| 7819 | } |
| 7820 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7821 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7822 | return CMD_WARNING; |
| 7823 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7824 | 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] | 7825 | } |
| 7826 | |
| 7827 | /* new001 */ |
| 7828 | DEFUN (show_bgp_afi, |
| 7829 | show_bgp_afi_cmd, |
| 7830 | "show bgp (ipv4|ipv6)", |
| 7831 | SHOW_STR |
| 7832 | BGP_STR |
| 7833 | "Address family\n" |
| 7834 | "Address family\n") |
| 7835 | { |
| 7836 | afi_t afi; |
| 7837 | |
| 7838 | if (bgp_parse_afi(argv[0], &afi)) { |
| 7839 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7840 | return CMD_WARNING; |
| 7841 | } |
| 7842 | return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal, |
| 7843 | NULL); |
| 7844 | } |
| 7845 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7846 | DEFUN (show_bgp_ipv6_safi, |
| 7847 | show_bgp_ipv6_safi_cmd, |
| 7848 | "show bgp ipv6 (unicast|multicast)", |
| 7849 | SHOW_STR |
| 7850 | BGP_STR |
| 7851 | "Address family\n" |
| 7852 | "Address Family modifier\n" |
| 7853 | "Address Family modifier\n") |
| 7854 | { |
| 7855 | if (strncmp (argv[0], "m", 1) == 0) |
| 7856 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7857 | NULL); |
| 7858 | |
| 7859 | 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] | 7860 | } |
| 7861 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7862 | DEFUN (show_bgp_ipv6_route, |
| 7863 | show_bgp_ipv6_route_cmd, |
| 7864 | "show bgp ipv6 X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7865 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7866 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7867 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7868 | "Network in the BGP routing table to display\n") |
| 7869 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7870 | 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] | 7871 | } |
| 7872 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7873 | DEFUN (show_bgp_ipv6_safi_route, |
| 7874 | show_bgp_ipv6_safi_route_cmd, |
| 7875 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7876 | SHOW_STR |
| 7877 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7878 | "Address family\n" |
| 7879 | "Address Family modifier\n" |
| 7880 | "Address Family modifier\n" |
| 7881 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7882 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7883 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7884 | 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] | 7885 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7886 | 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] | 7887 | } |
| 7888 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7889 | /* old command */ |
| 7890 | DEFUN (show_ipv6_bgp_route, |
| 7891 | show_ipv6_bgp_route_cmd, |
| 7892 | "show ipv6 bgp X:X::X:X", |
| 7893 | SHOW_STR |
| 7894 | IP_STR |
| 7895 | BGP_STR |
| 7896 | "Network in the BGP routing table to display\n") |
| 7897 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7898 | 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] | 7899 | } |
| 7900 | |
| 7901 | DEFUN (show_bgp_prefix, |
| 7902 | show_bgp_prefix_cmd, |
| 7903 | "show bgp X:X::X:X/M", |
| 7904 | SHOW_STR |
| 7905 | BGP_STR |
| 7906 | "IPv6 prefix <network>/<length>\n") |
| 7907 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7908 | 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] | 7909 | } |
| 7910 | |
| 7911 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7912 | /* new002 */ |
| 7913 | DEFUN (show_bgp_ipv6_prefix, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7914 | show_bgp_ipv6_prefix_cmd, |
| 7915 | "show bgp ipv6 X:X::X:X/M", |
| 7916 | SHOW_STR |
| 7917 | BGP_STR |
| 7918 | "Address family\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7919 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7920 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7921 | 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] | 7922 | } |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7923 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 7924 | show_bgp_ipv6_safi_prefix_cmd, |
| 7925 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 7926 | SHOW_STR |
| 7927 | BGP_STR |
| 7928 | "Address family\n" |
| 7929 | "Address Family modifier\n" |
| 7930 | "Address Family modifier\n" |
| 7931 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7932 | { |
| 7933 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7934 | 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] | 7935 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7936 | 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] | 7937 | } |
| 7938 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7939 | /* old command */ |
| 7940 | DEFUN (show_ipv6_bgp_prefix, |
| 7941 | show_ipv6_bgp_prefix_cmd, |
| 7942 | "show ipv6 bgp X:X::X:X/M", |
| 7943 | SHOW_STR |
| 7944 | IP_STR |
| 7945 | BGP_STR |
| 7946 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7947 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7948 | 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] | 7949 | } |
| 7950 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7951 | DEFUN (show_bgp_view, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7952 | show_bgp_view_cmd, |
| 7953 | "show bgp view WORD", |
| 7954 | SHOW_STR |
| 7955 | BGP_STR |
| 7956 | "BGP view\n" |
| 7957 | "View name\n") |
| 7958 | { |
| 7959 | struct bgp *bgp; |
| 7960 | |
| 7961 | /* BGP structure lookup. */ |
| 7962 | bgp = bgp_lookup_by_name (argv[0]); |
| 7963 | if (bgp == NULL) |
| 7964 | { |
| 7965 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7966 | return CMD_WARNING; |
| 7967 | } |
| 7968 | |
| 7969 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 7970 | } |
| 7971 | |
| 7972 | DEFUN (show_bgp_view_ipv6, |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7973 | show_bgp_view_ipv6_cmd, |
| 7974 | "show bgp view WORD ipv6", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7975 | SHOW_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7976 | BGP_STR |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7977 | "BGP view\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7978 | "View name\n" |
| 7979 | "Address family\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7980 | { |
| 7981 | struct bgp *bgp; |
| 7982 | |
| 7983 | /* BGP structure lookup. */ |
| 7984 | bgp = bgp_lookup_by_name (argv[0]); |
| 7985 | if (bgp == NULL) |
| 7986 | { |
| 7987 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7988 | return CMD_WARNING; |
| 7989 | } |
| 7990 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7991 | 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] | 7992 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7993 | |
| 7994 | DEFUN (show_bgp_view_route, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7995 | show_bgp_view_route_cmd, |
| 7996 | "show bgp view WORD X:X::X:X", |
| 7997 | SHOW_STR |
| 7998 | BGP_STR |
| 7999 | "BGP view\n" |
| 8000 | "View name\n" |
| 8001 | "Network in the BGP routing table to display\n") |
| 8002 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 8003 | 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] | 8004 | } |
| 8005 | |
| 8006 | DEFUN (show_bgp_view_ipv6_route, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8007 | show_bgp_view_ipv6_route_cmd, |
| 8008 | "show bgp view WORD ipv6 X:X::X:X", |
| 8009 | SHOW_STR |
| 8010 | BGP_STR |
| 8011 | "BGP view\n" |
| 8012 | "View name\n" |
| 8013 | "Address family\n" |
| 8014 | "Network in the BGP routing table to display\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8015 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 8016 | 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] | 8017 | } |
| 8018 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8019 | /* old command */ |
| 8020 | DEFUN (show_ipv6_mbgp, |
| 8021 | show_ipv6_mbgp_cmd, |
| 8022 | "show ipv6 mbgp", |
| 8023 | SHOW_STR |
| 8024 | IP_STR |
| 8025 | MBGP_STR) |
| 8026 | { |
| 8027 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 8028 | NULL); |
| 8029 | } |
| 8030 | |
| 8031 | /* old command */ |
| 8032 | DEFUN (show_ipv6_mbgp_route, |
| 8033 | show_ipv6_mbgp_route_cmd, |
| 8034 | "show ipv6 mbgp X:X::X:X", |
| 8035 | SHOW_STR |
| 8036 | IP_STR |
| 8037 | MBGP_STR |
| 8038 | "Network in the MBGP routing table to display\n") |
| 8039 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 8040 | 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] | 8041 | } |
| 8042 | |
| 8043 | /* old command */ |
| 8044 | DEFUN (show_ipv6_mbgp_prefix, |
| 8045 | show_ipv6_mbgp_prefix_cmd, |
| 8046 | "show ipv6 mbgp X:X::X:X/M", |
| 8047 | SHOW_STR |
| 8048 | IP_STR |
| 8049 | MBGP_STR |
| 8050 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 8051 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 8052 | 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] | 8053 | } |
| 8054 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8055 | DEFUN (show_bgp_view_prefix, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8056 | show_bgp_view_prefix_cmd, |
| 8057 | "show bgp view WORD X:X::X:X/M", |
| 8058 | SHOW_STR |
| 8059 | BGP_STR |
| 8060 | "BGP view\n" |
| 8061 | "View name\n" |
| 8062 | "IPv6 prefix <network>/<length>\n") |
| 8063 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 8064 | 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] | 8065 | } |
| 8066 | |
| 8067 | DEFUN (show_bgp_view_ipv6_prefix, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8068 | show_bgp_view_ipv6_prefix_cmd, |
| 8069 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 8070 | SHOW_STR |
| 8071 | BGP_STR |
| 8072 | "BGP view\n" |
| 8073 | "View name\n" |
| 8074 | "Address family\n" |
| 8075 | "IPv6 prefix <network>/<length>\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8076 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 8077 | 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] | 8078 | } |
| 8079 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8080 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8081 | 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] | 8082 | safi_t safi, enum bgp_show_type type) |
| 8083 | { |
| 8084 | int i; |
| 8085 | struct buffer *b; |
| 8086 | char *regstr; |
| 8087 | int first; |
| 8088 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8089 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8090 | |
| 8091 | first = 0; |
| 8092 | b = buffer_new (1024); |
| 8093 | for (i = 0; i < argc; i++) |
| 8094 | { |
| 8095 | if (first) |
| 8096 | buffer_putc (b, ' '); |
| 8097 | else |
| 8098 | { |
| 8099 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 8100 | continue; |
| 8101 | first = 1; |
| 8102 | } |
| 8103 | |
| 8104 | buffer_putstr (b, argv[i]); |
| 8105 | } |
| 8106 | buffer_putc (b, '\0'); |
| 8107 | |
| 8108 | regstr = buffer_getstr (b); |
| 8109 | buffer_free (b); |
| 8110 | |
| 8111 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 8112 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8113 | if (! regex) |
| 8114 | { |
| 8115 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 8116 | VTY_NEWLINE); |
| 8117 | return CMD_WARNING; |
| 8118 | } |
| 8119 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8120 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 8121 | bgp_regex_free (regex); |
| 8122 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8123 | } |
| 8124 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8125 | |
| 8126 | DEFUN (show_ip_bgp_regexp, |
| 8127 | show_ip_bgp_regexp_cmd, |
| 8128 | "show ip bgp regexp .LINE", |
| 8129 | SHOW_STR |
| 8130 | IP_STR |
| 8131 | BGP_STR |
| 8132 | "Display routes matching the AS path regular expression\n" |
| 8133 | "A regular-expression to match the BGP AS paths\n") |
| 8134 | { |
| 8135 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 8136 | bgp_show_type_regexp); |
| 8137 | } |
| 8138 | |
| 8139 | DEFUN (show_ip_bgp_flap_regexp, |
| 8140 | show_ip_bgp_flap_regexp_cmd, |
| 8141 | "show ip bgp flap-statistics regexp .LINE", |
| 8142 | SHOW_STR |
| 8143 | IP_STR |
| 8144 | BGP_STR |
| 8145 | "Display flap statistics of routes\n" |
| 8146 | "Display routes matching the AS path regular expression\n" |
| 8147 | "A regular-expression to match the BGP AS paths\n") |
| 8148 | { |
| 8149 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 8150 | bgp_show_type_flap_regexp); |
| 8151 | } |
| 8152 | |
| 8153 | ALIAS (show_ip_bgp_flap_regexp, |
| 8154 | show_ip_bgp_damp_flap_regexp_cmd, |
| 8155 | "show ip bgp dampening flap-statistics regexp .LINE", |
| 8156 | SHOW_STR |
| 8157 | IP_STR |
| 8158 | BGP_STR |
| 8159 | "Display detailed information about dampening\n" |
| 8160 | "Display flap statistics of routes\n" |
| 8161 | "Display routes matching the AS path regular expression\n" |
| 8162 | "A regular-expression to match the BGP AS paths\n") |
| 8163 | |
| 8164 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 8165 | show_ip_bgp_ipv4_regexp_cmd, |
| 8166 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 8167 | SHOW_STR |
| 8168 | IP_STR |
| 8169 | BGP_STR |
| 8170 | "Address family\n" |
| 8171 | "Address Family modifier\n" |
| 8172 | "Address Family modifier\n" |
| 8173 | "Display routes matching the AS path regular expression\n" |
| 8174 | "A regular-expression to match the BGP AS paths\n") |
| 8175 | { |
| 8176 | if (strncmp (argv[0], "m", 1) == 0) |
| 8177 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 8178 | bgp_show_type_regexp); |
| 8179 | |
| 8180 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 8181 | bgp_show_type_regexp); |
| 8182 | } |
| 8183 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8184 | DEFUN (show_bgp_regexp, |
| 8185 | show_bgp_regexp_cmd, |
| 8186 | "show bgp regexp .LINE", |
| 8187 | SHOW_STR |
| 8188 | BGP_STR |
| 8189 | "Display routes matching the AS path regular expression\n" |
| 8190 | "A regular-expression to match the BGP AS paths\n") |
| 8191 | { |
| 8192 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 8193 | bgp_show_type_regexp); |
| 8194 | } |
| 8195 | |
| 8196 | /* old command */ |
| 8197 | DEFUN (show_ipv6_bgp_regexp, |
| 8198 | show_ipv6_bgp_regexp_cmd, |
| 8199 | "show ipv6 bgp regexp .LINE", |
| 8200 | SHOW_STR |
| 8201 | IP_STR |
| 8202 | BGP_STR |
| 8203 | "Display routes matching the AS path regular expression\n" |
| 8204 | "A regular-expression to match the BGP AS paths\n") |
| 8205 | { |
| 8206 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 8207 | bgp_show_type_regexp); |
| 8208 | } |
| 8209 | |
| 8210 | /* old command */ |
| 8211 | DEFUN (show_ipv6_mbgp_regexp, |
| 8212 | show_ipv6_mbgp_regexp_cmd, |
| 8213 | "show ipv6 mbgp regexp .LINE", |
| 8214 | SHOW_STR |
| 8215 | IP_STR |
| 8216 | BGP_STR |
| 8217 | "Display routes matching the AS path regular expression\n" |
| 8218 | "A regular-expression to match the MBGP AS paths\n") |
| 8219 | { |
| 8220 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 8221 | bgp_show_type_regexp); |
| 8222 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8223 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8224 | DEFUN (show_bgp_ipv4_safi_flap_regexp, |
| 8225 | show_bgp_ipv4_safi_flap_regexp_cmd, |
| 8226 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8227 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8228 | BGP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8229 | IP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8230 | "Address Family Modifier\n" |
| 8231 | "Address Family Modifier\n" |
| 8232 | "Address Family Modifier\n" |
| 8233 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8234 | "Display flap statistics of routes\n" |
| 8235 | "Display routes matching the AS path regular expression\n" |
| 8236 | "A regular-expression to match the BGP AS paths\n") |
| 8237 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8238 | safi_t safi; |
| 8239 | |
| 8240 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8241 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 8242 | return CMD_WARNING; |
| 8243 | } |
| 8244 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi, |
| 8245 | bgp_show_type_flap_regexp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8246 | } |
| 8247 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8248 | ALIAS (show_bgp_ipv4_safi_flap_regexp, |
| 8249 | show_bgp_ipv4_safi_damp_flap_regexp_cmd, |
| 8250 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8251 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8252 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8253 | IP_STR |
| 8254 | "Address Family Modifier\n" |
| 8255 | "Address Family Modifier\n" |
| 8256 | "Address Family Modifier\n" |
| 8257 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8258 | "Display detailed information about dampening\n" |
| 8259 | "Display flap statistics of routes\n" |
| 8260 | "Display routes matching the AS path regular expression\n" |
| 8261 | "A regular-expression to match the BGP AS paths\n") |
| 8262 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8263 | DEFUN (show_bgp_ipv6_safi_flap_regexp, |
| 8264 | show_bgp_ipv6_safi_flap_regexp_cmd, |
| 8265 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8266 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8267 | BGP_STR |
| 8268 | IPV6_STR |
| 8269 | "Address Family Modifier\n" |
| 8270 | "Address Family Modifier\n" |
| 8271 | "Address Family Modifier\n" |
| 8272 | "Address Family Modifier\n" |
| 8273 | "Display flap statistics of routes\n" |
| 8274 | "Display routes matching the AS path regular expression\n" |
| 8275 | "A regular-expression to match the BGP AS paths\n") |
| 8276 | { |
| 8277 | safi_t safi; |
| 8278 | |
| 8279 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8280 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 8281 | return CMD_WARNING; |
| 8282 | } |
| 8283 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi, |
| 8284 | bgp_show_type_flap_regexp); |
| 8285 | } |
| 8286 | |
| 8287 | ALIAS (show_bgp_ipv6_safi_flap_regexp, |
| 8288 | show_bgp_ipv6_safi_damp_flap_regexp_cmd, |
| 8289 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE", |
| 8290 | SHOW_STR |
| 8291 | BGP_STR |
| 8292 | IPV6_STR |
| 8293 | "Address Family Modifier\n" |
| 8294 | "Address Family Modifier\n" |
| 8295 | "Address Family Modifier\n" |
| 8296 | "Address Family Modifier\n" |
| 8297 | "Display detailed information about dampening\n" |
| 8298 | "Display flap statistics of routes\n" |
| 8299 | "Display routes matching the AS path regular expression\n" |
| 8300 | "A regular-expression to match the BGP AS paths\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8301 | |
| 8302 | DEFUN (show_bgp_ipv4_safi_regexp, |
| 8303 | show_bgp_ipv4_safi_regexp_cmd, |
| 8304 | "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE", |
| 8305 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8306 | BGP_STR |
| 8307 | "Address family\n" |
| 8308 | "Address Family modifier\n" |
| 8309 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8310 | "Address Family modifier\n" |
| 8311 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8312 | "Display routes matching the AS path regular expression\n" |
| 8313 | "A regular-expression to match the BGP AS paths\n") |
| 8314 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8315 | safi_t safi; |
| 8316 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8317 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8318 | return CMD_WARNING; |
| 8319 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8320 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8321 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8322 | bgp_show_type_regexp); |
| 8323 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8324 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8325 | DEFUN (show_bgp_ipv6_safi_regexp, |
| 8326 | show_bgp_ipv6_safi_regexp_cmd, |
| 8327 | "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8328 | SHOW_STR |
| 8329 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8330 | "Address family\n" |
| 8331 | "Address Family modifier\n" |
| 8332 | "Address Family modifier\n" |
| 8333 | "Address Family modifier\n" |
| 8334 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8335 | "Display routes matching the AS path regular expression\n" |
| 8336 | "A regular-expression to match the BGP AS paths\n") |
| 8337 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8338 | safi_t safi; |
| 8339 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8340 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8341 | return CMD_WARNING; |
| 8342 | } |
| 8343 | |
| 8344 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8345 | bgp_show_type_regexp); |
| 8346 | } |
| 8347 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8348 | DEFUN (show_bgp_ipv6_regexp, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8349 | show_bgp_ipv6_regexp_cmd, |
| 8350 | "show bgp ipv6 regexp .LINE", |
| 8351 | SHOW_STR |
| 8352 | BGP_STR |
| 8353 | "Address family\n" |
| 8354 | "Display routes matching the AS path regular expression\n" |
| 8355 | "A regular-expression to match the BGP AS paths\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8356 | { |
| 8357 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 8358 | bgp_show_type_regexp); |
| 8359 | } |
| 8360 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8361 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8362 | 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] | 8363 | safi_t safi, enum bgp_show_type type) |
| 8364 | { |
| 8365 | struct prefix_list *plist; |
| 8366 | |
| 8367 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 8368 | if (plist == NULL) |
| 8369 | { |
| 8370 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 8371 | prefix_list_str, VTY_NEWLINE); |
| 8372 | return CMD_WARNING; |
| 8373 | } |
| 8374 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8375 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8376 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8377 | DEFUN (show_ip_bgp_prefix_list, |
| 8378 | show_ip_bgp_prefix_list_cmd, |
| 8379 | "show ip bgp prefix-list WORD", |
| 8380 | SHOW_STR |
| 8381 | IP_STR |
| 8382 | BGP_STR |
| 8383 | "Display routes conforming to the prefix-list\n" |
| 8384 | "IP prefix-list name\n") |
| 8385 | { |
| 8386 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8387 | bgp_show_type_prefix_list); |
| 8388 | } |
| 8389 | |
| 8390 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 8391 | show_ip_bgp_flap_prefix_list_cmd, |
| 8392 | "show ip bgp flap-statistics prefix-list WORD", |
| 8393 | SHOW_STR |
| 8394 | IP_STR |
| 8395 | BGP_STR |
| 8396 | "Display flap statistics of routes\n" |
| 8397 | "Display routes conforming to the prefix-list\n" |
| 8398 | "IP prefix-list name\n") |
| 8399 | { |
| 8400 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8401 | bgp_show_type_flap_prefix_list); |
| 8402 | } |
| 8403 | |
| 8404 | ALIAS (show_ip_bgp_flap_prefix_list, |
| 8405 | show_ip_bgp_damp_flap_prefix_list_cmd, |
| 8406 | "show ip bgp dampening flap-statistics prefix-list WORD", |
| 8407 | SHOW_STR |
| 8408 | IP_STR |
| 8409 | BGP_STR |
| 8410 | "Display detailed information about dampening\n" |
| 8411 | "Display flap statistics of routes\n" |
| 8412 | "Display routes conforming to the prefix-list\n" |
| 8413 | "IP prefix-list name\n") |
| 8414 | |
| 8415 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 8416 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 8417 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 8418 | SHOW_STR |
| 8419 | IP_STR |
| 8420 | BGP_STR |
| 8421 | "Address family\n" |
| 8422 | "Address Family modifier\n" |
| 8423 | "Address Family modifier\n" |
| 8424 | "Display routes conforming to the prefix-list\n" |
| 8425 | "IP prefix-list name\n") |
| 8426 | { |
| 8427 | if (strncmp (argv[0], "m", 1) == 0) |
| 8428 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8429 | bgp_show_type_prefix_list); |
| 8430 | |
| 8431 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8432 | bgp_show_type_prefix_list); |
| 8433 | } |
| 8434 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8435 | DEFUN (show_bgp_prefix_list, |
| 8436 | show_bgp_prefix_list_cmd, |
| 8437 | "show bgp prefix-list WORD", |
| 8438 | SHOW_STR |
| 8439 | BGP_STR |
| 8440 | "Display routes conforming to the prefix-list\n" |
| 8441 | "IPv6 prefix-list name\n") |
| 8442 | { |
| 8443 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8444 | bgp_show_type_prefix_list); |
| 8445 | } |
| 8446 | |
| 8447 | ALIAS (show_bgp_prefix_list, |
| 8448 | show_bgp_ipv6_prefix_list_cmd, |
| 8449 | "show bgp ipv6 prefix-list WORD", |
| 8450 | SHOW_STR |
| 8451 | BGP_STR |
| 8452 | "Address family\n" |
| 8453 | "Display routes conforming to the prefix-list\n" |
| 8454 | "IPv6 prefix-list name\n") |
| 8455 | |
| 8456 | /* old command */ |
| 8457 | DEFUN (show_ipv6_bgp_prefix_list, |
| 8458 | show_ipv6_bgp_prefix_list_cmd, |
| 8459 | "show ipv6 bgp prefix-list WORD", |
| 8460 | SHOW_STR |
| 8461 | IPV6_STR |
| 8462 | BGP_STR |
| 8463 | "Display routes matching the prefix-list\n" |
| 8464 | "IPv6 prefix-list name\n") |
| 8465 | { |
| 8466 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8467 | bgp_show_type_prefix_list); |
| 8468 | } |
| 8469 | |
| 8470 | /* old command */ |
| 8471 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 8472 | show_ipv6_mbgp_prefix_list_cmd, |
| 8473 | "show ipv6 mbgp prefix-list WORD", |
| 8474 | SHOW_STR |
| 8475 | IPV6_STR |
| 8476 | MBGP_STR |
| 8477 | "Display routes matching the prefix-list\n" |
| 8478 | "IPv6 prefix-list name\n") |
| 8479 | { |
| 8480 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8481 | bgp_show_type_prefix_list); |
| 8482 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8483 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8484 | DEFUN (show_bgp_ipv4_prefix_list, |
| 8485 | show_bgp_ipv4_prefix_list_cmd, |
| 8486 | "show bgp ipv4 prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8487 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8488 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8489 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8490 | "Display routes conforming to the prefix-list\n" |
| 8491 | "IP prefix-list name\n") |
| 8492 | { |
| 8493 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8494 | bgp_show_type_prefix_list); |
| 8495 | } |
| 8496 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8497 | DEFUN (show_bgp_ipv4_safi_flap_prefix_list, |
| 8498 | show_bgp_ipv4_safi_flap_prefix_list_cmd, |
| 8499 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8500 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8501 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8502 | IP_STR |
| 8503 | "Address Family Modifier\n" |
| 8504 | "Address Family Modifier\n" |
| 8505 | "Address Family Modifier\n" |
| 8506 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8507 | "Display flap statistics of routes\n" |
| 8508 | "Display routes conforming to the prefix-list\n" |
| 8509 | "IP prefix-list name\n") |
| 8510 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8511 | safi_t safi; |
| 8512 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8513 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8514 | return CMD_WARNING; |
| 8515 | } |
| 8516 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8517 | bgp_show_type_flap_prefix_list); |
| 8518 | } |
| 8519 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8520 | ALIAS (show_bgp_ipv4_safi_flap_prefix_list, |
| 8521 | show_bgp_ipv4_safi_damp_flap_prefix_list_cmd, |
| 8522 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8523 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8524 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8525 | IP_STR |
| 8526 | "Address Family Modifier\n" |
| 8527 | "Address Family Modifier\n" |
| 8528 | "Address Family Modifier\n" |
| 8529 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8530 | "Display detailed information about dampening\n" |
| 8531 | "Display flap statistics of routes\n" |
| 8532 | "Display routes conforming to the prefix-list\n" |
| 8533 | "IP prefix-list name\n") |
| 8534 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8535 | DEFUN (show_bgp_ipv6_safi_flap_prefix_list, |
| 8536 | show_bgp_ipv6_safi_flap_prefix_list_cmd, |
| 8537 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8538 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8539 | BGP_STR |
| 8540 | IPV6_STR |
| 8541 | "Address Family Modifier\n" |
| 8542 | "Address Family Modifier\n" |
| 8543 | "Address Family Modifier\n" |
| 8544 | "Address Family Modifier\n" |
| 8545 | "Display flap statistics of routes\n" |
| 8546 | "Display routes conforming to the prefix-list\n" |
| 8547 | "IP prefix-list name\n") |
| 8548 | { |
| 8549 | safi_t safi; |
| 8550 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8551 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8552 | return CMD_WARNING; |
| 8553 | } |
| 8554 | return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi, |
| 8555 | bgp_show_type_flap_prefix_list); |
| 8556 | } |
| 8557 | ALIAS (show_bgp_ipv6_safi_flap_prefix_list, |
| 8558 | show_bgp_ipv6_safi_damp_flap_prefix_list_cmd, |
| 8559 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD", |
| 8560 | SHOW_STR |
| 8561 | BGP_STR |
| 8562 | IPV6_STR |
| 8563 | "Address Family Modifier\n" |
| 8564 | "Address Family Modifier\n" |
| 8565 | "Address Family Modifier\n" |
| 8566 | "Address Family Modifier\n" |
| 8567 | "Display detailed information about dampening\n" |
| 8568 | "Display flap statistics of routes\n" |
| 8569 | "Display routes conforming to the prefix-list\n" |
| 8570 | "IP prefix-list name\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8571 | |
| 8572 | DEFUN (show_bgp_ipv4_safi_prefix_list, |
| 8573 | show_bgp_ipv4_safi_prefix_list_cmd, |
| 8574 | "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD", |
| 8575 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8576 | BGP_STR |
| 8577 | "Address family\n" |
| 8578 | "Address Family modifier\n" |
| 8579 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8580 | "Address Family modifier\n" |
| 8581 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8582 | "Display routes conforming to the prefix-list\n" |
| 8583 | "IP prefix-list name\n") |
| 8584 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8585 | safi_t safi; |
| 8586 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8587 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8588 | return CMD_WARNING; |
| 8589 | } |
| 8590 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8591 | bgp_show_type_prefix_list); |
| 8592 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8593 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8594 | DEFUN (show_bgp_ipv6_safi_prefix_list, |
| 8595 | show_bgp_ipv6_safi_prefix_list_cmd, |
| 8596 | "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8597 | SHOW_STR |
| 8598 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8599 | "Address family\n" |
| 8600 | "Address Family modifier\n" |
| 8601 | "Address Family modifier\n" |
| 8602 | "Address Family modifier\n" |
| 8603 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8604 | "Display routes conforming to the prefix-list\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8605 | "IP prefix-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8606 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8607 | safi_t safi; |
| 8608 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8609 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8610 | return CMD_WARNING; |
| 8611 | } |
| 8612 | return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8613 | bgp_show_type_prefix_list); |
| 8614 | } |
| 8615 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8616 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8617 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8618 | safi_t safi, enum bgp_show_type type) |
| 8619 | { |
| 8620 | struct as_list *as_list; |
| 8621 | |
| 8622 | as_list = as_list_lookup (filter); |
| 8623 | if (as_list == NULL) |
| 8624 | { |
| 8625 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 8626 | return CMD_WARNING; |
| 8627 | } |
| 8628 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8629 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8630 | } |
| 8631 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8632 | DEFUN (show_ip_bgp_filter_list, |
| 8633 | show_ip_bgp_filter_list_cmd, |
| 8634 | "show ip bgp filter-list WORD", |
| 8635 | SHOW_STR |
| 8636 | IP_STR |
| 8637 | BGP_STR |
| 8638 | "Display routes conforming to the filter-list\n" |
| 8639 | "Regular expression access list name\n") |
| 8640 | { |
| 8641 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8642 | bgp_show_type_filter_list); |
| 8643 | } |
| 8644 | |
| 8645 | DEFUN (show_ip_bgp_flap_filter_list, |
| 8646 | show_ip_bgp_flap_filter_list_cmd, |
| 8647 | "show ip bgp flap-statistics filter-list WORD", |
| 8648 | SHOW_STR |
| 8649 | IP_STR |
| 8650 | BGP_STR |
| 8651 | "Display flap statistics of routes\n" |
| 8652 | "Display routes conforming to the filter-list\n" |
| 8653 | "Regular expression access list name\n") |
| 8654 | { |
| 8655 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8656 | bgp_show_type_flap_filter_list); |
| 8657 | } |
| 8658 | |
| 8659 | ALIAS (show_ip_bgp_flap_filter_list, |
| 8660 | show_ip_bgp_damp_flap_filter_list_cmd, |
| 8661 | "show ip bgp dampening flap-statistics filter-list WORD", |
| 8662 | SHOW_STR |
| 8663 | IP_STR |
| 8664 | BGP_STR |
| 8665 | "Display detailed information about dampening\n" |
| 8666 | "Display flap statistics of routes\n" |
| 8667 | "Display routes conforming to the filter-list\n" |
| 8668 | "Regular expression access list name\n") |
| 8669 | |
| 8670 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 8671 | show_ip_bgp_ipv4_filter_list_cmd, |
| 8672 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 8673 | SHOW_STR |
| 8674 | IP_STR |
| 8675 | BGP_STR |
| 8676 | "Address family\n" |
| 8677 | "Address Family modifier\n" |
| 8678 | "Address Family modifier\n" |
| 8679 | "Display routes conforming to the filter-list\n" |
| 8680 | "Regular expression access list name\n") |
| 8681 | { |
| 8682 | if (strncmp (argv[0], "m", 1) == 0) |
| 8683 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8684 | bgp_show_type_filter_list); |
| 8685 | |
| 8686 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8687 | bgp_show_type_filter_list); |
| 8688 | } |
| 8689 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8690 | DEFUN (show_bgp_filter_list, |
| 8691 | show_bgp_filter_list_cmd, |
| 8692 | "show bgp filter-list WORD", |
| 8693 | SHOW_STR |
| 8694 | BGP_STR |
| 8695 | "Display routes conforming to the filter-list\n" |
| 8696 | "Regular expression access list name\n") |
| 8697 | { |
| 8698 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8699 | bgp_show_type_filter_list); |
| 8700 | } |
| 8701 | |
| 8702 | /* old command */ |
| 8703 | DEFUN (show_ipv6_bgp_filter_list, |
| 8704 | show_ipv6_bgp_filter_list_cmd, |
| 8705 | "show ipv6 bgp filter-list WORD", |
| 8706 | SHOW_STR |
| 8707 | IPV6_STR |
| 8708 | BGP_STR |
| 8709 | "Display routes conforming to the filter-list\n" |
| 8710 | "Regular expression access list name\n") |
| 8711 | { |
| 8712 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8713 | bgp_show_type_filter_list); |
| 8714 | } |
| 8715 | |
| 8716 | /* old command */ |
| 8717 | DEFUN (show_ipv6_mbgp_filter_list, |
| 8718 | show_ipv6_mbgp_filter_list_cmd, |
| 8719 | "show ipv6 mbgp filter-list WORD", |
| 8720 | SHOW_STR |
| 8721 | IPV6_STR |
| 8722 | MBGP_STR |
| 8723 | "Display routes conforming to the filter-list\n" |
| 8724 | "Regular expression access list name\n") |
| 8725 | { |
| 8726 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8727 | bgp_show_type_filter_list); |
| 8728 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8729 | |
| 8730 | DEFUN (show_ip_bgp_dampening_info, |
| 8731 | show_ip_bgp_dampening_params_cmd, |
| 8732 | "show ip bgp dampening parameters", |
| 8733 | SHOW_STR |
| 8734 | IP_STR |
| 8735 | BGP_STR |
| 8736 | "Display detailed information about dampening\n" |
| 8737 | "Display detail of configured dampening parameters\n") |
| 8738 | { |
| 8739 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); |
| 8740 | } |
| 8741 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8742 | DEFUN (show_bgp_ipv4_filter_list, |
| 8743 | show_bgp_ipv4_filter_list_cmd, |
| 8744 | "show bgp ipv4 filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8745 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8746 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8747 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8748 | "Display routes conforming to the filter-list\n" |
| 8749 | "Regular expression access list name\n") |
| 8750 | { |
| 8751 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8752 | bgp_show_type_filter_list); |
| 8753 | } |
| 8754 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8755 | DEFUN (show_bgp_ipv4_safi_flap_filter_list, |
| 8756 | show_bgp_ipv4_safi_flap_filter_list_cmd, |
| 8757 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8758 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8759 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8760 | IP_STR |
| 8761 | "Address Family modifier\n" |
| 8762 | "Address Family modifier\n" |
| 8763 | "Address Family modifier\n" |
| 8764 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8765 | "Display flap statistics of routes\n" |
| 8766 | "Display routes conforming to the filter-list\n" |
| 8767 | "Regular expression access list name\n") |
| 8768 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8769 | safi_t safi; |
| 8770 | |
| 8771 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8772 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8773 | return CMD_WARNING; |
| 8774 | } |
| 8775 | return bgp_show_filter_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8776 | bgp_show_type_flap_filter_list); |
| 8777 | } |
| 8778 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8779 | ALIAS (show_bgp_ipv4_safi_flap_filter_list, |
| 8780 | show_bgp_ipv4_safi_damp_flap_filter_list_cmd, |
| 8781 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8782 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8783 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8784 | IP_STR |
| 8785 | "Address Family modifier\n" |
| 8786 | "Address Family modifier\n" |
| 8787 | "Address Family modifier\n" |
| 8788 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8789 | "Display detailed information about dampening\n" |
| 8790 | "Display flap statistics of routes\n" |
| 8791 | "Display routes conforming to the filter-list\n" |
| 8792 | "Regular expression access list name\n") |
| 8793 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8794 | DEFUN (show_bgp_ipv6_safi_flap_filter_list, |
| 8795 | show_bgp_ipv6_safi_flap_filter_list_cmd, |
| 8796 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8797 | SHOW_STR |
| 8798 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8799 | IPV6_STR |
| 8800 | "Address Family modifier\n" |
| 8801 | "Address Family modifier\n" |
| 8802 | "Address Family modifier\n" |
| 8803 | "Address Family modifier\n" |
| 8804 | "Display flap statistics of routes\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8805 | "Display routes conforming to the filter-list\n" |
| 8806 | "Regular expression access list name\n") |
| 8807 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8808 | safi_t safi; |
| 8809 | |
| 8810 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8811 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8812 | return CMD_WARNING; |
| 8813 | } |
| 8814 | return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi, |
| 8815 | bgp_show_type_flap_filter_list); |
| 8816 | } |
| 8817 | ALIAS (show_bgp_ipv6_safi_flap_filter_list, |
| 8818 | show_bgp_ipv6_safi_damp_flap_filter_list_cmd, |
| 8819 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD", |
| 8820 | SHOW_STR |
| 8821 | BGP_STR |
| 8822 | IPV6_STR |
| 8823 | "Address Family modifier\n" |
| 8824 | "Address Family modifier\n" |
| 8825 | "Address Family modifier\n" |
| 8826 | "Address Family modifier\n" |
| 8827 | "Display detailed information about dampening\n" |
| 8828 | "Display flap statistics of routes\n" |
| 8829 | "Display routes conforming to the filter-list\n" |
| 8830 | "Regular expression access list name\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8831 | |
| 8832 | DEFUN (show_bgp_ipv4_safi_filter_list, |
| 8833 | show_bgp_ipv4_safi_filter_list_cmd, |
| 8834 | "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD", |
| 8835 | SHOW_STR |
| 8836 | BGP_STR |
| 8837 | "Address Family modifier\n" |
| 8838 | "Address Family modifier\n" |
| 8839 | "Address Family modifier\n" |
| 8840 | "Address Family modifier\n" |
| 8841 | "Display routes conforming to the filter-list\n" |
| 8842 | "Regular expression access list name\n") |
| 8843 | { |
| 8844 | safi_t safi; |
| 8845 | |
| 8846 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8847 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8848 | return CMD_WARNING; |
| 8849 | } |
| 8850 | return bgp_show_filter_list (vty, argv[1], AFI_IP, safi, |
| 8851 | bgp_show_type_filter_list); |
| 8852 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8853 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8854 | DEFUN (show_bgp_ipv6_safi_filter_list, |
| 8855 | show_bgp_ipv6_safi_filter_list_cmd, |
| 8856 | "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD", |
| 8857 | SHOW_STR |
| 8858 | BGP_STR |
| 8859 | "Address Family modifier\n" |
| 8860 | "Address Family modifier\n" |
| 8861 | "Address Family modifier\n" |
| 8862 | "Address Family modifier\n" |
| 8863 | "Display routes conforming to the filter-list\n" |
| 8864 | "Regular expression access list name\n") |
| 8865 | { |
| 8866 | safi_t safi; |
| 8867 | |
| 8868 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8869 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8870 | return CMD_WARNING; |
| 8871 | } |
| 8872 | return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi, |
| 8873 | bgp_show_type_filter_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8874 | } |
| 8875 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8876 | DEFUN (show_bgp_ipv6_filter_list, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8877 | show_bgp_ipv6_filter_list_cmd, |
| 8878 | "show bgp ipv6 filter-list WORD", |
| 8879 | SHOW_STR |
| 8880 | BGP_STR |
| 8881 | "Address family\n" |
| 8882 | "Display routes conforming to the filter-list\n" |
| 8883 | "Regular expression access list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8884 | { |
| 8885 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8886 | bgp_show_type_filter_list); |
| 8887 | } |
| 8888 | |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 8889 | |
| 8890 | DEFUN (show_ip_bgp_ipv4_dampening_parameters, |
| 8891 | show_ip_bgp_ipv4_dampening_parameters_cmd, |
| 8892 | "show ip bgp ipv4 (unicast|multicast) dampening parameters", |
| 8893 | SHOW_STR |
| 8894 | IP_STR |
| 8895 | BGP_STR |
| 8896 | "Address family\n" |
| 8897 | "Address Family modifier\n" |
| 8898 | "Address Family modifier\n" |
| 8899 | "Display detailed information about dampening\n" |
| 8900 | "Display detail of configured dampening parameters\n") |
| 8901 | { |
| 8902 | if (strncmp(argv[0], "m", 1) == 0) |
| 8903 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST); |
| 8904 | |
| 8905 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); |
| 8906 | } |
| 8907 | |
| 8908 | |
| 8909 | DEFUN (show_ip_bgp_ipv4_dampening_flap_stats, |
| 8910 | show_ip_bgp_ipv4_dampening_flap_stats_cmd, |
| 8911 | "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics", |
| 8912 | SHOW_STR |
| 8913 | IP_STR |
| 8914 | BGP_STR |
| 8915 | "Address family\n" |
| 8916 | "Address Family modifier\n" |
| 8917 | "Address Family modifier\n" |
| 8918 | "Display detailed information about dampening\n" |
| 8919 | "Display flap statistics of routes\n") |
| 8920 | { |
| 8921 | if (strncmp(argv[0], "m", 1) == 0) |
| 8922 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8923 | bgp_show_type_flap_statistics, NULL); |
| 8924 | |
| 8925 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8926 | bgp_show_type_flap_statistics, NULL); |
| 8927 | } |
| 8928 | |
| 8929 | DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths, |
| 8930 | show_ip_bgp_ipv4_dampening_dampd_paths_cmd, |
| 8931 | "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths", |
| 8932 | SHOW_STR |
| 8933 | IP_STR |
| 8934 | BGP_STR |
| 8935 | "Address family\n" |
| 8936 | "Address Family modifier\n" |
| 8937 | "Address Family modifier\n" |
| 8938 | "Display detailed information about dampening\n" |
| 8939 | "Display paths suppressed due to dampening\n") |
| 8940 | { |
| 8941 | if (strncmp(argv[0], "m", 1) == 0) |
| 8942 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8943 | bgp_show_type_dampend_paths, NULL); |
| 8944 | |
| 8945 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8946 | bgp_show_type_dampend_paths, NULL); |
| 8947 | } |
| 8948 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8949 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8950 | 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] | 8951 | safi_t safi, enum bgp_show_type type) |
| 8952 | { |
| 8953 | struct route_map *rmap; |
| 8954 | |
| 8955 | rmap = route_map_lookup_by_name (rmap_str); |
| 8956 | if (! rmap) |
| 8957 | { |
| 8958 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 8959 | rmap_str, VTY_NEWLINE); |
| 8960 | return CMD_WARNING; |
| 8961 | } |
| 8962 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8963 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8964 | } |
| 8965 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8966 | DEFUN (show_ip_bgp_route_map, |
| 8967 | show_ip_bgp_route_map_cmd, |
| 8968 | "show ip bgp route-map WORD", |
| 8969 | SHOW_STR |
| 8970 | IP_STR |
| 8971 | BGP_STR |
| 8972 | "Display routes matching the route-map\n" |
| 8973 | "A route-map to match on\n") |
| 8974 | { |
| 8975 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8976 | bgp_show_type_route_map); |
| 8977 | } |
| 8978 | |
| 8979 | DEFUN (show_ip_bgp_flap_route_map, |
| 8980 | show_ip_bgp_flap_route_map_cmd, |
| 8981 | "show ip bgp flap-statistics route-map WORD", |
| 8982 | SHOW_STR |
| 8983 | IP_STR |
| 8984 | BGP_STR |
| 8985 | "Display flap statistics of routes\n" |
| 8986 | "Display routes matching the route-map\n" |
| 8987 | "A route-map to match on\n") |
| 8988 | { |
| 8989 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8990 | bgp_show_type_flap_route_map); |
| 8991 | } |
| 8992 | |
| 8993 | ALIAS (show_ip_bgp_flap_route_map, |
| 8994 | show_ip_bgp_damp_flap_route_map_cmd, |
| 8995 | "show ip bgp dampening flap-statistics route-map WORD", |
| 8996 | SHOW_STR |
| 8997 | IP_STR |
| 8998 | BGP_STR |
| 8999 | "Display detailed information about dampening\n" |
| 9000 | "Display flap statistics of routes\n" |
| 9001 | "Display routes matching the route-map\n" |
| 9002 | "A route-map to match on\n") |
| 9003 | |
| 9004 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 9005 | show_ip_bgp_ipv4_route_map_cmd, |
| 9006 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 9007 | SHOW_STR |
| 9008 | IP_STR |
| 9009 | BGP_STR |
| 9010 | "Address family\n" |
| 9011 | "Address Family modifier\n" |
| 9012 | "Address Family modifier\n" |
| 9013 | "Display routes matching the route-map\n" |
| 9014 | "A route-map to match on\n") |
| 9015 | { |
| 9016 | if (strncmp (argv[0], "m", 1) == 0) |
| 9017 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 9018 | bgp_show_type_route_map); |
| 9019 | |
| 9020 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 9021 | bgp_show_type_route_map); |
| 9022 | } |
| 9023 | |
| 9024 | DEFUN (show_bgp_route_map, |
| 9025 | show_bgp_route_map_cmd, |
| 9026 | "show bgp route-map WORD", |
| 9027 | SHOW_STR |
| 9028 | BGP_STR |
| 9029 | "Display routes matching the route-map\n" |
| 9030 | "A route-map to match on\n") |
| 9031 | { |
| 9032 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9033 | bgp_show_type_route_map); |
| 9034 | } |
| 9035 | |
| 9036 | DEFUN (show_ip_bgp_cidr_only, |
| 9037 | show_ip_bgp_cidr_only_cmd, |
| 9038 | "show ip bgp cidr-only", |
| 9039 | SHOW_STR |
| 9040 | IP_STR |
| 9041 | BGP_STR |
| 9042 | "Display only routes with non-natural netmasks\n") |
| 9043 | { |
| 9044 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 9045 | bgp_show_type_cidr_only, NULL); |
| 9046 | } |
| 9047 | |
| 9048 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 9049 | show_ip_bgp_flap_cidr_only_cmd, |
| 9050 | "show ip bgp flap-statistics cidr-only", |
| 9051 | SHOW_STR |
| 9052 | IP_STR |
| 9053 | BGP_STR |
| 9054 | "Display flap statistics of routes\n" |
| 9055 | "Display only routes with non-natural netmasks\n") |
| 9056 | { |
| 9057 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 9058 | bgp_show_type_flap_cidr_only, NULL); |
| 9059 | } |
| 9060 | |
| 9061 | ALIAS (show_ip_bgp_flap_cidr_only, |
| 9062 | show_ip_bgp_damp_flap_cidr_only_cmd, |
| 9063 | "show ip bgp dampening flap-statistics cidr-only", |
| 9064 | SHOW_STR |
| 9065 | IP_STR |
| 9066 | BGP_STR |
| 9067 | "Display detailed information about dampening\n" |
| 9068 | "Display flap statistics of routes\n" |
| 9069 | "Display only routes with non-natural netmasks\n") |
| 9070 | |
| 9071 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 9072 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 9073 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 9074 | SHOW_STR |
| 9075 | IP_STR |
| 9076 | BGP_STR |
| 9077 | "Address family\n" |
| 9078 | "Address Family modifier\n" |
| 9079 | "Address Family modifier\n" |
| 9080 | "Display only routes with non-natural netmasks\n") |
| 9081 | { |
| 9082 | if (strncmp (argv[0], "m", 1) == 0) |
| 9083 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 9084 | bgp_show_type_cidr_only, NULL); |
| 9085 | |
| 9086 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 9087 | bgp_show_type_cidr_only, NULL); |
| 9088 | } |
| 9089 | |
| 9090 | DEFUN (show_ip_bgp_community_all, |
| 9091 | show_ip_bgp_community_all_cmd, |
| 9092 | "show ip bgp community", |
| 9093 | SHOW_STR |
| 9094 | IP_STR |
| 9095 | BGP_STR |
| 9096 | "Display routes matching the communities\n") |
| 9097 | { |
| 9098 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 9099 | bgp_show_type_community_all, NULL); |
| 9100 | } |
| 9101 | |
| 9102 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 9103 | show_ip_bgp_ipv4_community_all_cmd, |
| 9104 | "show ip bgp ipv4 (unicast|multicast) community", |
| 9105 | SHOW_STR |
| 9106 | IP_STR |
| 9107 | BGP_STR |
| 9108 | "Address family\n" |
| 9109 | "Address Family modifier\n" |
| 9110 | "Address Family modifier\n" |
| 9111 | "Display routes matching the communities\n") |
| 9112 | { |
| 9113 | if (strncmp (argv[0], "m", 1) == 0) |
| 9114 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 9115 | bgp_show_type_community_all, NULL); |
| 9116 | |
| 9117 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 9118 | bgp_show_type_community_all, NULL); |
| 9119 | } |
| 9120 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9121 | DEFUN (show_bgp_community_all, |
| 9122 | show_bgp_community_all_cmd, |
| 9123 | "show bgp community", |
| 9124 | SHOW_STR |
| 9125 | BGP_STR |
| 9126 | "Display routes matching the communities\n") |
| 9127 | { |
| 9128 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
| 9129 | bgp_show_type_community_all, NULL); |
| 9130 | } |
| 9131 | |
| 9132 | ALIAS (show_bgp_community_all, |
| 9133 | show_bgp_ipv6_community_all_cmd, |
| 9134 | "show bgp ipv6 community", |
| 9135 | SHOW_STR |
| 9136 | BGP_STR |
| 9137 | "Address family\n" |
| 9138 | "Display routes matching the communities\n") |
| 9139 | |
| 9140 | /* old command */ |
| 9141 | DEFUN (show_ipv6_bgp_community_all, |
| 9142 | show_ipv6_bgp_community_all_cmd, |
| 9143 | "show ipv6 bgp community", |
| 9144 | SHOW_STR |
| 9145 | IPV6_STR |
| 9146 | BGP_STR |
| 9147 | "Display routes matching the communities\n") |
| 9148 | { |
| 9149 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
| 9150 | bgp_show_type_community_all, NULL); |
| 9151 | } |
| 9152 | |
| 9153 | /* old command */ |
| 9154 | DEFUN (show_ipv6_mbgp_community_all, |
| 9155 | show_ipv6_mbgp_community_all_cmd, |
| 9156 | "show ipv6 mbgp community", |
| 9157 | SHOW_STR |
| 9158 | IPV6_STR |
| 9159 | MBGP_STR |
| 9160 | "Display routes matching the communities\n") |
| 9161 | { |
| 9162 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
| 9163 | bgp_show_type_community_all, NULL); |
| 9164 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9165 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9166 | DEFUN (show_bgp_ipv4_route_map, |
| 9167 | show_bgp_ipv4_route_map_cmd, |
| 9168 | "show bgp ipv4 route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9169 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9170 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9171 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9172 | "Display routes matching the route-map\n" |
| 9173 | "A route-map to match on\n") |
| 9174 | { |
| 9175 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9176 | bgp_show_type_route_map); |
| 9177 | } |
| 9178 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9179 | DEFUN (show_bgp_ipv4_safi_flap_route_map, |
| 9180 | show_bgp_ipv4_safi_flap_route_map_cmd, |
| 9181 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9182 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9183 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9184 | IP_STR |
| 9185 | "Address Family Modifier\n" |
| 9186 | "Address Family Modifier\n" |
| 9187 | "Address Family Modifier\n" |
| 9188 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9189 | "Display flap statistics of routes\n" |
| 9190 | "Display routes matching the route-map\n" |
| 9191 | "A route-map to match on\n") |
| 9192 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9193 | safi_t safi; |
| 9194 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9195 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9196 | return CMD_WARNING; |
| 9197 | } |
| 9198 | return bgp_show_route_map (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9199 | bgp_show_type_flap_route_map); |
| 9200 | } |
| 9201 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9202 | ALIAS (show_bgp_ipv4_safi_flap_route_map, |
| 9203 | show_bgp_ipv4_safi_damp_flap_route_map_cmd, |
| 9204 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9205 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9206 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9207 | IP_STR |
| 9208 | "Address Family Modifier\n" |
| 9209 | "Address Family Modifier\n" |
| 9210 | "Address Family Modifier\n" |
| 9211 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9212 | "Display detailed information about dampening\n" |
| 9213 | "Display flap statistics of routes\n" |
| 9214 | "Display routes matching the route-map\n" |
| 9215 | "A route-map to match on\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 9216 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9217 | DEFUN (show_bgp_ipv6_safi_flap_route_map, |
| 9218 | show_bgp_ipv6_safi_flap_route_map_cmd, |
| 9219 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9220 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9221 | BGP_STR |
| 9222 | IPV6_STR |
| 9223 | "Address Family Modifier\n" |
| 9224 | "Address Family Modifier\n" |
| 9225 | "Address Family Modifier\n" |
| 9226 | "Address Family Modifier\n" |
| 9227 | "Display flap statistics of routes\n" |
| 9228 | "Display routes matching the route-map\n" |
| 9229 | "A route-map to match on\n") |
| 9230 | { |
| 9231 | safi_t safi; |
| 9232 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9233 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9234 | return CMD_WARNING; |
| 9235 | } |
| 9236 | return bgp_show_route_map (vty, argv[1], AFI_IP6, safi, |
| 9237 | bgp_show_type_flap_route_map); |
| 9238 | } |
| 9239 | ALIAS (show_bgp_ipv6_safi_flap_route_map, |
| 9240 | show_bgp_ipv6_safi_damp_flap_route_map_cmd, |
| 9241 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD", |
| 9242 | SHOW_STR |
| 9243 | BGP_STR |
| 9244 | IPV6_STR |
| 9245 | "Address Family Modifier\n" |
| 9246 | "Address Family Modifier\n" |
| 9247 | "Address Family Modifier\n" |
| 9248 | "Address Family Modifier\n" |
| 9249 | "Display detailed information about dampening\n" |
| 9250 | "Display flap statistics of routes\n" |
| 9251 | "Display routes matching the route-map\n" |
| 9252 | "A route-map to match on\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9253 | |
| 9254 | DEFUN (show_bgp_ipv4_safi_route_map, |
| 9255 | show_bgp_ipv4_safi_route_map_cmd, |
| 9256 | "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD", |
| 9257 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9258 | BGP_STR |
| 9259 | "Address family\n" |
| 9260 | "Address Family modifier\n" |
| 9261 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9262 | "Address Family modifier\n" |
| 9263 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9264 | "Display routes matching the route-map\n" |
| 9265 | "A route-map to match on\n") |
| 9266 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9267 | safi_t safi; |
| 9268 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9269 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9270 | return CMD_WARNING; |
| 9271 | } |
| 9272 | return bgp_show_route_map (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9273 | bgp_show_type_route_map); |
| 9274 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 9275 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9276 | DEFUN (show_bgp_ipv6_safi_route_map, |
| 9277 | show_bgp_ipv6_safi_route_map_cmd, |
| 9278 | "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9279 | SHOW_STR |
| 9280 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9281 | "Address family\n" |
| 9282 | "Address Family modifier\n" |
| 9283 | "Address Family modifier\n" |
| 9284 | "Address Family modifier\n" |
| 9285 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9286 | "Display routes matching the route-map\n" |
| 9287 | "A route-map to match on\n") |
| 9288 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9289 | safi_t safi; |
| 9290 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9291 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9292 | return CMD_WARNING; |
| 9293 | } |
| 9294 | return bgp_show_route_map (vty, argv[1], AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9295 | bgp_show_type_route_map); |
| 9296 | } |
| 9297 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9298 | DEFUN (show_bgp_ipv6_route_map, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9299 | show_bgp_ipv6_route_map_cmd, |
| 9300 | "show bgp ipv6 route-map WORD", |
| 9301 | SHOW_STR |
| 9302 | BGP_STR |
| 9303 | "Address family\n" |
| 9304 | "Display routes matching the route-map\n" |
| 9305 | "A route-map to match on\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9306 | { |
| 9307 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9308 | bgp_show_type_route_map); |
| 9309 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9310 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9311 | DEFUN (show_bgp_ipv4_cidr_only, |
| 9312 | show_bgp_ipv4_cidr_only_cmd, |
| 9313 | "show bgp ipv4 cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9314 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9315 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9316 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9317 | "Display only routes with non-natural netmasks\n") |
| 9318 | { |
| 9319 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9320 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9321 | } |
| 9322 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9323 | DEFUN (show_bgp_ipv4_safi_flap_cidr_only, |
| 9324 | show_bgp_ipv4_safi_flap_cidr_only_cmd, |
| 9325 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9326 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9327 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9328 | "Address Family\n" |
| 9329 | "Address Family Modifier\n" |
| 9330 | "Address Family Modifier\n" |
| 9331 | "Address Family Modifier\n" |
| 9332 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9333 | "Display flap statistics of routes\n" |
| 9334 | "Display only routes with non-natural netmasks\n") |
| 9335 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9336 | safi_t safi; |
| 9337 | |
| 9338 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9339 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9340 | return CMD_WARNING; |
| 9341 | } |
| 9342 | 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] | 9343 | } |
| 9344 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9345 | ALIAS (show_bgp_ipv4_safi_flap_cidr_only, |
| 9346 | show_bgp_ipv4_safi_damp_flap_cidr_only_cmd, |
| 9347 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9348 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9349 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9350 | "Address Family\n" |
| 9351 | "Address Family Modifier\n" |
| 9352 | "Address Family Modifier\n" |
| 9353 | "Address Family Modifier\n" |
| 9354 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9355 | "Display detailed information about dampening\n" |
| 9356 | "Display flap statistics of routes\n" |
| 9357 | "Display only routes with non-natural netmasks\n") |
| 9358 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9359 | DEFUN (show_bgp_ipv4_safi_cidr_only, |
| 9360 | show_bgp_ipv4_safi_cidr_only_cmd, |
| 9361 | "show bgp ipv4 (unicast|multicast) cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9362 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9363 | BGP_STR |
| 9364 | "Address family\n" |
| 9365 | "Address Family modifier\n" |
| 9366 | "Address Family modifier\n" |
| 9367 | "Display only routes with non-natural netmasks\n") |
| 9368 | { |
| 9369 | if (strncmp (argv[0], "m", 1) == 0) |
| 9370 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9371 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9372 | |
| 9373 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9374 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9375 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9376 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9377 | /* new046 */ |
| 9378 | DEFUN (show_bgp_afi_safi_community_all, |
| 9379 | show_bgp_afi_safi_community_all_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9380 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9381 | SHOW_STR |
| 9382 | BGP_STR |
| 9383 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9384 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9385 | "Address Family modifier\n" |
| 9386 | "Address Family modifier\n" |
| 9387 | "Address Family modifier\n" |
| 9388 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9389 | "Display routes matching the communities\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9390 | { |
| 9391 | safi_t safi; |
| 9392 | afi_t afi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9393 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9394 | if (bgp_parse_afi(argv[0], &afi)) { |
| 9395 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 9396 | return CMD_WARNING; |
| 9397 | } |
| 9398 | if (bgp_parse_safi(argv[1], &safi)) { |
| 9399 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 9400 | return CMD_WARNING; |
| 9401 | } |
| 9402 | |
| 9403 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL); |
| 9404 | } |
| 9405 | DEFUN (show_bgp_afi_community_all, |
| 9406 | show_bgp_afi_community_all_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9407 | "show bgp (ipv4|ipv6) community", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9408 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9409 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9410 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9411 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9412 | "Display routes matching the communities\n") |
| 9413 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9414 | afi_t afi; |
| 9415 | safi_t safi = SAFI_UNICAST; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9416 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9417 | if (bgp_parse_afi(argv[0], &afi)) { |
| 9418 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 9419 | return CMD_WARNING; |
| 9420 | } |
| 9421 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9422 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9423 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9424 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9425 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 9426 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9427 | { |
| 9428 | struct community *com; |
| 9429 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9430 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9431 | int i; |
| 9432 | char *str; |
| 9433 | int first = 0; |
| 9434 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9435 | /* BGP structure lookup */ |
| 9436 | if (view_name) |
| 9437 | { |
| 9438 | bgp = bgp_lookup_by_name (view_name); |
| 9439 | if (bgp == NULL) |
| 9440 | { |
| 9441 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9442 | return CMD_WARNING; |
| 9443 | } |
| 9444 | } |
| 9445 | else |
| 9446 | { |
| 9447 | bgp = bgp_get_default (); |
| 9448 | if (bgp == NULL) |
| 9449 | { |
| 9450 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9451 | return CMD_WARNING; |
| 9452 | } |
| 9453 | } |
| 9454 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9455 | b = buffer_new (1024); |
| 9456 | for (i = 0; i < argc; i++) |
| 9457 | { |
| 9458 | if (first) |
| 9459 | buffer_putc (b, ' '); |
| 9460 | else |
| 9461 | { |
| 9462 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 9463 | continue; |
| 9464 | first = 1; |
| 9465 | } |
| 9466 | |
| 9467 | buffer_putstr (b, argv[i]); |
| 9468 | } |
| 9469 | buffer_putc (b, '\0'); |
| 9470 | |
| 9471 | str = buffer_getstr (b); |
| 9472 | buffer_free (b); |
| 9473 | |
| 9474 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 9475 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9476 | if (! com) |
| 9477 | { |
| 9478 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 9479 | return CMD_WARNING; |
| 9480 | } |
| 9481 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9482 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9483 | (exact ? bgp_show_type_community_exact : |
| 9484 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9485 | } |
| 9486 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9487 | DEFUN (show_ip_bgp_community, |
| 9488 | show_ip_bgp_community_cmd, |
| 9489 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9490 | SHOW_STR |
| 9491 | IP_STR |
| 9492 | BGP_STR |
| 9493 | "Display routes matching the communities\n" |
| 9494 | "community number\n" |
| 9495 | "Do not send outside local AS (well-known community)\n" |
| 9496 | "Do not advertise to any peer (well-known community)\n" |
| 9497 | "Do not export to next AS (well-known community)\n") |
| 9498 | { |
| 9499 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 9500 | } |
| 9501 | |
| 9502 | ALIAS (show_ip_bgp_community, |
| 9503 | show_ip_bgp_community2_cmd, |
| 9504 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9505 | SHOW_STR |
| 9506 | IP_STR |
| 9507 | BGP_STR |
| 9508 | "Display routes matching the communities\n" |
| 9509 | "community number\n" |
| 9510 | "Do not send outside local AS (well-known community)\n" |
| 9511 | "Do not advertise to any peer (well-known community)\n" |
| 9512 | "Do not export to next AS (well-known community)\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 | |
| 9518 | ALIAS (show_ip_bgp_community, |
| 9519 | show_ip_bgp_community3_cmd, |
| 9520 | "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)", |
| 9521 | SHOW_STR |
| 9522 | IP_STR |
| 9523 | BGP_STR |
| 9524 | "Display routes matching the communities\n" |
| 9525 | "community number\n" |
| 9526 | "Do not send outside local AS (well-known community)\n" |
| 9527 | "Do not advertise to any peer (well-known community)\n" |
| 9528 | "Do not export to next AS (well-known community)\n" |
| 9529 | "community number\n" |
| 9530 | "Do not send outside local AS (well-known community)\n" |
| 9531 | "Do not advertise to any peer (well-known community)\n" |
| 9532 | "Do not export to next AS (well-known community)\n" |
| 9533 | "community number\n" |
| 9534 | "Do not send outside local AS (well-known community)\n" |
| 9535 | "Do not advertise to any peer (well-known community)\n" |
| 9536 | "Do not export to next AS (well-known community)\n") |
| 9537 | |
| 9538 | ALIAS (show_ip_bgp_community, |
| 9539 | show_ip_bgp_community4_cmd, |
| 9540 | "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)", |
| 9541 | SHOW_STR |
| 9542 | IP_STR |
| 9543 | BGP_STR |
| 9544 | "Display routes matching the communities\n" |
| 9545 | "community number\n" |
| 9546 | "Do not send outside local AS (well-known community)\n" |
| 9547 | "Do not advertise to any peer (well-known community)\n" |
| 9548 | "Do not export to next AS (well-known community)\n" |
| 9549 | "community number\n" |
| 9550 | "Do not send outside local AS (well-known community)\n" |
| 9551 | "Do not advertise to any peer (well-known community)\n" |
| 9552 | "Do not export to next AS (well-known community)\n" |
| 9553 | "community number\n" |
| 9554 | "Do not send outside local AS (well-known community)\n" |
| 9555 | "Do not advertise to any peer (well-known community)\n" |
| 9556 | "Do not export to next AS (well-known community)\n" |
| 9557 | "community number\n" |
| 9558 | "Do not send outside local AS (well-known community)\n" |
| 9559 | "Do not advertise to any peer (well-known community)\n" |
| 9560 | "Do not export to next AS (well-known community)\n") |
| 9561 | |
| 9562 | DEFUN (show_ip_bgp_ipv4_community, |
| 9563 | show_ip_bgp_ipv4_community_cmd, |
| 9564 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 9565 | SHOW_STR |
| 9566 | IP_STR |
| 9567 | BGP_STR |
| 9568 | "Address family\n" |
| 9569 | "Address Family modifier\n" |
| 9570 | "Address Family modifier\n" |
| 9571 | "Display routes matching the communities\n" |
| 9572 | "community number\n" |
| 9573 | "Do not send outside local AS (well-known community)\n" |
| 9574 | "Do not advertise to any peer (well-known community)\n" |
| 9575 | "Do not export to next AS (well-known community)\n") |
| 9576 | { |
| 9577 | if (strncmp (argv[0], "m", 1) == 0) |
| 9578 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 9579 | |
| 9580 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 9581 | } |
| 9582 | |
| 9583 | ALIAS (show_ip_bgp_ipv4_community, |
| 9584 | show_ip_bgp_ipv4_community2_cmd, |
| 9585 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9586 | SHOW_STR |
| 9587 | IP_STR |
| 9588 | BGP_STR |
| 9589 | "Address family\n" |
| 9590 | "Address Family modifier\n" |
| 9591 | "Address Family modifier\n" |
| 9592 | "Display routes matching the communities\n" |
| 9593 | "community number\n" |
| 9594 | "Do not send outside local AS (well-known community)\n" |
| 9595 | "Do not advertise to any peer (well-known community)\n" |
| 9596 | "Do not export to next AS (well-known community)\n" |
| 9597 | "community number\n" |
| 9598 | "Do not send outside local AS (well-known community)\n" |
| 9599 | "Do not advertise to any peer (well-known community)\n" |
| 9600 | "Do not export to next AS (well-known community)\n") |
| 9601 | |
| 9602 | ALIAS (show_ip_bgp_ipv4_community, |
| 9603 | show_ip_bgp_ipv4_community3_cmd, |
| 9604 | "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)", |
| 9605 | SHOW_STR |
| 9606 | IP_STR |
| 9607 | BGP_STR |
| 9608 | "Address family\n" |
| 9609 | "Address Family modifier\n" |
| 9610 | "Address Family modifier\n" |
| 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 | |
| 9625 | ALIAS (show_ip_bgp_ipv4_community, |
| 9626 | show_ip_bgp_ipv4_community4_cmd, |
| 9627 | "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)", |
| 9628 | SHOW_STR |
| 9629 | IP_STR |
| 9630 | BGP_STR |
| 9631 | "Address family\n" |
| 9632 | "Address Family modifier\n" |
| 9633 | "Address Family modifier\n" |
| 9634 | "Display routes matching the communities\n" |
| 9635 | "community number\n" |
| 9636 | "Do not send outside local AS (well-known community)\n" |
| 9637 | "Do not advertise to any peer (well-known community)\n" |
| 9638 | "Do not export to next AS (well-known community)\n" |
| 9639 | "community number\n" |
| 9640 | "Do not send outside local AS (well-known community)\n" |
| 9641 | "Do not advertise to any peer (well-known community)\n" |
| 9642 | "Do not export to next AS (well-known community)\n" |
| 9643 | "community number\n" |
| 9644 | "Do not send outside local AS (well-known community)\n" |
| 9645 | "Do not advertise to any peer (well-known community)\n" |
| 9646 | "Do not export to next AS (well-known community)\n" |
| 9647 | "community number\n" |
| 9648 | "Do not send outside local AS (well-known community)\n" |
| 9649 | "Do not advertise to any peer (well-known community)\n" |
| 9650 | "Do not export to next AS (well-known community)\n") |
| 9651 | |
| 9652 | DEFUN (show_ip_bgp_community_exact, |
| 9653 | show_ip_bgp_community_exact_cmd, |
| 9654 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9655 | SHOW_STR |
| 9656 | IP_STR |
| 9657 | BGP_STR |
| 9658 | "Display routes matching the communities\n" |
| 9659 | "community number\n" |
| 9660 | "Do not send outside local AS (well-known community)\n" |
| 9661 | "Do not advertise to any peer (well-known community)\n" |
| 9662 | "Do not export to next AS (well-known community)\n" |
| 9663 | "Exact match of the communities") |
| 9664 | { |
| 9665 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 9666 | } |
| 9667 | |
| 9668 | ALIAS (show_ip_bgp_community_exact, |
| 9669 | show_ip_bgp_community2_exact_cmd, |
| 9670 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9671 | SHOW_STR |
| 9672 | IP_STR |
| 9673 | BGP_STR |
| 9674 | "Display routes matching the communities\n" |
| 9675 | "community number\n" |
| 9676 | "Do not send outside local AS (well-known community)\n" |
| 9677 | "Do not advertise to any peer (well-known community)\n" |
| 9678 | "Do not export to next AS (well-known community)\n" |
| 9679 | "community number\n" |
| 9680 | "Do not send outside local AS (well-known community)\n" |
| 9681 | "Do not advertise to any peer (well-known community)\n" |
| 9682 | "Do not export to next AS (well-known community)\n" |
| 9683 | "Exact match of the communities") |
| 9684 | |
| 9685 | ALIAS (show_ip_bgp_community_exact, |
| 9686 | show_ip_bgp_community3_exact_cmd, |
| 9687 | "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", |
| 9688 | SHOW_STR |
| 9689 | IP_STR |
| 9690 | BGP_STR |
| 9691 | "Display routes matching the communities\n" |
| 9692 | "community number\n" |
| 9693 | "Do not send outside local AS (well-known community)\n" |
| 9694 | "Do not advertise to any peer (well-known community)\n" |
| 9695 | "Do not export to next AS (well-known community)\n" |
| 9696 | "community number\n" |
| 9697 | "Do not send outside local AS (well-known community)\n" |
| 9698 | "Do not advertise to any peer (well-known community)\n" |
| 9699 | "Do not export to next AS (well-known community)\n" |
| 9700 | "community number\n" |
| 9701 | "Do not send outside local AS (well-known community)\n" |
| 9702 | "Do not advertise to any peer (well-known community)\n" |
| 9703 | "Do not export to next AS (well-known community)\n" |
| 9704 | "Exact match of the communities") |
| 9705 | |
| 9706 | ALIAS (show_ip_bgp_community_exact, |
| 9707 | show_ip_bgp_community4_exact_cmd, |
| 9708 | "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", |
| 9709 | SHOW_STR |
| 9710 | IP_STR |
| 9711 | BGP_STR |
| 9712 | "Display routes matching the communities\n" |
| 9713 | "community number\n" |
| 9714 | "Do not send outside local AS (well-known community)\n" |
| 9715 | "Do not advertise to any peer (well-known community)\n" |
| 9716 | "Do not export to next AS (well-known community)\n" |
| 9717 | "community number\n" |
| 9718 | "Do not send outside local AS (well-known community)\n" |
| 9719 | "Do not advertise to any peer (well-known community)\n" |
| 9720 | "Do not export to next AS (well-known community)\n" |
| 9721 | "community number\n" |
| 9722 | "Do not send outside local AS (well-known community)\n" |
| 9723 | "Do not advertise to any peer (well-known community)\n" |
| 9724 | "Do not export to next AS (well-known community)\n" |
| 9725 | "community number\n" |
| 9726 | "Do not send outside local AS (well-known community)\n" |
| 9727 | "Do not advertise to any peer (well-known community)\n" |
| 9728 | "Do not export to next AS (well-known community)\n" |
| 9729 | "Exact match of the communities") |
| 9730 | |
| 9731 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 9732 | show_ip_bgp_ipv4_community_exact_cmd, |
| 9733 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9734 | SHOW_STR |
| 9735 | IP_STR |
| 9736 | BGP_STR |
| 9737 | "Address family\n" |
| 9738 | "Address Family modifier\n" |
| 9739 | "Address Family modifier\n" |
| 9740 | "Display routes matching the communities\n" |
| 9741 | "community number\n" |
| 9742 | "Do not send outside local AS (well-known community)\n" |
| 9743 | "Do not advertise to any peer (well-known community)\n" |
| 9744 | "Do not export to next AS (well-known community)\n" |
| 9745 | "Exact match of the communities") |
| 9746 | { |
| 9747 | if (strncmp (argv[0], "m", 1) == 0) |
| 9748 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 9749 | |
| 9750 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 9751 | } |
| 9752 | |
| 9753 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9754 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 9755 | "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", |
| 9756 | SHOW_STR |
| 9757 | IP_STR |
| 9758 | BGP_STR |
| 9759 | "Address family\n" |
| 9760 | "Address Family modifier\n" |
| 9761 | "Address Family modifier\n" |
| 9762 | "Display routes matching the communities\n" |
| 9763 | "community number\n" |
| 9764 | "Do not send outside local AS (well-known community)\n" |
| 9765 | "Do not advertise to any peer (well-known community)\n" |
| 9766 | "Do not export to next AS (well-known community)\n" |
| 9767 | "community number\n" |
| 9768 | "Do not send outside local AS (well-known community)\n" |
| 9769 | "Do not advertise to any peer (well-known community)\n" |
| 9770 | "Do not export to next AS (well-known community)\n" |
| 9771 | "Exact match of the communities") |
| 9772 | |
| 9773 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9774 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 9775 | "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", |
| 9776 | SHOW_STR |
| 9777 | IP_STR |
| 9778 | BGP_STR |
| 9779 | "Address family\n" |
| 9780 | "Address Family modifier\n" |
| 9781 | "Address Family modifier\n" |
| 9782 | "Display routes matching the communities\n" |
| 9783 | "community number\n" |
| 9784 | "Do not send outside local AS (well-known community)\n" |
| 9785 | "Do not advertise to any peer (well-known community)\n" |
| 9786 | "Do not export to next AS (well-known community)\n" |
| 9787 | "community number\n" |
| 9788 | "Do not send outside local AS (well-known community)\n" |
| 9789 | "Do not advertise to any peer (well-known community)\n" |
| 9790 | "Do not export to next AS (well-known community)\n" |
| 9791 | "community number\n" |
| 9792 | "Do not send outside local AS (well-known community)\n" |
| 9793 | "Do not advertise to any peer (well-known community)\n" |
| 9794 | "Do not export to next AS (well-known community)\n" |
| 9795 | "Exact match of the communities") |
| 9796 | |
| 9797 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9798 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 9799 | "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", |
| 9800 | SHOW_STR |
| 9801 | IP_STR |
| 9802 | BGP_STR |
| 9803 | "Address family\n" |
| 9804 | "Address Family modifier\n" |
| 9805 | "Address Family modifier\n" |
| 9806 | "Display routes matching the communities\n" |
| 9807 | "community number\n" |
| 9808 | "Do not send outside local AS (well-known community)\n" |
| 9809 | "Do not advertise to any peer (well-known community)\n" |
| 9810 | "Do not export to next AS (well-known community)\n" |
| 9811 | "community number\n" |
| 9812 | "Do not send outside local AS (well-known community)\n" |
| 9813 | "Do not advertise to any peer (well-known community)\n" |
| 9814 | "Do not export to next AS (well-known community)\n" |
| 9815 | "community number\n" |
| 9816 | "Do not send outside local AS (well-known community)\n" |
| 9817 | "Do not advertise to any peer (well-known community)\n" |
| 9818 | "Do not export to next AS (well-known community)\n" |
| 9819 | "community number\n" |
| 9820 | "Do not send outside local AS (well-known community)\n" |
| 9821 | "Do not advertise to any peer (well-known community)\n" |
| 9822 | "Do not export to next AS (well-known community)\n" |
| 9823 | "Exact match of the communities") |
| 9824 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9825 | DEFUN (show_bgp_community, |
| 9826 | show_bgp_community_cmd, |
| 9827 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9828 | SHOW_STR |
| 9829 | BGP_STR |
| 9830 | "Display routes matching the communities\n" |
| 9831 | "community number\n" |
| 9832 | "Do not send outside local AS (well-known community)\n" |
| 9833 | "Do not advertise to any peer (well-known community)\n" |
| 9834 | "Do not export to next AS (well-known community)\n") |
| 9835 | { |
| 9836 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 9837 | } |
| 9838 | |
| 9839 | ALIAS (show_bgp_community, |
| 9840 | show_bgp_ipv6_community_cmd, |
| 9841 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 9842 | SHOW_STR |
| 9843 | BGP_STR |
| 9844 | "Address family\n" |
| 9845 | "Display routes matching the communities\n" |
| 9846 | "community number\n" |
| 9847 | "Do not send outside local AS (well-known community)\n" |
| 9848 | "Do not advertise to any peer (well-known community)\n" |
| 9849 | "Do not export to next AS (well-known community)\n") |
| 9850 | |
| 9851 | ALIAS (show_bgp_community, |
| 9852 | show_bgp_community2_cmd, |
| 9853 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9854 | SHOW_STR |
| 9855 | BGP_STR |
| 9856 | "Display routes matching the communities\n" |
| 9857 | "community number\n" |
| 9858 | "Do not send outside local AS (well-known community)\n" |
| 9859 | "Do not advertise to any peer (well-known community)\n" |
| 9860 | "Do not export to next AS (well-known community)\n" |
| 9861 | "community number\n" |
| 9862 | "Do not send outside local AS (well-known community)\n" |
| 9863 | "Do not advertise to any peer (well-known community)\n" |
| 9864 | "Do not export to next AS (well-known community)\n") |
| 9865 | |
| 9866 | ALIAS (show_bgp_community, |
| 9867 | show_bgp_ipv6_community2_cmd, |
| 9868 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9869 | SHOW_STR |
| 9870 | BGP_STR |
| 9871 | "Address family\n" |
| 9872 | "Display routes matching the communities\n" |
| 9873 | "community number\n" |
| 9874 | "Do not send outside local AS (well-known community)\n" |
| 9875 | "Do not advertise to any peer (well-known community)\n" |
| 9876 | "Do not export to next AS (well-known community)\n" |
| 9877 | "community number\n" |
| 9878 | "Do not send outside local AS (well-known community)\n" |
| 9879 | "Do not advertise to any peer (well-known community)\n" |
| 9880 | "Do not export to next AS (well-known community)\n") |
| 9881 | |
| 9882 | ALIAS (show_bgp_community, |
| 9883 | show_bgp_community3_cmd, |
| 9884 | "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)", |
| 9885 | SHOW_STR |
| 9886 | BGP_STR |
| 9887 | "Display routes matching the communities\n" |
| 9888 | "community number\n" |
| 9889 | "Do not send outside local AS (well-known community)\n" |
| 9890 | "Do not advertise to any peer (well-known community)\n" |
| 9891 | "Do not export to next AS (well-known community)\n" |
| 9892 | "community number\n" |
| 9893 | "Do not send outside local AS (well-known community)\n" |
| 9894 | "Do not advertise to any peer (well-known community)\n" |
| 9895 | "Do not export to next AS (well-known community)\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 | ALIAS (show_bgp_community, |
| 9902 | show_bgp_ipv6_community3_cmd, |
| 9903 | "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)", |
| 9904 | SHOW_STR |
| 9905 | BGP_STR |
| 9906 | "Address family\n" |
| 9907 | "Display routes matching the communities\n" |
| 9908 | "community number\n" |
| 9909 | "Do not send outside local AS (well-known community)\n" |
| 9910 | "Do not advertise to any peer (well-known community)\n" |
| 9911 | "Do not export to next AS (well-known community)\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 | ALIAS (show_bgp_community, |
| 9922 | show_bgp_community4_cmd, |
| 9923 | "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)", |
| 9924 | SHOW_STR |
| 9925 | BGP_STR |
| 9926 | "Display routes matching the communities\n" |
| 9927 | "community number\n" |
| 9928 | "Do not send outside local AS (well-known community)\n" |
| 9929 | "Do not advertise to any peer (well-known community)\n" |
| 9930 | "Do not export to next AS (well-known community)\n" |
| 9931 | "community number\n" |
| 9932 | "Do not send outside local AS (well-known community)\n" |
| 9933 | "Do not advertise to any peer (well-known community)\n" |
| 9934 | "Do not export to next AS (well-known community)\n" |
| 9935 | "community number\n" |
| 9936 | "Do not send outside local AS (well-known community)\n" |
| 9937 | "Do not advertise to any peer (well-known community)\n" |
| 9938 | "Do not export to next AS (well-known community)\n" |
| 9939 | "community number\n" |
| 9940 | "Do not send outside local AS (well-known community)\n" |
| 9941 | "Do not advertise to any peer (well-known community)\n" |
| 9942 | "Do not export to next AS (well-known community)\n") |
| 9943 | |
| 9944 | ALIAS (show_bgp_community, |
| 9945 | show_bgp_ipv6_community4_cmd, |
| 9946 | "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)", |
| 9947 | SHOW_STR |
| 9948 | BGP_STR |
| 9949 | "Address family\n" |
| 9950 | "Display routes matching the communities\n" |
| 9951 | "community number\n" |
| 9952 | "Do not send outside local AS (well-known community)\n" |
| 9953 | "Do not advertise to any peer (well-known community)\n" |
| 9954 | "Do not export to next AS (well-known community)\n" |
| 9955 | "community number\n" |
| 9956 | "Do not send outside local AS (well-known community)\n" |
| 9957 | "Do not advertise to any peer (well-known community)\n" |
| 9958 | "Do not export to next AS (well-known community)\n" |
| 9959 | "community number\n" |
| 9960 | "Do not send outside local AS (well-known community)\n" |
| 9961 | "Do not advertise to any peer (well-known community)\n" |
| 9962 | "Do not export to next AS (well-known community)\n" |
| 9963 | "community number\n" |
| 9964 | "Do not send outside local AS (well-known community)\n" |
| 9965 | "Do not advertise to any peer (well-known community)\n" |
| 9966 | "Do not export to next AS (well-known community)\n") |
| 9967 | |
| 9968 | /* old command */ |
| 9969 | DEFUN (show_ipv6_bgp_community, |
| 9970 | show_ipv6_bgp_community_cmd, |
| 9971 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9972 | SHOW_STR |
| 9973 | IPV6_STR |
| 9974 | BGP_STR |
| 9975 | "Display routes matching the communities\n" |
| 9976 | "community number\n" |
| 9977 | "Do not send outside local AS (well-known community)\n" |
| 9978 | "Do not advertise to any peer (well-known community)\n" |
| 9979 | "Do not export to next AS (well-known community)\n") |
| 9980 | { |
| 9981 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 9982 | } |
| 9983 | |
| 9984 | /* old command */ |
| 9985 | ALIAS (show_ipv6_bgp_community, |
| 9986 | show_ipv6_bgp_community2_cmd, |
| 9987 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9988 | SHOW_STR |
| 9989 | IPV6_STR |
| 9990 | BGP_STR |
| 9991 | "Display routes matching the communities\n" |
| 9992 | "community number\n" |
| 9993 | "Do not send outside local AS (well-known community)\n" |
| 9994 | "Do not advertise to any peer (well-known community)\n" |
| 9995 | "Do not export to next AS (well-known community)\n" |
| 9996 | "community number\n" |
| 9997 | "Do not send outside local AS (well-known community)\n" |
| 9998 | "Do not advertise to any peer (well-known community)\n" |
| 9999 | "Do not export to next AS (well-known community)\n") |
| 10000 | |
| 10001 | /* old command */ |
| 10002 | ALIAS (show_ipv6_bgp_community, |
| 10003 | show_ipv6_bgp_community3_cmd, |
| 10004 | "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)", |
| 10005 | SHOW_STR |
| 10006 | IPV6_STR |
| 10007 | BGP_STR |
| 10008 | "Display routes matching the communities\n" |
| 10009 | "community number\n" |
| 10010 | "Do not send outside local AS (well-known community)\n" |
| 10011 | "Do not advertise to any peer (well-known community)\n" |
| 10012 | "Do not export to next AS (well-known community)\n" |
| 10013 | "community number\n" |
| 10014 | "Do not send outside local AS (well-known community)\n" |
| 10015 | "Do not advertise to any peer (well-known community)\n" |
| 10016 | "Do not export to next AS (well-known community)\n" |
| 10017 | "community number\n" |
| 10018 | "Do not send outside local AS (well-known community)\n" |
| 10019 | "Do not advertise to any peer (well-known community)\n" |
| 10020 | "Do not export to next AS (well-known community)\n") |
| 10021 | |
| 10022 | /* old command */ |
| 10023 | ALIAS (show_ipv6_bgp_community, |
| 10024 | show_ipv6_bgp_community4_cmd, |
| 10025 | "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)", |
| 10026 | SHOW_STR |
| 10027 | IPV6_STR |
| 10028 | BGP_STR |
| 10029 | "Display routes matching the communities\n" |
| 10030 | "community number\n" |
| 10031 | "Do not send outside local AS (well-known community)\n" |
| 10032 | "Do not advertise to any peer (well-known community)\n" |
| 10033 | "Do not export to next AS (well-known community)\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 | |
| 10047 | DEFUN (show_bgp_community_exact, |
| 10048 | show_bgp_community_exact_cmd, |
| 10049 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10050 | SHOW_STR |
| 10051 | BGP_STR |
| 10052 | "Display routes matching the communities\n" |
| 10053 | "community number\n" |
| 10054 | "Do not send outside local AS (well-known community)\n" |
| 10055 | "Do not advertise to any peer (well-known community)\n" |
| 10056 | "Do not export to next AS (well-known community)\n" |
| 10057 | "Exact match of the communities") |
| 10058 | { |
| 10059 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 10060 | } |
| 10061 | |
| 10062 | ALIAS (show_bgp_community_exact, |
| 10063 | show_bgp_ipv6_community_exact_cmd, |
| 10064 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10065 | SHOW_STR |
| 10066 | BGP_STR |
| 10067 | "Address family\n" |
| 10068 | "Display routes matching the communities\n" |
| 10069 | "community number\n" |
| 10070 | "Do not send outside local AS (well-known community)\n" |
| 10071 | "Do not advertise to any peer (well-known community)\n" |
| 10072 | "Do not export to next AS (well-known community)\n" |
| 10073 | "Exact match of the communities") |
| 10074 | |
| 10075 | ALIAS (show_bgp_community_exact, |
| 10076 | show_bgp_community2_exact_cmd, |
| 10077 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10078 | SHOW_STR |
| 10079 | BGP_STR |
| 10080 | "Display routes matching the communities\n" |
| 10081 | "community number\n" |
| 10082 | "Do not send outside local AS (well-known community)\n" |
| 10083 | "Do not advertise to any peer (well-known community)\n" |
| 10084 | "Do not export to next AS (well-known community)\n" |
| 10085 | "community number\n" |
| 10086 | "Do not send outside local AS (well-known community)\n" |
| 10087 | "Do not advertise to any peer (well-known community)\n" |
| 10088 | "Do not export to next AS (well-known community)\n" |
| 10089 | "Exact match of the communities") |
| 10090 | |
| 10091 | ALIAS (show_bgp_community_exact, |
| 10092 | show_bgp_ipv6_community2_exact_cmd, |
| 10093 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10094 | SHOW_STR |
| 10095 | BGP_STR |
| 10096 | "Address family\n" |
| 10097 | "Display routes matching the communities\n" |
| 10098 | "community number\n" |
| 10099 | "Do not send outside local AS (well-known community)\n" |
| 10100 | "Do not advertise to any peer (well-known community)\n" |
| 10101 | "Do not export to next AS (well-known community)\n" |
| 10102 | "community number\n" |
| 10103 | "Do not send outside local AS (well-known community)\n" |
| 10104 | "Do not advertise to any peer (well-known community)\n" |
| 10105 | "Do not export to next AS (well-known community)\n" |
| 10106 | "Exact match of the communities") |
| 10107 | |
| 10108 | ALIAS (show_bgp_community_exact, |
| 10109 | show_bgp_community3_exact_cmd, |
| 10110 | "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", |
| 10111 | SHOW_STR |
| 10112 | BGP_STR |
| 10113 | "Display routes matching the communities\n" |
| 10114 | "community number\n" |
| 10115 | "Do not send outside local AS (well-known community)\n" |
| 10116 | "Do not advertise to any peer (well-known community)\n" |
| 10117 | "Do not export to next AS (well-known community)\n" |
| 10118 | "community number\n" |
| 10119 | "Do not send outside local AS (well-known community)\n" |
| 10120 | "Do not advertise to any peer (well-known community)\n" |
| 10121 | "Do not export to next AS (well-known community)\n" |
| 10122 | "community number\n" |
| 10123 | "Do not send outside local AS (well-known community)\n" |
| 10124 | "Do not advertise to any peer (well-known community)\n" |
| 10125 | "Do not export to next AS (well-known community)\n" |
| 10126 | "Exact match of the communities") |
| 10127 | |
| 10128 | ALIAS (show_bgp_community_exact, |
| 10129 | show_bgp_ipv6_community3_exact_cmd, |
| 10130 | "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", |
| 10131 | SHOW_STR |
| 10132 | BGP_STR |
| 10133 | "Address family\n" |
| 10134 | "Display routes matching the communities\n" |
| 10135 | "community number\n" |
| 10136 | "Do not send outside local AS (well-known community)\n" |
| 10137 | "Do not advertise to any peer (well-known community)\n" |
| 10138 | "Do not export to next AS (well-known community)\n" |
| 10139 | "community number\n" |
| 10140 | "Do not send outside local AS (well-known community)\n" |
| 10141 | "Do not advertise to any peer (well-known community)\n" |
| 10142 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") |
| 10148 | |
| 10149 | ALIAS (show_bgp_community_exact, |
| 10150 | show_bgp_community4_exact_cmd, |
| 10151 | "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", |
| 10152 | SHOW_STR |
| 10153 | BGP_STR |
| 10154 | "Display routes matching the communities\n" |
| 10155 | "community number\n" |
| 10156 | "Do not send outside local AS (well-known community)\n" |
| 10157 | "Do not advertise to any peer (well-known community)\n" |
| 10158 | "Do not export to next AS (well-known community)\n" |
| 10159 | "community number\n" |
| 10160 | "Do not send outside local AS (well-known community)\n" |
| 10161 | "Do not advertise to any peer (well-known community)\n" |
| 10162 | "Do not export to next AS (well-known community)\n" |
| 10163 | "community number\n" |
| 10164 | "Do not send outside local AS (well-known community)\n" |
| 10165 | "Do not advertise to any peer (well-known community)\n" |
| 10166 | "Do not export to next AS (well-known community)\n" |
| 10167 | "community number\n" |
| 10168 | "Do not send outside local AS (well-known community)\n" |
| 10169 | "Do not advertise to any peer (well-known community)\n" |
| 10170 | "Do not export to next AS (well-known community)\n" |
| 10171 | "Exact match of the communities") |
| 10172 | |
| 10173 | ALIAS (show_bgp_community_exact, |
| 10174 | show_bgp_ipv6_community4_exact_cmd, |
| 10175 | "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", |
| 10176 | SHOW_STR |
| 10177 | BGP_STR |
| 10178 | "Address family\n" |
| 10179 | "Display routes matching the communities\n" |
| 10180 | "community number\n" |
| 10181 | "Do not send outside local AS (well-known community)\n" |
| 10182 | "Do not advertise to any peer (well-known community)\n" |
| 10183 | "Do not export to next AS (well-known community)\n" |
| 10184 | "community number\n" |
| 10185 | "Do not send outside local AS (well-known community)\n" |
| 10186 | "Do not advertise to any peer (well-known community)\n" |
| 10187 | "Do not export to next AS (well-known community)\n" |
| 10188 | "community number\n" |
| 10189 | "Do not send outside local AS (well-known community)\n" |
| 10190 | "Do not advertise to any peer (well-known community)\n" |
| 10191 | "Do not export to next AS (well-known community)\n" |
| 10192 | "community number\n" |
| 10193 | "Do not send outside local AS (well-known community)\n" |
| 10194 | "Do not advertise to any peer (well-known community)\n" |
| 10195 | "Do not export to next AS (well-known community)\n" |
| 10196 | "Exact match of the communities") |
| 10197 | |
| 10198 | /* old command */ |
| 10199 | DEFUN (show_ipv6_bgp_community_exact, |
| 10200 | show_ipv6_bgp_community_exact_cmd, |
| 10201 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10202 | SHOW_STR |
| 10203 | IPV6_STR |
| 10204 | BGP_STR |
| 10205 | "Display routes matching the communities\n" |
| 10206 | "community number\n" |
| 10207 | "Do not send outside local AS (well-known community)\n" |
| 10208 | "Do not advertise to any peer (well-known community)\n" |
| 10209 | "Do not export to next AS (well-known community)\n" |
| 10210 | "Exact match of the communities") |
| 10211 | { |
| 10212 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 10213 | } |
| 10214 | |
| 10215 | /* old command */ |
| 10216 | ALIAS (show_ipv6_bgp_community_exact, |
| 10217 | show_ipv6_bgp_community2_exact_cmd, |
| 10218 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10219 | SHOW_STR |
| 10220 | IPV6_STR |
| 10221 | BGP_STR |
| 10222 | "Display routes matching the communities\n" |
| 10223 | "community number\n" |
| 10224 | "Do not send outside local AS (well-known community)\n" |
| 10225 | "Do not advertise to any peer (well-known community)\n" |
| 10226 | "Do not export to next AS (well-known community)\n" |
| 10227 | "community number\n" |
| 10228 | "Do not send outside local AS (well-known community)\n" |
| 10229 | "Do not advertise to any peer (well-known community)\n" |
| 10230 | "Do not export to next AS (well-known community)\n" |
| 10231 | "Exact match of the communities") |
| 10232 | |
| 10233 | /* old command */ |
| 10234 | ALIAS (show_ipv6_bgp_community_exact, |
| 10235 | show_ipv6_bgp_community3_exact_cmd, |
| 10236 | "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", |
| 10237 | SHOW_STR |
| 10238 | IPV6_STR |
| 10239 | BGP_STR |
| 10240 | "Display routes matching the communities\n" |
| 10241 | "community number\n" |
| 10242 | "Do not send outside local AS (well-known community)\n" |
| 10243 | "Do not advertise to any peer (well-known community)\n" |
| 10244 | "Do not export to next AS (well-known community)\n" |
| 10245 | "community number\n" |
| 10246 | "Do not send outside local AS (well-known community)\n" |
| 10247 | "Do not advertise to any peer (well-known community)\n" |
| 10248 | "Do not export to next AS (well-known community)\n" |
| 10249 | "community number\n" |
| 10250 | "Do not send outside local AS (well-known community)\n" |
| 10251 | "Do not advertise to any peer (well-known community)\n" |
| 10252 | "Do not export to next AS (well-known community)\n" |
| 10253 | "Exact match of the communities") |
| 10254 | |
| 10255 | /* old command */ |
| 10256 | ALIAS (show_ipv6_bgp_community_exact, |
| 10257 | show_ipv6_bgp_community4_exact_cmd, |
| 10258 | "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", |
| 10259 | SHOW_STR |
| 10260 | IPV6_STR |
| 10261 | BGP_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 | "Exact match of the communities") |
| 10280 | |
| 10281 | /* old command */ |
| 10282 | DEFUN (show_ipv6_mbgp_community, |
| 10283 | show_ipv6_mbgp_community_cmd, |
| 10284 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 10285 | SHOW_STR |
| 10286 | IPV6_STR |
| 10287 | MBGP_STR |
| 10288 | "Display routes matching the communities\n" |
| 10289 | "community number\n" |
| 10290 | "Do not send outside local AS (well-known community)\n" |
| 10291 | "Do not advertise to any peer (well-known community)\n" |
| 10292 | "Do not export to next AS (well-known community)\n") |
| 10293 | { |
| 10294 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 10295 | } |
| 10296 | |
| 10297 | /* old command */ |
| 10298 | ALIAS (show_ipv6_mbgp_community, |
| 10299 | show_ipv6_mbgp_community2_cmd, |
| 10300 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 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 | |
| 10314 | /* old command */ |
| 10315 | ALIAS (show_ipv6_mbgp_community, |
| 10316 | show_ipv6_mbgp_community3_cmd, |
| 10317 | "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)", |
| 10318 | SHOW_STR |
| 10319 | IPV6_STR |
| 10320 | MBGP_STR |
| 10321 | "Display routes matching the communities\n" |
| 10322 | "community number\n" |
| 10323 | "Do not send outside local AS (well-known community)\n" |
| 10324 | "Do not advertise to any peer (well-known community)\n" |
| 10325 | "Do not export to next AS (well-known community)\n" |
| 10326 | "community number\n" |
| 10327 | "Do not send outside local AS (well-known community)\n" |
| 10328 | "Do not advertise to any peer (well-known community)\n" |
| 10329 | "Do not export to next AS (well-known community)\n" |
| 10330 | "community number\n" |
| 10331 | "Do not send outside local AS (well-known community)\n" |
| 10332 | "Do not advertise to any peer (well-known community)\n" |
| 10333 | "Do not export to next AS (well-known community)\n") |
| 10334 | |
| 10335 | /* old command */ |
| 10336 | ALIAS (show_ipv6_mbgp_community, |
| 10337 | show_ipv6_mbgp_community4_cmd, |
| 10338 | "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)", |
| 10339 | SHOW_STR |
| 10340 | IPV6_STR |
| 10341 | MBGP_STR |
| 10342 | "Display routes matching the communities\n" |
| 10343 | "community number\n" |
| 10344 | "Do not send outside local AS (well-known community)\n" |
| 10345 | "Do not advertise to any peer (well-known community)\n" |
| 10346 | "Do not export to next AS (well-known community)\n" |
| 10347 | "community number\n" |
| 10348 | "Do not send outside local AS (well-known community)\n" |
| 10349 | "Do not advertise to any peer (well-known community)\n" |
| 10350 | "Do not export to next AS (well-known community)\n" |
| 10351 | "community number\n" |
| 10352 | "Do not send outside local AS (well-known community)\n" |
| 10353 | "Do not advertise to any peer (well-known community)\n" |
| 10354 | "Do not export to next AS (well-known community)\n" |
| 10355 | "community number\n" |
| 10356 | "Do not send outside local AS (well-known community)\n" |
| 10357 | "Do not advertise to any peer (well-known community)\n" |
| 10358 | "Do not export to next AS (well-known community)\n") |
| 10359 | |
| 10360 | /* old command */ |
| 10361 | DEFUN (show_ipv6_mbgp_community_exact, |
| 10362 | show_ipv6_mbgp_community_exact_cmd, |
| 10363 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10364 | SHOW_STR |
| 10365 | IPV6_STR |
| 10366 | MBGP_STR |
| 10367 | "Display routes matching the communities\n" |
| 10368 | "community number\n" |
| 10369 | "Do not send outside local AS (well-known community)\n" |
| 10370 | "Do not advertise to any peer (well-known community)\n" |
| 10371 | "Do not export to next AS (well-known community)\n" |
| 10372 | "Exact match of the communities") |
| 10373 | { |
| 10374 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 10375 | } |
| 10376 | |
| 10377 | /* old command */ |
| 10378 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10379 | show_ipv6_mbgp_community2_exact_cmd, |
| 10380 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10381 | SHOW_STR |
| 10382 | IPV6_STR |
| 10383 | MBGP_STR |
| 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 | "Exact match of the communities") |
| 10394 | |
| 10395 | /* old command */ |
| 10396 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10397 | show_ipv6_mbgp_community3_exact_cmd, |
| 10398 | "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", |
| 10399 | SHOW_STR |
| 10400 | IPV6_STR |
| 10401 | MBGP_STR |
| 10402 | "Display routes matching the communities\n" |
| 10403 | "community number\n" |
| 10404 | "Do not send outside local AS (well-known community)\n" |
| 10405 | "Do not advertise to any peer (well-known community)\n" |
| 10406 | "Do not export to next AS (well-known community)\n" |
| 10407 | "community number\n" |
| 10408 | "Do not send outside local AS (well-known community)\n" |
| 10409 | "Do not advertise to any peer (well-known community)\n" |
| 10410 | "Do not export to next AS (well-known community)\n" |
| 10411 | "community number\n" |
| 10412 | "Do not send outside local AS (well-known community)\n" |
| 10413 | "Do not advertise to any peer (well-known community)\n" |
| 10414 | "Do not export to next AS (well-known community)\n" |
| 10415 | "Exact match of the communities") |
| 10416 | |
| 10417 | /* old command */ |
| 10418 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10419 | show_ipv6_mbgp_community4_exact_cmd, |
| 10420 | "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", |
| 10421 | SHOW_STR |
| 10422 | IPV6_STR |
| 10423 | MBGP_STR |
| 10424 | "Display routes matching the communities\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 | "community number\n" |
| 10438 | "Do not send outside local AS (well-known community)\n" |
| 10439 | "Do not advertise to any peer (well-known community)\n" |
| 10440 | "Do not export to next AS (well-known community)\n" |
| 10441 | "Exact match of the communities") |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10442 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10443 | DEFUN (show_bgp_ipv4_community, |
| 10444 | show_bgp_ipv4_community_cmd, |
| 10445 | "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10446 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10447 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10448 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10449 | "Display routes matching the communities\n" |
| 10450 | "community number\n" |
| 10451 | "Do not send outside local AS (well-known community)\n" |
| 10452 | "Do not advertise to any peer (well-known community)\n" |
| 10453 | "Do not export to next AS (well-known community)\n") |
| 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_community, |
| 10459 | show_bgp_ipv4_community2_cmd, |
| 10460 | "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] | 10461 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10462 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10463 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10464 | "Display routes matching the communities\n" |
| 10465 | "community number\n" |
| 10466 | "Do not send outside local AS (well-known community)\n" |
| 10467 | "Do not advertise to any peer (well-known community)\n" |
| 10468 | "Do not export to next AS (well-known community)\n" |
| 10469 | "community number\n" |
| 10470 | "Do not send outside local AS (well-known community)\n" |
| 10471 | "Do not advertise to any peer (well-known community)\n" |
| 10472 | "Do not export to next AS (well-known community)\n") |
| 10473 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10474 | ALIAS (show_bgp_ipv4_community, |
| 10475 | show_bgp_ipv4_community3_cmd, |
| 10476 | "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] | 10477 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10478 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10479 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10480 | "Display routes matching the communities\n" |
| 10481 | "community number\n" |
| 10482 | "Do not send outside local AS (well-known community)\n" |
| 10483 | "Do not advertise to any peer (well-known community)\n" |
| 10484 | "Do not export to next AS (well-known community)\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 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10494 | ALIAS (show_bgp_ipv4_community, |
| 10495 | show_bgp_ipv4_community4_cmd, |
| 10496 | "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] | 10497 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10498 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10499 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10500 | "Display routes matching the communities\n" |
| 10501 | "community number\n" |
| 10502 | "Do not send outside local AS (well-known community)\n" |
| 10503 | "Do not advertise to any peer (well-known community)\n" |
| 10504 | "Do not export to next AS (well-known community)\n" |
| 10505 | "community number\n" |
| 10506 | "Do not send outside local AS (well-known community)\n" |
| 10507 | "Do not advertise to any peer (well-known community)\n" |
| 10508 | "Do not export to next AS (well-known community)\n" |
| 10509 | "community number\n" |
| 10510 | "Do not send outside local AS (well-known community)\n" |
| 10511 | "Do not advertise to any peer (well-known community)\n" |
| 10512 | "Do not export to next AS (well-known community)\n" |
| 10513 | "community number\n" |
| 10514 | "Do not send outside local AS (well-known community)\n" |
| 10515 | "Do not advertise to any peer (well-known community)\n" |
| 10516 | "Do not export to next AS (well-known community)\n") |
| 10517 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10518 | DEFUN (show_bgp_ipv4_safi_community, |
| 10519 | show_bgp_ipv4_safi_community_cmd, |
| 10520 | "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] | 10521 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10522 | BGP_STR |
| 10523 | "Address family\n" |
| 10524 | "Address Family modifier\n" |
| 10525 | "Address Family modifier\n" |
| 10526 | "Display routes matching the communities\n" |
| 10527 | "community number\n" |
| 10528 | "Do not send outside local AS (well-known community)\n" |
| 10529 | "Do not advertise to any peer (well-known community)\n" |
| 10530 | "Do not export to next AS (well-known community)\n") |
| 10531 | { |
| 10532 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10533 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10534 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10535 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10536 | } |
| 10537 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10538 | ALIAS (show_bgp_ipv4_safi_community, |
| 10539 | show_bgp_ipv4_safi_community2_cmd, |
| 10540 | "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] | 10541 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10542 | BGP_STR |
| 10543 | "Address family\n" |
| 10544 | "Address Family modifier\n" |
| 10545 | "Address Family modifier\n" |
| 10546 | "Display routes matching the communities\n" |
| 10547 | "community number\n" |
| 10548 | "Do not send outside local AS (well-known community)\n" |
| 10549 | "Do not advertise to any peer (well-known community)\n" |
| 10550 | "Do not export to next AS (well-known community)\n" |
| 10551 | "community number\n" |
| 10552 | "Do not send outside local AS (well-known community)\n" |
| 10553 | "Do not advertise to any peer (well-known community)\n" |
| 10554 | "Do not export to next AS (well-known community)\n") |
| 10555 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10556 | ALIAS (show_bgp_ipv4_safi_community, |
| 10557 | show_bgp_ipv4_safi_community3_cmd, |
| 10558 | "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] | 10559 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10560 | BGP_STR |
| 10561 | "Address family\n" |
| 10562 | "Address Family modifier\n" |
| 10563 | "Address Family modifier\n" |
| 10564 | "Display routes matching the communities\n" |
| 10565 | "community number\n" |
| 10566 | "Do not send outside local AS (well-known community)\n" |
| 10567 | "Do not advertise to any peer (well-known community)\n" |
| 10568 | "Do not export to next AS (well-known community)\n" |
| 10569 | "community number\n" |
| 10570 | "Do not send outside local AS (well-known community)\n" |
| 10571 | "Do not advertise to any peer (well-known community)\n" |
| 10572 | "Do not export to next AS (well-known community)\n" |
| 10573 | "community number\n" |
| 10574 | "Do not send outside local AS (well-known community)\n" |
| 10575 | "Do not advertise to any peer (well-known community)\n" |
| 10576 | "Do not export to next AS (well-known community)\n") |
| 10577 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10578 | ALIAS (show_bgp_ipv4_safi_community, |
| 10579 | show_bgp_ipv4_safi_community4_cmd, |
| 10580 | "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] | 10581 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10582 | BGP_STR |
| 10583 | "Address family\n" |
| 10584 | "Address Family modifier\n" |
| 10585 | "Address Family modifier\n" |
| 10586 | "Display routes matching the communities\n" |
| 10587 | "community number\n" |
| 10588 | "Do not send outside local AS (well-known community)\n" |
| 10589 | "Do not advertise to any peer (well-known community)\n" |
| 10590 | "Do not export to next AS (well-known community)\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 | "community number\n" |
| 10600 | "Do not send outside local AS (well-known community)\n" |
| 10601 | "Do not advertise to any peer (well-known community)\n" |
| 10602 | "Do not export to next AS (well-known community)\n") |
| 10603 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10604 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 10605 | show_bgp_view_afi_safi_community_all_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10606 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10607 | SHOW_STR |
| 10608 | BGP_STR |
| 10609 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10610 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10611 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10612 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10613 | "Address Family modifier\n" |
| 10614 | "Address Family modifier\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10615 | "Display routes matching the communities\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10616 | { |
| 10617 | int afi; |
| 10618 | int safi; |
| 10619 | struct bgp *bgp; |
| 10620 | |
| 10621 | /* BGP structure lookup. */ |
| 10622 | bgp = bgp_lookup_by_name (argv[0]); |
| 10623 | if (bgp == NULL) |
| 10624 | { |
| 10625 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10626 | return CMD_WARNING; |
| 10627 | } |
| 10628 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10629 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10630 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10631 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 10632 | } |
| 10633 | |
| 10634 | DEFUN (show_bgp_view_afi_safi_community, |
| 10635 | show_bgp_view_afi_safi_community_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10636 | "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] | 10637 | SHOW_STR |
| 10638 | BGP_STR |
| 10639 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10640 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10641 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10642 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10643 | "Address family modifier\n" |
| 10644 | "Address family modifier\n" |
| 10645 | "Display routes matching the communities\n" |
| 10646 | "community number\n" |
| 10647 | "Do not send outside local AS (well-known community)\n" |
| 10648 | "Do not advertise to any peer (well-known community)\n" |
| 10649 | "Do not export to next AS (well-known community)\n") |
| 10650 | { |
| 10651 | int afi; |
| 10652 | int safi; |
| 10653 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10654 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10655 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10656 | 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] | 10657 | } |
| 10658 | |
| 10659 | ALIAS (show_bgp_view_afi_safi_community, |
| 10660 | show_bgp_view_afi_safi_community2_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10661 | "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] | 10662 | SHOW_STR |
| 10663 | BGP_STR |
| 10664 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10665 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10666 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10667 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10668 | "Address family modifier\n" |
| 10669 | "Address family modifier\n" |
| 10670 | "Display routes matching the communities\n" |
| 10671 | "community number\n" |
| 10672 | "Do not send outside local AS (well-known community)\n" |
| 10673 | "Do not advertise to any peer (well-known community)\n" |
| 10674 | "Do not export to next AS (well-known community)\n" |
| 10675 | "community number\n" |
| 10676 | "Do not send outside local AS (well-known community)\n" |
| 10677 | "Do not advertise to any peer (well-known community)\n" |
| 10678 | "Do not export to next AS (well-known community)\n") |
| 10679 | |
| 10680 | ALIAS (show_bgp_view_afi_safi_community, |
| 10681 | show_bgp_view_afi_safi_community3_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10682 | "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] | 10683 | SHOW_STR |
| 10684 | BGP_STR |
| 10685 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10686 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10687 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10688 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10689 | "Address family modifier\n" |
| 10690 | "Address family modifier\n" |
| 10691 | "Display routes matching the communities\n" |
| 10692 | "community number\n" |
| 10693 | "Do not send outside local AS (well-known community)\n" |
| 10694 | "Do not advertise to any peer (well-known community)\n" |
| 10695 | "Do not export to next AS (well-known community)\n" |
| 10696 | "community number\n" |
| 10697 | "Do not send outside local AS (well-known community)\n" |
| 10698 | "Do not advertise to any peer (well-known community)\n" |
| 10699 | "Do not export to next AS (well-known community)\n" |
| 10700 | "community number\n" |
| 10701 | "Do not send outside local AS (well-known community)\n" |
| 10702 | "Do not advertise to any peer (well-known community)\n" |
| 10703 | "Do not export to next AS (well-known community)\n") |
| 10704 | |
| 10705 | ALIAS (show_bgp_view_afi_safi_community, |
| 10706 | show_bgp_view_afi_safi_community4_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10707 | "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] | 10708 | SHOW_STR |
| 10709 | BGP_STR |
| 10710 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10711 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10712 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10713 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10714 | "Address family modifier\n" |
| 10715 | "Address family modifier\n" |
| 10716 | "Display routes matching the communities\n" |
| 10717 | "community number\n" |
| 10718 | "Do not send outside local AS (well-known community)\n" |
| 10719 | "Do not advertise to any peer (well-known community)\n" |
| 10720 | "Do not export to next AS (well-known community)\n" |
| 10721 | "community number\n" |
| 10722 | "Do not send outside local AS (well-known community)\n" |
| 10723 | "Do not advertise to any peer (well-known community)\n" |
| 10724 | "Do not export to next AS (well-known community)\n" |
| 10725 | "community number\n" |
| 10726 | "Do not send outside local AS (well-known community)\n" |
| 10727 | "Do not advertise to any peer (well-known community)\n" |
| 10728 | "Do not export to next AS (well-known community)\n" |
| 10729 | "community number\n" |
| 10730 | "Do not send outside local AS (well-known community)\n" |
| 10731 | "Do not advertise to any peer (well-known community)\n" |
| 10732 | "Do not export to next AS (well-known community)\n") |
| 10733 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10734 | DEFUN (show_bgp_ipv4_community_exact, |
| 10735 | show_bgp_ipv4_community_exact_cmd, |
| 10736 | "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] | 10737 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10738 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10739 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10740 | "Display routes matching the communities\n" |
| 10741 | "community number\n" |
| 10742 | "Do not send outside local AS (well-known community)\n" |
| 10743 | "Do not advertise to any peer (well-known community)\n" |
| 10744 | "Do not export to next AS (well-known community)\n" |
| 10745 | "Exact match of the communities") |
| 10746 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10747 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10748 | } |
| 10749 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10750 | ALIAS (show_bgp_ipv4_community_exact, |
| 10751 | show_bgp_ipv4_community2_exact_cmd, |
| 10752 | "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] | 10753 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10754 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10755 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10756 | "Display routes matching the communities\n" |
| 10757 | "community number\n" |
| 10758 | "Do not send outside local AS (well-known community)\n" |
| 10759 | "Do not advertise to any peer (well-known community)\n" |
| 10760 | "Do not export to next AS (well-known community)\n" |
| 10761 | "community number\n" |
| 10762 | "Do not send outside local AS (well-known community)\n" |
| 10763 | "Do not advertise to any peer (well-known community)\n" |
| 10764 | "Do not export to next AS (well-known community)\n" |
| 10765 | "Exact match of the communities") |
| 10766 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10767 | ALIAS (show_bgp_ipv4_community_exact, |
| 10768 | show_bgp_ipv4_community3_exact_cmd, |
| 10769 | "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] | 10770 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10771 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10772 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10773 | "Display routes matching the communities\n" |
| 10774 | "community number\n" |
| 10775 | "Do not send outside local AS (well-known community)\n" |
| 10776 | "Do not advertise to any peer (well-known community)\n" |
| 10777 | "Do not export to next AS (well-known community)\n" |
| 10778 | "community number\n" |
| 10779 | "Do not send outside local AS (well-known community)\n" |
| 10780 | "Do not advertise to any peer (well-known community)\n" |
| 10781 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") |
| 10787 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10788 | ALIAS (show_bgp_ipv4_community_exact, |
| 10789 | show_bgp_ipv4_community4_exact_cmd, |
| 10790 | "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] | 10791 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10792 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10793 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10794 | "Display routes matching the communities\n" |
| 10795 | "community number\n" |
| 10796 | "Do not send outside local AS (well-known community)\n" |
| 10797 | "Do not advertise to any peer (well-known community)\n" |
| 10798 | "Do not export to next AS (well-known community)\n" |
| 10799 | "community number\n" |
| 10800 | "Do not send outside local AS (well-known community)\n" |
| 10801 | "Do not advertise to any peer (well-known community)\n" |
| 10802 | "Do not export to next AS (well-known community)\n" |
| 10803 | "community number\n" |
| 10804 | "Do not send outside local AS (well-known community)\n" |
| 10805 | "Do not advertise to any peer (well-known community)\n" |
| 10806 | "Do not export to next AS (well-known community)\n" |
| 10807 | "community number\n" |
| 10808 | "Do not send outside local AS (well-known community)\n" |
| 10809 | "Do not advertise to any peer (well-known community)\n" |
| 10810 | "Do not export to next AS (well-known community)\n" |
| 10811 | "Exact match of the communities") |
| 10812 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10813 | DEFUN (show_bgp_ipv4_safi_community4_exact, |
| 10814 | show_bgp_ipv4_safi_community_exact_cmd, |
| 10815 | "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] | 10816 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10817 | BGP_STR |
| 10818 | "Address family\n" |
| 10819 | "Address Family modifier\n" |
| 10820 | "Address Family modifier\n" |
| 10821 | "Display routes matching the communities\n" |
| 10822 | "community number\n" |
| 10823 | "Do not send outside local AS (well-known community)\n" |
| 10824 | "Do not advertise to any peer (well-known community)\n" |
| 10825 | "Do not export to next AS (well-known community)\n" |
| 10826 | "Exact match of the communities") |
| 10827 | { |
| 10828 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10829 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10830 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10831 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10832 | } |
| 10833 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10834 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10835 | show_bgp_ipv4_safi_community2_exact_cmd, |
| 10836 | "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] | 10837 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10838 | BGP_STR |
| 10839 | "Address family\n" |
| 10840 | "Address Family modifier\n" |
| 10841 | "Address Family modifier\n" |
| 10842 | "Display routes matching the communities\n" |
| 10843 | "community number\n" |
| 10844 | "Do not send outside local AS (well-known community)\n" |
| 10845 | "Do not advertise to any peer (well-known community)\n" |
| 10846 | "Do not export to next AS (well-known community)\n" |
| 10847 | "community number\n" |
| 10848 | "Do not send outside local AS (well-known community)\n" |
| 10849 | "Do not advertise to any peer (well-known community)\n" |
| 10850 | "Do not export to next AS (well-known community)\n" |
| 10851 | "Exact match of the communities") |
| 10852 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10853 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10854 | show_bgp_ipv4_safi_community3_exact_cmd, |
| 10855 | "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] | 10856 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10857 | BGP_STR |
| 10858 | "Address family\n" |
| 10859 | "Address Family modifier\n" |
| 10860 | "Address Family modifier\n" |
| 10861 | "Display routes matching the communities\n" |
| 10862 | "community number\n" |
| 10863 | "Do not send outside local AS (well-known community)\n" |
| 10864 | "Do not advertise to any peer (well-known community)\n" |
| 10865 | "Do not export to next AS (well-known community)\n" |
| 10866 | "community number\n" |
| 10867 | "Do not send outside local AS (well-known community)\n" |
| 10868 | "Do not advertise to any peer (well-known community)\n" |
| 10869 | "Do not export to next AS (well-known community)\n" |
| 10870 | "community number\n" |
| 10871 | "Do not send outside local AS (well-known community)\n" |
| 10872 | "Do not advertise to any peer (well-known community)\n" |
| 10873 | "Do not export to next AS (well-known community)\n" |
| 10874 | "Exact match of the communities") |
| 10875 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10876 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10877 | show_bgp_ipv4_safi_community4_exact_cmd, |
| 10878 | "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] | 10879 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10880 | BGP_STR |
| 10881 | "Address family\n" |
| 10882 | "Address Family modifier\n" |
| 10883 | "Address Family modifier\n" |
| 10884 | "Display routes matching the communities\n" |
| 10885 | "community number\n" |
| 10886 | "Do not send outside local AS (well-known community)\n" |
| 10887 | "Do not advertise to any peer (well-known community)\n" |
| 10888 | "Do not export to next AS (well-known community)\n" |
| 10889 | "community number\n" |
| 10890 | "Do not send outside local AS (well-known community)\n" |
| 10891 | "Do not advertise to any peer (well-known community)\n" |
| 10892 | "Do not export to next AS (well-known community)\n" |
| 10893 | "community number\n" |
| 10894 | "Do not send outside local AS (well-known community)\n" |
| 10895 | "Do not advertise to any peer (well-known community)\n" |
| 10896 | "Do not export to next AS (well-known community)\n" |
| 10897 | "community number\n" |
| 10898 | "Do not send outside local AS (well-known community)\n" |
| 10899 | "Do not advertise to any peer (well-known community)\n" |
| 10900 | "Do not export to next AS (well-known community)\n" |
| 10901 | "Exact match of the communities") |
| 10902 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10903 | DEFUN (show_bgp_ipv6_safi_community, |
| 10904 | show_bgp_ipv6_safi_community_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10905 | "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] | 10906 | SHOW_STR |
| 10907 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10908 | "Address family\n" |
| 10909 | "Address family modifier\n" |
| 10910 | "Address family modifier\n" |
| 10911 | "Address family modifier\n" |
| 10912 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10913 | "Display routes matching the communities\n" |
| 10914 | "community number\n" |
| 10915 | "Do not send outside local AS (well-known community)\n" |
| 10916 | "Do not advertise to any peer (well-known community)\n" |
| 10917 | "Do not export to next AS (well-known community)\n") |
| 10918 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10919 | safi_t safi; |
| 10920 | |
| 10921 | if (bgp_parse_safi(argv[0], &safi)) { |
| 10922 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 10923 | return CMD_WARNING; |
| 10924 | } |
| 10925 | 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] | 10926 | } |
| 10927 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10928 | ALIAS (show_bgp_ipv6_safi_community, |
| 10929 | show_bgp_ipv6_safi_community2_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10930 | "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] | 10931 | SHOW_STR |
| 10932 | BGP_STR |
| 10933 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10934 | "Address family modifier\n" |
| 10935 | "Address family modifier\n" |
| 10936 | "Address family modifier\n" |
| 10937 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10938 | "Display routes matching the communities\n" |
| 10939 | "community number\n" |
| 10940 | "Do not send outside local AS (well-known community)\n" |
| 10941 | "Do not advertise to any peer (well-known community)\n" |
| 10942 | "Do not export to next AS (well-known community)\n" |
| 10943 | "community number\n" |
| 10944 | "Do not send outside local AS (well-known community)\n" |
| 10945 | "Do not advertise to any peer (well-known community)\n" |
| 10946 | "Do not export to next AS (well-known community)\n") |
| 10947 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10948 | ALIAS (show_bgp_ipv6_safi_community, |
| 10949 | show_bgp_ipv6_safi_community3_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) (AA:NN|local-AS|no-advertise|no-export)", |
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 | "community number\n" |
| 10968 | "Do not send outside local AS (well-known community)\n" |
| 10969 | "Do not advertise to any peer (well-known community)\n" |
| 10970 | "Do not export to next AS (well-known community)\n") |
| 10971 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10972 | ALIAS (show_bgp_ipv6_safi_community, |
| 10973 | show_bgp_ipv6_safi_community4_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10974 | "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] | 10975 | SHOW_STR |
| 10976 | BGP_STR |
| 10977 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10978 | "Address family modifier\n" |
| 10979 | "Address family modifier\n" |
| 10980 | "Address family modifier\n" |
| 10981 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10982 | "Display routes matching the communities\n" |
| 10983 | "community number\n" |
| 10984 | "Do not send outside local AS (well-known community)\n" |
| 10985 | "Do not advertise to any peer (well-known community)\n" |
| 10986 | "Do not export to next AS (well-known community)\n" |
| 10987 | "community number\n" |
| 10988 | "Do not send outside local AS (well-known community)\n" |
| 10989 | "Do not advertise to any peer (well-known community)\n" |
| 10990 | "Do not export to next AS (well-known community)\n" |
| 10991 | "community number\n" |
| 10992 | "Do not send outside local AS (well-known community)\n" |
| 10993 | "Do not advertise to any peer (well-known community)\n" |
| 10994 | "Do not export to next AS (well-known community)\n" |
| 10995 | "community number\n" |
| 10996 | "Do not send outside local AS (well-known community)\n" |
| 10997 | "Do not advertise to any peer (well-known community)\n" |
| 10998 | "Do not export to next AS (well-known community)\n") |
| 10999 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11000 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11001 | DEFUN (show_bgp_ipv6_safi_community_exact, |
| 11002 | show_bgp_ipv6_safi_community_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11003 | "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] | 11004 | SHOW_STR |
| 11005 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11006 | "Address family\n" |
| 11007 | "Address family modifier\n" |
| 11008 | "Address family modifier\n" |
| 11009 | "Address family modifier\n" |
| 11010 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11011 | "Display routes matching the communities\n" |
| 11012 | "community number\n" |
| 11013 | "Do not send outside local AS (well-known community)\n" |
| 11014 | "Do not advertise to any peer (well-known community)\n" |
| 11015 | "Do not export to next AS (well-known community)\n" |
| 11016 | "Exact match of the communities") |
| 11017 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11018 | safi_t safi; |
| 11019 | |
| 11020 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11021 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11022 | return CMD_WARNING; |
| 11023 | } |
| 11024 | 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] | 11025 | } |
| 11026 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11027 | |
| 11028 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11029 | show_bgp_ipv6_safi_community2_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11030 | "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] | 11031 | SHOW_STR |
| 11032 | BGP_STR |
| 11033 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11034 | "Address family modifier\n" |
| 11035 | "Address family modifier\n" |
| 11036 | "Address family modifier\n" |
| 11037 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11038 | "Display routes matching the communities\n" |
| 11039 | "community number\n" |
| 11040 | "Do not send outside local AS (well-known community)\n" |
| 11041 | "Do not advertise to any peer (well-known community)\n" |
| 11042 | "Do not export to next AS (well-known community)\n" |
| 11043 | "community number\n" |
| 11044 | "Do not send outside local AS (well-known community)\n" |
| 11045 | "Do not advertise to any peer (well-known community)\n" |
| 11046 | "Do not export to next AS (well-known community)\n" |
| 11047 | "Exact match of the communities") |
| 11048 | |
| 11049 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11050 | show_bgp_ipv6_safi_community3_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11051 | "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] | 11052 | SHOW_STR |
| 11053 | BGP_STR |
| 11054 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11055 | "Address family modifier\n" |
| 11056 | "Address family modifier\n" |
| 11057 | "Address family modifier\n" |
| 11058 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11059 | "Display routes matching the communities\n" |
| 11060 | "community number\n" |
| 11061 | "Do not send outside local AS (well-known community)\n" |
| 11062 | "Do not advertise to any peer (well-known community)\n" |
| 11063 | "Do not export to next AS (well-known community)\n" |
| 11064 | "community number\n" |
| 11065 | "Do not send outside local AS (well-known community)\n" |
| 11066 | "Do not advertise to any peer (well-known community)\n" |
| 11067 | "Do not export to next AS (well-known community)\n" |
| 11068 | "community number\n" |
| 11069 | "Do not send outside local AS (well-known community)\n" |
| 11070 | "Do not advertise to any peer (well-known community)\n" |
| 11071 | "Do not export to next AS (well-known community)\n" |
| 11072 | "Exact match of the communities") |
| 11073 | |
| 11074 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11075 | show_bgp_ipv6_safi_community4_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11076 | "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] | 11077 | SHOW_STR |
| 11078 | BGP_STR |
| 11079 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11080 | "Address family modifier\n" |
| 11081 | "Address family modifier\n" |
| 11082 | "Address family modifier\n" |
| 11083 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11084 | "Display routes matching the communities\n" |
| 11085 | "community number\n" |
| 11086 | "Do not send outside local AS (well-known community)\n" |
| 11087 | "Do not advertise to any peer (well-known community)\n" |
| 11088 | "Do not export to next AS (well-known community)\n" |
| 11089 | "community number\n" |
| 11090 | "Do not send outside local AS (well-known community)\n" |
| 11091 | "Do not advertise to any peer (well-known community)\n" |
| 11092 | "Do not export to next AS (well-known community)\n" |
| 11093 | "community number\n" |
| 11094 | "Do not send outside local AS (well-known community)\n" |
| 11095 | "Do not advertise to any peer (well-known community)\n" |
| 11096 | "Do not export to next AS (well-known community)\n" |
| 11097 | "community number\n" |
| 11098 | "Do not send outside local AS (well-known community)\n" |
| 11099 | "Do not advertise to any peer (well-known community)\n" |
| 11100 | "Do not export to next AS (well-known community)\n" |
| 11101 | "Exact match of the communities") |
| 11102 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11103 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11104 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 11105 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11106 | { |
| 11107 | struct community_list *list; |
| 11108 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11109 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11110 | if (list == NULL) |
| 11111 | { |
| 11112 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 11113 | VTY_NEWLINE); |
| 11114 | return CMD_WARNING; |
| 11115 | } |
| 11116 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11117 | return bgp_show (vty, NULL, afi, safi, |
| 11118 | (exact ? bgp_show_type_community_list_exact : |
| 11119 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11120 | } |
| 11121 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11122 | DEFUN (show_ip_bgp_community_list, |
| 11123 | show_ip_bgp_community_list_cmd, |
| 11124 | "show ip bgp community-list (<1-500>|WORD)", |
| 11125 | SHOW_STR |
| 11126 | IP_STR |
| 11127 | BGP_STR |
| 11128 | "Display routes matching the community-list\n" |
| 11129 | "community-list number\n" |
| 11130 | "community-list name\n") |
| 11131 | { |
| 11132 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 11133 | } |
| 11134 | |
| 11135 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 11136 | show_ip_bgp_ipv4_community_list_cmd, |
| 11137 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
| 11138 | SHOW_STR |
| 11139 | IP_STR |
| 11140 | BGP_STR |
| 11141 | "Address family\n" |
| 11142 | "Address Family modifier\n" |
| 11143 | "Address Family modifier\n" |
| 11144 | "Display routes matching the community-list\n" |
| 11145 | "community-list number\n" |
| 11146 | "community-list name\n") |
| 11147 | { |
| 11148 | if (strncmp (argv[0], "m", 1) == 0) |
| 11149 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 11150 | |
| 11151 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 11152 | } |
| 11153 | |
| 11154 | DEFUN (show_ip_bgp_community_list_exact, |
| 11155 | show_ip_bgp_community_list_exact_cmd, |
| 11156 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
| 11157 | SHOW_STR |
| 11158 | IP_STR |
| 11159 | BGP_STR |
| 11160 | "Display routes matching the community-list\n" |
| 11161 | "community-list number\n" |
| 11162 | "community-list name\n" |
| 11163 | "Exact match of the communities\n") |
| 11164 | { |
| 11165 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 11166 | } |
| 11167 | |
| 11168 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 11169 | show_ip_bgp_ipv4_community_list_exact_cmd, |
| 11170 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
| 11171 | SHOW_STR |
| 11172 | IP_STR |
| 11173 | BGP_STR |
| 11174 | "Address family\n" |
| 11175 | "Address Family modifier\n" |
| 11176 | "Address Family modifier\n" |
| 11177 | "Display routes matching the community-list\n" |
| 11178 | "community-list number\n" |
| 11179 | "community-list name\n" |
| 11180 | "Exact match of the communities\n") |
| 11181 | { |
| 11182 | if (strncmp (argv[0], "m", 1) == 0) |
| 11183 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 11184 | |
| 11185 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 11186 | } |
| 11187 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11188 | DEFUN (show_bgp_community_list, |
| 11189 | show_bgp_community_list_cmd, |
| 11190 | "show bgp community-list (<1-500>|WORD)", |
| 11191 | SHOW_STR |
| 11192 | BGP_STR |
| 11193 | "Display routes matching the community-list\n" |
| 11194 | "community-list number\n" |
| 11195 | "community-list name\n") |
| 11196 | { |
| 11197 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 11198 | } |
| 11199 | |
| 11200 | ALIAS (show_bgp_community_list, |
| 11201 | show_bgp_ipv6_community_list_cmd, |
| 11202 | "show bgp ipv6 community-list (<1-500>|WORD)", |
| 11203 | SHOW_STR |
| 11204 | BGP_STR |
| 11205 | "Address family\n" |
| 11206 | "Display routes matching the community-list\n" |
| 11207 | "community-list number\n" |
| 11208 | "community-list name\n") |
| 11209 | |
| 11210 | /* old command */ |
| 11211 | DEFUN (show_ipv6_bgp_community_list, |
| 11212 | show_ipv6_bgp_community_list_cmd, |
| 11213 | "show ipv6 bgp community-list WORD", |
| 11214 | SHOW_STR |
| 11215 | IPV6_STR |
| 11216 | BGP_STR |
| 11217 | "Display routes matching the community-list\n" |
| 11218 | "community-list name\n") |
| 11219 | { |
| 11220 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 11221 | } |
| 11222 | |
| 11223 | /* old command */ |
| 11224 | DEFUN (show_ipv6_mbgp_community_list, |
| 11225 | show_ipv6_mbgp_community_list_cmd, |
| 11226 | "show ipv6 mbgp community-list WORD", |
| 11227 | SHOW_STR |
| 11228 | IPV6_STR |
| 11229 | MBGP_STR |
| 11230 | "Display routes matching the community-list\n" |
| 11231 | "community-list name\n") |
| 11232 | { |
| 11233 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 11234 | } |
| 11235 | |
| 11236 | DEFUN (show_bgp_community_list_exact, |
| 11237 | show_bgp_community_list_exact_cmd, |
| 11238 | "show bgp community-list (<1-500>|WORD) exact-match", |
| 11239 | SHOW_STR |
| 11240 | BGP_STR |
| 11241 | "Display routes matching the community-list\n" |
| 11242 | "community-list number\n" |
| 11243 | "community-list name\n" |
| 11244 | "Exact match of the communities\n") |
| 11245 | { |
| 11246 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 11247 | } |
| 11248 | |
| 11249 | ALIAS (show_bgp_community_list_exact, |
| 11250 | show_bgp_ipv6_community_list_exact_cmd, |
| 11251 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
| 11252 | SHOW_STR |
| 11253 | BGP_STR |
| 11254 | "Address family\n" |
| 11255 | "Display routes matching the community-list\n" |
| 11256 | "community-list number\n" |
| 11257 | "community-list name\n" |
| 11258 | "Exact match of the communities\n") |
| 11259 | |
| 11260 | /* old command */ |
| 11261 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 11262 | show_ipv6_bgp_community_list_exact_cmd, |
| 11263 | "show ipv6 bgp community-list WORD exact-match", |
| 11264 | SHOW_STR |
| 11265 | IPV6_STR |
| 11266 | BGP_STR |
| 11267 | "Display routes matching the community-list\n" |
| 11268 | "community-list name\n" |
| 11269 | "Exact match of the communities\n") |
| 11270 | { |
| 11271 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 11272 | } |
| 11273 | |
| 11274 | /* old command */ |
| 11275 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 11276 | show_ipv6_mbgp_community_list_exact_cmd, |
| 11277 | "show ipv6 mbgp community-list WORD exact-match", |
| 11278 | SHOW_STR |
| 11279 | IPV6_STR |
| 11280 | MBGP_STR |
| 11281 | "Display routes matching the community-list\n" |
| 11282 | "community-list name\n" |
| 11283 | "Exact match of the communities\n") |
| 11284 | { |
| 11285 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 11286 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11287 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11288 | DEFUN (show_bgp_ipv4_community_list, |
| 11289 | show_bgp_ipv4_community_list_cmd, |
| 11290 | "show bgp ipv4 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11291 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11292 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11293 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11294 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11295 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11296 | "community-list name\n") |
| 11297 | { |
| 11298 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 11299 | } |
| 11300 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11301 | DEFUN (show_bgp_ipv4_safi_community_list, |
| 11302 | show_bgp_ipv4_safi_community_list_cmd, |
| 11303 | "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11304 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11305 | BGP_STR |
| 11306 | "Address family\n" |
| 11307 | "Address Family modifier\n" |
| 11308 | "Address Family modifier\n" |
| 11309 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11310 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11311 | "community-list name\n") |
| 11312 | { |
| 11313 | if (strncmp (argv[0], "m", 1) == 0) |
| 11314 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 11315 | |
| 11316 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 11317 | } |
| 11318 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11319 | DEFUN (show_bgp_ipv4_community_list_exact, |
| 11320 | show_bgp_ipv4_community_list_exact_cmd, |
| 11321 | "show bgp ipv4 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11322 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11323 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11324 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11325 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11326 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11327 | "community-list name\n" |
| 11328 | "Exact match of the communities\n") |
| 11329 | { |
| 11330 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 11331 | } |
| 11332 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11333 | DEFUN (show_bgp_ipv4_safi_community_list_exact, |
| 11334 | show_bgp_ipv4_safi_community_list_exact_cmd, |
| 11335 | "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11336 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11337 | BGP_STR |
| 11338 | "Address family\n" |
| 11339 | "Address Family modifier\n" |
| 11340 | "Address Family modifier\n" |
| 11341 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11342 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11343 | "community-list name\n" |
| 11344 | "Exact match of the communities\n") |
| 11345 | { |
| 11346 | if (strncmp (argv[0], "m", 1) == 0) |
| 11347 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 11348 | |
| 11349 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 11350 | } |
| 11351 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11352 | DEFUN (show_bgp_ipv6_safi_community_list, |
| 11353 | show_bgp_ipv6_safi_community_list_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11354 | "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11355 | SHOW_STR |
| 11356 | BGP_STR |
| 11357 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11358 | "Address family modifier\n" |
| 11359 | "Address family modifier\n" |
| 11360 | "Address family modifier\n" |
| 11361 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11362 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11363 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 11364 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11365 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11366 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11367 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11368 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11369 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11370 | return CMD_WARNING; |
| 11371 | } |
| 11372 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11373 | } |
| 11374 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11375 | DEFUN (show_bgp_ipv6_safi_community_list_exact, |
| 11376 | show_bgp_ipv6_safi_community_list_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11377 | "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] | 11378 | SHOW_STR |
| 11379 | BGP_STR |
| 11380 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11381 | "Address family modifier\n" |
| 11382 | "Address family modifier\n" |
| 11383 | "Address family modifier\n" |
| 11384 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11385 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11386 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11387 | "community-list name\n" |
| 11388 | "Exact match of the communities\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11389 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11390 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11391 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11392 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11393 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11394 | return CMD_WARNING; |
| 11395 | } |
| 11396 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11397 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11398 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11399 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11400 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11401 | safi_t safi, enum bgp_show_type type) |
| 11402 | { |
| 11403 | int ret; |
| 11404 | struct prefix *p; |
| 11405 | |
| 11406 | p = prefix_new(); |
| 11407 | |
| 11408 | ret = str2prefix (prefix, p); |
| 11409 | if (! ret) |
| 11410 | { |
| 11411 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 11412 | return CMD_WARNING; |
| 11413 | } |
| 11414 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11415 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 11416 | prefix_free(p); |
| 11417 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11418 | } |
| 11419 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11420 | DEFUN (show_ip_bgp_prefix_longer, |
| 11421 | show_ip_bgp_prefix_longer_cmd, |
| 11422 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 11423 | SHOW_STR |
| 11424 | IP_STR |
| 11425 | BGP_STR |
| 11426 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11427 | "Display route and more specific routes\n") |
| 11428 | { |
| 11429 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11430 | bgp_show_type_prefix_longer); |
| 11431 | } |
| 11432 | |
| 11433 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 11434 | show_ip_bgp_flap_prefix_longer_cmd, |
| 11435 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 11436 | SHOW_STR |
| 11437 | IP_STR |
| 11438 | BGP_STR |
| 11439 | "Display flap statistics of routes\n" |
| 11440 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11441 | "Display route and more specific routes\n") |
| 11442 | { |
| 11443 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11444 | bgp_show_type_flap_prefix_longer); |
| 11445 | } |
| 11446 | |
| 11447 | ALIAS (show_ip_bgp_flap_prefix_longer, |
| 11448 | show_ip_bgp_damp_flap_prefix_longer_cmd, |
| 11449 | "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes", |
| 11450 | SHOW_STR |
| 11451 | IP_STR |
| 11452 | BGP_STR |
| 11453 | "Display detailed information about dampening\n" |
| 11454 | "Display flap statistics of routes\n" |
| 11455 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11456 | "Display route and more specific routes\n") |
| 11457 | |
| 11458 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 11459 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 11460 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 11461 | SHOW_STR |
| 11462 | IP_STR |
| 11463 | BGP_STR |
| 11464 | "Address family\n" |
| 11465 | "Address Family modifier\n" |
| 11466 | "Address Family modifier\n" |
| 11467 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11468 | "Display route and more specific routes\n") |
| 11469 | { |
| 11470 | if (strncmp (argv[0], "m", 1) == 0) |
| 11471 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 11472 | bgp_show_type_prefix_longer); |
| 11473 | |
| 11474 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 11475 | bgp_show_type_prefix_longer); |
| 11476 | } |
| 11477 | |
| 11478 | DEFUN (show_ip_bgp_flap_address, |
| 11479 | show_ip_bgp_flap_address_cmd, |
| 11480 | "show ip bgp flap-statistics A.B.C.D", |
| 11481 | SHOW_STR |
| 11482 | IP_STR |
| 11483 | BGP_STR |
| 11484 | "Display flap statistics of routes\n" |
| 11485 | "Network in the BGP routing table to display\n") |
| 11486 | { |
| 11487 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11488 | bgp_show_type_flap_address); |
| 11489 | } |
| 11490 | |
| 11491 | ALIAS (show_ip_bgp_flap_address, |
| 11492 | show_ip_bgp_damp_flap_address_cmd, |
| 11493 | "show ip bgp dampening flap-statistics A.B.C.D", |
| 11494 | SHOW_STR |
| 11495 | IP_STR |
| 11496 | BGP_STR |
| 11497 | "Display detailed information about dampening\n" |
| 11498 | "Display flap statistics of routes\n" |
| 11499 | "Network in the BGP routing table to display\n") |
| 11500 | |
| 11501 | DEFUN (show_ip_bgp_flap_prefix, |
| 11502 | show_ip_bgp_flap_prefix_cmd, |
| 11503 | "show ip bgp flap-statistics A.B.C.D/M", |
| 11504 | SHOW_STR |
| 11505 | IP_STR |
| 11506 | BGP_STR |
| 11507 | "Display flap statistics of routes\n" |
| 11508 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11509 | { |
| 11510 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11511 | bgp_show_type_flap_prefix); |
| 11512 | } |
| 11513 | |
| 11514 | ALIAS (show_ip_bgp_flap_prefix, |
| 11515 | show_ip_bgp_damp_flap_prefix_cmd, |
| 11516 | "show ip bgp dampening flap-statistics A.B.C.D/M", |
| 11517 | SHOW_STR |
| 11518 | IP_STR |
| 11519 | BGP_STR |
| 11520 | "Display detailed information about dampening\n" |
| 11521 | "Display flap statistics of routes\n" |
| 11522 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11523 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11524 | DEFUN (show_bgp_prefix_longer, |
| 11525 | show_bgp_prefix_longer_cmd, |
| 11526 | "show bgp X:X::X:X/M longer-prefixes", |
| 11527 | SHOW_STR |
| 11528 | BGP_STR |
| 11529 | "IPv6 prefix <network>/<length>\n" |
| 11530 | "Display route and more specific routes\n") |
| 11531 | { |
| 11532 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11533 | bgp_show_type_prefix_longer); |
| 11534 | } |
| 11535 | |
| 11536 | /* old command */ |
| 11537 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 11538 | show_ipv6_bgp_prefix_longer_cmd, |
| 11539 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 11540 | SHOW_STR |
| 11541 | IPV6_STR |
| 11542 | BGP_STR |
| 11543 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 11544 | "Display route and more specific routes\n") |
| 11545 | { |
| 11546 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11547 | bgp_show_type_prefix_longer); |
| 11548 | } |
| 11549 | |
| 11550 | /* old command */ |
| 11551 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 11552 | show_ipv6_mbgp_prefix_longer_cmd, |
| 11553 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 11554 | SHOW_STR |
| 11555 | IPV6_STR |
| 11556 | MBGP_STR |
| 11557 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 11558 | "Display route and more specific routes\n") |
| 11559 | { |
| 11560 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 11561 | bgp_show_type_prefix_longer); |
| 11562 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11563 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11564 | DEFUN (show_bgp_ipv4_prefix_longer, |
| 11565 | show_bgp_ipv4_prefix_longer_cmd, |
| 11566 | "show bgp ipv4 A.B.C.D/M longer-prefixes", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11567 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11568 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11569 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11570 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11571 | "Display route and more specific routes\n") |
| 11572 | { |
| 11573 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11574 | bgp_show_type_prefix_longer); |
| 11575 | } |
| 11576 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11577 | DEFUN (show_bgp_ipv4_safi_flap_prefix_longer, |
| 11578 | show_bgp_ipv4_safi_flap_prefix_longer_cmd, |
| 11579 | "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] | 11580 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11581 | BGP_STR |
| 11582 | "Address family\n" |
| 11583 | "Address Family modifier\n" |
| 11584 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11585 | "Address Family modifier\n" |
| 11586 | "Address Family modifier\n" |
| 11587 | "Display flap statistics of routes\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11588 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11589 | "Display route and more specific routes\n") |
| 11590 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11591 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11592 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11593 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11594 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11595 | return CMD_WARNING; |
| 11596 | } |
| 11597 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11598 | bgp_show_type_flap_prefix_longer); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11599 | } |
| 11600 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11601 | ALIAS (show_bgp_ipv4_safi_flap_prefix_longer, |
| 11602 | show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd, |
| 11603 | "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] | 11604 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11605 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11606 | "Address family\n" |
| 11607 | "Address Family modifier\n" |
| 11608 | "Address Family modifier\n" |
| 11609 | "Address Family modifier\n" |
| 11610 | "Address Family modifier\n" |
| 11611 | "Display detailed information about dampening\n" |
| 11612 | "Display flap statistics of routes\n" |
| 11613 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11614 | "Display route and more specific routes\n") |
| 11615 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11616 | DEFUN (show_bgp_ipv6_safi_flap_prefix_longer, |
| 11617 | show_bgp_ipv6_safi_flap_prefix_longer_cmd, |
| 11618 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes", |
| 11619 | SHOW_STR |
| 11620 | BGP_STR |
| 11621 | "Address family\n" |
| 11622 | "Address Family modifier\n" |
| 11623 | "Address Family modifier\n" |
| 11624 | "Address Family modifier\n" |
| 11625 | "Address Family modifier\n" |
| 11626 | "Display flap statistics of routes\n" |
| 11627 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11628 | "Display route and more specific routes\n") |
| 11629 | { |
| 11630 | safi_t safi; |
| 11631 | |
| 11632 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11633 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11634 | return CMD_WARNING; |
| 11635 | } |
| 11636 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi, |
| 11637 | bgp_show_type_flap_prefix_longer); |
| 11638 | } |
| 11639 | ALIAS (show_bgp_ipv6_safi_flap_prefix_longer, |
| 11640 | show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd, |
| 11641 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes", |
| 11642 | SHOW_STR |
| 11643 | BGP_STR |
| 11644 | "Address family\n" |
| 11645 | "Address Family modifier\n" |
| 11646 | "Address Family modifier\n" |
| 11647 | "Address Family modifier\n" |
| 11648 | "Address Family modifier\n" |
| 11649 | "Display detailed information about dampening\n" |
| 11650 | "Display flap statistics of routes\n" |
| 11651 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11652 | "Display route and more specific routes\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11653 | |
| 11654 | DEFUN (show_bgp_ipv4_safi_prefix_longer, |
| 11655 | show_bgp_ipv4_safi_prefix_longer_cmd, |
| 11656 | "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes", |
| 11657 | SHOW_STR |
| 11658 | BGP_STR |
| 11659 | "Address family\n" |
| 11660 | "Address Family modifier\n" |
| 11661 | "Address Family modifier\n" |
| 11662 | "Address Family modifier\n" |
| 11663 | "Address Family modifier\n" |
| 11664 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11665 | "Display route and more specific routes\n") |
| 11666 | { |
| 11667 | safi_t safi; |
| 11668 | |
| 11669 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11670 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11671 | return CMD_WARNING; |
| 11672 | } |
| 11673 | |
| 11674 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11675 | bgp_show_type_prefix_longer); |
| 11676 | } |
| 11677 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11678 | DEFUN (show_bgp_ipv6_safi_prefix_longer, |
| 11679 | show_bgp_ipv6_safi_prefix_longer_cmd, |
| 11680 | "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes", |
| 11681 | SHOW_STR |
| 11682 | BGP_STR |
| 11683 | "Address family\n" |
| 11684 | "Address Family modifier\n" |
| 11685 | "Address Family modifier\n" |
| 11686 | "Address Family modifier\n" |
| 11687 | "Address Family modifier\n" |
| 11688 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11689 | "Display route and more specific routes\n") |
| 11690 | { |
| 11691 | safi_t safi; |
| 11692 | |
| 11693 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11694 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11695 | return CMD_WARNING; |
| 11696 | } |
| 11697 | |
| 11698 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi, |
| 11699 | bgp_show_type_prefix_longer); |
| 11700 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11701 | |
| 11702 | DEFUN (show_bgp_ipv4_safi_flap_address, |
| 11703 | show_bgp_ipv4_safi_flap_address_cmd, |
| 11704 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D", |
| 11705 | SHOW_STR |
| 11706 | BGP_STR |
| 11707 | "Address family\n" |
| 11708 | "Address Family modifier\n" |
| 11709 | "Address Family modifier\n" |
| 11710 | "Address Family modifier\n" |
| 11711 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11712 | "Display flap statistics of routes\n" |
| 11713 | "Network in the BGP routing table to display\n") |
| 11714 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11715 | safi_t safi; |
| 11716 | |
| 11717 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11718 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11719 | return CMD_WARNING; |
| 11720 | } |
| 11721 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11722 | bgp_show_type_flap_address); |
| 11723 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11724 | ALIAS (show_bgp_ipv4_safi_flap_address, |
| 11725 | show_bgp_ipv4_safi_damp_flap_address_cmd, |
| 11726 | "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] | 11727 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11728 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11729 | "Address family\n" |
| 11730 | "Address Family modifier\n" |
| 11731 | "Address Family modifier\n" |
| 11732 | "Address Family modifier\n" |
| 11733 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11734 | "Display detailed information about dampening\n" |
| 11735 | "Display flap statistics of routes\n" |
| 11736 | "Network in the BGP routing table to display\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 11737 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11738 | DEFUN (show_bgp_ipv6_flap_address, |
| 11739 | show_bgp_ipv6_flap_address_cmd, |
| 11740 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11741 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11742 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11743 | "Address family\n" |
| 11744 | "Address Family modifier\n" |
| 11745 | "Address Family modifier\n" |
| 11746 | "Address Family modifier\n" |
| 11747 | "Address Family modifier\n" |
| 11748 | "Display flap statistics of routes\n" |
| 11749 | "Network in the BGP routing table to display\n") |
| 11750 | { |
| 11751 | safi_t safi; |
| 11752 | |
| 11753 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11754 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11755 | return CMD_WARNING; |
| 11756 | } |
| 11757 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11758 | bgp_show_type_flap_address); |
| 11759 | } |
| 11760 | ALIAS (show_bgp_ipv6_flap_address, |
| 11761 | show_bgp_ipv6_damp_flap_address_cmd, |
| 11762 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D", |
| 11763 | SHOW_STR |
| 11764 | BGP_STR |
| 11765 | "Address family\n" |
| 11766 | "Address Family modifier\n" |
| 11767 | "Address Family modifier\n" |
| 11768 | "Address Family modifier\n" |
| 11769 | "Address Family modifier\n" |
| 11770 | "Display detailed information about dampening\n" |
| 11771 | "Display flap statistics of routes\n" |
| 11772 | "Network in the BGP routing table to display\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11773 | |
| 11774 | DEFUN (show_bgp_ipv4_safi_flap_prefix, |
| 11775 | show_bgp_ipv4_safi_flap_prefix_cmd, |
| 11776 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M", |
| 11777 | SHOW_STR |
| 11778 | BGP_STR |
| 11779 | "Address family\n" |
| 11780 | "Address Family modifier\n" |
| 11781 | "Address Family modifier\n" |
| 11782 | "Address Family modifier\n" |
| 11783 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11784 | "Display flap statistics of routes\n" |
| 11785 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11786 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11787 | safi_t safi; |
| 11788 | |
| 11789 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11790 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11791 | return CMD_WARNING; |
| 11792 | } |
| 11793 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11794 | bgp_show_type_flap_prefix); |
| 11795 | } |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11796 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11797 | ALIAS (show_bgp_ipv4_safi_flap_prefix, |
| 11798 | show_bgp_ipv4_safi_damp_flap_prefix_cmd, |
| 11799 | "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] | 11800 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11801 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11802 | "Address family\n" |
| 11803 | "Address Family modifier\n" |
| 11804 | "Address Family modifier\n" |
| 11805 | "Address Family modifier\n" |
| 11806 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11807 | "Display detailed information about dampening\n" |
| 11808 | "Display flap statistics of routes\n" |
| 11809 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11810 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11811 | DEFUN (show_bgp_ipv6_safi_flap_prefix, |
| 11812 | show_bgp_ipv6_safi_flap_prefix_cmd, |
| 11813 | "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] | 11814 | SHOW_STR |
| 11815 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11816 | "Address family\n" |
| 11817 | "Address Family modifier\n" |
| 11818 | "Address Family modifier\n" |
| 11819 | "Address Family modifier\n" |
| 11820 | "Address Family modifier\n" |
| 11821 | "Display flap statistics of routes\n" |
| 11822 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11823 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11824 | safi_t safi; |
| 11825 | |
| 11826 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11827 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11828 | return CMD_WARNING; |
| 11829 | } |
| 11830 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi, |
| 11831 | bgp_show_type_flap_prefix); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11832 | } |
| 11833 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11834 | ALIAS (show_bgp_ipv6_safi_flap_prefix, |
| 11835 | show_bgp_ipv6_safi_damp_flap_prefix_cmd, |
| 11836 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M", |
| 11837 | SHOW_STR |
| 11838 | BGP_STR |
| 11839 | "Address family\n" |
| 11840 | "Address Family modifier\n" |
| 11841 | "Address Family modifier\n" |
| 11842 | "Address Family modifier\n" |
| 11843 | "Address Family modifier\n" |
| 11844 | "Display detailed information about dampening\n" |
| 11845 | "Display flap statistics of routes\n" |
| 11846 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11847 | |
| 11848 | DEFUN (show_bgp_ipv6_prefix_longer, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11849 | show_bgp_ipv6_prefix_longer_cmd, |
| 11850 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 11851 | SHOW_STR |
| 11852 | BGP_STR |
| 11853 | "Address family\n" |
| 11854 | "IPv6 prefix <network>/<length>\n" |
| 11855 | "Display route and more specific routes\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11856 | { |
| 11857 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11858 | bgp_show_type_prefix_longer); |
| 11859 | } |
| 11860 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11861 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11862 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 11863 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11864 | { |
| 11865 | int ret; |
| 11866 | struct bgp *bgp; |
| 11867 | struct peer *peer; |
| 11868 | union sockunion su; |
| 11869 | |
| 11870 | /* BGP structure lookup. */ |
| 11871 | if (view_name) |
| 11872 | { |
| 11873 | bgp = bgp_lookup_by_name (view_name); |
| 11874 | if (! bgp) |
| 11875 | { |
| 11876 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 11877 | return NULL; |
| 11878 | } |
| 11879 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 11880 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11881 | { |
| 11882 | bgp = bgp_get_default (); |
| 11883 | if (! bgp) |
| 11884 | { |
| 11885 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11886 | return NULL; |
| 11887 | } |
| 11888 | } |
| 11889 | |
| 11890 | /* Get peer sockunion. */ |
| 11891 | ret = str2sockunion (ip_str, &su); |
| 11892 | if (ret < 0) |
| 11893 | { |
| 11894 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 11895 | return NULL; |
| 11896 | } |
| 11897 | |
| 11898 | /* Peer structure lookup. */ |
| 11899 | peer = peer_lookup (bgp, &su); |
| 11900 | if (! peer) |
| 11901 | { |
| 11902 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 11903 | return NULL; |
| 11904 | } |
| 11905 | |
| 11906 | return peer; |
| 11907 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11908 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11909 | enum bgp_stats |
| 11910 | { |
| 11911 | BGP_STATS_MAXBITLEN = 0, |
| 11912 | BGP_STATS_RIB, |
| 11913 | BGP_STATS_PREFIXES, |
| 11914 | BGP_STATS_TOTPLEN, |
| 11915 | BGP_STATS_UNAGGREGATEABLE, |
| 11916 | BGP_STATS_MAX_AGGREGATEABLE, |
| 11917 | BGP_STATS_AGGREGATES, |
| 11918 | BGP_STATS_SPACE, |
| 11919 | BGP_STATS_ASPATH_COUNT, |
| 11920 | BGP_STATS_ASPATH_MAXHOPS, |
| 11921 | BGP_STATS_ASPATH_TOTHOPS, |
| 11922 | BGP_STATS_ASPATH_MAXSIZE, |
| 11923 | BGP_STATS_ASPATH_TOTSIZE, |
| 11924 | BGP_STATS_ASN_HIGHEST, |
| 11925 | BGP_STATS_MAX, |
| 11926 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11927 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11928 | static const char *table_stats_strs[] = |
| 11929 | { |
| 11930 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 11931 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 11932 | [BGP_STATS_RIB] = "Total Advertisements", |
| 11933 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 11934 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 11935 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 11936 | [BGP_STATS_SPACE] = "Address space advertised", |
| 11937 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 11938 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 11939 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 11940 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 11941 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 11942 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 11943 | [BGP_STATS_MAX] = NULL, |
| 11944 | }; |
| 11945 | |
| 11946 | struct bgp_table_stats |
| 11947 | { |
| 11948 | struct bgp_table *table; |
| 11949 | unsigned long long counts[BGP_STATS_MAX]; |
| 11950 | }; |
| 11951 | |
| 11952 | #if 0 |
| 11953 | #define TALLY_SIGFIG 100000 |
| 11954 | static unsigned long |
| 11955 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 11956 | { |
| 11957 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 11958 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 11959 | unsigned long ret = newtot / count; |
| 11960 | |
| 11961 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 11962 | return ret + 1; |
| 11963 | else |
| 11964 | return ret; |
| 11965 | } |
| 11966 | #endif |
| 11967 | |
| 11968 | static int |
| 11969 | bgp_table_stats_walker (struct thread *t) |
| 11970 | { |
| 11971 | struct bgp_node *rn; |
| 11972 | struct bgp_node *top; |
| 11973 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 11974 | unsigned int space = 0; |
| 11975 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 11976 | if (!(top = bgp_table_top (ts->table))) |
| 11977 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11978 | |
| 11979 | switch (top->p.family) |
| 11980 | { |
| 11981 | case AF_INET: |
| 11982 | space = IPV4_MAX_BITLEN; |
| 11983 | break; |
| 11984 | case AF_INET6: |
| 11985 | space = IPV6_MAX_BITLEN; |
| 11986 | break; |
| 11987 | } |
| 11988 | |
| 11989 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 11990 | |
| 11991 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 11992 | { |
| 11993 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 11994 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11995 | unsigned int rinum = 0; |
| 11996 | |
| 11997 | if (rn == top) |
| 11998 | continue; |
| 11999 | |
| 12000 | if (!rn->info) |
| 12001 | continue; |
| 12002 | |
| 12003 | ts->counts[BGP_STATS_PREFIXES]++; |
| 12004 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 12005 | |
| 12006 | #if 0 |
| 12007 | ts->counts[BGP_STATS_AVGPLEN] |
| 12008 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 12009 | ts->counts[BGP_STATS_AVGPLEN], |
| 12010 | rn->p.prefixlen); |
| 12011 | #endif |
| 12012 | |
| 12013 | /* check if the prefix is included by any other announcements */ |
| 12014 | while (prn && !prn->info) |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 12015 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12016 | |
| 12017 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 12018 | { |
| 12019 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 12020 | /* announced address space */ |
| 12021 | if (space) |
| 12022 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 12023 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12024 | else if (prn->info) |
| 12025 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 12026 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12027 | for (ri = rn->info; ri; ri = ri->next) |
| 12028 | { |
| 12029 | rinum++; |
| 12030 | ts->counts[BGP_STATS_RIB]++; |
| 12031 | |
| 12032 | if (ri->attr && |
| 12033 | (CHECK_FLAG (ri->attr->flag, |
| 12034 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 12035 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 12036 | |
| 12037 | /* as-path stats */ |
| 12038 | if (ri->attr && ri->attr->aspath) |
| 12039 | { |
| 12040 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 12041 | unsigned int size = aspath_size (ri->attr->aspath); |
| 12042 | as_t highest = aspath_highest (ri->attr->aspath); |
| 12043 | |
| 12044 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 12045 | |
| 12046 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 12047 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 12048 | |
| 12049 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 12050 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 12051 | |
| 12052 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 12053 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 12054 | #if 0 |
| 12055 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 12056 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 12057 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 12058 | hops); |
| 12059 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 12060 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 12061 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 12062 | size); |
| 12063 | #endif |
| 12064 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 12065 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 12066 | } |
| 12067 | } |
| 12068 | } |
| 12069 | return 0; |
| 12070 | } |
| 12071 | |
| 12072 | static int |
| 12073 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 12074 | { |
| 12075 | struct bgp_table_stats ts; |
| 12076 | unsigned int i; |
| 12077 | |
| 12078 | if (!bgp->rib[afi][safi]) |
| 12079 | { |
Donald Sharp | 3c96404 | 2016-01-25 23:38:53 -0500 | [diff] [blame] | 12080 | vty_out (vty, "%% No RIB exists for the specified AFI(%d)/SAFI(%d) %s", |
| 12081 | afi, safi, VTY_NEWLINE); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12082 | return CMD_WARNING; |
| 12083 | } |
| 12084 | |
| 12085 | memset (&ts, 0, sizeof (ts)); |
| 12086 | ts.table = bgp->rib[afi][safi]; |
| 12087 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 12088 | |
| 12089 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 12090 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 12091 | |
| 12092 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 12093 | { |
| 12094 | if (!table_stats_strs[i]) |
| 12095 | continue; |
| 12096 | |
| 12097 | switch (i) |
| 12098 | { |
| 12099 | #if 0 |
| 12100 | case BGP_STATS_ASPATH_AVGHOPS: |
| 12101 | case BGP_STATS_ASPATH_AVGSIZE: |
| 12102 | case BGP_STATS_AVGPLEN: |
| 12103 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12104 | vty_out (vty, "%12.2f", |
| 12105 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 12106 | break; |
| 12107 | #endif |
| 12108 | case BGP_STATS_ASPATH_TOTHOPS: |
| 12109 | case BGP_STATS_ASPATH_TOTSIZE: |
| 12110 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12111 | vty_out (vty, "%12.2f", |
| 12112 | ts.counts[i] ? |
| 12113 | (float)ts.counts[i] / |
| 12114 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 12115 | : 0); |
| 12116 | break; |
| 12117 | case BGP_STATS_TOTPLEN: |
| 12118 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12119 | vty_out (vty, "%12.2f", |
| 12120 | ts.counts[i] ? |
| 12121 | (float)ts.counts[i] / |
| 12122 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 12123 | : 0); |
| 12124 | break; |
| 12125 | case BGP_STATS_SPACE: |
| 12126 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12127 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 12128 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 12129 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 12130 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12131 | vty_out (vty, "%12.2f%s", |
| 12132 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 12133 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12134 | VTY_NEWLINE); |
| 12135 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 12136 | vty_out (vty, "%12.2f%s", |
| 12137 | (float)ts.counts[BGP_STATS_SPACE] / |
| 12138 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 12139 | VTY_NEWLINE); |
| 12140 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 12141 | break; |
| 12142 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 12143 | vty_out (vty, "%12.2f", |
| 12144 | (float)ts.counts[BGP_STATS_SPACE] / |
| 12145 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 12146 | break; |
| 12147 | default: |
| 12148 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12149 | vty_out (vty, "%12llu", ts.counts[i]); |
| 12150 | } |
| 12151 | |
| 12152 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12153 | } |
| 12154 | return CMD_SUCCESS; |
| 12155 | } |
| 12156 | |
| 12157 | static int |
| 12158 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 12159 | const char *afi_str, const char *safi_str) |
| 12160 | { |
| 12161 | struct bgp *bgp; |
| 12162 | afi_t afi; |
| 12163 | safi_t safi; |
| 12164 | |
| 12165 | if (name) |
| 12166 | bgp = bgp_lookup_by_name (name); |
| 12167 | else |
| 12168 | bgp = bgp_get_default (); |
| 12169 | |
| 12170 | if (!bgp) |
| 12171 | { |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 12172 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12173 | return CMD_WARNING; |
| 12174 | } |
| 12175 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 12176 | { |
| 12177 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 12178 | afi = AFI_IP; |
| 12179 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 12180 | afi = AFI_IP6; |
| 12181 | else |
| 12182 | { |
| 12183 | vty_out (vty, "%% Invalid address family %s%s", |
| 12184 | afi_str, VTY_NEWLINE); |
| 12185 | return CMD_WARNING; |
| 12186 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12187 | switch (safi_str[0]) { |
| 12188 | case 'm': |
| 12189 | safi = SAFI_MULTICAST; |
| 12190 | break; |
| 12191 | case 'u': |
| 12192 | safi = SAFI_UNICAST; |
| 12193 | break; |
| 12194 | case 'v': |
Donald Sharp | 3c96404 | 2016-01-25 23:38:53 -0500 | [diff] [blame] | 12195 | safi = SAFI_MPLS_VPN; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12196 | break; |
| 12197 | case 'e': |
| 12198 | safi = SAFI_ENCAP; |
| 12199 | break; |
| 12200 | default: |
| 12201 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12202 | safi_str, VTY_NEWLINE); |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12203 | return CMD_WARNING; |
| 12204 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12205 | } |
| 12206 | else |
| 12207 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12208 | vty_out (vty, "%% Invalid address family \"%s\"%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12209 | afi_str, VTY_NEWLINE); |
| 12210 | return CMD_WARNING; |
| 12211 | } |
| 12212 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12213 | return bgp_table_stats (vty, bgp, afi, safi); |
| 12214 | } |
| 12215 | |
| 12216 | DEFUN (show_bgp_statistics, |
| 12217 | show_bgp_statistics_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12218 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12219 | SHOW_STR |
| 12220 | BGP_STR |
| 12221 | "Address family\n" |
| 12222 | "Address family\n" |
| 12223 | "Address Family modifier\n" |
| 12224 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12225 | "Address Family modifier\n" |
| 12226 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12227 | "BGP RIB advertisement statistics\n") |
| 12228 | { |
| 12229 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 12230 | } |
| 12231 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12232 | ALIAS (show_bgp_statistics, |
| 12233 | show_bgp_statistics_vpnv4_cmd, |
| 12234 | "show bgp (ipv4) (vpnv4) statistics", |
| 12235 | SHOW_STR |
| 12236 | BGP_STR |
| 12237 | "Address family\n" |
| 12238 | "Address Family modifier\n" |
| 12239 | "BGP RIB advertisement statistics\n") |
| 12240 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12241 | DEFUN (show_bgp_statistics_view, |
| 12242 | show_bgp_statistics_view_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12243 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12244 | SHOW_STR |
| 12245 | BGP_STR |
| 12246 | "BGP view\n" |
| 12247 | "Address family\n" |
| 12248 | "Address family\n" |
| 12249 | "Address Family modifier\n" |
| 12250 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12251 | "Address Family modifier\n" |
| 12252 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12253 | "BGP RIB advertisement statistics\n") |
| 12254 | { |
| 12255 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 12256 | } |
| 12257 | |
| 12258 | ALIAS (show_bgp_statistics_view, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12259 | show_bgp_statistics_view_vpnv4_cmd, |
| 12260 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12261 | SHOW_STR |
| 12262 | BGP_STR |
| 12263 | "BGP view\n" |
| 12264 | "Address family\n" |
| 12265 | "Address Family modifier\n" |
| 12266 | "BGP RIB advertisement statistics\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12267 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12268 | enum bgp_pcounts |
| 12269 | { |
| 12270 | PCOUNT_ADJ_IN = 0, |
| 12271 | PCOUNT_DAMPED, |
| 12272 | PCOUNT_REMOVED, |
| 12273 | PCOUNT_HISTORY, |
| 12274 | PCOUNT_STALE, |
| 12275 | PCOUNT_VALID, |
| 12276 | PCOUNT_ALL, |
| 12277 | PCOUNT_COUNTED, |
| 12278 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 12279 | PCOUNT_MAX, |
| 12280 | }; |
| 12281 | |
| 12282 | static const char *pcount_strs[] = |
| 12283 | { |
| 12284 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 12285 | [PCOUNT_DAMPED] = "Damped", |
| 12286 | [PCOUNT_REMOVED] = "Removed", |
| 12287 | [PCOUNT_HISTORY] = "History", |
| 12288 | [PCOUNT_STALE] = "Stale", |
| 12289 | [PCOUNT_VALID] = "Valid", |
| 12290 | [PCOUNT_ALL] = "All RIB", |
| 12291 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 12292 | [PCOUNT_PFCNT] = "Useable", |
| 12293 | [PCOUNT_MAX] = NULL, |
| 12294 | }; |
| 12295 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12296 | struct peer_pcounts |
| 12297 | { |
| 12298 | unsigned int count[PCOUNT_MAX]; |
| 12299 | const struct peer *peer; |
| 12300 | const struct bgp_table *table; |
| 12301 | }; |
| 12302 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12303 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12304 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12305 | { |
| 12306 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12307 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 12308 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12309 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12310 | 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] | 12311 | { |
| 12312 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12313 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12314 | |
| 12315 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 12316 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12317 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12318 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12319 | for (ri = rn->info; ri; ri = ri->next) |
| 12320 | { |
| 12321 | char buf[SU_ADDRSTRLEN]; |
| 12322 | |
| 12323 | if (ri->peer != peer) |
| 12324 | continue; |
| 12325 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12326 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12327 | |
| 12328 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12329 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12330 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12331 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12332 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12333 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12334 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12335 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12336 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12337 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12338 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12339 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12340 | |
| 12341 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 12342 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12343 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12344 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12345 | plog_warn (peer->log, |
| 12346 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 12347 | peer->host, |
| 12348 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 12349 | buf, SU_ADDRSTRLEN), |
| 12350 | rn->p.prefixlen, |
| 12351 | ri->flags); |
| 12352 | } |
| 12353 | else |
| 12354 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12355 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12356 | plog_warn (peer->log, |
| 12357 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 12358 | peer->host, |
| 12359 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 12360 | buf, SU_ADDRSTRLEN), |
| 12361 | rn->p.prefixlen, |
| 12362 | ri->flags); |
| 12363 | } |
| 12364 | } |
| 12365 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12366 | return 0; |
| 12367 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12368 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12369 | static int |
| 12370 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 12371 | { |
| 12372 | struct peer_pcounts pcounts = { .peer = peer }; |
| 12373 | unsigned int i; |
| 12374 | |
| 12375 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 12376 | || !peer->bgp->rib[afi][safi]) |
| 12377 | { |
| 12378 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 12379 | return CMD_WARNING; |
| 12380 | } |
| 12381 | |
| 12382 | memset (&pcounts, 0, sizeof(pcounts)); |
| 12383 | pcounts.peer = peer; |
| 12384 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 12385 | |
| 12386 | /* in-place call via thread subsystem so as to record execution time |
| 12387 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 12388 | * on just vty_read()). |
| 12389 | */ |
| 12390 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 12391 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12392 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 12393 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 12394 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 12395 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 12396 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 12397 | |
| 12398 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12399 | vty_out (vty, "%20s: %-10d%s", |
| 12400 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12401 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12402 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12403 | { |
| 12404 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 12405 | peer->host, VTY_NEWLINE); |
| 12406 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 12407 | VTY_NEWLINE); |
| 12408 | } |
| 12409 | |
| 12410 | return CMD_SUCCESS; |
| 12411 | } |
| 12412 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12413 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 12414 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 12415 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12416 | SHOW_STR |
| 12417 | IP_STR |
| 12418 | BGP_STR |
| 12419 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12420 | "Neighbor to display information about\n" |
| 12421 | "Neighbor to display information about\n" |
| 12422 | "Display detailed prefix count information\n") |
| 12423 | { |
| 12424 | struct peer *peer; |
| 12425 | |
| 12426 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12427 | if (! peer) |
| 12428 | return CMD_WARNING; |
| 12429 | |
| 12430 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 12431 | } |
| 12432 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12433 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 12434 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 12435 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12436 | SHOW_STR |
| 12437 | BGP_STR |
| 12438 | "Address family\n" |
| 12439 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12440 | "Neighbor to display information about\n" |
| 12441 | "Neighbor to display information about\n" |
| 12442 | "Display detailed prefix count information\n") |
| 12443 | { |
| 12444 | struct peer *peer; |
| 12445 | |
| 12446 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12447 | if (! peer) |
| 12448 | return CMD_WARNING; |
| 12449 | |
| 12450 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 12451 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12452 | |
| 12453 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 12454 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 12455 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12456 | SHOW_STR |
| 12457 | IP_STR |
| 12458 | BGP_STR |
| 12459 | "Address family\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 | |
| 12469 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12470 | if (! peer) |
| 12471 | return CMD_WARNING; |
| 12472 | |
| 12473 | if (strncmp (argv[0], "m", 1) == 0) |
| 12474 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 12475 | |
| 12476 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 12477 | } |
| 12478 | |
| 12479 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 12480 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 12481 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12482 | SHOW_STR |
| 12483 | IP_STR |
| 12484 | BGP_STR |
| 12485 | "Address family\n" |
| 12486 | "Address Family modifier\n" |
| 12487 | "Address Family modifier\n" |
| 12488 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12489 | "Neighbor to display information about\n" |
| 12490 | "Neighbor to display information about\n" |
| 12491 | "Display detailed prefix count information\n") |
| 12492 | { |
| 12493 | struct peer *peer; |
| 12494 | |
| 12495 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12496 | if (! peer) |
| 12497 | return CMD_WARNING; |
| 12498 | |
| 12499 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 12500 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12501 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12502 | DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts, |
| 12503 | show_bgp_ipv4_safi_neighbor_prefix_counts_cmd, |
| 12504 | "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] | 12505 | SHOW_STR |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12506 | BGP_STR |
| 12507 | "Address family\n" |
| 12508 | "Address Family modifier\n" |
| 12509 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12510 | "Address Family modifier\n" |
| 12511 | "Address Family modifier\n" |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12512 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12513 | "Neighbor to display information about\n" |
| 12514 | "Neighbor to display information about\n" |
| 12515 | "Display detailed prefix count information\n") |
| 12516 | { |
| 12517 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12518 | safi_t safi; |
| 12519 | |
| 12520 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12521 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12522 | return CMD_WARNING; |
| 12523 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12524 | |
| 12525 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12526 | if (! peer) |
| 12527 | return CMD_WARNING; |
| 12528 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12529 | return bgp_peer_counts (vty, peer, AFI_IP, safi); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12530 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 12531 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12532 | DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts, |
| 12533 | show_bgp_ipv6_safi_neighbor_prefix_counts_cmd, |
| 12534 | "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12535 | SHOW_STR |
| 12536 | BGP_STR |
| 12537 | "Address family\n" |
| 12538 | "Address Family modifier\n" |
| 12539 | "Address Family modifier\n" |
| 12540 | "Address Family modifier\n" |
| 12541 | "Address Family modifier\n" |
| 12542 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12543 | "Neighbor to display information about\n" |
| 12544 | "Neighbor to display information about\n" |
| 12545 | "Display detailed prefix count information\n") |
| 12546 | { |
| 12547 | struct peer *peer; |
| 12548 | safi_t safi; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12549 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12550 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12551 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12552 | return CMD_WARNING; |
| 12553 | } |
| 12554 | |
| 12555 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12556 | if (! peer) |
| 12557 | return CMD_WARNING; |
| 12558 | |
| 12559 | return bgp_peer_counts (vty, peer, AFI_IP6, safi); |
| 12560 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12561 | |
| 12562 | DEFUN (show_ip_bgp_encap_neighbor_prefix_counts, |
| 12563 | show_ip_bgp_encap_neighbor_prefix_counts_cmd, |
| 12564 | "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] | 12565 | SHOW_STR |
| 12566 | IP_STR |
| 12567 | BGP_STR |
| 12568 | "Address family\n" |
| 12569 | "Address Family modifier\n" |
| 12570 | "Address Family modifier\n" |
| 12571 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12572 | "Neighbor to display information about\n" |
| 12573 | "Neighbor to display information about\n" |
| 12574 | "Display detailed prefix count information\n") |
| 12575 | { |
| 12576 | struct peer *peer; |
| 12577 | |
| 12578 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12579 | if (! peer) |
| 12580 | return CMD_WARNING; |
| 12581 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12582 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12583 | } |
| 12584 | |
| 12585 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12586 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12587 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 12588 | int in) |
| 12589 | { |
| 12590 | struct bgp_table *table; |
| 12591 | struct bgp_adj_in *ain; |
| 12592 | struct bgp_adj_out *adj; |
| 12593 | unsigned long output_count; |
| 12594 | struct bgp_node *rn; |
| 12595 | int header1 = 1; |
| 12596 | struct bgp *bgp; |
| 12597 | int header2 = 1; |
| 12598 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12599 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12600 | |
| 12601 | if (! bgp) |
| 12602 | return; |
| 12603 | |
| 12604 | table = bgp->rib[afi][safi]; |
| 12605 | |
| 12606 | output_count = 0; |
| 12607 | |
| 12608 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 12609 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 12610 | { |
| 12611 | 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] | 12612 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12613 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12614 | |
| 12615 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 12616 | VTY_NEWLINE, VTY_NEWLINE); |
| 12617 | header1 = 0; |
| 12618 | } |
| 12619 | |
| 12620 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12621 | if (in) |
| 12622 | { |
| 12623 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 12624 | if (ain->peer == peer) |
| 12625 | { |
| 12626 | if (header1) |
| 12627 | { |
| 12628 | 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] | 12629 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12630 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12631 | header1 = 0; |
| 12632 | } |
| 12633 | if (header2) |
| 12634 | { |
| 12635 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 12636 | header2 = 0; |
| 12637 | } |
| 12638 | if (ain->attr) |
| 12639 | { |
| 12640 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 12641 | output_count++; |
| 12642 | } |
| 12643 | } |
| 12644 | } |
| 12645 | else |
| 12646 | { |
| 12647 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 12648 | if (adj->peer == peer) |
| 12649 | { |
| 12650 | if (header1) |
| 12651 | { |
| 12652 | 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] | 12653 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12654 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12655 | header1 = 0; |
| 12656 | } |
| 12657 | if (header2) |
| 12658 | { |
| 12659 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 12660 | header2 = 0; |
| 12661 | } |
| 12662 | if (adj->attr) |
| 12663 | { |
| 12664 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 12665 | output_count++; |
| 12666 | } |
| 12667 | } |
| 12668 | } |
| 12669 | |
| 12670 | if (output_count != 0) |
| 12671 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 12672 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 12673 | } |
| 12674 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12675 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12676 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 12677 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12678 | if (! peer || ! peer->afc[afi][safi]) |
| 12679 | { |
| 12680 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 12681 | return CMD_WARNING; |
| 12682 | } |
| 12683 | |
| 12684 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 12685 | { |
| 12686 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 12687 | VTY_NEWLINE); |
| 12688 | return CMD_WARNING; |
| 12689 | } |
| 12690 | |
| 12691 | show_adj_route (vty, peer, afi, safi, in); |
| 12692 | |
| 12693 | return CMD_SUCCESS; |
| 12694 | } |
| 12695 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12696 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 12697 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 12698 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12699 | SHOW_STR |
| 12700 | IP_STR |
| 12701 | BGP_STR |
| 12702 | "BGP view\n" |
| 12703 | "View name\n" |
| 12704 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12705 | "Neighbor to display information about\n" |
| 12706 | "Neighbor to display information about\n" |
| 12707 | "Display the routes advertised to a BGP neighbor\n") |
| 12708 | { |
| 12709 | struct peer *peer; |
| 12710 | |
| 12711 | if (argc == 2) |
| 12712 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12713 | else |
| 12714 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12715 | |
| 12716 | if (! peer) |
| 12717 | return CMD_WARNING; |
| 12718 | |
| 12719 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 12720 | } |
| 12721 | |
| 12722 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
| 12723 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 12724 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12725 | SHOW_STR |
| 12726 | IP_STR |
| 12727 | BGP_STR |
| 12728 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12729 | "Neighbor to display information about\n" |
| 12730 | "Neighbor to display information about\n" |
| 12731 | "Display the routes advertised to a BGP neighbor\n") |
| 12732 | |
| 12733 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 12734 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 12735 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12736 | SHOW_STR |
| 12737 | IP_STR |
| 12738 | BGP_STR |
| 12739 | "Address family\n" |
| 12740 | "Address Family modifier\n" |
| 12741 | "Address Family modifier\n" |
| 12742 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12743 | "Neighbor to display information about\n" |
| 12744 | "Neighbor to display information about\n" |
| 12745 | "Display the routes advertised to a BGP neighbor\n") |
| 12746 | { |
| 12747 | struct peer *peer; |
| 12748 | |
| 12749 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12750 | if (! peer) |
| 12751 | return CMD_WARNING; |
| 12752 | |
| 12753 | if (strncmp (argv[0], "m", 1) == 0) |
| 12754 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 12755 | |
| 12756 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 12757 | } |
| 12758 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12759 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 12760 | show_bgp_view_neighbor_advertised_route_cmd, |
| 12761 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12762 | SHOW_STR |
| 12763 | BGP_STR |
| 12764 | "BGP view\n" |
| 12765 | "View name\n" |
| 12766 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12767 | "Neighbor to display information about\n" |
| 12768 | "Neighbor to display information about\n" |
| 12769 | "Display the routes advertised to a BGP neighbor\n") |
| 12770 | { |
| 12771 | struct peer *peer; |
| 12772 | |
| 12773 | if (argc == 2) |
| 12774 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12775 | else |
| 12776 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12777 | |
| 12778 | if (! peer) |
| 12779 | return CMD_WARNING; |
| 12780 | |
| 12781 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 12782 | } |
| 12783 | |
| 12784 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 12785 | show_bgp_view_neighbor_received_routes_cmd, |
| 12786 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12787 | SHOW_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_IP6, SAFI_UNICAST, 1); |
| 12807 | } |
| 12808 | |
| 12809 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12810 | show_bgp_neighbor_advertised_route_cmd, |
| 12811 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12812 | SHOW_STR |
| 12813 | BGP_STR |
| 12814 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12815 | "Neighbor to display information about\n" |
| 12816 | "Neighbor to display information about\n" |
| 12817 | "Display the routes advertised to a BGP neighbor\n") |
| 12818 | |
| 12819 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12820 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 12821 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12822 | SHOW_STR |
| 12823 | BGP_STR |
| 12824 | "Address family\n" |
| 12825 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12826 | "Neighbor to display information about\n" |
| 12827 | "Neighbor to display information about\n" |
| 12828 | "Display the routes advertised to a BGP neighbor\n") |
| 12829 | |
| 12830 | /* old command */ |
| 12831 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12832 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 12833 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12834 | SHOW_STR |
| 12835 | IPV6_STR |
| 12836 | BGP_STR |
| 12837 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12838 | "Neighbor to display information about\n" |
| 12839 | "Neighbor to display information about\n" |
| 12840 | "Display the routes advertised to a BGP neighbor\n") |
| 12841 | |
| 12842 | /* old command */ |
| 12843 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 12844 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 12845 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12846 | SHOW_STR |
| 12847 | IPV6_STR |
| 12848 | MBGP_STR |
| 12849 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12850 | "Neighbor to display information about\n" |
| 12851 | "Neighbor to display information about\n" |
| 12852 | "Display the routes advertised to a BGP neighbor\n") |
| 12853 | { |
| 12854 | struct peer *peer; |
| 12855 | |
| 12856 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12857 | if (! peer) |
| 12858 | return CMD_WARNING; |
| 12859 | |
| 12860 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
| 12861 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12862 | |
| 12863 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 12864 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 12865 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12866 | SHOW_STR |
| 12867 | IP_STR |
| 12868 | BGP_STR |
| 12869 | "BGP view\n" |
| 12870 | "View name\n" |
| 12871 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12872 | "Neighbor to display information about\n" |
| 12873 | "Neighbor to display information about\n" |
| 12874 | "Display the received routes from neighbor\n") |
| 12875 | { |
| 12876 | struct peer *peer; |
| 12877 | |
| 12878 | if (argc == 2) |
| 12879 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12880 | else |
| 12881 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12882 | |
| 12883 | if (! peer) |
| 12884 | return CMD_WARNING; |
| 12885 | |
| 12886 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 12887 | } |
| 12888 | |
| 12889 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
| 12890 | show_ip_bgp_neighbor_received_routes_cmd, |
| 12891 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12892 | SHOW_STR |
| 12893 | IP_STR |
| 12894 | BGP_STR |
| 12895 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12896 | "Neighbor to display information about\n" |
| 12897 | "Neighbor to display information about\n" |
| 12898 | "Display the received routes from neighbor\n") |
| 12899 | |
| 12900 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 12901 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 12902 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12903 | SHOW_STR |
| 12904 | BGP_STR |
| 12905 | "Address family\n" |
| 12906 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12907 | "Neighbor to display information about\n" |
| 12908 | "Neighbor to display information about\n" |
| 12909 | "Display the received routes from neighbor\n") |
| 12910 | |
| 12911 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 12912 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 12913 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12914 | SHOW_STR |
| 12915 | BGP_STR |
| 12916 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12917 | "Neighbor to display information about\n" |
| 12918 | "Neighbor to display information about\n" |
| 12919 | "Display information received from a BGP neighbor\n" |
| 12920 | "Display the prefixlist filter\n") |
| 12921 | { |
| 12922 | char name[BUFSIZ]; |
| 12923 | union sockunion su; |
| 12924 | struct peer *peer; |
| 12925 | int count, ret; |
| 12926 | |
| 12927 | ret = str2sockunion (argv[0], &su); |
| 12928 | if (ret < 0) |
| 12929 | { |
| 12930 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 12931 | return CMD_WARNING; |
| 12932 | } |
| 12933 | |
| 12934 | peer = peer_lookup (NULL, &su); |
| 12935 | if (! peer) |
| 12936 | return CMD_WARNING; |
| 12937 | |
| 12938 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 12939 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 12940 | if (count) |
| 12941 | { |
| 12942 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 12943 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 12944 | } |
| 12945 | |
| 12946 | return CMD_SUCCESS; |
| 12947 | } |
| 12948 | |
| 12949 | /* old command */ |
| 12950 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 12951 | ipv6_bgp_neighbor_received_routes_cmd, |
| 12952 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12953 | SHOW_STR |
| 12954 | IPV6_STR |
| 12955 | BGP_STR |
| 12956 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12957 | "Neighbor to display information about\n" |
| 12958 | "Neighbor to display information about\n" |
| 12959 | "Display the received routes from neighbor\n") |
| 12960 | |
| 12961 | /* old command */ |
| 12962 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 12963 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 12964 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12965 | SHOW_STR |
| 12966 | IPV6_STR |
| 12967 | MBGP_STR |
| 12968 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12969 | "Neighbor to display information about\n" |
| 12970 | "Neighbor to display information about\n" |
| 12971 | "Display the received routes from neighbor\n") |
| 12972 | { |
| 12973 | struct peer *peer; |
| 12974 | |
| 12975 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12976 | if (! peer) |
| 12977 | return CMD_WARNING; |
| 12978 | |
| 12979 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
| 12980 | } |
| 12981 | |
| 12982 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 12983 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 12984 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12985 | SHOW_STR |
| 12986 | BGP_STR |
| 12987 | "BGP view\n" |
| 12988 | "View name\n" |
| 12989 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12990 | "Neighbor to display information about\n" |
| 12991 | "Neighbor to display information about\n" |
| 12992 | "Display information received from a BGP neighbor\n" |
| 12993 | "Display the prefixlist filter\n") |
| 12994 | { |
| 12995 | char name[BUFSIZ]; |
| 12996 | union sockunion su; |
| 12997 | struct peer *peer; |
| 12998 | struct bgp *bgp; |
| 12999 | int count, ret; |
| 13000 | |
| 13001 | /* BGP structure lookup. */ |
| 13002 | bgp = bgp_lookup_by_name (argv[0]); |
| 13003 | if (bgp == NULL) |
| 13004 | { |
| 13005 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13006 | return CMD_WARNING; |
| 13007 | } |
| 13008 | |
| 13009 | ret = str2sockunion (argv[1], &su); |
| 13010 | if (ret < 0) |
| 13011 | { |
| 13012 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13013 | return CMD_WARNING; |
| 13014 | } |
| 13015 | |
| 13016 | peer = peer_lookup (bgp, &su); |
| 13017 | if (! peer) |
| 13018 | return CMD_WARNING; |
| 13019 | |
| 13020 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 13021 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13022 | if (count) |
| 13023 | { |
| 13024 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 13025 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13026 | } |
| 13027 | |
| 13028 | return CMD_SUCCESS; |
| 13029 | } |
| 13030 | |
| 13031 | |
| 13032 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 13033 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 13034 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 13035 | SHOW_STR |
| 13036 | IP_STR |
| 13037 | BGP_STR |
| 13038 | "Address family\n" |
| 13039 | "Address Family modifier\n" |
| 13040 | "Address Family modifier\n" |
| 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 received routes from neighbor\n") |
| 13045 | { |
| 13046 | struct peer *peer; |
| 13047 | |
| 13048 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13049 | if (! peer) |
| 13050 | return CMD_WARNING; |
| 13051 | |
| 13052 | if (strncmp (argv[0], "m", 1) == 0) |
| 13053 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 13054 | |
| 13055 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 13056 | } |
| 13057 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13058 | DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route, |
| 13059 | show_bgp_ipv4_safi_neighbor_advertised_route_cmd, |
| 13060 | "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] | 13061 | SHOW_STR |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13062 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13063 | "Address Family modifier\n" |
| 13064 | "Address Family modifier\n" |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13065 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13066 | "Neighbor to display information about\n" |
| 13067 | "Neighbor to display information about\n" |
| 13068 | "Display the routes advertised to a BGP neighbor\n") |
| 13069 | { |
| 13070 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13071 | safi_t safi; |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13072 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13073 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13074 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13075 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13076 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13077 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13078 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13079 | if (! peer) |
| 13080 | return CMD_WARNING; |
| 13081 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13082 | return peer_adj_routes (vty, peer, AFI_IP, safi, 0); |
| 13083 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13084 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13085 | DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route, |
| 13086 | show_bgp_ipv6_safi_neighbor_advertised_route_cmd, |
| 13087 | "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 13088 | SHOW_STR |
| 13089 | BGP_STR |
| 13090 | "Address Family modifier\n" |
| 13091 | "Address Family modifier\n" |
| 13092 | "Address Family modifier\n" |
| 13093 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13094 | "Neighbor to display information about\n" |
| 13095 | "Neighbor to display information about\n" |
| 13096 | "Display the routes advertised to a BGP neighbor\n") |
| 13097 | { |
| 13098 | struct peer *peer; |
| 13099 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13100 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13101 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13102 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13103 | return CMD_WARNING; |
| 13104 | } |
| 13105 | |
| 13106 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13107 | if (! peer) |
| 13108 | return CMD_WARNING; |
| 13109 | |
| 13110 | return peer_adj_routes (vty, peer, AFI_IP6, safi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13111 | } |
| 13112 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13113 | DEFUN (show_bgp_view_ipv6_neighbor_advertised_route, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13114 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 13115 | "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] | 13116 | SHOW_STR |
| 13117 | BGP_STR |
| 13118 | "BGP view\n" |
| 13119 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13120 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13121 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13122 | "Neighbor to display information about\n" |
| 13123 | "Neighbor to display information about\n" |
| 13124 | "Display the routes advertised to a BGP neighbor\n") |
| 13125 | { |
| 13126 | struct peer *peer; |
| 13127 | |
| 13128 | if (argc == 2) |
| 13129 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13130 | else |
| 13131 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13132 | |
| 13133 | if (! peer) |
| 13134 | return CMD_WARNING; |
| 13135 | |
| 13136 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 13137 | } |
| 13138 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13139 | DEFUN (show_bgp_view_ipv6_neighbor_received_routes, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13140 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 13141 | "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] | 13142 | SHOW_STR |
| 13143 | BGP_STR |
| 13144 | "BGP view\n" |
| 13145 | "View name\n" |
| 13146 | "Address family\n" |
| 13147 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13148 | "Neighbor to display information about\n" |
| 13149 | "Neighbor to display information about\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13150 | "Display the received routes from neighbor\n") |
| 13151 | { |
| 13152 | struct peer *peer; |
| 13153 | |
| 13154 | if (argc == 2) |
| 13155 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13156 | else |
| 13157 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13158 | |
| 13159 | if (! peer) |
| 13160 | return CMD_WARNING; |
| 13161 | |
| 13162 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 13163 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13164 | |
| 13165 | DEFUN (show_bgp_ipv4_safi_neighbor_received_routes, |
| 13166 | show_bgp_ipv4_safi_neighbor_received_routes_cmd, |
| 13167 | "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] | 13168 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13169 | BGP_STR |
| 13170 | "Address family\n" |
| 13171 | "Address Family modifier\n" |
| 13172 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13173 | "Address Family modifier\n" |
| 13174 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13175 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13176 | "Neighbor to display information about\n" |
| 13177 | "Neighbor to display information about\n" |
| 13178 | "Display the received routes from neighbor\n") |
| 13179 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13180 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13181 | safi_t safi; |
| 13182 | |
| 13183 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13184 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13185 | return CMD_WARNING; |
| 13186 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13187 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13188 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13189 | if (! peer) |
| 13190 | return CMD_WARNING; |
| 13191 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13192 | return peer_adj_routes (vty, peer, AFI_IP, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13193 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13194 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13195 | DEFUN (show_bgp_ipv6_safi_neighbor_received_routes, |
| 13196 | show_bgp_ipv6_safi_neighbor_received_routes_cmd, |
| 13197 | "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 13198 | SHOW_STR |
| 13199 | BGP_STR |
| 13200 | "Address family\n" |
| 13201 | "Address Family modifier\n" |
| 13202 | "Address Family modifier\n" |
| 13203 | "Address Family modifier\n" |
| 13204 | "Address Family modifier\n" |
| 13205 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13206 | "Neighbor to display information about\n" |
| 13207 | "Neighbor to display information about\n" |
| 13208 | "Display the received routes from neighbor\n") |
| 13209 | { |
| 13210 | struct peer *peer; |
| 13211 | safi_t safi; |
| 13212 | |
| 13213 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13214 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13215 | return CMD_WARNING; |
| 13216 | } |
| 13217 | |
| 13218 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13219 | if (! peer) |
| 13220 | return CMD_WARNING; |
| 13221 | |
| 13222 | return peer_adj_routes (vty, peer, AFI_IP6, safi, 1); |
| 13223 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13224 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13225 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 13226 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13227 | "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] | 13228 | SHOW_STR |
| 13229 | BGP_STR |
| 13230 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 13231 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13232 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13233 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13234 | "Address family modifier\n" |
| 13235 | "Address family modifier\n" |
| 13236 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13237 | "Neighbor to display information about\n" |
| 13238 | "Neighbor to display information about\n" |
| 13239 | "Display the advertised routes to neighbor\n" |
| 13240 | "Display the received routes from neighbor\n") |
| 13241 | { |
| 13242 | int afi; |
| 13243 | int safi; |
| 13244 | int in; |
| 13245 | struct peer *peer; |
| 13246 | |
David Lamparter | 94bad67 | 2015-03-03 08:52:22 +0100 | [diff] [blame] | 13247 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13248 | |
| 13249 | if (! peer) |
| 13250 | return CMD_WARNING; |
| 13251 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13252 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 13253 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13254 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13255 | |
| 13256 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 13257 | } |
| 13258 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13259 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 13260 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 13261 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 13262 | SHOW_STR |
| 13263 | IP_STR |
| 13264 | BGP_STR |
| 13265 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13266 | "Neighbor to display information about\n" |
| 13267 | "Neighbor to display information about\n" |
| 13268 | "Display information received from a BGP neighbor\n" |
| 13269 | "Display the prefixlist filter\n") |
| 13270 | { |
| 13271 | char name[BUFSIZ]; |
| 13272 | union sockunion su; |
| 13273 | struct peer *peer; |
| 13274 | int count, ret; |
| 13275 | |
| 13276 | ret = str2sockunion (argv[0], &su); |
| 13277 | if (ret < 0) |
| 13278 | { |
| 13279 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 13280 | return CMD_WARNING; |
| 13281 | } |
| 13282 | |
| 13283 | peer = peer_lookup (NULL, &su); |
| 13284 | if (! peer) |
| 13285 | return CMD_WARNING; |
| 13286 | |
| 13287 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 13288 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13289 | if (count) |
| 13290 | { |
| 13291 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 13292 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13293 | } |
| 13294 | |
| 13295 | return CMD_SUCCESS; |
| 13296 | } |
| 13297 | |
| 13298 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 13299 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 13300 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 13301 | SHOW_STR |
| 13302 | IP_STR |
| 13303 | BGP_STR |
| 13304 | "Address family\n" |
| 13305 | "Address Family modifier\n" |
| 13306 | "Address Family modifier\n" |
| 13307 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13308 | "Neighbor to display information about\n" |
| 13309 | "Neighbor to display information about\n" |
| 13310 | "Display information received from a BGP neighbor\n" |
| 13311 | "Display the prefixlist filter\n") |
| 13312 | { |
| 13313 | char name[BUFSIZ]; |
| 13314 | union sockunion su; |
| 13315 | struct peer *peer; |
| 13316 | int count, ret; |
| 13317 | |
| 13318 | ret = str2sockunion (argv[1], &su); |
| 13319 | if (ret < 0) |
| 13320 | { |
| 13321 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13322 | return CMD_WARNING; |
| 13323 | } |
| 13324 | |
| 13325 | peer = peer_lookup (NULL, &su); |
| 13326 | if (! peer) |
| 13327 | return CMD_WARNING; |
| 13328 | |
| 13329 | if (strncmp (argv[0], "m", 1) == 0) |
| 13330 | { |
| 13331 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 13332 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13333 | if (count) |
| 13334 | { |
| 13335 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 13336 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13337 | } |
| 13338 | } |
| 13339 | else |
| 13340 | { |
| 13341 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 13342 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13343 | if (count) |
| 13344 | { |
| 13345 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 13346 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13347 | } |
| 13348 | } |
| 13349 | |
| 13350 | return CMD_SUCCESS; |
| 13351 | } |
| 13352 | |
| 13353 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 13354 | show_bgp_neighbor_received_routes_cmd, |
| 13355 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 13356 | SHOW_STR |
| 13357 | BGP_STR |
| 13358 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13359 | "Neighbor to display information about\n" |
| 13360 | "Neighbor to display information about\n" |
| 13361 | "Display the received routes from neighbor\n") |
| 13362 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13363 | DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter, |
| 13364 | show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd, |
| 13365 | "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] | 13366 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13367 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13368 | IP_STR |
| 13369 | "Address Family modifier\n" |
| 13370 | "Address Family modifier\n" |
| 13371 | "Address Family modifier\n" |
| 13372 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13373 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13374 | "Neighbor to display information about\n" |
| 13375 | "Neighbor to display information about\n" |
| 13376 | "Display information received from a BGP neighbor\n" |
| 13377 | "Display the prefixlist filter\n") |
| 13378 | { |
| 13379 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13380 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13381 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13382 | int count, ret; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13383 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13384 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13385 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13386 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13387 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13388 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13389 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13390 | ret = str2sockunion (argv[1], &su); |
| 13391 | if (ret < 0) |
| 13392 | { |
| 13393 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13394 | return CMD_WARNING; |
| 13395 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13396 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13397 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13398 | if (! peer) |
| 13399 | return CMD_WARNING; |
| 13400 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13401 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi); |
| 13402 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13403 | if (count) { |
| 13404 | vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE); |
| 13405 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13406 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13407 | |
| 13408 | return CMD_SUCCESS; |
| 13409 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13410 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13411 | DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter, |
| 13412 | show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd, |
| 13413 | "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] | 13414 | SHOW_STR |
| 13415 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13416 | IP_STR |
| 13417 | "Address Family modifier\n" |
| 13418 | "Address Family modifier\n" |
| 13419 | "Address Family modifier\n" |
| 13420 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13421 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13422 | "Neighbor to display information about\n" |
| 13423 | "Neighbor to display information about\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13424 | "Display information received from a BGP neighbor\n" |
| 13425 | "Display the prefixlist filter\n") |
| 13426 | { |
| 13427 | char name[BUFSIZ]; |
| 13428 | union sockunion su; |
| 13429 | struct peer *peer; |
| 13430 | int count, ret; |
| 13431 | safi_t safi; |
| 13432 | |
| 13433 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13434 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13435 | return CMD_WARNING; |
| 13436 | } |
| 13437 | |
| 13438 | ret = str2sockunion (argv[1], &su); |
| 13439 | if (ret < 0) |
| 13440 | { |
| 13441 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13442 | return CMD_WARNING; |
| 13443 | } |
| 13444 | |
| 13445 | peer = peer_lookup (NULL, &su); |
| 13446 | if (! peer) |
| 13447 | return CMD_WARNING; |
| 13448 | |
| 13449 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi); |
| 13450 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13451 | if (count) { |
| 13452 | vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE); |
| 13453 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13454 | } |
| 13455 | |
| 13456 | return CMD_SUCCESS; |
| 13457 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13458 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13459 | DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13460 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 13461 | "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] | 13462 | SHOW_STR |
| 13463 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13464 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13465 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13466 | "Neighbor to display information about\n" |
| 13467 | "Neighbor to display information about\n" |
| 13468 | "Display information received from a BGP neighbor\n" |
| 13469 | "Display the prefixlist filter\n") |
| 13470 | { |
| 13471 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13472 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13473 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13474 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13475 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13476 | ret = str2sockunion (argv[0], &su); |
| 13477 | if (ret < 0) |
| 13478 | { |
| 13479 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 13480 | return CMD_WARNING; |
| 13481 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13482 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13483 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13484 | if (! peer) |
| 13485 | return CMD_WARNING; |
| 13486 | |
| 13487 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 13488 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13489 | if (count) |
| 13490 | { |
| 13491 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 13492 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13493 | } |
| 13494 | |
| 13495 | return CMD_SUCCESS; |
| 13496 | } |
| 13497 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13498 | DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13499 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 13500 | "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] | 13501 | SHOW_STR |
| 13502 | BGP_STR |
| 13503 | "BGP view\n" |
| 13504 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13505 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13506 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13507 | "Neighbor to display information about\n" |
| 13508 | "Neighbor to display information about\n" |
| 13509 | "Display information received from a BGP neighbor\n" |
| 13510 | "Display the prefixlist filter\n") |
| 13511 | { |
| 13512 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13513 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13514 | struct peer *peer; |
| 13515 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13516 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13517 | |
| 13518 | /* BGP structure lookup. */ |
| 13519 | bgp = bgp_lookup_by_name (argv[0]); |
| 13520 | if (bgp == NULL) |
| 13521 | { |
| 13522 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13523 | return CMD_WARNING; |
| 13524 | } |
| 13525 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13526 | ret = str2sockunion (argv[1], &su); |
| 13527 | if (ret < 0) |
| 13528 | { |
| 13529 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13530 | return CMD_WARNING; |
| 13531 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13532 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13533 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13534 | if (! peer) |
| 13535 | return CMD_WARNING; |
| 13536 | |
| 13537 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 13538 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13539 | if (count) |
| 13540 | { |
| 13541 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 13542 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13543 | } |
| 13544 | |
| 13545 | return CMD_SUCCESS; |
| 13546 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 13547 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 13548 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13549 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13550 | safi_t safi, enum bgp_show_type type) |
| 13551 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13552 | if (! peer || ! peer->afc[afi][safi]) |
| 13553 | { |
| 13554 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13555 | return CMD_WARNING; |
| 13556 | } |
| 13557 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 13558 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13559 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13560 | DEFUN (show_ip_bgp_neighbor_routes, |
| 13561 | show_ip_bgp_neighbor_routes_cmd, |
| 13562 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 13563 | SHOW_STR |
| 13564 | IP_STR |
| 13565 | BGP_STR |
| 13566 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13567 | "Neighbor to display information about\n" |
| 13568 | "Neighbor to display information about\n" |
| 13569 | "Display routes learned from neighbor\n") |
| 13570 | { |
| 13571 | struct peer *peer; |
| 13572 | |
| 13573 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13574 | if (! peer) |
| 13575 | return CMD_WARNING; |
| 13576 | |
| 13577 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13578 | bgp_show_type_neighbor); |
| 13579 | } |
| 13580 | |
| 13581 | DEFUN (show_ip_bgp_neighbor_flap, |
| 13582 | show_ip_bgp_neighbor_flap_cmd, |
| 13583 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 13584 | SHOW_STR |
| 13585 | IP_STR |
| 13586 | BGP_STR |
| 13587 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13588 | "Neighbor to display information about\n" |
| 13589 | "Neighbor to display information about\n" |
| 13590 | "Display flap statistics of the routes learned from neighbor\n") |
| 13591 | { |
| 13592 | struct peer *peer; |
| 13593 | |
| 13594 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13595 | if (! peer) |
| 13596 | return CMD_WARNING; |
| 13597 | |
| 13598 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13599 | bgp_show_type_flap_neighbor); |
| 13600 | } |
| 13601 | |
| 13602 | DEFUN (show_ip_bgp_neighbor_damp, |
| 13603 | show_ip_bgp_neighbor_damp_cmd, |
| 13604 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 13605 | SHOW_STR |
| 13606 | IP_STR |
| 13607 | BGP_STR |
| 13608 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13609 | "Neighbor to display information about\n" |
| 13610 | "Neighbor to display information about\n" |
| 13611 | "Display the dampened routes received from neighbor\n") |
| 13612 | { |
| 13613 | struct peer *peer; |
| 13614 | |
| 13615 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13616 | if (! peer) |
| 13617 | return CMD_WARNING; |
| 13618 | |
| 13619 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13620 | bgp_show_type_damp_neighbor); |
| 13621 | } |
| 13622 | |
| 13623 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 13624 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 13625 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 13626 | SHOW_STR |
| 13627 | IP_STR |
| 13628 | BGP_STR |
| 13629 | "Address family\n" |
| 13630 | "Address Family modifier\n" |
| 13631 | "Address Family modifier\n" |
| 13632 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13633 | "Neighbor to display information about\n" |
| 13634 | "Neighbor to display information about\n" |
| 13635 | "Display routes learned from neighbor\n") |
| 13636 | { |
| 13637 | struct peer *peer; |
| 13638 | |
| 13639 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13640 | if (! peer) |
| 13641 | return CMD_WARNING; |
| 13642 | |
| 13643 | if (strncmp (argv[0], "m", 1) == 0) |
| 13644 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
| 13645 | bgp_show_type_neighbor); |
| 13646 | |
| 13647 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13648 | bgp_show_type_neighbor); |
| 13649 | } |
| 13650 | |
| 13651 | DEFUN (show_ip_bgp_view_rsclient, |
| 13652 | show_ip_bgp_view_rsclient_cmd, |
| 13653 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 13654 | SHOW_STR |
| 13655 | IP_STR |
| 13656 | BGP_STR |
| 13657 | "BGP view\n" |
| 13658 | "View name\n" |
| 13659 | "Information about Route Server Client\n" |
| 13660 | NEIGHBOR_ADDR_STR) |
| 13661 | { |
| 13662 | struct bgp_table *table; |
| 13663 | struct peer *peer; |
| 13664 | |
| 13665 | if (argc == 2) |
| 13666 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13667 | else |
| 13668 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13669 | |
| 13670 | if (! peer) |
| 13671 | return CMD_WARNING; |
| 13672 | |
| 13673 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 13674 | { |
| 13675 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13676 | VTY_NEWLINE); |
| 13677 | return CMD_WARNING; |
| 13678 | } |
| 13679 | |
| 13680 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 13681 | PEER_FLAG_RSERVER_CLIENT)) |
| 13682 | { |
| 13683 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13684 | VTY_NEWLINE); |
| 13685 | return CMD_WARNING; |
| 13686 | } |
| 13687 | |
| 13688 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 13689 | |
| 13690 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 13691 | } |
| 13692 | |
| 13693 | ALIAS (show_ip_bgp_view_rsclient, |
| 13694 | show_ip_bgp_rsclient_cmd, |
| 13695 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 13696 | SHOW_STR |
| 13697 | IP_STR |
| 13698 | BGP_STR |
| 13699 | "Information about Route Server Client\n" |
| 13700 | NEIGHBOR_ADDR_STR) |
| 13701 | |
| 13702 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 13703 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 13704 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 13705 | SHOW_STR |
| 13706 | BGP_STR |
| 13707 | "BGP view\n" |
| 13708 | "View name\n" |
| 13709 | "Address family\n" |
| 13710 | "Address Family modifier\n" |
| 13711 | "Address Family modifier\n" |
| 13712 | "Information about Route Server Client\n" |
| 13713 | NEIGHBOR_ADDR_STR) |
| 13714 | { |
| 13715 | struct bgp_table *table; |
| 13716 | struct peer *peer; |
| 13717 | safi_t safi; |
| 13718 | |
| 13719 | if (argc == 3) { |
| 13720 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 13721 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13722 | } else { |
| 13723 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13724 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13725 | } |
| 13726 | |
| 13727 | if (! peer) |
| 13728 | return CMD_WARNING; |
| 13729 | |
| 13730 | if (! peer->afc[AFI_IP][safi]) |
| 13731 | { |
| 13732 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13733 | VTY_NEWLINE); |
| 13734 | return CMD_WARNING; |
| 13735 | } |
| 13736 | |
| 13737 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 13738 | PEER_FLAG_RSERVER_CLIENT)) |
| 13739 | { |
| 13740 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13741 | VTY_NEWLINE); |
| 13742 | return CMD_WARNING; |
| 13743 | } |
| 13744 | |
| 13745 | table = peer->rib[AFI_IP][safi]; |
| 13746 | |
| 13747 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 13748 | } |
| 13749 | |
| 13750 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 13751 | show_bgp_ipv4_safi_rsclient_cmd, |
| 13752 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 13753 | SHOW_STR |
| 13754 | BGP_STR |
| 13755 | "Address family\n" |
| 13756 | "Address Family modifier\n" |
| 13757 | "Address Family modifier\n" |
| 13758 | "Information about Route Server Client\n" |
| 13759 | NEIGHBOR_ADDR_STR) |
| 13760 | |
| 13761 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 13762 | show_ip_bgp_view_rsclient_route_cmd, |
| 13763 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13764 | SHOW_STR |
| 13765 | IP_STR |
| 13766 | BGP_STR |
| 13767 | "BGP view\n" |
| 13768 | "View name\n" |
| 13769 | "Information about Route Server Client\n" |
| 13770 | NEIGHBOR_ADDR_STR |
| 13771 | "Network in the BGP routing table to display\n") |
| 13772 | { |
| 13773 | struct bgp *bgp; |
| 13774 | struct peer *peer; |
| 13775 | |
| 13776 | /* BGP structure lookup. */ |
| 13777 | if (argc == 3) |
| 13778 | { |
| 13779 | bgp = bgp_lookup_by_name (argv[0]); |
| 13780 | if (bgp == NULL) |
| 13781 | { |
| 13782 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13783 | return CMD_WARNING; |
| 13784 | } |
| 13785 | } |
| 13786 | else |
| 13787 | { |
| 13788 | bgp = bgp_get_default (); |
| 13789 | if (bgp == NULL) |
| 13790 | { |
| 13791 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 13792 | return CMD_WARNING; |
| 13793 | } |
| 13794 | } |
| 13795 | |
| 13796 | if (argc == 3) |
| 13797 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13798 | else |
| 13799 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13800 | |
| 13801 | if (! peer) |
| 13802 | return CMD_WARNING; |
| 13803 | |
| 13804 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 13805 | { |
| 13806 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13807 | VTY_NEWLINE); |
| 13808 | return CMD_WARNING; |
| 13809 | } |
| 13810 | |
| 13811 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 13812 | PEER_FLAG_RSERVER_CLIENT)) |
| 13813 | { |
| 13814 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13815 | VTY_NEWLINE); |
| 13816 | return CMD_WARNING; |
| 13817 | } |
| 13818 | |
| 13819 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 13820 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 13821 | AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13822 | } |
| 13823 | |
| 13824 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 13825 | show_ip_bgp_rsclient_route_cmd, |
| 13826 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13827 | SHOW_STR |
| 13828 | IP_STR |
| 13829 | BGP_STR |
| 13830 | "Information about Route Server Client\n" |
| 13831 | NEIGHBOR_ADDR_STR |
| 13832 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13833 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13834 | DEFUN (show_bgp_ipv4_safi_neighbor_flap, |
| 13835 | show_bgp_ipv4_safi_neighbor_flap_cmd, |
| 13836 | "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] | 13837 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13838 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13839 | "Address Family Modifier\n" |
| 13840 | "Address Family Modifier\n" |
| 13841 | "Address Family Modifier\n" |
| 13842 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13843 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13844 | "Neighbor to display information about\n" |
| 13845 | "Neighbor to display information about\n" |
| 13846 | "Display flap statistics of the routes learned from neighbor\n") |
| 13847 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13848 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13849 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13850 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13851 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13852 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13853 | return CMD_WARNING; |
| 13854 | } |
| 13855 | |
| 13856 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13857 | if (! peer) |
| 13858 | return CMD_WARNING; |
| 13859 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13860 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13861 | bgp_show_type_flap_neighbor); |
| 13862 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13863 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13864 | DEFUN (show_bgp_ipv6_safi_neighbor_flap, |
| 13865 | show_bgp_ipv6_safi_neighbor_flap_cmd, |
| 13866 | "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] | 13867 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13868 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13869 | "Address Family Modifier\n" |
| 13870 | "Address Family Modifier\n" |
| 13871 | "Address Family Modifier\n" |
| 13872 | "Address Family Modifier\n" |
| 13873 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13874 | "Neighbor to display information about\n" |
| 13875 | "Neighbor to display information about\n" |
| 13876 | "Display flap statistics of the routes learned from neighbor\n") |
| 13877 | { |
| 13878 | struct peer *peer; |
| 13879 | safi_t safi; |
| 13880 | |
| 13881 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13882 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13883 | return CMD_WARNING; |
| 13884 | } |
| 13885 | |
| 13886 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13887 | if (! peer) |
| 13888 | return CMD_WARNING; |
| 13889 | |
| 13890 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13891 | bgp_show_type_flap_neighbor); |
| 13892 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13893 | |
| 13894 | DEFUN (show_bgp_ipv4_safi_neighbor_damp, |
| 13895 | show_bgp_ipv4_safi_neighbor_damp_cmd, |
| 13896 | "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 13897 | SHOW_STR |
| 13898 | BGP_STR |
| 13899 | "Address Family Modifier\n" |
| 13900 | "Address Family Modifier\n" |
| 13901 | "Address Family Modifier\n" |
| 13902 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13903 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13904 | "Neighbor to display information about\n" |
| 13905 | "Neighbor to display information about\n" |
| 13906 | "Display the dampened routes received from neighbor\n") |
| 13907 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13908 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13909 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13910 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13911 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13912 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13913 | return CMD_WARNING; |
| 13914 | } |
| 13915 | |
| 13916 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13917 | if (! peer) |
| 13918 | return CMD_WARNING; |
| 13919 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13920 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13921 | bgp_show_type_damp_neighbor); |
| 13922 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13923 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13924 | DEFUN (show_bgp_ipv6_safi_neighbor_damp, |
| 13925 | show_bgp_ipv6_safi_neighbor_damp_cmd, |
| 13926 | "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] | 13927 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13928 | BGP_STR |
| 13929 | "Address Family Modifier\n" |
| 13930 | "Address Family Modifier\n" |
| 13931 | "Address Family Modifier\n" |
| 13932 | "Address Family Modifier\n" |
| 13933 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13934 | "Neighbor to display information about\n" |
| 13935 | "Neighbor to display information about\n" |
| 13936 | "Display the dampened routes received from neighbor\n") |
| 13937 | { |
| 13938 | struct peer *peer; |
| 13939 | safi_t safi; |
| 13940 | |
| 13941 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13942 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13943 | return CMD_WARNING; |
| 13944 | } |
| 13945 | |
| 13946 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13947 | if (! peer) |
| 13948 | return CMD_WARNING; |
| 13949 | |
| 13950 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13951 | bgp_show_type_damp_neighbor); |
| 13952 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13953 | |
| 13954 | DEFUN (show_bgp_ipv4_safi_neighbor_routes, |
| 13955 | show_bgp_ipv4_safi_neighbor_routes_cmd, |
| 13956 | "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 13957 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13958 | BGP_STR |
| 13959 | "Address family\n" |
| 13960 | "Address Family modifier\n" |
| 13961 | "Address Family modifier\n" |
| 13962 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13963 | "Neighbor to display information about\n" |
| 13964 | "Neighbor to display information about\n" |
| 13965 | "Display routes learned from neighbor\n") |
| 13966 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13967 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13968 | safi_t safi; |
| 13969 | |
| 13970 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13971 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13972 | return CMD_WARNING; |
| 13973 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13974 | |
| 13975 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13976 | if (! peer) |
| 13977 | return CMD_WARNING; |
| 13978 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13979 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13980 | bgp_show_type_neighbor); |
| 13981 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13982 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13983 | DEFUN (show_bgp_ipv6_safi_neighbor_routes, |
| 13984 | show_bgp_ipv6_safi_neighbor_routes_cmd, |
| 13985 | "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] | 13986 | SHOW_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13987 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13988 | "Address family\n" |
| 13989 | "Address Family modifier\n" |
| 13990 | "Address Family modifier\n" |
| 13991 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13992 | NEIGHBOR_ADDR_STR |
| 13993 | NEIGHBOR_ADDR_STR |
| 13994 | "Display routes learned from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13995 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13996 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13997 | safi_t safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13998 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13999 | if (bgp_parse_safi(argv[0], &safi)) { |
| 14000 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 14001 | return CMD_WARNING; |
| 14002 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14003 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14004 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14005 | if (! peer) |
| 14006 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14007 | |
| 14008 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 14009 | bgp_show_type_neighbor); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14010 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14011 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14012 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 14013 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 14014 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 14015 | SHOW_STR |
| 14016 | BGP_STR |
| 14017 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14018 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14019 | "Address family\n" |
| 14020 | "Address Family modifier\n" |
| 14021 | "Address Family modifier\n" |
| 14022 | "Information about Route Server Client\n" |
| 14023 | NEIGHBOR_ADDR_STR |
| 14024 | "Network in the BGP routing table to display\n") |
| 14025 | { |
| 14026 | struct bgp *bgp; |
| 14027 | struct peer *peer; |
| 14028 | safi_t safi; |
| 14029 | |
| 14030 | /* BGP structure lookup. */ |
| 14031 | if (argc == 4) |
| 14032 | { |
| 14033 | bgp = bgp_lookup_by_name (argv[0]); |
| 14034 | if (bgp == NULL) |
| 14035 | { |
| 14036 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14037 | return CMD_WARNING; |
| 14038 | } |
| 14039 | } |
| 14040 | else |
| 14041 | { |
| 14042 | bgp = bgp_get_default (); |
| 14043 | if (bgp == NULL) |
| 14044 | { |
| 14045 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14046 | return CMD_WARNING; |
| 14047 | } |
| 14048 | } |
| 14049 | |
| 14050 | if (argc == 4) { |
| 14051 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14052 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14053 | } else { |
| 14054 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14055 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14056 | } |
| 14057 | |
| 14058 | if (! peer) |
| 14059 | return CMD_WARNING; |
| 14060 | |
| 14061 | if (! peer->afc[AFI_IP][safi]) |
| 14062 | { |
| 14063 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14064 | VTY_NEWLINE); |
| 14065 | return CMD_WARNING; |
| 14066 | } |
| 14067 | |
| 14068 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 14069 | PEER_FLAG_RSERVER_CLIENT)) |
| 14070 | { |
| 14071 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14072 | VTY_NEWLINE); |
| 14073 | return CMD_WARNING; |
| 14074 | } |
| 14075 | |
| 14076 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 14077 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14078 | AFI_IP, safi, NULL, 0, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14079 | } |
| 14080 | |
| 14081 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 14082 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 14083 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 14084 | SHOW_STR |
| 14085 | BGP_STR |
| 14086 | "Address family\n" |
| 14087 | "Address Family modifier\n" |
| 14088 | "Address Family modifier\n" |
| 14089 | "Information about Route Server Client\n" |
| 14090 | NEIGHBOR_ADDR_STR |
| 14091 | "Network in the BGP routing table to display\n") |
| 14092 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14093 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14094 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 14095 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 14096 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14097 | SHOW_STR |
| 14098 | BGP_STR |
| 14099 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14100 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14101 | "Address family\n" |
| 14102 | "Address Family modifier\n" |
| 14103 | "Address Family modifier\n" |
| 14104 | "Information about Route Server Client\n" |
| 14105 | NEIGHBOR_ADDR_STR |
| 14106 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 14107 | { |
| 14108 | struct bgp *bgp; |
| 14109 | struct peer *peer; |
| 14110 | safi_t safi; |
| 14111 | |
| 14112 | /* BGP structure lookup. */ |
| 14113 | if (argc == 4) |
| 14114 | { |
| 14115 | bgp = bgp_lookup_by_name (argv[0]); |
| 14116 | if (bgp == NULL) |
| 14117 | { |
| 14118 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14119 | return CMD_WARNING; |
| 14120 | } |
| 14121 | } |
| 14122 | else |
| 14123 | { |
| 14124 | bgp = bgp_get_default (); |
| 14125 | if (bgp == NULL) |
| 14126 | { |
| 14127 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14128 | return CMD_WARNING; |
| 14129 | } |
| 14130 | } |
| 14131 | |
| 14132 | if (argc == 4) { |
| 14133 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14134 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14135 | } else { |
| 14136 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14137 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14138 | } |
| 14139 | |
| 14140 | if (! peer) |
| 14141 | return CMD_WARNING; |
| 14142 | |
| 14143 | if (! peer->afc[AFI_IP][safi]) |
| 14144 | { |
| 14145 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14146 | VTY_NEWLINE); |
| 14147 | return CMD_WARNING; |
| 14148 | } |
| 14149 | |
| 14150 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 14151 | PEER_FLAG_RSERVER_CLIENT)) |
| 14152 | { |
| 14153 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14154 | VTY_NEWLINE); |
| 14155 | return CMD_WARNING; |
| 14156 | } |
| 14157 | |
| 14158 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 14159 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14160 | AFI_IP, safi, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14161 | } |
| 14162 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14163 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 14164 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 14165 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14166 | SHOW_STR |
| 14167 | IP_STR |
| 14168 | BGP_STR |
| 14169 | "BGP view\n" |
| 14170 | "View name\n" |
| 14171 | "Information about Route Server Client\n" |
| 14172 | NEIGHBOR_ADDR_STR |
| 14173 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 14174 | { |
| 14175 | struct bgp *bgp; |
| 14176 | struct peer *peer; |
| 14177 | |
| 14178 | /* BGP structure lookup. */ |
| 14179 | if (argc == 3) |
| 14180 | { |
| 14181 | bgp = bgp_lookup_by_name (argv[0]); |
| 14182 | if (bgp == NULL) |
| 14183 | { |
| 14184 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14185 | return CMD_WARNING; |
| 14186 | } |
| 14187 | } |
| 14188 | else |
| 14189 | { |
| 14190 | bgp = bgp_get_default (); |
| 14191 | if (bgp == NULL) |
| 14192 | { |
| 14193 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14194 | return CMD_WARNING; |
| 14195 | } |
| 14196 | } |
| 14197 | |
| 14198 | if (argc == 3) |
| 14199 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14200 | else |
| 14201 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14202 | |
| 14203 | if (! peer) |
| 14204 | return CMD_WARNING; |
| 14205 | |
| 14206 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 14207 | { |
| 14208 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14209 | VTY_NEWLINE); |
| 14210 | return CMD_WARNING; |
| 14211 | } |
| 14212 | |
| 14213 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 14214 | PEER_FLAG_RSERVER_CLIENT)) |
| 14215 | { |
| 14216 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14217 | VTY_NEWLINE); |
| 14218 | return CMD_WARNING; |
| 14219 | } |
| 14220 | |
| 14221 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 14222 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14223 | AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14224 | } |
| 14225 | |
| 14226 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 14227 | show_ip_bgp_rsclient_prefix_cmd, |
| 14228 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14229 | SHOW_STR |
| 14230 | IP_STR |
| 14231 | BGP_STR |
| 14232 | "Information about Route Server Client\n" |
| 14233 | NEIGHBOR_ADDR_STR |
| 14234 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 14235 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14236 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 14237 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 14238 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14239 | SHOW_STR |
| 14240 | BGP_STR |
| 14241 | "Address family\n" |
| 14242 | "Address Family modifier\n" |
| 14243 | "Address Family modifier\n" |
| 14244 | "Information about Route Server Client\n" |
| 14245 | NEIGHBOR_ADDR_STR |
| 14246 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14247 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14248 | DEFUN (show_bgp_view_ipv6_neighbor_routes, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14249 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 14250 | "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] | 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" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14255 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 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 routes learned from neighbor\n") |
| 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_neighbor); |
| 14273 | } |
| 14274 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14275 | DEFUN (show_bgp_view_neighbor_damp, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14276 | show_bgp_view_neighbor_damp_cmd, |
| 14277 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 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 the dampened routes received 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_damp_neighbor); |
| 14299 | } |
| 14300 | |
| 14301 | DEFUN (show_bgp_view_ipv6_neighbor_damp, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14302 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 14303 | "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] | 14304 | SHOW_STR |
| 14305 | BGP_STR |
| 14306 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14307 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14308 | "Address family\n" |
| 14309 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14310 | "Neighbor to display information about\n" |
| 14311 | "Neighbor to display information about\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14312 | "Display the dampened routes received from neighbor\n") |
| 14313 | { |
| 14314 | struct peer *peer; |
| 14315 | |
| 14316 | if (argc == 2) |
| 14317 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14318 | else |
| 14319 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14320 | |
| 14321 | if (! peer) |
| 14322 | return CMD_WARNING; |
| 14323 | |
| 14324 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14325 | bgp_show_type_damp_neighbor); |
| 14326 | } |
| 14327 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14328 | DEFUN (show_bgp_view_ipv6_neighbor_flap, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14329 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 14330 | "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] | 14331 | SHOW_STR |
| 14332 | BGP_STR |
| 14333 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14334 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14335 | "Address family\n" |
| 14336 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14337 | "Neighbor to display information about\n" |
| 14338 | "Neighbor to display information about\n" |
| 14339 | "Display the dampened routes received from neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14340 | { |
| 14341 | struct peer *peer; |
| 14342 | |
| 14343 | if (argc == 2) |
| 14344 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14345 | else |
| 14346 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14347 | |
| 14348 | if (! peer) |
| 14349 | return CMD_WARNING; |
| 14350 | |
| 14351 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14352 | bgp_show_type_flap_neighbor); |
| 14353 | } |
| 14354 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14355 | DEFUN (show_bgp_view_neighbor_flap, |
| 14356 | show_bgp_view_neighbor_flap_cmd, |
| 14357 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14358 | SHOW_STR |
| 14359 | BGP_STR |
| 14360 | "BGP view\n" |
| 14361 | "View name\n" |
| 14362 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14363 | "Neighbor to display information about\n" |
| 14364 | "Neighbor to display information about\n" |
| 14365 | "Display flap statistics of the routes learned from neighbor\n") |
| 14366 | { |
| 14367 | struct peer *peer; |
| 14368 | |
| 14369 | if (argc == 2) |
| 14370 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14371 | else |
| 14372 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14373 | |
| 14374 | if (! peer) |
| 14375 | return CMD_WARNING; |
| 14376 | |
| 14377 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14378 | bgp_show_type_flap_neighbor); |
| 14379 | } |
| 14380 | |
| 14381 | ALIAS (show_bgp_view_neighbor_flap, |
| 14382 | show_bgp_neighbor_flap_cmd, |
| 14383 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14384 | SHOW_STR |
| 14385 | BGP_STR |
| 14386 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14387 | "Neighbor to display information about\n" |
| 14388 | "Neighbor to display information about\n" |
| 14389 | "Display flap statistics of the routes learned from neighbor\n") |
| 14390 | |
| 14391 | ALIAS (show_bgp_view_neighbor_damp, |
| 14392 | show_bgp_neighbor_damp_cmd, |
| 14393 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14394 | SHOW_STR |
| 14395 | BGP_STR |
| 14396 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14397 | "Neighbor to display information about\n" |
| 14398 | "Neighbor to display information about\n" |
| 14399 | "Display the dampened routes received from neighbor\n") |
| 14400 | |
| 14401 | DEFUN (show_bgp_view_neighbor_routes, |
| 14402 | show_bgp_view_neighbor_routes_cmd, |
| 14403 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 14404 | SHOW_STR |
| 14405 | BGP_STR |
| 14406 | "BGP view\n" |
| 14407 | "View name\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 routes learned from neighbor\n") |
| 14412 | { |
| 14413 | struct peer *peer; |
| 14414 | |
| 14415 | if (argc == 2) |
| 14416 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14417 | else |
| 14418 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14419 | |
| 14420 | if (! peer) |
| 14421 | return CMD_WARNING; |
| 14422 | |
| 14423 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14424 | bgp_show_type_neighbor); |
| 14425 | } |
| 14426 | |
| 14427 | ALIAS (show_bgp_view_neighbor_routes, |
| 14428 | show_bgp_neighbor_routes_cmd, |
| 14429 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14430 | SHOW_STR |
| 14431 | BGP_STR |
| 14432 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14433 | "Neighbor to display information about\n" |
| 14434 | "Neighbor to display information about\n" |
| 14435 | "Display routes learned from neighbor\n") |
| 14436 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14437 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14438 | show_bgp_ipv6_neighbor_routes_cmd, |
| 14439 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 14440 | SHOW_STR |
| 14441 | BGP_STR |
| 14442 | "Address family\n" |
| 14443 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14444 | "Neighbor to display information about\n" |
| 14445 | "Neighbor to display information about\n" |
| 14446 | "Display routes learned from neighbor\n") |
| 14447 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14448 | /* old command */ |
| 14449 | ALIAS (show_bgp_view_neighbor_routes, |
| 14450 | ipv6_bgp_neighbor_routes_cmd, |
| 14451 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14452 | SHOW_STR |
| 14453 | IPV6_STR |
| 14454 | BGP_STR |
| 14455 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14456 | "Neighbor to display information about\n" |
| 14457 | "Neighbor to display information about\n" |
| 14458 | "Display routes learned from neighbor\n") |
| 14459 | |
| 14460 | /* old command */ |
| 14461 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 14462 | ipv6_mbgp_neighbor_routes_cmd, |
| 14463 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14464 | SHOW_STR |
| 14465 | IPV6_STR |
| 14466 | MBGP_STR |
| 14467 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14468 | "Neighbor to display information about\n" |
| 14469 | "Neighbor to display information about\n" |
| 14470 | "Display routes learned from neighbor\n") |
| 14471 | { |
| 14472 | struct peer *peer; |
| 14473 | |
| 14474 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14475 | if (! peer) |
| 14476 | return CMD_WARNING; |
| 14477 | |
| 14478 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
| 14479 | bgp_show_type_neighbor); |
| 14480 | } |
| 14481 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14482 | ALIAS (show_bgp_view_neighbor_flap, |
| 14483 | show_bgp_ipv6_neighbor_flap_cmd, |
| 14484 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14485 | SHOW_STR |
| 14486 | BGP_STR |
| 14487 | "Address family\n" |
| 14488 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14489 | "Neighbor to display information about\n" |
| 14490 | "Neighbor to display information about\n" |
| 14491 | "Display flap statistics of the routes learned from neighbor\n") |
| 14492 | |
| 14493 | ALIAS (show_bgp_view_neighbor_damp, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14494 | show_bgp_ipv6_neighbor_damp_cmd, |
| 14495 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14496 | SHOW_STR |
| 14497 | BGP_STR |
| 14498 | "Address family\n" |
| 14499 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14500 | "Neighbor to display information about\n" |
| 14501 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 14502 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14503 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14504 | DEFUN (show_bgp_view_rsclient, |
| 14505 | show_bgp_view_rsclient_cmd, |
| 14506 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 14507 | SHOW_STR |
| 14508 | BGP_STR |
| 14509 | "BGP view\n" |
| 14510 | "View name\n" |
| 14511 | "Information about Route Server Client\n" |
| 14512 | NEIGHBOR_ADDR_STR) |
| 14513 | { |
| 14514 | struct bgp_table *table; |
| 14515 | struct peer *peer; |
| 14516 | |
| 14517 | if (argc == 2) |
| 14518 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14519 | else |
| 14520 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14521 | |
| 14522 | if (! peer) |
| 14523 | return CMD_WARNING; |
| 14524 | |
| 14525 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14526 | { |
| 14527 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14528 | VTY_NEWLINE); |
| 14529 | return CMD_WARNING; |
| 14530 | } |
| 14531 | |
| 14532 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14533 | PEER_FLAG_RSERVER_CLIENT)) |
| 14534 | { |
| 14535 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14536 | VTY_NEWLINE); |
| 14537 | return CMD_WARNING; |
| 14538 | } |
| 14539 | |
| 14540 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 14541 | |
| 14542 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14543 | } |
| 14544 | |
| 14545 | ALIAS (show_bgp_view_rsclient, |
| 14546 | show_bgp_rsclient_cmd, |
| 14547 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 14548 | SHOW_STR |
| 14549 | BGP_STR |
| 14550 | "Information about Route Server Client\n" |
| 14551 | NEIGHBOR_ADDR_STR) |
| 14552 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14553 | DEFUN (show_bgp_view_ipv4_rsclient, |
| 14554 | show_bgp_view_ipv4_rsclient_cmd, |
| 14555 | "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] | 14556 | SHOW_STR |
| 14557 | BGP_STR |
| 14558 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14559 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14560 | "Address Family\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14561 | "Information about Route Server Client\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14562 | NEIGHBOR_ADDR_STR2) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14563 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14564 | struct bgp_table *table; |
| 14565 | struct peer *peer; |
| 14566 | |
| 14567 | if (argc == 2) |
| 14568 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14569 | else |
| 14570 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14571 | |
| 14572 | if (! peer) |
| 14573 | return CMD_WARNING; |
| 14574 | |
| 14575 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 14576 | { |
| 14577 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14578 | VTY_NEWLINE); |
| 14579 | return CMD_WARNING; |
| 14580 | } |
| 14581 | |
| 14582 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 14583 | PEER_FLAG_RSERVER_CLIENT)) |
| 14584 | { |
| 14585 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14586 | VTY_NEWLINE); |
| 14587 | return CMD_WARNING; |
| 14588 | } |
| 14589 | |
| 14590 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 14591 | |
| 14592 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14593 | } |
| 14594 | DEFUN (show_bgp_view_ipv6_rsclient, |
| 14595 | show_bgp_view_ipv6_rsclient_cmd, |
| 14596 | "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)", |
| 14597 | SHOW_STR |
| 14598 | BGP_STR |
| 14599 | "BGP view\n" |
| 14600 | "BGP view name\n" |
| 14601 | "Address Family\n" |
| 14602 | "Information about Route Server Client\n" |
| 14603 | NEIGHBOR_ADDR_STR2) |
| 14604 | { |
| 14605 | struct bgp_table *table; |
| 14606 | struct peer *peer; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14607 | |
| 14608 | if (argc == 2) |
| 14609 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14610 | else |
| 14611 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14612 | |
| 14613 | if (! peer) |
| 14614 | return CMD_WARNING; |
| 14615 | |
| 14616 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14617 | { |
| 14618 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14619 | VTY_NEWLINE); |
| 14620 | return CMD_WARNING; |
| 14621 | } |
| 14622 | |
| 14623 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14624 | PEER_FLAG_RSERVER_CLIENT)) |
| 14625 | { |
| 14626 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14627 | VTY_NEWLINE); |
| 14628 | return CMD_WARNING; |
| 14629 | } |
| 14630 | |
| 14631 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 14632 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 14633 | 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] | 14634 | } |
| 14635 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14636 | ALIAS (show_bgp_view_ipv4_rsclient, |
| 14637 | show_bgp_ipv4_rsclient_cmd, |
| 14638 | "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14639 | SHOW_STR |
| 14640 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14641 | "Address Family\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14642 | "Information about Route Server Client\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14643 | NEIGHBOR_ADDR_STR2) |
| 14644 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14645 | ALIAS (show_bgp_view_ipv6_rsclient, |
| 14646 | show_bgp_ipv6_rsclient_cmd, |
| 14647 | "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)", |
| 14648 | SHOW_STR |
| 14649 | BGP_STR |
| 14650 | "Address Family\n" |
| 14651 | "Information about Route Server Client\n" |
| 14652 | NEIGHBOR_ADDR_STR2) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14653 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14654 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 14655 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 14656 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 14657 | SHOW_STR |
| 14658 | BGP_STR |
| 14659 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14660 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14661 | "Address family\n" |
| 14662 | "Address Family modifier\n" |
| 14663 | "Address Family modifier\n" |
| 14664 | "Information about Route Server Client\n" |
| 14665 | NEIGHBOR_ADDR_STR) |
| 14666 | { |
| 14667 | struct bgp_table *table; |
| 14668 | struct peer *peer; |
| 14669 | safi_t safi; |
| 14670 | |
| 14671 | if (argc == 3) { |
| 14672 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14673 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14674 | } else { |
| 14675 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14676 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14677 | } |
| 14678 | |
| 14679 | if (! peer) |
| 14680 | return CMD_WARNING; |
| 14681 | |
| 14682 | if (! peer->afc[AFI_IP6][safi]) |
| 14683 | { |
| 14684 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14685 | VTY_NEWLINE); |
| 14686 | return CMD_WARNING; |
| 14687 | } |
| 14688 | |
| 14689 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 14690 | PEER_FLAG_RSERVER_CLIENT)) |
| 14691 | { |
| 14692 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14693 | VTY_NEWLINE); |
| 14694 | return CMD_WARNING; |
| 14695 | } |
| 14696 | |
| 14697 | table = peer->rib[AFI_IP6][safi]; |
| 14698 | |
| 14699 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14700 | } |
| 14701 | |
| 14702 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 14703 | show_bgp_ipv6_safi_rsclient_cmd, |
| 14704 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 14705 | SHOW_STR |
| 14706 | BGP_STR |
| 14707 | "Address family\n" |
| 14708 | "Address Family modifier\n" |
| 14709 | "Address Family modifier\n" |
| 14710 | "Information about Route Server Client\n" |
| 14711 | NEIGHBOR_ADDR_STR) |
| 14712 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14713 | DEFUN (show_bgp_view_rsclient_route, |
| 14714 | show_bgp_view_rsclient_route_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14715 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14716 | SHOW_STR |
| 14717 | BGP_STR |
| 14718 | "BGP view\n" |
| 14719 | "View name\n" |
| 14720 | "Information about Route Server Client\n" |
| 14721 | NEIGHBOR_ADDR_STR |
| 14722 | "Network in the BGP routing table to display\n") |
| 14723 | { |
| 14724 | struct bgp *bgp; |
| 14725 | struct peer *peer; |
| 14726 | |
| 14727 | /* BGP structure lookup. */ |
| 14728 | if (argc == 3) |
| 14729 | { |
| 14730 | bgp = bgp_lookup_by_name (argv[0]); |
| 14731 | if (bgp == NULL) |
| 14732 | { |
| 14733 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14734 | return CMD_WARNING; |
| 14735 | } |
| 14736 | } |
| 14737 | else |
| 14738 | { |
| 14739 | bgp = bgp_get_default (); |
| 14740 | if (bgp == NULL) |
| 14741 | { |
| 14742 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14743 | return CMD_WARNING; |
| 14744 | } |
| 14745 | } |
| 14746 | |
| 14747 | if (argc == 3) |
| 14748 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14749 | else |
| 14750 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14751 | |
| 14752 | if (! peer) |
| 14753 | return CMD_WARNING; |
| 14754 | |
| 14755 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14756 | { |
| 14757 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14758 | VTY_NEWLINE); |
| 14759 | return CMD_WARNING; |
| 14760 | } |
| 14761 | |
| 14762 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14763 | PEER_FLAG_RSERVER_CLIENT)) |
| 14764 | { |
| 14765 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14766 | VTY_NEWLINE); |
| 14767 | return CMD_WARNING; |
| 14768 | } |
| 14769 | |
| 14770 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14771 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14772 | AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14773 | } |
| 14774 | |
| 14775 | DEFUN (show_bgp_view_ipv6_rsclient_route, |
| 14776 | show_bgp_view_ipv6_rsclient_route_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14777 | "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] | 14778 | SHOW_STR |
| 14779 | BGP_STR |
| 14780 | "BGP view\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14781 | "BGP view name\n" |
| 14782 | "IP6_STR" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14783 | "Information about Route Server Client\n" |
| 14784 | NEIGHBOR_ADDR_STR |
| 14785 | "Network in the BGP routing table to display\n") |
| 14786 | { |
| 14787 | struct bgp *bgp; |
| 14788 | struct peer *peer; |
| 14789 | |
| 14790 | /* BGP structure lookup. */ |
| 14791 | if (argc == 3) |
| 14792 | { |
| 14793 | bgp = bgp_lookup_by_name (argv[0]); |
| 14794 | if (bgp == NULL) |
| 14795 | { |
| 14796 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14797 | return CMD_WARNING; |
| 14798 | } |
| 14799 | } |
| 14800 | else |
| 14801 | { |
| 14802 | bgp = bgp_get_default (); |
| 14803 | if (bgp == NULL) |
| 14804 | { |
| 14805 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14806 | return CMD_WARNING; |
| 14807 | } |
| 14808 | } |
| 14809 | |
| 14810 | if (argc == 3) |
| 14811 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14812 | else |
| 14813 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14814 | |
| 14815 | if (! peer) |
| 14816 | return CMD_WARNING; |
| 14817 | |
| 14818 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14819 | { |
| 14820 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14821 | VTY_NEWLINE); |
| 14822 | return CMD_WARNING; |
| 14823 | } |
| 14824 | |
| 14825 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14826 | PEER_FLAG_RSERVER_CLIENT)) |
| 14827 | { |
| 14828 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14829 | VTY_NEWLINE); |
| 14830 | return CMD_WARNING; |
| 14831 | } |
| 14832 | |
| 14833 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14834 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14835 | AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14836 | } |
| 14837 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14838 | ALIAS (show_bgp_view_ipv6_rsclient_route, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14839 | show_bgp_rsclient_route_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14840 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14841 | SHOW_STR |
| 14842 | BGP_STR |
| 14843 | "Information about Route Server Client\n" |
| 14844 | NEIGHBOR_ADDR_STR |
| 14845 | "Network in the BGP routing table to display\n") |
| 14846 | |
| 14847 | ALIAS (show_bgp_view_ipv6_rsclient_route, |
| 14848 | show_bgp_ipv6_rsclient_route_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14849 | "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] | 14850 | SHOW_STR |
| 14851 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14852 | IP6_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14853 | "Information about Route Server Client\n" |
| 14854 | NEIGHBOR_ADDR_STR |
| 14855 | "Network in the BGP routing table to display\n") |
| 14856 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14857 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 14858 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 14859 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14860 | SHOW_STR |
| 14861 | BGP_STR |
| 14862 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14863 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14864 | "Address family\n" |
| 14865 | "Address Family modifier\n" |
| 14866 | "Address Family modifier\n" |
| 14867 | "Information about Route Server Client\n" |
| 14868 | NEIGHBOR_ADDR_STR |
| 14869 | "Network in the BGP routing table to display\n") |
| 14870 | { |
| 14871 | struct bgp *bgp; |
| 14872 | struct peer *peer; |
| 14873 | safi_t safi; |
| 14874 | |
| 14875 | /* BGP structure lookup. */ |
| 14876 | if (argc == 4) |
| 14877 | { |
| 14878 | bgp = bgp_lookup_by_name (argv[0]); |
| 14879 | if (bgp == NULL) |
| 14880 | { |
| 14881 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14882 | return CMD_WARNING; |
| 14883 | } |
| 14884 | } |
| 14885 | else |
| 14886 | { |
| 14887 | bgp = bgp_get_default (); |
| 14888 | if (bgp == NULL) |
| 14889 | { |
| 14890 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14891 | return CMD_WARNING; |
| 14892 | } |
| 14893 | } |
| 14894 | |
| 14895 | if (argc == 4) { |
| 14896 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14897 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14898 | } else { |
| 14899 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14900 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14901 | } |
| 14902 | |
| 14903 | if (! peer) |
| 14904 | return CMD_WARNING; |
| 14905 | |
| 14906 | if (! peer->afc[AFI_IP6][safi]) |
| 14907 | { |
| 14908 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14909 | VTY_NEWLINE); |
| 14910 | return CMD_WARNING; |
| 14911 | } |
| 14912 | |
| 14913 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 14914 | PEER_FLAG_RSERVER_CLIENT)) |
| 14915 | { |
| 14916 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14917 | VTY_NEWLINE); |
| 14918 | return CMD_WARNING; |
| 14919 | } |
| 14920 | |
| 14921 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 14922 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14923 | AFI_IP6, safi, NULL, 0, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14924 | } |
| 14925 | |
| 14926 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 14927 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 14928 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14929 | SHOW_STR |
| 14930 | BGP_STR |
| 14931 | "Address family\n" |
| 14932 | "Address Family modifier\n" |
| 14933 | "Address Family modifier\n" |
| 14934 | "Information about Route Server Client\n" |
| 14935 | NEIGHBOR_ADDR_STR |
| 14936 | "Network in the BGP routing table to display\n") |
| 14937 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14938 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14939 | DEFUN (show_bgp_view_rsclient_prefix, |
| 14940 | show_bgp_view_rsclient_prefix_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14941 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 14942 | SHOW_STR |
| 14943 | BGP_STR |
| 14944 | "BGP view\n" |
| 14945 | "View name\n" |
| 14946 | "Information about Route Server Client\n" |
| 14947 | NEIGHBOR_ADDR_STR |
| 14948 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14949 | { |
| 14950 | struct bgp *bgp; |
| 14951 | struct peer *peer; |
| 14952 | |
| 14953 | /* BGP structure lookup. */ |
| 14954 | if (argc == 3) |
| 14955 | { |
| 14956 | bgp = bgp_lookup_by_name (argv[0]); |
| 14957 | if (bgp == NULL) |
| 14958 | { |
| 14959 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14960 | return CMD_WARNING; |
| 14961 | } |
| 14962 | } |
| 14963 | else |
| 14964 | { |
| 14965 | bgp = bgp_get_default (); |
| 14966 | if (bgp == NULL) |
| 14967 | { |
| 14968 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14969 | return CMD_WARNING; |
| 14970 | } |
| 14971 | } |
| 14972 | |
| 14973 | if (argc == 3) |
| 14974 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14975 | else |
| 14976 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14977 | |
| 14978 | if (! peer) |
| 14979 | return CMD_WARNING; |
| 14980 | |
| 14981 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14982 | { |
| 14983 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14984 | VTY_NEWLINE); |
| 14985 | return CMD_WARNING; |
| 14986 | } |
| 14987 | |
| 14988 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14989 | PEER_FLAG_RSERVER_CLIENT)) |
| 14990 | { |
| 14991 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14992 | VTY_NEWLINE); |
| 14993 | return CMD_WARNING; |
| 14994 | } |
| 14995 | |
| 14996 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14997 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14998 | AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14999 | } |
| 15000 | |
| 15001 | DEFUN (show_bgp_view_ipv6_rsclient_prefix, |
| 15002 | show_bgp_view_ipv6_rsclient_prefix_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15003 | "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] | 15004 | SHOW_STR |
| 15005 | BGP_STR |
| 15006 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15007 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15008 | IP6_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15009 | "Information about Route Server Client\n" |
| 15010 | NEIGHBOR_ADDR_STR |
| 15011 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15012 | { |
| 15013 | struct bgp *bgp; |
| 15014 | struct peer *peer; |
| 15015 | |
| 15016 | /* BGP structure lookup. */ |
| 15017 | if (argc == 3) |
| 15018 | { |
| 15019 | bgp = bgp_lookup_by_name (argv[0]); |
| 15020 | if (bgp == NULL) |
| 15021 | { |
| 15022 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 15023 | return CMD_WARNING; |
| 15024 | } |
| 15025 | } |
| 15026 | else |
| 15027 | { |
| 15028 | bgp = bgp_get_default (); |
| 15029 | if (bgp == NULL) |
| 15030 | { |
| 15031 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 15032 | return CMD_WARNING; |
| 15033 | } |
| 15034 | } |
| 15035 | |
| 15036 | if (argc == 3) |
| 15037 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 15038 | else |
| 15039 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 15040 | |
| 15041 | if (! peer) |
| 15042 | return CMD_WARNING; |
| 15043 | |
| 15044 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 15045 | { |
| 15046 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 15047 | VTY_NEWLINE); |
| 15048 | return CMD_WARNING; |
| 15049 | } |
| 15050 | |
| 15051 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 15052 | PEER_FLAG_RSERVER_CLIENT)) |
| 15053 | { |
| 15054 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 15055 | VTY_NEWLINE); |
| 15056 | return CMD_WARNING; |
| 15057 | } |
| 15058 | |
| 15059 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 15060 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 15061 | AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15062 | } |
| 15063 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15064 | ALIAS (show_bgp_view_ipv6_rsclient_prefix, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15065 | show_bgp_rsclient_prefix_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15066 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 15067 | SHOW_STR |
| 15068 | BGP_STR |
| 15069 | "Information about Route Server Client\n" |
| 15070 | NEIGHBOR_ADDR_STR |
| 15071 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15072 | |
| 15073 | ALIAS (show_bgp_view_ipv6_rsclient_prefix, |
| 15074 | show_bgp_ipv6_rsclient_prefix_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15075 | "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] | 15076 | SHOW_STR |
| 15077 | BGP_STR |
| 15078 | "Information about Route Server Client\n" |
| 15079 | NEIGHBOR_ADDR_STR |
| 15080 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15081 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15082 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 15083 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 15084 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 15085 | SHOW_STR |
| 15086 | BGP_STR |
| 15087 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15088 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15089 | "Address family\n" |
| 15090 | "Address Family modifier\n" |
| 15091 | "Address Family modifier\n" |
| 15092 | "Information about Route Server Client\n" |
| 15093 | NEIGHBOR_ADDR_STR |
| 15094 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15095 | { |
| 15096 | struct bgp *bgp; |
| 15097 | struct peer *peer; |
| 15098 | safi_t safi; |
| 15099 | |
| 15100 | /* BGP structure lookup. */ |
| 15101 | if (argc == 4) |
| 15102 | { |
| 15103 | bgp = bgp_lookup_by_name (argv[0]); |
| 15104 | if (bgp == NULL) |
| 15105 | { |
| 15106 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 15107 | return CMD_WARNING; |
| 15108 | } |
| 15109 | } |
| 15110 | else |
| 15111 | { |
| 15112 | bgp = bgp_get_default (); |
| 15113 | if (bgp == NULL) |
| 15114 | { |
| 15115 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 15116 | return CMD_WARNING; |
| 15117 | } |
| 15118 | } |
| 15119 | |
| 15120 | if (argc == 4) { |
| 15121 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 15122 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 15123 | } else { |
| 15124 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 15125 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 15126 | } |
| 15127 | |
| 15128 | if (! peer) |
| 15129 | return CMD_WARNING; |
| 15130 | |
| 15131 | if (! peer->afc[AFI_IP6][safi]) |
| 15132 | { |
| 15133 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 15134 | VTY_NEWLINE); |
| 15135 | return CMD_WARNING; |
| 15136 | } |
| 15137 | |
| 15138 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 15139 | PEER_FLAG_RSERVER_CLIENT)) |
| 15140 | { |
| 15141 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 15142 | VTY_NEWLINE); |
| 15143 | return CMD_WARNING; |
| 15144 | } |
| 15145 | |
| 15146 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 15147 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 15148 | AFI_IP6, safi, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15149 | } |
| 15150 | |
| 15151 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 15152 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 15153 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 15154 | SHOW_STR |
| 15155 | BGP_STR |
| 15156 | "Address family\n" |
| 15157 | "Address Family modifier\n" |
| 15158 | "Address Family modifier\n" |
| 15159 | "Information about Route Server Client\n" |
| 15160 | NEIGHBOR_ADDR_STR |
| 15161 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15162 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15163 | struct bgp_table *bgp_distance_table; |
| 15164 | |
| 15165 | struct bgp_distance |
| 15166 | { |
| 15167 | /* Distance value for the IP source prefix. */ |
| 15168 | u_char distance; |
| 15169 | |
| 15170 | /* Name of the access-list to be matched. */ |
| 15171 | char *access_list; |
| 15172 | }; |
| 15173 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15174 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 15175 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15176 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 15177 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15178 | } |
| 15179 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15180 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15181 | bgp_distance_free (struct bgp_distance *bdistance) |
| 15182 | { |
| 15183 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 15184 | } |
| 15185 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15186 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 15187 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 15188 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15189 | { |
| 15190 | int ret; |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15191 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15192 | u_char distance; |
| 15193 | struct bgp_node *rn; |
| 15194 | struct bgp_distance *bdistance; |
| 15195 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15196 | ret = str2prefix (ip_str, &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15197 | if (ret == 0) |
| 15198 | { |
| 15199 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 15200 | return CMD_WARNING; |
| 15201 | } |
| 15202 | |
| 15203 | distance = atoi (distance_str); |
| 15204 | |
| 15205 | /* Get BGP distance node. */ |
| 15206 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 15207 | if (rn->info) |
| 15208 | { |
| 15209 | bdistance = rn->info; |
| 15210 | bgp_unlock_node (rn); |
| 15211 | } |
| 15212 | else |
| 15213 | { |
| 15214 | bdistance = bgp_distance_new (); |
| 15215 | rn->info = bdistance; |
| 15216 | } |
| 15217 | |
| 15218 | /* Set distance value. */ |
| 15219 | bdistance->distance = distance; |
| 15220 | |
| 15221 | /* Reset access-list configuration. */ |
| 15222 | if (bdistance->access_list) |
| 15223 | { |
| 15224 | free (bdistance->access_list); |
| 15225 | bdistance->access_list = NULL; |
| 15226 | } |
| 15227 | if (access_list_str) |
| 15228 | bdistance->access_list = strdup (access_list_str); |
| 15229 | |
| 15230 | return CMD_SUCCESS; |
| 15231 | } |
| 15232 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15233 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 15234 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 15235 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15236 | { |
| 15237 | int ret; |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15238 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15239 | u_char distance; |
| 15240 | struct bgp_node *rn; |
| 15241 | struct bgp_distance *bdistance; |
| 15242 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15243 | ret = str2prefix (ip_str, &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15244 | if (ret == 0) |
| 15245 | { |
| 15246 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 15247 | return CMD_WARNING; |
| 15248 | } |
| 15249 | |
| 15250 | distance = atoi (distance_str); |
| 15251 | |
| 15252 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 15253 | if (! rn) |
| 15254 | { |
| 15255 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 15256 | return CMD_WARNING; |
| 15257 | } |
| 15258 | |
| 15259 | bdistance = rn->info; |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 15260 | |
| 15261 | if (bdistance->distance != distance) |
| 15262 | { |
| 15263 | vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); |
| 15264 | return CMD_WARNING; |
| 15265 | } |
| 15266 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15267 | if (bdistance->access_list) |
| 15268 | free (bdistance->access_list); |
| 15269 | bgp_distance_free (bdistance); |
| 15270 | |
| 15271 | rn->info = NULL; |
| 15272 | bgp_unlock_node (rn); |
| 15273 | bgp_unlock_node (rn); |
| 15274 | |
| 15275 | return CMD_SUCCESS; |
| 15276 | } |
| 15277 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15278 | /* Apply BGP information to distance method. */ |
| 15279 | u_char |
| 15280 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 15281 | { |
| 15282 | struct bgp_node *rn; |
| 15283 | struct prefix_ipv4 q; |
| 15284 | struct peer *peer; |
| 15285 | struct bgp_distance *bdistance; |
| 15286 | struct access_list *alist; |
| 15287 | struct bgp_static *bgp_static; |
| 15288 | |
| 15289 | if (! bgp) |
| 15290 | return 0; |
| 15291 | |
| 15292 | if (p->family != AF_INET) |
| 15293 | return 0; |
| 15294 | |
| 15295 | peer = rinfo->peer; |
| 15296 | |
| 15297 | if (peer->su.sa.sa_family != AF_INET) |
| 15298 | return 0; |
| 15299 | |
| 15300 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 15301 | q.family = AF_INET; |
| 15302 | q.prefix = peer->su.sin.sin_addr; |
| 15303 | q.prefixlen = IPV4_MAX_BITLEN; |
| 15304 | |
| 15305 | /* Check source address. */ |
| 15306 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 15307 | if (rn) |
| 15308 | { |
| 15309 | bdistance = rn->info; |
| 15310 | bgp_unlock_node (rn); |
| 15311 | |
| 15312 | if (bdistance->access_list) |
| 15313 | { |
| 15314 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 15315 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 15316 | return bdistance->distance; |
| 15317 | } |
| 15318 | else |
| 15319 | return bdistance->distance; |
| 15320 | } |
| 15321 | |
| 15322 | /* Backdoor check. */ |
| 15323 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 15324 | if (rn) |
| 15325 | { |
| 15326 | bgp_static = rn->info; |
| 15327 | bgp_unlock_node (rn); |
| 15328 | |
| 15329 | if (bgp_static->backdoor) |
| 15330 | { |
| 15331 | if (bgp->distance_local) |
| 15332 | return bgp->distance_local; |
| 15333 | else |
| 15334 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15335 | } |
| 15336 | } |
| 15337 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 15338 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15339 | { |
| 15340 | if (bgp->distance_ebgp) |
| 15341 | return bgp->distance_ebgp; |
| 15342 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 15343 | } |
| 15344 | else |
| 15345 | { |
| 15346 | if (bgp->distance_ibgp) |
| 15347 | return bgp->distance_ibgp; |
| 15348 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15349 | } |
| 15350 | } |
| 15351 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15352 | #ifdef HAVE_IPV6 |
| 15353 | /* Apply BGP information to ipv6 distance method. */ |
| 15354 | u_char |
| 15355 | ipv6_bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 15356 | { |
| 15357 | struct bgp_node *rn; |
| 15358 | struct prefix_ipv6 q; |
| 15359 | struct peer *peer; |
| 15360 | struct bgp_distance *bdistance; |
| 15361 | struct access_list *alist; |
| 15362 | struct bgp_static *bgp_static; |
| 15363 | |
| 15364 | if (! bgp) |
| 15365 | return 0; |
| 15366 | |
| 15367 | if (p->family != AF_INET6) |
| 15368 | return 0; |
| 15369 | |
| 15370 | peer = rinfo->peer; |
| 15371 | |
| 15372 | if (peer->su.sa.sa_family != AF_INET6) |
| 15373 | return 0; |
| 15374 | |
| 15375 | memset (&q, 0, sizeof (struct prefix_ipv6)); |
| 15376 | q.family = AF_INET; |
| 15377 | q.prefix = peer->su.sin6.sin6_addr; |
| 15378 | q.prefixlen = IPV6_MAX_BITLEN; |
| 15379 | |
| 15380 | /* Check source address. */ |
| 15381 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 15382 | if (rn) |
| 15383 | { |
| 15384 | bdistance = rn->info; |
| 15385 | bgp_unlock_node (rn); |
| 15386 | |
| 15387 | if (bdistance->access_list) |
| 15388 | { |
| 15389 | alist = access_list_lookup (AFI_IP6, bdistance->access_list); |
| 15390 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 15391 | return bdistance->distance; |
| 15392 | } |
| 15393 | else |
| 15394 | return bdistance->distance; |
| 15395 | } |
| 15396 | /* Backdoor check. */ |
| 15397 | rn = bgp_node_lookup (bgp->route[AFI_IP6][SAFI_UNICAST], p); |
| 15398 | if (rn) |
| 15399 | { |
| 15400 | bgp_static = rn->info; |
| 15401 | bgp_unlock_node (rn); |
| 15402 | |
| 15403 | if (bgp_static->backdoor) |
| 15404 | { |
| 15405 | if (bgp->ipv6_distance_local) |
| 15406 | return bgp->ipv6_distance_local; |
| 15407 | else |
| 15408 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15409 | } |
| 15410 | } |
| 15411 | |
| 15412 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 15413 | { |
| 15414 | if (bgp->ipv6_distance_ebgp) |
| 15415 | return bgp->ipv6_distance_ebgp; |
| 15416 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 15417 | } |
| 15418 | else |
| 15419 | { |
| 15420 | if (bgp->ipv6_distance_ibgp) |
| 15421 | return bgp->ipv6_distance_ibgp; |
| 15422 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15423 | } |
| 15424 | } |
| 15425 | #endif /* HAVE_IPV6 */ |
| 15426 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15427 | DEFUN (bgp_distance, |
| 15428 | bgp_distance_cmd, |
| 15429 | "distance bgp <1-255> <1-255> <1-255>", |
| 15430 | "Define an administrative distance\n" |
| 15431 | "BGP distance\n" |
| 15432 | "Distance for routes external to the AS\n" |
| 15433 | "Distance for routes internal to the AS\n" |
| 15434 | "Distance for local routes\n") |
| 15435 | { |
| 15436 | struct bgp *bgp; |
| 15437 | |
| 15438 | bgp = vty->index; |
| 15439 | |
| 15440 | bgp->distance_ebgp = atoi (argv[0]); |
| 15441 | bgp->distance_ibgp = atoi (argv[1]); |
| 15442 | bgp->distance_local = atoi (argv[2]); |
| 15443 | return CMD_SUCCESS; |
| 15444 | } |
| 15445 | |
| 15446 | DEFUN (no_bgp_distance, |
| 15447 | no_bgp_distance_cmd, |
| 15448 | "no distance bgp <1-255> <1-255> <1-255>", |
| 15449 | NO_STR |
| 15450 | "Define an administrative distance\n" |
| 15451 | "BGP distance\n" |
| 15452 | "Distance for routes external to the AS\n" |
| 15453 | "Distance for routes internal to the AS\n" |
| 15454 | "Distance for local routes\n") |
| 15455 | { |
| 15456 | struct bgp *bgp; |
| 15457 | |
| 15458 | bgp = vty->index; |
| 15459 | |
| 15460 | bgp->distance_ebgp= 0; |
| 15461 | bgp->distance_ibgp = 0; |
| 15462 | bgp->distance_local = 0; |
| 15463 | return CMD_SUCCESS; |
| 15464 | } |
| 15465 | |
| 15466 | ALIAS (no_bgp_distance, |
| 15467 | no_bgp_distance2_cmd, |
| 15468 | "no distance bgp", |
| 15469 | NO_STR |
| 15470 | "Define an administrative distance\n" |
| 15471 | "BGP distance\n") |
| 15472 | |
| 15473 | DEFUN (bgp_distance_source, |
| 15474 | bgp_distance_source_cmd, |
| 15475 | "distance <1-255> A.B.C.D/M", |
| 15476 | "Define an administrative distance\n" |
| 15477 | "Administrative distance\n" |
| 15478 | "IP source prefix\n") |
| 15479 | { |
| 15480 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 15481 | return CMD_SUCCESS; |
| 15482 | } |
| 15483 | |
| 15484 | DEFUN (no_bgp_distance_source, |
| 15485 | no_bgp_distance_source_cmd, |
| 15486 | "no distance <1-255> A.B.C.D/M", |
| 15487 | NO_STR |
| 15488 | "Define an administrative distance\n" |
| 15489 | "Administrative distance\n" |
| 15490 | "IP source prefix\n") |
| 15491 | { |
| 15492 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 15493 | return CMD_SUCCESS; |
| 15494 | } |
| 15495 | |
| 15496 | DEFUN (bgp_distance_source_access_list, |
| 15497 | bgp_distance_source_access_list_cmd, |
| 15498 | "distance <1-255> A.B.C.D/M WORD", |
| 15499 | "Define an administrative distance\n" |
| 15500 | "Administrative distance\n" |
| 15501 | "IP source prefix\n" |
| 15502 | "Access list name\n") |
| 15503 | { |
| 15504 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 15505 | return CMD_SUCCESS; |
| 15506 | } |
| 15507 | |
| 15508 | DEFUN (no_bgp_distance_source_access_list, |
| 15509 | no_bgp_distance_source_access_list_cmd, |
| 15510 | "no distance <1-255> A.B.C.D/M WORD", |
| 15511 | NO_STR |
| 15512 | "Define an administrative distance\n" |
| 15513 | "Administrative distance\n" |
| 15514 | "IP source prefix\n" |
| 15515 | "Access list name\n") |
| 15516 | { |
| 15517 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 15518 | return CMD_SUCCESS; |
| 15519 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15520 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15521 | #ifdef HAVE_IPV6 |
| 15522 | DEFUN (ipv6_bgp_distance, |
| 15523 | ipv6_bgp_distance_cmd, |
| 15524 | "distance bgp <1-255> <1-255> <1-255>", |
| 15525 | "Define an administrative distance\n" |
| 15526 | "BGP distance\n" |
| 15527 | "Distance for routes external to the AS\n" |
| 15528 | "Distance for routes internal to the AS\n" |
| 15529 | "Distance for local routes\n") |
| 15530 | { |
| 15531 | struct bgp *bgp; |
| 15532 | |
| 15533 | bgp = vty->index; |
| 15534 | |
| 15535 | bgp->ipv6_distance_ebgp = atoi (argv[0]); |
| 15536 | bgp->ipv6_distance_ibgp = atoi (argv[1]); |
| 15537 | bgp->ipv6_distance_local = atoi (argv[2]); |
| 15538 | return CMD_SUCCESS; |
| 15539 | } |
| 15540 | |
| 15541 | DEFUN (no_ipv6_bgp_distance, |
| 15542 | no_ipv6_bgp_distance_cmd, |
| 15543 | "no distance bgp <1-255> <1-255> <1-255>", |
| 15544 | NO_STR |
| 15545 | "Define an administrative distance\n" |
| 15546 | "BGP distance\n" |
| 15547 | "Distance for routes external to the AS\n" |
| 15548 | "Distance for routes internal to the AS\n" |
| 15549 | "Distance for local routes\n") |
| 15550 | { |
| 15551 | struct bgp *bgp; |
| 15552 | |
| 15553 | bgp = vty->index; |
| 15554 | |
| 15555 | bgp->ipv6_distance_ebgp= 0; |
| 15556 | bgp->ipv6_distance_ibgp = 0; |
| 15557 | bgp->ipv6_distance_local = 0; |
| 15558 | return CMD_SUCCESS; |
| 15559 | } |
| 15560 | |
| 15561 | ALIAS (no_ipv6_bgp_distance, |
| 15562 | no_ipv6_bgp_distance2_cmd, |
| 15563 | "no distance bgp", |
| 15564 | NO_STR |
| 15565 | "Define an administrative distance\n" |
| 15566 | "BGP distance\n") |
| 15567 | |
| 15568 | DEFUN (ipv6_bgp_distance_source, |
| 15569 | ipv6_bgp_distance_source_cmd, |
| 15570 | "distance <1-255> X:X::X:X/M", |
| 15571 | "Define an administrative distance\n" |
| 15572 | "Administrative distance\n" |
| 15573 | "IP source prefix\n") |
| 15574 | { |
| 15575 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 15576 | return CMD_SUCCESS; |
| 15577 | } |
| 15578 | |
| 15579 | DEFUN (no_ipv6_bgp_distance_source, |
| 15580 | no_ipv6_bgp_distance_source_cmd, |
| 15581 | "no distance <1-255> X:X::X:X/M", |
| 15582 | NO_STR |
| 15583 | "Define an administrative distance\n" |
| 15584 | "Administrative distance\n" |
| 15585 | "IP source prefix\n") |
| 15586 | { |
| 15587 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 15588 | return CMD_SUCCESS; |
| 15589 | } |
| 15590 | |
| 15591 | DEFUN (ipv6_bgp_distance_source_access_list, |
| 15592 | ipv6_bgp_distance_source_access_list_cmd, |
| 15593 | "distance <1-255> X:X::X:X/M WORD", |
| 15594 | "Define an administrative distance\n" |
| 15595 | "Administrative distance\n" |
| 15596 | "IP source prefix\n" |
| 15597 | "Access list name\n") |
| 15598 | { |
| 15599 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 15600 | return CMD_SUCCESS; |
| 15601 | } |
| 15602 | |
| 15603 | DEFUN (no_ipv6_bgp_distance_source_access_list, |
| 15604 | no_ipv6_bgp_distance_source_access_list_cmd, |
| 15605 | "no distance <1-255> X:X::X:X/M WORD", |
| 15606 | NO_STR |
| 15607 | "Define an administrative distance\n" |
| 15608 | "Administrative distance\n" |
| 15609 | "IP source prefix\n" |
| 15610 | "Access list name\n") |
| 15611 | { |
| 15612 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 15613 | return CMD_SUCCESS; |
| 15614 | } |
| 15615 | #endif |
| 15616 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15617 | DEFUN (bgp_damp_set, |
| 15618 | bgp_damp_set_cmd, |
| 15619 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 15620 | "BGP Specific commands\n" |
| 15621 | "Enable route-flap dampening\n" |
| 15622 | "Half-life time for the penalty\n" |
| 15623 | "Value to start reusing a route\n" |
| 15624 | "Value to start suppressing a route\n" |
| 15625 | "Maximum duration to suppress a stable route\n") |
| 15626 | { |
| 15627 | struct bgp *bgp; |
| 15628 | int half = DEFAULT_HALF_LIFE * 60; |
| 15629 | int reuse = DEFAULT_REUSE; |
| 15630 | int suppress = DEFAULT_SUPPRESS; |
| 15631 | int max = 4 * half; |
| 15632 | |
| 15633 | if (argc == 4) |
| 15634 | { |
| 15635 | half = atoi (argv[0]) * 60; |
| 15636 | reuse = atoi (argv[1]); |
| 15637 | suppress = atoi (argv[2]); |
| 15638 | max = atoi (argv[3]) * 60; |
| 15639 | } |
| 15640 | else if (argc == 1) |
| 15641 | { |
| 15642 | half = atoi (argv[0]) * 60; |
| 15643 | max = 4 * half; |
| 15644 | } |
| 15645 | |
| 15646 | bgp = vty->index; |
Balaji | aa7dbb1 | 2015-03-16 16:55:26 +0000 | [diff] [blame] | 15647 | |
| 15648 | if (suppress < reuse) |
| 15649 | { |
| 15650 | vty_out (vty, "Suppress value cannot be less than reuse value %s", |
| 15651 | VTY_NEWLINE); |
| 15652 | return 0; |
| 15653 | } |
| 15654 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15655 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 15656 | half, reuse, suppress, max); |
| 15657 | } |
| 15658 | |
| 15659 | ALIAS (bgp_damp_set, |
| 15660 | bgp_damp_set2_cmd, |
| 15661 | "bgp dampening <1-45>", |
| 15662 | "BGP Specific commands\n" |
| 15663 | "Enable route-flap dampening\n" |
| 15664 | "Half-life time for the penalty\n") |
| 15665 | |
| 15666 | ALIAS (bgp_damp_set, |
| 15667 | bgp_damp_set3_cmd, |
| 15668 | "bgp dampening", |
| 15669 | "BGP Specific commands\n" |
| 15670 | "Enable route-flap dampening\n") |
| 15671 | |
| 15672 | DEFUN (bgp_damp_unset, |
| 15673 | bgp_damp_unset_cmd, |
| 15674 | "no bgp dampening", |
| 15675 | NO_STR |
| 15676 | "BGP Specific commands\n" |
| 15677 | "Enable route-flap dampening\n") |
| 15678 | { |
| 15679 | struct bgp *bgp; |
| 15680 | |
| 15681 | bgp = vty->index; |
| 15682 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 15683 | } |
| 15684 | |
| 15685 | ALIAS (bgp_damp_unset, |
| 15686 | bgp_damp_unset2_cmd, |
| 15687 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 15688 | NO_STR |
| 15689 | "BGP Specific commands\n" |
| 15690 | "Enable route-flap dampening\n" |
| 15691 | "Half-life time for the penalty\n" |
| 15692 | "Value to start reusing a route\n" |
| 15693 | "Value to start suppressing a route\n" |
| 15694 | "Maximum duration to suppress a stable route\n") |
| 15695 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15696 | DEFUN (show_ip_bgp_dampened_paths, |
| 15697 | show_ip_bgp_dampened_paths_cmd, |
| 15698 | "show ip bgp dampened-paths", |
| 15699 | SHOW_STR |
| 15700 | IP_STR |
| 15701 | BGP_STR |
| 15702 | "Display paths suppressed due to dampening\n") |
| 15703 | { |
| 15704 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 15705 | NULL); |
| 15706 | } |
| 15707 | |
| 15708 | ALIAS (show_ip_bgp_dampened_paths, |
| 15709 | show_ip_bgp_damp_dampened_paths_cmd, |
| 15710 | "show ip bgp dampening dampened-paths", |
| 15711 | SHOW_STR |
| 15712 | IP_STR |
| 15713 | BGP_STR |
| 15714 | "Display detailed information about dampening\n" |
| 15715 | "Display paths suppressed due to dampening\n") |
| 15716 | |
| 15717 | DEFUN (show_ip_bgp_flap_statistics, |
| 15718 | show_ip_bgp_flap_statistics_cmd, |
| 15719 | "show ip bgp flap-statistics", |
| 15720 | SHOW_STR |
| 15721 | IP_STR |
| 15722 | BGP_STR |
| 15723 | "Display flap statistics of routes\n") |
| 15724 | { |
| 15725 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 15726 | bgp_show_type_flap_statistics, NULL); |
| 15727 | } |
| 15728 | |
| 15729 | ALIAS (show_ip_bgp_flap_statistics, |
| 15730 | show_ip_bgp_damp_flap_statistics_cmd, |
| 15731 | "show ip bgp dampening flap-statistics", |
| 15732 | SHOW_STR |
| 15733 | IP_STR |
| 15734 | BGP_STR |
| 15735 | "Display detailed information about dampening\n" |
| 15736 | "Display flap statistics of routes\n") |
| 15737 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15738 | DEFUN (show_bgp_ipv4_safi_dampened_paths, |
| 15739 | show_bgp_ipv4_safi_dampened_paths_cmd, |
| 15740 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15741 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15742 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15743 | IP_STR |
| 15744 | "Address Family modifier\n" |
| 15745 | "Address Family modifier\n" |
| 15746 | "Address Family modifier\n" |
| 15747 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15748 | "Display paths suppressed due to dampening\n") |
| 15749 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15750 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15751 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15752 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15753 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15754 | return CMD_WARNING; |
| 15755 | } |
| 15756 | |
| 15757 | return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL); |
| 15758 | } |
| 15759 | ALIAS (show_bgp_ipv4_safi_dampened_paths, |
| 15760 | show_bgp_ipv4_safi_damp_dampened_paths_cmd, |
| 15761 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15762 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15763 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15764 | IP_STR |
| 15765 | "Address Family modifier\n" |
| 15766 | "Address Family modifier\n" |
| 15767 | "Address Family modifier\n" |
| 15768 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15769 | "Display detailed information about dampening\n" |
| 15770 | "Display paths suppressed due to dampening\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 15771 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15772 | DEFUN (show_bgp_ipv6_safi_dampened_paths, |
| 15773 | show_bgp_ipv6_safi_dampened_paths_cmd, |
| 15774 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15775 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15776 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15777 | IPV6_STR |
| 15778 | "Address Family modifier\n" |
| 15779 | "Address Family modifier\n" |
| 15780 | "Address Family modifier\n" |
| 15781 | "Address Family modifier\n" |
| 15782 | "Display paths suppressed due to dampening\n") |
| 15783 | { |
| 15784 | safi_t safi; |
| 15785 | |
| 15786 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15787 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15788 | return CMD_WARNING; |
| 15789 | } |
| 15790 | |
| 15791 | return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL); |
| 15792 | } |
| 15793 | ALIAS (show_bgp_ipv6_safi_dampened_paths, |
| 15794 | show_bgp_ipv6_safi_damp_dampened_paths_cmd, |
| 15795 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths", |
| 15796 | SHOW_STR |
| 15797 | BGP_STR |
| 15798 | IPV6_STR |
| 15799 | "Address Family modifier\n" |
| 15800 | "Address Family modifier\n" |
| 15801 | "Address Family modifier\n" |
| 15802 | "Address Family modifier\n" |
| 15803 | "Display detailed information about dampening\n" |
| 15804 | "Display paths suppressed due to dampening\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15805 | |
| 15806 | DEFUN (show_bgp_ipv4_safi_flap_statistics, |
| 15807 | show_bgp_ipv4_safi_flap_statistics_cmd, |
| 15808 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics", |
| 15809 | SHOW_STR |
| 15810 | BGP_STR |
| 15811 | "Address Family\n" |
| 15812 | "Address Family modifier\n" |
| 15813 | "Address Family modifier\n" |
| 15814 | "Address Family modifier\n" |
| 15815 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15816 | "Display flap statistics of routes\n") |
| 15817 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15818 | safi_t safi; |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15819 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15820 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15821 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15822 | return CMD_WARNING; |
| 15823 | } |
| 15824 | |
| 15825 | return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL); |
| 15826 | } |
| 15827 | ALIAS (show_bgp_ipv4_safi_flap_statistics, |
| 15828 | show_bgp_ipv4_safi_damp_flap_statistics_cmd, |
| 15829 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15830 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15831 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15832 | "Address Family\n" |
| 15833 | "Address Family modifier\n" |
| 15834 | "Address Family modifier\n" |
| 15835 | "Address Family modifier\n" |
| 15836 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15837 | "Display detailed information about dampening\n" |
| 15838 | "Display flap statistics of routes\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 15839 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15840 | DEFUN (show_bgp_ipv6_safi_flap_statistics, |
| 15841 | show_bgp_ipv6_safi_flap_statistics_cmd, |
| 15842 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics", |
| 15843 | SHOW_STR |
| 15844 | BGP_STR |
| 15845 | "Address Family\n" |
| 15846 | "Address Family modifier\n" |
| 15847 | "Address Family modifier\n" |
| 15848 | "Address Family modifier\n" |
| 15849 | "Address Family modifier\n" |
| 15850 | "Display flap statistics of routes\n") |
| 15851 | { |
| 15852 | safi_t safi; |
| 15853 | |
| 15854 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15855 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15856 | return CMD_WARNING; |
| 15857 | } |
| 15858 | |
| 15859 | return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL); |
| 15860 | } |
| 15861 | ALIAS (show_bgp_ipv6_safi_flap_statistics, |
| 15862 | show_bgp_ipv6_safi_damp_flap_statistics_cmd, |
| 15863 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics", |
| 15864 | SHOW_STR |
| 15865 | BGP_STR |
| 15866 | "Address Family\n" |
| 15867 | "Address Family modifier\n" |
| 15868 | "Address Family modifier\n" |
| 15869 | "Address Family modifier\n" |
| 15870 | "Address Family modifier\n" |
| 15871 | "Display detailed information about dampening\n" |
| 15872 | "Display flap statistics of routes\n") |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15873 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15874 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15875 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 15876 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 15877 | const char *ip_str, afi_t afi, safi_t safi, |
| 15878 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15879 | { |
| 15880 | int ret; |
| 15881 | struct prefix match; |
| 15882 | struct bgp_node *rn; |
| 15883 | struct bgp_node *rm; |
| 15884 | struct bgp_info *ri; |
| 15885 | struct bgp_info *ri_temp; |
| 15886 | struct bgp *bgp; |
| 15887 | struct bgp_table *table; |
| 15888 | |
| 15889 | /* BGP structure lookup. */ |
| 15890 | if (view_name) |
| 15891 | { |
| 15892 | bgp = bgp_lookup_by_name (view_name); |
| 15893 | if (bgp == NULL) |
| 15894 | { |
| 15895 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 15896 | return CMD_WARNING; |
| 15897 | } |
| 15898 | } |
| 15899 | else |
| 15900 | { |
| 15901 | bgp = bgp_get_default (); |
| 15902 | if (bgp == NULL) |
| 15903 | { |
| 15904 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 15905 | return CMD_WARNING; |
| 15906 | } |
| 15907 | } |
| 15908 | |
| 15909 | /* Check IP address argument. */ |
| 15910 | ret = str2prefix (ip_str, &match); |
| 15911 | if (! ret) |
| 15912 | { |
| 15913 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 15914 | return CMD_WARNING; |
| 15915 | } |
| 15916 | |
| 15917 | match.family = afi2family (afi); |
| 15918 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15919 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15920 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15921 | 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] | 15922 | { |
| 15923 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 15924 | continue; |
| 15925 | |
| 15926 | if ((table = rn->info) != NULL) |
| 15927 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 15928 | { |
| 15929 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 15930 | { |
| 15931 | ri = rm->info; |
| 15932 | while (ri) |
| 15933 | { |
| 15934 | if (ri->extra && ri->extra->damp_info) |
| 15935 | { |
| 15936 | ri_temp = ri->next; |
| 15937 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 15938 | ri = ri_temp; |
| 15939 | } |
| 15940 | else |
| 15941 | ri = ri->next; |
| 15942 | } |
| 15943 | } |
| 15944 | |
| 15945 | bgp_unlock_node (rm); |
| 15946 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15947 | } |
| 15948 | } |
| 15949 | else |
| 15950 | { |
| 15951 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 15952 | { |
| 15953 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 15954 | { |
| 15955 | ri = rn->info; |
| 15956 | while (ri) |
| 15957 | { |
| 15958 | if (ri->extra && ri->extra->damp_info) |
| 15959 | { |
| 15960 | ri_temp = ri->next; |
| 15961 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 15962 | ri = ri_temp; |
| 15963 | } |
| 15964 | else |
| 15965 | ri = ri->next; |
| 15966 | } |
| 15967 | } |
| 15968 | |
| 15969 | bgp_unlock_node (rn); |
| 15970 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15971 | } |
| 15972 | |
| 15973 | return CMD_SUCCESS; |
| 15974 | } |
| 15975 | |
| 15976 | DEFUN (clear_ip_bgp_dampening, |
| 15977 | clear_ip_bgp_dampening_cmd, |
| 15978 | "clear ip bgp dampening", |
| 15979 | CLEAR_STR |
| 15980 | IP_STR |
| 15981 | BGP_STR |
| 15982 | "Clear route flap dampening information\n") |
| 15983 | { |
| 15984 | bgp_damp_info_clean (); |
| 15985 | return CMD_SUCCESS; |
| 15986 | } |
| 15987 | |
| 15988 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 15989 | clear_ip_bgp_dampening_prefix_cmd, |
| 15990 | "clear ip bgp dampening A.B.C.D/M", |
| 15991 | CLEAR_STR |
| 15992 | IP_STR |
| 15993 | BGP_STR |
| 15994 | "Clear route flap dampening information\n" |
| 15995 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 15996 | { |
| 15997 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 15998 | SAFI_UNICAST, NULL, 1); |
| 15999 | } |
| 16000 | |
| 16001 | DEFUN (clear_ip_bgp_dampening_address, |
| 16002 | clear_ip_bgp_dampening_address_cmd, |
| 16003 | "clear ip bgp dampening A.B.C.D", |
| 16004 | CLEAR_STR |
| 16005 | IP_STR |
| 16006 | BGP_STR |
| 16007 | "Clear route flap dampening information\n" |
| 16008 | "Network to clear damping information\n") |
| 16009 | { |
| 16010 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 16011 | SAFI_UNICAST, NULL, 0); |
| 16012 | } |
| 16013 | |
| 16014 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 16015 | clear_ip_bgp_dampening_address_mask_cmd, |
| 16016 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 16017 | CLEAR_STR |
| 16018 | IP_STR |
| 16019 | BGP_STR |
| 16020 | "Clear route flap dampening information\n" |
| 16021 | "Network to clear damping information\n" |
| 16022 | "Network mask\n") |
| 16023 | { |
| 16024 | int ret; |
| 16025 | char prefix_str[BUFSIZ]; |
| 16026 | |
| 16027 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 16028 | if (! ret) |
| 16029 | { |
| 16030 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 16031 | return CMD_WARNING; |
| 16032 | } |
| 16033 | |
| 16034 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 16035 | SAFI_UNICAST, NULL, 0); |
| 16036 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 16037 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 16038 | /* also used for encap safi */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 16039 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16040 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 16041 | afi_t afi, safi_t safi, int *write) |
| 16042 | { |
| 16043 | struct bgp_node *prn; |
| 16044 | struct bgp_node *rn; |
| 16045 | struct bgp_table *table; |
| 16046 | struct prefix *p; |
| 16047 | struct prefix_rd *prd; |
| 16048 | struct bgp_static *bgp_static; |
| 16049 | u_int32_t label; |
| 16050 | char buf[SU_ADDRSTRLEN]; |
| 16051 | char rdbuf[RD_ADDRSTRLEN]; |
| 16052 | |
| 16053 | /* Network configuration. */ |
| 16054 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 16055 | if ((table = prn->info) != NULL) |
| 16056 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 16057 | if ((bgp_static = rn->info) != NULL) |
| 16058 | { |
| 16059 | p = &rn->p; |
| 16060 | prd = (struct prefix_rd *) &prn->p; |
| 16061 | |
| 16062 | /* "address-family" display. */ |
| 16063 | bgp_config_write_family_header (vty, afi, safi, write); |
| 16064 | |
| 16065 | /* "network" configuration display. */ |
| 16066 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 16067 | label = decode_label (bgp_static->tag); |
| 16068 | |
| 16069 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 16070 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16071 | p->prefixlen, |
| 16072 | rdbuf, label); |
| 16073 | vty_out (vty, "%s", VTY_NEWLINE); |
| 16074 | } |
| 16075 | return 0; |
| 16076 | } |
| 16077 | |
| 16078 | /* Configuration of static route announcement and aggregate |
| 16079 | information. */ |
| 16080 | int |
| 16081 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 16082 | afi_t afi, safi_t safi, int *write) |
| 16083 | { |
| 16084 | struct bgp_node *rn; |
| 16085 | struct prefix *p; |
| 16086 | struct bgp_static *bgp_static; |
| 16087 | struct bgp_aggregate *bgp_aggregate; |
| 16088 | char buf[SU_ADDRSTRLEN]; |
| 16089 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 16090 | if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16091 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 16092 | |
| 16093 | /* Network configuration. */ |
| 16094 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 16095 | if ((bgp_static = rn->info) != NULL) |
| 16096 | { |
| 16097 | p = &rn->p; |
| 16098 | |
| 16099 | /* "address-family" display. */ |
| 16100 | bgp_config_write_family_header (vty, afi, safi, write); |
| 16101 | |
| 16102 | /* "network" configuration display. */ |
| 16103 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 16104 | { |
| 16105 | u_int32_t destination; |
| 16106 | struct in_addr netmask; |
| 16107 | |
| 16108 | destination = ntohl (p->u.prefix4.s_addr); |
| 16109 | masklen2ip (p->prefixlen, &netmask); |
| 16110 | vty_out (vty, " network %s", |
| 16111 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 16112 | |
| 16113 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 16114 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 16115 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 16116 | || p->u.prefix4.s_addr == 0) |
| 16117 | { |
| 16118 | /* Natural mask is not display. */ |
| 16119 | } |
| 16120 | else |
| 16121 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 16122 | } |
| 16123 | else |
| 16124 | { |
| 16125 | vty_out (vty, " network %s/%d", |
| 16126 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16127 | p->prefixlen); |
| 16128 | } |
| 16129 | |
| 16130 | if (bgp_static->rmap.name) |
| 16131 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 16132 | else |
| 16133 | { |
| 16134 | if (bgp_static->backdoor) |
| 16135 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 16136 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16137 | |
| 16138 | vty_out (vty, "%s", VTY_NEWLINE); |
| 16139 | } |
| 16140 | |
| 16141 | /* Aggregate-address configuration. */ |
| 16142 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 16143 | if ((bgp_aggregate = rn->info) != NULL) |
| 16144 | { |
| 16145 | p = &rn->p; |
| 16146 | |
| 16147 | /* "address-family" display. */ |
| 16148 | bgp_config_write_family_header (vty, afi, safi, write); |
| 16149 | |
| 16150 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 16151 | { |
| 16152 | struct in_addr netmask; |
| 16153 | |
| 16154 | masklen2ip (p->prefixlen, &netmask); |
| 16155 | vty_out (vty, " aggregate-address %s %s", |
| 16156 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16157 | inet_ntoa (netmask)); |
| 16158 | } |
| 16159 | else |
| 16160 | { |
| 16161 | vty_out (vty, " aggregate-address %s/%d", |
| 16162 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16163 | p->prefixlen); |
| 16164 | } |
| 16165 | |
| 16166 | if (bgp_aggregate->as_set) |
| 16167 | vty_out (vty, " as-set"); |
| 16168 | |
| 16169 | if (bgp_aggregate->summary_only) |
| 16170 | vty_out (vty, " summary-only"); |
| 16171 | |
| 16172 | vty_out (vty, "%s", VTY_NEWLINE); |
| 16173 | } |
| 16174 | |
| 16175 | return 0; |
| 16176 | } |
| 16177 | |
| 16178 | int |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16179 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp, |
| 16180 | afi_t afi, safi_t safi, int *write) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16181 | { |
| 16182 | struct bgp_node *rn; |
| 16183 | struct bgp_distance *bdistance; |
| 16184 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16185 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 16186 | { |
| 16187 | /* Distance configuration. */ |
| 16188 | if (bgp->distance_ebgp |
| 16189 | && bgp->distance_ibgp |
| 16190 | && bgp->distance_local |
| 16191 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 16192 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 16193 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 16194 | vty_out (vty, " distance bgp %d %d %d%s", |
| 16195 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 16196 | VTY_NEWLINE); |
| 16197 | |
| 16198 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 16199 | if ((bdistance = rn->info) != NULL) |
| 16200 | { |
| 16201 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 16202 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 16203 | bdistance->access_list ? bdistance->access_list : "", |
| 16204 | VTY_NEWLINE); |
| 16205 | } |
| 16206 | } |
| 16207 | |
| 16208 | #ifdef HAVE_IPV6 |
| 16209 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
| 16210 | { |
| 16211 | bgp_config_write_family_header (vty, afi, safi, write); |
| 16212 | if (bgp->ipv6_distance_ebgp |
| 16213 | && bgp->ipv6_distance_ibgp |
| 16214 | && bgp->ipv6_distance_local |
| 16215 | && (bgp->ipv6_distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 16216 | || bgp->ipv6_distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 16217 | || bgp->ipv6_distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 16218 | vty_out (vty, " distance bgp %d %d %d%s", |
| 16219 | bgp->ipv6_distance_ebgp, bgp->ipv6_distance_ibgp, bgp->ipv6_distance_local, |
| 16220 | VTY_NEWLINE); |
| 16221 | |
| 16222 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 16223 | if ((bdistance = rn->info) != NULL) |
| 16224 | { |
| 16225 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 16226 | inet6_ntoa (rn->p.u.prefix6), rn->p.prefixlen, |
| 16227 | bdistance->access_list ? bdistance->access_list : "", |
| 16228 | VTY_NEWLINE); |
| 16229 | } |
| 16230 | } |
| 16231 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16232 | |
| 16233 | return 0; |
| 16234 | } |
| 16235 | |
| 16236 | /* Allocate routing table structure and install commands. */ |
| 16237 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 16238 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16239 | { |
| 16240 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 16241 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16242 | |
| 16243 | /* IPv4 BGP commands. */ |
| 16244 | install_element (BGP_NODE, &bgp_network_cmd); |
| 16245 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 16246 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 16247 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 16248 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 16249 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 16250 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 16251 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 16252 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 16253 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 16254 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 16255 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 16256 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 16257 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 16258 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 16259 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 16260 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 16261 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 16262 | |
| 16263 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 16264 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 16265 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 16266 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 16267 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 16268 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 16269 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 16270 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 16271 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 16272 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 16273 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 16274 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 16275 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 16276 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 16277 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 16278 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 16279 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 16280 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 16281 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 16282 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16283 | |
| 16284 | /* IPv4 unicast configuration. */ |
| 16285 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 16286 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 16287 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 16288 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 16289 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 16290 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16291 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16292 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 16293 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 16294 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 16295 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 16296 | 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] | 16297 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16298 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 16299 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 16300 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 16301 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 16302 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 16303 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 16304 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 16305 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 16306 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 16307 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 16308 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 16309 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 16310 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 16311 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 16312 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 16313 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 16314 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 16315 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 16316 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 16317 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16318 | |
| 16319 | /* IPv4 multicast configuration. */ |
| 16320 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 16321 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 16322 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 16323 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 16324 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 16325 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 16326 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 16327 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 16328 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 16329 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 16330 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 16331 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 16332 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 16333 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 16334 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 16335 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 16336 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 16337 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 16338 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 16339 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 16340 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 16341 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 16342 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 16343 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 16344 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 16345 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 16346 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 16347 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 16348 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 16349 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 16350 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 16351 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16352 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16353 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16354 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16355 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd); |
| 16356 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd); |
| 16357 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); |
| 16358 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); |
| 16359 | install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd); |
| 16360 | install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd); |
| 16361 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd); |
| 16362 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd); |
| 16363 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16364 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16365 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd); |
| 16366 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd); |
| 16367 | install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd); |
| 16368 | install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd); |
| 16369 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); |
| 16370 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); |
| 16371 | install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd); |
| 16372 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd); |
| 16373 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd); |
| 16374 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd); |
| 16375 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd); |
| 16376 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd); |
| 16377 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd); |
| 16378 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd); |
| 16379 | install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd); |
| 16380 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd); |
| 16381 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd); |
| 16382 | install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd); |
| 16383 | install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd); |
| 16384 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd); |
| 16385 | install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd); |
| 16386 | install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd); |
| 16387 | install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd); |
| 16388 | install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd); |
| 16389 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd); |
| 16390 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd); |
| 16391 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd); |
| 16392 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16393 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 16394 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 16395 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 16396 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 16397 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16398 | install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd); |
| 16399 | install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd); |
| 16400 | install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd); |
| 16401 | install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd); |
| 16402 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd); |
| 16403 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd); |
| 16404 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd); |
| 16405 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd); |
| 16406 | install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd); |
| 16407 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd); |
| 16408 | install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd); |
| 16409 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd); |
| 16410 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd); |
| 16411 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd); |
| 16412 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd); |
| 16413 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd); |
| 16414 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd); |
| 16415 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd); |
| 16416 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16417 | 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] | 16418 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd); |
| 16419 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd); |
| 16420 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd); |
| 16421 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd); |
| 16422 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd); |
| 16423 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd); |
| 16424 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd); |
| 16425 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd); |
| 16426 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd); |
| 16427 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd); |
| 16428 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd); |
| 16429 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd); |
| 16430 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd); |
| 16431 | install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd); |
| 16432 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd); |
| 16433 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd); |
| 16434 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd); |
| 16435 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd); |
| 16436 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd); |
| 16437 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd); |
| 16438 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd); |
| 16439 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd); |
| 16440 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd); |
| 16441 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd); |
| 16442 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd); |
| 16443 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd); |
| 16444 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd); |
| 16445 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd); |
| 16446 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd); |
| 16447 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd); |
| 16448 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd); |
| 16449 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd); |
| 16450 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd); |
| 16451 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd); |
| 16452 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd); |
| 16453 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd); |
| 16454 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd); |
| 16455 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd); |
| 16456 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd); |
| 16457 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd); |
| 16458 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd); |
| 16459 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd); |
| 16460 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd); |
| 16461 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd); |
| 16462 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16463 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16464 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16465 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16466 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16467 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16468 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16469 | |
| 16470 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16471 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16472 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); |
| 16473 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); |
| 16474 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd); |
| 16475 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd); |
| 16476 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16477 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16478 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd); |
| 16479 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd); |
| 16480 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd); |
| 16481 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd); |
| 16482 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); |
| 16483 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); |
| 16484 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd); |
| 16485 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd); |
| 16486 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd); |
| 16487 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd); |
| 16488 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd); |
| 16489 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd); |
| 16490 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd); |
| 16491 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd); |
| 16492 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd); |
| 16493 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16494 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 16495 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 16496 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 16497 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 16498 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16499 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd); |
| 16500 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd); |
| 16501 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd); |
| 16502 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd); |
| 16503 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd); |
| 16504 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd); |
| 16505 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd); |
| 16506 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16507 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16508 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16509 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16510 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16511 | |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16512 | /* BGP dampening clear commands */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16513 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 16514 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 16515 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 16516 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 16517 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16518 | /* New config IPv6 BGP commands. */ |
| 16519 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 16520 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 16521 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 16522 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 16523 | |
| 16524 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 16525 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 16526 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 16527 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 16528 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 16529 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 16530 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 16531 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16532 | /* Old config IPv6 BGP commands. */ |
| 16533 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 16534 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 16535 | |
| 16536 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 16537 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 16538 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 16539 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 16540 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16541 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16542 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16543 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16544 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16545 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16546 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16547 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16548 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16549 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16550 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd); |
| 16551 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd); |
| 16552 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd); |
| 16553 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd); |
| 16554 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd); |
| 16555 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd); |
| 16556 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd); |
| 16557 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16558 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16559 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16560 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16561 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16562 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16563 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16564 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16565 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16566 | install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd); |
| 16567 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16568 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16569 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16570 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16571 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16572 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16573 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16574 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16575 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16576 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16577 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16578 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16579 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16580 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16581 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16582 | install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd); |
| 16583 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16584 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16585 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16586 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16587 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16588 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16589 | |
| 16590 | /* Restricted: |
| 16591 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 16592 | */ |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16593 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16594 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16595 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16596 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16597 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd); |
| 16598 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd); |
| 16599 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd); |
| 16600 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd); |
| 16601 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd); |
| 16602 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd); |
| 16603 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd); |
| 16604 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd); |
| 16605 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16606 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16607 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16608 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16609 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16610 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16611 | 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] | 16612 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16613 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16614 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16615 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16616 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 16617 | /* Statistics */ |
| 16618 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16619 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16620 | |
| 16621 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 16622 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 16623 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 16624 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 16625 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 16626 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 16627 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16628 | #ifdef HAVE_IPV6 |
| 16629 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_cmd); |
| 16630 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_cmd); |
| 16631 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance2_cmd); |
| 16632 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_cmd); |
| 16633 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_cmd); |
| 16634 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_access_list_cmd); |
| 16635 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_access_list_cmd); |
| 16636 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16637 | |
| 16638 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 16639 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 16640 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 16641 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 16642 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 16643 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 16644 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 16645 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 16646 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 16647 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Balaji | 9145f0e | 2016-01-20 22:59:27 +0530 | [diff] [blame] | 16648 | |
| 16649 | /* IPv4 Multicast Mode */ |
| 16650 | install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd); |
| 16651 | install_element (BGP_IPV4M_NODE, &bgp_damp_set2_cmd); |
| 16652 | install_element (BGP_IPV4M_NODE, &bgp_damp_set3_cmd); |
| 16653 | install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd); |
| 16654 | install_element (BGP_IPV4M_NODE, &bgp_damp_unset2_cmd); |
| 16655 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16656 | |
| 16657 | /* Deprecated AS-Pathlimit commands */ |
| 16658 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 16659 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 16660 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16661 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16662 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16663 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16664 | |
| 16665 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 16666 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16667 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16668 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16669 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16670 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16671 | |
| 16672 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 16673 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 16674 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16675 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16676 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16677 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16678 | |
| 16679 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 16680 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16681 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16682 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16683 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16684 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16685 | |
| 16686 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 16687 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 16688 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16689 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16690 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16691 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16692 | |
| 16693 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 16694 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16695 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16696 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16697 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16698 | 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] | 16699 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16700 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 16701 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16702 | |
| 16703 | /* old style commands */ |
| 16704 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 16705 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 16706 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16707 | install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd); |
| 16708 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16709 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 16710 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 16711 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 16712 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 16713 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16714 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
| 16715 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); |
| 16716 | install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16717 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 16718 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 16719 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 16720 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 16721 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 16722 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 16723 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 16724 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 16725 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 16726 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 16727 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 16728 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 16729 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 16730 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 16731 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 16732 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 16733 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 16734 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 16735 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 16736 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 16737 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 16738 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 16739 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 16740 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 16741 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 16742 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 16743 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 16744 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 16745 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 16746 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 16747 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 16748 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 16749 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 16750 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 16751 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 16752 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 16753 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 16754 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 16755 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 16756 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 16757 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 16758 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 16759 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 16760 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 16761 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 16762 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 16763 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 16764 | install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 16765 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16766 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 16767 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd); |
| 16768 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16769 | install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
| 16770 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 16771 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
| 16772 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 16773 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd); |
| 16774 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 16775 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 16776 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
| 16777 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 16778 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 16779 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
| 16780 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 16781 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
| 16782 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 16783 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
| 16784 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 16785 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
| 16786 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 16787 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
| 16788 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
| 16789 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 16790 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 16791 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 16792 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
| 16793 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 16794 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 16795 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16796 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16797 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16798 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd); |
| 16799 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16800 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 16801 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 16802 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 16803 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16804 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
| 16805 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); |
| 16806 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16807 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 16808 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 16809 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 16810 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 16811 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 16812 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 16813 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 16814 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 16815 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 16816 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 16817 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 16818 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 16819 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 16820 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 16821 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 16822 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 16823 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 16824 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 16825 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 16826 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 16827 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 16828 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 16829 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 16830 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16831 | |
| 16832 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 16833 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 16834 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16835 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16836 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 16837 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 16838 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 16839 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16840 | install_element (VIEW_NODE, &show_bgp_route_pathtype_cmd); |
| 16841 | install_element (VIEW_NODE, &show_bgp_ipv6_route_pathtype_cmd); |
| 16842 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); |
| 16843 | install_element (VIEW_NODE, &show_bgp_prefix_pathtype_cmd); |
| 16844 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); |
| 16845 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16846 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 16847 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 16848 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 16849 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 16850 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 16851 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 16852 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 16853 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 16854 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 16855 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 16856 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 16857 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 16858 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 16859 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 16860 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd); |
| 16861 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 16862 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd); |
| 16863 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 16864 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 16865 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 16866 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 16867 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 16868 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 16869 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 16870 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
| 16871 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 16872 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 16873 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 16874 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 16875 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 16876 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 16877 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 16878 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 16879 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 16880 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16881 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16882 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 16883 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16884 | install_element (RESTRICTED_NODE, &show_bgp_route_pathtype_cmd); |
| 16885 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_pathtype_cmd); |
| 16886 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); |
| 16887 | install_element (RESTRICTED_NODE, &show_bgp_prefix_pathtype_cmd); |
| 16888 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); |
| 16889 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16890 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 16891 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 16892 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 16893 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 16894 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 16895 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 16896 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 16897 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 16898 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 16899 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 16900 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16901 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16902 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 16903 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16904 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16905 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 16906 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 16907 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 16908 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 16909 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 16910 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 16911 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 16912 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 16913 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 16914 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 16915 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 16916 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 16917 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 16918 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 16919 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 16920 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 16921 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 16922 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 16923 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 16924 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 16925 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 16926 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 16927 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 16928 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 16929 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 16930 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 16931 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 16932 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 16933 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 16934 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 16935 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 16936 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 16937 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 16938 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 16939 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 16940 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16941 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16942 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16943 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16944 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16945 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16946 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16947 | /* old with name safi collision */ |
| 16948 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 16949 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 16950 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 16951 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 16952 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 16953 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 16954 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 16955 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 16956 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 16957 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 16958 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 16959 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 16960 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 16961 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 16962 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 16963 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16964 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16965 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 16966 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16967 | |
| 16968 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
| 16969 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
| 16970 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
| 16971 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16972 | |
| 16973 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
| 16974 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
| 16975 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
| 16976 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16977 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 16978 | |
| 16979 | void |
| 16980 | bgp_route_finish (void) |
| 16981 | { |
| 16982 | bgp_table_unlock (bgp_distance_table); |
| 16983 | bgp_distance_table = NULL; |
| 16984 | } |