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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 899 | |
| 900 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 901 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 902 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 903 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 904 | { |
| 905 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 906 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 907 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 908 | peer->host, |
| 909 | bgp->confed_id); |
| 910 | return 0; |
| 911 | } |
| 912 | } |
Thorvald Natvig | 95509a6 | 2016-09-29 10:25:35 -0700 | [diff] [blame] | 913 | #endif /* BGP_SEND_ASPATH_CHECK */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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)) |
Daniel Walton | 4d48bb3 | 2016-11-29 12:47:12 -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)) |
Daniel Walton | 4d48bb3 | 2016-11-29 12:47:12 -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; |
Christian Franke | c8e8097 | 2016-06-14 20:07:01 +0200 | [diff] [blame] | 9431 | int i, rv; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | |
Christian Franke | c8e8097 | 2016-06-14 20:07:01 +0200 | [diff] [blame] | 9482 | rv = bgp_show (vty, bgp, afi, safi, |
| 9483 | (exact ? bgp_show_type_community_exact : |
| 9484 | bgp_show_type_community), com); |
| 9485 | community_free(com); |
| 9486 | return rv; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9487 | } |
| 9488 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9489 | DEFUN (show_ip_bgp_community, |
| 9490 | show_ip_bgp_community_cmd, |
| 9491 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9492 | SHOW_STR |
| 9493 | IP_STR |
| 9494 | BGP_STR |
| 9495 | "Display routes matching the communities\n" |
| 9496 | "community number\n" |
| 9497 | "Do not send outside local AS (well-known community)\n" |
| 9498 | "Do not advertise to any peer (well-known community)\n" |
| 9499 | "Do not export to next AS (well-known community)\n") |
| 9500 | { |
| 9501 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 9502 | } |
| 9503 | |
| 9504 | ALIAS (show_ip_bgp_community, |
| 9505 | show_ip_bgp_community2_cmd, |
| 9506 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9507 | SHOW_STR |
| 9508 | IP_STR |
| 9509 | BGP_STR |
| 9510 | "Display routes matching the communities\n" |
| 9511 | "community number\n" |
| 9512 | "Do not send outside local AS (well-known community)\n" |
| 9513 | "Do not advertise to any peer (well-known community)\n" |
| 9514 | "Do not export to next AS (well-known community)\n" |
| 9515 | "community number\n" |
| 9516 | "Do not send outside local AS (well-known community)\n" |
| 9517 | "Do not advertise to any peer (well-known community)\n" |
| 9518 | "Do not export to next AS (well-known community)\n") |
| 9519 | |
| 9520 | ALIAS (show_ip_bgp_community, |
| 9521 | show_ip_bgp_community3_cmd, |
| 9522 | "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)", |
| 9523 | SHOW_STR |
| 9524 | IP_STR |
| 9525 | BGP_STR |
| 9526 | "Display routes matching the communities\n" |
| 9527 | "community number\n" |
| 9528 | "Do not send outside local AS (well-known community)\n" |
| 9529 | "Do not advertise to any peer (well-known community)\n" |
| 9530 | "Do not export to next AS (well-known community)\n" |
| 9531 | "community number\n" |
| 9532 | "Do not send outside local AS (well-known community)\n" |
| 9533 | "Do not advertise to any peer (well-known community)\n" |
| 9534 | "Do not export to next AS (well-known community)\n" |
| 9535 | "community number\n" |
| 9536 | "Do not send outside local AS (well-known community)\n" |
| 9537 | "Do not advertise to any peer (well-known community)\n" |
| 9538 | "Do not export to next AS (well-known community)\n") |
| 9539 | |
| 9540 | ALIAS (show_ip_bgp_community, |
| 9541 | show_ip_bgp_community4_cmd, |
| 9542 | "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)", |
| 9543 | SHOW_STR |
| 9544 | IP_STR |
| 9545 | BGP_STR |
| 9546 | "Display routes matching the communities\n" |
| 9547 | "community number\n" |
| 9548 | "Do not send outside local AS (well-known community)\n" |
| 9549 | "Do not advertise to any peer (well-known community)\n" |
| 9550 | "Do not export to next AS (well-known community)\n" |
| 9551 | "community number\n" |
| 9552 | "Do not send outside local AS (well-known community)\n" |
| 9553 | "Do not advertise to any peer (well-known community)\n" |
| 9554 | "Do not export to next AS (well-known community)\n" |
| 9555 | "community number\n" |
| 9556 | "Do not send outside local AS (well-known community)\n" |
| 9557 | "Do not advertise to any peer (well-known community)\n" |
| 9558 | "Do not export to next AS (well-known community)\n" |
| 9559 | "community number\n" |
| 9560 | "Do not send outside local AS (well-known community)\n" |
| 9561 | "Do not advertise to any peer (well-known community)\n" |
| 9562 | "Do not export to next AS (well-known community)\n") |
| 9563 | |
| 9564 | DEFUN (show_ip_bgp_ipv4_community, |
| 9565 | show_ip_bgp_ipv4_community_cmd, |
| 9566 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 9567 | SHOW_STR |
| 9568 | IP_STR |
| 9569 | BGP_STR |
| 9570 | "Address family\n" |
| 9571 | "Address Family modifier\n" |
| 9572 | "Address Family modifier\n" |
| 9573 | "Display routes matching the communities\n" |
| 9574 | "community number\n" |
| 9575 | "Do not send outside local AS (well-known community)\n" |
| 9576 | "Do not advertise to any peer (well-known community)\n" |
| 9577 | "Do not export to next AS (well-known community)\n") |
| 9578 | { |
| 9579 | if (strncmp (argv[0], "m", 1) == 0) |
| 9580 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 9581 | |
| 9582 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 9583 | } |
| 9584 | |
| 9585 | ALIAS (show_ip_bgp_ipv4_community, |
| 9586 | show_ip_bgp_ipv4_community2_cmd, |
| 9587 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9588 | SHOW_STR |
| 9589 | IP_STR |
| 9590 | BGP_STR |
| 9591 | "Address family\n" |
| 9592 | "Address Family modifier\n" |
| 9593 | "Address Family modifier\n" |
| 9594 | "Display routes matching the communities\n" |
| 9595 | "community number\n" |
| 9596 | "Do not send outside local AS (well-known community)\n" |
| 9597 | "Do not advertise to any peer (well-known community)\n" |
| 9598 | "Do not export to next AS (well-known community)\n" |
| 9599 | "community number\n" |
| 9600 | "Do not send outside local AS (well-known community)\n" |
| 9601 | "Do not advertise to any peer (well-known community)\n" |
| 9602 | "Do not export to next AS (well-known community)\n") |
| 9603 | |
| 9604 | ALIAS (show_ip_bgp_ipv4_community, |
| 9605 | show_ip_bgp_ipv4_community3_cmd, |
| 9606 | "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)", |
| 9607 | SHOW_STR |
| 9608 | IP_STR |
| 9609 | BGP_STR |
| 9610 | "Address family\n" |
| 9611 | "Address Family modifier\n" |
| 9612 | "Address Family modifier\n" |
| 9613 | "Display routes matching the communities\n" |
| 9614 | "community number\n" |
| 9615 | "Do not send outside local AS (well-known community)\n" |
| 9616 | "Do not advertise to any peer (well-known community)\n" |
| 9617 | "Do not export to next AS (well-known community)\n" |
| 9618 | "community number\n" |
| 9619 | "Do not send outside local AS (well-known community)\n" |
| 9620 | "Do not advertise to any peer (well-known community)\n" |
| 9621 | "Do not export to next AS (well-known community)\n" |
| 9622 | "community number\n" |
| 9623 | "Do not send outside local AS (well-known community)\n" |
| 9624 | "Do not advertise to any peer (well-known community)\n" |
| 9625 | "Do not export to next AS (well-known community)\n") |
| 9626 | |
| 9627 | ALIAS (show_ip_bgp_ipv4_community, |
| 9628 | show_ip_bgp_ipv4_community4_cmd, |
| 9629 | "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)", |
| 9630 | SHOW_STR |
| 9631 | IP_STR |
| 9632 | BGP_STR |
| 9633 | "Address family\n" |
| 9634 | "Address Family modifier\n" |
| 9635 | "Address Family modifier\n" |
| 9636 | "Display routes matching the communities\n" |
| 9637 | "community number\n" |
| 9638 | "Do not send outside local AS (well-known community)\n" |
| 9639 | "Do not advertise to any peer (well-known community)\n" |
| 9640 | "Do not export to next AS (well-known community)\n" |
| 9641 | "community number\n" |
| 9642 | "Do not send outside local AS (well-known community)\n" |
| 9643 | "Do not advertise to any peer (well-known community)\n" |
| 9644 | "Do not export to next AS (well-known community)\n" |
| 9645 | "community number\n" |
| 9646 | "Do not send outside local AS (well-known community)\n" |
| 9647 | "Do not advertise to any peer (well-known community)\n" |
| 9648 | "Do not export to next AS (well-known community)\n" |
| 9649 | "community number\n" |
| 9650 | "Do not send outside local AS (well-known community)\n" |
| 9651 | "Do not advertise to any peer (well-known community)\n" |
| 9652 | "Do not export to next AS (well-known community)\n") |
| 9653 | |
| 9654 | DEFUN (show_ip_bgp_community_exact, |
| 9655 | show_ip_bgp_community_exact_cmd, |
| 9656 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9657 | SHOW_STR |
| 9658 | IP_STR |
| 9659 | BGP_STR |
| 9660 | "Display routes matching the communities\n" |
| 9661 | "community number\n" |
| 9662 | "Do not send outside local AS (well-known community)\n" |
| 9663 | "Do not advertise to any peer (well-known community)\n" |
| 9664 | "Do not export to next AS (well-known community)\n" |
| 9665 | "Exact match of the communities") |
| 9666 | { |
| 9667 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 9668 | } |
| 9669 | |
| 9670 | ALIAS (show_ip_bgp_community_exact, |
| 9671 | show_ip_bgp_community2_exact_cmd, |
| 9672 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9673 | SHOW_STR |
| 9674 | IP_STR |
| 9675 | BGP_STR |
| 9676 | "Display routes matching the communities\n" |
| 9677 | "community number\n" |
| 9678 | "Do not send outside local AS (well-known community)\n" |
| 9679 | "Do not advertise to any peer (well-known community)\n" |
| 9680 | "Do not export to next AS (well-known community)\n" |
| 9681 | "community number\n" |
| 9682 | "Do not send outside local AS (well-known community)\n" |
| 9683 | "Do not advertise to any peer (well-known community)\n" |
| 9684 | "Do not export to next AS (well-known community)\n" |
| 9685 | "Exact match of the communities") |
| 9686 | |
| 9687 | ALIAS (show_ip_bgp_community_exact, |
| 9688 | show_ip_bgp_community3_exact_cmd, |
| 9689 | "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", |
| 9690 | SHOW_STR |
| 9691 | IP_STR |
| 9692 | BGP_STR |
| 9693 | "Display routes matching the communities\n" |
| 9694 | "community number\n" |
| 9695 | "Do not send outside local AS (well-known community)\n" |
| 9696 | "Do not advertise to any peer (well-known community)\n" |
| 9697 | "Do not export to next AS (well-known community)\n" |
| 9698 | "community number\n" |
| 9699 | "Do not send outside local AS (well-known community)\n" |
| 9700 | "Do not advertise to any peer (well-known community)\n" |
| 9701 | "Do not export to next AS (well-known community)\n" |
| 9702 | "community number\n" |
| 9703 | "Do not send outside local AS (well-known community)\n" |
| 9704 | "Do not advertise to any peer (well-known community)\n" |
| 9705 | "Do not export to next AS (well-known community)\n" |
| 9706 | "Exact match of the communities") |
| 9707 | |
| 9708 | ALIAS (show_ip_bgp_community_exact, |
| 9709 | show_ip_bgp_community4_exact_cmd, |
| 9710 | "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", |
| 9711 | SHOW_STR |
| 9712 | IP_STR |
| 9713 | BGP_STR |
| 9714 | "Display routes matching the communities\n" |
| 9715 | "community number\n" |
| 9716 | "Do not send outside local AS (well-known community)\n" |
| 9717 | "Do not advertise to any peer (well-known community)\n" |
| 9718 | "Do not export to next AS (well-known community)\n" |
| 9719 | "community number\n" |
| 9720 | "Do not send outside local AS (well-known community)\n" |
| 9721 | "Do not advertise to any peer (well-known community)\n" |
| 9722 | "Do not export to next AS (well-known community)\n" |
| 9723 | "community number\n" |
| 9724 | "Do not send outside local AS (well-known community)\n" |
| 9725 | "Do not advertise to any peer (well-known community)\n" |
| 9726 | "Do not export to next AS (well-known community)\n" |
| 9727 | "community number\n" |
| 9728 | "Do not send outside local AS (well-known community)\n" |
| 9729 | "Do not advertise to any peer (well-known community)\n" |
| 9730 | "Do not export to next AS (well-known community)\n" |
| 9731 | "Exact match of the communities") |
| 9732 | |
| 9733 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 9734 | show_ip_bgp_ipv4_community_exact_cmd, |
| 9735 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9736 | SHOW_STR |
| 9737 | IP_STR |
| 9738 | BGP_STR |
| 9739 | "Address family\n" |
| 9740 | "Address Family modifier\n" |
| 9741 | "Address Family modifier\n" |
| 9742 | "Display routes matching the communities\n" |
| 9743 | "community number\n" |
| 9744 | "Do not send outside local AS (well-known community)\n" |
| 9745 | "Do not advertise to any peer (well-known community)\n" |
| 9746 | "Do not export to next AS (well-known community)\n" |
| 9747 | "Exact match of the communities") |
| 9748 | { |
| 9749 | if (strncmp (argv[0], "m", 1) == 0) |
| 9750 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 9751 | |
| 9752 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 9753 | } |
| 9754 | |
| 9755 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9756 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 9757 | "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", |
| 9758 | SHOW_STR |
| 9759 | IP_STR |
| 9760 | BGP_STR |
| 9761 | "Address family\n" |
| 9762 | "Address Family modifier\n" |
| 9763 | "Address Family modifier\n" |
| 9764 | "Display routes matching the communities\n" |
| 9765 | "community number\n" |
| 9766 | "Do not send outside local AS (well-known community)\n" |
| 9767 | "Do not advertise to any peer (well-known community)\n" |
| 9768 | "Do not export to next AS (well-known community)\n" |
| 9769 | "community number\n" |
| 9770 | "Do not send outside local AS (well-known community)\n" |
| 9771 | "Do not advertise to any peer (well-known community)\n" |
| 9772 | "Do not export to next AS (well-known community)\n" |
| 9773 | "Exact match of the communities") |
| 9774 | |
| 9775 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9776 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 9777 | "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", |
| 9778 | SHOW_STR |
| 9779 | IP_STR |
| 9780 | BGP_STR |
| 9781 | "Address family\n" |
| 9782 | "Address Family modifier\n" |
| 9783 | "Address Family modifier\n" |
| 9784 | "Display routes matching the communities\n" |
| 9785 | "community number\n" |
| 9786 | "Do not send outside local AS (well-known community)\n" |
| 9787 | "Do not advertise to any peer (well-known community)\n" |
| 9788 | "Do not export to next AS (well-known community)\n" |
| 9789 | "community number\n" |
| 9790 | "Do not send outside local AS (well-known community)\n" |
| 9791 | "Do not advertise to any peer (well-known community)\n" |
| 9792 | "Do not export to next AS (well-known community)\n" |
| 9793 | "community number\n" |
| 9794 | "Do not send outside local AS (well-known community)\n" |
| 9795 | "Do not advertise to any peer (well-known community)\n" |
| 9796 | "Do not export to next AS (well-known community)\n" |
| 9797 | "Exact match of the communities") |
| 9798 | |
| 9799 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9800 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 9801 | "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", |
| 9802 | SHOW_STR |
| 9803 | IP_STR |
| 9804 | BGP_STR |
| 9805 | "Address family\n" |
| 9806 | "Address Family modifier\n" |
| 9807 | "Address Family modifier\n" |
| 9808 | "Display routes matching the communities\n" |
| 9809 | "community number\n" |
| 9810 | "Do not send outside local AS (well-known community)\n" |
| 9811 | "Do not advertise to any peer (well-known community)\n" |
| 9812 | "Do not export to next AS (well-known community)\n" |
| 9813 | "community number\n" |
| 9814 | "Do not send outside local AS (well-known community)\n" |
| 9815 | "Do not advertise to any peer (well-known community)\n" |
| 9816 | "Do not export to next AS (well-known community)\n" |
| 9817 | "community number\n" |
| 9818 | "Do not send outside local AS (well-known community)\n" |
| 9819 | "Do not advertise to any peer (well-known community)\n" |
| 9820 | "Do not export to next AS (well-known community)\n" |
| 9821 | "community number\n" |
| 9822 | "Do not send outside local AS (well-known community)\n" |
| 9823 | "Do not advertise to any peer (well-known community)\n" |
| 9824 | "Do not export to next AS (well-known community)\n" |
| 9825 | "Exact match of the communities") |
| 9826 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9827 | DEFUN (show_bgp_community, |
| 9828 | show_bgp_community_cmd, |
| 9829 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9830 | SHOW_STR |
| 9831 | BGP_STR |
| 9832 | "Display routes matching the communities\n" |
| 9833 | "community number\n" |
| 9834 | "Do not send outside local AS (well-known community)\n" |
| 9835 | "Do not advertise to any peer (well-known community)\n" |
| 9836 | "Do not export to next AS (well-known community)\n") |
| 9837 | { |
| 9838 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 9839 | } |
| 9840 | |
| 9841 | ALIAS (show_bgp_community, |
| 9842 | show_bgp_ipv6_community_cmd, |
| 9843 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 9844 | SHOW_STR |
| 9845 | BGP_STR |
| 9846 | "Address family\n" |
| 9847 | "Display routes matching the communities\n" |
| 9848 | "community number\n" |
| 9849 | "Do not send outside local AS (well-known community)\n" |
| 9850 | "Do not advertise to any peer (well-known community)\n" |
| 9851 | "Do not export to next AS (well-known community)\n") |
| 9852 | |
| 9853 | ALIAS (show_bgp_community, |
| 9854 | show_bgp_community2_cmd, |
| 9855 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9856 | SHOW_STR |
| 9857 | BGP_STR |
| 9858 | "Display routes matching the communities\n" |
| 9859 | "community number\n" |
| 9860 | "Do not send outside local AS (well-known community)\n" |
| 9861 | "Do not advertise to any peer (well-known community)\n" |
| 9862 | "Do not export to next AS (well-known community)\n" |
| 9863 | "community number\n" |
| 9864 | "Do not send outside local AS (well-known community)\n" |
| 9865 | "Do not advertise to any peer (well-known community)\n" |
| 9866 | "Do not export to next AS (well-known community)\n") |
| 9867 | |
| 9868 | ALIAS (show_bgp_community, |
| 9869 | show_bgp_ipv6_community2_cmd, |
| 9870 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9871 | SHOW_STR |
| 9872 | BGP_STR |
| 9873 | "Address family\n" |
| 9874 | "Display routes matching the communities\n" |
| 9875 | "community number\n" |
| 9876 | "Do not send outside local AS (well-known community)\n" |
| 9877 | "Do not advertise to any peer (well-known community)\n" |
| 9878 | "Do not export to next AS (well-known community)\n" |
| 9879 | "community number\n" |
| 9880 | "Do not send outside local AS (well-known community)\n" |
| 9881 | "Do not advertise to any peer (well-known community)\n" |
| 9882 | "Do not export to next AS (well-known community)\n") |
| 9883 | |
| 9884 | ALIAS (show_bgp_community, |
| 9885 | show_bgp_community3_cmd, |
| 9886 | "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)", |
| 9887 | SHOW_STR |
| 9888 | BGP_STR |
| 9889 | "Display routes matching the communities\n" |
| 9890 | "community number\n" |
| 9891 | "Do not send outside local AS (well-known community)\n" |
| 9892 | "Do not advertise to any peer (well-known community)\n" |
| 9893 | "Do not export to next AS (well-known community)\n" |
| 9894 | "community number\n" |
| 9895 | "Do not send outside local AS (well-known community)\n" |
| 9896 | "Do not advertise to any peer (well-known community)\n" |
| 9897 | "Do not export to next AS (well-known community)\n" |
| 9898 | "community number\n" |
| 9899 | "Do not send outside local AS (well-known community)\n" |
| 9900 | "Do not advertise to any peer (well-known community)\n" |
| 9901 | "Do not export to next AS (well-known community)\n") |
| 9902 | |
| 9903 | ALIAS (show_bgp_community, |
| 9904 | show_bgp_ipv6_community3_cmd, |
| 9905 | "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)", |
| 9906 | SHOW_STR |
| 9907 | BGP_STR |
| 9908 | "Address family\n" |
| 9909 | "Display routes matching the communities\n" |
| 9910 | "community number\n" |
| 9911 | "Do not send outside local AS (well-known community)\n" |
| 9912 | "Do not advertise to any peer (well-known community)\n" |
| 9913 | "Do not export to next AS (well-known community)\n" |
| 9914 | "community number\n" |
| 9915 | "Do not send outside local AS (well-known community)\n" |
| 9916 | "Do not advertise to any peer (well-known community)\n" |
| 9917 | "Do not export to next AS (well-known community)\n" |
| 9918 | "community number\n" |
| 9919 | "Do not send outside local AS (well-known community)\n" |
| 9920 | "Do not advertise to any peer (well-known community)\n" |
| 9921 | "Do not export to next AS (well-known community)\n") |
| 9922 | |
| 9923 | ALIAS (show_bgp_community, |
| 9924 | show_bgp_community4_cmd, |
| 9925 | "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)", |
| 9926 | SHOW_STR |
| 9927 | BGP_STR |
| 9928 | "Display routes matching the communities\n" |
| 9929 | "community number\n" |
| 9930 | "Do not send outside local AS (well-known community)\n" |
| 9931 | "Do not advertise to any peer (well-known community)\n" |
| 9932 | "Do not export to next AS (well-known community)\n" |
| 9933 | "community number\n" |
| 9934 | "Do not send outside local AS (well-known community)\n" |
| 9935 | "Do not advertise to any peer (well-known community)\n" |
| 9936 | "Do not export to next AS (well-known community)\n" |
| 9937 | "community number\n" |
| 9938 | "Do not send outside local AS (well-known community)\n" |
| 9939 | "Do not advertise to any peer (well-known community)\n" |
| 9940 | "Do not export to next AS (well-known community)\n" |
| 9941 | "community number\n" |
| 9942 | "Do not send outside local AS (well-known community)\n" |
| 9943 | "Do not advertise to any peer (well-known community)\n" |
| 9944 | "Do not export to next AS (well-known community)\n") |
| 9945 | |
| 9946 | ALIAS (show_bgp_community, |
| 9947 | show_bgp_ipv6_community4_cmd, |
| 9948 | "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)", |
| 9949 | SHOW_STR |
| 9950 | BGP_STR |
| 9951 | "Address family\n" |
| 9952 | "Display routes matching the communities\n" |
| 9953 | "community number\n" |
| 9954 | "Do not send outside local AS (well-known community)\n" |
| 9955 | "Do not advertise to any peer (well-known community)\n" |
| 9956 | "Do not export to next AS (well-known community)\n" |
| 9957 | "community number\n" |
| 9958 | "Do not send outside local AS (well-known community)\n" |
| 9959 | "Do not advertise to any peer (well-known community)\n" |
| 9960 | "Do not export to next AS (well-known community)\n" |
| 9961 | "community number\n" |
| 9962 | "Do not send outside local AS (well-known community)\n" |
| 9963 | "Do not advertise to any peer (well-known community)\n" |
| 9964 | "Do not export to next AS (well-known community)\n" |
| 9965 | "community number\n" |
| 9966 | "Do not send outside local AS (well-known community)\n" |
| 9967 | "Do not advertise to any peer (well-known community)\n" |
| 9968 | "Do not export to next AS (well-known community)\n") |
| 9969 | |
| 9970 | /* old command */ |
| 9971 | DEFUN (show_ipv6_bgp_community, |
| 9972 | show_ipv6_bgp_community_cmd, |
| 9973 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9974 | SHOW_STR |
| 9975 | IPV6_STR |
| 9976 | BGP_STR |
| 9977 | "Display routes matching the communities\n" |
| 9978 | "community number\n" |
| 9979 | "Do not send outside local AS (well-known community)\n" |
| 9980 | "Do not advertise to any peer (well-known community)\n" |
| 9981 | "Do not export to next AS (well-known community)\n") |
| 9982 | { |
| 9983 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 9984 | } |
| 9985 | |
| 9986 | /* old command */ |
| 9987 | ALIAS (show_ipv6_bgp_community, |
| 9988 | show_ipv6_bgp_community2_cmd, |
| 9989 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9990 | SHOW_STR |
| 9991 | IPV6_STR |
| 9992 | BGP_STR |
| 9993 | "Display routes matching the communities\n" |
| 9994 | "community number\n" |
| 9995 | "Do not send outside local AS (well-known community)\n" |
| 9996 | "Do not advertise to any peer (well-known community)\n" |
| 9997 | "Do not export to next AS (well-known community)\n" |
| 9998 | "community number\n" |
| 9999 | "Do not send outside local AS (well-known community)\n" |
| 10000 | "Do not advertise to any peer (well-known community)\n" |
| 10001 | "Do not export to next AS (well-known community)\n") |
| 10002 | |
| 10003 | /* old command */ |
| 10004 | ALIAS (show_ipv6_bgp_community, |
| 10005 | show_ipv6_bgp_community3_cmd, |
| 10006 | "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)", |
| 10007 | SHOW_STR |
| 10008 | IPV6_STR |
| 10009 | BGP_STR |
| 10010 | "Display routes matching the communities\n" |
| 10011 | "community number\n" |
| 10012 | "Do not send outside local AS (well-known community)\n" |
| 10013 | "Do not advertise to any peer (well-known community)\n" |
| 10014 | "Do not export to next AS (well-known community)\n" |
| 10015 | "community number\n" |
| 10016 | "Do not send outside local AS (well-known community)\n" |
| 10017 | "Do not advertise to any peer (well-known community)\n" |
| 10018 | "Do not export to next AS (well-known community)\n" |
| 10019 | "community number\n" |
| 10020 | "Do not send outside local AS (well-known community)\n" |
| 10021 | "Do not advertise to any peer (well-known community)\n" |
| 10022 | "Do not export to next AS (well-known community)\n") |
| 10023 | |
| 10024 | /* old command */ |
| 10025 | ALIAS (show_ipv6_bgp_community, |
| 10026 | show_ipv6_bgp_community4_cmd, |
| 10027 | "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)", |
| 10028 | SHOW_STR |
| 10029 | IPV6_STR |
| 10030 | BGP_STR |
| 10031 | "Display routes matching the communities\n" |
| 10032 | "community number\n" |
| 10033 | "Do not send outside local AS (well-known community)\n" |
| 10034 | "Do not advertise to any peer (well-known community)\n" |
| 10035 | "Do not export to next AS (well-known community)\n" |
| 10036 | "community number\n" |
| 10037 | "Do not send outside local AS (well-known community)\n" |
| 10038 | "Do not advertise to any peer (well-known community)\n" |
| 10039 | "Do not export to next AS (well-known community)\n" |
| 10040 | "community number\n" |
| 10041 | "Do not send outside local AS (well-known community)\n" |
| 10042 | "Do not advertise to any peer (well-known community)\n" |
| 10043 | "Do not export to next AS (well-known community)\n" |
| 10044 | "community number\n" |
| 10045 | "Do not send outside local AS (well-known community)\n" |
| 10046 | "Do not advertise to any peer (well-known community)\n" |
| 10047 | "Do not export to next AS (well-known community)\n") |
| 10048 | |
| 10049 | DEFUN (show_bgp_community_exact, |
| 10050 | show_bgp_community_exact_cmd, |
| 10051 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10052 | SHOW_STR |
| 10053 | BGP_STR |
| 10054 | "Display routes matching the communities\n" |
| 10055 | "community number\n" |
| 10056 | "Do not send outside local AS (well-known community)\n" |
| 10057 | "Do not advertise to any peer (well-known community)\n" |
| 10058 | "Do not export to next AS (well-known community)\n" |
| 10059 | "Exact match of the communities") |
| 10060 | { |
| 10061 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 10062 | } |
| 10063 | |
| 10064 | ALIAS (show_bgp_community_exact, |
| 10065 | show_bgp_ipv6_community_exact_cmd, |
| 10066 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10067 | SHOW_STR |
| 10068 | BGP_STR |
| 10069 | "Address family\n" |
| 10070 | "Display routes matching the communities\n" |
| 10071 | "community number\n" |
| 10072 | "Do not send outside local AS (well-known community)\n" |
| 10073 | "Do not advertise to any peer (well-known community)\n" |
| 10074 | "Do not export to next AS (well-known community)\n" |
| 10075 | "Exact match of the communities") |
| 10076 | |
| 10077 | ALIAS (show_bgp_community_exact, |
| 10078 | show_bgp_community2_exact_cmd, |
| 10079 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10080 | SHOW_STR |
| 10081 | BGP_STR |
| 10082 | "Display routes matching the communities\n" |
| 10083 | "community number\n" |
| 10084 | "Do not send outside local AS (well-known community)\n" |
| 10085 | "Do not advertise to any peer (well-known community)\n" |
| 10086 | "Do not export to next AS (well-known community)\n" |
| 10087 | "community number\n" |
| 10088 | "Do not send outside local AS (well-known community)\n" |
| 10089 | "Do not advertise to any peer (well-known community)\n" |
| 10090 | "Do not export to next AS (well-known community)\n" |
| 10091 | "Exact match of the communities") |
| 10092 | |
| 10093 | ALIAS (show_bgp_community_exact, |
| 10094 | show_bgp_ipv6_community2_exact_cmd, |
| 10095 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10096 | SHOW_STR |
| 10097 | BGP_STR |
| 10098 | "Address family\n" |
| 10099 | "Display routes matching the communities\n" |
| 10100 | "community number\n" |
| 10101 | "Do not send outside local AS (well-known community)\n" |
| 10102 | "Do not advertise to any peer (well-known community)\n" |
| 10103 | "Do not export to next AS (well-known community)\n" |
| 10104 | "community number\n" |
| 10105 | "Do not send outside local AS (well-known community)\n" |
| 10106 | "Do not advertise to any peer (well-known community)\n" |
| 10107 | "Do not export to next AS (well-known community)\n" |
| 10108 | "Exact match of the communities") |
| 10109 | |
| 10110 | ALIAS (show_bgp_community_exact, |
| 10111 | show_bgp_community3_exact_cmd, |
| 10112 | "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", |
| 10113 | SHOW_STR |
| 10114 | BGP_STR |
| 10115 | "Display routes matching the communities\n" |
| 10116 | "community number\n" |
| 10117 | "Do not send outside local AS (well-known community)\n" |
| 10118 | "Do not advertise to any peer (well-known community)\n" |
| 10119 | "Do not export to next AS (well-known community)\n" |
| 10120 | "community number\n" |
| 10121 | "Do not send outside local AS (well-known community)\n" |
| 10122 | "Do not advertise to any peer (well-known community)\n" |
| 10123 | "Do not export to next AS (well-known community)\n" |
| 10124 | "community number\n" |
| 10125 | "Do not send outside local AS (well-known community)\n" |
| 10126 | "Do not advertise to any peer (well-known community)\n" |
| 10127 | "Do not export to next AS (well-known community)\n" |
| 10128 | "Exact match of the communities") |
| 10129 | |
| 10130 | ALIAS (show_bgp_community_exact, |
| 10131 | show_bgp_ipv6_community3_exact_cmd, |
| 10132 | "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", |
| 10133 | SHOW_STR |
| 10134 | BGP_STR |
| 10135 | "Address family\n" |
| 10136 | "Display routes matching the communities\n" |
| 10137 | "community number\n" |
| 10138 | "Do not send outside local AS (well-known community)\n" |
| 10139 | "Do not advertise to any peer (well-known community)\n" |
| 10140 | "Do not export to next AS (well-known community)\n" |
| 10141 | "community number\n" |
| 10142 | "Do not send outside local AS (well-known community)\n" |
| 10143 | "Do not advertise to any peer (well-known community)\n" |
| 10144 | "Do not export to next AS (well-known community)\n" |
| 10145 | "community number\n" |
| 10146 | "Do not send outside local AS (well-known community)\n" |
| 10147 | "Do not advertise to any peer (well-known community)\n" |
| 10148 | "Do not export to next AS (well-known community)\n" |
| 10149 | "Exact match of the communities") |
| 10150 | |
| 10151 | ALIAS (show_bgp_community_exact, |
| 10152 | show_bgp_community4_exact_cmd, |
| 10153 | "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", |
| 10154 | SHOW_STR |
| 10155 | BGP_STR |
| 10156 | "Display routes matching the communities\n" |
| 10157 | "community number\n" |
| 10158 | "Do not send outside local AS (well-known community)\n" |
| 10159 | "Do not advertise to any peer (well-known community)\n" |
| 10160 | "Do not export to next AS (well-known community)\n" |
| 10161 | "community number\n" |
| 10162 | "Do not send outside local AS (well-known community)\n" |
| 10163 | "Do not advertise to any peer (well-known community)\n" |
| 10164 | "Do not export to next AS (well-known community)\n" |
| 10165 | "community number\n" |
| 10166 | "Do not send outside local AS (well-known community)\n" |
| 10167 | "Do not advertise to any peer (well-known community)\n" |
| 10168 | "Do not export to next AS (well-known community)\n" |
| 10169 | "community number\n" |
| 10170 | "Do not send outside local AS (well-known community)\n" |
| 10171 | "Do not advertise to any peer (well-known community)\n" |
| 10172 | "Do not export to next AS (well-known community)\n" |
| 10173 | "Exact match of the communities") |
| 10174 | |
| 10175 | ALIAS (show_bgp_community_exact, |
| 10176 | show_bgp_ipv6_community4_exact_cmd, |
| 10177 | "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", |
| 10178 | SHOW_STR |
| 10179 | BGP_STR |
| 10180 | "Address family\n" |
| 10181 | "Display routes matching the communities\n" |
| 10182 | "community number\n" |
| 10183 | "Do not send outside local AS (well-known community)\n" |
| 10184 | "Do not advertise to any peer (well-known community)\n" |
| 10185 | "Do not export to next AS (well-known community)\n" |
| 10186 | "community number\n" |
| 10187 | "Do not send outside local AS (well-known community)\n" |
| 10188 | "Do not advertise to any peer (well-known community)\n" |
| 10189 | "Do not export to next AS (well-known community)\n" |
| 10190 | "community number\n" |
| 10191 | "Do not send outside local AS (well-known community)\n" |
| 10192 | "Do not advertise to any peer (well-known community)\n" |
| 10193 | "Do not export to next AS (well-known community)\n" |
| 10194 | "community number\n" |
| 10195 | "Do not send outside local AS (well-known community)\n" |
| 10196 | "Do not advertise to any peer (well-known community)\n" |
| 10197 | "Do not export to next AS (well-known community)\n" |
| 10198 | "Exact match of the communities") |
| 10199 | |
| 10200 | /* old command */ |
| 10201 | DEFUN (show_ipv6_bgp_community_exact, |
| 10202 | show_ipv6_bgp_community_exact_cmd, |
| 10203 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10204 | SHOW_STR |
| 10205 | IPV6_STR |
| 10206 | BGP_STR |
| 10207 | "Display routes matching the communities\n" |
| 10208 | "community number\n" |
| 10209 | "Do not send outside local AS (well-known community)\n" |
| 10210 | "Do not advertise to any peer (well-known community)\n" |
| 10211 | "Do not export to next AS (well-known community)\n" |
| 10212 | "Exact match of the communities") |
| 10213 | { |
| 10214 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 10215 | } |
| 10216 | |
| 10217 | /* old command */ |
| 10218 | ALIAS (show_ipv6_bgp_community_exact, |
| 10219 | show_ipv6_bgp_community2_exact_cmd, |
| 10220 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10221 | SHOW_STR |
| 10222 | IPV6_STR |
| 10223 | BGP_STR |
| 10224 | "Display routes matching the communities\n" |
| 10225 | "community number\n" |
| 10226 | "Do not send outside local AS (well-known community)\n" |
| 10227 | "Do not advertise to any peer (well-known community)\n" |
| 10228 | "Do not export to next AS (well-known community)\n" |
| 10229 | "community number\n" |
| 10230 | "Do not send outside local AS (well-known community)\n" |
| 10231 | "Do not advertise to any peer (well-known community)\n" |
| 10232 | "Do not export to next AS (well-known community)\n" |
| 10233 | "Exact match of the communities") |
| 10234 | |
| 10235 | /* old command */ |
| 10236 | ALIAS (show_ipv6_bgp_community_exact, |
| 10237 | show_ipv6_bgp_community3_exact_cmd, |
| 10238 | "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", |
| 10239 | SHOW_STR |
| 10240 | IPV6_STR |
| 10241 | BGP_STR |
| 10242 | "Display routes matching the communities\n" |
| 10243 | "community number\n" |
| 10244 | "Do not send outside local AS (well-known community)\n" |
| 10245 | "Do not advertise to any peer (well-known community)\n" |
| 10246 | "Do not export to next AS (well-known community)\n" |
| 10247 | "community number\n" |
| 10248 | "Do not send outside local AS (well-known community)\n" |
| 10249 | "Do not advertise to any peer (well-known community)\n" |
| 10250 | "Do not export to next AS (well-known community)\n" |
| 10251 | "community number\n" |
| 10252 | "Do not send outside local AS (well-known community)\n" |
| 10253 | "Do not advertise to any peer (well-known community)\n" |
| 10254 | "Do not export to next AS (well-known community)\n" |
| 10255 | "Exact match of the communities") |
| 10256 | |
| 10257 | /* old command */ |
| 10258 | ALIAS (show_ipv6_bgp_community_exact, |
| 10259 | show_ipv6_bgp_community4_exact_cmd, |
| 10260 | "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", |
| 10261 | SHOW_STR |
| 10262 | IPV6_STR |
| 10263 | BGP_STR |
| 10264 | "Display routes matching the communities\n" |
| 10265 | "community number\n" |
| 10266 | "Do not send outside local AS (well-known community)\n" |
| 10267 | "Do not advertise to any peer (well-known community)\n" |
| 10268 | "Do not export to next AS (well-known community)\n" |
| 10269 | "community number\n" |
| 10270 | "Do not send outside local AS (well-known community)\n" |
| 10271 | "Do not advertise to any peer (well-known community)\n" |
| 10272 | "Do not export to next AS (well-known community)\n" |
| 10273 | "community number\n" |
| 10274 | "Do not send outside local AS (well-known community)\n" |
| 10275 | "Do not advertise to any peer (well-known community)\n" |
| 10276 | "Do not export to next AS (well-known community)\n" |
| 10277 | "community number\n" |
| 10278 | "Do not send outside local AS (well-known community)\n" |
| 10279 | "Do not advertise to any peer (well-known community)\n" |
| 10280 | "Do not export to next AS (well-known community)\n" |
| 10281 | "Exact match of the communities") |
| 10282 | |
| 10283 | /* old command */ |
| 10284 | DEFUN (show_ipv6_mbgp_community, |
| 10285 | show_ipv6_mbgp_community_cmd, |
| 10286 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 10287 | SHOW_STR |
| 10288 | IPV6_STR |
| 10289 | MBGP_STR |
| 10290 | "Display routes matching the communities\n" |
| 10291 | "community number\n" |
| 10292 | "Do not send outside local AS (well-known community)\n" |
| 10293 | "Do not advertise to any peer (well-known community)\n" |
| 10294 | "Do not export to next AS (well-known community)\n") |
| 10295 | { |
| 10296 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 10297 | } |
| 10298 | |
| 10299 | /* old command */ |
| 10300 | ALIAS (show_ipv6_mbgp_community, |
| 10301 | show_ipv6_mbgp_community2_cmd, |
| 10302 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 10303 | SHOW_STR |
| 10304 | IPV6_STR |
| 10305 | MBGP_STR |
| 10306 | "Display routes matching the communities\n" |
| 10307 | "community number\n" |
| 10308 | "Do not send outside local AS (well-known community)\n" |
| 10309 | "Do not advertise to any peer (well-known community)\n" |
| 10310 | "Do not export to next AS (well-known community)\n" |
| 10311 | "community number\n" |
| 10312 | "Do not send outside local AS (well-known community)\n" |
| 10313 | "Do not advertise to any peer (well-known community)\n" |
| 10314 | "Do not export to next AS (well-known community)\n") |
| 10315 | |
| 10316 | /* old command */ |
| 10317 | ALIAS (show_ipv6_mbgp_community, |
| 10318 | show_ipv6_mbgp_community3_cmd, |
| 10319 | "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)", |
| 10320 | SHOW_STR |
| 10321 | IPV6_STR |
| 10322 | MBGP_STR |
| 10323 | "Display routes matching the communities\n" |
| 10324 | "community number\n" |
| 10325 | "Do not send outside local AS (well-known community)\n" |
| 10326 | "Do not advertise to any peer (well-known community)\n" |
| 10327 | "Do not export to next AS (well-known community)\n" |
| 10328 | "community number\n" |
| 10329 | "Do not send outside local AS (well-known community)\n" |
| 10330 | "Do not advertise to any peer (well-known community)\n" |
| 10331 | "Do not export to next AS (well-known community)\n" |
| 10332 | "community number\n" |
| 10333 | "Do not send outside local AS (well-known community)\n" |
| 10334 | "Do not advertise to any peer (well-known community)\n" |
| 10335 | "Do not export to next AS (well-known community)\n") |
| 10336 | |
| 10337 | /* old command */ |
| 10338 | ALIAS (show_ipv6_mbgp_community, |
| 10339 | show_ipv6_mbgp_community4_cmd, |
| 10340 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 10341 | SHOW_STR |
| 10342 | IPV6_STR |
| 10343 | MBGP_STR |
| 10344 | "Display routes matching the communities\n" |
| 10345 | "community number\n" |
| 10346 | "Do not send outside local AS (well-known community)\n" |
| 10347 | "Do not advertise to any peer (well-known community)\n" |
| 10348 | "Do not export to next AS (well-known community)\n" |
| 10349 | "community number\n" |
| 10350 | "Do not send outside local AS (well-known community)\n" |
| 10351 | "Do not advertise to any peer (well-known community)\n" |
| 10352 | "Do not export to next AS (well-known community)\n" |
| 10353 | "community number\n" |
| 10354 | "Do not send outside local AS (well-known community)\n" |
| 10355 | "Do not advertise to any peer (well-known community)\n" |
| 10356 | "Do not export to next AS (well-known community)\n" |
| 10357 | "community number\n" |
| 10358 | "Do not send outside local AS (well-known community)\n" |
| 10359 | "Do not advertise to any peer (well-known community)\n" |
| 10360 | "Do not export to next AS (well-known community)\n") |
| 10361 | |
| 10362 | /* old command */ |
| 10363 | DEFUN (show_ipv6_mbgp_community_exact, |
| 10364 | show_ipv6_mbgp_community_exact_cmd, |
| 10365 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10366 | SHOW_STR |
| 10367 | IPV6_STR |
| 10368 | MBGP_STR |
| 10369 | "Display routes matching the communities\n" |
| 10370 | "community number\n" |
| 10371 | "Do not send outside local AS (well-known community)\n" |
| 10372 | "Do not advertise to any peer (well-known community)\n" |
| 10373 | "Do not export to next AS (well-known community)\n" |
| 10374 | "Exact match of the communities") |
| 10375 | { |
| 10376 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 10377 | } |
| 10378 | |
| 10379 | /* old command */ |
| 10380 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10381 | show_ipv6_mbgp_community2_exact_cmd, |
| 10382 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10383 | SHOW_STR |
| 10384 | IPV6_STR |
| 10385 | MBGP_STR |
| 10386 | "Display routes matching the communities\n" |
| 10387 | "community number\n" |
| 10388 | "Do not send outside local AS (well-known community)\n" |
| 10389 | "Do not advertise to any peer (well-known community)\n" |
| 10390 | "Do not export to next AS (well-known community)\n" |
| 10391 | "community number\n" |
| 10392 | "Do not send outside local AS (well-known community)\n" |
| 10393 | "Do not advertise to any peer (well-known community)\n" |
| 10394 | "Do not export to next AS (well-known community)\n" |
| 10395 | "Exact match of the communities") |
| 10396 | |
| 10397 | /* old command */ |
| 10398 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10399 | show_ipv6_mbgp_community3_exact_cmd, |
| 10400 | "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", |
| 10401 | SHOW_STR |
| 10402 | IPV6_STR |
| 10403 | MBGP_STR |
| 10404 | "Display routes matching the communities\n" |
| 10405 | "community number\n" |
| 10406 | "Do not send outside local AS (well-known community)\n" |
| 10407 | "Do not advertise to any peer (well-known community)\n" |
| 10408 | "Do not export to next AS (well-known community)\n" |
| 10409 | "community number\n" |
| 10410 | "Do not send outside local AS (well-known community)\n" |
| 10411 | "Do not advertise to any peer (well-known community)\n" |
| 10412 | "Do not export to next AS (well-known community)\n" |
| 10413 | "community number\n" |
| 10414 | "Do not send outside local AS (well-known community)\n" |
| 10415 | "Do not advertise to any peer (well-known community)\n" |
| 10416 | "Do not export to next AS (well-known community)\n" |
| 10417 | "Exact match of the communities") |
| 10418 | |
| 10419 | /* old command */ |
| 10420 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10421 | show_ipv6_mbgp_community4_exact_cmd, |
| 10422 | "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", |
| 10423 | SHOW_STR |
| 10424 | IPV6_STR |
| 10425 | MBGP_STR |
| 10426 | "Display routes matching the communities\n" |
| 10427 | "community number\n" |
| 10428 | "Do not send outside local AS (well-known community)\n" |
| 10429 | "Do not advertise to any peer (well-known community)\n" |
| 10430 | "Do not export to next AS (well-known community)\n" |
| 10431 | "community number\n" |
| 10432 | "Do not send outside local AS (well-known community)\n" |
| 10433 | "Do not advertise to any peer (well-known community)\n" |
| 10434 | "Do not export to next AS (well-known community)\n" |
| 10435 | "community number\n" |
| 10436 | "Do not send outside local AS (well-known community)\n" |
| 10437 | "Do not advertise to any peer (well-known community)\n" |
| 10438 | "Do not export to next AS (well-known community)\n" |
| 10439 | "community number\n" |
| 10440 | "Do not send outside local AS (well-known community)\n" |
| 10441 | "Do not advertise to any peer (well-known community)\n" |
| 10442 | "Do not export to next AS (well-known community)\n" |
| 10443 | "Exact match of the communities") |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10444 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10445 | DEFUN (show_bgp_ipv4_community, |
| 10446 | show_bgp_ipv4_community_cmd, |
| 10447 | "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10448 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10449 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10450 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10451 | "Display routes matching the communities\n" |
| 10452 | "community number\n" |
| 10453 | "Do not send outside local AS (well-known community)\n" |
| 10454 | "Do not advertise to any peer (well-known community)\n" |
| 10455 | "Do not export to next AS (well-known community)\n") |
| 10456 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10457 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10458 | } |
| 10459 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10460 | ALIAS (show_bgp_ipv4_community, |
| 10461 | show_bgp_ipv4_community2_cmd, |
| 10462 | "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] | 10463 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10464 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10465 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10466 | "Display routes matching the communities\n" |
| 10467 | "community number\n" |
| 10468 | "Do not send outside local AS (well-known community)\n" |
| 10469 | "Do not advertise to any peer (well-known community)\n" |
| 10470 | "Do not export to next AS (well-known community)\n" |
| 10471 | "community number\n" |
| 10472 | "Do not send outside local AS (well-known community)\n" |
| 10473 | "Do not advertise to any peer (well-known community)\n" |
| 10474 | "Do not export to next AS (well-known community)\n") |
| 10475 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10476 | ALIAS (show_bgp_ipv4_community, |
| 10477 | show_bgp_ipv4_community3_cmd, |
| 10478 | "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] | 10479 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10480 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10481 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10482 | "Display routes matching the communities\n" |
| 10483 | "community number\n" |
| 10484 | "Do not send outside local AS (well-known community)\n" |
| 10485 | "Do not advertise to any peer (well-known community)\n" |
| 10486 | "Do not export to next AS (well-known community)\n" |
| 10487 | "community number\n" |
| 10488 | "Do not send outside local AS (well-known community)\n" |
| 10489 | "Do not advertise to any peer (well-known community)\n" |
| 10490 | "Do not export to next AS (well-known community)\n" |
| 10491 | "community number\n" |
| 10492 | "Do not send outside local AS (well-known community)\n" |
| 10493 | "Do not advertise to any peer (well-known community)\n" |
| 10494 | "Do not export to next AS (well-known community)\n") |
| 10495 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10496 | ALIAS (show_bgp_ipv4_community, |
| 10497 | show_bgp_ipv4_community4_cmd, |
| 10498 | "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] | 10499 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10500 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10501 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10502 | "Display routes matching the communities\n" |
| 10503 | "community number\n" |
| 10504 | "Do not send outside local AS (well-known community)\n" |
| 10505 | "Do not advertise to any peer (well-known community)\n" |
| 10506 | "Do not export to next AS (well-known community)\n" |
| 10507 | "community number\n" |
| 10508 | "Do not send outside local AS (well-known community)\n" |
| 10509 | "Do not advertise to any peer (well-known community)\n" |
| 10510 | "Do not export to next AS (well-known community)\n" |
| 10511 | "community number\n" |
| 10512 | "Do not send outside local AS (well-known community)\n" |
| 10513 | "Do not advertise to any peer (well-known community)\n" |
| 10514 | "Do not export to next AS (well-known community)\n" |
| 10515 | "community number\n" |
| 10516 | "Do not send outside local AS (well-known community)\n" |
| 10517 | "Do not advertise to any peer (well-known community)\n" |
| 10518 | "Do not export to next AS (well-known community)\n") |
| 10519 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10520 | DEFUN (show_bgp_ipv4_safi_community, |
| 10521 | show_bgp_ipv4_safi_community_cmd, |
| 10522 | "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] | 10523 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10524 | BGP_STR |
| 10525 | "Address family\n" |
| 10526 | "Address Family modifier\n" |
| 10527 | "Address Family modifier\n" |
| 10528 | "Display routes matching the communities\n" |
| 10529 | "community number\n" |
| 10530 | "Do not send outside local AS (well-known community)\n" |
| 10531 | "Do not advertise to any peer (well-known community)\n" |
| 10532 | "Do not export to next AS (well-known community)\n") |
| 10533 | { |
| 10534 | if (strncmp (argv[0], "m", 1) == 0) |
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_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10536 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10537 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10538 | } |
| 10539 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10540 | ALIAS (show_bgp_ipv4_safi_community, |
| 10541 | show_bgp_ipv4_safi_community2_cmd, |
| 10542 | "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] | 10543 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10544 | BGP_STR |
| 10545 | "Address family\n" |
| 10546 | "Address Family modifier\n" |
| 10547 | "Address Family modifier\n" |
| 10548 | "Display routes matching the communities\n" |
| 10549 | "community number\n" |
| 10550 | "Do not send outside local AS (well-known community)\n" |
| 10551 | "Do not advertise to any peer (well-known community)\n" |
| 10552 | "Do not export to next AS (well-known community)\n" |
| 10553 | "community number\n" |
| 10554 | "Do not send outside local AS (well-known community)\n" |
| 10555 | "Do not advertise to any peer (well-known community)\n" |
| 10556 | "Do not export to next AS (well-known community)\n") |
| 10557 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10558 | ALIAS (show_bgp_ipv4_safi_community, |
| 10559 | show_bgp_ipv4_safi_community3_cmd, |
| 10560 | "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] | 10561 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10562 | BGP_STR |
| 10563 | "Address family\n" |
| 10564 | "Address Family modifier\n" |
| 10565 | "Address Family modifier\n" |
| 10566 | "Display routes matching the communities\n" |
| 10567 | "community number\n" |
| 10568 | "Do not send outside local AS (well-known community)\n" |
| 10569 | "Do not advertise to any peer (well-known community)\n" |
| 10570 | "Do not export to next AS (well-known community)\n" |
| 10571 | "community number\n" |
| 10572 | "Do not send outside local AS (well-known community)\n" |
| 10573 | "Do not advertise to any peer (well-known community)\n" |
| 10574 | "Do not export to next AS (well-known community)\n" |
| 10575 | "community number\n" |
| 10576 | "Do not send outside local AS (well-known community)\n" |
| 10577 | "Do not advertise to any peer (well-known community)\n" |
| 10578 | "Do not export to next AS (well-known community)\n") |
| 10579 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10580 | ALIAS (show_bgp_ipv4_safi_community, |
| 10581 | show_bgp_ipv4_safi_community4_cmd, |
| 10582 | "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] | 10583 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10584 | BGP_STR |
| 10585 | "Address family\n" |
| 10586 | "Address Family modifier\n" |
| 10587 | "Address Family modifier\n" |
| 10588 | "Display routes matching the communities\n" |
| 10589 | "community number\n" |
| 10590 | "Do not send outside local AS (well-known community)\n" |
| 10591 | "Do not advertise to any peer (well-known community)\n" |
| 10592 | "Do not export to next AS (well-known community)\n" |
| 10593 | "community number\n" |
| 10594 | "Do not send outside local AS (well-known community)\n" |
| 10595 | "Do not advertise to any peer (well-known community)\n" |
| 10596 | "Do not export to next AS (well-known community)\n" |
| 10597 | "community number\n" |
| 10598 | "Do not send outside local AS (well-known community)\n" |
| 10599 | "Do not advertise to any peer (well-known community)\n" |
| 10600 | "Do not export to next AS (well-known community)\n" |
| 10601 | "community number\n" |
| 10602 | "Do not send outside local AS (well-known community)\n" |
| 10603 | "Do not advertise to any peer (well-known community)\n" |
| 10604 | "Do not export to next AS (well-known community)\n") |
| 10605 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10606 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 10607 | show_bgp_view_afi_safi_community_all_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10608 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10609 | SHOW_STR |
| 10610 | BGP_STR |
| 10611 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10612 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10613 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10614 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10615 | "Address Family modifier\n" |
| 10616 | "Address Family modifier\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10617 | "Display routes matching the communities\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10618 | { |
| 10619 | int afi; |
| 10620 | int safi; |
| 10621 | struct bgp *bgp; |
| 10622 | |
| 10623 | /* BGP structure lookup. */ |
| 10624 | bgp = bgp_lookup_by_name (argv[0]); |
| 10625 | if (bgp == NULL) |
| 10626 | { |
| 10627 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10628 | return CMD_WARNING; |
| 10629 | } |
| 10630 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10631 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10632 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10633 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 10634 | } |
| 10635 | |
| 10636 | DEFUN (show_bgp_view_afi_safi_community, |
| 10637 | show_bgp_view_afi_safi_community_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10638 | "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] | 10639 | SHOW_STR |
| 10640 | BGP_STR |
| 10641 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10642 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10643 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10644 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10645 | "Address family modifier\n" |
| 10646 | "Address family modifier\n" |
| 10647 | "Display routes matching the communities\n" |
| 10648 | "community number\n" |
| 10649 | "Do not send outside local AS (well-known community)\n" |
| 10650 | "Do not advertise to any peer (well-known community)\n" |
| 10651 | "Do not export to next AS (well-known community)\n") |
| 10652 | { |
| 10653 | int afi; |
| 10654 | int safi; |
| 10655 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10656 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10657 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10658 | 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] | 10659 | } |
| 10660 | |
| 10661 | ALIAS (show_bgp_view_afi_safi_community, |
| 10662 | show_bgp_view_afi_safi_community2_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10663 | "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] | 10664 | SHOW_STR |
| 10665 | BGP_STR |
| 10666 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10667 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10668 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10669 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10670 | "Address family modifier\n" |
| 10671 | "Address family modifier\n" |
| 10672 | "Display routes matching the communities\n" |
| 10673 | "community number\n" |
| 10674 | "Do not send outside local AS (well-known community)\n" |
| 10675 | "Do not advertise to any peer (well-known community)\n" |
| 10676 | "Do not export to next AS (well-known community)\n" |
| 10677 | "community number\n" |
| 10678 | "Do not send outside local AS (well-known community)\n" |
| 10679 | "Do not advertise to any peer (well-known community)\n" |
| 10680 | "Do not export to next AS (well-known community)\n") |
| 10681 | |
| 10682 | ALIAS (show_bgp_view_afi_safi_community, |
| 10683 | show_bgp_view_afi_safi_community3_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10684 | "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] | 10685 | SHOW_STR |
| 10686 | BGP_STR |
| 10687 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10688 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10689 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10690 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10691 | "Address family modifier\n" |
| 10692 | "Address family modifier\n" |
| 10693 | "Display routes matching the communities\n" |
| 10694 | "community number\n" |
| 10695 | "Do not send outside local AS (well-known community)\n" |
| 10696 | "Do not advertise to any peer (well-known community)\n" |
| 10697 | "Do not export to next AS (well-known community)\n" |
| 10698 | "community number\n" |
| 10699 | "Do not send outside local AS (well-known community)\n" |
| 10700 | "Do not advertise to any peer (well-known community)\n" |
| 10701 | "Do not export to next AS (well-known community)\n" |
| 10702 | "community number\n" |
| 10703 | "Do not send outside local AS (well-known community)\n" |
| 10704 | "Do not advertise to any peer (well-known community)\n" |
| 10705 | "Do not export to next AS (well-known community)\n") |
| 10706 | |
| 10707 | ALIAS (show_bgp_view_afi_safi_community, |
| 10708 | show_bgp_view_afi_safi_community4_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10709 | "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] | 10710 | SHOW_STR |
| 10711 | BGP_STR |
| 10712 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10713 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10714 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10715 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10716 | "Address family modifier\n" |
| 10717 | "Address family modifier\n" |
| 10718 | "Display routes matching the communities\n" |
| 10719 | "community number\n" |
| 10720 | "Do not send outside local AS (well-known community)\n" |
| 10721 | "Do not advertise to any peer (well-known community)\n" |
| 10722 | "Do not export to next AS (well-known community)\n" |
| 10723 | "community number\n" |
| 10724 | "Do not send outside local AS (well-known community)\n" |
| 10725 | "Do not advertise to any peer (well-known community)\n" |
| 10726 | "Do not export to next AS (well-known community)\n" |
| 10727 | "community number\n" |
| 10728 | "Do not send outside local AS (well-known community)\n" |
| 10729 | "Do not advertise to any peer (well-known community)\n" |
| 10730 | "Do not export to next AS (well-known community)\n" |
| 10731 | "community number\n" |
| 10732 | "Do not send outside local AS (well-known community)\n" |
| 10733 | "Do not advertise to any peer (well-known community)\n" |
| 10734 | "Do not export to next AS (well-known community)\n") |
| 10735 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10736 | DEFUN (show_bgp_ipv4_community_exact, |
| 10737 | show_bgp_ipv4_community_exact_cmd, |
| 10738 | "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] | 10739 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10740 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10741 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10742 | "Display routes matching the communities\n" |
| 10743 | "community number\n" |
| 10744 | "Do not send outside local AS (well-known community)\n" |
| 10745 | "Do not advertise to any peer (well-known community)\n" |
| 10746 | "Do not export to next AS (well-known community)\n" |
| 10747 | "Exact match of the communities") |
| 10748 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10749 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10750 | } |
| 10751 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10752 | ALIAS (show_bgp_ipv4_community_exact, |
| 10753 | show_bgp_ipv4_community2_exact_cmd, |
| 10754 | "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] | 10755 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10756 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10757 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10758 | "Display routes matching the communities\n" |
| 10759 | "community number\n" |
| 10760 | "Do not send outside local AS (well-known community)\n" |
| 10761 | "Do not advertise to any peer (well-known community)\n" |
| 10762 | "Do not export to next AS (well-known community)\n" |
| 10763 | "community number\n" |
| 10764 | "Do not send outside local AS (well-known community)\n" |
| 10765 | "Do not advertise to any peer (well-known community)\n" |
| 10766 | "Do not export to next AS (well-known community)\n" |
| 10767 | "Exact match of the communities") |
| 10768 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10769 | ALIAS (show_bgp_ipv4_community_exact, |
| 10770 | show_bgp_ipv4_community3_exact_cmd, |
| 10771 | "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] | 10772 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10773 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10774 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10775 | "Display routes matching the communities\n" |
| 10776 | "community number\n" |
| 10777 | "Do not send outside local AS (well-known community)\n" |
| 10778 | "Do not advertise to any peer (well-known community)\n" |
| 10779 | "Do not export to next AS (well-known community)\n" |
| 10780 | "community number\n" |
| 10781 | "Do not send outside local AS (well-known community)\n" |
| 10782 | "Do not advertise to any peer (well-known community)\n" |
| 10783 | "Do not export to next AS (well-known community)\n" |
| 10784 | "community number\n" |
| 10785 | "Do not send outside local AS (well-known community)\n" |
| 10786 | "Do not advertise to any peer (well-known community)\n" |
| 10787 | "Do not export to next AS (well-known community)\n" |
| 10788 | "Exact match of the communities") |
| 10789 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10790 | ALIAS (show_bgp_ipv4_community_exact, |
| 10791 | show_bgp_ipv4_community4_exact_cmd, |
| 10792 | "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] | 10793 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10794 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10795 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10796 | "Display routes matching the communities\n" |
| 10797 | "community number\n" |
| 10798 | "Do not send outside local AS (well-known community)\n" |
| 10799 | "Do not advertise to any peer (well-known community)\n" |
| 10800 | "Do not export to next AS (well-known community)\n" |
| 10801 | "community number\n" |
| 10802 | "Do not send outside local AS (well-known community)\n" |
| 10803 | "Do not advertise to any peer (well-known community)\n" |
| 10804 | "Do not export to next AS (well-known community)\n" |
| 10805 | "community number\n" |
| 10806 | "Do not send outside local AS (well-known community)\n" |
| 10807 | "Do not advertise to any peer (well-known community)\n" |
| 10808 | "Do not export to next AS (well-known community)\n" |
| 10809 | "community number\n" |
| 10810 | "Do not send outside local AS (well-known community)\n" |
| 10811 | "Do not advertise to any peer (well-known community)\n" |
| 10812 | "Do not export to next AS (well-known community)\n" |
| 10813 | "Exact match of the communities") |
| 10814 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10815 | DEFUN (show_bgp_ipv4_safi_community4_exact, |
| 10816 | show_bgp_ipv4_safi_community_exact_cmd, |
| 10817 | "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] | 10818 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10819 | BGP_STR |
| 10820 | "Address family\n" |
| 10821 | "Address Family modifier\n" |
| 10822 | "Address Family modifier\n" |
| 10823 | "Display routes matching the communities\n" |
| 10824 | "community number\n" |
| 10825 | "Do not send outside local AS (well-known community)\n" |
| 10826 | "Do not advertise to any peer (well-known community)\n" |
| 10827 | "Do not export to next AS (well-known community)\n" |
| 10828 | "Exact match of the communities") |
| 10829 | { |
| 10830 | if (strncmp (argv[0], "m", 1) == 0) |
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_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10832 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10833 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10834 | } |
| 10835 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10836 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10837 | show_bgp_ipv4_safi_community2_exact_cmd, |
| 10838 | "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] | 10839 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10840 | BGP_STR |
| 10841 | "Address family\n" |
| 10842 | "Address Family modifier\n" |
| 10843 | "Address Family modifier\n" |
| 10844 | "Display routes matching the communities\n" |
| 10845 | "community number\n" |
| 10846 | "Do not send outside local AS (well-known community)\n" |
| 10847 | "Do not advertise to any peer (well-known community)\n" |
| 10848 | "Do not export to next AS (well-known community)\n" |
| 10849 | "community number\n" |
| 10850 | "Do not send outside local AS (well-known community)\n" |
| 10851 | "Do not advertise to any peer (well-known community)\n" |
| 10852 | "Do not export to next AS (well-known community)\n" |
| 10853 | "Exact match of the communities") |
| 10854 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10855 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10856 | show_bgp_ipv4_safi_community3_exact_cmd, |
| 10857 | "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] | 10858 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10859 | BGP_STR |
| 10860 | "Address family\n" |
| 10861 | "Address Family modifier\n" |
| 10862 | "Address Family modifier\n" |
| 10863 | "Display routes matching the communities\n" |
| 10864 | "community number\n" |
| 10865 | "Do not send outside local AS (well-known community)\n" |
| 10866 | "Do not advertise to any peer (well-known community)\n" |
| 10867 | "Do not export to next AS (well-known community)\n" |
| 10868 | "community number\n" |
| 10869 | "Do not send outside local AS (well-known community)\n" |
| 10870 | "Do not advertise to any peer (well-known community)\n" |
| 10871 | "Do not export to next AS (well-known community)\n" |
| 10872 | "community number\n" |
| 10873 | "Do not send outside local AS (well-known community)\n" |
| 10874 | "Do not advertise to any peer (well-known community)\n" |
| 10875 | "Do not export to next AS (well-known community)\n" |
| 10876 | "Exact match of the communities") |
| 10877 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10878 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10879 | show_bgp_ipv4_safi_community4_exact_cmd, |
| 10880 | "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] | 10881 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10882 | BGP_STR |
| 10883 | "Address family\n" |
| 10884 | "Address Family modifier\n" |
| 10885 | "Address Family modifier\n" |
| 10886 | "Display routes matching the communities\n" |
| 10887 | "community number\n" |
| 10888 | "Do not send outside local AS (well-known community)\n" |
| 10889 | "Do not advertise to any peer (well-known community)\n" |
| 10890 | "Do not export to next AS (well-known community)\n" |
| 10891 | "community number\n" |
| 10892 | "Do not send outside local AS (well-known community)\n" |
| 10893 | "Do not advertise to any peer (well-known community)\n" |
| 10894 | "Do not export to next AS (well-known community)\n" |
| 10895 | "community number\n" |
| 10896 | "Do not send outside local AS (well-known community)\n" |
| 10897 | "Do not advertise to any peer (well-known community)\n" |
| 10898 | "Do not export to next AS (well-known community)\n" |
| 10899 | "community number\n" |
| 10900 | "Do not send outside local AS (well-known community)\n" |
| 10901 | "Do not advertise to any peer (well-known community)\n" |
| 10902 | "Do not export to next AS (well-known community)\n" |
| 10903 | "Exact match of the communities") |
| 10904 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10905 | DEFUN (show_bgp_ipv6_safi_community, |
| 10906 | show_bgp_ipv6_safi_community_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10907 | "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] | 10908 | SHOW_STR |
| 10909 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10910 | "Address family\n" |
| 10911 | "Address family modifier\n" |
| 10912 | "Address family modifier\n" |
| 10913 | "Address family modifier\n" |
| 10914 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10915 | "Display routes matching the communities\n" |
| 10916 | "community number\n" |
| 10917 | "Do not send outside local AS (well-known community)\n" |
| 10918 | "Do not advertise to any peer (well-known community)\n" |
| 10919 | "Do not export to next AS (well-known community)\n") |
| 10920 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10921 | safi_t safi; |
| 10922 | |
| 10923 | if (bgp_parse_safi(argv[0], &safi)) { |
| 10924 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 10925 | return CMD_WARNING; |
| 10926 | } |
| 10927 | 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] | 10928 | } |
| 10929 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10930 | ALIAS (show_bgp_ipv6_safi_community, |
| 10931 | show_bgp_ipv6_safi_community2_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10932 | "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] | 10933 | SHOW_STR |
| 10934 | BGP_STR |
| 10935 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10936 | "Address family modifier\n" |
| 10937 | "Address family modifier\n" |
| 10938 | "Address family modifier\n" |
| 10939 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10940 | "Display routes matching the communities\n" |
| 10941 | "community number\n" |
| 10942 | "Do not send outside local AS (well-known community)\n" |
| 10943 | "Do not advertise to any peer (well-known community)\n" |
| 10944 | "Do not export to next AS (well-known community)\n" |
| 10945 | "community number\n" |
| 10946 | "Do not send outside local AS (well-known community)\n" |
| 10947 | "Do not advertise to any peer (well-known community)\n" |
| 10948 | "Do not export to next AS (well-known community)\n") |
| 10949 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10950 | ALIAS (show_bgp_ipv6_safi_community, |
| 10951 | show_bgp_ipv6_safi_community3_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10952 | "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] | 10953 | SHOW_STR |
| 10954 | BGP_STR |
| 10955 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10956 | "Address family modifier\n" |
| 10957 | "Address family modifier\n" |
| 10958 | "Address family modifier\n" |
| 10959 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10960 | "Display routes matching the communities\n" |
| 10961 | "community number\n" |
| 10962 | "Do not send outside local AS (well-known community)\n" |
| 10963 | "Do not advertise to any peer (well-known community)\n" |
| 10964 | "Do not export to next AS (well-known community)\n" |
| 10965 | "community number\n" |
| 10966 | "Do not send outside local AS (well-known community)\n" |
| 10967 | "Do not advertise to any peer (well-known community)\n" |
| 10968 | "Do not export to next AS (well-known community)\n" |
| 10969 | "community number\n" |
| 10970 | "Do not send outside local AS (well-known community)\n" |
| 10971 | "Do not advertise to any peer (well-known community)\n" |
| 10972 | "Do not export to next AS (well-known community)\n") |
| 10973 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10974 | ALIAS (show_bgp_ipv6_safi_community, |
| 10975 | show_bgp_ipv6_safi_community4_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10976 | "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] | 10977 | SHOW_STR |
| 10978 | BGP_STR |
| 10979 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10980 | "Address family modifier\n" |
| 10981 | "Address family modifier\n" |
| 10982 | "Address family modifier\n" |
| 10983 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10984 | "Display routes matching the communities\n" |
| 10985 | "community number\n" |
| 10986 | "Do not send outside local AS (well-known community)\n" |
| 10987 | "Do not advertise to any peer (well-known community)\n" |
| 10988 | "Do not export to next AS (well-known community)\n" |
| 10989 | "community number\n" |
| 10990 | "Do not send outside local AS (well-known community)\n" |
| 10991 | "Do not advertise to any peer (well-known community)\n" |
| 10992 | "Do not export to next AS (well-known community)\n" |
| 10993 | "community number\n" |
| 10994 | "Do not send outside local AS (well-known community)\n" |
| 10995 | "Do not advertise to any peer (well-known community)\n" |
| 10996 | "Do not export to next AS (well-known community)\n" |
| 10997 | "community number\n" |
| 10998 | "Do not send outside local AS (well-known community)\n" |
| 10999 | "Do not advertise to any peer (well-known community)\n" |
| 11000 | "Do not export to next AS (well-known community)\n") |
| 11001 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11002 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11003 | DEFUN (show_bgp_ipv6_safi_community_exact, |
| 11004 | show_bgp_ipv6_safi_community_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11005 | "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] | 11006 | SHOW_STR |
| 11007 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11008 | "Address family\n" |
| 11009 | "Address family modifier\n" |
| 11010 | "Address family modifier\n" |
| 11011 | "Address family modifier\n" |
| 11012 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11013 | "Display routes matching the communities\n" |
| 11014 | "community number\n" |
| 11015 | "Do not send outside local AS (well-known community)\n" |
| 11016 | "Do not advertise to any peer (well-known community)\n" |
| 11017 | "Do not export to next AS (well-known community)\n" |
| 11018 | "Exact match of the communities") |
| 11019 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11020 | safi_t safi; |
| 11021 | |
| 11022 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11023 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11024 | return CMD_WARNING; |
| 11025 | } |
| 11026 | 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] | 11027 | } |
| 11028 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11029 | |
| 11030 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11031 | show_bgp_ipv6_safi_community2_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11032 | "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] | 11033 | SHOW_STR |
| 11034 | BGP_STR |
| 11035 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11036 | "Address family modifier\n" |
| 11037 | "Address family modifier\n" |
| 11038 | "Address family modifier\n" |
| 11039 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11040 | "Display routes matching the communities\n" |
| 11041 | "community number\n" |
| 11042 | "Do not send outside local AS (well-known community)\n" |
| 11043 | "Do not advertise to any peer (well-known community)\n" |
| 11044 | "Do not export to next AS (well-known community)\n" |
| 11045 | "community number\n" |
| 11046 | "Do not send outside local AS (well-known community)\n" |
| 11047 | "Do not advertise to any peer (well-known community)\n" |
| 11048 | "Do not export to next AS (well-known community)\n" |
| 11049 | "Exact match of the communities") |
| 11050 | |
| 11051 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11052 | show_bgp_ipv6_safi_community3_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11053 | "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] | 11054 | SHOW_STR |
| 11055 | BGP_STR |
| 11056 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11057 | "Address family modifier\n" |
| 11058 | "Address family modifier\n" |
| 11059 | "Address family modifier\n" |
| 11060 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11061 | "Display routes matching the communities\n" |
| 11062 | "community number\n" |
| 11063 | "Do not send outside local AS (well-known community)\n" |
| 11064 | "Do not advertise to any peer (well-known community)\n" |
| 11065 | "Do not export to next AS (well-known community)\n" |
| 11066 | "community number\n" |
| 11067 | "Do not send outside local AS (well-known community)\n" |
| 11068 | "Do not advertise to any peer (well-known community)\n" |
| 11069 | "Do not export to next AS (well-known community)\n" |
| 11070 | "community number\n" |
| 11071 | "Do not send outside local AS (well-known community)\n" |
| 11072 | "Do not advertise to any peer (well-known community)\n" |
| 11073 | "Do not export to next AS (well-known community)\n" |
| 11074 | "Exact match of the communities") |
| 11075 | |
| 11076 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11077 | show_bgp_ipv6_safi_community4_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11078 | "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] | 11079 | SHOW_STR |
| 11080 | BGP_STR |
| 11081 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11082 | "Address family modifier\n" |
| 11083 | "Address family modifier\n" |
| 11084 | "Address family modifier\n" |
| 11085 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11086 | "Display routes matching the communities\n" |
| 11087 | "community number\n" |
| 11088 | "Do not send outside local AS (well-known community)\n" |
| 11089 | "Do not advertise to any peer (well-known community)\n" |
| 11090 | "Do not export to next AS (well-known community)\n" |
| 11091 | "community number\n" |
| 11092 | "Do not send outside local AS (well-known community)\n" |
| 11093 | "Do not advertise to any peer (well-known community)\n" |
| 11094 | "Do not export to next AS (well-known community)\n" |
| 11095 | "community number\n" |
| 11096 | "Do not send outside local AS (well-known community)\n" |
| 11097 | "Do not advertise to any peer (well-known community)\n" |
| 11098 | "Do not export to next AS (well-known community)\n" |
| 11099 | "community number\n" |
| 11100 | "Do not send outside local AS (well-known community)\n" |
| 11101 | "Do not advertise to any peer (well-known community)\n" |
| 11102 | "Do not export to next AS (well-known community)\n" |
| 11103 | "Exact match of the communities") |
| 11104 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11105 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11106 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 11107 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11108 | { |
| 11109 | struct community_list *list; |
| 11110 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11111 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11112 | if (list == NULL) |
| 11113 | { |
| 11114 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 11115 | VTY_NEWLINE); |
| 11116 | return CMD_WARNING; |
| 11117 | } |
| 11118 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11119 | return bgp_show (vty, NULL, afi, safi, |
| 11120 | (exact ? bgp_show_type_community_list_exact : |
| 11121 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11122 | } |
| 11123 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11124 | DEFUN (show_ip_bgp_community_list, |
| 11125 | show_ip_bgp_community_list_cmd, |
| 11126 | "show ip bgp community-list (<1-500>|WORD)", |
| 11127 | SHOW_STR |
| 11128 | IP_STR |
| 11129 | BGP_STR |
| 11130 | "Display routes matching the community-list\n" |
| 11131 | "community-list number\n" |
| 11132 | "community-list name\n") |
| 11133 | { |
| 11134 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 11135 | } |
| 11136 | |
| 11137 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 11138 | show_ip_bgp_ipv4_community_list_cmd, |
| 11139 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
| 11140 | SHOW_STR |
| 11141 | IP_STR |
| 11142 | BGP_STR |
| 11143 | "Address family\n" |
| 11144 | "Address Family modifier\n" |
| 11145 | "Address Family modifier\n" |
| 11146 | "Display routes matching the community-list\n" |
| 11147 | "community-list number\n" |
| 11148 | "community-list name\n") |
| 11149 | { |
| 11150 | if (strncmp (argv[0], "m", 1) == 0) |
| 11151 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 11152 | |
| 11153 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 11154 | } |
| 11155 | |
| 11156 | DEFUN (show_ip_bgp_community_list_exact, |
| 11157 | show_ip_bgp_community_list_exact_cmd, |
| 11158 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
| 11159 | SHOW_STR |
| 11160 | IP_STR |
| 11161 | BGP_STR |
| 11162 | "Display routes matching the community-list\n" |
| 11163 | "community-list number\n" |
| 11164 | "community-list name\n" |
| 11165 | "Exact match of the communities\n") |
| 11166 | { |
| 11167 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 11168 | } |
| 11169 | |
| 11170 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 11171 | show_ip_bgp_ipv4_community_list_exact_cmd, |
| 11172 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
| 11173 | SHOW_STR |
| 11174 | IP_STR |
| 11175 | BGP_STR |
| 11176 | "Address family\n" |
| 11177 | "Address Family modifier\n" |
| 11178 | "Address Family modifier\n" |
| 11179 | "Display routes matching the community-list\n" |
| 11180 | "community-list number\n" |
| 11181 | "community-list name\n" |
| 11182 | "Exact match of the communities\n") |
| 11183 | { |
| 11184 | if (strncmp (argv[0], "m", 1) == 0) |
| 11185 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 11186 | |
| 11187 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 11188 | } |
| 11189 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11190 | DEFUN (show_bgp_community_list, |
| 11191 | show_bgp_community_list_cmd, |
| 11192 | "show bgp community-list (<1-500>|WORD)", |
| 11193 | SHOW_STR |
| 11194 | BGP_STR |
| 11195 | "Display routes matching the community-list\n" |
| 11196 | "community-list number\n" |
| 11197 | "community-list name\n") |
| 11198 | { |
| 11199 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 11200 | } |
| 11201 | |
| 11202 | ALIAS (show_bgp_community_list, |
| 11203 | show_bgp_ipv6_community_list_cmd, |
| 11204 | "show bgp ipv6 community-list (<1-500>|WORD)", |
| 11205 | SHOW_STR |
| 11206 | BGP_STR |
| 11207 | "Address family\n" |
| 11208 | "Display routes matching the community-list\n" |
| 11209 | "community-list number\n" |
| 11210 | "community-list name\n") |
| 11211 | |
| 11212 | /* old command */ |
| 11213 | DEFUN (show_ipv6_bgp_community_list, |
| 11214 | show_ipv6_bgp_community_list_cmd, |
| 11215 | "show ipv6 bgp community-list WORD", |
| 11216 | SHOW_STR |
| 11217 | IPV6_STR |
| 11218 | BGP_STR |
| 11219 | "Display routes matching the community-list\n" |
| 11220 | "community-list name\n") |
| 11221 | { |
| 11222 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 11223 | } |
| 11224 | |
| 11225 | /* old command */ |
| 11226 | DEFUN (show_ipv6_mbgp_community_list, |
| 11227 | show_ipv6_mbgp_community_list_cmd, |
| 11228 | "show ipv6 mbgp community-list WORD", |
| 11229 | SHOW_STR |
| 11230 | IPV6_STR |
| 11231 | MBGP_STR |
| 11232 | "Display routes matching the community-list\n" |
| 11233 | "community-list name\n") |
| 11234 | { |
| 11235 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 11236 | } |
| 11237 | |
| 11238 | DEFUN (show_bgp_community_list_exact, |
| 11239 | show_bgp_community_list_exact_cmd, |
| 11240 | "show bgp community-list (<1-500>|WORD) exact-match", |
| 11241 | SHOW_STR |
| 11242 | BGP_STR |
| 11243 | "Display routes matching the community-list\n" |
| 11244 | "community-list number\n" |
| 11245 | "community-list name\n" |
| 11246 | "Exact match of the communities\n") |
| 11247 | { |
| 11248 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 11249 | } |
| 11250 | |
| 11251 | ALIAS (show_bgp_community_list_exact, |
| 11252 | show_bgp_ipv6_community_list_exact_cmd, |
| 11253 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
| 11254 | SHOW_STR |
| 11255 | BGP_STR |
| 11256 | "Address family\n" |
| 11257 | "Display routes matching the community-list\n" |
| 11258 | "community-list number\n" |
| 11259 | "community-list name\n" |
| 11260 | "Exact match of the communities\n") |
| 11261 | |
| 11262 | /* old command */ |
| 11263 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 11264 | show_ipv6_bgp_community_list_exact_cmd, |
| 11265 | "show ipv6 bgp community-list WORD exact-match", |
| 11266 | SHOW_STR |
| 11267 | IPV6_STR |
| 11268 | BGP_STR |
| 11269 | "Display routes matching the community-list\n" |
| 11270 | "community-list name\n" |
| 11271 | "Exact match of the communities\n") |
| 11272 | { |
| 11273 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 11274 | } |
| 11275 | |
| 11276 | /* old command */ |
| 11277 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 11278 | show_ipv6_mbgp_community_list_exact_cmd, |
| 11279 | "show ipv6 mbgp community-list WORD exact-match", |
| 11280 | SHOW_STR |
| 11281 | IPV6_STR |
| 11282 | MBGP_STR |
| 11283 | "Display routes matching the community-list\n" |
| 11284 | "community-list name\n" |
| 11285 | "Exact match of the communities\n") |
| 11286 | { |
| 11287 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 11288 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11289 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11290 | DEFUN (show_bgp_ipv4_community_list, |
| 11291 | show_bgp_ipv4_community_list_cmd, |
| 11292 | "show bgp ipv4 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11293 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11294 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11295 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11296 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11297 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11298 | "community-list name\n") |
| 11299 | { |
| 11300 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 11301 | } |
| 11302 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11303 | DEFUN (show_bgp_ipv4_safi_community_list, |
| 11304 | show_bgp_ipv4_safi_community_list_cmd, |
| 11305 | "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11306 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11307 | BGP_STR |
| 11308 | "Address family\n" |
| 11309 | "Address Family modifier\n" |
| 11310 | "Address Family modifier\n" |
| 11311 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11312 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11313 | "community-list name\n") |
| 11314 | { |
| 11315 | if (strncmp (argv[0], "m", 1) == 0) |
| 11316 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 11317 | |
| 11318 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 11319 | } |
| 11320 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11321 | DEFUN (show_bgp_ipv4_community_list_exact, |
| 11322 | show_bgp_ipv4_community_list_exact_cmd, |
| 11323 | "show bgp ipv4 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11324 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11325 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11326 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11327 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11328 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11329 | "community-list name\n" |
| 11330 | "Exact match of the communities\n") |
| 11331 | { |
| 11332 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 11333 | } |
| 11334 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11335 | DEFUN (show_bgp_ipv4_safi_community_list_exact, |
| 11336 | show_bgp_ipv4_safi_community_list_exact_cmd, |
| 11337 | "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11338 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11339 | BGP_STR |
| 11340 | "Address family\n" |
| 11341 | "Address Family modifier\n" |
| 11342 | "Address Family modifier\n" |
| 11343 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11344 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11345 | "community-list name\n" |
| 11346 | "Exact match of the communities\n") |
| 11347 | { |
| 11348 | if (strncmp (argv[0], "m", 1) == 0) |
| 11349 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 11350 | |
| 11351 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 11352 | } |
| 11353 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11354 | DEFUN (show_bgp_ipv6_safi_community_list, |
| 11355 | show_bgp_ipv6_safi_community_list_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11356 | "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11357 | SHOW_STR |
| 11358 | BGP_STR |
| 11359 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11360 | "Address family modifier\n" |
| 11361 | "Address family modifier\n" |
| 11362 | "Address family modifier\n" |
| 11363 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11364 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11365 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 11366 | "community-list name\n") |
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 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11369 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11370 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11371 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11372 | return CMD_WARNING; |
| 11373 | } |
| 11374 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11375 | } |
| 11376 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11377 | DEFUN (show_bgp_ipv6_safi_community_list_exact, |
| 11378 | show_bgp_ipv6_safi_community_list_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11379 | "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] | 11380 | SHOW_STR |
| 11381 | BGP_STR |
| 11382 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11383 | "Address family modifier\n" |
| 11384 | "Address family modifier\n" |
| 11385 | "Address family modifier\n" |
| 11386 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11387 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11388 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11389 | "community-list name\n" |
| 11390 | "Exact match of the communities\n") |
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 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11393 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11394 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11395 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11396 | return CMD_WARNING; |
| 11397 | } |
| 11398 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11399 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11400 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11401 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11402 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11403 | safi_t safi, enum bgp_show_type type) |
| 11404 | { |
| 11405 | int ret; |
| 11406 | struct prefix *p; |
| 11407 | |
| 11408 | p = prefix_new(); |
| 11409 | |
| 11410 | ret = str2prefix (prefix, p); |
| 11411 | if (! ret) |
| 11412 | { |
| 11413 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 11414 | return CMD_WARNING; |
| 11415 | } |
| 11416 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11417 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 11418 | prefix_free(p); |
| 11419 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11420 | } |
| 11421 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11422 | DEFUN (show_ip_bgp_prefix_longer, |
| 11423 | show_ip_bgp_prefix_longer_cmd, |
| 11424 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 11425 | SHOW_STR |
| 11426 | IP_STR |
| 11427 | BGP_STR |
| 11428 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11429 | "Display route and more specific routes\n") |
| 11430 | { |
| 11431 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11432 | bgp_show_type_prefix_longer); |
| 11433 | } |
| 11434 | |
| 11435 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 11436 | show_ip_bgp_flap_prefix_longer_cmd, |
| 11437 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 11438 | SHOW_STR |
| 11439 | IP_STR |
| 11440 | BGP_STR |
| 11441 | "Display flap statistics of routes\n" |
| 11442 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11443 | "Display route and more specific routes\n") |
| 11444 | { |
| 11445 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11446 | bgp_show_type_flap_prefix_longer); |
| 11447 | } |
| 11448 | |
| 11449 | ALIAS (show_ip_bgp_flap_prefix_longer, |
| 11450 | show_ip_bgp_damp_flap_prefix_longer_cmd, |
| 11451 | "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes", |
| 11452 | SHOW_STR |
| 11453 | IP_STR |
| 11454 | BGP_STR |
| 11455 | "Display detailed information about dampening\n" |
| 11456 | "Display flap statistics of routes\n" |
| 11457 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11458 | "Display route and more specific routes\n") |
| 11459 | |
| 11460 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 11461 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 11462 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 11463 | SHOW_STR |
| 11464 | IP_STR |
| 11465 | BGP_STR |
| 11466 | "Address family\n" |
| 11467 | "Address Family modifier\n" |
| 11468 | "Address Family modifier\n" |
| 11469 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11470 | "Display route and more specific routes\n") |
| 11471 | { |
| 11472 | if (strncmp (argv[0], "m", 1) == 0) |
| 11473 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 11474 | bgp_show_type_prefix_longer); |
| 11475 | |
| 11476 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 11477 | bgp_show_type_prefix_longer); |
| 11478 | } |
| 11479 | |
| 11480 | DEFUN (show_ip_bgp_flap_address, |
| 11481 | show_ip_bgp_flap_address_cmd, |
| 11482 | "show ip bgp flap-statistics A.B.C.D", |
| 11483 | SHOW_STR |
| 11484 | IP_STR |
| 11485 | BGP_STR |
| 11486 | "Display flap statistics of routes\n" |
| 11487 | "Network in the BGP routing table to display\n") |
| 11488 | { |
| 11489 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11490 | bgp_show_type_flap_address); |
| 11491 | } |
| 11492 | |
| 11493 | ALIAS (show_ip_bgp_flap_address, |
| 11494 | show_ip_bgp_damp_flap_address_cmd, |
| 11495 | "show ip bgp dampening flap-statistics A.B.C.D", |
| 11496 | SHOW_STR |
| 11497 | IP_STR |
| 11498 | BGP_STR |
| 11499 | "Display detailed information about dampening\n" |
| 11500 | "Display flap statistics of routes\n" |
| 11501 | "Network in the BGP routing table to display\n") |
| 11502 | |
| 11503 | DEFUN (show_ip_bgp_flap_prefix, |
| 11504 | show_ip_bgp_flap_prefix_cmd, |
| 11505 | "show ip bgp flap-statistics A.B.C.D/M", |
| 11506 | SHOW_STR |
| 11507 | IP_STR |
| 11508 | BGP_STR |
| 11509 | "Display flap statistics of routes\n" |
| 11510 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11511 | { |
| 11512 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11513 | bgp_show_type_flap_prefix); |
| 11514 | } |
| 11515 | |
| 11516 | ALIAS (show_ip_bgp_flap_prefix, |
| 11517 | show_ip_bgp_damp_flap_prefix_cmd, |
| 11518 | "show ip bgp dampening flap-statistics A.B.C.D/M", |
| 11519 | SHOW_STR |
| 11520 | IP_STR |
| 11521 | BGP_STR |
| 11522 | "Display detailed information about dampening\n" |
| 11523 | "Display flap statistics of routes\n" |
| 11524 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11525 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11526 | DEFUN (show_bgp_prefix_longer, |
| 11527 | show_bgp_prefix_longer_cmd, |
| 11528 | "show bgp X:X::X:X/M longer-prefixes", |
| 11529 | SHOW_STR |
| 11530 | BGP_STR |
| 11531 | "IPv6 prefix <network>/<length>\n" |
| 11532 | "Display route and more specific routes\n") |
| 11533 | { |
| 11534 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11535 | bgp_show_type_prefix_longer); |
| 11536 | } |
| 11537 | |
| 11538 | /* old command */ |
| 11539 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 11540 | show_ipv6_bgp_prefix_longer_cmd, |
| 11541 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 11542 | SHOW_STR |
| 11543 | IPV6_STR |
| 11544 | BGP_STR |
| 11545 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 11546 | "Display route and more specific routes\n") |
| 11547 | { |
| 11548 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11549 | bgp_show_type_prefix_longer); |
| 11550 | } |
| 11551 | |
| 11552 | /* old command */ |
| 11553 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 11554 | show_ipv6_mbgp_prefix_longer_cmd, |
| 11555 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 11556 | SHOW_STR |
| 11557 | IPV6_STR |
| 11558 | MBGP_STR |
| 11559 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 11560 | "Display route and more specific routes\n") |
| 11561 | { |
| 11562 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 11563 | bgp_show_type_prefix_longer); |
| 11564 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11565 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11566 | DEFUN (show_bgp_ipv4_prefix_longer, |
| 11567 | show_bgp_ipv4_prefix_longer_cmd, |
| 11568 | "show bgp ipv4 A.B.C.D/M longer-prefixes", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11569 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11570 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11571 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11572 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11573 | "Display route and more specific routes\n") |
| 11574 | { |
| 11575 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11576 | bgp_show_type_prefix_longer); |
| 11577 | } |
| 11578 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11579 | DEFUN (show_bgp_ipv4_safi_flap_prefix_longer, |
| 11580 | show_bgp_ipv4_safi_flap_prefix_longer_cmd, |
| 11581 | "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] | 11582 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11583 | BGP_STR |
| 11584 | "Address family\n" |
| 11585 | "Address Family modifier\n" |
| 11586 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11587 | "Address Family modifier\n" |
| 11588 | "Address Family modifier\n" |
| 11589 | "Display flap statistics of routes\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11590 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11591 | "Display route and more specific routes\n") |
| 11592 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11593 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11594 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11595 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11596 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11597 | return CMD_WARNING; |
| 11598 | } |
| 11599 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11600 | bgp_show_type_flap_prefix_longer); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11601 | } |
| 11602 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11603 | ALIAS (show_bgp_ipv4_safi_flap_prefix_longer, |
| 11604 | show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd, |
| 11605 | "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] | 11606 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11607 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11608 | "Address family\n" |
| 11609 | "Address Family modifier\n" |
| 11610 | "Address Family modifier\n" |
| 11611 | "Address Family modifier\n" |
| 11612 | "Address Family modifier\n" |
| 11613 | "Display detailed information about dampening\n" |
| 11614 | "Display flap statistics of routes\n" |
| 11615 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11616 | "Display route and more specific routes\n") |
| 11617 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11618 | DEFUN (show_bgp_ipv6_safi_flap_prefix_longer, |
| 11619 | show_bgp_ipv6_safi_flap_prefix_longer_cmd, |
| 11620 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes", |
| 11621 | SHOW_STR |
| 11622 | BGP_STR |
| 11623 | "Address family\n" |
| 11624 | "Address Family modifier\n" |
| 11625 | "Address Family modifier\n" |
| 11626 | "Address Family modifier\n" |
| 11627 | "Address Family modifier\n" |
| 11628 | "Display flap statistics of routes\n" |
| 11629 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11630 | "Display route and more specific routes\n") |
| 11631 | { |
| 11632 | safi_t safi; |
| 11633 | |
| 11634 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11635 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11636 | return CMD_WARNING; |
| 11637 | } |
| 11638 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi, |
| 11639 | bgp_show_type_flap_prefix_longer); |
| 11640 | } |
| 11641 | ALIAS (show_bgp_ipv6_safi_flap_prefix_longer, |
| 11642 | show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd, |
| 11643 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes", |
| 11644 | SHOW_STR |
| 11645 | BGP_STR |
| 11646 | "Address family\n" |
| 11647 | "Address Family modifier\n" |
| 11648 | "Address Family modifier\n" |
| 11649 | "Address Family modifier\n" |
| 11650 | "Address Family modifier\n" |
| 11651 | "Display detailed information about dampening\n" |
| 11652 | "Display flap statistics of routes\n" |
| 11653 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11654 | "Display route and more specific routes\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11655 | |
| 11656 | DEFUN (show_bgp_ipv4_safi_prefix_longer, |
| 11657 | show_bgp_ipv4_safi_prefix_longer_cmd, |
| 11658 | "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes", |
| 11659 | SHOW_STR |
| 11660 | BGP_STR |
| 11661 | "Address family\n" |
| 11662 | "Address Family modifier\n" |
| 11663 | "Address Family modifier\n" |
| 11664 | "Address Family modifier\n" |
| 11665 | "Address Family modifier\n" |
| 11666 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11667 | "Display route and more specific routes\n") |
| 11668 | { |
| 11669 | safi_t safi; |
| 11670 | |
| 11671 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11672 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11673 | return CMD_WARNING; |
| 11674 | } |
| 11675 | |
| 11676 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11677 | bgp_show_type_prefix_longer); |
| 11678 | } |
| 11679 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11680 | DEFUN (show_bgp_ipv6_safi_prefix_longer, |
| 11681 | show_bgp_ipv6_safi_prefix_longer_cmd, |
| 11682 | "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes", |
| 11683 | SHOW_STR |
| 11684 | BGP_STR |
| 11685 | "Address family\n" |
| 11686 | "Address Family modifier\n" |
| 11687 | "Address Family modifier\n" |
| 11688 | "Address Family modifier\n" |
| 11689 | "Address Family modifier\n" |
| 11690 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11691 | "Display route and more specific routes\n") |
| 11692 | { |
| 11693 | safi_t safi; |
| 11694 | |
| 11695 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11696 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11697 | return CMD_WARNING; |
| 11698 | } |
| 11699 | |
| 11700 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi, |
| 11701 | bgp_show_type_prefix_longer); |
| 11702 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11703 | |
| 11704 | DEFUN (show_bgp_ipv4_safi_flap_address, |
| 11705 | show_bgp_ipv4_safi_flap_address_cmd, |
| 11706 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D", |
| 11707 | SHOW_STR |
| 11708 | BGP_STR |
| 11709 | "Address family\n" |
| 11710 | "Address Family modifier\n" |
| 11711 | "Address Family modifier\n" |
| 11712 | "Address Family modifier\n" |
| 11713 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11714 | "Display flap statistics of routes\n" |
| 11715 | "Network in the BGP routing table to display\n") |
| 11716 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11717 | safi_t safi; |
| 11718 | |
| 11719 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11720 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11721 | return CMD_WARNING; |
| 11722 | } |
| 11723 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11724 | bgp_show_type_flap_address); |
| 11725 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11726 | ALIAS (show_bgp_ipv4_safi_flap_address, |
| 11727 | show_bgp_ipv4_safi_damp_flap_address_cmd, |
| 11728 | "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] | 11729 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11730 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11731 | "Address family\n" |
| 11732 | "Address Family modifier\n" |
| 11733 | "Address Family modifier\n" |
| 11734 | "Address Family modifier\n" |
| 11735 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11736 | "Display detailed information about dampening\n" |
| 11737 | "Display flap statistics of routes\n" |
| 11738 | "Network in the BGP routing table to display\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 11739 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11740 | DEFUN (show_bgp_ipv6_flap_address, |
| 11741 | show_bgp_ipv6_flap_address_cmd, |
| 11742 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11743 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11744 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11745 | "Address family\n" |
| 11746 | "Address Family modifier\n" |
| 11747 | "Address Family modifier\n" |
| 11748 | "Address Family modifier\n" |
| 11749 | "Address Family modifier\n" |
| 11750 | "Display flap statistics of routes\n" |
| 11751 | "Network in the BGP routing table to display\n") |
| 11752 | { |
| 11753 | safi_t safi; |
| 11754 | |
| 11755 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11756 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11757 | return CMD_WARNING; |
| 11758 | } |
| 11759 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11760 | bgp_show_type_flap_address); |
| 11761 | } |
| 11762 | ALIAS (show_bgp_ipv6_flap_address, |
| 11763 | show_bgp_ipv6_damp_flap_address_cmd, |
| 11764 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D", |
| 11765 | SHOW_STR |
| 11766 | BGP_STR |
| 11767 | "Address family\n" |
| 11768 | "Address Family modifier\n" |
| 11769 | "Address Family modifier\n" |
| 11770 | "Address Family modifier\n" |
| 11771 | "Address Family modifier\n" |
| 11772 | "Display detailed information about dampening\n" |
| 11773 | "Display flap statistics of routes\n" |
| 11774 | "Network in the BGP routing table to display\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11775 | |
| 11776 | DEFUN (show_bgp_ipv4_safi_flap_prefix, |
| 11777 | show_bgp_ipv4_safi_flap_prefix_cmd, |
| 11778 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M", |
| 11779 | SHOW_STR |
| 11780 | BGP_STR |
| 11781 | "Address family\n" |
| 11782 | "Address Family modifier\n" |
| 11783 | "Address Family modifier\n" |
| 11784 | "Address Family modifier\n" |
| 11785 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11786 | "Display flap statistics of routes\n" |
| 11787 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11788 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11789 | safi_t safi; |
| 11790 | |
| 11791 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11792 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11793 | return CMD_WARNING; |
| 11794 | } |
| 11795 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11796 | bgp_show_type_flap_prefix); |
| 11797 | } |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11798 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11799 | ALIAS (show_bgp_ipv4_safi_flap_prefix, |
| 11800 | show_bgp_ipv4_safi_damp_flap_prefix_cmd, |
| 11801 | "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] | 11802 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11803 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11804 | "Address family\n" |
| 11805 | "Address Family modifier\n" |
| 11806 | "Address Family modifier\n" |
| 11807 | "Address Family modifier\n" |
| 11808 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11809 | "Display detailed information about dampening\n" |
| 11810 | "Display flap statistics of routes\n" |
| 11811 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11812 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11813 | DEFUN (show_bgp_ipv6_safi_flap_prefix, |
| 11814 | show_bgp_ipv6_safi_flap_prefix_cmd, |
| 11815 | "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] | 11816 | SHOW_STR |
| 11817 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11818 | "Address family\n" |
| 11819 | "Address Family modifier\n" |
| 11820 | "Address Family modifier\n" |
| 11821 | "Address Family modifier\n" |
| 11822 | "Address Family modifier\n" |
| 11823 | "Display flap statistics of routes\n" |
| 11824 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11825 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11826 | safi_t safi; |
| 11827 | |
| 11828 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11829 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11830 | return CMD_WARNING; |
| 11831 | } |
| 11832 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi, |
| 11833 | bgp_show_type_flap_prefix); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11834 | } |
| 11835 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11836 | ALIAS (show_bgp_ipv6_safi_flap_prefix, |
| 11837 | show_bgp_ipv6_safi_damp_flap_prefix_cmd, |
| 11838 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M", |
| 11839 | SHOW_STR |
| 11840 | BGP_STR |
| 11841 | "Address family\n" |
| 11842 | "Address Family modifier\n" |
| 11843 | "Address Family modifier\n" |
| 11844 | "Address Family modifier\n" |
| 11845 | "Address Family modifier\n" |
| 11846 | "Display detailed information about dampening\n" |
| 11847 | "Display flap statistics of routes\n" |
| 11848 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11849 | |
| 11850 | DEFUN (show_bgp_ipv6_prefix_longer, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11851 | show_bgp_ipv6_prefix_longer_cmd, |
| 11852 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 11853 | SHOW_STR |
| 11854 | BGP_STR |
| 11855 | "Address family\n" |
| 11856 | "IPv6 prefix <network>/<length>\n" |
| 11857 | "Display route and more specific routes\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11858 | { |
| 11859 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11860 | bgp_show_type_prefix_longer); |
| 11861 | } |
| 11862 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11863 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11864 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 11865 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11866 | { |
| 11867 | int ret; |
| 11868 | struct bgp *bgp; |
| 11869 | struct peer *peer; |
| 11870 | union sockunion su; |
| 11871 | |
| 11872 | /* BGP structure lookup. */ |
| 11873 | if (view_name) |
| 11874 | { |
| 11875 | bgp = bgp_lookup_by_name (view_name); |
| 11876 | if (! bgp) |
| 11877 | { |
| 11878 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 11879 | return NULL; |
| 11880 | } |
| 11881 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 11882 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11883 | { |
| 11884 | bgp = bgp_get_default (); |
| 11885 | if (! bgp) |
| 11886 | { |
| 11887 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11888 | return NULL; |
| 11889 | } |
| 11890 | } |
| 11891 | |
| 11892 | /* Get peer sockunion. */ |
| 11893 | ret = str2sockunion (ip_str, &su); |
| 11894 | if (ret < 0) |
| 11895 | { |
| 11896 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 11897 | return NULL; |
| 11898 | } |
| 11899 | |
| 11900 | /* Peer structure lookup. */ |
| 11901 | peer = peer_lookup (bgp, &su); |
| 11902 | if (! peer) |
| 11903 | { |
| 11904 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 11905 | return NULL; |
| 11906 | } |
| 11907 | |
| 11908 | return peer; |
| 11909 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11910 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11911 | enum bgp_stats |
| 11912 | { |
| 11913 | BGP_STATS_MAXBITLEN = 0, |
| 11914 | BGP_STATS_RIB, |
| 11915 | BGP_STATS_PREFIXES, |
| 11916 | BGP_STATS_TOTPLEN, |
| 11917 | BGP_STATS_UNAGGREGATEABLE, |
| 11918 | BGP_STATS_MAX_AGGREGATEABLE, |
| 11919 | BGP_STATS_AGGREGATES, |
| 11920 | BGP_STATS_SPACE, |
| 11921 | BGP_STATS_ASPATH_COUNT, |
| 11922 | BGP_STATS_ASPATH_MAXHOPS, |
| 11923 | BGP_STATS_ASPATH_TOTHOPS, |
| 11924 | BGP_STATS_ASPATH_MAXSIZE, |
| 11925 | BGP_STATS_ASPATH_TOTSIZE, |
| 11926 | BGP_STATS_ASN_HIGHEST, |
| 11927 | BGP_STATS_MAX, |
| 11928 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11929 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11930 | static const char *table_stats_strs[] = |
| 11931 | { |
| 11932 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 11933 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 11934 | [BGP_STATS_RIB] = "Total Advertisements", |
| 11935 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 11936 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 11937 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 11938 | [BGP_STATS_SPACE] = "Address space advertised", |
| 11939 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 11940 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 11941 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 11942 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 11943 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 11944 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 11945 | [BGP_STATS_MAX] = NULL, |
| 11946 | }; |
| 11947 | |
| 11948 | struct bgp_table_stats |
| 11949 | { |
| 11950 | struct bgp_table *table; |
| 11951 | unsigned long long counts[BGP_STATS_MAX]; |
| 11952 | }; |
| 11953 | |
| 11954 | #if 0 |
| 11955 | #define TALLY_SIGFIG 100000 |
| 11956 | static unsigned long |
| 11957 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 11958 | { |
| 11959 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 11960 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 11961 | unsigned long ret = newtot / count; |
| 11962 | |
| 11963 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 11964 | return ret + 1; |
| 11965 | else |
| 11966 | return ret; |
| 11967 | } |
| 11968 | #endif |
| 11969 | |
| 11970 | static int |
| 11971 | bgp_table_stats_walker (struct thread *t) |
| 11972 | { |
| 11973 | struct bgp_node *rn; |
| 11974 | struct bgp_node *top; |
| 11975 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 11976 | unsigned int space = 0; |
| 11977 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 11978 | if (!(top = bgp_table_top (ts->table))) |
| 11979 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11980 | |
| 11981 | switch (top->p.family) |
| 11982 | { |
| 11983 | case AF_INET: |
| 11984 | space = IPV4_MAX_BITLEN; |
| 11985 | break; |
| 11986 | case AF_INET6: |
| 11987 | space = IPV6_MAX_BITLEN; |
| 11988 | break; |
| 11989 | } |
| 11990 | |
| 11991 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 11992 | |
| 11993 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 11994 | { |
| 11995 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 11996 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11997 | unsigned int rinum = 0; |
| 11998 | |
| 11999 | if (rn == top) |
| 12000 | continue; |
| 12001 | |
| 12002 | if (!rn->info) |
| 12003 | continue; |
| 12004 | |
| 12005 | ts->counts[BGP_STATS_PREFIXES]++; |
| 12006 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 12007 | |
| 12008 | #if 0 |
| 12009 | ts->counts[BGP_STATS_AVGPLEN] |
| 12010 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 12011 | ts->counts[BGP_STATS_AVGPLEN], |
| 12012 | rn->p.prefixlen); |
| 12013 | #endif |
| 12014 | |
| 12015 | /* check if the prefix is included by any other announcements */ |
| 12016 | while (prn && !prn->info) |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 12017 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12018 | |
| 12019 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 12020 | { |
| 12021 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 12022 | /* announced address space */ |
| 12023 | if (space) |
| 12024 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 12025 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12026 | else if (prn->info) |
| 12027 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 12028 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12029 | for (ri = rn->info; ri; ri = ri->next) |
| 12030 | { |
| 12031 | rinum++; |
| 12032 | ts->counts[BGP_STATS_RIB]++; |
| 12033 | |
| 12034 | if (ri->attr && |
| 12035 | (CHECK_FLAG (ri->attr->flag, |
| 12036 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 12037 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 12038 | |
| 12039 | /* as-path stats */ |
| 12040 | if (ri->attr && ri->attr->aspath) |
| 12041 | { |
| 12042 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 12043 | unsigned int size = aspath_size (ri->attr->aspath); |
| 12044 | as_t highest = aspath_highest (ri->attr->aspath); |
| 12045 | |
| 12046 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 12047 | |
| 12048 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 12049 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 12050 | |
| 12051 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 12052 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 12053 | |
| 12054 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 12055 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 12056 | #if 0 |
| 12057 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 12058 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 12059 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 12060 | hops); |
| 12061 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 12062 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 12063 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 12064 | size); |
| 12065 | #endif |
| 12066 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 12067 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 12068 | } |
| 12069 | } |
| 12070 | } |
| 12071 | return 0; |
| 12072 | } |
| 12073 | |
| 12074 | static int |
| 12075 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 12076 | { |
| 12077 | struct bgp_table_stats ts; |
| 12078 | unsigned int i; |
| 12079 | |
| 12080 | if (!bgp->rib[afi][safi]) |
| 12081 | { |
Donald Sharp | 3c96404 | 2016-01-25 23:38:53 -0500 | [diff] [blame] | 12082 | vty_out (vty, "%% No RIB exists for the specified AFI(%d)/SAFI(%d) %s", |
| 12083 | afi, safi, VTY_NEWLINE); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12084 | return CMD_WARNING; |
| 12085 | } |
| 12086 | |
| 12087 | memset (&ts, 0, sizeof (ts)); |
| 12088 | ts.table = bgp->rib[afi][safi]; |
| 12089 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 12090 | |
| 12091 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 12092 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 12093 | |
| 12094 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 12095 | { |
| 12096 | if (!table_stats_strs[i]) |
| 12097 | continue; |
| 12098 | |
| 12099 | switch (i) |
| 12100 | { |
| 12101 | #if 0 |
| 12102 | case BGP_STATS_ASPATH_AVGHOPS: |
| 12103 | case BGP_STATS_ASPATH_AVGSIZE: |
| 12104 | case BGP_STATS_AVGPLEN: |
| 12105 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12106 | vty_out (vty, "%12.2f", |
| 12107 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 12108 | break; |
| 12109 | #endif |
| 12110 | case BGP_STATS_ASPATH_TOTHOPS: |
| 12111 | case BGP_STATS_ASPATH_TOTSIZE: |
| 12112 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12113 | vty_out (vty, "%12.2f", |
| 12114 | ts.counts[i] ? |
| 12115 | (float)ts.counts[i] / |
| 12116 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 12117 | : 0); |
| 12118 | break; |
| 12119 | case BGP_STATS_TOTPLEN: |
| 12120 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12121 | vty_out (vty, "%12.2f", |
| 12122 | ts.counts[i] ? |
| 12123 | (float)ts.counts[i] / |
| 12124 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 12125 | : 0); |
| 12126 | break; |
| 12127 | case BGP_STATS_SPACE: |
| 12128 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12129 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 12130 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 12131 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 12132 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12133 | vty_out (vty, "%12.2f%s", |
| 12134 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 12135 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12136 | VTY_NEWLINE); |
| 12137 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 12138 | vty_out (vty, "%12.2f%s", |
| 12139 | (float)ts.counts[BGP_STATS_SPACE] / |
| 12140 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 12141 | VTY_NEWLINE); |
| 12142 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 12143 | break; |
| 12144 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 12145 | vty_out (vty, "%12.2f", |
| 12146 | (float)ts.counts[BGP_STATS_SPACE] / |
| 12147 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 12148 | break; |
| 12149 | default: |
| 12150 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12151 | vty_out (vty, "%12llu", ts.counts[i]); |
| 12152 | } |
| 12153 | |
| 12154 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12155 | } |
| 12156 | return CMD_SUCCESS; |
| 12157 | } |
| 12158 | |
| 12159 | static int |
| 12160 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 12161 | const char *afi_str, const char *safi_str) |
| 12162 | { |
| 12163 | struct bgp *bgp; |
| 12164 | afi_t afi; |
| 12165 | safi_t safi; |
| 12166 | |
| 12167 | if (name) |
| 12168 | bgp = bgp_lookup_by_name (name); |
| 12169 | else |
| 12170 | bgp = bgp_get_default (); |
| 12171 | |
| 12172 | if (!bgp) |
| 12173 | { |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 12174 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12175 | return CMD_WARNING; |
| 12176 | } |
| 12177 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 12178 | { |
| 12179 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 12180 | afi = AFI_IP; |
| 12181 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 12182 | afi = AFI_IP6; |
| 12183 | else |
| 12184 | { |
| 12185 | vty_out (vty, "%% Invalid address family %s%s", |
| 12186 | afi_str, VTY_NEWLINE); |
| 12187 | return CMD_WARNING; |
| 12188 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12189 | switch (safi_str[0]) { |
| 12190 | case 'm': |
| 12191 | safi = SAFI_MULTICAST; |
| 12192 | break; |
| 12193 | case 'u': |
| 12194 | safi = SAFI_UNICAST; |
| 12195 | break; |
| 12196 | case 'v': |
Donald Sharp | 3c96404 | 2016-01-25 23:38:53 -0500 | [diff] [blame] | 12197 | safi = SAFI_MPLS_VPN; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12198 | break; |
| 12199 | case 'e': |
| 12200 | safi = SAFI_ENCAP; |
| 12201 | break; |
| 12202 | default: |
| 12203 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12204 | safi_str, VTY_NEWLINE); |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12205 | return CMD_WARNING; |
| 12206 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12207 | } |
| 12208 | else |
| 12209 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12210 | vty_out (vty, "%% Invalid address family \"%s\"%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12211 | afi_str, VTY_NEWLINE); |
| 12212 | return CMD_WARNING; |
| 12213 | } |
| 12214 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12215 | return bgp_table_stats (vty, bgp, afi, safi); |
| 12216 | } |
| 12217 | |
| 12218 | DEFUN (show_bgp_statistics, |
| 12219 | show_bgp_statistics_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12220 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12221 | SHOW_STR |
| 12222 | BGP_STR |
| 12223 | "Address family\n" |
| 12224 | "Address family\n" |
| 12225 | "Address Family modifier\n" |
| 12226 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12227 | "Address Family modifier\n" |
| 12228 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12229 | "BGP RIB advertisement statistics\n") |
| 12230 | { |
| 12231 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 12232 | } |
| 12233 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12234 | ALIAS (show_bgp_statistics, |
| 12235 | show_bgp_statistics_vpnv4_cmd, |
| 12236 | "show bgp (ipv4) (vpnv4) statistics", |
| 12237 | SHOW_STR |
| 12238 | BGP_STR |
| 12239 | "Address family\n" |
| 12240 | "Address Family modifier\n" |
| 12241 | "BGP RIB advertisement statistics\n") |
| 12242 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12243 | DEFUN (show_bgp_statistics_view, |
| 12244 | show_bgp_statistics_view_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12245 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12246 | SHOW_STR |
| 12247 | BGP_STR |
| 12248 | "BGP view\n" |
| 12249 | "Address family\n" |
| 12250 | "Address family\n" |
| 12251 | "Address Family modifier\n" |
| 12252 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12253 | "Address Family modifier\n" |
| 12254 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12255 | "BGP RIB advertisement statistics\n") |
| 12256 | { |
| 12257 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 12258 | } |
| 12259 | |
| 12260 | ALIAS (show_bgp_statistics_view, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12261 | show_bgp_statistics_view_vpnv4_cmd, |
| 12262 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12263 | SHOW_STR |
| 12264 | BGP_STR |
| 12265 | "BGP view\n" |
| 12266 | "Address family\n" |
| 12267 | "Address Family modifier\n" |
| 12268 | "BGP RIB advertisement statistics\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12269 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12270 | enum bgp_pcounts |
| 12271 | { |
| 12272 | PCOUNT_ADJ_IN = 0, |
| 12273 | PCOUNT_DAMPED, |
| 12274 | PCOUNT_REMOVED, |
| 12275 | PCOUNT_HISTORY, |
| 12276 | PCOUNT_STALE, |
| 12277 | PCOUNT_VALID, |
| 12278 | PCOUNT_ALL, |
| 12279 | PCOUNT_COUNTED, |
| 12280 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 12281 | PCOUNT_MAX, |
| 12282 | }; |
| 12283 | |
| 12284 | static const char *pcount_strs[] = |
| 12285 | { |
| 12286 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 12287 | [PCOUNT_DAMPED] = "Damped", |
| 12288 | [PCOUNT_REMOVED] = "Removed", |
| 12289 | [PCOUNT_HISTORY] = "History", |
| 12290 | [PCOUNT_STALE] = "Stale", |
| 12291 | [PCOUNT_VALID] = "Valid", |
| 12292 | [PCOUNT_ALL] = "All RIB", |
| 12293 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 12294 | [PCOUNT_PFCNT] = "Useable", |
| 12295 | [PCOUNT_MAX] = NULL, |
| 12296 | }; |
| 12297 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12298 | struct peer_pcounts |
| 12299 | { |
| 12300 | unsigned int count[PCOUNT_MAX]; |
| 12301 | const struct peer *peer; |
| 12302 | const struct bgp_table *table; |
| 12303 | }; |
| 12304 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12305 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12306 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12307 | { |
| 12308 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12309 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 12310 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12311 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12312 | 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] | 12313 | { |
| 12314 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12315 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12316 | |
| 12317 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 12318 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12319 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12320 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12321 | for (ri = rn->info; ri; ri = ri->next) |
| 12322 | { |
| 12323 | char buf[SU_ADDRSTRLEN]; |
| 12324 | |
| 12325 | if (ri->peer != peer) |
| 12326 | continue; |
| 12327 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12328 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12329 | |
| 12330 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12331 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12332 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12333 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12334 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12335 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12336 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12337 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12338 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12339 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12340 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12341 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12342 | |
| 12343 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 12344 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12345 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12346 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12347 | plog_warn (peer->log, |
| 12348 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 12349 | peer->host, |
| 12350 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 12351 | buf, SU_ADDRSTRLEN), |
| 12352 | rn->p.prefixlen, |
| 12353 | ri->flags); |
| 12354 | } |
| 12355 | else |
| 12356 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12357 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12358 | plog_warn (peer->log, |
| 12359 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 12360 | peer->host, |
| 12361 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 12362 | buf, SU_ADDRSTRLEN), |
| 12363 | rn->p.prefixlen, |
| 12364 | ri->flags); |
| 12365 | } |
| 12366 | } |
| 12367 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12368 | return 0; |
| 12369 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12370 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12371 | static int |
| 12372 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 12373 | { |
| 12374 | struct peer_pcounts pcounts = { .peer = peer }; |
| 12375 | unsigned int i; |
| 12376 | |
| 12377 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 12378 | || !peer->bgp->rib[afi][safi]) |
| 12379 | { |
| 12380 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 12381 | return CMD_WARNING; |
| 12382 | } |
| 12383 | |
| 12384 | memset (&pcounts, 0, sizeof(pcounts)); |
| 12385 | pcounts.peer = peer; |
| 12386 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 12387 | |
| 12388 | /* in-place call via thread subsystem so as to record execution time |
| 12389 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 12390 | * on just vty_read()). |
| 12391 | */ |
| 12392 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 12393 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12394 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 12395 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 12396 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 12397 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 12398 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 12399 | |
| 12400 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12401 | vty_out (vty, "%20s: %-10d%s", |
| 12402 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12403 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12404 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12405 | { |
| 12406 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 12407 | peer->host, VTY_NEWLINE); |
| 12408 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 12409 | VTY_NEWLINE); |
| 12410 | } |
| 12411 | |
| 12412 | return CMD_SUCCESS; |
| 12413 | } |
| 12414 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12415 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 12416 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 12417 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12418 | SHOW_STR |
| 12419 | IP_STR |
| 12420 | BGP_STR |
| 12421 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12422 | "Neighbor to display information about\n" |
| 12423 | "Neighbor to display information about\n" |
| 12424 | "Display detailed prefix count information\n") |
| 12425 | { |
| 12426 | struct peer *peer; |
| 12427 | |
| 12428 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12429 | if (! peer) |
| 12430 | return CMD_WARNING; |
| 12431 | |
| 12432 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 12433 | } |
| 12434 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12435 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 12436 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 12437 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12438 | SHOW_STR |
| 12439 | BGP_STR |
| 12440 | "Address family\n" |
| 12441 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12442 | "Neighbor to display information about\n" |
| 12443 | "Neighbor to display information about\n" |
| 12444 | "Display detailed prefix count information\n") |
| 12445 | { |
| 12446 | struct peer *peer; |
| 12447 | |
| 12448 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12449 | if (! peer) |
| 12450 | return CMD_WARNING; |
| 12451 | |
| 12452 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 12453 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12454 | |
| 12455 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 12456 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 12457 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12458 | SHOW_STR |
| 12459 | IP_STR |
| 12460 | BGP_STR |
| 12461 | "Address family\n" |
| 12462 | "Address Family modifier\n" |
| 12463 | "Address Family modifier\n" |
| 12464 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12465 | "Neighbor to display information about\n" |
| 12466 | "Neighbor to display information about\n" |
| 12467 | "Display detailed prefix count information\n") |
| 12468 | { |
| 12469 | struct peer *peer; |
| 12470 | |
| 12471 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12472 | if (! peer) |
| 12473 | return CMD_WARNING; |
| 12474 | |
| 12475 | if (strncmp (argv[0], "m", 1) == 0) |
| 12476 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 12477 | |
| 12478 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 12479 | } |
| 12480 | |
| 12481 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 12482 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 12483 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12484 | SHOW_STR |
| 12485 | IP_STR |
| 12486 | BGP_STR |
| 12487 | "Address family\n" |
| 12488 | "Address Family modifier\n" |
| 12489 | "Address Family modifier\n" |
| 12490 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12491 | "Neighbor to display information about\n" |
| 12492 | "Neighbor to display information about\n" |
| 12493 | "Display detailed prefix count information\n") |
| 12494 | { |
| 12495 | struct peer *peer; |
| 12496 | |
| 12497 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12498 | if (! peer) |
| 12499 | return CMD_WARNING; |
| 12500 | |
| 12501 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 12502 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12503 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12504 | DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts, |
| 12505 | show_bgp_ipv4_safi_neighbor_prefix_counts_cmd, |
| 12506 | "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] | 12507 | SHOW_STR |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12508 | BGP_STR |
| 12509 | "Address family\n" |
| 12510 | "Address Family modifier\n" |
| 12511 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12512 | "Address Family modifier\n" |
| 12513 | "Address Family modifier\n" |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12514 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12515 | "Neighbor to display information about\n" |
| 12516 | "Neighbor to display information about\n" |
| 12517 | "Display detailed prefix count information\n") |
| 12518 | { |
| 12519 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12520 | safi_t safi; |
| 12521 | |
| 12522 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12523 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12524 | return CMD_WARNING; |
| 12525 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12526 | |
| 12527 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12528 | if (! peer) |
| 12529 | return CMD_WARNING; |
| 12530 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12531 | return bgp_peer_counts (vty, peer, AFI_IP, safi); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12532 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 12533 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12534 | DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts, |
| 12535 | show_bgp_ipv6_safi_neighbor_prefix_counts_cmd, |
| 12536 | "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12537 | SHOW_STR |
| 12538 | BGP_STR |
| 12539 | "Address family\n" |
| 12540 | "Address Family modifier\n" |
| 12541 | "Address Family modifier\n" |
| 12542 | "Address Family modifier\n" |
| 12543 | "Address Family modifier\n" |
| 12544 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12545 | "Neighbor to display information about\n" |
| 12546 | "Neighbor to display information about\n" |
| 12547 | "Display detailed prefix count information\n") |
| 12548 | { |
| 12549 | struct peer *peer; |
| 12550 | safi_t safi; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12551 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12552 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12553 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12554 | return CMD_WARNING; |
| 12555 | } |
| 12556 | |
| 12557 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12558 | if (! peer) |
| 12559 | return CMD_WARNING; |
| 12560 | |
| 12561 | return bgp_peer_counts (vty, peer, AFI_IP6, safi); |
| 12562 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12563 | |
| 12564 | DEFUN (show_ip_bgp_encap_neighbor_prefix_counts, |
| 12565 | show_ip_bgp_encap_neighbor_prefix_counts_cmd, |
| 12566 | "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] | 12567 | SHOW_STR |
| 12568 | IP_STR |
| 12569 | BGP_STR |
| 12570 | "Address family\n" |
| 12571 | "Address Family modifier\n" |
| 12572 | "Address Family modifier\n" |
| 12573 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12574 | "Neighbor to display information about\n" |
| 12575 | "Neighbor to display information about\n" |
| 12576 | "Display detailed prefix count information\n") |
| 12577 | { |
| 12578 | struct peer *peer; |
| 12579 | |
| 12580 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12581 | if (! peer) |
| 12582 | return CMD_WARNING; |
| 12583 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12584 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12585 | } |
| 12586 | |
| 12587 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12588 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12589 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 12590 | int in) |
| 12591 | { |
| 12592 | struct bgp_table *table; |
| 12593 | struct bgp_adj_in *ain; |
| 12594 | struct bgp_adj_out *adj; |
| 12595 | unsigned long output_count; |
| 12596 | struct bgp_node *rn; |
| 12597 | int header1 = 1; |
| 12598 | struct bgp *bgp; |
| 12599 | int header2 = 1; |
| 12600 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12601 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12602 | |
| 12603 | if (! bgp) |
| 12604 | return; |
| 12605 | |
| 12606 | table = bgp->rib[afi][safi]; |
| 12607 | |
| 12608 | output_count = 0; |
| 12609 | |
| 12610 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 12611 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 12612 | { |
| 12613 | 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] | 12614 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12615 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12616 | |
| 12617 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 12618 | VTY_NEWLINE, VTY_NEWLINE); |
| 12619 | header1 = 0; |
| 12620 | } |
| 12621 | |
| 12622 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12623 | if (in) |
| 12624 | { |
| 12625 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 12626 | if (ain->peer == peer) |
| 12627 | { |
| 12628 | if (header1) |
| 12629 | { |
| 12630 | 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] | 12631 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12632 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12633 | header1 = 0; |
| 12634 | } |
| 12635 | if (header2) |
| 12636 | { |
| 12637 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 12638 | header2 = 0; |
| 12639 | } |
| 12640 | if (ain->attr) |
| 12641 | { |
| 12642 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 12643 | output_count++; |
| 12644 | } |
| 12645 | } |
| 12646 | } |
| 12647 | else |
| 12648 | { |
| 12649 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 12650 | if (adj->peer == peer) |
| 12651 | { |
| 12652 | if (header1) |
| 12653 | { |
| 12654 | 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] | 12655 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12656 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12657 | header1 = 0; |
| 12658 | } |
| 12659 | if (header2) |
| 12660 | { |
| 12661 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 12662 | header2 = 0; |
| 12663 | } |
| 12664 | if (adj->attr) |
| 12665 | { |
| 12666 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 12667 | output_count++; |
| 12668 | } |
| 12669 | } |
| 12670 | } |
| 12671 | |
| 12672 | if (output_count != 0) |
| 12673 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 12674 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 12675 | } |
| 12676 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12677 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12678 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 12679 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12680 | if (! peer || ! peer->afc[afi][safi]) |
| 12681 | { |
| 12682 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 12683 | return CMD_WARNING; |
| 12684 | } |
| 12685 | |
| 12686 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 12687 | { |
| 12688 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 12689 | VTY_NEWLINE); |
| 12690 | return CMD_WARNING; |
| 12691 | } |
| 12692 | |
| 12693 | show_adj_route (vty, peer, afi, safi, in); |
| 12694 | |
| 12695 | return CMD_SUCCESS; |
| 12696 | } |
| 12697 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12698 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 12699 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 12700 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12701 | SHOW_STR |
| 12702 | IP_STR |
| 12703 | BGP_STR |
| 12704 | "BGP view\n" |
| 12705 | "View name\n" |
| 12706 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12707 | "Neighbor to display information about\n" |
| 12708 | "Neighbor to display information about\n" |
| 12709 | "Display the routes advertised to a BGP neighbor\n") |
| 12710 | { |
| 12711 | struct peer *peer; |
| 12712 | |
| 12713 | if (argc == 2) |
| 12714 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12715 | else |
| 12716 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12717 | |
| 12718 | if (! peer) |
| 12719 | return CMD_WARNING; |
| 12720 | |
| 12721 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 12722 | } |
| 12723 | |
| 12724 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
| 12725 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 12726 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12727 | SHOW_STR |
| 12728 | IP_STR |
| 12729 | BGP_STR |
| 12730 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12731 | "Neighbor to display information about\n" |
| 12732 | "Neighbor to display information about\n" |
| 12733 | "Display the routes advertised to a BGP neighbor\n") |
| 12734 | |
| 12735 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 12736 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 12737 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12738 | SHOW_STR |
| 12739 | IP_STR |
| 12740 | BGP_STR |
| 12741 | "Address family\n" |
| 12742 | "Address Family modifier\n" |
| 12743 | "Address Family modifier\n" |
| 12744 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12745 | "Neighbor to display information about\n" |
| 12746 | "Neighbor to display information about\n" |
| 12747 | "Display the routes advertised to a BGP neighbor\n") |
| 12748 | { |
| 12749 | struct peer *peer; |
| 12750 | |
| 12751 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12752 | if (! peer) |
| 12753 | return CMD_WARNING; |
| 12754 | |
| 12755 | if (strncmp (argv[0], "m", 1) == 0) |
| 12756 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 12757 | |
| 12758 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 12759 | } |
| 12760 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12761 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 12762 | show_bgp_view_neighbor_advertised_route_cmd, |
| 12763 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12764 | SHOW_STR |
| 12765 | BGP_STR |
| 12766 | "BGP view\n" |
| 12767 | "View name\n" |
| 12768 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12769 | "Neighbor to display information about\n" |
| 12770 | "Neighbor to display information about\n" |
| 12771 | "Display the routes advertised to a BGP neighbor\n") |
| 12772 | { |
| 12773 | struct peer *peer; |
| 12774 | |
| 12775 | if (argc == 2) |
| 12776 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12777 | else |
| 12778 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12779 | |
| 12780 | if (! peer) |
| 12781 | return CMD_WARNING; |
| 12782 | |
| 12783 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 12784 | } |
| 12785 | |
| 12786 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 12787 | show_bgp_view_neighbor_received_routes_cmd, |
| 12788 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12789 | SHOW_STR |
| 12790 | BGP_STR |
| 12791 | "BGP view\n" |
| 12792 | "View name\n" |
| 12793 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12794 | "Neighbor to display information about\n" |
| 12795 | "Neighbor to display information about\n" |
| 12796 | "Display the received routes from neighbor\n") |
| 12797 | { |
| 12798 | struct peer *peer; |
| 12799 | |
| 12800 | if (argc == 2) |
| 12801 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12802 | else |
| 12803 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12804 | |
| 12805 | if (! peer) |
| 12806 | return CMD_WARNING; |
| 12807 | |
| 12808 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 12809 | } |
| 12810 | |
| 12811 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12812 | show_bgp_neighbor_advertised_route_cmd, |
| 12813 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12814 | SHOW_STR |
| 12815 | BGP_STR |
| 12816 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12817 | "Neighbor to display information about\n" |
| 12818 | "Neighbor to display information about\n" |
| 12819 | "Display the routes advertised to a BGP neighbor\n") |
| 12820 | |
| 12821 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12822 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 12823 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12824 | SHOW_STR |
| 12825 | BGP_STR |
| 12826 | "Address family\n" |
| 12827 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12828 | "Neighbor to display information about\n" |
| 12829 | "Neighbor to display information about\n" |
| 12830 | "Display the routes advertised to a BGP neighbor\n") |
| 12831 | |
| 12832 | /* old command */ |
| 12833 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12834 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 12835 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12836 | SHOW_STR |
| 12837 | IPV6_STR |
| 12838 | BGP_STR |
| 12839 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12840 | "Neighbor to display information about\n" |
| 12841 | "Neighbor to display information about\n" |
| 12842 | "Display the routes advertised to a BGP neighbor\n") |
| 12843 | |
| 12844 | /* old command */ |
| 12845 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 12846 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 12847 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12848 | SHOW_STR |
| 12849 | IPV6_STR |
| 12850 | MBGP_STR |
| 12851 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12852 | "Neighbor to display information about\n" |
| 12853 | "Neighbor to display information about\n" |
| 12854 | "Display the routes advertised to a BGP neighbor\n") |
| 12855 | { |
| 12856 | struct peer *peer; |
| 12857 | |
| 12858 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12859 | if (! peer) |
| 12860 | return CMD_WARNING; |
| 12861 | |
| 12862 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
| 12863 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12864 | |
| 12865 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 12866 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 12867 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12868 | SHOW_STR |
| 12869 | IP_STR |
| 12870 | BGP_STR |
| 12871 | "BGP view\n" |
| 12872 | "View name\n" |
| 12873 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12874 | "Neighbor to display information about\n" |
| 12875 | "Neighbor to display information about\n" |
| 12876 | "Display the received routes from neighbor\n") |
| 12877 | { |
| 12878 | struct peer *peer; |
| 12879 | |
| 12880 | if (argc == 2) |
| 12881 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12882 | else |
| 12883 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12884 | |
| 12885 | if (! peer) |
| 12886 | return CMD_WARNING; |
| 12887 | |
| 12888 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 12889 | } |
| 12890 | |
| 12891 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
| 12892 | show_ip_bgp_neighbor_received_routes_cmd, |
| 12893 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12894 | SHOW_STR |
| 12895 | IP_STR |
| 12896 | BGP_STR |
| 12897 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12898 | "Neighbor to display information about\n" |
| 12899 | "Neighbor to display information about\n" |
| 12900 | "Display the received routes from neighbor\n") |
| 12901 | |
| 12902 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 12903 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 12904 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12905 | SHOW_STR |
| 12906 | BGP_STR |
| 12907 | "Address family\n" |
| 12908 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12909 | "Neighbor to display information about\n" |
| 12910 | "Neighbor to display information about\n" |
| 12911 | "Display the received routes from neighbor\n") |
| 12912 | |
| 12913 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 12914 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 12915 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12916 | SHOW_STR |
| 12917 | BGP_STR |
| 12918 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12919 | "Neighbor to display information about\n" |
| 12920 | "Neighbor to display information about\n" |
| 12921 | "Display information received from a BGP neighbor\n" |
| 12922 | "Display the prefixlist filter\n") |
| 12923 | { |
| 12924 | char name[BUFSIZ]; |
| 12925 | union sockunion su; |
| 12926 | struct peer *peer; |
| 12927 | int count, ret; |
| 12928 | |
| 12929 | ret = str2sockunion (argv[0], &su); |
| 12930 | if (ret < 0) |
| 12931 | { |
| 12932 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 12933 | return CMD_WARNING; |
| 12934 | } |
| 12935 | |
| 12936 | peer = peer_lookup (NULL, &su); |
| 12937 | if (! peer) |
| 12938 | return CMD_WARNING; |
| 12939 | |
| 12940 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 12941 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 12942 | if (count) |
| 12943 | { |
| 12944 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 12945 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 12946 | } |
| 12947 | |
| 12948 | return CMD_SUCCESS; |
| 12949 | } |
| 12950 | |
| 12951 | /* old command */ |
| 12952 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 12953 | ipv6_bgp_neighbor_received_routes_cmd, |
| 12954 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12955 | SHOW_STR |
| 12956 | IPV6_STR |
| 12957 | BGP_STR |
| 12958 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12959 | "Neighbor to display information about\n" |
| 12960 | "Neighbor to display information about\n" |
| 12961 | "Display the received routes from neighbor\n") |
| 12962 | |
| 12963 | /* old command */ |
| 12964 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 12965 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 12966 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12967 | SHOW_STR |
| 12968 | IPV6_STR |
| 12969 | MBGP_STR |
| 12970 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12971 | "Neighbor to display information about\n" |
| 12972 | "Neighbor to display information about\n" |
| 12973 | "Display the received routes from neighbor\n") |
| 12974 | { |
| 12975 | struct peer *peer; |
| 12976 | |
| 12977 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12978 | if (! peer) |
| 12979 | return CMD_WARNING; |
| 12980 | |
| 12981 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
| 12982 | } |
| 12983 | |
| 12984 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 12985 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 12986 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12987 | SHOW_STR |
| 12988 | BGP_STR |
| 12989 | "BGP view\n" |
| 12990 | "View name\n" |
| 12991 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12992 | "Neighbor to display information about\n" |
| 12993 | "Neighbor to display information about\n" |
| 12994 | "Display information received from a BGP neighbor\n" |
| 12995 | "Display the prefixlist filter\n") |
| 12996 | { |
| 12997 | char name[BUFSIZ]; |
| 12998 | union sockunion su; |
| 12999 | struct peer *peer; |
| 13000 | struct bgp *bgp; |
| 13001 | int count, ret; |
| 13002 | |
| 13003 | /* BGP structure lookup. */ |
| 13004 | bgp = bgp_lookup_by_name (argv[0]); |
| 13005 | if (bgp == NULL) |
| 13006 | { |
| 13007 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13008 | return CMD_WARNING; |
| 13009 | } |
| 13010 | |
| 13011 | ret = str2sockunion (argv[1], &su); |
| 13012 | if (ret < 0) |
| 13013 | { |
| 13014 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13015 | return CMD_WARNING; |
| 13016 | } |
| 13017 | |
| 13018 | peer = peer_lookup (bgp, &su); |
| 13019 | if (! peer) |
| 13020 | return CMD_WARNING; |
| 13021 | |
| 13022 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 13023 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13024 | if (count) |
| 13025 | { |
| 13026 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 13027 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13028 | } |
| 13029 | |
| 13030 | return CMD_SUCCESS; |
| 13031 | } |
| 13032 | |
| 13033 | |
| 13034 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 13035 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 13036 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 13037 | SHOW_STR |
| 13038 | IP_STR |
| 13039 | BGP_STR |
| 13040 | "Address family\n" |
| 13041 | "Address Family modifier\n" |
| 13042 | "Address Family modifier\n" |
| 13043 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13044 | "Neighbor to display information about\n" |
| 13045 | "Neighbor to display information about\n" |
| 13046 | "Display the received routes from neighbor\n") |
| 13047 | { |
| 13048 | struct peer *peer; |
| 13049 | |
| 13050 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13051 | if (! peer) |
| 13052 | return CMD_WARNING; |
| 13053 | |
| 13054 | if (strncmp (argv[0], "m", 1) == 0) |
| 13055 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 13056 | |
| 13057 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 13058 | } |
| 13059 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13060 | DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route, |
| 13061 | show_bgp_ipv4_safi_neighbor_advertised_route_cmd, |
| 13062 | "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] | 13063 | SHOW_STR |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13064 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13065 | "Address Family modifier\n" |
| 13066 | "Address Family modifier\n" |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13067 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13068 | "Neighbor to display information about\n" |
| 13069 | "Neighbor to display information about\n" |
| 13070 | "Display the routes advertised to a BGP neighbor\n") |
| 13071 | { |
| 13072 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13073 | safi_t safi; |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13074 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13075 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13076 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13077 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13078 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13079 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13080 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13081 | if (! peer) |
| 13082 | return CMD_WARNING; |
| 13083 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13084 | return peer_adj_routes (vty, peer, AFI_IP, safi, 0); |
| 13085 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13086 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13087 | DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route, |
| 13088 | show_bgp_ipv6_safi_neighbor_advertised_route_cmd, |
| 13089 | "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 13090 | SHOW_STR |
| 13091 | BGP_STR |
| 13092 | "Address Family modifier\n" |
| 13093 | "Address Family modifier\n" |
| 13094 | "Address Family modifier\n" |
| 13095 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13096 | "Neighbor to display information about\n" |
| 13097 | "Neighbor to display information about\n" |
| 13098 | "Display the routes advertised to a BGP neighbor\n") |
| 13099 | { |
| 13100 | struct peer *peer; |
| 13101 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13102 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13103 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13104 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13105 | return CMD_WARNING; |
| 13106 | } |
| 13107 | |
| 13108 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13109 | if (! peer) |
| 13110 | return CMD_WARNING; |
| 13111 | |
| 13112 | return peer_adj_routes (vty, peer, AFI_IP6, safi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13113 | } |
| 13114 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13115 | DEFUN (show_bgp_view_ipv6_neighbor_advertised_route, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13116 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 13117 | "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] | 13118 | SHOW_STR |
| 13119 | BGP_STR |
| 13120 | "BGP view\n" |
| 13121 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13122 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13123 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13124 | "Neighbor to display information about\n" |
| 13125 | "Neighbor to display information about\n" |
| 13126 | "Display the routes advertised to a BGP neighbor\n") |
| 13127 | { |
| 13128 | struct peer *peer; |
| 13129 | |
| 13130 | if (argc == 2) |
| 13131 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13132 | else |
| 13133 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13134 | |
| 13135 | if (! peer) |
| 13136 | return CMD_WARNING; |
| 13137 | |
| 13138 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 13139 | } |
| 13140 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13141 | DEFUN (show_bgp_view_ipv6_neighbor_received_routes, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13142 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 13143 | "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] | 13144 | SHOW_STR |
| 13145 | BGP_STR |
| 13146 | "BGP view\n" |
| 13147 | "View name\n" |
| 13148 | "Address family\n" |
| 13149 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13150 | "Neighbor to display information about\n" |
| 13151 | "Neighbor to display information about\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13152 | "Display the received routes from neighbor\n") |
| 13153 | { |
| 13154 | struct peer *peer; |
| 13155 | |
| 13156 | if (argc == 2) |
| 13157 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13158 | else |
| 13159 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13160 | |
| 13161 | if (! peer) |
| 13162 | return CMD_WARNING; |
| 13163 | |
| 13164 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 13165 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13166 | |
| 13167 | DEFUN (show_bgp_ipv4_safi_neighbor_received_routes, |
| 13168 | show_bgp_ipv4_safi_neighbor_received_routes_cmd, |
| 13169 | "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] | 13170 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13171 | BGP_STR |
| 13172 | "Address family\n" |
| 13173 | "Address Family modifier\n" |
| 13174 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13175 | "Address Family modifier\n" |
| 13176 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13177 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13178 | "Neighbor to display information about\n" |
| 13179 | "Neighbor to display information about\n" |
| 13180 | "Display the received routes from neighbor\n") |
| 13181 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13182 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13183 | safi_t safi; |
| 13184 | |
| 13185 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13186 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13187 | return CMD_WARNING; |
| 13188 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13189 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13190 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13191 | if (! peer) |
| 13192 | return CMD_WARNING; |
| 13193 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13194 | return peer_adj_routes (vty, peer, AFI_IP, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13195 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13196 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13197 | DEFUN (show_bgp_ipv6_safi_neighbor_received_routes, |
| 13198 | show_bgp_ipv6_safi_neighbor_received_routes_cmd, |
| 13199 | "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 13200 | SHOW_STR |
| 13201 | BGP_STR |
| 13202 | "Address family\n" |
| 13203 | "Address Family modifier\n" |
| 13204 | "Address Family modifier\n" |
| 13205 | "Address Family modifier\n" |
| 13206 | "Address Family modifier\n" |
| 13207 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13208 | "Neighbor to display information about\n" |
| 13209 | "Neighbor to display information about\n" |
| 13210 | "Display the received routes from neighbor\n") |
| 13211 | { |
| 13212 | struct peer *peer; |
| 13213 | safi_t safi; |
| 13214 | |
| 13215 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13216 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13217 | return CMD_WARNING; |
| 13218 | } |
| 13219 | |
| 13220 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13221 | if (! peer) |
| 13222 | return CMD_WARNING; |
| 13223 | |
| 13224 | return peer_adj_routes (vty, peer, AFI_IP6, safi, 1); |
| 13225 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13226 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13227 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 13228 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13229 | "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] | 13230 | SHOW_STR |
| 13231 | BGP_STR |
| 13232 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 13233 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13234 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13235 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13236 | "Address family modifier\n" |
| 13237 | "Address family modifier\n" |
| 13238 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13239 | "Neighbor to display information about\n" |
| 13240 | "Neighbor to display information about\n" |
| 13241 | "Display the advertised routes to neighbor\n" |
| 13242 | "Display the received routes from neighbor\n") |
| 13243 | { |
| 13244 | int afi; |
| 13245 | int safi; |
| 13246 | int in; |
| 13247 | struct peer *peer; |
| 13248 | |
David Lamparter | 94bad67 | 2015-03-03 08:52:22 +0100 | [diff] [blame] | 13249 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13250 | |
| 13251 | if (! peer) |
| 13252 | return CMD_WARNING; |
| 13253 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13254 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 13255 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13256 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13257 | |
| 13258 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 13259 | } |
| 13260 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13261 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 13262 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 13263 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 13264 | SHOW_STR |
| 13265 | IP_STR |
| 13266 | BGP_STR |
| 13267 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13268 | "Neighbor to display information about\n" |
| 13269 | "Neighbor to display information about\n" |
| 13270 | "Display information received from a BGP neighbor\n" |
| 13271 | "Display the prefixlist filter\n") |
| 13272 | { |
| 13273 | char name[BUFSIZ]; |
| 13274 | union sockunion su; |
| 13275 | struct peer *peer; |
| 13276 | int count, ret; |
| 13277 | |
| 13278 | ret = str2sockunion (argv[0], &su); |
| 13279 | if (ret < 0) |
| 13280 | { |
| 13281 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 13282 | return CMD_WARNING; |
| 13283 | } |
| 13284 | |
| 13285 | peer = peer_lookup (NULL, &su); |
| 13286 | if (! peer) |
| 13287 | return CMD_WARNING; |
| 13288 | |
| 13289 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 13290 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13291 | if (count) |
| 13292 | { |
| 13293 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 13294 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13295 | } |
| 13296 | |
| 13297 | return CMD_SUCCESS; |
| 13298 | } |
| 13299 | |
| 13300 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 13301 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 13302 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 13303 | SHOW_STR |
| 13304 | IP_STR |
| 13305 | BGP_STR |
| 13306 | "Address family\n" |
| 13307 | "Address Family modifier\n" |
| 13308 | "Address Family modifier\n" |
| 13309 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13310 | "Neighbor to display information about\n" |
| 13311 | "Neighbor to display information about\n" |
| 13312 | "Display information received from a BGP neighbor\n" |
| 13313 | "Display the prefixlist filter\n") |
| 13314 | { |
| 13315 | char name[BUFSIZ]; |
| 13316 | union sockunion su; |
| 13317 | struct peer *peer; |
| 13318 | int count, ret; |
| 13319 | |
| 13320 | ret = str2sockunion (argv[1], &su); |
| 13321 | if (ret < 0) |
| 13322 | { |
| 13323 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13324 | return CMD_WARNING; |
| 13325 | } |
| 13326 | |
| 13327 | peer = peer_lookup (NULL, &su); |
| 13328 | if (! peer) |
| 13329 | return CMD_WARNING; |
| 13330 | |
| 13331 | if (strncmp (argv[0], "m", 1) == 0) |
| 13332 | { |
| 13333 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 13334 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13335 | if (count) |
| 13336 | { |
| 13337 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 13338 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13339 | } |
| 13340 | } |
| 13341 | else |
| 13342 | { |
| 13343 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 13344 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13345 | if (count) |
| 13346 | { |
| 13347 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 13348 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13349 | } |
| 13350 | } |
| 13351 | |
| 13352 | return CMD_SUCCESS; |
| 13353 | } |
| 13354 | |
| 13355 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 13356 | show_bgp_neighbor_received_routes_cmd, |
| 13357 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 13358 | SHOW_STR |
| 13359 | BGP_STR |
| 13360 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13361 | "Neighbor to display information about\n" |
| 13362 | "Neighbor to display information about\n" |
| 13363 | "Display the received routes from neighbor\n") |
| 13364 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13365 | DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter, |
| 13366 | show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd, |
| 13367 | "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] | 13368 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13369 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13370 | IP_STR |
| 13371 | "Address Family modifier\n" |
| 13372 | "Address Family modifier\n" |
| 13373 | "Address Family modifier\n" |
| 13374 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13375 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13376 | "Neighbor to display information about\n" |
| 13377 | "Neighbor to display information about\n" |
| 13378 | "Display information received from a BGP neighbor\n" |
| 13379 | "Display the prefixlist filter\n") |
| 13380 | { |
| 13381 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13382 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13383 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13384 | int count, ret; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13385 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13386 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13387 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13388 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13389 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13390 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13391 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13392 | ret = str2sockunion (argv[1], &su); |
| 13393 | if (ret < 0) |
| 13394 | { |
| 13395 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13396 | return CMD_WARNING; |
| 13397 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13398 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13399 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13400 | if (! peer) |
| 13401 | return CMD_WARNING; |
| 13402 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13403 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi); |
| 13404 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13405 | if (count) { |
| 13406 | vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE); |
| 13407 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13408 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13409 | |
| 13410 | return CMD_SUCCESS; |
| 13411 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13412 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13413 | DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter, |
| 13414 | show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd, |
| 13415 | "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] | 13416 | SHOW_STR |
| 13417 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13418 | IP_STR |
| 13419 | "Address Family modifier\n" |
| 13420 | "Address Family modifier\n" |
| 13421 | "Address Family modifier\n" |
| 13422 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13423 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13424 | "Neighbor to display information about\n" |
| 13425 | "Neighbor to display information about\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13426 | "Display information received from a BGP neighbor\n" |
| 13427 | "Display the prefixlist filter\n") |
| 13428 | { |
| 13429 | char name[BUFSIZ]; |
| 13430 | union sockunion su; |
| 13431 | struct peer *peer; |
| 13432 | int count, ret; |
| 13433 | safi_t safi; |
| 13434 | |
| 13435 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13436 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13437 | return CMD_WARNING; |
| 13438 | } |
| 13439 | |
| 13440 | ret = str2sockunion (argv[1], &su); |
| 13441 | if (ret < 0) |
| 13442 | { |
| 13443 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13444 | return CMD_WARNING; |
| 13445 | } |
| 13446 | |
| 13447 | peer = peer_lookup (NULL, &su); |
| 13448 | if (! peer) |
| 13449 | return CMD_WARNING; |
| 13450 | |
| 13451 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi); |
| 13452 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13453 | if (count) { |
| 13454 | vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE); |
| 13455 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13456 | } |
| 13457 | |
| 13458 | return CMD_SUCCESS; |
| 13459 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13460 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13461 | DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13462 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 13463 | "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] | 13464 | SHOW_STR |
| 13465 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13466 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13467 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13468 | "Neighbor to display information about\n" |
| 13469 | "Neighbor to display information about\n" |
| 13470 | "Display information received from a BGP neighbor\n" |
| 13471 | "Display the prefixlist filter\n") |
| 13472 | { |
| 13473 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13474 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13475 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13476 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13477 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13478 | ret = str2sockunion (argv[0], &su); |
| 13479 | if (ret < 0) |
| 13480 | { |
| 13481 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 13482 | return CMD_WARNING; |
| 13483 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13484 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13485 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13486 | if (! peer) |
| 13487 | return CMD_WARNING; |
| 13488 | |
| 13489 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 13490 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13491 | if (count) |
| 13492 | { |
| 13493 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 13494 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13495 | } |
| 13496 | |
| 13497 | return CMD_SUCCESS; |
| 13498 | } |
| 13499 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13500 | DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13501 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 13502 | "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] | 13503 | SHOW_STR |
| 13504 | BGP_STR |
| 13505 | "BGP view\n" |
| 13506 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13507 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13508 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13509 | "Neighbor to display information about\n" |
| 13510 | "Neighbor to display information about\n" |
| 13511 | "Display information received from a BGP neighbor\n" |
| 13512 | "Display the prefixlist filter\n") |
| 13513 | { |
| 13514 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13515 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13516 | struct peer *peer; |
| 13517 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13518 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13519 | |
| 13520 | /* BGP structure lookup. */ |
| 13521 | bgp = bgp_lookup_by_name (argv[0]); |
| 13522 | if (bgp == NULL) |
| 13523 | { |
| 13524 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13525 | return CMD_WARNING; |
| 13526 | } |
| 13527 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13528 | ret = str2sockunion (argv[1], &su); |
| 13529 | if (ret < 0) |
| 13530 | { |
| 13531 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13532 | return CMD_WARNING; |
| 13533 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13534 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13535 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13536 | if (! peer) |
| 13537 | return CMD_WARNING; |
| 13538 | |
| 13539 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 13540 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13541 | if (count) |
| 13542 | { |
| 13543 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 13544 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13545 | } |
| 13546 | |
| 13547 | return CMD_SUCCESS; |
| 13548 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 13549 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 13550 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13551 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13552 | safi_t safi, enum bgp_show_type type) |
| 13553 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13554 | if (! peer || ! peer->afc[afi][safi]) |
| 13555 | { |
| 13556 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13557 | return CMD_WARNING; |
| 13558 | } |
| 13559 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 13560 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13561 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13562 | DEFUN (show_ip_bgp_neighbor_routes, |
| 13563 | show_ip_bgp_neighbor_routes_cmd, |
| 13564 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 13565 | SHOW_STR |
| 13566 | IP_STR |
| 13567 | BGP_STR |
| 13568 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13569 | "Neighbor to display information about\n" |
| 13570 | "Neighbor to display information about\n" |
| 13571 | "Display routes learned from neighbor\n") |
| 13572 | { |
| 13573 | struct peer *peer; |
| 13574 | |
| 13575 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13576 | if (! peer) |
| 13577 | return CMD_WARNING; |
| 13578 | |
| 13579 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13580 | bgp_show_type_neighbor); |
| 13581 | } |
| 13582 | |
| 13583 | DEFUN (show_ip_bgp_neighbor_flap, |
| 13584 | show_ip_bgp_neighbor_flap_cmd, |
| 13585 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 13586 | SHOW_STR |
| 13587 | IP_STR |
| 13588 | BGP_STR |
| 13589 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13590 | "Neighbor to display information about\n" |
| 13591 | "Neighbor to display information about\n" |
| 13592 | "Display flap statistics of the routes learned from neighbor\n") |
| 13593 | { |
| 13594 | struct peer *peer; |
| 13595 | |
| 13596 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13597 | if (! peer) |
| 13598 | return CMD_WARNING; |
| 13599 | |
| 13600 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13601 | bgp_show_type_flap_neighbor); |
| 13602 | } |
| 13603 | |
| 13604 | DEFUN (show_ip_bgp_neighbor_damp, |
| 13605 | show_ip_bgp_neighbor_damp_cmd, |
| 13606 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 13607 | SHOW_STR |
| 13608 | IP_STR |
| 13609 | BGP_STR |
| 13610 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13611 | "Neighbor to display information about\n" |
| 13612 | "Neighbor to display information about\n" |
| 13613 | "Display the dampened routes received from neighbor\n") |
| 13614 | { |
| 13615 | struct peer *peer; |
| 13616 | |
| 13617 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13618 | if (! peer) |
| 13619 | return CMD_WARNING; |
| 13620 | |
| 13621 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13622 | bgp_show_type_damp_neighbor); |
| 13623 | } |
| 13624 | |
| 13625 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 13626 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 13627 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 13628 | SHOW_STR |
| 13629 | IP_STR |
| 13630 | BGP_STR |
| 13631 | "Address family\n" |
| 13632 | "Address Family modifier\n" |
| 13633 | "Address Family modifier\n" |
| 13634 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13635 | "Neighbor to display information about\n" |
| 13636 | "Neighbor to display information about\n" |
| 13637 | "Display routes learned from neighbor\n") |
| 13638 | { |
| 13639 | struct peer *peer; |
| 13640 | |
| 13641 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13642 | if (! peer) |
| 13643 | return CMD_WARNING; |
| 13644 | |
| 13645 | if (strncmp (argv[0], "m", 1) == 0) |
| 13646 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
| 13647 | bgp_show_type_neighbor); |
| 13648 | |
| 13649 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13650 | bgp_show_type_neighbor); |
| 13651 | } |
| 13652 | |
| 13653 | DEFUN (show_ip_bgp_view_rsclient, |
| 13654 | show_ip_bgp_view_rsclient_cmd, |
| 13655 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 13656 | SHOW_STR |
| 13657 | IP_STR |
| 13658 | BGP_STR |
| 13659 | "BGP view\n" |
| 13660 | "View name\n" |
| 13661 | "Information about Route Server Client\n" |
| 13662 | NEIGHBOR_ADDR_STR) |
| 13663 | { |
| 13664 | struct bgp_table *table; |
| 13665 | struct peer *peer; |
| 13666 | |
| 13667 | if (argc == 2) |
| 13668 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13669 | else |
| 13670 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13671 | |
| 13672 | if (! peer) |
| 13673 | return CMD_WARNING; |
| 13674 | |
| 13675 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 13676 | { |
| 13677 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13678 | VTY_NEWLINE); |
| 13679 | return CMD_WARNING; |
| 13680 | } |
| 13681 | |
| 13682 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 13683 | PEER_FLAG_RSERVER_CLIENT)) |
| 13684 | { |
| 13685 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13686 | VTY_NEWLINE); |
| 13687 | return CMD_WARNING; |
| 13688 | } |
| 13689 | |
| 13690 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 13691 | |
| 13692 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 13693 | } |
| 13694 | |
| 13695 | ALIAS (show_ip_bgp_view_rsclient, |
| 13696 | show_ip_bgp_rsclient_cmd, |
| 13697 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 13698 | SHOW_STR |
| 13699 | IP_STR |
| 13700 | BGP_STR |
| 13701 | "Information about Route Server Client\n" |
| 13702 | NEIGHBOR_ADDR_STR) |
| 13703 | |
| 13704 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 13705 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 13706 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 13707 | SHOW_STR |
| 13708 | BGP_STR |
| 13709 | "BGP view\n" |
| 13710 | "View name\n" |
| 13711 | "Address family\n" |
| 13712 | "Address Family modifier\n" |
| 13713 | "Address Family modifier\n" |
| 13714 | "Information about Route Server Client\n" |
| 13715 | NEIGHBOR_ADDR_STR) |
| 13716 | { |
| 13717 | struct bgp_table *table; |
| 13718 | struct peer *peer; |
| 13719 | safi_t safi; |
| 13720 | |
| 13721 | if (argc == 3) { |
| 13722 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 13723 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13724 | } else { |
| 13725 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13726 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13727 | } |
| 13728 | |
| 13729 | if (! peer) |
| 13730 | return CMD_WARNING; |
| 13731 | |
| 13732 | if (! peer->afc[AFI_IP][safi]) |
| 13733 | { |
| 13734 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13735 | VTY_NEWLINE); |
| 13736 | return CMD_WARNING; |
| 13737 | } |
| 13738 | |
| 13739 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 13740 | PEER_FLAG_RSERVER_CLIENT)) |
| 13741 | { |
| 13742 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13743 | VTY_NEWLINE); |
| 13744 | return CMD_WARNING; |
| 13745 | } |
| 13746 | |
| 13747 | table = peer->rib[AFI_IP][safi]; |
| 13748 | |
| 13749 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 13750 | } |
| 13751 | |
| 13752 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 13753 | show_bgp_ipv4_safi_rsclient_cmd, |
| 13754 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 13755 | SHOW_STR |
| 13756 | BGP_STR |
| 13757 | "Address family\n" |
| 13758 | "Address Family modifier\n" |
| 13759 | "Address Family modifier\n" |
| 13760 | "Information about Route Server Client\n" |
| 13761 | NEIGHBOR_ADDR_STR) |
| 13762 | |
| 13763 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 13764 | show_ip_bgp_view_rsclient_route_cmd, |
| 13765 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13766 | SHOW_STR |
| 13767 | IP_STR |
| 13768 | BGP_STR |
| 13769 | "BGP view\n" |
| 13770 | "View name\n" |
| 13771 | "Information about Route Server Client\n" |
| 13772 | NEIGHBOR_ADDR_STR |
| 13773 | "Network in the BGP routing table to display\n") |
| 13774 | { |
| 13775 | struct bgp *bgp; |
| 13776 | struct peer *peer; |
| 13777 | |
| 13778 | /* BGP structure lookup. */ |
| 13779 | if (argc == 3) |
| 13780 | { |
| 13781 | bgp = bgp_lookup_by_name (argv[0]); |
| 13782 | if (bgp == NULL) |
| 13783 | { |
| 13784 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13785 | return CMD_WARNING; |
| 13786 | } |
| 13787 | } |
| 13788 | else |
| 13789 | { |
| 13790 | bgp = bgp_get_default (); |
| 13791 | if (bgp == NULL) |
| 13792 | { |
| 13793 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 13794 | return CMD_WARNING; |
| 13795 | } |
| 13796 | } |
| 13797 | |
| 13798 | if (argc == 3) |
| 13799 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13800 | else |
| 13801 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13802 | |
| 13803 | if (! peer) |
| 13804 | return CMD_WARNING; |
| 13805 | |
| 13806 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 13807 | { |
| 13808 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13809 | VTY_NEWLINE); |
| 13810 | return CMD_WARNING; |
| 13811 | } |
| 13812 | |
| 13813 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 13814 | PEER_FLAG_RSERVER_CLIENT)) |
| 13815 | { |
| 13816 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13817 | VTY_NEWLINE); |
| 13818 | return CMD_WARNING; |
| 13819 | } |
| 13820 | |
| 13821 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 13822 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 13823 | AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13824 | } |
| 13825 | |
| 13826 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 13827 | show_ip_bgp_rsclient_route_cmd, |
| 13828 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13829 | SHOW_STR |
| 13830 | IP_STR |
| 13831 | BGP_STR |
| 13832 | "Information about Route Server Client\n" |
| 13833 | NEIGHBOR_ADDR_STR |
| 13834 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13835 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13836 | DEFUN (show_bgp_ipv4_safi_neighbor_flap, |
| 13837 | show_bgp_ipv4_safi_neighbor_flap_cmd, |
| 13838 | "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] | 13839 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13840 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13841 | "Address Family Modifier\n" |
| 13842 | "Address Family Modifier\n" |
| 13843 | "Address Family Modifier\n" |
| 13844 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13845 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13846 | "Neighbor to display information about\n" |
| 13847 | "Neighbor to display information about\n" |
| 13848 | "Display flap statistics of the routes learned from neighbor\n") |
| 13849 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13850 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13851 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13852 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13853 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13854 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13855 | return CMD_WARNING; |
| 13856 | } |
| 13857 | |
| 13858 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13859 | if (! peer) |
| 13860 | return CMD_WARNING; |
| 13861 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13862 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13863 | bgp_show_type_flap_neighbor); |
| 13864 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13865 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13866 | DEFUN (show_bgp_ipv6_safi_neighbor_flap, |
| 13867 | show_bgp_ipv6_safi_neighbor_flap_cmd, |
| 13868 | "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] | 13869 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13870 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13871 | "Address Family Modifier\n" |
| 13872 | "Address Family Modifier\n" |
| 13873 | "Address Family Modifier\n" |
| 13874 | "Address Family Modifier\n" |
| 13875 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13876 | "Neighbor to display information about\n" |
| 13877 | "Neighbor to display information about\n" |
| 13878 | "Display flap statistics of the routes learned from neighbor\n") |
| 13879 | { |
| 13880 | struct peer *peer; |
| 13881 | safi_t safi; |
| 13882 | |
| 13883 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13884 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13885 | return CMD_WARNING; |
| 13886 | } |
| 13887 | |
| 13888 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13889 | if (! peer) |
| 13890 | return CMD_WARNING; |
| 13891 | |
| 13892 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13893 | bgp_show_type_flap_neighbor); |
| 13894 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13895 | |
| 13896 | DEFUN (show_bgp_ipv4_safi_neighbor_damp, |
| 13897 | show_bgp_ipv4_safi_neighbor_damp_cmd, |
| 13898 | "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 13899 | SHOW_STR |
| 13900 | BGP_STR |
| 13901 | "Address Family Modifier\n" |
| 13902 | "Address Family Modifier\n" |
| 13903 | "Address Family Modifier\n" |
| 13904 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13905 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13906 | "Neighbor to display information about\n" |
| 13907 | "Neighbor to display information about\n" |
| 13908 | "Display the dampened routes received from neighbor\n") |
| 13909 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13910 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13911 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13912 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13913 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13914 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13915 | return CMD_WARNING; |
| 13916 | } |
| 13917 | |
| 13918 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13919 | if (! peer) |
| 13920 | return CMD_WARNING; |
| 13921 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13922 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13923 | bgp_show_type_damp_neighbor); |
| 13924 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13925 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13926 | DEFUN (show_bgp_ipv6_safi_neighbor_damp, |
| 13927 | show_bgp_ipv6_safi_neighbor_damp_cmd, |
| 13928 | "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] | 13929 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13930 | BGP_STR |
| 13931 | "Address Family Modifier\n" |
| 13932 | "Address Family Modifier\n" |
| 13933 | "Address Family Modifier\n" |
| 13934 | "Address Family Modifier\n" |
| 13935 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13936 | "Neighbor to display information about\n" |
| 13937 | "Neighbor to display information about\n" |
| 13938 | "Display the dampened routes received from neighbor\n") |
| 13939 | { |
| 13940 | struct peer *peer; |
| 13941 | safi_t safi; |
| 13942 | |
| 13943 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13944 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13945 | return CMD_WARNING; |
| 13946 | } |
| 13947 | |
| 13948 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13949 | if (! peer) |
| 13950 | return CMD_WARNING; |
| 13951 | |
| 13952 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13953 | bgp_show_type_damp_neighbor); |
| 13954 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13955 | |
| 13956 | DEFUN (show_bgp_ipv4_safi_neighbor_routes, |
| 13957 | show_bgp_ipv4_safi_neighbor_routes_cmd, |
| 13958 | "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 13959 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13960 | BGP_STR |
| 13961 | "Address family\n" |
| 13962 | "Address Family modifier\n" |
| 13963 | "Address Family modifier\n" |
| 13964 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13965 | "Neighbor to display information about\n" |
| 13966 | "Neighbor to display information about\n" |
| 13967 | "Display routes learned from neighbor\n") |
| 13968 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13969 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13970 | safi_t safi; |
| 13971 | |
| 13972 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13973 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13974 | return CMD_WARNING; |
| 13975 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13976 | |
| 13977 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13978 | if (! peer) |
| 13979 | return CMD_WARNING; |
| 13980 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13981 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13982 | bgp_show_type_neighbor); |
| 13983 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13984 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13985 | DEFUN (show_bgp_ipv6_safi_neighbor_routes, |
| 13986 | show_bgp_ipv6_safi_neighbor_routes_cmd, |
| 13987 | "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] | 13988 | SHOW_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13989 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13990 | "Address family\n" |
| 13991 | "Address Family modifier\n" |
| 13992 | "Address Family modifier\n" |
| 13993 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13994 | NEIGHBOR_ADDR_STR |
| 13995 | NEIGHBOR_ADDR_STR |
| 13996 | "Display routes learned from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13997 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13998 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13999 | safi_t safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14000 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14001 | if (bgp_parse_safi(argv[0], &safi)) { |
| 14002 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 14003 | return CMD_WARNING; |
| 14004 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14005 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14006 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14007 | if (! peer) |
| 14008 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14009 | |
| 14010 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 14011 | bgp_show_type_neighbor); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14012 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14013 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14014 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 14015 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 14016 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 14017 | SHOW_STR |
| 14018 | BGP_STR |
| 14019 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14020 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14021 | "Address family\n" |
| 14022 | "Address Family modifier\n" |
| 14023 | "Address Family modifier\n" |
| 14024 | "Information about Route Server Client\n" |
| 14025 | NEIGHBOR_ADDR_STR |
| 14026 | "Network in the BGP routing table to display\n") |
| 14027 | { |
| 14028 | struct bgp *bgp; |
| 14029 | struct peer *peer; |
| 14030 | safi_t safi; |
| 14031 | |
| 14032 | /* BGP structure lookup. */ |
| 14033 | if (argc == 4) |
| 14034 | { |
| 14035 | bgp = bgp_lookup_by_name (argv[0]); |
| 14036 | if (bgp == NULL) |
| 14037 | { |
| 14038 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14039 | return CMD_WARNING; |
| 14040 | } |
| 14041 | } |
| 14042 | else |
| 14043 | { |
| 14044 | bgp = bgp_get_default (); |
| 14045 | if (bgp == NULL) |
| 14046 | { |
| 14047 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14048 | return CMD_WARNING; |
| 14049 | } |
| 14050 | } |
| 14051 | |
| 14052 | if (argc == 4) { |
| 14053 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14054 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14055 | } else { |
| 14056 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14057 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14058 | } |
| 14059 | |
| 14060 | if (! peer) |
| 14061 | return CMD_WARNING; |
| 14062 | |
| 14063 | if (! peer->afc[AFI_IP][safi]) |
| 14064 | { |
| 14065 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14066 | VTY_NEWLINE); |
| 14067 | return CMD_WARNING; |
| 14068 | } |
| 14069 | |
| 14070 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 14071 | PEER_FLAG_RSERVER_CLIENT)) |
| 14072 | { |
| 14073 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14074 | VTY_NEWLINE); |
| 14075 | return CMD_WARNING; |
| 14076 | } |
| 14077 | |
| 14078 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 14079 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14080 | AFI_IP, safi, NULL, 0, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14081 | } |
| 14082 | |
| 14083 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 14084 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 14085 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 14086 | SHOW_STR |
| 14087 | BGP_STR |
| 14088 | "Address family\n" |
| 14089 | "Address Family modifier\n" |
| 14090 | "Address Family modifier\n" |
| 14091 | "Information about Route Server Client\n" |
| 14092 | NEIGHBOR_ADDR_STR |
| 14093 | "Network in the BGP routing table to display\n") |
| 14094 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14095 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14096 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 14097 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 14098 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14099 | SHOW_STR |
| 14100 | BGP_STR |
| 14101 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14102 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14103 | "Address family\n" |
| 14104 | "Address Family modifier\n" |
| 14105 | "Address Family modifier\n" |
| 14106 | "Information about Route Server Client\n" |
| 14107 | NEIGHBOR_ADDR_STR |
| 14108 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 14109 | { |
| 14110 | struct bgp *bgp; |
| 14111 | struct peer *peer; |
| 14112 | safi_t safi; |
| 14113 | |
| 14114 | /* BGP structure lookup. */ |
| 14115 | if (argc == 4) |
| 14116 | { |
| 14117 | bgp = bgp_lookup_by_name (argv[0]); |
| 14118 | if (bgp == NULL) |
| 14119 | { |
| 14120 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14121 | return CMD_WARNING; |
| 14122 | } |
| 14123 | } |
| 14124 | else |
| 14125 | { |
| 14126 | bgp = bgp_get_default (); |
| 14127 | if (bgp == NULL) |
| 14128 | { |
| 14129 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14130 | return CMD_WARNING; |
| 14131 | } |
| 14132 | } |
| 14133 | |
| 14134 | if (argc == 4) { |
| 14135 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14136 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14137 | } else { |
| 14138 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14139 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14140 | } |
| 14141 | |
| 14142 | if (! peer) |
| 14143 | return CMD_WARNING; |
| 14144 | |
| 14145 | if (! peer->afc[AFI_IP][safi]) |
| 14146 | { |
| 14147 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14148 | VTY_NEWLINE); |
| 14149 | return CMD_WARNING; |
| 14150 | } |
| 14151 | |
| 14152 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 14153 | PEER_FLAG_RSERVER_CLIENT)) |
| 14154 | { |
| 14155 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14156 | VTY_NEWLINE); |
| 14157 | return CMD_WARNING; |
| 14158 | } |
| 14159 | |
| 14160 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 14161 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14162 | AFI_IP, safi, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14163 | } |
| 14164 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14165 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 14166 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 14167 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14168 | SHOW_STR |
| 14169 | IP_STR |
| 14170 | BGP_STR |
| 14171 | "BGP view\n" |
| 14172 | "View name\n" |
| 14173 | "Information about Route Server Client\n" |
| 14174 | NEIGHBOR_ADDR_STR |
| 14175 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 14176 | { |
| 14177 | struct bgp *bgp; |
| 14178 | struct peer *peer; |
| 14179 | |
| 14180 | /* BGP structure lookup. */ |
| 14181 | if (argc == 3) |
| 14182 | { |
| 14183 | bgp = bgp_lookup_by_name (argv[0]); |
| 14184 | if (bgp == NULL) |
| 14185 | { |
| 14186 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14187 | return CMD_WARNING; |
| 14188 | } |
| 14189 | } |
| 14190 | else |
| 14191 | { |
| 14192 | bgp = bgp_get_default (); |
| 14193 | if (bgp == NULL) |
| 14194 | { |
| 14195 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14196 | return CMD_WARNING; |
| 14197 | } |
| 14198 | } |
| 14199 | |
| 14200 | if (argc == 3) |
| 14201 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14202 | else |
| 14203 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14204 | |
| 14205 | if (! peer) |
| 14206 | return CMD_WARNING; |
| 14207 | |
| 14208 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 14209 | { |
| 14210 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14211 | VTY_NEWLINE); |
| 14212 | return CMD_WARNING; |
| 14213 | } |
| 14214 | |
| 14215 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 14216 | PEER_FLAG_RSERVER_CLIENT)) |
| 14217 | { |
| 14218 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14219 | VTY_NEWLINE); |
| 14220 | return CMD_WARNING; |
| 14221 | } |
| 14222 | |
| 14223 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 14224 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14225 | AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14226 | } |
| 14227 | |
| 14228 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 14229 | show_ip_bgp_rsclient_prefix_cmd, |
| 14230 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14231 | SHOW_STR |
| 14232 | IP_STR |
| 14233 | BGP_STR |
| 14234 | "Information about Route Server Client\n" |
| 14235 | NEIGHBOR_ADDR_STR |
| 14236 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 14237 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14238 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 14239 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 14240 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14241 | SHOW_STR |
| 14242 | BGP_STR |
| 14243 | "Address family\n" |
| 14244 | "Address Family modifier\n" |
| 14245 | "Address Family modifier\n" |
| 14246 | "Information about Route Server Client\n" |
| 14247 | NEIGHBOR_ADDR_STR |
| 14248 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14249 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14250 | DEFUN (show_bgp_view_ipv6_neighbor_routes, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14251 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 14252 | "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] | 14253 | SHOW_STR |
| 14254 | BGP_STR |
| 14255 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14256 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14257 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14258 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14259 | "Neighbor to display information about\n" |
| 14260 | "Neighbor to display information about\n" |
| 14261 | "Display routes learned from neighbor\n") |
| 14262 | { |
| 14263 | struct peer *peer; |
| 14264 | |
| 14265 | if (argc == 2) |
| 14266 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14267 | else |
| 14268 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14269 | |
| 14270 | if (! peer) |
| 14271 | return CMD_WARNING; |
| 14272 | |
| 14273 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14274 | bgp_show_type_neighbor); |
| 14275 | } |
| 14276 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14277 | DEFUN (show_bgp_view_neighbor_damp, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14278 | show_bgp_view_neighbor_damp_cmd, |
| 14279 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14280 | SHOW_STR |
| 14281 | BGP_STR |
| 14282 | "BGP view\n" |
| 14283 | "View name\n" |
| 14284 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14285 | "Neighbor to display information about\n" |
| 14286 | "Neighbor to display information about\n" |
| 14287 | "Display the dampened routes received from neighbor\n") |
| 14288 | { |
| 14289 | struct peer *peer; |
| 14290 | |
| 14291 | if (argc == 2) |
| 14292 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14293 | else |
| 14294 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14295 | |
| 14296 | if (! peer) |
| 14297 | return CMD_WARNING; |
| 14298 | |
| 14299 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14300 | bgp_show_type_damp_neighbor); |
| 14301 | } |
| 14302 | |
| 14303 | DEFUN (show_bgp_view_ipv6_neighbor_damp, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14304 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 14305 | "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] | 14306 | SHOW_STR |
| 14307 | BGP_STR |
| 14308 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14309 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14310 | "Address family\n" |
| 14311 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14312 | "Neighbor to display information about\n" |
| 14313 | "Neighbor to display information about\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14314 | "Display the dampened routes received from neighbor\n") |
| 14315 | { |
| 14316 | struct peer *peer; |
| 14317 | |
| 14318 | if (argc == 2) |
| 14319 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14320 | else |
| 14321 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14322 | |
| 14323 | if (! peer) |
| 14324 | return CMD_WARNING; |
| 14325 | |
| 14326 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14327 | bgp_show_type_damp_neighbor); |
| 14328 | } |
| 14329 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14330 | DEFUN (show_bgp_view_ipv6_neighbor_flap, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14331 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 14332 | "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] | 14333 | SHOW_STR |
| 14334 | BGP_STR |
| 14335 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14336 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14337 | "Address family\n" |
| 14338 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14339 | "Neighbor to display information about\n" |
| 14340 | "Neighbor to display information about\n" |
| 14341 | "Display the dampened routes received from neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14342 | { |
| 14343 | struct peer *peer; |
| 14344 | |
| 14345 | if (argc == 2) |
| 14346 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14347 | else |
| 14348 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14349 | |
| 14350 | if (! peer) |
| 14351 | return CMD_WARNING; |
| 14352 | |
| 14353 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14354 | bgp_show_type_flap_neighbor); |
| 14355 | } |
| 14356 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14357 | DEFUN (show_bgp_view_neighbor_flap, |
| 14358 | show_bgp_view_neighbor_flap_cmd, |
| 14359 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14360 | SHOW_STR |
| 14361 | BGP_STR |
| 14362 | "BGP view\n" |
| 14363 | "View name\n" |
| 14364 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14365 | "Neighbor to display information about\n" |
| 14366 | "Neighbor to display information about\n" |
| 14367 | "Display flap statistics of the routes learned from neighbor\n") |
| 14368 | { |
| 14369 | struct peer *peer; |
| 14370 | |
| 14371 | if (argc == 2) |
| 14372 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14373 | else |
| 14374 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14375 | |
| 14376 | if (! peer) |
| 14377 | return CMD_WARNING; |
| 14378 | |
| 14379 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14380 | bgp_show_type_flap_neighbor); |
| 14381 | } |
| 14382 | |
| 14383 | ALIAS (show_bgp_view_neighbor_flap, |
| 14384 | show_bgp_neighbor_flap_cmd, |
| 14385 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14386 | SHOW_STR |
| 14387 | BGP_STR |
| 14388 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14389 | "Neighbor to display information about\n" |
| 14390 | "Neighbor to display information about\n" |
| 14391 | "Display flap statistics of the routes learned from neighbor\n") |
| 14392 | |
| 14393 | ALIAS (show_bgp_view_neighbor_damp, |
| 14394 | show_bgp_neighbor_damp_cmd, |
| 14395 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14396 | SHOW_STR |
| 14397 | BGP_STR |
| 14398 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14399 | "Neighbor to display information about\n" |
| 14400 | "Neighbor to display information about\n" |
| 14401 | "Display the dampened routes received from neighbor\n") |
| 14402 | |
| 14403 | DEFUN (show_bgp_view_neighbor_routes, |
| 14404 | show_bgp_view_neighbor_routes_cmd, |
| 14405 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 14406 | SHOW_STR |
| 14407 | BGP_STR |
| 14408 | "BGP view\n" |
| 14409 | "View name\n" |
| 14410 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14411 | "Neighbor to display information about\n" |
| 14412 | "Neighbor to display information about\n" |
| 14413 | "Display routes learned from neighbor\n") |
| 14414 | { |
| 14415 | struct peer *peer; |
| 14416 | |
| 14417 | if (argc == 2) |
| 14418 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14419 | else |
| 14420 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14421 | |
| 14422 | if (! peer) |
| 14423 | return CMD_WARNING; |
| 14424 | |
| 14425 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14426 | bgp_show_type_neighbor); |
| 14427 | } |
| 14428 | |
| 14429 | ALIAS (show_bgp_view_neighbor_routes, |
| 14430 | show_bgp_neighbor_routes_cmd, |
| 14431 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14432 | SHOW_STR |
| 14433 | BGP_STR |
| 14434 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14435 | "Neighbor to display information about\n" |
| 14436 | "Neighbor to display information about\n" |
| 14437 | "Display routes learned from neighbor\n") |
| 14438 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14439 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14440 | show_bgp_ipv6_neighbor_routes_cmd, |
| 14441 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 14442 | SHOW_STR |
| 14443 | BGP_STR |
| 14444 | "Address family\n" |
| 14445 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14446 | "Neighbor to display information about\n" |
| 14447 | "Neighbor to display information about\n" |
| 14448 | "Display routes learned from neighbor\n") |
| 14449 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14450 | /* old command */ |
| 14451 | ALIAS (show_bgp_view_neighbor_routes, |
| 14452 | ipv6_bgp_neighbor_routes_cmd, |
| 14453 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14454 | SHOW_STR |
| 14455 | IPV6_STR |
| 14456 | BGP_STR |
| 14457 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14458 | "Neighbor to display information about\n" |
| 14459 | "Neighbor to display information about\n" |
| 14460 | "Display routes learned from neighbor\n") |
| 14461 | |
| 14462 | /* old command */ |
| 14463 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 14464 | ipv6_mbgp_neighbor_routes_cmd, |
| 14465 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14466 | SHOW_STR |
| 14467 | IPV6_STR |
| 14468 | MBGP_STR |
| 14469 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14470 | "Neighbor to display information about\n" |
| 14471 | "Neighbor to display information about\n" |
| 14472 | "Display routes learned from neighbor\n") |
| 14473 | { |
| 14474 | struct peer *peer; |
| 14475 | |
| 14476 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14477 | if (! peer) |
| 14478 | return CMD_WARNING; |
| 14479 | |
| 14480 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
| 14481 | bgp_show_type_neighbor); |
| 14482 | } |
| 14483 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14484 | ALIAS (show_bgp_view_neighbor_flap, |
| 14485 | show_bgp_ipv6_neighbor_flap_cmd, |
| 14486 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14487 | SHOW_STR |
| 14488 | BGP_STR |
| 14489 | "Address family\n" |
| 14490 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14491 | "Neighbor to display information about\n" |
| 14492 | "Neighbor to display information about\n" |
| 14493 | "Display flap statistics of the routes learned from neighbor\n") |
| 14494 | |
| 14495 | ALIAS (show_bgp_view_neighbor_damp, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14496 | show_bgp_ipv6_neighbor_damp_cmd, |
| 14497 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14498 | SHOW_STR |
| 14499 | BGP_STR |
| 14500 | "Address family\n" |
| 14501 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14502 | "Neighbor to display information about\n" |
| 14503 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 14504 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14505 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14506 | DEFUN (show_bgp_view_rsclient, |
| 14507 | show_bgp_view_rsclient_cmd, |
| 14508 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 14509 | SHOW_STR |
| 14510 | BGP_STR |
| 14511 | "BGP view\n" |
| 14512 | "View name\n" |
| 14513 | "Information about Route Server Client\n" |
| 14514 | NEIGHBOR_ADDR_STR) |
| 14515 | { |
| 14516 | struct bgp_table *table; |
| 14517 | struct peer *peer; |
| 14518 | |
| 14519 | if (argc == 2) |
| 14520 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14521 | else |
| 14522 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14523 | |
| 14524 | if (! peer) |
| 14525 | return CMD_WARNING; |
| 14526 | |
| 14527 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14528 | { |
| 14529 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14530 | VTY_NEWLINE); |
| 14531 | return CMD_WARNING; |
| 14532 | } |
| 14533 | |
| 14534 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14535 | PEER_FLAG_RSERVER_CLIENT)) |
| 14536 | { |
| 14537 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14538 | VTY_NEWLINE); |
| 14539 | return CMD_WARNING; |
| 14540 | } |
| 14541 | |
| 14542 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 14543 | |
| 14544 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14545 | } |
| 14546 | |
| 14547 | ALIAS (show_bgp_view_rsclient, |
| 14548 | show_bgp_rsclient_cmd, |
| 14549 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 14550 | SHOW_STR |
| 14551 | BGP_STR |
| 14552 | "Information about Route Server Client\n" |
| 14553 | NEIGHBOR_ADDR_STR) |
| 14554 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14555 | DEFUN (show_bgp_view_ipv4_rsclient, |
| 14556 | show_bgp_view_ipv4_rsclient_cmd, |
| 14557 | "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] | 14558 | SHOW_STR |
| 14559 | BGP_STR |
| 14560 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14561 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14562 | "Address Family\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14563 | "Information about Route Server Client\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14564 | NEIGHBOR_ADDR_STR2) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14565 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14566 | struct bgp_table *table; |
| 14567 | struct peer *peer; |
| 14568 | |
| 14569 | if (argc == 2) |
| 14570 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14571 | else |
| 14572 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14573 | |
| 14574 | if (! peer) |
| 14575 | return CMD_WARNING; |
| 14576 | |
| 14577 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 14578 | { |
| 14579 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14580 | VTY_NEWLINE); |
| 14581 | return CMD_WARNING; |
| 14582 | } |
| 14583 | |
| 14584 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 14585 | PEER_FLAG_RSERVER_CLIENT)) |
| 14586 | { |
| 14587 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14588 | VTY_NEWLINE); |
| 14589 | return CMD_WARNING; |
| 14590 | } |
| 14591 | |
| 14592 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 14593 | |
| 14594 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14595 | } |
| 14596 | DEFUN (show_bgp_view_ipv6_rsclient, |
| 14597 | show_bgp_view_ipv6_rsclient_cmd, |
| 14598 | "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)", |
| 14599 | SHOW_STR |
| 14600 | BGP_STR |
| 14601 | "BGP view\n" |
| 14602 | "BGP view name\n" |
| 14603 | "Address Family\n" |
| 14604 | "Information about Route Server Client\n" |
| 14605 | NEIGHBOR_ADDR_STR2) |
| 14606 | { |
| 14607 | struct bgp_table *table; |
| 14608 | struct peer *peer; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14609 | |
| 14610 | if (argc == 2) |
| 14611 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14612 | else |
| 14613 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14614 | |
| 14615 | if (! peer) |
| 14616 | return CMD_WARNING; |
| 14617 | |
| 14618 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14619 | { |
| 14620 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14621 | VTY_NEWLINE); |
| 14622 | return CMD_WARNING; |
| 14623 | } |
| 14624 | |
| 14625 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14626 | PEER_FLAG_RSERVER_CLIENT)) |
| 14627 | { |
| 14628 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14629 | VTY_NEWLINE); |
| 14630 | return CMD_WARNING; |
| 14631 | } |
| 14632 | |
| 14633 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 14634 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 14635 | 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] | 14636 | } |
| 14637 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14638 | ALIAS (show_bgp_view_ipv4_rsclient, |
| 14639 | show_bgp_ipv4_rsclient_cmd, |
| 14640 | "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14641 | SHOW_STR |
| 14642 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14643 | "Address Family\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14644 | "Information about Route Server Client\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14645 | NEIGHBOR_ADDR_STR2) |
| 14646 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14647 | ALIAS (show_bgp_view_ipv6_rsclient, |
| 14648 | show_bgp_ipv6_rsclient_cmd, |
| 14649 | "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)", |
| 14650 | SHOW_STR |
| 14651 | BGP_STR |
| 14652 | "Address Family\n" |
| 14653 | "Information about Route Server Client\n" |
| 14654 | NEIGHBOR_ADDR_STR2) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14655 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14656 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 14657 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 14658 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 14659 | SHOW_STR |
| 14660 | BGP_STR |
| 14661 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14662 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14663 | "Address family\n" |
| 14664 | "Address Family modifier\n" |
| 14665 | "Address Family modifier\n" |
| 14666 | "Information about Route Server Client\n" |
| 14667 | NEIGHBOR_ADDR_STR) |
| 14668 | { |
| 14669 | struct bgp_table *table; |
| 14670 | struct peer *peer; |
| 14671 | safi_t safi; |
| 14672 | |
| 14673 | if (argc == 3) { |
| 14674 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14675 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14676 | } else { |
| 14677 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14678 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14679 | } |
| 14680 | |
| 14681 | if (! peer) |
| 14682 | return CMD_WARNING; |
| 14683 | |
| 14684 | if (! peer->afc[AFI_IP6][safi]) |
| 14685 | { |
| 14686 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14687 | VTY_NEWLINE); |
| 14688 | return CMD_WARNING; |
| 14689 | } |
| 14690 | |
| 14691 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 14692 | PEER_FLAG_RSERVER_CLIENT)) |
| 14693 | { |
| 14694 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14695 | VTY_NEWLINE); |
| 14696 | return CMD_WARNING; |
| 14697 | } |
| 14698 | |
| 14699 | table = peer->rib[AFI_IP6][safi]; |
| 14700 | |
| 14701 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14702 | } |
| 14703 | |
| 14704 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 14705 | show_bgp_ipv6_safi_rsclient_cmd, |
| 14706 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 14707 | SHOW_STR |
| 14708 | BGP_STR |
| 14709 | "Address family\n" |
| 14710 | "Address Family modifier\n" |
| 14711 | "Address Family modifier\n" |
| 14712 | "Information about Route Server Client\n" |
| 14713 | NEIGHBOR_ADDR_STR) |
| 14714 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14715 | DEFUN (show_bgp_view_rsclient_route, |
| 14716 | show_bgp_view_rsclient_route_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14717 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14718 | SHOW_STR |
| 14719 | BGP_STR |
| 14720 | "BGP view\n" |
| 14721 | "View name\n" |
| 14722 | "Information about Route Server Client\n" |
| 14723 | NEIGHBOR_ADDR_STR |
| 14724 | "Network in the BGP routing table to display\n") |
| 14725 | { |
| 14726 | struct bgp *bgp; |
| 14727 | struct peer *peer; |
| 14728 | |
| 14729 | /* BGP structure lookup. */ |
| 14730 | if (argc == 3) |
| 14731 | { |
| 14732 | bgp = bgp_lookup_by_name (argv[0]); |
| 14733 | if (bgp == NULL) |
| 14734 | { |
| 14735 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14736 | return CMD_WARNING; |
| 14737 | } |
| 14738 | } |
| 14739 | else |
| 14740 | { |
| 14741 | bgp = bgp_get_default (); |
| 14742 | if (bgp == NULL) |
| 14743 | { |
| 14744 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14745 | return CMD_WARNING; |
| 14746 | } |
| 14747 | } |
| 14748 | |
| 14749 | if (argc == 3) |
| 14750 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14751 | else |
| 14752 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14753 | |
| 14754 | if (! peer) |
| 14755 | return CMD_WARNING; |
| 14756 | |
| 14757 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14758 | { |
| 14759 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14760 | VTY_NEWLINE); |
| 14761 | return CMD_WARNING; |
| 14762 | } |
| 14763 | |
| 14764 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14765 | PEER_FLAG_RSERVER_CLIENT)) |
| 14766 | { |
| 14767 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14768 | VTY_NEWLINE); |
| 14769 | return CMD_WARNING; |
| 14770 | } |
| 14771 | |
| 14772 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14773 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14774 | AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14775 | } |
| 14776 | |
| 14777 | DEFUN (show_bgp_view_ipv6_rsclient_route, |
| 14778 | show_bgp_view_ipv6_rsclient_route_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14779 | "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] | 14780 | SHOW_STR |
| 14781 | BGP_STR |
| 14782 | "BGP view\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14783 | "BGP view name\n" |
| 14784 | "IP6_STR" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14785 | "Information about Route Server Client\n" |
| 14786 | NEIGHBOR_ADDR_STR |
| 14787 | "Network in the BGP routing table to display\n") |
| 14788 | { |
| 14789 | struct bgp *bgp; |
| 14790 | struct peer *peer; |
| 14791 | |
| 14792 | /* BGP structure lookup. */ |
| 14793 | if (argc == 3) |
| 14794 | { |
| 14795 | bgp = bgp_lookup_by_name (argv[0]); |
| 14796 | if (bgp == NULL) |
| 14797 | { |
| 14798 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14799 | return CMD_WARNING; |
| 14800 | } |
| 14801 | } |
| 14802 | else |
| 14803 | { |
| 14804 | bgp = bgp_get_default (); |
| 14805 | if (bgp == NULL) |
| 14806 | { |
| 14807 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14808 | return CMD_WARNING; |
| 14809 | } |
| 14810 | } |
| 14811 | |
| 14812 | if (argc == 3) |
| 14813 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14814 | else |
| 14815 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14816 | |
| 14817 | if (! peer) |
| 14818 | return CMD_WARNING; |
| 14819 | |
| 14820 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14821 | { |
| 14822 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14823 | VTY_NEWLINE); |
| 14824 | return CMD_WARNING; |
| 14825 | } |
| 14826 | |
| 14827 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14828 | PEER_FLAG_RSERVER_CLIENT)) |
| 14829 | { |
| 14830 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14831 | VTY_NEWLINE); |
| 14832 | return CMD_WARNING; |
| 14833 | } |
| 14834 | |
| 14835 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14836 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14837 | AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14838 | } |
| 14839 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14840 | ALIAS (show_bgp_view_ipv6_rsclient_route, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14841 | show_bgp_rsclient_route_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14842 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14843 | SHOW_STR |
| 14844 | BGP_STR |
| 14845 | "Information about Route Server Client\n" |
| 14846 | NEIGHBOR_ADDR_STR |
| 14847 | "Network in the BGP routing table to display\n") |
| 14848 | |
| 14849 | ALIAS (show_bgp_view_ipv6_rsclient_route, |
| 14850 | show_bgp_ipv6_rsclient_route_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14851 | "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] | 14852 | SHOW_STR |
| 14853 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14854 | IP6_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14855 | "Information about Route Server Client\n" |
| 14856 | NEIGHBOR_ADDR_STR |
| 14857 | "Network in the BGP routing table to display\n") |
| 14858 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14859 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 14860 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 14861 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14862 | SHOW_STR |
| 14863 | BGP_STR |
| 14864 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14865 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14866 | "Address family\n" |
| 14867 | "Address Family modifier\n" |
| 14868 | "Address Family modifier\n" |
| 14869 | "Information about Route Server Client\n" |
| 14870 | NEIGHBOR_ADDR_STR |
| 14871 | "Network in the BGP routing table to display\n") |
| 14872 | { |
| 14873 | struct bgp *bgp; |
| 14874 | struct peer *peer; |
| 14875 | safi_t safi; |
| 14876 | |
| 14877 | /* BGP structure lookup. */ |
| 14878 | if (argc == 4) |
| 14879 | { |
| 14880 | bgp = bgp_lookup_by_name (argv[0]); |
| 14881 | if (bgp == NULL) |
| 14882 | { |
| 14883 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14884 | return CMD_WARNING; |
| 14885 | } |
| 14886 | } |
| 14887 | else |
| 14888 | { |
| 14889 | bgp = bgp_get_default (); |
| 14890 | if (bgp == NULL) |
| 14891 | { |
| 14892 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14893 | return CMD_WARNING; |
| 14894 | } |
| 14895 | } |
| 14896 | |
| 14897 | if (argc == 4) { |
| 14898 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14899 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14900 | } else { |
| 14901 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14902 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14903 | } |
| 14904 | |
| 14905 | if (! peer) |
| 14906 | return CMD_WARNING; |
| 14907 | |
| 14908 | if (! peer->afc[AFI_IP6][safi]) |
| 14909 | { |
| 14910 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14911 | VTY_NEWLINE); |
| 14912 | return CMD_WARNING; |
| 14913 | } |
| 14914 | |
| 14915 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 14916 | PEER_FLAG_RSERVER_CLIENT)) |
| 14917 | { |
| 14918 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14919 | VTY_NEWLINE); |
| 14920 | return CMD_WARNING; |
| 14921 | } |
| 14922 | |
| 14923 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 14924 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14925 | AFI_IP6, safi, NULL, 0, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14926 | } |
| 14927 | |
| 14928 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 14929 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 14930 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14931 | SHOW_STR |
| 14932 | BGP_STR |
| 14933 | "Address family\n" |
| 14934 | "Address Family modifier\n" |
| 14935 | "Address Family modifier\n" |
| 14936 | "Information about Route Server Client\n" |
| 14937 | NEIGHBOR_ADDR_STR |
| 14938 | "Network in the BGP routing table to display\n") |
| 14939 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14940 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14941 | DEFUN (show_bgp_view_rsclient_prefix, |
| 14942 | show_bgp_view_rsclient_prefix_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14943 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 14944 | SHOW_STR |
| 14945 | BGP_STR |
| 14946 | "BGP view\n" |
| 14947 | "View name\n" |
| 14948 | "Information about Route Server Client\n" |
| 14949 | NEIGHBOR_ADDR_STR |
| 14950 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14951 | { |
| 14952 | struct bgp *bgp; |
| 14953 | struct peer *peer; |
| 14954 | |
| 14955 | /* BGP structure lookup. */ |
| 14956 | if (argc == 3) |
| 14957 | { |
| 14958 | bgp = bgp_lookup_by_name (argv[0]); |
| 14959 | if (bgp == NULL) |
| 14960 | { |
| 14961 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14962 | return CMD_WARNING; |
| 14963 | } |
| 14964 | } |
| 14965 | else |
| 14966 | { |
| 14967 | bgp = bgp_get_default (); |
| 14968 | if (bgp == NULL) |
| 14969 | { |
| 14970 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14971 | return CMD_WARNING; |
| 14972 | } |
| 14973 | } |
| 14974 | |
| 14975 | if (argc == 3) |
| 14976 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14977 | else |
| 14978 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14979 | |
| 14980 | if (! peer) |
| 14981 | return CMD_WARNING; |
| 14982 | |
| 14983 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14984 | { |
| 14985 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14986 | VTY_NEWLINE); |
| 14987 | return CMD_WARNING; |
| 14988 | } |
| 14989 | |
| 14990 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14991 | PEER_FLAG_RSERVER_CLIENT)) |
| 14992 | { |
| 14993 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14994 | VTY_NEWLINE); |
| 14995 | return CMD_WARNING; |
| 14996 | } |
| 14997 | |
| 14998 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14999 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 15000 | AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15001 | } |
| 15002 | |
| 15003 | DEFUN (show_bgp_view_ipv6_rsclient_prefix, |
| 15004 | show_bgp_view_ipv6_rsclient_prefix_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15005 | "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] | 15006 | SHOW_STR |
| 15007 | BGP_STR |
| 15008 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15009 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15010 | IP6_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15011 | "Information about Route Server Client\n" |
| 15012 | NEIGHBOR_ADDR_STR |
| 15013 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15014 | { |
| 15015 | struct bgp *bgp; |
| 15016 | struct peer *peer; |
| 15017 | |
| 15018 | /* BGP structure lookup. */ |
| 15019 | if (argc == 3) |
| 15020 | { |
| 15021 | bgp = bgp_lookup_by_name (argv[0]); |
| 15022 | if (bgp == NULL) |
| 15023 | { |
| 15024 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 15025 | return CMD_WARNING; |
| 15026 | } |
| 15027 | } |
| 15028 | else |
| 15029 | { |
| 15030 | bgp = bgp_get_default (); |
| 15031 | if (bgp == NULL) |
| 15032 | { |
| 15033 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 15034 | return CMD_WARNING; |
| 15035 | } |
| 15036 | } |
| 15037 | |
| 15038 | if (argc == 3) |
| 15039 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 15040 | else |
| 15041 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 15042 | |
| 15043 | if (! peer) |
| 15044 | return CMD_WARNING; |
| 15045 | |
| 15046 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 15047 | { |
| 15048 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 15049 | VTY_NEWLINE); |
| 15050 | return CMD_WARNING; |
| 15051 | } |
| 15052 | |
| 15053 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 15054 | PEER_FLAG_RSERVER_CLIENT)) |
| 15055 | { |
| 15056 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 15057 | VTY_NEWLINE); |
| 15058 | return CMD_WARNING; |
| 15059 | } |
| 15060 | |
| 15061 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 15062 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 15063 | AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15064 | } |
| 15065 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15066 | ALIAS (show_bgp_view_ipv6_rsclient_prefix, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 15067 | show_bgp_rsclient_prefix_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15068 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 15069 | SHOW_STR |
| 15070 | BGP_STR |
| 15071 | "Information about Route Server Client\n" |
| 15072 | NEIGHBOR_ADDR_STR |
| 15073 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15074 | |
| 15075 | ALIAS (show_bgp_view_ipv6_rsclient_prefix, |
| 15076 | show_bgp_ipv6_rsclient_prefix_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15077 | "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] | 15078 | SHOW_STR |
| 15079 | BGP_STR |
| 15080 | "Information about Route Server Client\n" |
| 15081 | NEIGHBOR_ADDR_STR |
| 15082 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15083 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15084 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 15085 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 15086 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 15087 | SHOW_STR |
| 15088 | BGP_STR |
| 15089 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15090 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15091 | "Address family\n" |
| 15092 | "Address Family modifier\n" |
| 15093 | "Address Family modifier\n" |
| 15094 | "Information about Route Server Client\n" |
| 15095 | NEIGHBOR_ADDR_STR |
| 15096 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15097 | { |
| 15098 | struct bgp *bgp; |
| 15099 | struct peer *peer; |
| 15100 | safi_t safi; |
| 15101 | |
| 15102 | /* BGP structure lookup. */ |
| 15103 | if (argc == 4) |
| 15104 | { |
| 15105 | bgp = bgp_lookup_by_name (argv[0]); |
| 15106 | if (bgp == NULL) |
| 15107 | { |
| 15108 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 15109 | return CMD_WARNING; |
| 15110 | } |
| 15111 | } |
| 15112 | else |
| 15113 | { |
| 15114 | bgp = bgp_get_default (); |
| 15115 | if (bgp == NULL) |
| 15116 | { |
| 15117 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 15118 | return CMD_WARNING; |
| 15119 | } |
| 15120 | } |
| 15121 | |
| 15122 | if (argc == 4) { |
| 15123 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 15124 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 15125 | } else { |
| 15126 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 15127 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 15128 | } |
| 15129 | |
| 15130 | if (! peer) |
| 15131 | return CMD_WARNING; |
| 15132 | |
| 15133 | if (! peer->afc[AFI_IP6][safi]) |
| 15134 | { |
| 15135 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 15136 | VTY_NEWLINE); |
| 15137 | return CMD_WARNING; |
| 15138 | } |
| 15139 | |
| 15140 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 15141 | PEER_FLAG_RSERVER_CLIENT)) |
| 15142 | { |
| 15143 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 15144 | VTY_NEWLINE); |
| 15145 | return CMD_WARNING; |
| 15146 | } |
| 15147 | |
| 15148 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 15149 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 15150 | AFI_IP6, safi, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15151 | } |
| 15152 | |
| 15153 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 15154 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 15155 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 15156 | SHOW_STR |
| 15157 | BGP_STR |
| 15158 | "Address family\n" |
| 15159 | "Address Family modifier\n" |
| 15160 | "Address Family modifier\n" |
| 15161 | "Information about Route Server Client\n" |
| 15162 | NEIGHBOR_ADDR_STR |
| 15163 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15164 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15165 | struct bgp_table *bgp_distance_table; |
| 15166 | |
| 15167 | struct bgp_distance |
| 15168 | { |
| 15169 | /* Distance value for the IP source prefix. */ |
| 15170 | u_char distance; |
| 15171 | |
| 15172 | /* Name of the access-list to be matched. */ |
| 15173 | char *access_list; |
| 15174 | }; |
| 15175 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15176 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 15177 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15178 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 15179 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15180 | } |
| 15181 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15182 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15183 | bgp_distance_free (struct bgp_distance *bdistance) |
| 15184 | { |
| 15185 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 15186 | } |
| 15187 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15188 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 15189 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 15190 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15191 | { |
| 15192 | int ret; |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15193 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15194 | u_char distance; |
| 15195 | struct bgp_node *rn; |
| 15196 | struct bgp_distance *bdistance; |
| 15197 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15198 | ret = str2prefix (ip_str, &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15199 | if (ret == 0) |
| 15200 | { |
| 15201 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 15202 | return CMD_WARNING; |
| 15203 | } |
| 15204 | |
| 15205 | distance = atoi (distance_str); |
| 15206 | |
| 15207 | /* Get BGP distance node. */ |
| 15208 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 15209 | if (rn->info) |
| 15210 | { |
| 15211 | bdistance = rn->info; |
| 15212 | bgp_unlock_node (rn); |
| 15213 | } |
| 15214 | else |
| 15215 | { |
| 15216 | bdistance = bgp_distance_new (); |
| 15217 | rn->info = bdistance; |
| 15218 | } |
| 15219 | |
| 15220 | /* Set distance value. */ |
| 15221 | bdistance->distance = distance; |
| 15222 | |
| 15223 | /* Reset access-list configuration. */ |
| 15224 | if (bdistance->access_list) |
| 15225 | { |
| 15226 | free (bdistance->access_list); |
| 15227 | bdistance->access_list = NULL; |
| 15228 | } |
| 15229 | if (access_list_str) |
| 15230 | bdistance->access_list = strdup (access_list_str); |
| 15231 | |
| 15232 | return CMD_SUCCESS; |
| 15233 | } |
| 15234 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15235 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 15236 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 15237 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15238 | { |
| 15239 | int ret; |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15240 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15241 | u_char distance; |
| 15242 | struct bgp_node *rn; |
| 15243 | struct bgp_distance *bdistance; |
| 15244 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15245 | ret = str2prefix (ip_str, &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15246 | if (ret == 0) |
| 15247 | { |
| 15248 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 15249 | return CMD_WARNING; |
| 15250 | } |
| 15251 | |
| 15252 | distance = atoi (distance_str); |
| 15253 | |
| 15254 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 15255 | if (! rn) |
| 15256 | { |
| 15257 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 15258 | return CMD_WARNING; |
| 15259 | } |
| 15260 | |
| 15261 | bdistance = rn->info; |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 15262 | |
| 15263 | if (bdistance->distance != distance) |
| 15264 | { |
| 15265 | vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); |
| 15266 | return CMD_WARNING; |
| 15267 | } |
| 15268 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15269 | if (bdistance->access_list) |
| 15270 | free (bdistance->access_list); |
| 15271 | bgp_distance_free (bdistance); |
| 15272 | |
| 15273 | rn->info = NULL; |
| 15274 | bgp_unlock_node (rn); |
| 15275 | bgp_unlock_node (rn); |
| 15276 | |
| 15277 | return CMD_SUCCESS; |
| 15278 | } |
| 15279 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15280 | /* Apply BGP information to distance method. */ |
| 15281 | u_char |
| 15282 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 15283 | { |
| 15284 | struct bgp_node *rn; |
| 15285 | struct prefix_ipv4 q; |
| 15286 | struct peer *peer; |
| 15287 | struct bgp_distance *bdistance; |
| 15288 | struct access_list *alist; |
| 15289 | struct bgp_static *bgp_static; |
| 15290 | |
| 15291 | if (! bgp) |
| 15292 | return 0; |
| 15293 | |
| 15294 | if (p->family != AF_INET) |
| 15295 | return 0; |
| 15296 | |
| 15297 | peer = rinfo->peer; |
| 15298 | |
| 15299 | if (peer->su.sa.sa_family != AF_INET) |
| 15300 | return 0; |
| 15301 | |
| 15302 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 15303 | q.family = AF_INET; |
| 15304 | q.prefix = peer->su.sin.sin_addr; |
| 15305 | q.prefixlen = IPV4_MAX_BITLEN; |
| 15306 | |
| 15307 | /* Check source address. */ |
| 15308 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 15309 | if (rn) |
| 15310 | { |
| 15311 | bdistance = rn->info; |
| 15312 | bgp_unlock_node (rn); |
| 15313 | |
| 15314 | if (bdistance->access_list) |
| 15315 | { |
| 15316 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 15317 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 15318 | return bdistance->distance; |
| 15319 | } |
| 15320 | else |
| 15321 | return bdistance->distance; |
| 15322 | } |
| 15323 | |
| 15324 | /* Backdoor check. */ |
| 15325 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 15326 | if (rn) |
| 15327 | { |
| 15328 | bgp_static = rn->info; |
| 15329 | bgp_unlock_node (rn); |
| 15330 | |
| 15331 | if (bgp_static->backdoor) |
| 15332 | { |
| 15333 | if (bgp->distance_local) |
| 15334 | return bgp->distance_local; |
| 15335 | else |
| 15336 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15337 | } |
| 15338 | } |
| 15339 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 15340 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15341 | { |
| 15342 | if (bgp->distance_ebgp) |
| 15343 | return bgp->distance_ebgp; |
| 15344 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 15345 | } |
| 15346 | else |
| 15347 | { |
| 15348 | if (bgp->distance_ibgp) |
| 15349 | return bgp->distance_ibgp; |
| 15350 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15351 | } |
| 15352 | } |
| 15353 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15354 | #ifdef HAVE_IPV6 |
| 15355 | /* Apply BGP information to ipv6 distance method. */ |
| 15356 | u_char |
| 15357 | ipv6_bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 15358 | { |
| 15359 | struct bgp_node *rn; |
| 15360 | struct prefix_ipv6 q; |
| 15361 | struct peer *peer; |
| 15362 | struct bgp_distance *bdistance; |
| 15363 | struct access_list *alist; |
| 15364 | struct bgp_static *bgp_static; |
| 15365 | |
| 15366 | if (! bgp) |
| 15367 | return 0; |
| 15368 | |
| 15369 | if (p->family != AF_INET6) |
| 15370 | return 0; |
| 15371 | |
| 15372 | peer = rinfo->peer; |
| 15373 | |
| 15374 | if (peer->su.sa.sa_family != AF_INET6) |
| 15375 | return 0; |
| 15376 | |
| 15377 | memset (&q, 0, sizeof (struct prefix_ipv6)); |
| 15378 | q.family = AF_INET; |
| 15379 | q.prefix = peer->su.sin6.sin6_addr; |
| 15380 | q.prefixlen = IPV6_MAX_BITLEN; |
| 15381 | |
| 15382 | /* Check source address. */ |
| 15383 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 15384 | if (rn) |
| 15385 | { |
| 15386 | bdistance = rn->info; |
| 15387 | bgp_unlock_node (rn); |
| 15388 | |
| 15389 | if (bdistance->access_list) |
| 15390 | { |
| 15391 | alist = access_list_lookup (AFI_IP6, bdistance->access_list); |
| 15392 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 15393 | return bdistance->distance; |
| 15394 | } |
| 15395 | else |
| 15396 | return bdistance->distance; |
| 15397 | } |
| 15398 | /* Backdoor check. */ |
| 15399 | rn = bgp_node_lookup (bgp->route[AFI_IP6][SAFI_UNICAST], p); |
| 15400 | if (rn) |
| 15401 | { |
| 15402 | bgp_static = rn->info; |
| 15403 | bgp_unlock_node (rn); |
| 15404 | |
| 15405 | if (bgp_static->backdoor) |
| 15406 | { |
| 15407 | if (bgp->ipv6_distance_local) |
| 15408 | return bgp->ipv6_distance_local; |
| 15409 | else |
| 15410 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15411 | } |
| 15412 | } |
| 15413 | |
| 15414 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 15415 | { |
| 15416 | if (bgp->ipv6_distance_ebgp) |
| 15417 | return bgp->ipv6_distance_ebgp; |
| 15418 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 15419 | } |
| 15420 | else |
| 15421 | { |
| 15422 | if (bgp->ipv6_distance_ibgp) |
| 15423 | return bgp->ipv6_distance_ibgp; |
| 15424 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15425 | } |
| 15426 | } |
| 15427 | #endif /* HAVE_IPV6 */ |
| 15428 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15429 | DEFUN (bgp_distance, |
| 15430 | bgp_distance_cmd, |
| 15431 | "distance bgp <1-255> <1-255> <1-255>", |
| 15432 | "Define an administrative distance\n" |
| 15433 | "BGP distance\n" |
| 15434 | "Distance for routes external to the AS\n" |
| 15435 | "Distance for routes internal to the AS\n" |
| 15436 | "Distance for local routes\n") |
| 15437 | { |
| 15438 | struct bgp *bgp; |
| 15439 | |
| 15440 | bgp = vty->index; |
| 15441 | |
| 15442 | bgp->distance_ebgp = atoi (argv[0]); |
| 15443 | bgp->distance_ibgp = atoi (argv[1]); |
| 15444 | bgp->distance_local = atoi (argv[2]); |
| 15445 | return CMD_SUCCESS; |
| 15446 | } |
| 15447 | |
| 15448 | DEFUN (no_bgp_distance, |
| 15449 | no_bgp_distance_cmd, |
| 15450 | "no distance bgp <1-255> <1-255> <1-255>", |
| 15451 | NO_STR |
| 15452 | "Define an administrative distance\n" |
| 15453 | "BGP distance\n" |
| 15454 | "Distance for routes external to the AS\n" |
| 15455 | "Distance for routes internal to the AS\n" |
| 15456 | "Distance for local routes\n") |
| 15457 | { |
| 15458 | struct bgp *bgp; |
| 15459 | |
| 15460 | bgp = vty->index; |
| 15461 | |
| 15462 | bgp->distance_ebgp= 0; |
| 15463 | bgp->distance_ibgp = 0; |
| 15464 | bgp->distance_local = 0; |
| 15465 | return CMD_SUCCESS; |
| 15466 | } |
| 15467 | |
| 15468 | ALIAS (no_bgp_distance, |
| 15469 | no_bgp_distance2_cmd, |
| 15470 | "no distance bgp", |
| 15471 | NO_STR |
| 15472 | "Define an administrative distance\n" |
| 15473 | "BGP distance\n") |
| 15474 | |
| 15475 | DEFUN (bgp_distance_source, |
| 15476 | bgp_distance_source_cmd, |
| 15477 | "distance <1-255> A.B.C.D/M", |
| 15478 | "Define an administrative distance\n" |
| 15479 | "Administrative distance\n" |
| 15480 | "IP source prefix\n") |
| 15481 | { |
| 15482 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 15483 | return CMD_SUCCESS; |
| 15484 | } |
| 15485 | |
| 15486 | DEFUN (no_bgp_distance_source, |
| 15487 | no_bgp_distance_source_cmd, |
| 15488 | "no distance <1-255> A.B.C.D/M", |
| 15489 | NO_STR |
| 15490 | "Define an administrative distance\n" |
| 15491 | "Administrative distance\n" |
| 15492 | "IP source prefix\n") |
| 15493 | { |
| 15494 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 15495 | return CMD_SUCCESS; |
| 15496 | } |
| 15497 | |
| 15498 | DEFUN (bgp_distance_source_access_list, |
| 15499 | bgp_distance_source_access_list_cmd, |
| 15500 | "distance <1-255> A.B.C.D/M WORD", |
| 15501 | "Define an administrative distance\n" |
| 15502 | "Administrative distance\n" |
| 15503 | "IP source prefix\n" |
| 15504 | "Access list name\n") |
| 15505 | { |
| 15506 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 15507 | return CMD_SUCCESS; |
| 15508 | } |
| 15509 | |
| 15510 | DEFUN (no_bgp_distance_source_access_list, |
| 15511 | no_bgp_distance_source_access_list_cmd, |
| 15512 | "no distance <1-255> A.B.C.D/M WORD", |
| 15513 | NO_STR |
| 15514 | "Define an administrative distance\n" |
| 15515 | "Administrative distance\n" |
| 15516 | "IP source prefix\n" |
| 15517 | "Access list name\n") |
| 15518 | { |
| 15519 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 15520 | return CMD_SUCCESS; |
| 15521 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15522 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15523 | #ifdef HAVE_IPV6 |
| 15524 | DEFUN (ipv6_bgp_distance, |
| 15525 | ipv6_bgp_distance_cmd, |
| 15526 | "distance bgp <1-255> <1-255> <1-255>", |
| 15527 | "Define an administrative distance\n" |
| 15528 | "BGP distance\n" |
| 15529 | "Distance for routes external to the AS\n" |
| 15530 | "Distance for routes internal to the AS\n" |
| 15531 | "Distance for local routes\n") |
| 15532 | { |
| 15533 | struct bgp *bgp; |
| 15534 | |
| 15535 | bgp = vty->index; |
| 15536 | |
| 15537 | bgp->ipv6_distance_ebgp = atoi (argv[0]); |
| 15538 | bgp->ipv6_distance_ibgp = atoi (argv[1]); |
| 15539 | bgp->ipv6_distance_local = atoi (argv[2]); |
| 15540 | return CMD_SUCCESS; |
| 15541 | } |
| 15542 | |
| 15543 | DEFUN (no_ipv6_bgp_distance, |
| 15544 | no_ipv6_bgp_distance_cmd, |
| 15545 | "no distance bgp <1-255> <1-255> <1-255>", |
| 15546 | NO_STR |
| 15547 | "Define an administrative distance\n" |
| 15548 | "BGP distance\n" |
| 15549 | "Distance for routes external to the AS\n" |
| 15550 | "Distance for routes internal to the AS\n" |
| 15551 | "Distance for local routes\n") |
| 15552 | { |
| 15553 | struct bgp *bgp; |
| 15554 | |
| 15555 | bgp = vty->index; |
| 15556 | |
| 15557 | bgp->ipv6_distance_ebgp= 0; |
| 15558 | bgp->ipv6_distance_ibgp = 0; |
| 15559 | bgp->ipv6_distance_local = 0; |
| 15560 | return CMD_SUCCESS; |
| 15561 | } |
| 15562 | |
| 15563 | ALIAS (no_ipv6_bgp_distance, |
| 15564 | no_ipv6_bgp_distance2_cmd, |
| 15565 | "no distance bgp", |
| 15566 | NO_STR |
| 15567 | "Define an administrative distance\n" |
| 15568 | "BGP distance\n") |
| 15569 | |
| 15570 | DEFUN (ipv6_bgp_distance_source, |
| 15571 | ipv6_bgp_distance_source_cmd, |
| 15572 | "distance <1-255> X:X::X:X/M", |
| 15573 | "Define an administrative distance\n" |
| 15574 | "Administrative distance\n" |
| 15575 | "IP source prefix\n") |
| 15576 | { |
| 15577 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 15578 | return CMD_SUCCESS; |
| 15579 | } |
| 15580 | |
| 15581 | DEFUN (no_ipv6_bgp_distance_source, |
| 15582 | no_ipv6_bgp_distance_source_cmd, |
| 15583 | "no distance <1-255> X:X::X:X/M", |
| 15584 | NO_STR |
| 15585 | "Define an administrative distance\n" |
| 15586 | "Administrative distance\n" |
| 15587 | "IP source prefix\n") |
| 15588 | { |
| 15589 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 15590 | return CMD_SUCCESS; |
| 15591 | } |
| 15592 | |
| 15593 | DEFUN (ipv6_bgp_distance_source_access_list, |
| 15594 | ipv6_bgp_distance_source_access_list_cmd, |
| 15595 | "distance <1-255> X:X::X:X/M WORD", |
| 15596 | "Define an administrative distance\n" |
| 15597 | "Administrative distance\n" |
| 15598 | "IP source prefix\n" |
| 15599 | "Access list name\n") |
| 15600 | { |
| 15601 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 15602 | return CMD_SUCCESS; |
| 15603 | } |
| 15604 | |
| 15605 | DEFUN (no_ipv6_bgp_distance_source_access_list, |
| 15606 | no_ipv6_bgp_distance_source_access_list_cmd, |
| 15607 | "no distance <1-255> X:X::X:X/M WORD", |
| 15608 | NO_STR |
| 15609 | "Define an administrative distance\n" |
| 15610 | "Administrative distance\n" |
| 15611 | "IP source prefix\n" |
| 15612 | "Access list name\n") |
| 15613 | { |
| 15614 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 15615 | return CMD_SUCCESS; |
| 15616 | } |
| 15617 | #endif |
| 15618 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15619 | DEFUN (bgp_damp_set, |
| 15620 | bgp_damp_set_cmd, |
| 15621 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 15622 | "BGP Specific commands\n" |
| 15623 | "Enable route-flap dampening\n" |
| 15624 | "Half-life time for the penalty\n" |
| 15625 | "Value to start reusing a route\n" |
| 15626 | "Value to start suppressing a route\n" |
| 15627 | "Maximum duration to suppress a stable route\n") |
| 15628 | { |
| 15629 | struct bgp *bgp; |
| 15630 | int half = DEFAULT_HALF_LIFE * 60; |
| 15631 | int reuse = DEFAULT_REUSE; |
| 15632 | int suppress = DEFAULT_SUPPRESS; |
| 15633 | int max = 4 * half; |
| 15634 | |
| 15635 | if (argc == 4) |
| 15636 | { |
| 15637 | half = atoi (argv[0]) * 60; |
| 15638 | reuse = atoi (argv[1]); |
| 15639 | suppress = atoi (argv[2]); |
| 15640 | max = atoi (argv[3]) * 60; |
| 15641 | } |
| 15642 | else if (argc == 1) |
| 15643 | { |
| 15644 | half = atoi (argv[0]) * 60; |
| 15645 | max = 4 * half; |
| 15646 | } |
| 15647 | |
| 15648 | bgp = vty->index; |
Balaji | aa7dbb1 | 2015-03-16 16:55:26 +0000 | [diff] [blame] | 15649 | |
| 15650 | if (suppress < reuse) |
| 15651 | { |
| 15652 | vty_out (vty, "Suppress value cannot be less than reuse value %s", |
| 15653 | VTY_NEWLINE); |
| 15654 | return 0; |
| 15655 | } |
| 15656 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15657 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 15658 | half, reuse, suppress, max); |
| 15659 | } |
| 15660 | |
| 15661 | ALIAS (bgp_damp_set, |
| 15662 | bgp_damp_set2_cmd, |
| 15663 | "bgp dampening <1-45>", |
| 15664 | "BGP Specific commands\n" |
| 15665 | "Enable route-flap dampening\n" |
| 15666 | "Half-life time for the penalty\n") |
| 15667 | |
| 15668 | ALIAS (bgp_damp_set, |
| 15669 | bgp_damp_set3_cmd, |
| 15670 | "bgp dampening", |
| 15671 | "BGP Specific commands\n" |
| 15672 | "Enable route-flap dampening\n") |
| 15673 | |
| 15674 | DEFUN (bgp_damp_unset, |
| 15675 | bgp_damp_unset_cmd, |
| 15676 | "no bgp dampening", |
| 15677 | NO_STR |
| 15678 | "BGP Specific commands\n" |
| 15679 | "Enable route-flap dampening\n") |
| 15680 | { |
| 15681 | struct bgp *bgp; |
| 15682 | |
| 15683 | bgp = vty->index; |
| 15684 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 15685 | } |
| 15686 | |
| 15687 | ALIAS (bgp_damp_unset, |
| 15688 | bgp_damp_unset2_cmd, |
| 15689 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 15690 | NO_STR |
| 15691 | "BGP Specific commands\n" |
| 15692 | "Enable route-flap dampening\n" |
| 15693 | "Half-life time for the penalty\n" |
| 15694 | "Value to start reusing a route\n" |
| 15695 | "Value to start suppressing a route\n" |
| 15696 | "Maximum duration to suppress a stable route\n") |
| 15697 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15698 | DEFUN (show_ip_bgp_dampened_paths, |
| 15699 | show_ip_bgp_dampened_paths_cmd, |
| 15700 | "show ip bgp dampened-paths", |
| 15701 | SHOW_STR |
| 15702 | IP_STR |
| 15703 | BGP_STR |
| 15704 | "Display paths suppressed due to dampening\n") |
| 15705 | { |
| 15706 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 15707 | NULL); |
| 15708 | } |
| 15709 | |
| 15710 | ALIAS (show_ip_bgp_dampened_paths, |
| 15711 | show_ip_bgp_damp_dampened_paths_cmd, |
| 15712 | "show ip bgp dampening dampened-paths", |
| 15713 | SHOW_STR |
| 15714 | IP_STR |
| 15715 | BGP_STR |
| 15716 | "Display detailed information about dampening\n" |
| 15717 | "Display paths suppressed due to dampening\n") |
| 15718 | |
| 15719 | DEFUN (show_ip_bgp_flap_statistics, |
| 15720 | show_ip_bgp_flap_statistics_cmd, |
| 15721 | "show ip bgp flap-statistics", |
| 15722 | SHOW_STR |
| 15723 | IP_STR |
| 15724 | BGP_STR |
| 15725 | "Display flap statistics of routes\n") |
| 15726 | { |
| 15727 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 15728 | bgp_show_type_flap_statistics, NULL); |
| 15729 | } |
| 15730 | |
| 15731 | ALIAS (show_ip_bgp_flap_statistics, |
| 15732 | show_ip_bgp_damp_flap_statistics_cmd, |
| 15733 | "show ip bgp dampening flap-statistics", |
| 15734 | SHOW_STR |
| 15735 | IP_STR |
| 15736 | BGP_STR |
| 15737 | "Display detailed information about dampening\n" |
| 15738 | "Display flap statistics of routes\n") |
| 15739 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15740 | DEFUN (show_bgp_ipv4_safi_dampened_paths, |
| 15741 | show_bgp_ipv4_safi_dampened_paths_cmd, |
| 15742 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15743 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15744 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15745 | IP_STR |
| 15746 | "Address Family modifier\n" |
| 15747 | "Address Family modifier\n" |
| 15748 | "Address Family modifier\n" |
| 15749 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15750 | "Display paths suppressed due to dampening\n") |
| 15751 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15752 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15753 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15754 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15755 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15756 | return CMD_WARNING; |
| 15757 | } |
| 15758 | |
| 15759 | return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL); |
| 15760 | } |
| 15761 | ALIAS (show_bgp_ipv4_safi_dampened_paths, |
| 15762 | show_bgp_ipv4_safi_damp_dampened_paths_cmd, |
| 15763 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15764 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15765 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15766 | IP_STR |
| 15767 | "Address Family modifier\n" |
| 15768 | "Address Family modifier\n" |
| 15769 | "Address Family modifier\n" |
| 15770 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15771 | "Display detailed information about dampening\n" |
| 15772 | "Display paths suppressed due to dampening\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 15773 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15774 | DEFUN (show_bgp_ipv6_safi_dampened_paths, |
| 15775 | show_bgp_ipv6_safi_dampened_paths_cmd, |
| 15776 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15777 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15778 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15779 | IPV6_STR |
| 15780 | "Address Family modifier\n" |
| 15781 | "Address Family modifier\n" |
| 15782 | "Address Family modifier\n" |
| 15783 | "Address Family modifier\n" |
| 15784 | "Display paths suppressed due to dampening\n") |
| 15785 | { |
| 15786 | safi_t safi; |
| 15787 | |
| 15788 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15789 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15790 | return CMD_WARNING; |
| 15791 | } |
| 15792 | |
| 15793 | return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL); |
| 15794 | } |
| 15795 | ALIAS (show_bgp_ipv6_safi_dampened_paths, |
| 15796 | show_bgp_ipv6_safi_damp_dampened_paths_cmd, |
| 15797 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths", |
| 15798 | SHOW_STR |
| 15799 | BGP_STR |
| 15800 | IPV6_STR |
| 15801 | "Address Family modifier\n" |
| 15802 | "Address Family modifier\n" |
| 15803 | "Address Family modifier\n" |
| 15804 | "Address Family modifier\n" |
| 15805 | "Display detailed information about dampening\n" |
| 15806 | "Display paths suppressed due to dampening\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15807 | |
| 15808 | DEFUN (show_bgp_ipv4_safi_flap_statistics, |
| 15809 | show_bgp_ipv4_safi_flap_statistics_cmd, |
| 15810 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics", |
| 15811 | SHOW_STR |
| 15812 | BGP_STR |
| 15813 | "Address Family\n" |
| 15814 | "Address Family modifier\n" |
| 15815 | "Address Family modifier\n" |
| 15816 | "Address Family modifier\n" |
| 15817 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15818 | "Display flap statistics of routes\n") |
| 15819 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15820 | safi_t safi; |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15821 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15822 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15823 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15824 | return CMD_WARNING; |
| 15825 | } |
| 15826 | |
| 15827 | return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL); |
| 15828 | } |
| 15829 | ALIAS (show_bgp_ipv4_safi_flap_statistics, |
| 15830 | show_bgp_ipv4_safi_damp_flap_statistics_cmd, |
| 15831 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15832 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15833 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15834 | "Address Family\n" |
| 15835 | "Address Family modifier\n" |
| 15836 | "Address Family modifier\n" |
| 15837 | "Address Family modifier\n" |
| 15838 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15839 | "Display detailed information about dampening\n" |
| 15840 | "Display flap statistics of routes\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 15841 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15842 | DEFUN (show_bgp_ipv6_safi_flap_statistics, |
| 15843 | show_bgp_ipv6_safi_flap_statistics_cmd, |
| 15844 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics", |
| 15845 | SHOW_STR |
| 15846 | BGP_STR |
| 15847 | "Address Family\n" |
| 15848 | "Address Family modifier\n" |
| 15849 | "Address Family modifier\n" |
| 15850 | "Address Family modifier\n" |
| 15851 | "Address Family modifier\n" |
| 15852 | "Display flap statistics of routes\n") |
| 15853 | { |
| 15854 | safi_t safi; |
| 15855 | |
| 15856 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15857 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15858 | return CMD_WARNING; |
| 15859 | } |
| 15860 | |
| 15861 | return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL); |
| 15862 | } |
| 15863 | ALIAS (show_bgp_ipv6_safi_flap_statistics, |
| 15864 | show_bgp_ipv6_safi_damp_flap_statistics_cmd, |
| 15865 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics", |
| 15866 | SHOW_STR |
| 15867 | BGP_STR |
| 15868 | "Address Family\n" |
| 15869 | "Address Family modifier\n" |
| 15870 | "Address Family modifier\n" |
| 15871 | "Address Family modifier\n" |
| 15872 | "Address Family modifier\n" |
| 15873 | "Display detailed information about dampening\n" |
| 15874 | "Display flap statistics of routes\n") |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15875 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15876 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15877 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 15878 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 15879 | const char *ip_str, afi_t afi, safi_t safi, |
| 15880 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15881 | { |
| 15882 | int ret; |
| 15883 | struct prefix match; |
| 15884 | struct bgp_node *rn; |
| 15885 | struct bgp_node *rm; |
| 15886 | struct bgp_info *ri; |
| 15887 | struct bgp_info *ri_temp; |
| 15888 | struct bgp *bgp; |
| 15889 | struct bgp_table *table; |
| 15890 | |
| 15891 | /* BGP structure lookup. */ |
| 15892 | if (view_name) |
| 15893 | { |
| 15894 | bgp = bgp_lookup_by_name (view_name); |
| 15895 | if (bgp == NULL) |
| 15896 | { |
| 15897 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 15898 | return CMD_WARNING; |
| 15899 | } |
| 15900 | } |
| 15901 | else |
| 15902 | { |
| 15903 | bgp = bgp_get_default (); |
| 15904 | if (bgp == NULL) |
| 15905 | { |
| 15906 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 15907 | return CMD_WARNING; |
| 15908 | } |
| 15909 | } |
| 15910 | |
| 15911 | /* Check IP address argument. */ |
| 15912 | ret = str2prefix (ip_str, &match); |
| 15913 | if (! ret) |
| 15914 | { |
| 15915 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 15916 | return CMD_WARNING; |
| 15917 | } |
| 15918 | |
| 15919 | match.family = afi2family (afi); |
| 15920 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15921 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15922 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15923 | 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] | 15924 | { |
| 15925 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 15926 | continue; |
| 15927 | |
| 15928 | if ((table = rn->info) != NULL) |
| 15929 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 15930 | { |
| 15931 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 15932 | { |
| 15933 | ri = rm->info; |
| 15934 | while (ri) |
| 15935 | { |
| 15936 | if (ri->extra && ri->extra->damp_info) |
| 15937 | { |
| 15938 | ri_temp = ri->next; |
| 15939 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 15940 | ri = ri_temp; |
| 15941 | } |
| 15942 | else |
| 15943 | ri = ri->next; |
| 15944 | } |
| 15945 | } |
| 15946 | |
| 15947 | bgp_unlock_node (rm); |
| 15948 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15949 | } |
| 15950 | } |
| 15951 | else |
| 15952 | { |
| 15953 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 15954 | { |
| 15955 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 15956 | { |
| 15957 | ri = rn->info; |
| 15958 | while (ri) |
| 15959 | { |
| 15960 | if (ri->extra && ri->extra->damp_info) |
| 15961 | { |
| 15962 | ri_temp = ri->next; |
| 15963 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 15964 | ri = ri_temp; |
| 15965 | } |
| 15966 | else |
| 15967 | ri = ri->next; |
| 15968 | } |
| 15969 | } |
| 15970 | |
| 15971 | bgp_unlock_node (rn); |
| 15972 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15973 | } |
| 15974 | |
| 15975 | return CMD_SUCCESS; |
| 15976 | } |
| 15977 | |
| 15978 | DEFUN (clear_ip_bgp_dampening, |
| 15979 | clear_ip_bgp_dampening_cmd, |
| 15980 | "clear ip bgp dampening", |
| 15981 | CLEAR_STR |
| 15982 | IP_STR |
| 15983 | BGP_STR |
| 15984 | "Clear route flap dampening information\n") |
| 15985 | { |
| 15986 | bgp_damp_info_clean (); |
| 15987 | return CMD_SUCCESS; |
| 15988 | } |
| 15989 | |
| 15990 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 15991 | clear_ip_bgp_dampening_prefix_cmd, |
| 15992 | "clear ip bgp dampening A.B.C.D/M", |
| 15993 | CLEAR_STR |
| 15994 | IP_STR |
| 15995 | BGP_STR |
| 15996 | "Clear route flap dampening information\n" |
| 15997 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 15998 | { |
| 15999 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 16000 | SAFI_UNICAST, NULL, 1); |
| 16001 | } |
| 16002 | |
| 16003 | DEFUN (clear_ip_bgp_dampening_address, |
| 16004 | clear_ip_bgp_dampening_address_cmd, |
| 16005 | "clear ip bgp dampening A.B.C.D", |
| 16006 | CLEAR_STR |
| 16007 | IP_STR |
| 16008 | BGP_STR |
| 16009 | "Clear route flap dampening information\n" |
| 16010 | "Network to clear damping information\n") |
| 16011 | { |
| 16012 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 16013 | SAFI_UNICAST, NULL, 0); |
| 16014 | } |
| 16015 | |
| 16016 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 16017 | clear_ip_bgp_dampening_address_mask_cmd, |
| 16018 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 16019 | CLEAR_STR |
| 16020 | IP_STR |
| 16021 | BGP_STR |
| 16022 | "Clear route flap dampening information\n" |
| 16023 | "Network to clear damping information\n" |
| 16024 | "Network mask\n") |
| 16025 | { |
| 16026 | int ret; |
| 16027 | char prefix_str[BUFSIZ]; |
| 16028 | |
| 16029 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 16030 | if (! ret) |
| 16031 | { |
| 16032 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 16033 | return CMD_WARNING; |
| 16034 | } |
| 16035 | |
| 16036 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 16037 | SAFI_UNICAST, NULL, 0); |
| 16038 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 16039 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 16040 | /* also used for encap safi */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 16041 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16042 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 16043 | afi_t afi, safi_t safi, int *write) |
| 16044 | { |
| 16045 | struct bgp_node *prn; |
| 16046 | struct bgp_node *rn; |
| 16047 | struct bgp_table *table; |
| 16048 | struct prefix *p; |
| 16049 | struct prefix_rd *prd; |
| 16050 | struct bgp_static *bgp_static; |
| 16051 | u_int32_t label; |
| 16052 | char buf[SU_ADDRSTRLEN]; |
| 16053 | char rdbuf[RD_ADDRSTRLEN]; |
| 16054 | |
| 16055 | /* Network configuration. */ |
| 16056 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 16057 | if ((table = prn->info) != NULL) |
| 16058 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 16059 | if ((bgp_static = rn->info) != NULL) |
| 16060 | { |
| 16061 | p = &rn->p; |
| 16062 | prd = (struct prefix_rd *) &prn->p; |
| 16063 | |
| 16064 | /* "address-family" display. */ |
| 16065 | bgp_config_write_family_header (vty, afi, safi, write); |
| 16066 | |
| 16067 | /* "network" configuration display. */ |
| 16068 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 16069 | label = decode_label (bgp_static->tag); |
| 16070 | |
| 16071 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 16072 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16073 | p->prefixlen, |
| 16074 | rdbuf, label); |
| 16075 | vty_out (vty, "%s", VTY_NEWLINE); |
| 16076 | } |
| 16077 | return 0; |
| 16078 | } |
| 16079 | |
| 16080 | /* Configuration of static route announcement and aggregate |
| 16081 | information. */ |
| 16082 | int |
| 16083 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 16084 | afi_t afi, safi_t safi, int *write) |
| 16085 | { |
| 16086 | struct bgp_node *rn; |
| 16087 | struct prefix *p; |
| 16088 | struct bgp_static *bgp_static; |
| 16089 | struct bgp_aggregate *bgp_aggregate; |
| 16090 | char buf[SU_ADDRSTRLEN]; |
| 16091 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 16092 | if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16093 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 16094 | |
| 16095 | /* Network configuration. */ |
| 16096 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 16097 | if ((bgp_static = rn->info) != NULL) |
| 16098 | { |
| 16099 | p = &rn->p; |
| 16100 | |
| 16101 | /* "address-family" display. */ |
| 16102 | bgp_config_write_family_header (vty, afi, safi, write); |
| 16103 | |
| 16104 | /* "network" configuration display. */ |
| 16105 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 16106 | { |
| 16107 | u_int32_t destination; |
| 16108 | struct in_addr netmask; |
| 16109 | |
| 16110 | destination = ntohl (p->u.prefix4.s_addr); |
| 16111 | masklen2ip (p->prefixlen, &netmask); |
| 16112 | vty_out (vty, " network %s", |
| 16113 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 16114 | |
| 16115 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 16116 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 16117 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 16118 | || p->u.prefix4.s_addr == 0) |
| 16119 | { |
| 16120 | /* Natural mask is not display. */ |
| 16121 | } |
| 16122 | else |
| 16123 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 16124 | } |
| 16125 | else |
| 16126 | { |
| 16127 | vty_out (vty, " network %s/%d", |
| 16128 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16129 | p->prefixlen); |
| 16130 | } |
| 16131 | |
| 16132 | if (bgp_static->rmap.name) |
| 16133 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 16134 | else |
| 16135 | { |
| 16136 | if (bgp_static->backdoor) |
| 16137 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 16138 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16139 | |
| 16140 | vty_out (vty, "%s", VTY_NEWLINE); |
| 16141 | } |
| 16142 | |
| 16143 | /* Aggregate-address configuration. */ |
| 16144 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 16145 | if ((bgp_aggregate = rn->info) != NULL) |
| 16146 | { |
| 16147 | p = &rn->p; |
| 16148 | |
| 16149 | /* "address-family" display. */ |
| 16150 | bgp_config_write_family_header (vty, afi, safi, write); |
| 16151 | |
| 16152 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 16153 | { |
| 16154 | struct in_addr netmask; |
| 16155 | |
| 16156 | masklen2ip (p->prefixlen, &netmask); |
| 16157 | vty_out (vty, " aggregate-address %s %s", |
| 16158 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16159 | inet_ntoa (netmask)); |
| 16160 | } |
| 16161 | else |
| 16162 | { |
| 16163 | vty_out (vty, " aggregate-address %s/%d", |
| 16164 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16165 | p->prefixlen); |
| 16166 | } |
| 16167 | |
| 16168 | if (bgp_aggregate->as_set) |
| 16169 | vty_out (vty, " as-set"); |
| 16170 | |
| 16171 | if (bgp_aggregate->summary_only) |
| 16172 | vty_out (vty, " summary-only"); |
| 16173 | |
| 16174 | vty_out (vty, "%s", VTY_NEWLINE); |
| 16175 | } |
| 16176 | |
| 16177 | return 0; |
| 16178 | } |
| 16179 | |
| 16180 | int |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16181 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp, |
| 16182 | afi_t afi, safi_t safi, int *write) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16183 | { |
| 16184 | struct bgp_node *rn; |
| 16185 | struct bgp_distance *bdistance; |
| 16186 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16187 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 16188 | { |
| 16189 | /* Distance configuration. */ |
| 16190 | if (bgp->distance_ebgp |
| 16191 | && bgp->distance_ibgp |
| 16192 | && bgp->distance_local |
| 16193 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 16194 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 16195 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 16196 | vty_out (vty, " distance bgp %d %d %d%s", |
| 16197 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 16198 | VTY_NEWLINE); |
| 16199 | |
| 16200 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 16201 | if ((bdistance = rn->info) != NULL) |
| 16202 | { |
| 16203 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 16204 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 16205 | bdistance->access_list ? bdistance->access_list : "", |
| 16206 | VTY_NEWLINE); |
| 16207 | } |
| 16208 | } |
| 16209 | |
| 16210 | #ifdef HAVE_IPV6 |
| 16211 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
| 16212 | { |
| 16213 | bgp_config_write_family_header (vty, afi, safi, write); |
| 16214 | if (bgp->ipv6_distance_ebgp |
| 16215 | && bgp->ipv6_distance_ibgp |
| 16216 | && bgp->ipv6_distance_local |
| 16217 | && (bgp->ipv6_distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 16218 | || bgp->ipv6_distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 16219 | || bgp->ipv6_distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 16220 | vty_out (vty, " distance bgp %d %d %d%s", |
| 16221 | bgp->ipv6_distance_ebgp, bgp->ipv6_distance_ibgp, bgp->ipv6_distance_local, |
| 16222 | VTY_NEWLINE); |
| 16223 | |
| 16224 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 16225 | if ((bdistance = rn->info) != NULL) |
| 16226 | { |
| 16227 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 16228 | inet6_ntoa (rn->p.u.prefix6), rn->p.prefixlen, |
| 16229 | bdistance->access_list ? bdistance->access_list : "", |
| 16230 | VTY_NEWLINE); |
| 16231 | } |
| 16232 | } |
| 16233 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16234 | |
| 16235 | return 0; |
| 16236 | } |
| 16237 | |
| 16238 | /* Allocate routing table structure and install commands. */ |
| 16239 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 16240 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16241 | { |
| 16242 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 16243 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16244 | |
| 16245 | /* IPv4 BGP commands. */ |
| 16246 | install_element (BGP_NODE, &bgp_network_cmd); |
| 16247 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 16248 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 16249 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 16250 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 16251 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 16252 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 16253 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 16254 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 16255 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 16256 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 16257 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 16258 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 16259 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 16260 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 16261 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 16262 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 16263 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 16264 | |
| 16265 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 16266 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 16267 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 16268 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 16269 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 16270 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 16271 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 16272 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 16273 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 16274 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 16275 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 16276 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 16277 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 16278 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 16279 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 16280 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 16281 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 16282 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 16283 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 16284 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16285 | |
| 16286 | /* IPv4 unicast configuration. */ |
| 16287 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 16288 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 16289 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 16290 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 16291 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 16292 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16293 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16294 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 16295 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 16296 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 16297 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 16298 | 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] | 16299 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16300 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 16301 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 16302 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 16303 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 16304 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 16305 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 16306 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 16307 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 16308 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 16309 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 16310 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 16311 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 16312 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 16313 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 16314 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 16315 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 16316 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 16317 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 16318 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 16319 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16320 | |
| 16321 | /* IPv4 multicast configuration. */ |
| 16322 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 16323 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 16324 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 16325 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 16326 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 16327 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 16328 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 16329 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 16330 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 16331 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 16332 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 16333 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 16334 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 16335 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 16336 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 16337 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 16338 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 16339 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 16340 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 16341 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 16342 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 16343 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 16344 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 16345 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 16346 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 16347 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 16348 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 16349 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 16350 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 16351 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 16352 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 16353 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16354 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16355 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16356 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16357 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd); |
| 16358 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd); |
| 16359 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); |
| 16360 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); |
| 16361 | install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd); |
| 16362 | install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd); |
| 16363 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd); |
| 16364 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd); |
| 16365 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16366 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16367 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd); |
| 16368 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd); |
| 16369 | install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd); |
| 16370 | install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd); |
| 16371 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); |
| 16372 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); |
| 16373 | install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd); |
| 16374 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd); |
| 16375 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd); |
| 16376 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd); |
| 16377 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd); |
| 16378 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd); |
| 16379 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd); |
| 16380 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd); |
| 16381 | install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd); |
| 16382 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd); |
| 16383 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd); |
| 16384 | install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd); |
| 16385 | install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd); |
| 16386 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd); |
| 16387 | install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd); |
| 16388 | install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd); |
| 16389 | install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd); |
| 16390 | install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd); |
| 16391 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd); |
| 16392 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd); |
| 16393 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd); |
| 16394 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16395 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 16396 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 16397 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 16398 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 16399 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16400 | install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd); |
| 16401 | install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd); |
| 16402 | install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd); |
| 16403 | install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd); |
| 16404 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd); |
| 16405 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd); |
| 16406 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd); |
| 16407 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd); |
| 16408 | install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd); |
| 16409 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd); |
| 16410 | install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd); |
| 16411 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd); |
| 16412 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd); |
| 16413 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd); |
| 16414 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd); |
| 16415 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd); |
| 16416 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd); |
| 16417 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd); |
| 16418 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16419 | 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] | 16420 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd); |
| 16421 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd); |
| 16422 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd); |
| 16423 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd); |
| 16424 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd); |
| 16425 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd); |
| 16426 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd); |
| 16427 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd); |
| 16428 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd); |
| 16429 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd); |
| 16430 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd); |
| 16431 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd); |
| 16432 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd); |
| 16433 | install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd); |
| 16434 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd); |
| 16435 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd); |
| 16436 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd); |
| 16437 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd); |
| 16438 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd); |
| 16439 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd); |
| 16440 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd); |
| 16441 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd); |
| 16442 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd); |
| 16443 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd); |
| 16444 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd); |
| 16445 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd); |
| 16446 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd); |
| 16447 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd); |
| 16448 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd); |
| 16449 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd); |
| 16450 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd); |
| 16451 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd); |
| 16452 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd); |
| 16453 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd); |
| 16454 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd); |
| 16455 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd); |
| 16456 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd); |
| 16457 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd); |
| 16458 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd); |
| 16459 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd); |
| 16460 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd); |
| 16461 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd); |
| 16462 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd); |
| 16463 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd); |
| 16464 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16465 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16466 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16467 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16468 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16469 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16470 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16471 | |
| 16472 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16473 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16474 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); |
| 16475 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); |
| 16476 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd); |
| 16477 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd); |
| 16478 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16479 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16480 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd); |
| 16481 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd); |
| 16482 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd); |
| 16483 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd); |
| 16484 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); |
| 16485 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); |
| 16486 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd); |
| 16487 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd); |
| 16488 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd); |
| 16489 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd); |
| 16490 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd); |
| 16491 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd); |
| 16492 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd); |
| 16493 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd); |
| 16494 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd); |
| 16495 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16496 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 16497 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 16498 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 16499 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 16500 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16501 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd); |
| 16502 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd); |
| 16503 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd); |
| 16504 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd); |
| 16505 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd); |
| 16506 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd); |
| 16507 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd); |
| 16508 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16509 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16510 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16511 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16512 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16513 | |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16514 | /* BGP dampening clear commands */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16515 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 16516 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 16517 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 16518 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 16519 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16520 | /* New config IPv6 BGP commands. */ |
| 16521 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 16522 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 16523 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 16524 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 16525 | |
| 16526 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 16527 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 16528 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 16529 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 16530 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 16531 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 16532 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 16533 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16534 | /* Old config IPv6 BGP commands. */ |
| 16535 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 16536 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 16537 | |
| 16538 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 16539 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 16540 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 16541 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 16542 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16543 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16544 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16545 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16546 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16547 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16548 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16549 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16550 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16551 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16552 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd); |
| 16553 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd); |
| 16554 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd); |
| 16555 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd); |
| 16556 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd); |
| 16557 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd); |
| 16558 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd); |
| 16559 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16560 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16561 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16562 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16563 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16564 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16565 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16566 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16567 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16568 | install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd); |
| 16569 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16570 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16571 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16572 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16573 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16574 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16575 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16576 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16577 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16578 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16579 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16580 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16581 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16582 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16583 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16584 | install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd); |
| 16585 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16586 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16587 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16588 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16589 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16590 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16591 | |
| 16592 | /* Restricted: |
| 16593 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 16594 | */ |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16595 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16596 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16597 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16598 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16599 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd); |
| 16600 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd); |
| 16601 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd); |
| 16602 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd); |
| 16603 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd); |
| 16604 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd); |
| 16605 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd); |
| 16606 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd); |
| 16607 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16608 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16609 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16610 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16611 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16612 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16613 | 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] | 16614 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16615 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16616 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16617 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16618 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 16619 | /* Statistics */ |
| 16620 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16621 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16622 | |
| 16623 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 16624 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 16625 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 16626 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 16627 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 16628 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 16629 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16630 | #ifdef HAVE_IPV6 |
| 16631 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_cmd); |
| 16632 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_cmd); |
| 16633 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance2_cmd); |
| 16634 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_cmd); |
| 16635 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_cmd); |
| 16636 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_access_list_cmd); |
| 16637 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_access_list_cmd); |
| 16638 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16639 | |
| 16640 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 16641 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 16642 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 16643 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 16644 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 16645 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 16646 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 16647 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 16648 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 16649 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Balaji | 9145f0e | 2016-01-20 22:59:27 +0530 | [diff] [blame] | 16650 | |
| 16651 | /* IPv4 Multicast Mode */ |
| 16652 | install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd); |
| 16653 | install_element (BGP_IPV4M_NODE, &bgp_damp_set2_cmd); |
| 16654 | install_element (BGP_IPV4M_NODE, &bgp_damp_set3_cmd); |
| 16655 | install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd); |
| 16656 | install_element (BGP_IPV4M_NODE, &bgp_damp_unset2_cmd); |
| 16657 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16658 | |
| 16659 | /* Deprecated AS-Pathlimit commands */ |
| 16660 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 16661 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 16662 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16663 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16664 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16665 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16666 | |
| 16667 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 16668 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16669 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16670 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16671 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16672 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16673 | |
| 16674 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 16675 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 16676 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16677 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16678 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16679 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16680 | |
| 16681 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 16682 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16683 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16684 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16685 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16686 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16687 | |
| 16688 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 16689 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 16690 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16691 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16692 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16693 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16694 | |
| 16695 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 16696 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16697 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16698 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16699 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16700 | 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] | 16701 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16702 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 16703 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16704 | |
| 16705 | /* old style commands */ |
| 16706 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 16707 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 16708 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16709 | install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd); |
| 16710 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16711 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 16712 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 16713 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 16714 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 16715 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16716 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
| 16717 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); |
| 16718 | install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16719 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 16720 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 16721 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 16722 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 16723 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 16724 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 16725 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 16726 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 16727 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 16728 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 16729 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 16730 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 16731 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 16732 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 16733 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 16734 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 16735 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 16736 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 16737 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 16738 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 16739 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 16740 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 16741 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 16742 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 16743 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 16744 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 16745 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 16746 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 16747 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 16748 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 16749 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 16750 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 16751 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 16752 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 16753 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 16754 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 16755 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 16756 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 16757 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 16758 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 16759 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 16760 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 16761 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 16762 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 16763 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 16764 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 16765 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 16766 | install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 16767 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16768 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 16769 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd); |
| 16770 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16771 | install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
| 16772 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 16773 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
| 16774 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 16775 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd); |
| 16776 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 16777 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 16778 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
| 16779 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 16780 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 16781 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
| 16782 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 16783 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
| 16784 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 16785 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
| 16786 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 16787 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
| 16788 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 16789 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
| 16790 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
| 16791 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 16792 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 16793 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 16794 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
| 16795 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 16796 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 16797 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16798 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16799 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16800 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd); |
| 16801 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16802 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 16803 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 16804 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 16805 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16806 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
| 16807 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); |
| 16808 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16809 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 16810 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 16811 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 16812 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 16813 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 16814 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 16815 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 16816 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 16817 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 16818 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 16819 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 16820 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 16821 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 16822 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 16823 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 16824 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 16825 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 16826 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 16827 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 16828 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 16829 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 16830 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 16831 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 16832 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16833 | |
| 16834 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 16835 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 16836 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16837 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16838 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 16839 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 16840 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 16841 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16842 | install_element (VIEW_NODE, &show_bgp_route_pathtype_cmd); |
| 16843 | install_element (VIEW_NODE, &show_bgp_ipv6_route_pathtype_cmd); |
| 16844 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); |
| 16845 | install_element (VIEW_NODE, &show_bgp_prefix_pathtype_cmd); |
| 16846 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); |
| 16847 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16848 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 16849 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 16850 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 16851 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 16852 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 16853 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 16854 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 16855 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 16856 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 16857 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 16858 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 16859 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 16860 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 16861 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 16862 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd); |
| 16863 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 16864 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd); |
| 16865 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 16866 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 16867 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 16868 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 16869 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 16870 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 16871 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 16872 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
| 16873 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 16874 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 16875 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 16876 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 16877 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 16878 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 16879 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 16880 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 16881 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 16882 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16883 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16884 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 16885 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16886 | install_element (RESTRICTED_NODE, &show_bgp_route_pathtype_cmd); |
| 16887 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_pathtype_cmd); |
| 16888 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); |
| 16889 | install_element (RESTRICTED_NODE, &show_bgp_prefix_pathtype_cmd); |
| 16890 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); |
| 16891 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16892 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 16893 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 16894 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 16895 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 16896 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 16897 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 16898 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 16899 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 16900 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 16901 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 16902 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16903 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16904 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 16905 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16906 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16907 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 16908 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 16909 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 16910 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 16911 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 16912 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 16913 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 16914 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 16915 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 16916 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 16917 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 16918 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 16919 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 16920 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 16921 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 16922 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 16923 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 16924 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 16925 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 16926 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 16927 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 16928 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 16929 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 16930 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 16931 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 16932 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 16933 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 16934 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 16935 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 16936 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 16937 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 16938 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 16939 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 16940 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 16941 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 16942 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16943 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16944 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16945 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16946 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16947 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16948 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16949 | /* old with name safi collision */ |
| 16950 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 16951 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 16952 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 16953 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 16954 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 16955 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 16956 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 16957 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 16958 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 16959 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 16960 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 16961 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 16962 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 16963 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 16964 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 16965 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16966 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16967 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 16968 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16969 | |
| 16970 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
| 16971 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
| 16972 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
| 16973 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16974 | |
| 16975 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
| 16976 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
| 16977 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
| 16978 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16979 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 16980 | |
| 16981 | void |
| 16982 | bgp_route_finish (void) |
| 16983 | { |
| 16984 | bgp_table_unlock (bgp_distance_table); |
| 16985 | bgp_distance_table = NULL; |
| 16986 | } |