paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* BGP routing information |
| 2 | Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro |
| 3 | |
| 4 | This file is part of GNU Zebra. |
| 5 | |
| 6 | GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | under the terms of the GNU General Public License as published by the |
| 8 | Free Software Foundation; either version 2, or (at your option) any |
| 9 | later version. |
| 10 | |
| 11 | GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 19 | 02111-1307, USA. */ |
| 20 | |
| 21 | #include <zebra.h> |
| 22 | |
| 23 | #include "prefix.h" |
| 24 | #include "linklist.h" |
| 25 | #include "memory.h" |
| 26 | #include "command.h" |
| 27 | #include "stream.h" |
| 28 | #include "filter.h" |
| 29 | #include "str.h" |
| 30 | #include "log.h" |
| 31 | #include "routemap.h" |
| 32 | #include "buffer.h" |
| 33 | #include "sockunion.h" |
| 34 | #include "plist.h" |
| 35 | #include "thread.h" |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 36 | #include "workqueue.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 37 | |
| 38 | #include "bgpd/bgpd.h" |
| 39 | #include "bgpd/bgp_table.h" |
| 40 | #include "bgpd/bgp_route.h" |
| 41 | #include "bgpd/bgp_attr.h" |
| 42 | #include "bgpd/bgp_debug.h" |
| 43 | #include "bgpd/bgp_aspath.h" |
| 44 | #include "bgpd/bgp_regex.h" |
| 45 | #include "bgpd/bgp_community.h" |
| 46 | #include "bgpd/bgp_ecommunity.h" |
| 47 | #include "bgpd/bgp_clist.h" |
| 48 | #include "bgpd/bgp_packet.h" |
| 49 | #include "bgpd/bgp_filter.h" |
| 50 | #include "bgpd/bgp_fsm.h" |
| 51 | #include "bgpd/bgp_mplsvpn.h" |
| 52 | #include "bgpd/bgp_nexthop.h" |
| 53 | #include "bgpd/bgp_damp.h" |
| 54 | #include "bgpd/bgp_advertise.h" |
| 55 | #include "bgpd/bgp_zebra.h" |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 56 | #include "bgpd/bgp_vty.h" |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 57 | #include "bgpd/bgp_mpath.h" |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 58 | #include "bgpd/bgp_nht.c" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 59 | |
| 60 | /* Extern from bgp_dump.c */ |
Stephen Hemminger | dde7258 | 2009-05-08 15:19:07 -0700 | [diff] [blame] | 61 | extern const char *bgp_origin_str[]; |
| 62 | extern const char *bgp_origin_long_str[]; |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 63 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 64 | static struct bgp_node * |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 65 | bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 66 | struct prefix_rd *prd) |
| 67 | { |
| 68 | struct bgp_node *rn; |
| 69 | struct bgp_node *prn = NULL; |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 70 | |
| 71 | assert (table); |
| 72 | if (!table) |
| 73 | return NULL; |
| 74 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 75 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 76 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 77 | prn = bgp_node_get (table, (struct prefix *) prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 78 | |
| 79 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 80 | prn->info = bgp_table_init (afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 81 | else |
| 82 | bgp_unlock_node (prn); |
| 83 | table = prn->info; |
| 84 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 85 | |
| 86 | rn = bgp_node_get (table, p); |
| 87 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 88 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 89 | rn->prn = prn; |
| 90 | |
| 91 | return rn; |
| 92 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 93 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 94 | /* Allocate bgp_info_extra */ |
| 95 | static struct bgp_info_extra * |
| 96 | bgp_info_extra_new (void) |
| 97 | { |
| 98 | struct bgp_info_extra *new; |
| 99 | new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra)); |
| 100 | return new; |
| 101 | } |
| 102 | |
| 103 | static void |
| 104 | bgp_info_extra_free (struct bgp_info_extra **extra) |
| 105 | { |
| 106 | if (extra && *extra) |
| 107 | { |
| 108 | if ((*extra)->damp_info) |
| 109 | bgp_damp_info_free ((*extra)->damp_info, 0); |
| 110 | |
| 111 | (*extra)->damp_info = NULL; |
| 112 | |
| 113 | XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra); |
| 114 | |
| 115 | *extra = NULL; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | /* Get bgp_info extra information for the given bgp_info, lazy allocated |
| 120 | * if required. |
| 121 | */ |
| 122 | struct bgp_info_extra * |
| 123 | bgp_info_extra_get (struct bgp_info *ri) |
| 124 | { |
| 125 | if (!ri->extra) |
| 126 | ri->extra = bgp_info_extra_new(); |
| 127 | return ri->extra; |
| 128 | } |
| 129 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 130 | /* Free bgp route information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 131 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 132 | bgp_info_free (struct bgp_info *binfo) |
| 133 | { |
| 134 | if (binfo->attr) |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 135 | bgp_attr_unintern (&binfo->attr); |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 136 | |
| 137 | bgp_unlink_nexthop(binfo); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 138 | bgp_info_extra_free (&binfo->extra); |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 139 | bgp_info_mpath_free (&binfo->mpath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 140 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 141 | peer_unlock (binfo->peer); /* bgp_info peer reference */ |
| 142 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 143 | XFREE (MTYPE_BGP_ROUTE, binfo); |
| 144 | } |
| 145 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 146 | struct bgp_info * |
| 147 | bgp_info_lock (struct bgp_info *binfo) |
| 148 | { |
| 149 | binfo->lock++; |
| 150 | return binfo; |
| 151 | } |
| 152 | |
| 153 | struct bgp_info * |
| 154 | bgp_info_unlock (struct bgp_info *binfo) |
| 155 | { |
| 156 | assert (binfo && binfo->lock > 0); |
| 157 | binfo->lock--; |
| 158 | |
| 159 | if (binfo->lock == 0) |
| 160 | { |
| 161 | #if 0 |
| 162 | zlog_debug ("%s: unlocked and freeing", __func__); |
| 163 | zlog_backtrace (LOG_DEBUG); |
| 164 | #endif |
| 165 | bgp_info_free (binfo); |
| 166 | return NULL; |
| 167 | } |
| 168 | |
| 169 | #if 0 |
| 170 | if (binfo->lock == 1) |
| 171 | { |
| 172 | zlog_debug ("%s: unlocked to 1", __func__); |
| 173 | zlog_backtrace (LOG_DEBUG); |
| 174 | } |
| 175 | #endif |
| 176 | |
| 177 | return binfo; |
| 178 | } |
| 179 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 180 | void |
| 181 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) |
| 182 | { |
| 183 | struct bgp_info *top; |
| 184 | |
| 185 | top = rn->info; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 186 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 187 | ri->next = rn->info; |
| 188 | ri->prev = NULL; |
| 189 | if (top) |
| 190 | top->prev = ri; |
| 191 | rn->info = ri; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 192 | |
| 193 | bgp_info_lock (ri); |
| 194 | bgp_lock_node (rn); |
| 195 | peer_lock (ri->peer); /* bgp_info peer reference */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 196 | } |
| 197 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 198 | /* Do the actual removal of info from RIB, for use by bgp_process |
| 199 | completion callback *only* */ |
| 200 | static void |
| 201 | bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 202 | { |
| 203 | if (ri->next) |
| 204 | ri->next->prev = ri->prev; |
| 205 | if (ri->prev) |
| 206 | ri->prev->next = ri->next; |
| 207 | else |
| 208 | rn->info = ri->next; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 209 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 210 | bgp_info_mpath_dequeue (ri); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 211 | bgp_info_unlock (ri); |
| 212 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 213 | } |
| 214 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 215 | void |
| 216 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) |
| 217 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 218 | bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED); |
| 219 | /* set of previous already took care of pcount */ |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 220 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 221 | } |
| 222 | |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 223 | /* undo the effects of a previous call to bgp_info_delete; typically |
| 224 | called when a route is deleted and then quickly re-added before the |
| 225 | deletion has been processed */ |
| 226 | static void |
| 227 | bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri) |
| 228 | { |
| 229 | bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED); |
| 230 | /* unset of previous already took care of pcount */ |
| 231 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 232 | } |
| 233 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 234 | /* Adjust pcount as required */ |
| 235 | static void |
| 236 | bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) |
| 237 | { |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 238 | struct bgp_table *table; |
| 239 | |
| 240 | assert (rn && bgp_node_table (rn)); |
Paul Jakma | 6f58544 | 2006-10-22 19:13:07 +0000 | [diff] [blame] | 241 | assert (ri && ri->peer && ri->peer->bgp); |
| 242 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 243 | table = bgp_node_table (rn); |
| 244 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 245 | /* Ignore 'pcount' for RS-client tables */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 246 | if (table->type != BGP_TABLE_MAIN |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 247 | || ri->peer == ri->peer->bgp->peer_self) |
| 248 | return; |
| 249 | |
Daniel Walton | e25a974 | 2015-11-09 20:21:50 -0500 | [diff] [blame^] | 250 | if (!BGP_INFO_COUNTABLE (ri) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 251 | && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 252 | { |
| 253 | |
| 254 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 255 | |
| 256 | /* slight hack, but more robust against errors. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 257 | if (ri->peer->pcount[table->afi][table->safi]) |
| 258 | ri->peer->pcount[table->afi][table->safi]--; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 259 | else |
| 260 | { |
| 261 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", |
| 262 | __func__, ri->peer->host); |
| 263 | zlog_backtrace (LOG_WARNING); |
| 264 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); |
| 265 | } |
| 266 | } |
Daniel Walton | e25a974 | 2015-11-09 20:21:50 -0500 | [diff] [blame^] | 267 | else if (BGP_INFO_COUNTABLE (ri) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 268 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 269 | { |
| 270 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 271 | ri->peer->pcount[table->afi][table->safi]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 272 | } |
| 273 | } |
| 274 | |
| 275 | |
| 276 | /* Set/unset bgp_info flags, adjusting any other state as needed. |
| 277 | * This is here primarily to keep prefix-count in check. |
| 278 | */ |
| 279 | void |
| 280 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 281 | { |
| 282 | SET_FLAG (ri->flags, flag); |
| 283 | |
Daniel Walton | e25a974 | 2015-11-09 20:21:50 -0500 | [diff] [blame^] | 284 | /* early bath if we know it's not a flag that changes countability state */ |
| 285 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_HISTORY|BGP_INFO_REMOVED)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 286 | return; |
| 287 | |
| 288 | bgp_pcount_adjust (rn, ri); |
| 289 | } |
| 290 | |
| 291 | void |
| 292 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 293 | { |
| 294 | UNSET_FLAG (ri->flags, flag); |
| 295 | |
Daniel Walton | e25a974 | 2015-11-09 20:21:50 -0500 | [diff] [blame^] | 296 | /* early bath if we know it's not a flag that changes countability state */ |
| 297 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_HISTORY|BGP_INFO_REMOVED)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 298 | return; |
| 299 | |
| 300 | bgp_pcount_adjust (rn, ri); |
| 301 | } |
| 302 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 303 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 304 | missing-as-worst" is specified, treat it as the worst value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 305 | static u_int32_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 306 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
| 307 | { |
| 308 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 309 | return attr->med; |
| 310 | else |
| 311 | { |
| 312 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 313 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 314 | else |
| 315 | return 0; |
| 316 | } |
| 317 | } |
| 318 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 319 | /* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist |
| 320 | * is preferred, or 0 if they are the same (usually will only occur if |
| 321 | * multipath is enabled */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 322 | static int |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 323 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 324 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 325 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 326 | struct attr *newattr, *existattr; |
| 327 | struct attr_extra *newattre, *existattre; |
| 328 | bgp_peer_sort_t new_sort; |
| 329 | bgp_peer_sort_t exist_sort; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 330 | u_int32_t new_pref; |
| 331 | u_int32_t exist_pref; |
| 332 | u_int32_t new_med; |
| 333 | u_int32_t exist_med; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 334 | u_int32_t new_weight; |
| 335 | u_int32_t exist_weight; |
| 336 | uint32_t newm, existm; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 337 | struct in_addr new_id; |
| 338 | struct in_addr exist_id; |
| 339 | int new_cluster; |
| 340 | int exist_cluster; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 341 | int internal_as_route; |
| 342 | int confed_as_route; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 343 | int ret; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 344 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 345 | /* 0. Null check. */ |
| 346 | if (new == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 347 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 348 | if (exist == NULL) |
| 349 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 350 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 351 | newattr = new->attr; |
| 352 | existattr = exist->attr; |
| 353 | newattre = newattr->extra; |
| 354 | existattre = existattr->extra; |
| 355 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 356 | /* 1. Weight check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 357 | new_weight = exist_weight = 0; |
| 358 | |
| 359 | if (newattre) |
| 360 | new_weight = newattre->weight; |
| 361 | if (existattre) |
| 362 | exist_weight = existattre->weight; |
| 363 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 364 | if (new_weight > exist_weight) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 365 | return -1; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 366 | if (new_weight < exist_weight) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 367 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 368 | |
| 369 | /* 2. Local preference check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 370 | new_pref = exist_pref = bgp->default_local_pref; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 371 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 372 | if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 373 | new_pref = newattr->local_pref; |
| 374 | if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 375 | exist_pref = existattr->local_pref; |
| 376 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 377 | if (new_pref > exist_pref) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 378 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 379 | if (new_pref < exist_pref) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 380 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 381 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 382 | /* 3. Local route check. We prefer: |
| 383 | * - BGP_ROUTE_STATIC |
| 384 | * - BGP_ROUTE_AGGREGATE |
| 385 | * - BGP_ROUTE_REDISTRIBUTE |
| 386 | */ |
| 387 | if (! (new->sub_type == BGP_ROUTE_NORMAL)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 388 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 389 | if (! (exist->sub_type == BGP_ROUTE_NORMAL)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 390 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 391 | |
| 392 | /* 4. AS path length check. */ |
| 393 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 394 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 395 | int exist_hops = aspath_count_hops (existattr->aspath); |
| 396 | int exist_confeds = aspath_count_confeds (existattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 397 | |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 398 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
| 399 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 400 | int aspath_hops; |
| 401 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 402 | aspath_hops = aspath_count_hops (newattr->aspath); |
| 403 | aspath_hops += aspath_count_confeds (newattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 404 | |
| 405 | if ( aspath_hops < (exist_hops + exist_confeds)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 406 | return -1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 407 | if ( aspath_hops > (exist_hops + exist_confeds)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 408 | return 1; |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 409 | } |
| 410 | else |
| 411 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 412 | int newhops = aspath_count_hops (newattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 413 | |
| 414 | if (newhops < exist_hops) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 415 | return -1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 416 | if (newhops > exist_hops) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 417 | return 1; |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 418 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | /* 5. Origin check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 422 | if (newattr->origin < existattr->origin) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 423 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 424 | if (newattr->origin > existattr->origin) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 425 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 426 | |
| 427 | /* 6. MED check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 428 | internal_as_route = (aspath_count_hops (newattr->aspath) == 0 |
| 429 | && aspath_count_hops (existattr->aspath) == 0); |
| 430 | confed_as_route = (aspath_count_confeds (newattr->aspath) > 0 |
| 431 | && aspath_count_confeds (existattr->aspath) > 0 |
| 432 | && aspath_count_hops (newattr->aspath) == 0 |
| 433 | && aspath_count_hops (existattr->aspath) == 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 434 | |
| 435 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 436 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 437 | && confed_as_route) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 438 | || aspath_cmp_left (newattr->aspath, existattr->aspath) |
| 439 | || aspath_cmp_left_confed (newattr->aspath, existattr->aspath) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 440 | || internal_as_route) |
| 441 | { |
| 442 | new_med = bgp_med_value (new->attr, bgp); |
| 443 | exist_med = bgp_med_value (exist->attr, bgp); |
| 444 | |
| 445 | if (new_med < exist_med) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 446 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 447 | if (new_med > exist_med) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 448 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | /* 7. Peer type check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 452 | new_sort = new->peer->sort; |
| 453 | exist_sort = exist->peer->sort; |
| 454 | |
| 455 | if (new_sort == BGP_PEER_EBGP |
| 456 | && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 457 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 458 | if (exist_sort == BGP_PEER_EBGP |
| 459 | && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 460 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 461 | |
| 462 | /* 8. IGP metric check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 463 | newm = existm = 0; |
| 464 | |
| 465 | if (new->extra) |
| 466 | newm = new->extra->igpmetric; |
| 467 | if (exist->extra) |
| 468 | existm = exist->extra->igpmetric; |
| 469 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 470 | if (newm < existm) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 471 | return -1; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 472 | if (newm > existm) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 473 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 474 | |
| 475 | /* 9. Maximum path check. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 476 | if (bgp_mpath_is_configured (bgp, afi, safi)) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 477 | { |
Pradosh Mohapatra | 2fdd455 | 2013-09-07 07:02:36 +0000 | [diff] [blame] | 478 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) |
| 479 | { |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 480 | /* |
| 481 | * For the two paths, all comparison steps till IGP metric |
| 482 | * have succeeded - including AS_PATH hop count. Since 'bgp |
| 483 | * bestpath as-path multipath-relax' knob is on, we don't need |
| 484 | * an exact match of AS_PATH. Thus, mark the paths are equal. |
| 485 | * That will trigger both these paths to get into the multipath |
| 486 | * array. |
| 487 | */ |
| 488 | return 0; |
Pradosh Mohapatra | 2fdd455 | 2013-09-07 07:02:36 +0000 | [diff] [blame] | 489 | } |
| 490 | else if (new->peer->sort == BGP_PEER_IBGP) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 491 | { |
| 492 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) |
| 493 | return 0; |
| 494 | } |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 495 | else if (new->peer->as == exist->peer->as) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 496 | return 0; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 497 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 498 | |
| 499 | /* 10. If both paths are external, prefer the path that was received |
| 500 | first (the oldest one). This step minimizes route-flap, since a |
| 501 | newer path won't displace an older one, even if it was the |
| 502 | preferred route based on the additional decision criteria below. */ |
| 503 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 504 | && new_sort == BGP_PEER_EBGP |
| 505 | && exist_sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 506 | { |
| 507 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 508 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 509 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 510 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 511 | } |
| 512 | |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 513 | /* 11. Router-ID comparision. */ |
| 514 | /* If one of the paths is "stale", the corresponding peer router-id will |
| 515 | * be 0 and would always win over the other path. If originator id is |
| 516 | * used for the comparision, it will decide which path is better. |
| 517 | */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 518 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 519 | new_id.s_addr = newattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 520 | else |
| 521 | new_id.s_addr = new->peer->remote_id.s_addr; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 522 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 523 | exist_id.s_addr = existattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 524 | else |
| 525 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 526 | |
| 527 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 528 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 529 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 530 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 531 | |
| 532 | /* 12. Cluster length comparision. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 533 | new_cluster = exist_cluster = 0; |
| 534 | |
| 535 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 536 | new_cluster = newattre->cluster->length; |
| 537 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 538 | exist_cluster = existattre->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 539 | |
| 540 | if (new_cluster < exist_cluster) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 541 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 542 | if (new_cluster > exist_cluster) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 543 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 544 | |
| 545 | /* 13. Neighbor address comparision. */ |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 546 | /* Do this only if neither path is "stale" as stale paths do not have |
| 547 | * valid peer information (as the connection may or may not be up). |
| 548 | */ |
| 549 | if (CHECK_FLAG (exist->flags, BGP_INFO_STALE)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 550 | return -1; |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 551 | if (CHECK_FLAG (new->flags, BGP_INFO_STALE)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 552 | return 1; |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 553 | /* locally configured routes to advertise do not have su_remote */ |
| 554 | if (new->peer->su_remote == NULL) |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 555 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 556 | if (exist->peer->su_remote == NULL) |
| 557 | return -1; |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 558 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 559 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 560 | |
| 561 | if (ret == 1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 562 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 563 | if (ret == -1) |
| 564 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 565 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 566 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 567 | } |
| 568 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 569 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 570 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 571 | afi_t afi, safi_t safi) |
| 572 | { |
| 573 | struct bgp_filter *filter; |
| 574 | |
| 575 | filter = &peer->filter[afi][safi]; |
| 576 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 577 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 578 | if (BGP_DEBUG (update, UPDATE_IN) \ |
| 579 | && !(F ## _IN (filter))) \ |
| 580 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ |
| 581 | peer->host, #f, F ## _IN_NAME(filter)); |
| 582 | |
| 583 | if (DISTRIBUTE_IN_NAME (filter)) { |
| 584 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 585 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 586 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 587 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 588 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 589 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 590 | if (PREFIX_LIST_IN_NAME (filter)) { |
| 591 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 592 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 593 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 594 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 595 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 596 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 597 | if (FILTER_LIST_IN_NAME (filter)) { |
| 598 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 599 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 600 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 601 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 602 | } |
| 603 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 604 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 605 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 606 | } |
| 607 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 608 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 609 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 610 | afi_t afi, safi_t safi) |
| 611 | { |
| 612 | struct bgp_filter *filter; |
| 613 | |
| 614 | filter = &peer->filter[afi][safi]; |
| 615 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 616 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 617 | if (BGP_DEBUG (update, UPDATE_OUT) \ |
| 618 | && !(F ## _OUT (filter))) \ |
| 619 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ |
| 620 | peer->host, #f, F ## _OUT_NAME(filter)); |
| 621 | |
| 622 | if (DISTRIBUTE_OUT_NAME (filter)) { |
| 623 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 624 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 625 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 626 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 627 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 628 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 629 | if (PREFIX_LIST_OUT_NAME (filter)) { |
| 630 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 631 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 632 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 633 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 634 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 635 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 636 | if (FILTER_LIST_OUT_NAME (filter)) { |
| 637 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 638 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 639 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 640 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 641 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 642 | |
| 643 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 644 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 648 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 649 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 650 | { |
| 651 | if (attr->community) |
| 652 | { |
| 653 | /* NO_ADVERTISE check. */ |
| 654 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 655 | return 1; |
| 656 | |
| 657 | /* NO_EXPORT check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 658 | if (peer->sort == BGP_PEER_EBGP && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 659 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 660 | return 1; |
| 661 | |
| 662 | /* NO_EXPORT_SUBCONFED check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 663 | if (peer->sort == BGP_PEER_EBGP |
| 664 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 665 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 666 | return 1; |
| 667 | } |
| 668 | return 0; |
| 669 | } |
| 670 | |
| 671 | /* Route reflection loop check. */ |
| 672 | static int |
| 673 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 674 | { |
| 675 | struct in_addr cluster_id; |
| 676 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 677 | if (attr->extra && attr->extra->cluster) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 678 | { |
| 679 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 680 | cluster_id = peer->bgp->cluster_id; |
| 681 | else |
| 682 | cluster_id = peer->bgp->router_id; |
| 683 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 684 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 685 | return 1; |
| 686 | } |
| 687 | return 0; |
| 688 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 689 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 690 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 691 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 692 | afi_t afi, safi_t safi) |
| 693 | { |
| 694 | struct bgp_filter *filter; |
| 695 | struct bgp_info info; |
| 696 | route_map_result_t ret; |
| 697 | |
| 698 | filter = &peer->filter[afi][safi]; |
| 699 | |
| 700 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 701 | if (peer->weight) |
| 702 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 703 | |
| 704 | /* Route map apply. */ |
| 705 | if (ROUTE_MAP_IN_NAME (filter)) |
| 706 | { |
| 707 | /* Duplicate current value to new strucutre for modification. */ |
| 708 | info.peer = peer; |
| 709 | info.attr = attr; |
| 710 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 711 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 712 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 713 | /* Apply BGP route map to the attribute. */ |
| 714 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 715 | |
| 716 | peer->rmap_type = 0; |
| 717 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 718 | if (ret == RMAP_DENYMATCH) |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 719 | /* caller has multiple error paths with bgp_attr_flush() */ |
| 720 | return RMAP_DENY; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 721 | } |
| 722 | return RMAP_PERMIT; |
| 723 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 724 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 725 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 726 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 727 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 728 | { |
| 729 | struct bgp_filter *filter; |
| 730 | struct bgp_info info; |
| 731 | route_map_result_t ret; |
| 732 | |
| 733 | filter = &peer->filter[afi][safi]; |
| 734 | |
| 735 | /* Route map apply. */ |
| 736 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 737 | { |
| 738 | /* Duplicate current value to new strucutre for modification. */ |
| 739 | info.peer = rsclient; |
| 740 | info.attr = attr; |
| 741 | |
| 742 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 743 | |
| 744 | /* Apply BGP route map to the attribute. */ |
| 745 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 746 | |
| 747 | rsclient->rmap_type = 0; |
| 748 | |
| 749 | if (ret == RMAP_DENYMATCH) |
| 750 | { |
| 751 | /* Free newly generated AS path and community by route-map. */ |
| 752 | bgp_attr_flush (attr); |
| 753 | return RMAP_DENY; |
| 754 | } |
| 755 | } |
| 756 | return RMAP_PERMIT; |
| 757 | } |
| 758 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 759 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 760 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 761 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 762 | { |
| 763 | struct bgp_filter *filter; |
| 764 | struct bgp_info info; |
| 765 | route_map_result_t ret; |
| 766 | |
| 767 | filter = &rsclient->filter[afi][safi]; |
| 768 | |
| 769 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 770 | if (peer->weight) |
| 771 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 772 | |
| 773 | /* Route map apply. */ |
| 774 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 775 | { |
| 776 | /* Duplicate current value to new strucutre for modification. */ |
| 777 | info.peer = peer; |
| 778 | info.attr = attr; |
| 779 | |
| 780 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 781 | |
| 782 | /* Apply BGP route map to the attribute. */ |
| 783 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 784 | |
| 785 | peer->rmap_type = 0; |
| 786 | |
| 787 | if (ret == RMAP_DENYMATCH) |
| 788 | { |
| 789 | /* Free newly generated AS path and community by route-map. */ |
| 790 | bgp_attr_flush (attr); |
| 791 | return RMAP_DENY; |
| 792 | } |
| 793 | } |
| 794 | return RMAP_PERMIT; |
| 795 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 796 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 797 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 798 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 799 | struct attr *attr, afi_t afi, safi_t safi) |
| 800 | { |
| 801 | int ret; |
| 802 | char buf[SU_ADDRSTRLEN]; |
| 803 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 804 | struct peer *from; |
| 805 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 806 | int transparent; |
| 807 | int reflect; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 808 | struct attr *riattr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 809 | |
| 810 | from = ri->peer; |
| 811 | filter = &peer->filter[afi][safi]; |
| 812 | bgp = peer->bgp; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 813 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 814 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 815 | if (DISABLE_BGP_ANNOUNCE) |
| 816 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 817 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 818 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 819 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 820 | return 0; |
| 821 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 822 | /* Do not send back route to sender. */ |
| 823 | if (from == peer) |
| 824 | return 0; |
| 825 | |
| 826 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 827 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 828 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 829 | return 0; |
| 830 | |
| 831 | /* Default route check. */ |
| 832 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 833 | { |
| 834 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 835 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 836 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 837 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 838 | } |
| 839 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 840 | /* Transparency check. */ |
| 841 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 842 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 843 | transparent = 1; |
| 844 | else |
| 845 | transparent = 0; |
| 846 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 847 | /* If community is not disabled check the no-export and local. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 848 | if (! transparent && bgp_community_filter (peer, riattr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 849 | return 0; |
| 850 | |
| 851 | /* If the attribute has originator-id and it is same as remote |
| 852 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 853 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 854 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 855 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 856 | { |
| 857 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 858 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 859 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 860 | peer->host, |
| 861 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 862 | p->prefixlen); |
| 863 | return 0; |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | /* ORF prefix-list filter check */ |
| 868 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 869 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 870 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 871 | if (peer->orf_plist[afi][safi]) |
| 872 | { |
| 873 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 874 | return 0; |
| 875 | } |
| 876 | |
| 877 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 878 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 879 | { |
| 880 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 881 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 882 | "%s [Update:SEND] %s/%d is filtered", |
| 883 | peer->host, |
| 884 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 885 | p->prefixlen); |
| 886 | return 0; |
| 887 | } |
| 888 | |
| 889 | #ifdef BGP_SEND_ASPATH_CHECK |
| 890 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 891 | if (aspath_loop_check (riattr->aspath, peer->as)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 892 | { |
| 893 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 894 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 895 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 896 | peer->host, peer->as); |
| 897 | return 0; |
| 898 | } |
| 899 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 900 | |
| 901 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 902 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 903 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 904 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 905 | { |
| 906 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 907 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 908 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 909 | peer->host, |
| 910 | bgp->confed_id); |
| 911 | return 0; |
| 912 | } |
| 913 | } |
| 914 | |
| 915 | /* Route-Reflect check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 916 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 917 | reflect = 1; |
| 918 | else |
| 919 | reflect = 0; |
| 920 | |
| 921 | /* IBGP reflection check. */ |
| 922 | if (reflect) |
| 923 | { |
| 924 | /* A route from a Client peer. */ |
| 925 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 926 | { |
| 927 | /* Reflect to all the Non-Client peers and also to the |
| 928 | Client peers other than the originator. Originator check |
| 929 | is already done. So there is noting to do. */ |
| 930 | /* no bgp client-to-client reflection check. */ |
| 931 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 932 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 933 | return 0; |
| 934 | } |
| 935 | else |
| 936 | { |
| 937 | /* A route from a Non-client peer. Reflect to all other |
| 938 | clients. */ |
| 939 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 940 | return 0; |
| 941 | } |
| 942 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 943 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 944 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 945 | bgp_attr_dup (attr, riattr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 946 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 947 | /* If local-preference is not set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 948 | if ((peer->sort == BGP_PEER_IBGP |
| 949 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 950 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 951 | { |
| 952 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 953 | attr->local_pref = bgp->default_local_pref; |
| 954 | } |
| 955 | |
Pradosh Mohapatra | 689bb66 | 2013-09-07 07:13:37 +0000 | [diff] [blame] | 956 | /* If originator-id is not set and the route is to be reflected, |
| 957 | set the originator id */ |
| 958 | if (peer && from && peer->sort == BGP_PEER_IBGP && |
| 959 | from->sort == BGP_PEER_IBGP && |
| 960 | (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) |
| 961 | { |
| 962 | attr->extra = bgp_attr_extra_get(attr); |
| 963 | IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id)); |
| 964 | SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID); |
| 965 | } |
| 966 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 967 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 968 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 969 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 970 | { |
| 971 | if (ri->peer != bgp->peer_self && ! transparent |
| 972 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 973 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 974 | } |
| 975 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 976 | |
| 977 | #define NEXTHOP_IS_V4 (\ |
| 978 | (safi != SAFI_ENCAP && p->family == AF_INET) || \ |
| 979 | (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 4)) |
| 980 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 981 | #define NEXTHOP_IS_V6 (\ |
| 982 | (safi != SAFI_ENCAP && p->family == AF_INET6) || \ |
| 983 | (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16)) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 984 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 985 | /* next-hop-set */ |
Timo Teräs | 9e7a53c | 2014-04-24 10:22:37 +0300 | [diff] [blame] | 986 | if (transparent |
| 987 | || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 988 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 989 | && ((NEXTHOP_IS_V4 && attr->nexthop.s_addr) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 990 | || (NEXTHOP_IS_V6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 991 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 992 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 993 | { |
| 994 | /* NEXT-HOP Unchanged. */ |
| 995 | } |
| 996 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 997 | || (NEXTHOP_IS_V4 && attr->nexthop.s_addr == 0) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 998 | || (NEXTHOP_IS_V6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 999 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1000 | || (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1001 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 1002 | { |
| 1003 | /* Set IPv4 nexthop. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1004 | if (NEXTHOP_IS_V4) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1005 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1006 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1007 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 1008 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1009 | else |
| 1010 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1011 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1012 | /* Set IPv6 nexthop. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1013 | if (NEXTHOP_IS_V6) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1014 | { |
| 1015 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1016 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1017 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1018 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1019 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1020 | } |
| 1021 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1022 | if (p->family == AF_INET6 && safi != SAFI_ENCAP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1023 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1024 | /* Left nexthop_local unchanged if so configured. */ |
| 1025 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 1026 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1027 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1028 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 1029 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1030 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1031 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1032 | } |
| 1033 | |
| 1034 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 1035 | else |
| 1036 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1037 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1038 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1039 | |
| 1040 | /* Set link-local address for shared network peer. */ |
| 1041 | if (peer->shared_network |
| 1042 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 1043 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1044 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1045 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1046 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1047 | } |
| 1048 | |
| 1049 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 1050 | address.*/ |
| 1051 | if (reflect) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1052 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1053 | |
| 1054 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 1055 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1056 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1057 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1058 | |
| 1059 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1060 | |
| 1061 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1062 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1063 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1064 | && aspath_private_as_check (attr->aspath)) |
| 1065 | attr->aspath = aspath_empty_get (); |
| 1066 | |
| 1067 | /* Route map & unsuppress-map apply. */ |
| 1068 | if (ROUTE_MAP_OUT_NAME (filter) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1069 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1070 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1071 | struct bgp_info info; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1072 | struct attr dummy_attr; |
| 1073 | struct attr_extra dummy_extra; |
| 1074 | |
| 1075 | dummy_attr.extra = &dummy_extra; |
| 1076 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1077 | info.peer = peer; |
| 1078 | info.attr = attr; |
| 1079 | |
| 1080 | /* The route reflector is not allowed to modify the attributes |
Dinesh Dutt | 083e5e2 | 2015-11-09 20:21:54 -0500 | [diff] [blame] | 1081 | of the reflected IBGP routes, unless configured to allow it */ |
| 1082 | if ((from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) && |
| 1083 | !bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1084 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1085 | bgp_attr_dup (&dummy_attr, attr); |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1086 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1087 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1088 | |
| 1089 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1090 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1091 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1092 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1093 | else |
| 1094 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1095 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1096 | peer->rmap_type = 0; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1097 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1098 | if (ret == RMAP_DENYMATCH) |
| 1099 | { |
| 1100 | bgp_attr_flush (attr); |
| 1101 | return 0; |
| 1102 | } |
| 1103 | } |
| 1104 | return 1; |
| 1105 | } |
| 1106 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1107 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1108 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1109 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1110 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1111 | int ret; |
| 1112 | char buf[SU_ADDRSTRLEN]; |
| 1113 | struct bgp_filter *filter; |
| 1114 | struct bgp_info info; |
| 1115 | struct peer *from; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1116 | struct attr *riattr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1117 | |
| 1118 | from = ri->peer; |
| 1119 | filter = &rsclient->filter[afi][safi]; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1120 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1121 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 1122 | if (DISABLE_BGP_ANNOUNCE) |
| 1123 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1124 | |
| 1125 | /* Do not send back route to sender. */ |
| 1126 | if (from == rsclient) |
| 1127 | return 0; |
| 1128 | |
| 1129 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1130 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1131 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 1132 | return 0; |
| 1133 | |
| 1134 | /* Default route check. */ |
| 1135 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1136 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1137 | { |
| 1138 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1139 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1140 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1141 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1142 | } |
| 1143 | |
| 1144 | /* If the attribute has originator-id and it is same as remote |
| 1145 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1146 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1147 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1148 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1149 | &riattr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1150 | { |
| 1151 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1152 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1153 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1154 | rsclient->host, |
| 1155 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1156 | p->prefixlen); |
| 1157 | return 0; |
| 1158 | } |
| 1159 | } |
| 1160 | |
| 1161 | /* ORF prefix-list filter check */ |
| 1162 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1163 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1164 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1165 | if (rsclient->orf_plist[afi][safi]) |
| 1166 | { |
| 1167 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1168 | return 0; |
| 1169 | } |
| 1170 | |
| 1171 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1172 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1173 | { |
| 1174 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1175 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1176 | "%s [Update:SEND] %s/%d is filtered", |
| 1177 | rsclient->host, |
| 1178 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1179 | p->prefixlen); |
| 1180 | return 0; |
| 1181 | } |
| 1182 | |
| 1183 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1184 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1185 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1186 | { |
| 1187 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1188 | zlog (rsclient->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 1189 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1190 | rsclient->host, rsclient->as); |
| 1191 | return 0; |
| 1192 | } |
| 1193 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1194 | |
| 1195 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1196 | bgp_attr_dup (attr, riattr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1197 | |
| 1198 | /* next-hop-set */ |
| 1199 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1200 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1201 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1202 | ) |
| 1203 | { |
| 1204 | /* Set IPv4 nexthop. */ |
| 1205 | if (p->family == AF_INET) |
| 1206 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1207 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1208 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1209 | IPV4_MAX_BYTELEN); |
| 1210 | else |
| 1211 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1212 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1213 | /* Set IPv6 nexthop. */ |
| 1214 | if (p->family == AF_INET6) |
| 1215 | { |
| 1216 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1217 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1218 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1219 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1220 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1221 | } |
| 1222 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1223 | if (p->family == AF_INET6) |
| 1224 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1225 | struct attr_extra *attre = attr->extra; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1226 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1227 | /* Left nexthop_local unchanged if so configured. */ |
| 1228 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1229 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1230 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1231 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1232 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1233 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1234 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1235 | } |
| 1236 | |
| 1237 | /* Default nexthop_local treatment for RS-Clients */ |
| 1238 | else |
| 1239 | { |
| 1240 | /* Announcer and RS-Client are both in the same network */ |
| 1241 | if (rsclient->shared_network && from->shared_network && |
| 1242 | (rsclient->ifindex == from->ifindex)) |
| 1243 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1244 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1245 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1246 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1247 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1248 | } |
| 1249 | |
| 1250 | /* Set link-local address for shared network peer. */ |
| 1251 | else if (rsclient->shared_network |
| 1252 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1253 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1254 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1255 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1256 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
| 1259 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1260 | attre->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1261 | } |
| 1262 | |
| 1263 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1264 | |
| 1265 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1266 | if (rsclient->sort == BGP_PEER_EBGP |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1267 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1268 | && aspath_private_as_check (attr->aspath)) |
| 1269 | attr->aspath = aspath_empty_get (); |
| 1270 | |
| 1271 | /* Route map & unsuppress-map apply. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1272 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1273 | { |
| 1274 | info.peer = rsclient; |
| 1275 | info.attr = attr; |
| 1276 | |
| 1277 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1278 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1279 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1280 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1281 | else |
| 1282 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1283 | |
| 1284 | rsclient->rmap_type = 0; |
| 1285 | |
| 1286 | if (ret == RMAP_DENYMATCH) |
| 1287 | { |
| 1288 | bgp_attr_flush (attr); |
| 1289 | return 0; |
| 1290 | } |
| 1291 | } |
| 1292 | |
| 1293 | return 1; |
| 1294 | } |
| 1295 | |
| 1296 | struct bgp_info_pair |
| 1297 | { |
| 1298 | struct bgp_info *old; |
| 1299 | struct bgp_info *new; |
| 1300 | }; |
| 1301 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1302 | static void |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1303 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1304 | struct bgp_info_pair *result, |
| 1305 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1306 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1307 | struct bgp_info *new_select; |
| 1308 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1309 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1310 | struct bgp_info *ri1; |
| 1311 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1312 | struct bgp_info *nextri = NULL; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1313 | int cmpret, do_mpath; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1314 | struct list mp_list; |
Paul Jakma | 91b9e85 | 2015-12-01 14:32:11 +0000 | [diff] [blame] | 1315 | |
| 1316 | result->old = result->new = NULL; |
| 1317 | |
| 1318 | if (rn->info == NULL) |
| 1319 | { |
| 1320 | char buf[PREFIX_STRLEN]; |
| 1321 | zlog_warn ("%s: Called for route_node %s with no routing entries!", |
| 1322 | __func__, |
| 1323 | prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf))); |
| 1324 | return; |
| 1325 | } |
| 1326 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1327 | bgp_mp_list_init (&mp_list); |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1328 | do_mpath = bgp_mpath_is_configured (bgp, afi, safi); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1329 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1330 | /* bgp deterministic-med */ |
| 1331 | new_select = NULL; |
| 1332 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1333 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1334 | { |
| 1335 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1336 | continue; |
| 1337 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1338 | continue; |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1339 | if (ri1->peer && ri1->peer != bgp->peer_self) |
| 1340 | if (ri1->peer->status != Established) |
| 1341 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1342 | |
| 1343 | new_select = ri1; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1344 | if (do_mpath) |
| 1345 | bgp_mp_list_add (&mp_list, ri1); |
| 1346 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1347 | if (ri1->next) |
| 1348 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1349 | { |
| 1350 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1351 | continue; |
| 1352 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1353 | continue; |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1354 | if (ri2->peer && |
| 1355 | ri2->peer != bgp->peer_self && |
| 1356 | !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT)) |
| 1357 | if (ri2->peer->status != Established) |
| 1358 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1359 | |
| 1360 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1361 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1362 | ri2->attr->aspath)) |
| 1363 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1364 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
| 1365 | old_select = ri2; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1366 | if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi)) |
| 1367 | == -1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1368 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1369 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1370 | new_select = ri2; |
| 1371 | } |
| 1372 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1373 | if (do_mpath) |
| 1374 | { |
| 1375 | if (cmpret != 0) |
| 1376 | bgp_mp_list_clear (&mp_list); |
| 1377 | |
| 1378 | if (cmpret == 0 || cmpret == -1) |
| 1379 | bgp_mp_list_add (&mp_list, ri2); |
| 1380 | } |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1381 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1382 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1383 | } |
| 1384 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1385 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1386 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1387 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1388 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1389 | bgp_mp_list_clear (&mp_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1390 | } |
| 1391 | |
| 1392 | /* Check old selected route and new selected route. */ |
| 1393 | old_select = NULL; |
| 1394 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1395 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1396 | { |
| 1397 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1398 | old_select = ri; |
| 1399 | |
| 1400 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1401 | { |
| 1402 | /* reap REMOVED routes, if needs be |
| 1403 | * selected route must stay for a while longer though |
| 1404 | */ |
| 1405 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1406 | && (ri != old_select)) |
| 1407 | bgp_info_reap (rn, ri); |
| 1408 | |
| 1409 | continue; |
| 1410 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1411 | |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1412 | if (ri->peer && |
| 1413 | ri->peer != bgp->peer_self && |
| 1414 | !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT)) |
| 1415 | if (ri->peer->status != Established) |
| 1416 | continue; |
| 1417 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1418 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1419 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1420 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1421 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1422 | continue; |
| 1423 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1424 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1425 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1426 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1427 | if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1428 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1429 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1430 | bgp_mp_dmed_deselect (new_select); |
| 1431 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1432 | new_select = ri; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1433 | } |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1434 | else if (cmpret == 1 && do_mpath |
| 1435 | && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1436 | bgp_mp_dmed_deselect (ri); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1437 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1438 | if (do_mpath) |
| 1439 | { |
| 1440 | if (cmpret != 0) |
| 1441 | bgp_mp_list_clear (&mp_list); |
| 1442 | |
| 1443 | if (cmpret == 0 || cmpret == -1) |
| 1444 | bgp_mp_list_add (&mp_list, ri); |
| 1445 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1446 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1447 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1448 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1449 | bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1450 | |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1451 | bgp_info_mpath_aggregate_update (new_select, old_select); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1452 | bgp_mp_list_clear (&mp_list); |
| 1453 | |
| 1454 | result->old = old_select; |
| 1455 | result->new = new_select; |
| 1456 | |
| 1457 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1458 | } |
| 1459 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1460 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1461 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1462 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1463 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1464 | struct prefix *p; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1465 | struct attr attr; |
| 1466 | struct attr_extra extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1467 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1468 | memset (&attr, 0, sizeof(struct attr)); |
| 1469 | memset (&extra, 0, sizeof(struct attr_extra)); |
| 1470 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1471 | p = &rn->p; |
| 1472 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1473 | /* Announce route to Established peer. */ |
| 1474 | if (peer->status != Established) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1475 | return 0; |
| 1476 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1477 | /* Address family configuration check. */ |
| 1478 | if (! peer->afc_nego[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1479 | return 0; |
| 1480 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1481 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1482 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1483 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1484 | return 0; |
| 1485 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1486 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 1487 | attr.extra = &extra; |
| 1488 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1489 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1490 | { |
| 1491 | case BGP_TABLE_MAIN: |
| 1492 | /* Announcement to peer->conf. If the route is filtered, |
| 1493 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1494 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
| 1495 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1496 | else |
| 1497 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1498 | break; |
| 1499 | case BGP_TABLE_RSCLIENT: |
| 1500 | /* Announcement to peer->conf. If the route is filtered, |
| 1501 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1502 | if (selected && |
| 1503 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) |
| 1504 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
| 1505 | else |
| 1506 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1507 | break; |
| 1508 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1509 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1510 | bgp_attr_flush (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1511 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1512 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1513 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1514 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1515 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1516 | struct bgp *bgp; |
| 1517 | struct bgp_node *rn; |
| 1518 | afi_t afi; |
| 1519 | safi_t safi; |
| 1520 | }; |
| 1521 | |
| 1522 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1523 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1524 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1525 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1526 | struct bgp *bgp = pq->bgp; |
| 1527 | struct bgp_node *rn = pq->rn; |
| 1528 | afi_t afi = pq->afi; |
| 1529 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1530 | struct bgp_info *new_select; |
| 1531 | struct bgp_info *old_select; |
| 1532 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1533 | struct listnode *node, *nnode; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1534 | struct peer *rsclient = bgp_node_table (rn)->owner; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1535 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1536 | /* Best path selection. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1537 | bgp_best_selection (bgp, rn, &old_and_new, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1538 | new_select = old_and_new.new; |
| 1539 | old_select = old_and_new.old; |
| 1540 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1541 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1542 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1543 | if (rsclient->group) |
| 1544 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1545 | { |
| 1546 | /* Nothing to do. */ |
| 1547 | if (old_select && old_select == new_select) |
| 1548 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1549 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1550 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1551 | if (old_select) |
| 1552 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
| 1553 | if (new_select) |
| 1554 | { |
| 1555 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1556 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1557 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
| 1558 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1559 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1560 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1561 | afi, safi); |
| 1562 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1563 | } |
| 1564 | else |
| 1565 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1566 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1567 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1568 | if (new_select) |
| 1569 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1570 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1571 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1572 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1573 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1574 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1575 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1576 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1577 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1578 | bgp_info_reap (rn, old_select); |
| 1579 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1580 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1581 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1582 | } |
| 1583 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1584 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1585 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1586 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1587 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1588 | struct bgp *bgp = pq->bgp; |
| 1589 | struct bgp_node *rn = pq->rn; |
| 1590 | afi_t afi = pq->afi; |
| 1591 | safi_t safi = pq->safi; |
| 1592 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1593 | struct bgp_info *new_select; |
| 1594 | struct bgp_info *old_select; |
| 1595 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1596 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1597 | struct peer *peer; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1598 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1599 | /* Best path selection. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1600 | bgp_best_selection (bgp, rn, &old_and_new, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1601 | old_select = old_and_new.old; |
| 1602 | new_select = old_and_new.new; |
| 1603 | |
| 1604 | /* Nothing to do. */ |
Daniel Walton | 325fcfb | 2015-05-19 17:58:10 -0700 | [diff] [blame] | 1605 | if (old_select && old_select == new_select |
| 1606 | && !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1607 | { |
| 1608 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1609 | { |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1610 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
| 1611 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1612 | bgp_zebra_announce (p, old_select, bgp, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1613 | |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1614 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1615 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1616 | return WQ_SUCCESS; |
| 1617 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1618 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1619 | |
Daniel Walton | 325fcfb | 2015-05-19 17:58:10 -0700 | [diff] [blame] | 1620 | /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */ |
| 1621 | UNSET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); |
| 1622 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1623 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1624 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1625 | if (new_select) |
| 1626 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1627 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1628 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1629 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1630 | } |
| 1631 | |
| 1632 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1633 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1634 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1635 | { |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1636 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1637 | } |
| 1638 | |
| 1639 | /* FIB update. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1640 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
| 1641 | ! bgp_option_check (BGP_OPT_NO_FIB))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1642 | { |
| 1643 | if (new_select |
| 1644 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1645 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1646 | bgp_zebra_announce (p, new_select, bgp, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1647 | else |
| 1648 | { |
| 1649 | /* Withdraw the route from the kernel. */ |
| 1650 | if (old_select |
| 1651 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1652 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1653 | bgp_zebra_withdraw (p, old_select, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1654 | } |
| 1655 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1656 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1657 | /* Reap old select bgp_info, if it has been removed */ |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1658 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1659 | bgp_info_reap (rn, old_select); |
| 1660 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1661 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1662 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1663 | } |
| 1664 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1665 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1666 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1667 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1668 | struct bgp_process_queue *pq = data; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1669 | struct bgp_table *table = bgp_node_table (pq->rn); |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1670 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1671 | bgp_unlock (pq->bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1672 | bgp_unlock_node (pq->rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1673 | bgp_table_unlock (table); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1674 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1675 | } |
| 1676 | |
| 1677 | static void |
| 1678 | bgp_process_queue_init (void) |
| 1679 | { |
| 1680 | bm->process_main_queue |
| 1681 | = work_queue_new (bm->master, "process_main_queue"); |
| 1682 | bm->process_rsclient_queue |
| 1683 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1684 | |
| 1685 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1686 | { |
| 1687 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1688 | exit (1); |
| 1689 | } |
| 1690 | |
| 1691 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1692 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1693 | bm->process_main_queue->spec.max_retries = 0; |
| 1694 | bm->process_main_queue->spec.hold = 50; |
| 1695 | |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1696 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
David Lamparter | d43f8b3 | 2015-03-03 08:54:54 +0100 | [diff] [blame] | 1697 | bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del; |
| 1698 | bm->process_rsclient_queue->spec.max_retries = 0; |
| 1699 | bm->process_rsclient_queue->spec.hold = 50; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1700 | } |
| 1701 | |
| 1702 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1703 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1704 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1705 | struct bgp_process_queue *pqnode; |
| 1706 | |
| 1707 | /* already scheduled for processing? */ |
| 1708 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1709 | return; |
| 1710 | |
Paul Jakma | 91b9e85 | 2015-12-01 14:32:11 +0000 | [diff] [blame] | 1711 | if (rn->info == NULL) |
| 1712 | { |
| 1713 | /* XXX: Perhaps remove before next release, after we've flushed out |
| 1714 | * any obvious cases |
| 1715 | */ |
| 1716 | assert (rn->info != NULL); |
| 1717 | char buf[PREFIX_STRLEN]; |
| 1718 | zlog_warn ("%s: Called for route_node %s with no routing entries!", |
| 1719 | __func__, |
| 1720 | prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf))); |
| 1721 | return; |
| 1722 | } |
| 1723 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1724 | if ( (bm->process_main_queue == NULL) || |
| 1725 | (bm->process_rsclient_queue == NULL) ) |
| 1726 | bgp_process_queue_init (); |
| 1727 | |
| 1728 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1729 | sizeof (struct bgp_process_queue)); |
| 1730 | if (!pqnode) |
| 1731 | return; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1732 | |
| 1733 | /* all unlocked in bgp_processq_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1734 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1735 | pqnode->rn = bgp_lock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1736 | pqnode->bgp = bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1737 | bgp_lock (bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1738 | pqnode->afi = afi; |
| 1739 | pqnode->safi = safi; |
| 1740 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1741 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1742 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1743 | case BGP_TABLE_MAIN: |
| 1744 | work_queue_add (bm->process_main_queue, pqnode); |
| 1745 | break; |
| 1746 | case BGP_TABLE_RSCLIENT: |
| 1747 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1748 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1749 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1750 | |
Stephen Hemminger | 07ff4dc | 2013-01-04 22:29:20 +0000 | [diff] [blame] | 1751 | SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1752 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1753 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1754 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1755 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1756 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1757 | { |
| 1758 | struct peer *peer; |
| 1759 | |
| 1760 | peer = THREAD_ARG (thread); |
| 1761 | peer->t_pmax_restart = NULL; |
| 1762 | |
| 1763 | if (BGP_DEBUG (events, EVENTS)) |
| 1764 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1765 | peer->host); |
| 1766 | |
| 1767 | peer_clear (peer); |
| 1768 | |
| 1769 | return 0; |
| 1770 | } |
| 1771 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1772 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1773 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1774 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1775 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1776 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1777 | return 0; |
| 1778 | |
| 1779 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1780 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1781 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1782 | && ! always) |
| 1783 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1784 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1785 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1786 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1787 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1788 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1789 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1790 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1791 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1792 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1793 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1794 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1795 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1796 | |
| 1797 | if (safi == SAFI_MPLS_VPN) |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 1798 | safi = SAFI_MPLS_LABELED_VPN; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1799 | |
| 1800 | ndata[0] = (afi >> 8); |
| 1801 | ndata[1] = afi; |
| 1802 | ndata[2] = safi; |
| 1803 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1804 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1805 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1806 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1807 | |
| 1808 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1809 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1810 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1811 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1812 | |
| 1813 | /* restart timer start */ |
| 1814 | if (peer->pmax_restart[afi][safi]) |
| 1815 | { |
| 1816 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1817 | |
| 1818 | if (BGP_DEBUG (events, EVENTS)) |
| 1819 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1820 | peer->host, peer->v_pmax_restart); |
| 1821 | |
| 1822 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1823 | peer->v_pmax_restart); |
| 1824 | } |
| 1825 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1826 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1827 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1828 | else |
| 1829 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1830 | |
| 1831 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1832 | { |
| 1833 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1834 | && ! always) |
| 1835 | return 0; |
| 1836 | |
| 1837 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1838 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1839 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1840 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1841 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1842 | } |
| 1843 | else |
| 1844 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1845 | return 0; |
| 1846 | } |
| 1847 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1848 | /* Unconditionally remove the route from the RIB, without taking |
| 1849 | * damping into consideration (eg, because the session went down) |
| 1850 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1851 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1852 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1853 | afi_t afi, safi_t safi) |
| 1854 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1855 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1856 | |
| 1857 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1858 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1859 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1860 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1861 | } |
| 1862 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1863 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1864 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1865 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1866 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1867 | int status = BGP_DAMP_NONE; |
| 1868 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1869 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1870 | * the bgp_info in the RIB for historical reference. |
| 1871 | */ |
| 1872 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1873 | && peer->sort == BGP_PEER_EBGP) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1874 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1875 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1876 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1877 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1878 | return; |
| 1879 | } |
| 1880 | |
| 1881 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1882 | } |
| 1883 | |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 1884 | static struct bgp_info * |
| 1885 | info_make (int type, int sub_type, struct peer *peer, struct attr *attr, |
| 1886 | struct bgp_node *rn) |
| 1887 | { |
| 1888 | struct bgp_info *new; |
| 1889 | |
| 1890 | /* Make new BGP info. */ |
| 1891 | new = XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
| 1892 | new->type = type; |
| 1893 | new->sub_type = sub_type; |
| 1894 | new->peer = peer; |
| 1895 | new->attr = attr; |
| 1896 | new->uptime = bgp_clock (); |
| 1897 | new->net = rn; |
| 1898 | return new; |
| 1899 | } |
| 1900 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1901 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1902 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1903 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1904 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1905 | { |
| 1906 | struct bgp_node *rn; |
| 1907 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1908 | struct attr new_attr; |
| 1909 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1910 | struct attr *attr_new; |
| 1911 | struct attr *attr_new2; |
| 1912 | struct bgp_info *ri; |
| 1913 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1914 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1915 | char buf[SU_ADDRSTRLEN]; |
| 1916 | |
| 1917 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1918 | if (peer == rsclient) |
| 1919 | return; |
| 1920 | |
| 1921 | bgp = peer->bgp; |
| 1922 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1923 | |
| 1924 | /* Check previously received route. */ |
| 1925 | for (ri = rn->info; ri; ri = ri->next) |
| 1926 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1927 | break; |
| 1928 | |
| 1929 | /* AS path loop check. */ |
Milan Kocian | 000e157 | 2013-10-18 07:59:38 +0000 | [diff] [blame] | 1930 | if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1931 | { |
| 1932 | reason = "as-path contains our own AS;"; |
| 1933 | goto filtered; |
| 1934 | } |
| 1935 | |
| 1936 | /* Route reflector originator ID check. */ |
| 1937 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1938 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1939 | { |
| 1940 | reason = "originator is us;"; |
| 1941 | goto filtered; |
| 1942 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1943 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1944 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1945 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1946 | |
| 1947 | /* Apply export policy. */ |
| 1948 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1949 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1950 | { |
| 1951 | reason = "export-policy;"; |
| 1952 | goto filtered; |
| 1953 | } |
| 1954 | |
| 1955 | attr_new2 = bgp_attr_intern (&new_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1956 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1957 | /* Apply import policy. */ |
| 1958 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1959 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1960 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1961 | |
| 1962 | reason = "import-policy;"; |
| 1963 | goto filtered; |
| 1964 | } |
| 1965 | |
| 1966 | attr_new = bgp_attr_intern (&new_attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1967 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1968 | |
| 1969 | /* IPv4 unicast next hop check. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1970 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1971 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1972 | /* Next hop must not be 0.0.0.0 nor Class D/E address. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1973 | if (new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1974 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1975 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1976 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1977 | |
| 1978 | reason = "martian next-hop;"; |
| 1979 | goto filtered; |
| 1980 | } |
| 1981 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1982 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1983 | /* If the update is implicit withdraw. */ |
| 1984 | if (ri) |
| 1985 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1986 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1987 | |
| 1988 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1989 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1990 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1991 | { |
| 1992 | |
paul | 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]; |
| 2132 | |
Lou Berger | 370b7e5 | 2016-02-04 21:29:49 -0500 | [diff] [blame] | 2133 | memset (&new_attr, 0, sizeof(struct attr)); |
| 2134 | memset (&new_extra, 0, sizeof(struct attr_extra)); |
| 2135 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2136 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2137 | 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] | 2138 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2139 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2140 | Adj-RIBs-In. */ |
Jorge Boncompte [DTI2] | 343aa82 | 2012-05-07 16:53:08 +0000 | [diff] [blame] | 2141 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2142 | && peer != bgp->peer_self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2143 | bgp_adj_in_set (rn, peer, attr); |
| 2144 | |
| 2145 | /* Check previously received route. */ |
| 2146 | for (ri = rn->info; ri; ri = ri->next) |
| 2147 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2148 | break; |
| 2149 | |
| 2150 | /* AS path local-as loop check. */ |
| 2151 | if (peer->change_local_as) |
| 2152 | { |
| 2153 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 2154 | aspath_loop_count = 1; |
| 2155 | |
| 2156 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 2157 | { |
| 2158 | reason = "as-path contains our own AS;"; |
| 2159 | goto filtered; |
| 2160 | } |
| 2161 | } |
| 2162 | |
| 2163 | /* AS path loop check. */ |
| 2164 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 2165 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2166 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2167 | > peer->allowas_in[afi][safi])) |
| 2168 | { |
| 2169 | reason = "as-path contains our own AS;"; |
| 2170 | goto filtered; |
| 2171 | } |
| 2172 | |
| 2173 | /* Route reflector originator ID check. */ |
| 2174 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2175 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2176 | { |
| 2177 | reason = "originator is us;"; |
| 2178 | goto filtered; |
| 2179 | } |
| 2180 | |
| 2181 | /* Route reflector cluster ID check. */ |
| 2182 | if (bgp_cluster_filter (peer, attr)) |
| 2183 | { |
| 2184 | reason = "reflected from the same cluster;"; |
| 2185 | goto filtered; |
| 2186 | } |
| 2187 | |
| 2188 | /* Apply incoming filter. */ |
| 2189 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2190 | { |
| 2191 | reason = "filter;"; |
| 2192 | goto filtered; |
| 2193 | } |
| 2194 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2195 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2196 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2197 | |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2198 | /* Apply incoming route-map. |
| 2199 | * NB: new_attr may now contain newly allocated values from route-map "set" |
| 2200 | * commands, so we need bgp_attr_flush in the error paths, until we intern |
| 2201 | * the attr (which takes over the memory references) */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2202 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2203 | { |
| 2204 | reason = "route-map;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2205 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2206 | goto filtered; |
| 2207 | } |
| 2208 | |
| 2209 | /* IPv4 unicast next hop check. */ |
| 2210 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2211 | { |
| 2212 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2213 | discard it. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2214 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 |
Denis Ovsienko | 8e80bdf | 2011-08-05 18:52:52 +0400 | [diff] [blame] | 2215 | && ! bgp_nexthop_onlink (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2216 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2217 | { |
| 2218 | reason = "non-connected next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2219 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2220 | goto filtered; |
| 2221 | } |
| 2222 | |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2223 | /* 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] | 2224 | must not be my own address. */ |
Jorge Boncompte [DTI2] | 10f9bf3 | 2012-05-07 16:52:52 +0000 | [diff] [blame] | 2225 | if (new_attr.nexthop.s_addr == 0 |
| 2226 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) |
| 2227 | || bgp_nexthop_self (&new_attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2228 | { |
| 2229 | reason = "martian next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2230 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2231 | goto filtered; |
| 2232 | } |
| 2233 | } |
| 2234 | |
| 2235 | attr_new = bgp_attr_intern (&new_attr); |
| 2236 | |
| 2237 | /* If the update is implicit withdraw. */ |
| 2238 | if (ri) |
| 2239 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2240 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2241 | |
| 2242 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2243 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2244 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2245 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2246 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2247 | && peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2248 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2249 | { |
| 2250 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2251 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2252 | peer->host, |
| 2253 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2254 | p->prefixlen); |
| 2255 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2256 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2257 | { |
| 2258 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2259 | bgp_process (bgp, rn, afi, safi); |
| 2260 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2261 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2262 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2263 | { |
| 2264 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2265 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2266 | "%s rcvd %s/%d...duplicate ignored", |
| 2267 | peer->host, |
| 2268 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2269 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2270 | |
| 2271 | /* graceful restart STALE flag unset. */ |
| 2272 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2273 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2274 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2275 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2276 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2277 | } |
| 2278 | |
| 2279 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2280 | bgp_attr_unintern (&attr_new); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2281 | bgp_attr_flush (&new_attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2282 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2283 | return 0; |
| 2284 | } |
| 2285 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2286 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2287 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2288 | { |
| 2289 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2290 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2291 | peer->host, |
| 2292 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2293 | p->prefixlen); |
| 2294 | bgp_info_restore (rn, ri); |
| 2295 | } |
| 2296 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2297 | /* Received Logging. */ |
| 2298 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2299 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2300 | peer->host, |
| 2301 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2302 | p->prefixlen); |
| 2303 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2304 | /* graceful restart STALE flag unset. */ |
| 2305 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2306 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2307 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2308 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2309 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2310 | |
| 2311 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2312 | * only if update is accepted, they'll increment below. |
| 2313 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2314 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2315 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2316 | /* Update bgp route dampening information. */ |
| 2317 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2318 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2319 | { |
| 2320 | /* This is implicit withdraw so we should update dampening |
| 2321 | information. */ |
| 2322 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2323 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2324 | } |
| 2325 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2326 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2327 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2328 | ri->attr = attr_new; |
| 2329 | |
| 2330 | /* Update MPLS tag. */ |
| 2331 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2332 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2333 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2334 | bgp_attr_flush (&new_attr); |
| 2335 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2336 | /* Update bgp route dampening information. */ |
| 2337 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2338 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2339 | { |
| 2340 | /* Now we do normal update dampening. */ |
| 2341 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2342 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2343 | { |
| 2344 | bgp_unlock_node (rn); |
| 2345 | return 0; |
| 2346 | } |
| 2347 | } |
| 2348 | |
| 2349 | /* Nexthop reachability check. */ |
| 2350 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2351 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2352 | && (peer->sort == BGP_PEER_IBGP |
| 2353 | || peer->sort == BGP_PEER_CONFED |
| 2354 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2355 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2356 | { |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 2357 | if (bgp_find_or_add_nexthop (afi, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2358 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2359 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2360 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2361 | } |
| 2362 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2363 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2364 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2365 | bgp_attr_flush (&new_attr); |
| 2366 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2367 | /* Process change. */ |
| 2368 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2369 | |
| 2370 | bgp_process (bgp, rn, afi, safi); |
| 2371 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2372 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2373 | return 0; |
| 2374 | } |
| 2375 | |
| 2376 | /* Received Logging. */ |
| 2377 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2378 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2379 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2380 | peer->host, |
| 2381 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2382 | p->prefixlen); |
| 2383 | } |
| 2384 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2385 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 2386 | new = info_make(type, sub_type, peer, attr_new, rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2387 | |
| 2388 | /* Update MPLS tag. */ |
| 2389 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2390 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2391 | |
| 2392 | /* Nexthop reachability check. */ |
| 2393 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2394 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2395 | && (peer->sort == BGP_PEER_IBGP |
| 2396 | || peer->sort == BGP_PEER_CONFED |
| 2397 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2398 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2399 | { |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 2400 | if (bgp_find_or_add_nexthop (afi, new, NULL, NULL)) |
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 |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2403 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2404 | } |
| 2405 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2406 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2407 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2408 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2409 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2410 | |
| 2411 | /* Register new BGP information. */ |
| 2412 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2413 | |
| 2414 | /* route_node_get lock */ |
| 2415 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2416 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2417 | bgp_attr_flush (&new_attr); |
| 2418 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2419 | /* If maximum prefix count is configured and current prefix |
| 2420 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2421 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2422 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2423 | |
| 2424 | /* Process change. */ |
| 2425 | bgp_process (bgp, rn, afi, safi); |
| 2426 | |
| 2427 | return 0; |
| 2428 | |
| 2429 | /* This BGP update is filtered. Log the reason then update BGP |
| 2430 | entry. */ |
| 2431 | filtered: |
| 2432 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2433 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2434 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2435 | peer->host, |
| 2436 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2437 | p->prefixlen, reason); |
| 2438 | |
| 2439 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2440 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2441 | |
| 2442 | bgp_unlock_node (rn); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2443 | bgp_attr_flush (&new_attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2444 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2445 | return 0; |
| 2446 | } |
| 2447 | |
| 2448 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2449 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2450 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2451 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2452 | { |
| 2453 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2454 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2455 | struct bgp *bgp; |
| 2456 | int ret; |
| 2457 | |
| 2458 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2459 | soft_reconfig); |
| 2460 | |
| 2461 | bgp = peer->bgp; |
| 2462 | |
| 2463 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2464 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2465 | { |
| 2466 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2467 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2468 | sub_type, prd, tag); |
| 2469 | } |
| 2470 | |
| 2471 | return ret; |
| 2472 | } |
| 2473 | |
| 2474 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2475 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2476 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2477 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2478 | { |
| 2479 | struct bgp *bgp; |
| 2480 | char buf[SU_ADDRSTRLEN]; |
| 2481 | struct bgp_node *rn; |
| 2482 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2483 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2484 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2485 | |
| 2486 | bgp = peer->bgp; |
| 2487 | |
David Lamparter | 4584c23 | 2015-04-13 09:50:00 +0200 | [diff] [blame] | 2488 | /* Lookup node. */ |
| 2489 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
| 2490 | |
| 2491 | /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all |
| 2492 | * routes that are filtered. This tanks out Quagga RS pretty badly due to |
| 2493 | * the iteration over all RS clients. |
| 2494 | * Since we need to remove the entry from adj_in anyway, do that first and |
| 2495 | * if there was no entry, we don't need to do anything more. */ |
| 2496 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2497 | && peer != bgp->peer_self) |
| 2498 | if (!bgp_adj_in_unset (rn, peer)) |
| 2499 | { |
| 2500 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2501 | zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d " |
| 2502 | "not in adj-in", peer->host, |
| 2503 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2504 | p->prefixlen); |
| 2505 | bgp_unlock_node (rn); |
| 2506 | return 0; |
| 2507 | } |
| 2508 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2509 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2510 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2511 | { |
| 2512 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2513 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2514 | } |
| 2515 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2516 | /* Logging. */ |
| 2517 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2518 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2519 | peer->host, |
| 2520 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2521 | p->prefixlen); |
| 2522 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2523 | /* Lookup withdrawn route. */ |
| 2524 | for (ri = rn->info; ri; ri = ri->next) |
| 2525 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2526 | break; |
| 2527 | |
| 2528 | /* Withdraw specified route from routing table. */ |
| 2529 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2530 | bgp_rib_withdraw (rn, ri, peer, afi, safi, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2531 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2532 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2533 | "%s Can't find the route %s/%d", peer->host, |
| 2534 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2535 | p->prefixlen); |
| 2536 | |
| 2537 | /* Unlock bgp_node_get() lock. */ |
| 2538 | bgp_unlock_node (rn); |
| 2539 | |
| 2540 | return 0; |
| 2541 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2542 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2543 | void |
| 2544 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2545 | { |
| 2546 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 2547 | struct attr attr; |
Jorge Boncompte [DTI2] | 577ac57 | 2012-05-07 16:53:06 +0000 | [diff] [blame] | 2548 | struct aspath *aspath; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2549 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2550 | struct peer *from; |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2551 | struct bgp_node *rn; |
| 2552 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2553 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2554 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2555 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2556 | return; |
| 2557 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2558 | bgp = peer->bgp; |
| 2559 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2560 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2561 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2562 | aspath = attr.aspath; |
| 2563 | attr.local_pref = bgp->default_local_pref; |
| 2564 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2565 | |
| 2566 | if (afi == AFI_IP) |
| 2567 | str2prefix ("0.0.0.0/0", &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2568 | else if (afi == AFI_IP6) |
| 2569 | { |
Jorge Boncompte [DTI2] | 6182d65 | 2012-05-07 16:53:02 +0000 | [diff] [blame] | 2570 | struct attr_extra *ae = attr.extra; |
| 2571 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2572 | str2prefix ("::/0", &p); |
| 2573 | |
| 2574 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2575 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2576 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2577 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2578 | |
| 2579 | /* If the peer is on shared nextwork and we have link-local |
| 2580 | nexthop set it. */ |
| 2581 | if (peer->shared_network |
| 2582 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2583 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2584 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2585 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2586 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2587 | } |
| 2588 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2589 | |
| 2590 | if (peer->default_rmap[afi][safi].name) |
| 2591 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2592 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2593 | for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn)) |
| 2594 | { |
| 2595 | for (ri = rn->info; ri; ri = ri->next) |
| 2596 | { |
| 2597 | struct attr dummy_attr; |
| 2598 | struct attr_extra dummy_extra; |
| 2599 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2600 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2601 | /* Provide dummy so the route-map can't modify the attributes */ |
| 2602 | dummy_attr.extra = &dummy_extra; |
| 2603 | bgp_attr_dup(&dummy_attr, ri->attr); |
| 2604 | info.peer = ri->peer; |
| 2605 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2606 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2607 | ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p, |
| 2608 | RMAP_BGP, &info); |
| 2609 | |
| 2610 | /* The route map might have set attributes. If we don't flush them |
| 2611 | * here, they will be leaked. */ |
| 2612 | bgp_attr_flush(&dummy_attr); |
| 2613 | if (ret != RMAP_DENYMATCH) |
| 2614 | break; |
| 2615 | } |
| 2616 | if (ret != RMAP_DENYMATCH) |
| 2617 | break; |
| 2618 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2619 | bgp->peer_self->rmap_type = 0; |
| 2620 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2621 | if (ret == RMAP_DENYMATCH) |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2622 | withdraw = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2623 | } |
| 2624 | |
| 2625 | if (withdraw) |
| 2626 | { |
| 2627 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2628 | bgp_default_withdraw_send (peer, afi, safi); |
| 2629 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2630 | } |
| 2631 | else |
| 2632 | { |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2633 | if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2634 | { |
| 2635 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2636 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2637 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2638 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2639 | |
| 2640 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2641 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2642 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2643 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2644 | static void |
| 2645 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2646 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2647 | { |
| 2648 | struct bgp_node *rn; |
| 2649 | struct bgp_info *ri; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2650 | struct attr attr; |
| 2651 | struct attr_extra extra; |
| 2652 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2653 | memset(&extra, 0, sizeof(extra)); |
| 2654 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2655 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2656 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2657 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2658 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2659 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2660 | bgp_default_originate (peer, afi, safi, 0); |
| 2661 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2662 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 2663 | attr.extra = &extra; |
| 2664 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2665 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2666 | for (ri = rn->info; ri; ri = ri->next) |
| 2667 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2668 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2669 | if ( (rsclient) ? |
| 2670 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2671 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2672 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2673 | else |
| 2674 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2675 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2676 | |
| 2677 | bgp_attr_flush_encap(&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2678 | } |
| 2679 | |
| 2680 | void |
| 2681 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2682 | { |
| 2683 | struct bgp_node *rn; |
| 2684 | struct bgp_table *table; |
| 2685 | |
| 2686 | if (peer->status != Established) |
| 2687 | return; |
| 2688 | |
| 2689 | if (! peer->afc_nego[afi][safi]) |
| 2690 | return; |
| 2691 | |
| 2692 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2693 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2694 | return; |
| 2695 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2696 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2697 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2698 | else |
| 2699 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2700 | rn = bgp_route_next(rn)) |
| 2701 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2702 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2703 | |
| 2704 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2705 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2706 | } |
| 2707 | |
| 2708 | void |
| 2709 | bgp_announce_route_all (struct peer *peer) |
| 2710 | { |
| 2711 | afi_t afi; |
| 2712 | safi_t safi; |
| 2713 | |
| 2714 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2715 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2716 | bgp_announce_route (peer, afi, safi); |
| 2717 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2718 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2719 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2720 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2721 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2722 | { |
| 2723 | struct bgp_node *rn; |
| 2724 | struct bgp_adj_in *ain; |
| 2725 | |
| 2726 | if (! table) |
| 2727 | table = rsclient->bgp->rib[afi][safi]; |
| 2728 | |
| 2729 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2730 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2731 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2732 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2733 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2734 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2735 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2736 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2737 | } |
| 2738 | } |
| 2739 | |
| 2740 | void |
| 2741 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2742 | { |
| 2743 | struct bgp_table *table; |
| 2744 | struct bgp_node *rn; |
| 2745 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2746 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2747 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2748 | |
| 2749 | else |
| 2750 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2751 | rn = bgp_route_next (rn)) |
| 2752 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2753 | { |
| 2754 | struct prefix_rd prd; |
| 2755 | prd.family = AF_UNSPEC; |
| 2756 | prd.prefixlen = 64; |
| 2757 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2758 | |
| 2759 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); |
| 2760 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2761 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2762 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2763 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2764 | 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] | 2765 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2766 | { |
| 2767 | int ret; |
| 2768 | struct bgp_node *rn; |
| 2769 | struct bgp_adj_in *ain; |
| 2770 | |
| 2771 | if (! table) |
| 2772 | table = peer->bgp->rib[afi][safi]; |
| 2773 | |
| 2774 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2775 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2776 | { |
| 2777 | if (ain->peer == peer) |
| 2778 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2779 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2780 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2781 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2782 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2783 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2784 | prd, tag, 1); |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2785 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2786 | if (ret < 0) |
| 2787 | { |
| 2788 | bgp_unlock_node (rn); |
| 2789 | return; |
| 2790 | } |
| 2791 | continue; |
| 2792 | } |
| 2793 | } |
| 2794 | } |
| 2795 | |
| 2796 | void |
| 2797 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2798 | { |
| 2799 | struct bgp_node *rn; |
| 2800 | struct bgp_table *table; |
| 2801 | |
| 2802 | if (peer->status != Established) |
| 2803 | return; |
| 2804 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2805 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2806 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2807 | else |
| 2808 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2809 | rn = bgp_route_next (rn)) |
| 2810 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2811 | { |
| 2812 | struct prefix_rd prd; |
| 2813 | prd.family = AF_UNSPEC; |
| 2814 | prd.prefixlen = 64; |
| 2815 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2816 | |
| 2817 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); |
| 2818 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2819 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2820 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2821 | |
| 2822 | struct bgp_clear_node_queue |
| 2823 | { |
| 2824 | struct bgp_node *rn; |
| 2825 | enum bgp_clear_route_type purpose; |
| 2826 | }; |
| 2827 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2828 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2829 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2830 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2831 | struct bgp_clear_node_queue *cnq = data; |
| 2832 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2833 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2834 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2835 | afi_t afi = bgp_node_table (rn)->afi; |
| 2836 | safi_t safi = bgp_node_table (rn)->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2837 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2838 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2839 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2840 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2841 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2842 | { |
| 2843 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2844 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2845 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2846 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2847 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2848 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2849 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2850 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2851 | break; |
| 2852 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2853 | return WQ_SUCCESS; |
| 2854 | } |
| 2855 | |
| 2856 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2857 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2858 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2859 | struct bgp_clear_node_queue *cnq = data; |
| 2860 | struct bgp_node *rn = cnq->rn; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2861 | struct bgp_table *table = bgp_node_table (rn); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2862 | |
| 2863 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2864 | bgp_table_unlock (table); |
| 2865 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2866 | } |
| 2867 | |
| 2868 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2869 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2870 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2871 | struct peer *peer = wq->spec.data; |
| 2872 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2873 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2874 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2875 | |
| 2876 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2877 | } |
| 2878 | |
| 2879 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2880 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2881 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2882 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2883 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2884 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2885 | #undef CLEAR_QUEUE_NAME_LEN |
| 2886 | |
| 2887 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2888 | { |
| 2889 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2890 | exit (1); |
| 2891 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2892 | peer->clear_node_queue->spec.hold = 10; |
| 2893 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2894 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2895 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2896 | peer->clear_node_queue->spec.max_retries = 0; |
| 2897 | |
| 2898 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2899 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2900 | } |
| 2901 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2902 | static void |
| 2903 | 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] | 2904 | struct bgp_table *table, struct peer *rsclient, |
| 2905 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2906 | { |
| 2907 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2908 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2909 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2910 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2911 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2912 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2913 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2914 | if (! table) |
| 2915 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2916 | |
| 2917 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2918 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2919 | struct bgp_info *ri; |
| 2920 | struct bgp_adj_in *ain; |
| 2921 | struct bgp_adj_out *aout; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2922 | |
| 2923 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2924 | * queued for every clearing peer, regardless of whether it is |
| 2925 | * relevant to the peer at hand. |
| 2926 | * |
| 2927 | * Overview: There are 3 different indices which need to be |
| 2928 | * scrubbed, potentially, when a peer is removed: |
| 2929 | * |
| 2930 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2931 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2932 | * 3 other routes visible by the peer's adj-out index |
| 2933 | * |
| 2934 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2935 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2936 | * adj-outs at our leisure. |
| 2937 | * |
| 2938 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2939 | * invisible via RIB index before peer session is allowed to be |
| 2940 | * brought back up. So one needs to know when such a 'search' is |
| 2941 | * complete. |
| 2942 | * |
| 2943 | * Ideally: |
| 2944 | * |
| 2945 | * - there'd be a single global queue or a single RIB walker |
| 2946 | * - rather than tracking which route_nodes still need to be |
| 2947 | * examined on a peer basis, we'd track which peers still |
| 2948 | * aren't cleared |
| 2949 | * |
| 2950 | * Given that our per-peer prefix-counts now should be reliable, |
| 2951 | * this may actually be achievable. It doesn't seem to be a huge |
| 2952 | * problem at this time, |
| 2953 | */ |
Jorge Boncompte [DTI2] | 24e50f2 | 2012-05-07 15:17:33 +0000 | [diff] [blame] | 2954 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2955 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2956 | { |
| 2957 | bgp_adj_in_remove (rn, ain); |
| 2958 | bgp_unlock_node (rn); |
| 2959 | break; |
| 2960 | } |
| 2961 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2962 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2963 | { |
| 2964 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2965 | bgp_unlock_node (rn); |
| 2966 | break; |
| 2967 | } |
| 2968 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2969 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2970 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2971 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2972 | struct bgp_clear_node_queue *cnq; |
| 2973 | |
| 2974 | /* both unlocked in bgp_clear_node_queue_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2975 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2976 | bgp_lock_node (rn); |
| 2977 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2978 | sizeof (struct bgp_clear_node_queue)); |
| 2979 | cnq->rn = rn; |
| 2980 | cnq->purpose = purpose; |
| 2981 | work_queue_add (peer->clear_node_queue, cnq); |
| 2982 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2983 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2984 | } |
| 2985 | return; |
| 2986 | } |
| 2987 | |
| 2988 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2989 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 2990 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2991 | { |
| 2992 | struct bgp_node *rn; |
| 2993 | struct bgp_table *table; |
| 2994 | struct peer *rsclient; |
| 2995 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2996 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2997 | if (peer->clear_node_queue == NULL) |
| 2998 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2999 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 3000 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 3001 | * Idle until it receives a Clearing_Completed event. This protects |
| 3002 | * against peers which flap faster than we can we clear, which could |
| 3003 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3004 | * |
| 3005 | * a) race with routes from the new session being installed before |
| 3006 | * clear_route_node visits the node (to delete the route of that |
| 3007 | * peer) |
| 3008 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 3009 | * on the process_main queue. Fast-flapping could cause that queue |
| 3010 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3011 | */ |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3012 | |
| 3013 | /* lock peer in assumption that clear-node-queue will get nodes; if so, |
| 3014 | * the unlock will happen upon work-queue completion; other wise, the |
| 3015 | * unlock happens at the end of this function. |
| 3016 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 3017 | if (!peer->clear_node_queue->thread) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3018 | peer_lock (peer); /* bgp_clear_node_complete */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3019 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3020 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3021 | case BGP_CLEAR_ROUTE_NORMAL: |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3022 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3023 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 3024 | else |
| 3025 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 3026 | rn = bgp_route_next (rn)) |
| 3027 | if ((table = rn->info) != NULL) |
| 3028 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 3029 | |
| 3030 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 3031 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 3032 | PEER_FLAG_RSERVER_CLIENT)) |
| 3033 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 3034 | break; |
| 3035 | |
| 3036 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3037 | /* |
| 3038 | * gpz 091009: TBD why don't we have special handling for |
| 3039 | * SAFI_MPLS_VPN here in the original quagga code? |
| 3040 | * (and, by extension, for SAFI_ENCAP) |
| 3041 | */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3042 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 3043 | break; |
| 3044 | |
| 3045 | default: |
| 3046 | assert (0); |
| 3047 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3048 | } |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3049 | |
| 3050 | /* unlock if no nodes got added to the clear-node-queue. */ |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 3051 | if (!peer->clear_node_queue->thread) |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3052 | peer_unlock (peer); |
| 3053 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3054 | } |
| 3055 | |
| 3056 | void |
| 3057 | bgp_clear_route_all (struct peer *peer) |
| 3058 | { |
| 3059 | afi_t afi; |
| 3060 | safi_t safi; |
| 3061 | |
| 3062 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3063 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3064 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3065 | } |
| 3066 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3067 | /* |
| 3068 | * Finish freeing things when exiting |
| 3069 | */ |
| 3070 | static void |
| 3071 | bgp_drain_workqueue_immediate (struct work_queue *wq) |
| 3072 | { |
| 3073 | if (!wq) |
| 3074 | return; |
| 3075 | |
| 3076 | if (!wq->thread) |
| 3077 | { |
| 3078 | /* |
| 3079 | * no thread implies no queued items |
| 3080 | */ |
| 3081 | assert(!wq->items->count); |
| 3082 | return; |
| 3083 | } |
| 3084 | |
| 3085 | while (wq->items->count) |
| 3086 | { |
| 3087 | if (wq->thread) |
| 3088 | thread_cancel(wq->thread); |
| 3089 | work_queue_run(wq->thread); |
| 3090 | } |
| 3091 | } |
| 3092 | |
| 3093 | /* |
| 3094 | * Special function to process clear node queue when bgpd is exiting |
| 3095 | * and the thread scheduler is no longer running. |
| 3096 | */ |
| 3097 | void |
| 3098 | bgp_peer_clear_node_queue_drain_immediate(struct peer *peer) |
| 3099 | { |
| 3100 | if (!peer) |
| 3101 | return; |
| 3102 | |
| 3103 | bgp_drain_workqueue_immediate(peer->clear_node_queue); |
| 3104 | } |
| 3105 | |
| 3106 | /* |
| 3107 | * The work queues are not specific to a BGP instance, but the |
| 3108 | * items in them refer to BGP instances, so this should be called |
| 3109 | * before each BGP instance is deleted. |
| 3110 | */ |
| 3111 | void |
| 3112 | bgp_process_queues_drain_immediate(void) |
| 3113 | { |
| 3114 | bgp_drain_workqueue_immediate(bm->process_main_queue); |
| 3115 | bgp_drain_workqueue_immediate(bm->process_rsclient_queue); |
| 3116 | } |
| 3117 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3118 | void |
| 3119 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 3120 | { |
| 3121 | struct bgp_table *table; |
| 3122 | struct bgp_node *rn; |
| 3123 | struct bgp_adj_in *ain; |
| 3124 | |
| 3125 | table = peer->bgp->rib[afi][safi]; |
| 3126 | |
| 3127 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3128 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 3129 | if (ain->peer == peer) |
| 3130 | { |
| 3131 | bgp_adj_in_remove (rn, ain); |
| 3132 | bgp_unlock_node (rn); |
| 3133 | break; |
| 3134 | } |
| 3135 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 3136 | |
| 3137 | void |
| 3138 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 3139 | { |
| 3140 | struct bgp_node *rn; |
| 3141 | struct bgp_info *ri; |
| 3142 | struct bgp_table *table; |
| 3143 | |
| 3144 | table = peer->bgp->rib[afi][safi]; |
| 3145 | |
| 3146 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3147 | { |
| 3148 | for (ri = rn->info; ri; ri = ri->next) |
| 3149 | if (ri->peer == peer) |
| 3150 | { |
| 3151 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 3152 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3153 | break; |
| 3154 | } |
| 3155 | } |
| 3156 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3157 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3158 | static void |
| 3159 | bgp_cleanup_table(struct bgp_table *table, safi_t safi) |
| 3160 | { |
| 3161 | struct bgp_node *rn; |
| 3162 | struct bgp_info *ri; |
| 3163 | struct bgp_info *next; |
| 3164 | |
| 3165 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3166 | for (ri = rn->info; ri; ri = next) |
| 3167 | { |
| 3168 | next = ri->next; |
| 3169 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3170 | && ri->type == ZEBRA_ROUTE_BGP |
| 3171 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 3172 | bgp_zebra_withdraw (&rn->p, ri, safi); |
| 3173 | } |
| 3174 | } |
| 3175 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3176 | /* Delete all kernel routes. */ |
| 3177 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3178 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3179 | { |
| 3180 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3181 | struct listnode *node, *nnode; |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3182 | afi_t afi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3183 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3184 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3185 | { |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3186 | for (afi = AFI_IP; afi < AFI_MAX; ++afi) |
| 3187 | { |
| 3188 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3189 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3190 | bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3191 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3192 | /* |
| 3193 | * VPN and ENCAP tables are two-level (RD is top level) |
| 3194 | */ |
| 3195 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn; |
| 3196 | rn = bgp_route_next (rn)) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3197 | { |
| 3198 | if (rn->info) |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3199 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3200 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN); |
| 3201 | bgp_table_finish ((struct bgp_table **)&(rn->info)); |
| 3202 | rn->info = NULL; |
| 3203 | bgp_unlock_node(rn); |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3204 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3205 | } |
| 3206 | |
| 3207 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn; |
| 3208 | rn = bgp_route_next (rn)) |
| 3209 | { |
| 3210 | if (rn->info) |
| 3211 | { |
| 3212 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP); |
| 3213 | bgp_table_finish ((struct bgp_table **)&(rn->info)); |
| 3214 | rn->info = NULL; |
| 3215 | bgp_unlock_node(rn); |
| 3216 | } |
| 3217 | } |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3218 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3219 | } |
| 3220 | } |
| 3221 | |
| 3222 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3223 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3224 | { |
| 3225 | vty_reset (); |
| 3226 | bgp_zclient_reset (); |
| 3227 | access_list_reset (); |
| 3228 | prefix_list_reset (); |
| 3229 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3230 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3231 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3232 | value. */ |
| 3233 | int |
Paul Jakma | 518a4b7 | 2016-02-04 13:27:04 +0000 | [diff] [blame] | 3234 | bgp_nlri_parse_ip (struct peer *peer, struct attr *attr, |
| 3235 | struct bgp_nlri *packet) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3236 | { |
| 3237 | u_char *pnt; |
| 3238 | u_char *lim; |
| 3239 | struct prefix p; |
| 3240 | int psize; |
| 3241 | int ret; |
| 3242 | |
| 3243 | /* Check peer status. */ |
| 3244 | if (peer->status != Established) |
| 3245 | return 0; |
| 3246 | |
| 3247 | pnt = packet->nlri; |
| 3248 | lim = pnt + packet->length; |
| 3249 | |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3250 | /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for |
| 3251 | syntactic validity. If the field is syntactically incorrect, |
| 3252 | then the Error Subcode is set to Invalid Network Field. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3253 | for (; pnt < lim; pnt += psize) |
| 3254 | { |
| 3255 | /* Clear prefix structure. */ |
| 3256 | memset (&p, 0, sizeof (struct prefix)); |
| 3257 | |
| 3258 | /* Fetch prefix length. */ |
| 3259 | p.prefixlen = *pnt++; |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3260 | /* afi/safi validity already verified by caller, bgp_update_receive */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3261 | p.family = afi2family (packet->afi); |
| 3262 | |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3263 | /* Prefix length check. */ |
| 3264 | if (p.prefixlen > prefix_blen (&p) * 8) |
| 3265 | { |
| 3266 | plog_err (peer->log, |
| 3267 | "%s [Error] Update packet error" |
| 3268 | " (wrong prefix length %u for afi %u)", |
| 3269 | peer->host, p.prefixlen, packet->afi); |
| 3270 | return -1; |
| 3271 | } |
| 3272 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3273 | /* Packet size overflow check. */ |
| 3274 | psize = PSIZE (p.prefixlen); |
| 3275 | |
| 3276 | /* When packet overflow occur return immediately. */ |
| 3277 | if (pnt + psize > lim) |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3278 | { |
| 3279 | plog_err (peer->log, |
| 3280 | "%s [Error] Update packet error" |
| 3281 | " (prefix length %u overflows packet)", |
| 3282 | peer->host, p.prefixlen); |
| 3283 | return -1; |
| 3284 | } |
| 3285 | |
| 3286 | /* Defensive coding, double-check the psize fits in a struct prefix */ |
| 3287 | if (psize > (ssize_t) sizeof(p.u)) |
| 3288 | { |
| 3289 | plog_err (peer->log, |
| 3290 | "%s [Error] Update packet error" |
| 3291 | " (prefix length %u too large for prefix storage %zu!?!!", |
| 3292 | peer->host, p.prefixlen, sizeof(p.u)); |
| 3293 | return -1; |
| 3294 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3295 | |
| 3296 | /* Fetch prefix from NLRI packet. */ |
| 3297 | memcpy (&p.u.prefix, pnt, psize); |
| 3298 | |
| 3299 | /* Check address. */ |
| 3300 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3301 | { |
| 3302 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3303 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3304 | /* |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3305 | * From RFC4271 Section 6.3: |
| 3306 | * |
| 3307 | * If a prefix in the NLRI field is semantically incorrect |
| 3308 | * (e.g., an unexpected multicast IP address), an error SHOULD |
| 3309 | * be logged locally, and the prefix SHOULD be ignored. |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3310 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3311 | zlog (peer->log, LOG_ERR, |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3312 | "%s: IPv4 unicast NLRI is multicast address %s, ignoring", |
| 3313 | peer->host, inet_ntoa (p.u.prefix4)); |
| 3314 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3315 | } |
| 3316 | } |
| 3317 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3318 | /* Check address. */ |
| 3319 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3320 | { |
| 3321 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3322 | { |
| 3323 | char buf[BUFSIZ]; |
| 3324 | |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3325 | zlog (peer->log, LOG_ERR, |
| 3326 | "%s: IPv6 unicast NLRI is link-local address %s, ignoring", |
| 3327 | peer->host, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3328 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3329 | continue; |
| 3330 | } |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3331 | if (IN6_IS_ADDR_MULTICAST (&p.u.prefix6)) |
| 3332 | { |
| 3333 | char buf[BUFSIZ]; |
| 3334 | |
| 3335 | zlog (peer->log, LOG_ERR, |
| 3336 | "%s: IPv6 unicast NLRI is multicast address %s, ignoring", |
| 3337 | peer->host, |
| 3338 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3339 | continue; |
| 3340 | } |
| 3341 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3342 | |
| 3343 | /* Normal process. */ |
| 3344 | if (attr) |
| 3345 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3346 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3347 | else |
| 3348 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3349 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3350 | |
| 3351 | /* Address family configuration mismatch or maximum-prefix count |
| 3352 | overflow. */ |
| 3353 | if (ret < 0) |
| 3354 | return -1; |
| 3355 | } |
| 3356 | |
| 3357 | /* Packet length consistency check. */ |
| 3358 | if (pnt != lim) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3359 | { |
| 3360 | plog_err (peer->log, |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3361 | "%s [Error] Update packet error" |
| 3362 | " (prefix length mismatch with total length)", |
| 3363 | peer->host); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3364 | return -1; |
| 3365 | } |
Paul Jakma | 405e9e1 | 2016-02-04 17:00:18 +0000 | [diff] [blame] | 3366 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3367 | return 0; |
| 3368 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3369 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3370 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3371 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3372 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3373 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3374 | } |
| 3375 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3376 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3377 | bgp_static_free (struct bgp_static *bgp_static) |
| 3378 | { |
| 3379 | if (bgp_static->rmap.name) |
| 3380 | free (bgp_static->rmap.name); |
| 3381 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3382 | } |
| 3383 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3384 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3385 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3386 | struct prefix *p, afi_t afi, safi_t safi) |
| 3387 | { |
| 3388 | struct bgp_node *rn; |
| 3389 | struct bgp_info *ri; |
| 3390 | |
| 3391 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3392 | |
| 3393 | /* Check selected route and self inserted route. */ |
| 3394 | for (ri = rn->info; ri; ri = ri->next) |
| 3395 | if (ri->peer == bgp->peer_self |
| 3396 | && ri->type == ZEBRA_ROUTE_BGP |
| 3397 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3398 | break; |
| 3399 | |
| 3400 | /* Withdraw static BGP route from routing table. */ |
| 3401 | if (ri) |
| 3402 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3403 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3404 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3405 | } |
| 3406 | |
| 3407 | /* Unlock bgp_node_lookup. */ |
| 3408 | bgp_unlock_node (rn); |
| 3409 | } |
| 3410 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3411 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3412 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3413 | struct bgp_static *bgp_static, |
| 3414 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3415 | { |
| 3416 | struct bgp_node *rn; |
| 3417 | struct bgp_info *ri; |
| 3418 | struct bgp_info *new; |
| 3419 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3420 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3421 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3422 | struct attr new_attr; |
| 3423 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3424 | struct bgp *bgp; |
| 3425 | int ret; |
| 3426 | char buf[SU_ADDRSTRLEN]; |
| 3427 | |
| 3428 | bgp = rsclient->bgp; |
| 3429 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3430 | assert (bgp_static); |
| 3431 | if (!bgp_static) |
| 3432 | return; |
| 3433 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3434 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3435 | |
| 3436 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3437 | |
| 3438 | attr.nexthop = bgp_static->igpnexthop; |
| 3439 | attr.med = bgp_static->igpmetric; |
| 3440 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3441 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3442 | if (bgp_static->atomic) |
| 3443 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3444 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3445 | /* Apply network route-map for export to this rsclient. */ |
| 3446 | if (bgp_static->rmap.name) |
| 3447 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3448 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3449 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3450 | info.attr = &attr_tmp; |
| 3451 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3452 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3453 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3454 | |
| 3455 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3456 | |
| 3457 | rsclient->rmap_type = 0; |
| 3458 | |
| 3459 | if (ret == RMAP_DENYMATCH) |
| 3460 | { |
| 3461 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3462 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3463 | |
| 3464 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3465 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3466 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3467 | bgp_attr_extra_free (&attr); |
| 3468 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3469 | return; |
| 3470 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3471 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3472 | } |
| 3473 | else |
| 3474 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3475 | |
| 3476 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3477 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3478 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3479 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3480 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3481 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3482 | == RMAP_DENY) |
| 3483 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3484 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3485 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3486 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3487 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3488 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3489 | p->prefixlen, rsclient->host); |
| 3490 | |
| 3491 | bgp->peer_self->rmap_type = 0; |
| 3492 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3493 | bgp_attr_unintern (&attr_new); |
| 3494 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3495 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3496 | |
| 3497 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3498 | |
| 3499 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3500 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3501 | |
| 3502 | bgp->peer_self->rmap_type = 0; |
| 3503 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3504 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3505 | attr_new = bgp_attr_intern (&new_attr); |
| 3506 | |
| 3507 | for (ri = rn->info; ri; ri = ri->next) |
| 3508 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3509 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3510 | break; |
| 3511 | |
| 3512 | if (ri) |
| 3513 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3514 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3515 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3516 | { |
| 3517 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3518 | bgp_attr_unintern (&attr_new); |
| 3519 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3520 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3521 | return; |
| 3522 | } |
| 3523 | else |
| 3524 | { |
| 3525 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3526 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3527 | |
| 3528 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3529 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3530 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3531 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3532 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3533 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3534 | |
| 3535 | /* Process change. */ |
| 3536 | bgp_process (bgp, rn, afi, safi); |
| 3537 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3538 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3539 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3540 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3541 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3542 | } |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3543 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3544 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3545 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, |
| 3546 | attr_new, rn); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3547 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3548 | |
| 3549 | /* Register new BGP information. */ |
| 3550 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3551 | |
| 3552 | /* route_node_get lock */ |
| 3553 | bgp_unlock_node (rn); |
| 3554 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3555 | /* Process change. */ |
| 3556 | bgp_process (bgp, rn, afi, safi); |
| 3557 | |
| 3558 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3559 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3560 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3561 | } |
| 3562 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3563 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3564 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3565 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3566 | { |
| 3567 | struct bgp_node *rn; |
| 3568 | struct bgp_info *ri; |
| 3569 | struct bgp_info *new; |
| 3570 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3571 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3572 | struct attr *attr_new; |
| 3573 | int ret; |
| 3574 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3575 | assert (bgp_static); |
| 3576 | if (!bgp_static) |
| 3577 | return; |
| 3578 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3579 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3580 | |
| 3581 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3582 | |
| 3583 | attr.nexthop = bgp_static->igpnexthop; |
| 3584 | attr.med = bgp_static->igpmetric; |
| 3585 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3586 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3587 | if (bgp_static->atomic) |
| 3588 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3589 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3590 | /* Apply route-map. */ |
| 3591 | if (bgp_static->rmap.name) |
| 3592 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3593 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3594 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3595 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3596 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3597 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3598 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3599 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3600 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3601 | bgp->peer_self->rmap_type = 0; |
| 3602 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3603 | if (ret == RMAP_DENYMATCH) |
| 3604 | { |
| 3605 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3606 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3607 | |
| 3608 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3609 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3610 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3611 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3612 | return; |
| 3613 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3614 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3615 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3616 | else |
| 3617 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3618 | |
| 3619 | for (ri = rn->info; ri; ri = ri->next) |
| 3620 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3621 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3622 | break; |
| 3623 | |
| 3624 | if (ri) |
| 3625 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3626 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3627 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3628 | { |
| 3629 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3630 | bgp_attr_unintern (&attr_new); |
| 3631 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3632 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3633 | return; |
| 3634 | } |
| 3635 | else |
| 3636 | { |
| 3637 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3638 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3639 | |
| 3640 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3641 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3642 | bgp_info_restore(rn, ri); |
| 3643 | else |
| 3644 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3645 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3646 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3647 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3648 | |
| 3649 | /* Process change. */ |
| 3650 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3651 | bgp_process (bgp, rn, afi, safi); |
| 3652 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3653 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3654 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3655 | return; |
| 3656 | } |
| 3657 | } |
| 3658 | |
| 3659 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3660 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, attr_new, |
| 3661 | rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3662 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3663 | |
| 3664 | /* Aggregate address increment. */ |
| 3665 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3666 | |
| 3667 | /* Register new BGP information. */ |
| 3668 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3669 | |
| 3670 | /* route_node_get lock */ |
| 3671 | bgp_unlock_node (rn); |
| 3672 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3673 | /* Process change. */ |
| 3674 | bgp_process (bgp, rn, afi, safi); |
| 3675 | |
| 3676 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3677 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3678 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3679 | } |
| 3680 | |
| 3681 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3682 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3683 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3684 | { |
| 3685 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3686 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3687 | |
| 3688 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3689 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3690 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3691 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3692 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3693 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3694 | } |
| 3695 | } |
| 3696 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3697 | void |
| 3698 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3699 | safi_t safi) |
| 3700 | { |
| 3701 | struct bgp_node *rn; |
| 3702 | struct bgp_info *ri; |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3703 | struct bgp_info *new; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3704 | |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3705 | /* Make new BGP info. */ |
| 3706 | rn = bgp_node_get (bgp->rib[afi][safi], p); |
| 3707 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, |
| 3708 | bgp_attr_default_intern(BGP_ORIGIN_IGP), rn); |
| 3709 | |
| 3710 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3711 | |
| 3712 | /* Check selected route and self inserted route. */ |
| 3713 | for (ri = rn->info; ri; ri = ri->next) |
| 3714 | if (ri->peer == bgp->peer_self |
| 3715 | && ri->type == ZEBRA_ROUTE_BGP |
| 3716 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3717 | break; |
| 3718 | |
| 3719 | /* Withdraw static BGP route from routing table. */ |
| 3720 | if (ri) |
| 3721 | { |
| 3722 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3723 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3724 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3725 | } |
| 3726 | |
| 3727 | /* Unlock bgp_node_lookup. */ |
| 3728 | bgp_unlock_node (rn); |
| 3729 | } |
| 3730 | |
| 3731 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3732 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3733 | { |
| 3734 | struct bgp_static *bgp_static; |
| 3735 | struct bgp *bgp; |
| 3736 | struct bgp_node *rn; |
| 3737 | struct prefix *p; |
| 3738 | |
| 3739 | bgp = rsclient->bgp; |
| 3740 | |
| 3741 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3742 | if ((bgp_static = rn->info) != NULL) |
| 3743 | { |
| 3744 | p = &rn->p; |
| 3745 | |
| 3746 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3747 | afi, safi); |
| 3748 | } |
| 3749 | } |
| 3750 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3751 | /* |
| 3752 | * Used for SAFI_MPLS_VPN and SAFI_ENCAP |
| 3753 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3754 | static void |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3755 | bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3756 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3757 | { |
| 3758 | struct bgp_node *rn; |
| 3759 | struct bgp_info *ri; |
| 3760 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3761 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3762 | |
| 3763 | /* Check selected route and self inserted route. */ |
| 3764 | for (ri = rn->info; ri; ri = ri->next) |
| 3765 | if (ri->peer == bgp->peer_self |
| 3766 | && ri->type == ZEBRA_ROUTE_BGP |
| 3767 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3768 | break; |
| 3769 | |
| 3770 | /* Withdraw static BGP route from routing table. */ |
| 3771 | if (ri) |
| 3772 | { |
| 3773 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3774 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3775 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3776 | } |
| 3777 | |
| 3778 | /* Unlock bgp_node_lookup. */ |
| 3779 | bgp_unlock_node (rn); |
| 3780 | } |
| 3781 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3782 | static void |
| 3783 | bgp_static_update_safi (struct bgp *bgp, struct prefix *p, |
| 3784 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3785 | { |
| 3786 | struct bgp_node *rn; |
| 3787 | struct bgp_info *new; |
| 3788 | struct attr *attr_new; |
| 3789 | struct attr attr = { 0 }; |
| 3790 | struct bgp_info *ri; |
| 3791 | |
| 3792 | assert (bgp_static); |
| 3793 | |
| 3794 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd); |
| 3795 | |
| 3796 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 3797 | |
| 3798 | attr.nexthop = bgp_static->igpnexthop; |
| 3799 | attr.med = bgp_static->igpmetric; |
| 3800 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 3801 | |
| 3802 | /* Apply route-map. */ |
| 3803 | if (bgp_static->rmap.name) |
| 3804 | { |
| 3805 | struct attr attr_tmp = attr; |
| 3806 | struct bgp_info info; |
| 3807 | int ret; |
| 3808 | |
| 3809 | info.peer = bgp->peer_self; |
| 3810 | info.attr = &attr_tmp; |
| 3811 | |
| 3812 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3813 | |
| 3814 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3815 | |
| 3816 | bgp->peer_self->rmap_type = 0; |
| 3817 | |
| 3818 | if (ret == RMAP_DENYMATCH) |
| 3819 | { |
| 3820 | /* Free uninterned attribute. */ |
| 3821 | bgp_attr_flush (&attr_tmp); |
| 3822 | |
| 3823 | /* Unintern original. */ |
| 3824 | aspath_unintern (&attr.aspath); |
| 3825 | bgp_attr_extra_free (&attr); |
| 3826 | bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd, |
| 3827 | bgp_static->tag); |
| 3828 | return; |
| 3829 | } |
| 3830 | |
| 3831 | attr_new = bgp_attr_intern (&attr_tmp); |
| 3832 | } |
| 3833 | else |
| 3834 | { |
| 3835 | attr_new = bgp_attr_intern (&attr); |
| 3836 | } |
| 3837 | |
| 3838 | for (ri = rn->info; ri; ri = ri->next) |
| 3839 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3840 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3841 | break; |
| 3842 | |
| 3843 | if (ri) |
| 3844 | { |
| 3845 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3846 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3847 | { |
| 3848 | bgp_unlock_node (rn); |
| 3849 | bgp_attr_unintern (&attr_new); |
| 3850 | aspath_unintern (&attr.aspath); |
| 3851 | bgp_attr_extra_free (&attr); |
| 3852 | return; |
| 3853 | } |
| 3854 | else |
| 3855 | { |
| 3856 | /* The attribute is changed. */ |
| 3857 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
| 3858 | |
| 3859 | /* Rewrite BGP route information. */ |
| 3860 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3861 | bgp_info_restore(rn, ri); |
| 3862 | else |
| 3863 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 3864 | bgp_attr_unintern (&ri->attr); |
| 3865 | ri->attr = attr_new; |
| 3866 | ri->uptime = bgp_clock (); |
| 3867 | |
| 3868 | /* Process change. */ |
| 3869 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3870 | bgp_process (bgp, rn, afi, safi); |
| 3871 | bgp_unlock_node (rn); |
| 3872 | aspath_unintern (&attr.aspath); |
| 3873 | bgp_attr_extra_free (&attr); |
| 3874 | return; |
| 3875 | } |
| 3876 | } |
| 3877 | |
| 3878 | |
| 3879 | /* Make new BGP info. */ |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 3880 | new = info_make (ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, |
| 3881 | attr_new, rn); |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3882 | SET_FLAG (new->flags, BGP_INFO_VALID); |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3883 | new->extra = bgp_info_extra_new(); |
| 3884 | memcpy (new->extra->tag, bgp_static->tag, 3); |
| 3885 | |
| 3886 | /* Aggregate address increment. */ |
| 3887 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3888 | |
| 3889 | /* Register new BGP information. */ |
| 3890 | bgp_info_add (rn, new); |
| 3891 | |
| 3892 | /* route_node_get lock */ |
| 3893 | bgp_unlock_node (rn); |
| 3894 | |
| 3895 | /* Process change. */ |
| 3896 | bgp_process (bgp, rn, afi, safi); |
| 3897 | |
| 3898 | /* Unintern original. */ |
| 3899 | aspath_unintern (&attr.aspath); |
| 3900 | bgp_attr_extra_free (&attr); |
| 3901 | } |
| 3902 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3903 | /* Configure static BGP network. When user don't run zebra, static |
| 3904 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3905 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3906 | 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] | 3907 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3908 | { |
| 3909 | int ret; |
| 3910 | struct prefix p; |
| 3911 | struct bgp_static *bgp_static; |
| 3912 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3913 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3914 | |
| 3915 | /* Convert IP prefix string to struct prefix. */ |
| 3916 | ret = str2prefix (ip_str, &p); |
| 3917 | if (! ret) |
| 3918 | { |
| 3919 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3920 | return CMD_WARNING; |
| 3921 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3922 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3923 | { |
| 3924 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3925 | VTY_NEWLINE); |
| 3926 | return CMD_WARNING; |
| 3927 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3928 | |
| 3929 | apply_mask (&p); |
| 3930 | |
| 3931 | /* Set BGP static route configuration. */ |
| 3932 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3933 | |
| 3934 | if (rn->info) |
| 3935 | { |
| 3936 | /* Configuration change. */ |
| 3937 | bgp_static = rn->info; |
| 3938 | |
| 3939 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3940 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 3941 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3942 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3943 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3944 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3945 | if (rmap) |
| 3946 | { |
| 3947 | if (bgp_static->rmap.name) |
| 3948 | free (bgp_static->rmap.name); |
| 3949 | bgp_static->rmap.name = strdup (rmap); |
| 3950 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3951 | } |
| 3952 | else |
| 3953 | { |
| 3954 | if (bgp_static->rmap.name) |
| 3955 | free (bgp_static->rmap.name); |
| 3956 | bgp_static->rmap.name = NULL; |
| 3957 | bgp_static->rmap.map = NULL; |
| 3958 | bgp_static->valid = 0; |
| 3959 | } |
| 3960 | bgp_unlock_node (rn); |
| 3961 | } |
| 3962 | else |
| 3963 | { |
| 3964 | /* New configuration. */ |
| 3965 | bgp_static = bgp_static_new (); |
| 3966 | bgp_static->backdoor = backdoor; |
| 3967 | bgp_static->valid = 0; |
| 3968 | bgp_static->igpmetric = 0; |
| 3969 | bgp_static->igpnexthop.s_addr = 0; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3970 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3971 | if (rmap) |
| 3972 | { |
| 3973 | if (bgp_static->rmap.name) |
| 3974 | free (bgp_static->rmap.name); |
| 3975 | bgp_static->rmap.name = strdup (rmap); |
| 3976 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3977 | } |
| 3978 | rn->info = bgp_static; |
| 3979 | } |
| 3980 | |
| 3981 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3982 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3983 | { |
| 3984 | bgp_static->valid = 1; |
| 3985 | |
| 3986 | if (need_update) |
| 3987 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3988 | |
| 3989 | if (! bgp_static->backdoor) |
| 3990 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3991 | } |
| 3992 | |
| 3993 | return CMD_SUCCESS; |
| 3994 | } |
| 3995 | |
| 3996 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3997 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3998 | 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] | 3999 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4000 | { |
| 4001 | int ret; |
| 4002 | struct prefix p; |
| 4003 | struct bgp_static *bgp_static; |
| 4004 | struct bgp_node *rn; |
| 4005 | |
| 4006 | /* Convert IP prefix string to struct prefix. */ |
| 4007 | ret = str2prefix (ip_str, &p); |
| 4008 | if (! ret) |
| 4009 | { |
| 4010 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4011 | return CMD_WARNING; |
| 4012 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4013 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 4014 | { |
| 4015 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 4016 | VTY_NEWLINE); |
| 4017 | return CMD_WARNING; |
| 4018 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4019 | |
| 4020 | apply_mask (&p); |
| 4021 | |
| 4022 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 4023 | if (! rn) |
| 4024 | { |
| 4025 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 4026 | VTY_NEWLINE); |
| 4027 | return CMD_WARNING; |
| 4028 | } |
| 4029 | |
| 4030 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4031 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4032 | /* Update BGP RIB. */ |
| 4033 | if (! bgp_static->backdoor) |
| 4034 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 4035 | |
| 4036 | /* Clear configuration. */ |
| 4037 | bgp_static_free (bgp_static); |
| 4038 | rn->info = NULL; |
| 4039 | bgp_unlock_node (rn); |
| 4040 | bgp_unlock_node (rn); |
| 4041 | |
| 4042 | return CMD_SUCCESS; |
| 4043 | } |
| 4044 | |
| 4045 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 4046 | instance. */ |
| 4047 | void |
| 4048 | bgp_static_delete (struct bgp *bgp) |
| 4049 | { |
| 4050 | afi_t afi; |
| 4051 | safi_t safi; |
| 4052 | struct bgp_node *rn; |
| 4053 | struct bgp_node *rm; |
| 4054 | struct bgp_table *table; |
| 4055 | struct bgp_static *bgp_static; |
| 4056 | |
| 4057 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 4058 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 4059 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 4060 | if (rn->info != NULL) |
| 4061 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4062 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4063 | { |
| 4064 | table = rn->info; |
| 4065 | |
| 4066 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 4067 | { |
| 4068 | bgp_static = rn->info; |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4069 | bgp_static_withdraw_safi (bgp, &rm->p, |
| 4070 | AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4071 | (struct prefix_rd *)&rn->p, |
| 4072 | bgp_static->tag); |
| 4073 | bgp_static_free (bgp_static); |
| 4074 | rn->info = NULL; |
| 4075 | bgp_unlock_node (rn); |
| 4076 | } |
| 4077 | } |
| 4078 | else |
| 4079 | { |
| 4080 | bgp_static = rn->info; |
| 4081 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 4082 | bgp_static_free (bgp_static); |
| 4083 | rn->info = NULL; |
| 4084 | bgp_unlock_node (rn); |
| 4085 | } |
| 4086 | } |
| 4087 | } |
| 4088 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4089 | /* |
| 4090 | * gpz 110624 |
| 4091 | * Currently this is used to set static routes for VPN and ENCAP. |
| 4092 | * I think it can probably be factored with bgp_static_set. |
| 4093 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4094 | int |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4095 | bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str, |
| 4096 | const char *rd_str, const char *tag_str, |
| 4097 | const char *rmap_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4098 | { |
| 4099 | int ret; |
| 4100 | struct prefix p; |
| 4101 | struct prefix_rd prd; |
| 4102 | struct bgp *bgp; |
| 4103 | struct bgp_node *prn; |
| 4104 | struct bgp_node *rn; |
| 4105 | struct bgp_table *table; |
| 4106 | struct bgp_static *bgp_static; |
| 4107 | u_char tag[3]; |
| 4108 | |
| 4109 | bgp = vty->index; |
| 4110 | |
| 4111 | ret = str2prefix (ip_str, &p); |
| 4112 | if (! ret) |
| 4113 | { |
| 4114 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4115 | return CMD_WARNING; |
| 4116 | } |
| 4117 | apply_mask (&p); |
| 4118 | |
| 4119 | ret = str2prefix_rd (rd_str, &prd); |
| 4120 | if (! ret) |
| 4121 | { |
| 4122 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4123 | return CMD_WARNING; |
| 4124 | } |
| 4125 | |
| 4126 | ret = str2tag (tag_str, tag); |
| 4127 | if (! ret) |
| 4128 | { |
| 4129 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4130 | return CMD_WARNING; |
| 4131 | } |
| 4132 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4133 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4134 | (struct prefix *)&prd); |
| 4135 | if (prn->info == NULL) |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4136 | prn->info = bgp_table_init (AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4137 | else |
| 4138 | bgp_unlock_node (prn); |
| 4139 | table = prn->info; |
| 4140 | |
| 4141 | rn = bgp_node_get (table, &p); |
| 4142 | |
| 4143 | if (rn->info) |
| 4144 | { |
| 4145 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 4146 | bgp_unlock_node (rn); |
| 4147 | } |
| 4148 | else |
| 4149 | { |
| 4150 | /* New configuration. */ |
| 4151 | bgp_static = bgp_static_new (); |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4152 | bgp_static->backdoor = 0; |
| 4153 | bgp_static->valid = 0; |
| 4154 | bgp_static->igpmetric = 0; |
| 4155 | bgp_static->igpnexthop.s_addr = 0; |
| 4156 | memcpy(bgp_static->tag, tag, 3); |
| 4157 | bgp_static->prd = prd; |
| 4158 | |
| 4159 | if (rmap_str) |
| 4160 | { |
| 4161 | if (bgp_static->rmap.name) |
| 4162 | free (bgp_static->rmap.name); |
| 4163 | bgp_static->rmap.name = strdup (rmap_str); |
| 4164 | bgp_static->rmap.map = route_map_lookup_by_name (rmap_str); |
| 4165 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4166 | rn->info = bgp_static; |
| 4167 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4168 | bgp_static->valid = 1; |
| 4169 | bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4170 | } |
| 4171 | |
| 4172 | return CMD_SUCCESS; |
| 4173 | } |
| 4174 | |
| 4175 | /* Configure static BGP network. */ |
| 4176 | int |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4177 | bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str, |
| 4178 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4179 | { |
| 4180 | int ret; |
| 4181 | struct bgp *bgp; |
| 4182 | struct prefix p; |
| 4183 | struct prefix_rd prd; |
| 4184 | struct bgp_node *prn; |
| 4185 | struct bgp_node *rn; |
| 4186 | struct bgp_table *table; |
| 4187 | struct bgp_static *bgp_static; |
| 4188 | u_char tag[3]; |
| 4189 | |
| 4190 | bgp = vty->index; |
| 4191 | |
| 4192 | /* Convert IP prefix string to struct prefix. */ |
| 4193 | ret = str2prefix (ip_str, &p); |
| 4194 | if (! ret) |
| 4195 | { |
| 4196 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4197 | return CMD_WARNING; |
| 4198 | } |
| 4199 | apply_mask (&p); |
| 4200 | |
| 4201 | ret = str2prefix_rd (rd_str, &prd); |
| 4202 | if (! ret) |
| 4203 | { |
| 4204 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4205 | return CMD_WARNING; |
| 4206 | } |
| 4207 | |
| 4208 | ret = str2tag (tag_str, tag); |
| 4209 | if (! ret) |
| 4210 | { |
| 4211 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4212 | return CMD_WARNING; |
| 4213 | } |
| 4214 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4215 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4216 | (struct prefix *)&prd); |
| 4217 | if (prn->info == NULL) |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4218 | prn->info = bgp_table_init (AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4219 | else |
| 4220 | bgp_unlock_node (prn); |
| 4221 | table = prn->info; |
| 4222 | |
| 4223 | rn = bgp_node_lookup (table, &p); |
| 4224 | |
| 4225 | if (rn) |
| 4226 | { |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4227 | bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4228 | |
| 4229 | bgp_static = rn->info; |
| 4230 | bgp_static_free (bgp_static); |
| 4231 | rn->info = NULL; |
| 4232 | bgp_unlock_node (rn); |
| 4233 | bgp_unlock_node (rn); |
| 4234 | } |
| 4235 | else |
| 4236 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 4237 | |
| 4238 | return CMD_SUCCESS; |
| 4239 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4240 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4241 | DEFUN (bgp_network, |
| 4242 | bgp_network_cmd, |
| 4243 | "network A.B.C.D/M", |
| 4244 | "Specify a network to announce via BGP\n" |
| 4245 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4246 | { |
| 4247 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4248 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4249 | } |
| 4250 | |
| 4251 | DEFUN (bgp_network_route_map, |
| 4252 | bgp_network_route_map_cmd, |
| 4253 | "network A.B.C.D/M route-map WORD", |
| 4254 | "Specify a network to announce via BGP\n" |
| 4255 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4256 | "Route-map to modify the attributes\n" |
| 4257 | "Name of the route map\n") |
| 4258 | { |
| 4259 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4260 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4261 | } |
| 4262 | |
| 4263 | DEFUN (bgp_network_backdoor, |
| 4264 | bgp_network_backdoor_cmd, |
| 4265 | "network A.B.C.D/M backdoor", |
| 4266 | "Specify a network to announce via BGP\n" |
| 4267 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4268 | "Specify a BGP backdoor route\n") |
| 4269 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4270 | 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] | 4271 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4272 | } |
| 4273 | |
| 4274 | DEFUN (bgp_network_mask, |
| 4275 | bgp_network_mask_cmd, |
| 4276 | "network A.B.C.D mask A.B.C.D", |
| 4277 | "Specify a network to announce via BGP\n" |
| 4278 | "Network number\n" |
| 4279 | "Network mask\n" |
| 4280 | "Network mask\n") |
| 4281 | { |
| 4282 | int ret; |
| 4283 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4284 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4285 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4286 | if (! ret) |
| 4287 | { |
| 4288 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4289 | return CMD_WARNING; |
| 4290 | } |
| 4291 | |
| 4292 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4293 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4294 | } |
| 4295 | |
| 4296 | DEFUN (bgp_network_mask_route_map, |
| 4297 | bgp_network_mask_route_map_cmd, |
| 4298 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4299 | "Specify a network to announce via BGP\n" |
| 4300 | "Network number\n" |
| 4301 | "Network mask\n" |
| 4302 | "Network mask\n" |
| 4303 | "Route-map to modify the attributes\n" |
| 4304 | "Name of the route map\n") |
| 4305 | { |
| 4306 | int ret; |
| 4307 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4308 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4309 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4310 | if (! ret) |
| 4311 | { |
| 4312 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4313 | return CMD_WARNING; |
| 4314 | } |
| 4315 | |
| 4316 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4317 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4318 | } |
| 4319 | |
| 4320 | DEFUN (bgp_network_mask_backdoor, |
| 4321 | bgp_network_mask_backdoor_cmd, |
| 4322 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4323 | "Specify a network to announce via BGP\n" |
| 4324 | "Network number\n" |
| 4325 | "Network mask\n" |
| 4326 | "Network mask\n" |
| 4327 | "Specify a BGP backdoor route\n") |
| 4328 | { |
| 4329 | int ret; |
| 4330 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4331 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4332 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4333 | if (! ret) |
| 4334 | { |
| 4335 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4336 | return CMD_WARNING; |
| 4337 | } |
| 4338 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4339 | 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] | 4340 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4341 | } |
| 4342 | |
| 4343 | DEFUN (bgp_network_mask_natural, |
| 4344 | bgp_network_mask_natural_cmd, |
| 4345 | "network A.B.C.D", |
| 4346 | "Specify a network to announce via BGP\n" |
| 4347 | "Network number\n") |
| 4348 | { |
| 4349 | int ret; |
| 4350 | char prefix_str[BUFSIZ]; |
| 4351 | |
| 4352 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4353 | if (! ret) |
| 4354 | { |
| 4355 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4356 | return CMD_WARNING; |
| 4357 | } |
| 4358 | |
| 4359 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4360 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4361 | } |
| 4362 | |
| 4363 | DEFUN (bgp_network_mask_natural_route_map, |
| 4364 | bgp_network_mask_natural_route_map_cmd, |
| 4365 | "network A.B.C.D route-map WORD", |
| 4366 | "Specify a network to announce via BGP\n" |
| 4367 | "Network number\n" |
| 4368 | "Route-map to modify the attributes\n" |
| 4369 | "Name of the route map\n") |
| 4370 | { |
| 4371 | int ret; |
| 4372 | char prefix_str[BUFSIZ]; |
| 4373 | |
| 4374 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4375 | if (! ret) |
| 4376 | { |
| 4377 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4378 | return CMD_WARNING; |
| 4379 | } |
| 4380 | |
| 4381 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4382 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4383 | } |
| 4384 | |
| 4385 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4386 | bgp_network_mask_natural_backdoor_cmd, |
| 4387 | "network A.B.C.D backdoor", |
| 4388 | "Specify a network to announce via BGP\n" |
| 4389 | "Network number\n" |
| 4390 | "Specify a BGP backdoor route\n") |
| 4391 | { |
| 4392 | int ret; |
| 4393 | char prefix_str[BUFSIZ]; |
| 4394 | |
| 4395 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4396 | if (! ret) |
| 4397 | { |
| 4398 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4399 | return CMD_WARNING; |
| 4400 | } |
| 4401 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4402 | 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] | 4403 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4404 | } |
| 4405 | |
| 4406 | DEFUN (no_bgp_network, |
| 4407 | no_bgp_network_cmd, |
| 4408 | "no network A.B.C.D/M", |
| 4409 | NO_STR |
| 4410 | "Specify a network to announce via BGP\n" |
| 4411 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4412 | { |
| 4413 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4414 | bgp_node_safi (vty)); |
| 4415 | } |
| 4416 | |
| 4417 | ALIAS (no_bgp_network, |
| 4418 | no_bgp_network_route_map_cmd, |
| 4419 | "no network A.B.C.D/M route-map WORD", |
| 4420 | NO_STR |
| 4421 | "Specify a network to announce via BGP\n" |
| 4422 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4423 | "Route-map to modify the attributes\n" |
| 4424 | "Name of the route map\n") |
| 4425 | |
| 4426 | ALIAS (no_bgp_network, |
| 4427 | no_bgp_network_backdoor_cmd, |
| 4428 | "no network A.B.C.D/M backdoor", |
| 4429 | NO_STR |
| 4430 | "Specify a network to announce via BGP\n" |
| 4431 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4432 | "Specify a BGP backdoor route\n") |
| 4433 | |
| 4434 | DEFUN (no_bgp_network_mask, |
| 4435 | no_bgp_network_mask_cmd, |
| 4436 | "no network A.B.C.D mask A.B.C.D", |
| 4437 | NO_STR |
| 4438 | "Specify a network to announce via BGP\n" |
| 4439 | "Network number\n" |
| 4440 | "Network mask\n" |
| 4441 | "Network mask\n") |
| 4442 | { |
| 4443 | int ret; |
| 4444 | char prefix_str[BUFSIZ]; |
| 4445 | |
| 4446 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4447 | if (! ret) |
| 4448 | { |
| 4449 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4450 | return CMD_WARNING; |
| 4451 | } |
| 4452 | |
| 4453 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4454 | bgp_node_safi (vty)); |
| 4455 | } |
| 4456 | |
| 4457 | ALIAS (no_bgp_network_mask, |
| 4458 | no_bgp_network_mask_route_map_cmd, |
| 4459 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4460 | NO_STR |
| 4461 | "Specify a network to announce via BGP\n" |
| 4462 | "Network number\n" |
| 4463 | "Network mask\n" |
| 4464 | "Network mask\n" |
| 4465 | "Route-map to modify the attributes\n" |
| 4466 | "Name of the route map\n") |
| 4467 | |
| 4468 | ALIAS (no_bgp_network_mask, |
| 4469 | no_bgp_network_mask_backdoor_cmd, |
| 4470 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4471 | NO_STR |
| 4472 | "Specify a network to announce via BGP\n" |
| 4473 | "Network number\n" |
| 4474 | "Network mask\n" |
| 4475 | "Network mask\n" |
| 4476 | "Specify a BGP backdoor route\n") |
| 4477 | |
| 4478 | DEFUN (no_bgp_network_mask_natural, |
| 4479 | no_bgp_network_mask_natural_cmd, |
| 4480 | "no network A.B.C.D", |
| 4481 | NO_STR |
| 4482 | "Specify a network to announce via BGP\n" |
| 4483 | "Network number\n") |
| 4484 | { |
| 4485 | int ret; |
| 4486 | char prefix_str[BUFSIZ]; |
| 4487 | |
| 4488 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4489 | if (! ret) |
| 4490 | { |
| 4491 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4492 | return CMD_WARNING; |
| 4493 | } |
| 4494 | |
| 4495 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4496 | bgp_node_safi (vty)); |
| 4497 | } |
| 4498 | |
| 4499 | ALIAS (no_bgp_network_mask_natural, |
| 4500 | no_bgp_network_mask_natural_route_map_cmd, |
| 4501 | "no network A.B.C.D route-map WORD", |
| 4502 | NO_STR |
| 4503 | "Specify a network to announce via BGP\n" |
| 4504 | "Network number\n" |
| 4505 | "Route-map to modify the attributes\n" |
| 4506 | "Name of the route map\n") |
| 4507 | |
| 4508 | ALIAS (no_bgp_network_mask_natural, |
| 4509 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4510 | "no network A.B.C.D backdoor", |
| 4511 | NO_STR |
| 4512 | "Specify a network to announce via BGP\n" |
| 4513 | "Network number\n" |
| 4514 | "Specify a BGP backdoor route\n") |
| 4515 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4516 | DEFUN (ipv6_bgp_network, |
| 4517 | ipv6_bgp_network_cmd, |
| 4518 | "network X:X::X:X/M", |
| 4519 | "Specify a network to announce via BGP\n" |
| 4520 | "IPv6 prefix <network>/<length>\n") |
| 4521 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4522 | 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] | 4523 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4524 | } |
| 4525 | |
| 4526 | DEFUN (ipv6_bgp_network_route_map, |
| 4527 | ipv6_bgp_network_route_map_cmd, |
| 4528 | "network X:X::X:X/M route-map WORD", |
| 4529 | "Specify a network to announce via BGP\n" |
| 4530 | "IPv6 prefix <network>/<length>\n" |
| 4531 | "Route-map to modify the attributes\n" |
| 4532 | "Name of the route map\n") |
| 4533 | { |
| 4534 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4535 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4536 | } |
| 4537 | |
| 4538 | DEFUN (no_ipv6_bgp_network, |
| 4539 | no_ipv6_bgp_network_cmd, |
| 4540 | "no network X:X::X:X/M", |
| 4541 | NO_STR |
| 4542 | "Specify a network to announce via BGP\n" |
| 4543 | "IPv6 prefix <network>/<length>\n") |
| 4544 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4545 | 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] | 4546 | } |
| 4547 | |
| 4548 | ALIAS (no_ipv6_bgp_network, |
| 4549 | no_ipv6_bgp_network_route_map_cmd, |
| 4550 | "no network X:X::X:X/M route-map WORD", |
| 4551 | NO_STR |
| 4552 | "Specify a network to announce via BGP\n" |
| 4553 | "IPv6 prefix <network>/<length>\n" |
| 4554 | "Route-map to modify the attributes\n" |
| 4555 | "Name of the route map\n") |
| 4556 | |
| 4557 | ALIAS (ipv6_bgp_network, |
| 4558 | old_ipv6_bgp_network_cmd, |
| 4559 | "ipv6 bgp network X:X::X:X/M", |
| 4560 | IPV6_STR |
| 4561 | BGP_STR |
| 4562 | "Specify a network to announce via BGP\n" |
| 4563 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4564 | |
| 4565 | ALIAS (no_ipv6_bgp_network, |
| 4566 | old_no_ipv6_bgp_network_cmd, |
| 4567 | "no ipv6 bgp network X:X::X:X/M", |
| 4568 | NO_STR |
| 4569 | IPV6_STR |
| 4570 | BGP_STR |
| 4571 | "Specify a network to announce via BGP\n" |
| 4572 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4573 | |
| 4574 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4575 | ALIAS_DEPRECATED (bgp_network, |
| 4576 | bgp_network_ttl_cmd, |
| 4577 | "network A.B.C.D/M pathlimit <0-255>", |
| 4578 | "Specify a network to announce via BGP\n" |
| 4579 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4580 | "AS-Path hopcount limit attribute\n" |
| 4581 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4582 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4583 | bgp_network_backdoor_ttl_cmd, |
| 4584 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4585 | "Specify a network to announce via BGP\n" |
| 4586 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4587 | "Specify a BGP backdoor route\n" |
| 4588 | "AS-Path hopcount limit attribute\n" |
| 4589 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4590 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4591 | bgp_network_mask_ttl_cmd, |
| 4592 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4593 | "Specify a network to announce via BGP\n" |
| 4594 | "Network number\n" |
| 4595 | "Network mask\n" |
| 4596 | "Network mask\n" |
| 4597 | "AS-Path hopcount limit attribute\n" |
| 4598 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4599 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4600 | bgp_network_mask_backdoor_ttl_cmd, |
| 4601 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4602 | "Specify a network to announce via BGP\n" |
| 4603 | "Network number\n" |
| 4604 | "Network mask\n" |
| 4605 | "Network mask\n" |
| 4606 | "Specify a BGP backdoor route\n" |
| 4607 | "AS-Path hopcount limit attribute\n" |
| 4608 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4609 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4610 | bgp_network_mask_natural_ttl_cmd, |
| 4611 | "network A.B.C.D pathlimit <0-255>", |
| 4612 | "Specify a network to announce via BGP\n" |
| 4613 | "Network number\n" |
| 4614 | "AS-Path hopcount limit attribute\n" |
| 4615 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4616 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4617 | bgp_network_mask_natural_backdoor_ttl_cmd, |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 4618 | "network A.B.C.D backdoor pathlimit <1-255>", |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4619 | "Specify a network to announce via BGP\n" |
| 4620 | "Network number\n" |
| 4621 | "Specify a BGP backdoor route\n" |
| 4622 | "AS-Path hopcount limit attribute\n" |
| 4623 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4624 | ALIAS_DEPRECATED (no_bgp_network, |
| 4625 | no_bgp_network_ttl_cmd, |
| 4626 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4627 | NO_STR |
| 4628 | "Specify a network to announce via BGP\n" |
| 4629 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4630 | "AS-Path hopcount limit attribute\n" |
| 4631 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4632 | ALIAS_DEPRECATED (no_bgp_network, |
| 4633 | no_bgp_network_backdoor_ttl_cmd, |
| 4634 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4635 | NO_STR |
| 4636 | "Specify a network to announce via BGP\n" |
| 4637 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4638 | "Specify a BGP backdoor route\n" |
| 4639 | "AS-Path hopcount limit attribute\n" |
| 4640 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4641 | ALIAS_DEPRECATED (no_bgp_network, |
| 4642 | no_bgp_network_mask_ttl_cmd, |
| 4643 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4644 | NO_STR |
| 4645 | "Specify a network to announce via BGP\n" |
| 4646 | "Network number\n" |
| 4647 | "Network mask\n" |
| 4648 | "Network mask\n" |
| 4649 | "AS-Path hopcount limit attribute\n" |
| 4650 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4651 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4652 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4653 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4654 | NO_STR |
| 4655 | "Specify a network to announce via BGP\n" |
| 4656 | "Network number\n" |
| 4657 | "Network mask\n" |
| 4658 | "Network mask\n" |
| 4659 | "Specify a BGP backdoor route\n" |
| 4660 | "AS-Path hopcount limit attribute\n" |
| 4661 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4662 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4663 | no_bgp_network_mask_natural_ttl_cmd, |
| 4664 | "no network A.B.C.D pathlimit <0-255>", |
| 4665 | NO_STR |
| 4666 | "Specify a network to announce via BGP\n" |
| 4667 | "Network number\n" |
| 4668 | "AS-Path hopcount limit attribute\n" |
| 4669 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4670 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4671 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4672 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4673 | NO_STR |
| 4674 | "Specify a network to announce via BGP\n" |
| 4675 | "Network number\n" |
| 4676 | "Specify a BGP backdoor route\n" |
| 4677 | "AS-Path hopcount limit attribute\n" |
| 4678 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4679 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4680 | ipv6_bgp_network_ttl_cmd, |
| 4681 | "network X:X::X:X/M pathlimit <0-255>", |
| 4682 | "Specify a network to announce via BGP\n" |
| 4683 | "IPv6 prefix <network>/<length>\n" |
| 4684 | "AS-Path hopcount limit attribute\n" |
| 4685 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4686 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4687 | no_ipv6_bgp_network_ttl_cmd, |
| 4688 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4689 | NO_STR |
| 4690 | "Specify a network to announce via BGP\n" |
| 4691 | "IPv6 prefix <network>/<length>\n" |
| 4692 | "AS-Path hopcount limit attribute\n" |
| 4693 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4694 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4695 | /* Aggreagete address: |
| 4696 | |
| 4697 | advertise-map Set condition to advertise attribute |
| 4698 | as-set Generate AS set path information |
| 4699 | attribute-map Set attributes of aggregate |
| 4700 | route-map Set parameters of aggregate |
| 4701 | summary-only Filter more specific routes from updates |
| 4702 | suppress-map Conditionally filter more specific routes from updates |
| 4703 | <cr> |
| 4704 | */ |
| 4705 | struct bgp_aggregate |
| 4706 | { |
| 4707 | /* Summary-only flag. */ |
| 4708 | u_char summary_only; |
| 4709 | |
| 4710 | /* AS set generation. */ |
| 4711 | u_char as_set; |
| 4712 | |
| 4713 | /* Route-map for aggregated route. */ |
| 4714 | struct route_map *map; |
| 4715 | |
| 4716 | /* Suppress-count. */ |
| 4717 | unsigned long count; |
| 4718 | |
| 4719 | /* SAFI configuration. */ |
| 4720 | safi_t safi; |
| 4721 | }; |
| 4722 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4723 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4724 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4725 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4726 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4727 | } |
| 4728 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4729 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4730 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4731 | { |
| 4732 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4733 | } |
| 4734 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 4735 | /* Update an aggregate as routes are added/removed from the BGP table */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4736 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4737 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4738 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4739 | struct bgp_aggregate *aggregate) |
| 4740 | { |
| 4741 | struct bgp_table *table; |
| 4742 | struct bgp_node *top; |
| 4743 | struct bgp_node *rn; |
| 4744 | u_char origin; |
| 4745 | struct aspath *aspath = NULL; |
| 4746 | struct aspath *asmerge = NULL; |
| 4747 | struct community *community = NULL; |
| 4748 | struct community *commerge = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4749 | struct bgp_info *ri; |
| 4750 | struct bgp_info *new; |
| 4751 | int first = 1; |
| 4752 | unsigned long match = 0; |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 4753 | u_char atomic_aggregate = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4754 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4755 | /* ORIGIN attribute: If at least one route among routes that are |
| 4756 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4757 | aggregated route must have the ORIGIN attribute with the value |
| 4758 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4759 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4760 | route must have the origin attribute with the value EGP. In all |
| 4761 | other case the value of the ORIGIN attribute of the aggregated |
| 4762 | route is INTERNAL. */ |
| 4763 | origin = BGP_ORIGIN_IGP; |
| 4764 | |
| 4765 | table = bgp->rib[afi][safi]; |
| 4766 | |
| 4767 | top = bgp_node_get (table, p); |
| 4768 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4769 | if (rn->p.prefixlen > p->prefixlen) |
| 4770 | { |
| 4771 | match = 0; |
| 4772 | |
| 4773 | for (ri = rn->info; ri; ri = ri->next) |
| 4774 | { |
| 4775 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4776 | continue; |
| 4777 | |
| 4778 | if (del && ri == del) |
| 4779 | continue; |
| 4780 | |
| 4781 | if (! rinew && first) |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 4782 | first = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4783 | |
| 4784 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4785 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4786 | || ri->attr->med != med) |
| 4787 | { |
| 4788 | if (aspath) |
| 4789 | aspath_free (aspath); |
| 4790 | if (community) |
| 4791 | community_free (community); |
| 4792 | bgp_unlock_node (rn); |
| 4793 | bgp_unlock_node (top); |
| 4794 | return; |
| 4795 | } |
| 4796 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4797 | |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 4798 | if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 4799 | atomic_aggregate = 1; |
| 4800 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4801 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4802 | { |
| 4803 | if (aggregate->summary_only) |
| 4804 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4805 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4806 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4807 | match++; |
| 4808 | } |
| 4809 | |
| 4810 | aggregate->count++; |
| 4811 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 4812 | if (origin < ri->attr->origin) |
| 4813 | origin = ri->attr->origin; |
| 4814 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4815 | if (aggregate->as_set) |
| 4816 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4817 | if (aspath) |
| 4818 | { |
| 4819 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4820 | aspath_free (aspath); |
| 4821 | aspath = asmerge; |
| 4822 | } |
| 4823 | else |
| 4824 | aspath = aspath_dup (ri->attr->aspath); |
| 4825 | |
| 4826 | if (ri->attr->community) |
| 4827 | { |
| 4828 | if (community) |
| 4829 | { |
| 4830 | commerge = community_merge (community, |
| 4831 | ri->attr->community); |
| 4832 | community = community_uniq_sort (commerge); |
| 4833 | community_free (commerge); |
| 4834 | } |
| 4835 | else |
| 4836 | community = community_dup (ri->attr->community); |
| 4837 | } |
| 4838 | } |
| 4839 | } |
| 4840 | } |
| 4841 | if (match) |
| 4842 | bgp_process (bgp, rn, afi, safi); |
| 4843 | } |
| 4844 | bgp_unlock_node (top); |
| 4845 | |
| 4846 | if (rinew) |
| 4847 | { |
| 4848 | aggregate->count++; |
| 4849 | |
| 4850 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4851 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4852 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 4853 | if (origin < rinew->attr->origin) |
| 4854 | origin = rinew->attr->origin; |
| 4855 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4856 | if (aggregate->as_set) |
| 4857 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4858 | if (aspath) |
| 4859 | { |
| 4860 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4861 | aspath_free (aspath); |
| 4862 | aspath = asmerge; |
| 4863 | } |
| 4864 | else |
| 4865 | aspath = aspath_dup (rinew->attr->aspath); |
| 4866 | |
| 4867 | if (rinew->attr->community) |
| 4868 | { |
| 4869 | if (community) |
| 4870 | { |
| 4871 | commerge = community_merge (community, |
| 4872 | rinew->attr->community); |
| 4873 | community = community_uniq_sort (commerge); |
| 4874 | community_free (commerge); |
| 4875 | } |
| 4876 | else |
| 4877 | community = community_dup (rinew->attr->community); |
| 4878 | } |
| 4879 | } |
| 4880 | } |
| 4881 | |
| 4882 | if (aggregate->count > 0) |
| 4883 | { |
| 4884 | rn = bgp_node_get (table, p); |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 4885 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self, |
| 4886 | bgp_attr_aggregate_intern(bgp, origin, aspath, community, |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 4887 | aggregate->as_set, |
| 4888 | atomic_aggregate), rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4889 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4890 | |
| 4891 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4892 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4893 | bgp_process (bgp, rn, afi, safi); |
| 4894 | } |
| 4895 | else |
| 4896 | { |
| 4897 | if (aspath) |
| 4898 | aspath_free (aspath); |
| 4899 | if (community) |
| 4900 | community_free (community); |
| 4901 | } |
| 4902 | } |
| 4903 | |
| 4904 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4905 | struct bgp_aggregate *); |
| 4906 | |
| 4907 | void |
| 4908 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4909 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4910 | { |
| 4911 | struct bgp_node *child; |
| 4912 | struct bgp_node *rn; |
| 4913 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4914 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4915 | |
| 4916 | /* MPLS-VPN aggregation is not yet supported. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4917 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4918 | return; |
| 4919 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4920 | table = bgp->aggregate[afi][safi]; |
| 4921 | |
| 4922 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4923 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4924 | return; |
| 4925 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4926 | if (p->prefixlen == 0) |
| 4927 | return; |
| 4928 | |
| 4929 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4930 | return; |
| 4931 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4932 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4933 | |
| 4934 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4935 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4936 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4937 | { |
| 4938 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4939 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4940 | } |
| 4941 | bgp_unlock_node (child); |
| 4942 | } |
| 4943 | |
| 4944 | void |
| 4945 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4946 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4947 | { |
| 4948 | struct bgp_node *child; |
| 4949 | struct bgp_node *rn; |
| 4950 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4951 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4952 | |
| 4953 | /* MPLS-VPN aggregation is not yet supported. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4954 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4955 | return; |
| 4956 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4957 | table = bgp->aggregate[afi][safi]; |
| 4958 | |
| 4959 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4960 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4961 | return; |
| 4962 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4963 | if (p->prefixlen == 0) |
| 4964 | return; |
| 4965 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4966 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4967 | |
| 4968 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4969 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4970 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4971 | { |
| 4972 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4973 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4974 | } |
| 4975 | bgp_unlock_node (child); |
| 4976 | } |
| 4977 | |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 4978 | /* Called via bgp_aggregate_set when the user configures aggregate-address */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4979 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4980 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4981 | struct bgp_aggregate *aggregate) |
| 4982 | { |
| 4983 | struct bgp_table *table; |
| 4984 | struct bgp_node *top; |
| 4985 | struct bgp_node *rn; |
| 4986 | struct bgp_info *new; |
| 4987 | struct bgp_info *ri; |
| 4988 | unsigned long match; |
| 4989 | u_char origin = BGP_ORIGIN_IGP; |
| 4990 | struct aspath *aspath = NULL; |
| 4991 | struct aspath *asmerge = NULL; |
| 4992 | struct community *community = NULL; |
| 4993 | struct community *commerge = NULL; |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 4994 | u_char atomic_aggregate = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4995 | |
| 4996 | table = bgp->rib[afi][safi]; |
| 4997 | |
| 4998 | /* Sanity check. */ |
| 4999 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 5000 | return; |
| 5001 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 5002 | return; |
| 5003 | |
| 5004 | /* If routes exists below this node, generate aggregate routes. */ |
| 5005 | top = bgp_node_get (table, p); |
| 5006 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 5007 | if (rn->p.prefixlen > p->prefixlen) |
| 5008 | { |
| 5009 | match = 0; |
| 5010 | |
| 5011 | for (ri = rn->info; ri; ri = ri->next) |
| 5012 | { |
| 5013 | if (BGP_INFO_HOLDDOWN (ri)) |
| 5014 | continue; |
| 5015 | |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 5016 | if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 5017 | atomic_aggregate = 1; |
| 5018 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5019 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 5020 | { |
| 5021 | /* summary-only aggregate route suppress aggregated |
| 5022 | route announcement. */ |
| 5023 | if (aggregate->summary_only) |
| 5024 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5025 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5026 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5027 | match++; |
| 5028 | } |
Daniel Walton | 76a7280 | 2015-05-19 17:47:24 -0700 | [diff] [blame] | 5029 | |
| 5030 | /* If at least one route among routes that are aggregated has |
| 5031 | * ORIGIN with the value INCOMPLETE, then the aggregated route |
| 5032 | * MUST have the ORIGIN attribute with the value INCOMPLETE. |
| 5033 | * Otherwise, if at least one route among routes that are |
| 5034 | * aggregated has ORIGIN with the value EGP, then the aggregated |
| 5035 | * route MUST have the ORIGIN attribute with the value EGP. |
| 5036 | */ |
| 5037 | if (origin < ri->attr->origin) |
| 5038 | origin = ri->attr->origin; |
| 5039 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5040 | /* as-set aggregate route generate origin, as path, |
| 5041 | community aggregation. */ |
| 5042 | if (aggregate->as_set) |
| 5043 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5044 | if (aspath) |
| 5045 | { |
| 5046 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 5047 | aspath_free (aspath); |
| 5048 | aspath = asmerge; |
| 5049 | } |
| 5050 | else |
| 5051 | aspath = aspath_dup (ri->attr->aspath); |
| 5052 | |
| 5053 | if (ri->attr->community) |
| 5054 | { |
| 5055 | if (community) |
| 5056 | { |
| 5057 | commerge = community_merge (community, |
| 5058 | ri->attr->community); |
| 5059 | community = community_uniq_sort (commerge); |
| 5060 | community_free (commerge); |
| 5061 | } |
| 5062 | else |
| 5063 | community = community_dup (ri->attr->community); |
| 5064 | } |
| 5065 | } |
| 5066 | aggregate->count++; |
| 5067 | } |
| 5068 | } |
| 5069 | |
| 5070 | /* If this node is suppressed, process the change. */ |
| 5071 | if (match) |
| 5072 | bgp_process (bgp, rn, afi, safi); |
| 5073 | } |
| 5074 | bgp_unlock_node (top); |
| 5075 | |
| 5076 | /* Add aggregate route to BGP table. */ |
| 5077 | if (aggregate->count) |
| 5078 | { |
| 5079 | rn = bgp_node_get (table, p); |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 5080 | new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self, |
| 5081 | bgp_attr_aggregate_intern(bgp, origin, aspath, community, |
Daniel Walton | f2eb9ca | 2015-05-19 17:47:21 -0700 | [diff] [blame] | 5082 | aggregate->as_set, |
| 5083 | atomic_aggregate), rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5084 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5085 | |
| 5086 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5087 | bgp_unlock_node (rn); |
| 5088 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5089 | /* Process change. */ |
| 5090 | bgp_process (bgp, rn, afi, safi); |
| 5091 | } |
Denil Vira | e2a9258 | 2015-08-11 13:34:59 -0700 | [diff] [blame] | 5092 | else |
| 5093 | { |
| 5094 | if (aspath) |
| 5095 | aspath_free (aspath); |
| 5096 | if (community) |
| 5097 | community_free (community); |
| 5098 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5099 | } |
| 5100 | |
| 5101 | void |
| 5102 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 5103 | safi_t safi, struct bgp_aggregate *aggregate) |
| 5104 | { |
| 5105 | struct bgp_table *table; |
| 5106 | struct bgp_node *top; |
| 5107 | struct bgp_node *rn; |
| 5108 | struct bgp_info *ri; |
| 5109 | unsigned long match; |
| 5110 | |
| 5111 | table = bgp->rib[afi][safi]; |
| 5112 | |
| 5113 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 5114 | return; |
| 5115 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 5116 | return; |
| 5117 | |
| 5118 | /* If routes exists below this node, generate aggregate routes. */ |
| 5119 | top = bgp_node_get (table, p); |
| 5120 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 5121 | if (rn->p.prefixlen > p->prefixlen) |
| 5122 | { |
| 5123 | match = 0; |
| 5124 | |
| 5125 | for (ri = rn->info; ri; ri = ri->next) |
| 5126 | { |
| 5127 | if (BGP_INFO_HOLDDOWN (ri)) |
| 5128 | continue; |
| 5129 | |
| 5130 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 5131 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5132 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5133 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5134 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5135 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5136 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5137 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5138 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5139 | match++; |
| 5140 | } |
| 5141 | } |
| 5142 | aggregate->count--; |
| 5143 | } |
| 5144 | } |
| 5145 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5146 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5147 | if (match) |
| 5148 | bgp_process (bgp, rn, afi, safi); |
| 5149 | } |
| 5150 | bgp_unlock_node (top); |
| 5151 | |
| 5152 | /* Delete aggregate route from BGP table. */ |
| 5153 | rn = bgp_node_get (table, p); |
| 5154 | |
| 5155 | for (ri = rn->info; ri; ri = ri->next) |
| 5156 | if (ri->peer == bgp->peer_self |
| 5157 | && ri->type == ZEBRA_ROUTE_BGP |
| 5158 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 5159 | break; |
| 5160 | |
| 5161 | /* Withdraw static BGP route from routing table. */ |
| 5162 | if (ri) |
| 5163 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5164 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5165 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5166 | } |
| 5167 | |
| 5168 | /* Unlock bgp_node_lookup. */ |
| 5169 | bgp_unlock_node (rn); |
| 5170 | } |
| 5171 | |
| 5172 | /* Aggregate route attribute. */ |
| 5173 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 5174 | #define AGGREGATE_AS_SET 1 |
| 5175 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5176 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5177 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 5178 | afi_t afi, safi_t safi) |
| 5179 | { |
| 5180 | int ret; |
| 5181 | struct prefix p; |
| 5182 | struct bgp_node *rn; |
| 5183 | struct bgp *bgp; |
| 5184 | struct bgp_aggregate *aggregate; |
| 5185 | |
| 5186 | /* Convert string to prefix structure. */ |
| 5187 | ret = str2prefix (prefix_str, &p); |
| 5188 | if (!ret) |
| 5189 | { |
| 5190 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5191 | return CMD_WARNING; |
| 5192 | } |
| 5193 | apply_mask (&p); |
| 5194 | |
| 5195 | /* Get BGP structure. */ |
| 5196 | bgp = vty->index; |
| 5197 | |
| 5198 | /* Old configuration check. */ |
| 5199 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 5200 | if (! rn) |
| 5201 | { |
| 5202 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 5203 | VTY_NEWLINE); |
| 5204 | return CMD_WARNING; |
| 5205 | } |
| 5206 | |
| 5207 | aggregate = rn->info; |
| 5208 | if (aggregate->safi & SAFI_UNICAST) |
| 5209 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5210 | if (aggregate->safi & SAFI_MULTICAST) |
| 5211 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5212 | |
| 5213 | /* Unlock aggregate address configuration. */ |
| 5214 | rn->info = NULL; |
| 5215 | bgp_aggregate_free (aggregate); |
| 5216 | bgp_unlock_node (rn); |
| 5217 | bgp_unlock_node (rn); |
| 5218 | |
| 5219 | return CMD_SUCCESS; |
| 5220 | } |
| 5221 | |
| 5222 | static int |
| 5223 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5224 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5225 | u_char summary_only, u_char as_set) |
| 5226 | { |
| 5227 | int ret; |
| 5228 | struct prefix p; |
| 5229 | struct bgp_node *rn; |
| 5230 | struct bgp *bgp; |
| 5231 | struct bgp_aggregate *aggregate; |
| 5232 | |
| 5233 | /* Convert string to prefix structure. */ |
| 5234 | ret = str2prefix (prefix_str, &p); |
| 5235 | if (!ret) |
| 5236 | { |
| 5237 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5238 | return CMD_WARNING; |
| 5239 | } |
| 5240 | apply_mask (&p); |
| 5241 | |
| 5242 | /* Get BGP structure. */ |
| 5243 | bgp = vty->index; |
| 5244 | |
| 5245 | /* Old configuration check. */ |
| 5246 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 5247 | |
| 5248 | if (rn->info) |
| 5249 | { |
| 5250 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5251 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5252 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 5253 | if (ret) |
| 5254 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5255 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 5256 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5257 | return CMD_WARNING; |
| 5258 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5259 | } |
| 5260 | |
| 5261 | /* Make aggregate address structure. */ |
| 5262 | aggregate = bgp_aggregate_new (); |
| 5263 | aggregate->summary_only = summary_only; |
| 5264 | aggregate->as_set = as_set; |
| 5265 | aggregate->safi = safi; |
| 5266 | rn->info = aggregate; |
| 5267 | |
| 5268 | /* Aggregate address insert into BGP routing table. */ |
| 5269 | if (safi & SAFI_UNICAST) |
| 5270 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5271 | if (safi & SAFI_MULTICAST) |
| 5272 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5273 | |
| 5274 | return CMD_SUCCESS; |
| 5275 | } |
| 5276 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5277 | DEFUN (aggregate_address, |
| 5278 | aggregate_address_cmd, |
| 5279 | "aggregate-address A.B.C.D/M", |
| 5280 | "Configure BGP aggregate entries\n" |
| 5281 | "Aggregate prefix\n") |
| 5282 | { |
| 5283 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5284 | } |
| 5285 | |
| 5286 | DEFUN (aggregate_address_mask, |
| 5287 | aggregate_address_mask_cmd, |
| 5288 | "aggregate-address A.B.C.D A.B.C.D", |
| 5289 | "Configure BGP aggregate entries\n" |
| 5290 | "Aggregate address\n" |
| 5291 | "Aggregate mask\n") |
| 5292 | { |
| 5293 | int ret; |
| 5294 | char prefix_str[BUFSIZ]; |
| 5295 | |
| 5296 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5297 | |
| 5298 | if (! ret) |
| 5299 | { |
| 5300 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5301 | return CMD_WARNING; |
| 5302 | } |
| 5303 | |
| 5304 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5305 | 0, 0); |
| 5306 | } |
| 5307 | |
| 5308 | DEFUN (aggregate_address_summary_only, |
| 5309 | aggregate_address_summary_only_cmd, |
| 5310 | "aggregate-address A.B.C.D/M summary-only", |
| 5311 | "Configure BGP aggregate entries\n" |
| 5312 | "Aggregate prefix\n" |
| 5313 | "Filter more specific routes from updates\n") |
| 5314 | { |
| 5315 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5316 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5317 | } |
| 5318 | |
| 5319 | DEFUN (aggregate_address_mask_summary_only, |
| 5320 | aggregate_address_mask_summary_only_cmd, |
| 5321 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5322 | "Configure BGP aggregate entries\n" |
| 5323 | "Aggregate address\n" |
| 5324 | "Aggregate mask\n" |
| 5325 | "Filter more specific routes from updates\n") |
| 5326 | { |
| 5327 | int ret; |
| 5328 | char prefix_str[BUFSIZ]; |
| 5329 | |
| 5330 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5331 | |
| 5332 | if (! ret) |
| 5333 | { |
| 5334 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5335 | return CMD_WARNING; |
| 5336 | } |
| 5337 | |
| 5338 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5339 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5340 | } |
| 5341 | |
| 5342 | DEFUN (aggregate_address_as_set, |
| 5343 | aggregate_address_as_set_cmd, |
| 5344 | "aggregate-address A.B.C.D/M as-set", |
| 5345 | "Configure BGP aggregate entries\n" |
| 5346 | "Aggregate prefix\n" |
| 5347 | "Generate AS set path information\n") |
| 5348 | { |
| 5349 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5350 | 0, AGGREGATE_AS_SET); |
| 5351 | } |
| 5352 | |
| 5353 | DEFUN (aggregate_address_mask_as_set, |
| 5354 | aggregate_address_mask_as_set_cmd, |
| 5355 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5356 | "Configure BGP aggregate entries\n" |
| 5357 | "Aggregate address\n" |
| 5358 | "Aggregate mask\n" |
| 5359 | "Generate AS set path information\n") |
| 5360 | { |
| 5361 | int ret; |
| 5362 | char prefix_str[BUFSIZ]; |
| 5363 | |
| 5364 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5365 | |
| 5366 | if (! ret) |
| 5367 | { |
| 5368 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5369 | return CMD_WARNING; |
| 5370 | } |
| 5371 | |
| 5372 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5373 | 0, AGGREGATE_AS_SET); |
| 5374 | } |
| 5375 | |
| 5376 | |
| 5377 | DEFUN (aggregate_address_as_set_summary, |
| 5378 | aggregate_address_as_set_summary_cmd, |
| 5379 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5380 | "Configure BGP aggregate entries\n" |
| 5381 | "Aggregate prefix\n" |
| 5382 | "Generate AS set path information\n" |
| 5383 | "Filter more specific routes from updates\n") |
| 5384 | { |
| 5385 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5386 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5387 | } |
| 5388 | |
| 5389 | ALIAS (aggregate_address_as_set_summary, |
| 5390 | aggregate_address_summary_as_set_cmd, |
| 5391 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5392 | "Configure BGP aggregate entries\n" |
| 5393 | "Aggregate prefix\n" |
| 5394 | "Filter more specific routes from updates\n" |
| 5395 | "Generate AS set path information\n") |
| 5396 | |
| 5397 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5398 | aggregate_address_mask_as_set_summary_cmd, |
| 5399 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5400 | "Configure BGP aggregate entries\n" |
| 5401 | "Aggregate address\n" |
| 5402 | "Aggregate mask\n" |
| 5403 | "Generate AS set path information\n" |
| 5404 | "Filter more specific routes from updates\n") |
| 5405 | { |
| 5406 | int ret; |
| 5407 | char prefix_str[BUFSIZ]; |
| 5408 | |
| 5409 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5410 | |
| 5411 | if (! ret) |
| 5412 | { |
| 5413 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5414 | return CMD_WARNING; |
| 5415 | } |
| 5416 | |
| 5417 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5418 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5419 | } |
| 5420 | |
| 5421 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5422 | aggregate_address_mask_summary_as_set_cmd, |
| 5423 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5424 | "Configure BGP aggregate entries\n" |
| 5425 | "Aggregate address\n" |
| 5426 | "Aggregate mask\n" |
| 5427 | "Filter more specific routes from updates\n" |
| 5428 | "Generate AS set path information\n") |
| 5429 | |
| 5430 | DEFUN (no_aggregate_address, |
| 5431 | no_aggregate_address_cmd, |
| 5432 | "no aggregate-address A.B.C.D/M", |
| 5433 | NO_STR |
| 5434 | "Configure BGP aggregate entries\n" |
| 5435 | "Aggregate prefix\n") |
| 5436 | { |
| 5437 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5438 | } |
| 5439 | |
| 5440 | ALIAS (no_aggregate_address, |
| 5441 | no_aggregate_address_summary_only_cmd, |
| 5442 | "no aggregate-address A.B.C.D/M summary-only", |
| 5443 | NO_STR |
| 5444 | "Configure BGP aggregate entries\n" |
| 5445 | "Aggregate prefix\n" |
| 5446 | "Filter more specific routes from updates\n") |
| 5447 | |
| 5448 | ALIAS (no_aggregate_address, |
| 5449 | no_aggregate_address_as_set_cmd, |
| 5450 | "no aggregate-address A.B.C.D/M as-set", |
| 5451 | NO_STR |
| 5452 | "Configure BGP aggregate entries\n" |
| 5453 | "Aggregate prefix\n" |
| 5454 | "Generate AS set path information\n") |
| 5455 | |
| 5456 | ALIAS (no_aggregate_address, |
| 5457 | no_aggregate_address_as_set_summary_cmd, |
| 5458 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5459 | NO_STR |
| 5460 | "Configure BGP aggregate entries\n" |
| 5461 | "Aggregate prefix\n" |
| 5462 | "Generate AS set path information\n" |
| 5463 | "Filter more specific routes from updates\n") |
| 5464 | |
| 5465 | ALIAS (no_aggregate_address, |
| 5466 | no_aggregate_address_summary_as_set_cmd, |
| 5467 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5468 | NO_STR |
| 5469 | "Configure BGP aggregate entries\n" |
| 5470 | "Aggregate prefix\n" |
| 5471 | "Filter more specific routes from updates\n" |
| 5472 | "Generate AS set path information\n") |
| 5473 | |
| 5474 | DEFUN (no_aggregate_address_mask, |
| 5475 | no_aggregate_address_mask_cmd, |
| 5476 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5477 | NO_STR |
| 5478 | "Configure BGP aggregate entries\n" |
| 5479 | "Aggregate address\n" |
| 5480 | "Aggregate mask\n") |
| 5481 | { |
| 5482 | int ret; |
| 5483 | char prefix_str[BUFSIZ]; |
| 5484 | |
| 5485 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5486 | |
| 5487 | if (! ret) |
| 5488 | { |
| 5489 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5490 | return CMD_WARNING; |
| 5491 | } |
| 5492 | |
| 5493 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5494 | } |
| 5495 | |
| 5496 | ALIAS (no_aggregate_address_mask, |
| 5497 | no_aggregate_address_mask_summary_only_cmd, |
| 5498 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5499 | NO_STR |
| 5500 | "Configure BGP aggregate entries\n" |
| 5501 | "Aggregate address\n" |
| 5502 | "Aggregate mask\n" |
| 5503 | "Filter more specific routes from updates\n") |
| 5504 | |
| 5505 | ALIAS (no_aggregate_address_mask, |
| 5506 | no_aggregate_address_mask_as_set_cmd, |
| 5507 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5508 | NO_STR |
| 5509 | "Configure BGP aggregate entries\n" |
| 5510 | "Aggregate address\n" |
| 5511 | "Aggregate mask\n" |
| 5512 | "Generate AS set path information\n") |
| 5513 | |
| 5514 | ALIAS (no_aggregate_address_mask, |
| 5515 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5516 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5517 | NO_STR |
| 5518 | "Configure BGP aggregate entries\n" |
| 5519 | "Aggregate address\n" |
| 5520 | "Aggregate mask\n" |
| 5521 | "Generate AS set path information\n" |
| 5522 | "Filter more specific routes from updates\n") |
| 5523 | |
| 5524 | ALIAS (no_aggregate_address_mask, |
| 5525 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5526 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5527 | NO_STR |
| 5528 | "Configure BGP aggregate entries\n" |
| 5529 | "Aggregate address\n" |
| 5530 | "Aggregate mask\n" |
| 5531 | "Filter more specific routes from updates\n" |
| 5532 | "Generate AS set path information\n") |
| 5533 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5534 | DEFUN (ipv6_aggregate_address, |
| 5535 | ipv6_aggregate_address_cmd, |
| 5536 | "aggregate-address X:X::X:X/M", |
| 5537 | "Configure BGP aggregate entries\n" |
| 5538 | "Aggregate prefix\n") |
| 5539 | { |
| 5540 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5541 | } |
| 5542 | |
| 5543 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5544 | ipv6_aggregate_address_summary_only_cmd, |
| 5545 | "aggregate-address X:X::X:X/M summary-only", |
| 5546 | "Configure BGP aggregate entries\n" |
| 5547 | "Aggregate prefix\n" |
| 5548 | "Filter more specific routes from updates\n") |
| 5549 | { |
| 5550 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5551 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5552 | } |
| 5553 | |
| 5554 | DEFUN (no_ipv6_aggregate_address, |
| 5555 | no_ipv6_aggregate_address_cmd, |
| 5556 | "no aggregate-address X:X::X:X/M", |
| 5557 | NO_STR |
| 5558 | "Configure BGP aggregate entries\n" |
| 5559 | "Aggregate prefix\n") |
| 5560 | { |
| 5561 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5562 | } |
| 5563 | |
| 5564 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5565 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5566 | "no aggregate-address X:X::X:X/M summary-only", |
| 5567 | NO_STR |
| 5568 | "Configure BGP aggregate entries\n" |
| 5569 | "Aggregate prefix\n" |
| 5570 | "Filter more specific routes from updates\n") |
| 5571 | { |
| 5572 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5573 | } |
| 5574 | |
| 5575 | ALIAS (ipv6_aggregate_address, |
| 5576 | old_ipv6_aggregate_address_cmd, |
| 5577 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5578 | IPV6_STR |
| 5579 | BGP_STR |
| 5580 | "Configure BGP aggregate entries\n" |
| 5581 | "Aggregate prefix\n") |
| 5582 | |
| 5583 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5584 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5585 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5586 | IPV6_STR |
| 5587 | BGP_STR |
| 5588 | "Configure BGP aggregate entries\n" |
| 5589 | "Aggregate prefix\n" |
| 5590 | "Filter more specific routes from updates\n") |
| 5591 | |
| 5592 | ALIAS (no_ipv6_aggregate_address, |
| 5593 | old_no_ipv6_aggregate_address_cmd, |
| 5594 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5595 | NO_STR |
| 5596 | IPV6_STR |
| 5597 | BGP_STR |
| 5598 | "Configure BGP aggregate entries\n" |
| 5599 | "Aggregate prefix\n") |
| 5600 | |
| 5601 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5602 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5603 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5604 | NO_STR |
| 5605 | IPV6_STR |
| 5606 | BGP_STR |
| 5607 | "Configure BGP aggregate entries\n" |
| 5608 | "Aggregate prefix\n" |
| 5609 | "Filter more specific routes from updates\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5610 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5611 | /* Redistribute route treatment. */ |
| 5612 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5613 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5614 | const struct in6_addr *nexthop6, |
Paul Jakma | 96d1060 | 2016-07-01 14:23:45 +0100 | [diff] [blame] | 5615 | u_int32_t metric, u_char type, route_tag_t tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5616 | { |
| 5617 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5618 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5619 | struct bgp_info *new; |
| 5620 | struct bgp_info *bi; |
| 5621 | struct bgp_info info; |
| 5622 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5623 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5624 | struct attr *new_attr; |
| 5625 | afi_t afi; |
| 5626 | int ret; |
| 5627 | |
| 5628 | /* Make default attribute. */ |
| 5629 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5630 | if (nexthop) |
| 5631 | attr.nexthop = *nexthop; |
| 5632 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5633 | if (nexthop6) |
| 5634 | { |
| 5635 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5636 | extra->mp_nexthop_global = *nexthop6; |
| 5637 | extra->mp_nexthop_len = 16; |
| 5638 | } |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5639 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5640 | attr.med = metric; |
| 5641 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Piotr Chytła | 605aa33 | 2015-12-01 10:03:54 -0500 | [diff] [blame] | 5642 | attr.extra->tag = tag; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5643 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5644 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5645 | { |
| 5646 | afi = family2afi (p->family); |
| 5647 | |
| 5648 | if (bgp->redist[afi][type]) |
| 5649 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5650 | struct attr attr_new; |
| 5651 | struct attr_extra extra_new; |
| 5652 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5653 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5654 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5655 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5656 | |
| 5657 | if (bgp->redist_metric_flag[afi][type]) |
| 5658 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5659 | |
| 5660 | /* Apply route-map. */ |
Daniel Walton | 1994dc8 | 2015-09-17 10:15:59 -0400 | [diff] [blame] | 5661 | if (bgp->rmap[afi][type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5662 | { |
| 5663 | info.peer = bgp->peer_self; |
| 5664 | info.attr = &attr_new; |
| 5665 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5666 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5667 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5668 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5669 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5670 | |
| 5671 | bgp->peer_self->rmap_type = 0; |
| 5672 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5673 | if (ret == RMAP_DENYMATCH) |
| 5674 | { |
| 5675 | /* Free uninterned attribute. */ |
| 5676 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5677 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5678 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5679 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5680 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5681 | bgp_redistribute_delete (p, type); |
| 5682 | return; |
| 5683 | } |
| 5684 | } |
| 5685 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5686 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5687 | afi, SAFI_UNICAST, p, NULL); |
| 5688 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5689 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5690 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5691 | for (bi = bn->info; bi; bi = bi->next) |
| 5692 | if (bi->peer == bgp->peer_self |
| 5693 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5694 | break; |
| 5695 | |
| 5696 | if (bi) |
| 5697 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5698 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5699 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5700 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5701 | bgp_attr_unintern (&new_attr); |
| 5702 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5703 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5704 | bgp_unlock_node (bn); |
| 5705 | return; |
| 5706 | } |
| 5707 | else |
| 5708 | { |
| 5709 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5710 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5711 | |
| 5712 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5713 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5714 | bgp_info_restore(bn, bi); |
| 5715 | else |
| 5716 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5717 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5718 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5719 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5720 | |
| 5721 | /* Process change. */ |
| 5722 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5723 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5724 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5725 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5726 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5727 | return; |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 5728 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5729 | } |
| 5730 | |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 5731 | new = info_make(type, BGP_ROUTE_REDISTRIBUTE, bgp->peer_self, |
| 5732 | new_attr, bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5733 | SET_FLAG (new->flags, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5734 | |
| 5735 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5736 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5737 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5738 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5739 | } |
| 5740 | } |
| 5741 | |
| 5742 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5743 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5744 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5745 | } |
| 5746 | |
| 5747 | void |
| 5748 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5749 | { |
| 5750 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5751 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5752 | afi_t afi; |
| 5753 | struct bgp_node *rn; |
| 5754 | struct bgp_info *ri; |
| 5755 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5756 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5757 | { |
| 5758 | afi = family2afi (p->family); |
| 5759 | |
| 5760 | if (bgp->redist[afi][type]) |
| 5761 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5762 | 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] | 5763 | |
| 5764 | for (ri = rn->info; ri; ri = ri->next) |
| 5765 | if (ri->peer == bgp->peer_self |
| 5766 | && ri->type == type) |
| 5767 | break; |
| 5768 | |
| 5769 | if (ri) |
| 5770 | { |
| 5771 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5772 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5773 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5774 | } |
| 5775 | bgp_unlock_node (rn); |
| 5776 | } |
| 5777 | } |
| 5778 | } |
| 5779 | |
| 5780 | /* Withdraw specified route type's route. */ |
| 5781 | void |
| 5782 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5783 | { |
| 5784 | struct bgp_node *rn; |
| 5785 | struct bgp_info *ri; |
| 5786 | struct bgp_table *table; |
| 5787 | |
| 5788 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5789 | |
| 5790 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5791 | { |
| 5792 | for (ri = rn->info; ri; ri = ri->next) |
| 5793 | if (ri->peer == bgp->peer_self |
| 5794 | && ri->type == type) |
| 5795 | break; |
| 5796 | |
| 5797 | if (ri) |
| 5798 | { |
| 5799 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5800 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5801 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5802 | } |
| 5803 | } |
| 5804 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5805 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5806 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5807 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5808 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5809 | { |
| 5810 | int len; |
| 5811 | u_int32_t destination; |
| 5812 | char buf[BUFSIZ]; |
| 5813 | |
| 5814 | if (p->family == AF_INET) |
| 5815 | { |
| 5816 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5817 | destination = ntohl (p->u.prefix4.s_addr); |
| 5818 | |
| 5819 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5820 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5821 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5822 | || p->u.prefix4.s_addr == 0) |
| 5823 | { |
| 5824 | /* When mask is natural, mask is not displayed. */ |
| 5825 | } |
| 5826 | else |
| 5827 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5828 | } |
| 5829 | else |
| 5830 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5831 | p->prefixlen); |
| 5832 | |
| 5833 | len = 17 - len; |
| 5834 | if (len < 1) |
| 5835 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5836 | else |
| 5837 | vty_out (vty, "%*s", len, " "); |
| 5838 | } |
| 5839 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5840 | enum bgp_display_type |
| 5841 | { |
| 5842 | normal_list, |
| 5843 | }; |
| 5844 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5845 | /* Print the short form route status for a bgp_info */ |
| 5846 | static void |
| 5847 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5848 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5849 | /* Route status display. */ |
| 5850 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5851 | vty_out (vty, "R"); |
| 5852 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5853 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5854 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5855 | vty_out (vty, "s"); |
Daniel Walton | e2a0ebf | 2015-05-19 18:03:43 -0700 | [diff] [blame] | 5856 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_VALID) && |
| 5857 | ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5858 | vty_out (vty, "*"); |
| 5859 | else |
| 5860 | vty_out (vty, " "); |
| 5861 | |
| 5862 | /* Selected */ |
| 5863 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5864 | vty_out (vty, "h"); |
| 5865 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5866 | vty_out (vty, "d"); |
| 5867 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5868 | vty_out (vty, ">"); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 5869 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
| 5870 | vty_out (vty, "="); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5871 | else |
| 5872 | vty_out (vty, " "); |
| 5873 | |
| 5874 | /* Internal route. */ |
| 5875 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5876 | vty_out (vty, "i"); |
| 5877 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5878 | vty_out (vty, " "); |
| 5879 | } |
| 5880 | |
| 5881 | /* called from terminal list command */ |
| 5882 | void |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5883 | route_vty_out( |
| 5884 | struct vty *vty, |
| 5885 | struct prefix *p, |
| 5886 | struct bgp_info *binfo, |
| 5887 | int display, |
| 5888 | safi_t safi) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5889 | { |
| 5890 | struct attr *attr; |
| 5891 | |
| 5892 | /* short status lead text */ |
| 5893 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5894 | |
| 5895 | /* print prefix and mask */ |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5896 | if (!display) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5897 | route_vty_out_route (p, vty); |
| 5898 | else |
| 5899 | vty_out (vty, "%*s", 17, " "); |
| 5900 | |
| 5901 | /* Print attribute */ |
| 5902 | attr = binfo->attr; |
| 5903 | if (attr) |
| 5904 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5905 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5906 | /* |
| 5907 | * NEXTHOP start |
| 5908 | */ |
| 5909 | |
| 5910 | /* |
| 5911 | * For ENCAP routes, nexthop address family is not |
| 5912 | * neccessarily the same as the prefix address family. |
| 5913 | * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field |
| 5914 | */ |
| 5915 | if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) { |
| 5916 | if (attr->extra) { |
| 5917 | char buf[BUFSIZ]; |
| 5918 | int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len); |
| 5919 | |
| 5920 | switch (af) { |
| 5921 | case AF_INET: |
| 5922 | vty_out (vty, "%s", inet_ntop(af, |
| 5923 | &attr->extra->mp_nexthop_global_in, buf, BUFSIZ)); |
| 5924 | break; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5925 | case AF_INET6: |
| 5926 | vty_out (vty, "%s", inet_ntop(af, |
| 5927 | &attr->extra->mp_nexthop_global, buf, BUFSIZ)); |
| 5928 | break; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5929 | default: |
| 5930 | vty_out(vty, "?"); |
| 5931 | } |
| 5932 | } else { |
| 5933 | vty_out(vty, "?"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5934 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5935 | } else { |
| 5936 | |
| 5937 | if (p->family == AF_INET) |
| 5938 | { |
| 5939 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5940 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5941 | else if (p->family == AF_INET6) |
| 5942 | { |
| 5943 | int len; |
| 5944 | char buf[BUFSIZ]; |
| 5945 | |
| 5946 | len = vty_out (vty, "%s", |
| 5947 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 5948 | buf, BUFSIZ)); |
| 5949 | len = 16 - len; |
| 5950 | if (len < 1) |
| 5951 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5952 | else |
| 5953 | vty_out (vty, "%*s", len, " "); |
| 5954 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5955 | else |
| 5956 | { |
| 5957 | vty_out(vty, "?"); |
| 5958 | } |
| 5959 | } |
| 5960 | |
| 5961 | /* |
| 5962 | * NEXTHOP end |
| 5963 | */ |
| 5964 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5965 | |
| 5966 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5967 | vty_out (vty, "%10u ", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5968 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5969 | vty_out (vty, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5970 | |
| 5971 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5972 | vty_out (vty, "%7u ", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5973 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 5974 | vty_out (vty, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5975 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5976 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5977 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5978 | /* Print aspath */ |
| 5979 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 5980 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5981 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5982 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5983 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 5984 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5985 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5986 | } |
| 5987 | |
| 5988 | /* called from terminal list command */ |
| 5989 | void |
| 5990 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5991 | struct attr *attr, safi_t safi) |
| 5992 | { |
| 5993 | /* Route status display. */ |
| 5994 | vty_out (vty, "*"); |
| 5995 | vty_out (vty, ">"); |
| 5996 | vty_out (vty, " "); |
| 5997 | |
| 5998 | /* print prefix and mask */ |
| 5999 | route_vty_out_route (p, vty); |
| 6000 | |
| 6001 | /* Print attribute */ |
| 6002 | if (attr) |
| 6003 | { |
| 6004 | if (p->family == AF_INET) |
| 6005 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6006 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6007 | vty_out (vty, "%-16s", |
| 6008 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6009 | else |
| 6010 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6011 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6012 | else if (p->family == AF_INET6) |
| 6013 | { |
| 6014 | int len; |
| 6015 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6016 | |
| 6017 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6018 | |
| 6019 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6020 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6021 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6022 | len = 16 - len; |
| 6023 | if (len < 1) |
| 6024 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 6025 | else |
| 6026 | vty_out (vty, "%*s", len, " "); |
| 6027 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6028 | |
| 6029 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6030 | vty_out (vty, "%10u ", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6031 | else |
| 6032 | vty_out (vty, " "); |
| 6033 | |
| 6034 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6035 | vty_out (vty, "%7u ", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6036 | else |
| 6037 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6038 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6039 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6040 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6041 | /* Print aspath */ |
| 6042 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6043 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6044 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6045 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6046 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6047 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6048 | |
| 6049 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6050 | } |
| 6051 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6052 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6053 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 6054 | struct bgp_info *binfo, int display, safi_t safi) |
| 6055 | { |
| 6056 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6057 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6058 | |
| 6059 | if (!binfo->extra) |
| 6060 | return; |
| 6061 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6062 | /* short status lead text */ |
| 6063 | route_vty_short_status_out (vty, binfo); |
| 6064 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6065 | /* print prefix and mask */ |
| 6066 | if (! display) |
| 6067 | route_vty_out_route (p, vty); |
| 6068 | else |
| 6069 | vty_out (vty, "%*s", 17, " "); |
| 6070 | |
| 6071 | /* Print attribute */ |
| 6072 | attr = binfo->attr; |
| 6073 | if (attr) |
| 6074 | { |
| 6075 | if (p->family == AF_INET) |
| 6076 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6077 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6078 | vty_out (vty, "%-16s", |
| 6079 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6080 | else |
| 6081 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6082 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6083 | else if (p->family == AF_INET6) |
| 6084 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6085 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6086 | char buf[BUFSIZ]; |
| 6087 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6088 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6089 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6090 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6091 | buf, BUFSIZ)); |
| 6092 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6093 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6094 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6095 | buf, BUFSIZ), |
| 6096 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 6097 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6098 | |
| 6099 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6100 | } |
| 6101 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6102 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6103 | |
| 6104 | vty_out (vty, "notag/%d", label); |
| 6105 | |
| 6106 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6107 | } |
| 6108 | |
| 6109 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6110 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6111 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 6112 | struct bgp_info *binfo, int display, safi_t safi) |
| 6113 | { |
| 6114 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6115 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6116 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6117 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6118 | /* short status lead text */ |
| 6119 | route_vty_short_status_out (vty, binfo); |
| 6120 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6121 | /* print prefix and mask */ |
| 6122 | if (! display) |
| 6123 | route_vty_out_route (p, vty); |
| 6124 | else |
| 6125 | vty_out (vty, "%*s", 17, " "); |
| 6126 | |
| 6127 | len = vty_out (vty, "%s", binfo->peer->host); |
| 6128 | len = 17 - len; |
| 6129 | if (len < 1) |
| 6130 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 6131 | else |
| 6132 | vty_out (vty, "%*s", len, " "); |
| 6133 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6134 | 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] | 6135 | |
| 6136 | /* Print attribute */ |
| 6137 | attr = binfo->attr; |
| 6138 | if (attr) |
| 6139 | { |
| 6140 | /* Print aspath */ |
| 6141 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6142 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6143 | |
| 6144 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6145 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6146 | } |
| 6147 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6148 | } |
| 6149 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6150 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6151 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6152 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 6153 | struct bgp_info *binfo, int display, safi_t safi) |
| 6154 | { |
| 6155 | struct attr *attr; |
| 6156 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6157 | char timebuf[BGP_UPTIME_LEN]; |
| 6158 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6159 | |
| 6160 | if (!binfo->extra) |
| 6161 | return; |
| 6162 | |
| 6163 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6164 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6165 | /* short status lead text */ |
| 6166 | route_vty_short_status_out (vty, binfo); |
| 6167 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6168 | /* print prefix and mask */ |
| 6169 | if (! display) |
| 6170 | route_vty_out_route (p, vty); |
| 6171 | else |
| 6172 | vty_out (vty, "%*s", 17, " "); |
| 6173 | |
| 6174 | len = vty_out (vty, "%s", binfo->peer->host); |
| 6175 | len = 16 - len; |
| 6176 | if (len < 1) |
| 6177 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 6178 | else |
| 6179 | vty_out (vty, "%*s", len, " "); |
| 6180 | |
| 6181 | len = vty_out (vty, "%d", bdi->flap); |
| 6182 | len = 5 - len; |
| 6183 | if (len < 1) |
| 6184 | vty_out (vty, " "); |
| 6185 | else |
| 6186 | vty_out (vty, "%*s ", len, " "); |
| 6187 | |
| 6188 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 6189 | timebuf, BGP_UPTIME_LEN)); |
| 6190 | |
| 6191 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 6192 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6193 | 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] | 6194 | else |
| 6195 | vty_out (vty, "%*s ", 8, " "); |
| 6196 | |
| 6197 | /* Print attribute */ |
| 6198 | attr = binfo->attr; |
| 6199 | if (attr) |
| 6200 | { |
| 6201 | /* Print aspath */ |
| 6202 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6203 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6204 | |
| 6205 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6206 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6207 | } |
| 6208 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6209 | } |
| 6210 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6211 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6212 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 6213 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 6214 | { |
| 6215 | char buf[INET6_ADDRSTRLEN]; |
| 6216 | char buf1[BUFSIZ]; |
| 6217 | struct attr *attr; |
| 6218 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6219 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6220 | time_t tbuf; |
| 6221 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6222 | |
| 6223 | attr = binfo->attr; |
| 6224 | |
| 6225 | if (attr) |
| 6226 | { |
| 6227 | /* Line1 display AS-path, Aggregator */ |
| 6228 | if (attr->aspath) |
| 6229 | { |
| 6230 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 6231 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6232 | vty_out (vty, "Local"); |
| 6233 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6234 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6235 | } |
| 6236 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6237 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 6238 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6239 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 6240 | vty_out (vty, ", (stale)"); |
| 6241 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 6242 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6243 | attr->extra->aggregator_as, |
| 6244 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6245 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 6246 | vty_out (vty, ", (Received from a RR-client)"); |
| 6247 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 6248 | vty_out (vty, ", (Received from a RS-client)"); |
| 6249 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6250 | vty_out (vty, ", (history entry)"); |
| 6251 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 6252 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6253 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6254 | |
| 6255 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 6256 | if (p->family == AF_INET) |
| 6257 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6258 | vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6259 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6260 | inet_ntoa (attr->nexthop)); |
| 6261 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6262 | else |
| 6263 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6264 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6265 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6266 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6267 | buf, INET6_ADDRSTRLEN)); |
| 6268 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6269 | |
| 6270 | if (binfo->peer == bgp->peer_self) |
| 6271 | { |
| 6272 | vty_out (vty, " from %s ", |
| 6273 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 6274 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 6275 | } |
| 6276 | else |
| 6277 | { |
| 6278 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6279 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6280 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 6281 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6282 | if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) { |
| 6283 | buf[0] = '?'; |
| 6284 | buf[1] = 0; |
| 6285 | } |
| 6286 | vty_out (vty, " from %s", buf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6287 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6288 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6289 | else |
| 6290 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 6291 | } |
| 6292 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6293 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6294 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6295 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6296 | { |
| 6297 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6298 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6299 | buf, INET6_ADDRSTRLEN), |
| 6300 | VTY_NEWLINE); |
| 6301 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6302 | |
Piotr Chytła | 605aa33 | 2015-12-01 10:03:54 -0500 | [diff] [blame] | 6303 | /* 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] | 6304 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 6305 | |
| 6306 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6307 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6308 | |
| 6309 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6310 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6311 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6312 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6313 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6314 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6315 | vty_out (vty, ", weight %u", attr->extra->weight); |
Piotr Chytła | 605aa33 | 2015-12-01 10:03:54 -0500 | [diff] [blame] | 6316 | |
| 6317 | if (attr->extra && attr->extra->tag != 0) |
| 6318 | vty_out (vty, ", tag %d", attr->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6319 | |
Daniel Walton | e2a0ebf | 2015-05-19 18:03:43 -0700 | [diff] [blame] | 6320 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6321 | vty_out (vty, ", invalid"); |
| 6322 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6323 | vty_out (vty, ", valid"); |
| 6324 | |
| 6325 | if (binfo->peer != bgp->peer_self) |
| 6326 | { |
| 6327 | if (binfo->peer->as == binfo->peer->local_as) |
| 6328 | vty_out (vty, ", internal"); |
| 6329 | else |
| 6330 | vty_out (vty, ", %s", |
| 6331 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6332 | } |
| 6333 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6334 | vty_out (vty, ", aggregated, local"); |
| 6335 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6336 | vty_out (vty, ", sourced"); |
| 6337 | else |
| 6338 | vty_out (vty, ", sourced, local"); |
| 6339 | |
| 6340 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6341 | vty_out (vty, ", atomic-aggregate"); |
| 6342 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6343 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6344 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6345 | bgp_info_mpath_count (binfo))) |
| 6346 | vty_out (vty, ", multipath"); |
| 6347 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6348 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6349 | vty_out (vty, ", best"); |
| 6350 | |
| 6351 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6352 | |
| 6353 | /* Line 4 display Community */ |
| 6354 | if (attr->community) |
| 6355 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6356 | VTY_NEWLINE); |
| 6357 | |
| 6358 | /* Line 5 display Extended-community */ |
| 6359 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6360 | vty_out (vty, " Extended Community: %s%s", |
| 6361 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6362 | |
| 6363 | /* Line 6 display Originator, Cluster-id */ |
| 6364 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6365 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6366 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6367 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6368 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6369 | vty_out (vty, " Originator: %s", |
| 6370 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6371 | |
| 6372 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6373 | { |
| 6374 | int i; |
| 6375 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6376 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6377 | vty_out (vty, "%s ", |
| 6378 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6379 | } |
| 6380 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6381 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6382 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6383 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6384 | bgp_damp_info_vty (vty, binfo); |
| 6385 | |
| 6386 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6387 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6388 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6389 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6390 | #else |
| 6391 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6392 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6393 | } |
| 6394 | vty_out (vty, "%s", VTY_NEWLINE); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 6395 | } |
| 6396 | |
| 6397 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\ |
| 6398 | "h history, * valid, > best, = multipath,%s"\ |
| 6399 | " i internal, r RIB-failure, S Stale, R Removed%s" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6400 | #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] | 6401 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6402 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6403 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6404 | |
| 6405 | enum bgp_show_type |
| 6406 | { |
| 6407 | bgp_show_type_normal, |
| 6408 | bgp_show_type_regexp, |
| 6409 | bgp_show_type_prefix_list, |
| 6410 | bgp_show_type_filter_list, |
| 6411 | bgp_show_type_route_map, |
| 6412 | bgp_show_type_neighbor, |
| 6413 | bgp_show_type_cidr_only, |
| 6414 | bgp_show_type_prefix_longer, |
| 6415 | bgp_show_type_community_all, |
| 6416 | bgp_show_type_community, |
| 6417 | bgp_show_type_community_exact, |
| 6418 | bgp_show_type_community_list, |
| 6419 | bgp_show_type_community_list_exact, |
| 6420 | bgp_show_type_flap_statistics, |
| 6421 | bgp_show_type_flap_address, |
| 6422 | bgp_show_type_flap_prefix, |
| 6423 | bgp_show_type_flap_cidr_only, |
| 6424 | bgp_show_type_flap_regexp, |
| 6425 | bgp_show_type_flap_filter_list, |
| 6426 | bgp_show_type_flap_prefix_list, |
| 6427 | bgp_show_type_flap_prefix_longer, |
| 6428 | bgp_show_type_flap_route_map, |
| 6429 | bgp_show_type_flap_neighbor, |
| 6430 | bgp_show_type_dampend_paths, |
| 6431 | bgp_show_type_damp_neighbor |
| 6432 | }; |
| 6433 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6434 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6435 | 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] | 6436 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6437 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6438 | struct bgp_info *ri; |
| 6439 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6440 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6441 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6442 | unsigned long output_count; |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6443 | unsigned long total_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6444 | |
| 6445 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6446 | output_count = 0; |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6447 | total_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6448 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6449 | /* Start processing of routes. */ |
| 6450 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6451 | if (rn->info != NULL) |
| 6452 | { |
| 6453 | display = 0; |
| 6454 | |
| 6455 | for (ri = rn->info; ri; ri = ri->next) |
| 6456 | { |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6457 | total_count++; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6458 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6459 | || type == bgp_show_type_flap_address |
| 6460 | || type == bgp_show_type_flap_prefix |
| 6461 | || type == bgp_show_type_flap_cidr_only |
| 6462 | || type == bgp_show_type_flap_regexp |
| 6463 | || type == bgp_show_type_flap_filter_list |
| 6464 | || type == bgp_show_type_flap_prefix_list |
| 6465 | || type == bgp_show_type_flap_prefix_longer |
| 6466 | || type == bgp_show_type_flap_route_map |
| 6467 | || type == bgp_show_type_flap_neighbor |
| 6468 | || type == bgp_show_type_dampend_paths |
| 6469 | || type == bgp_show_type_damp_neighbor) |
| 6470 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6471 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6472 | continue; |
| 6473 | } |
| 6474 | if (type == bgp_show_type_regexp |
| 6475 | || type == bgp_show_type_flap_regexp) |
| 6476 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6477 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6478 | |
| 6479 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6480 | continue; |
| 6481 | } |
| 6482 | if (type == bgp_show_type_prefix_list |
| 6483 | || type == bgp_show_type_flap_prefix_list) |
| 6484 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6485 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6486 | |
| 6487 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6488 | continue; |
| 6489 | } |
| 6490 | if (type == bgp_show_type_filter_list |
| 6491 | || type == bgp_show_type_flap_filter_list) |
| 6492 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6493 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6494 | |
| 6495 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6496 | continue; |
| 6497 | } |
| 6498 | if (type == bgp_show_type_route_map |
| 6499 | || type == bgp_show_type_flap_route_map) |
| 6500 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6501 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6502 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6503 | struct attr dummy_attr; |
| 6504 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6505 | int ret; |
| 6506 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6507 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6508 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6509 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6510 | binfo.peer = ri->peer; |
| 6511 | binfo.attr = &dummy_attr; |
| 6512 | |
| 6513 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6514 | if (ret == RMAP_DENYMATCH) |
| 6515 | continue; |
| 6516 | } |
| 6517 | if (type == bgp_show_type_neighbor |
| 6518 | || type == bgp_show_type_flap_neighbor |
| 6519 | || type == bgp_show_type_damp_neighbor) |
| 6520 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6521 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6522 | |
| 6523 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6524 | continue; |
| 6525 | } |
| 6526 | if (type == bgp_show_type_cidr_only |
| 6527 | || type == bgp_show_type_flap_cidr_only) |
| 6528 | { |
| 6529 | u_int32_t destination; |
| 6530 | |
| 6531 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6532 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6533 | continue; |
| 6534 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6535 | continue; |
| 6536 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6537 | continue; |
| 6538 | } |
| 6539 | if (type == bgp_show_type_prefix_longer |
| 6540 | || type == bgp_show_type_flap_prefix_longer) |
| 6541 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6542 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6543 | |
| 6544 | if (! prefix_match (p, &rn->p)) |
| 6545 | continue; |
| 6546 | } |
| 6547 | if (type == bgp_show_type_community_all) |
| 6548 | { |
| 6549 | if (! ri->attr->community) |
| 6550 | continue; |
| 6551 | } |
| 6552 | if (type == bgp_show_type_community) |
| 6553 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6554 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6555 | |
| 6556 | if (! ri->attr->community || |
| 6557 | ! community_match (ri->attr->community, com)) |
| 6558 | continue; |
| 6559 | } |
| 6560 | if (type == bgp_show_type_community_exact) |
| 6561 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6562 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6563 | |
| 6564 | if (! ri->attr->community || |
| 6565 | ! community_cmp (ri->attr->community, com)) |
| 6566 | continue; |
| 6567 | } |
| 6568 | if (type == bgp_show_type_community_list) |
| 6569 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6570 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6571 | |
| 6572 | if (! community_list_match (ri->attr->community, list)) |
| 6573 | continue; |
| 6574 | } |
| 6575 | if (type == bgp_show_type_community_list_exact) |
| 6576 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6577 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6578 | |
| 6579 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6580 | continue; |
| 6581 | } |
| 6582 | if (type == bgp_show_type_flap_address |
| 6583 | || type == bgp_show_type_flap_prefix) |
| 6584 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6585 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6586 | |
| 6587 | if (! prefix_match (&rn->p, p)) |
| 6588 | continue; |
| 6589 | |
| 6590 | if (type == bgp_show_type_flap_prefix) |
| 6591 | if (p->prefixlen != rn->p.prefixlen) |
| 6592 | continue; |
| 6593 | } |
| 6594 | if (type == bgp_show_type_dampend_paths |
| 6595 | || type == bgp_show_type_damp_neighbor) |
| 6596 | { |
| 6597 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6598 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6599 | continue; |
| 6600 | } |
| 6601 | |
| 6602 | if (header) |
| 6603 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6604 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6605 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6606 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6607 | if (type == bgp_show_type_dampend_paths |
| 6608 | || type == bgp_show_type_damp_neighbor) |
| 6609 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6610 | else if (type == bgp_show_type_flap_statistics |
| 6611 | || type == bgp_show_type_flap_address |
| 6612 | || type == bgp_show_type_flap_prefix |
| 6613 | || type == bgp_show_type_flap_cidr_only |
| 6614 | || type == bgp_show_type_flap_regexp |
| 6615 | || type == bgp_show_type_flap_filter_list |
| 6616 | || type == bgp_show_type_flap_prefix_list |
| 6617 | || type == bgp_show_type_flap_prefix_longer |
| 6618 | || type == bgp_show_type_flap_route_map |
| 6619 | || type == bgp_show_type_flap_neighbor) |
| 6620 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6621 | else |
| 6622 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6623 | header = 0; |
| 6624 | } |
| 6625 | |
| 6626 | if (type == bgp_show_type_dampend_paths |
| 6627 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6628 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6629 | else if (type == bgp_show_type_flap_statistics |
| 6630 | || type == bgp_show_type_flap_address |
| 6631 | || type == bgp_show_type_flap_prefix |
| 6632 | || type == bgp_show_type_flap_cidr_only |
| 6633 | || type == bgp_show_type_flap_regexp |
| 6634 | || type == bgp_show_type_flap_filter_list |
| 6635 | || type == bgp_show_type_flap_prefix_list |
| 6636 | || type == bgp_show_type_flap_prefix_longer |
| 6637 | || type == bgp_show_type_flap_route_map |
| 6638 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6639 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6640 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6641 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6642 | display++; |
| 6643 | } |
| 6644 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6645 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6646 | } |
| 6647 | |
| 6648 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6649 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6650 | { |
| 6651 | if (type == bgp_show_type_normal) |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6652 | 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] | 6653 | } |
| 6654 | else |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 6655 | vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s", |
| 6656 | VTY_NEWLINE, output_count, total_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6657 | |
| 6658 | return CMD_SUCCESS; |
| 6659 | } |
| 6660 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6661 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6662 | 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] | 6663 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6664 | { |
| 6665 | struct bgp_table *table; |
| 6666 | |
| 6667 | if (bgp == NULL) { |
| 6668 | bgp = bgp_get_default (); |
| 6669 | } |
| 6670 | |
| 6671 | if (bgp == NULL) |
| 6672 | { |
| 6673 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6674 | return CMD_WARNING; |
| 6675 | } |
| 6676 | |
| 6677 | |
| 6678 | table = bgp->rib[afi][safi]; |
| 6679 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6680 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6681 | } |
| 6682 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6683 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6684 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6685 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6686 | struct bgp_node *rn, |
| 6687 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6688 | { |
| 6689 | struct bgp_info *ri; |
| 6690 | struct prefix *p; |
| 6691 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6692 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6693 | char buf1[INET6_ADDRSTRLEN]; |
| 6694 | char buf2[INET6_ADDRSTRLEN]; |
| 6695 | int count = 0; |
| 6696 | int best = 0; |
| 6697 | int suppress = 0; |
| 6698 | int no_export = 0; |
| 6699 | int no_advertise = 0; |
| 6700 | int local_as = 0; |
| 6701 | int first = 0; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6702 | int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6703 | |
| 6704 | p = &rn->p; |
| 6705 | 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] | 6706 | (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6707 | printrd ? ":" : "", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6708 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6709 | p->prefixlen, VTY_NEWLINE); |
| 6710 | |
| 6711 | for (ri = rn->info; ri; ri = ri->next) |
| 6712 | { |
| 6713 | count++; |
| 6714 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6715 | { |
| 6716 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6717 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6718 | suppress = 1; |
| 6719 | if (ri->attr->community != NULL) |
| 6720 | { |
| 6721 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6722 | no_advertise = 1; |
| 6723 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6724 | no_export = 1; |
| 6725 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6726 | local_as = 1; |
| 6727 | } |
| 6728 | } |
| 6729 | } |
| 6730 | |
| 6731 | vty_out (vty, "Paths: (%d available", count); |
| 6732 | if (best) |
| 6733 | { |
| 6734 | vty_out (vty, ", best #%d", best); |
| 6735 | if (safi == SAFI_UNICAST) |
| 6736 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6737 | } |
| 6738 | else |
| 6739 | vty_out (vty, ", no best path"); |
| 6740 | if (no_advertise) |
| 6741 | vty_out (vty, ", not advertised to any peer"); |
| 6742 | else if (no_export) |
| 6743 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6744 | else if (local_as) |
| 6745 | vty_out (vty, ", not advertised outside local AS"); |
| 6746 | if (suppress) |
| 6747 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6748 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6749 | |
| 6750 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6751 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6752 | { |
| 6753 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6754 | { |
| 6755 | if (! first) |
| 6756 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6757 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6758 | first = 1; |
| 6759 | } |
| 6760 | } |
| 6761 | if (! first) |
| 6762 | vty_out (vty, " Not advertised to any peer"); |
| 6763 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6764 | } |
| 6765 | |
| 6766 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6767 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6768 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6769 | struct bgp_table *rib, const char *ip_str, |
| 6770 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6771 | int prefix_check, enum bgp_path_type pathtype) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6772 | { |
| 6773 | int ret; |
| 6774 | int header; |
| 6775 | int display = 0; |
| 6776 | struct prefix match; |
| 6777 | struct bgp_node *rn; |
| 6778 | struct bgp_node *rm; |
| 6779 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6780 | struct bgp_table *table; |
| 6781 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 6782 | memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6783 | /* Check IP address argument. */ |
| 6784 | ret = str2prefix (ip_str, &match); |
| 6785 | if (! ret) |
| 6786 | { |
| 6787 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6788 | return CMD_WARNING; |
| 6789 | } |
| 6790 | |
| 6791 | match.family = afi2family (afi); |
| 6792 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6793 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6794 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6795 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6796 | { |
| 6797 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6798 | continue; |
| 6799 | |
| 6800 | if ((table = rn->info) != NULL) |
| 6801 | { |
| 6802 | header = 1; |
| 6803 | |
| 6804 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6805 | { |
| 6806 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6807 | { |
| 6808 | bgp_unlock_node (rm); |
| 6809 | continue; |
| 6810 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6811 | |
| 6812 | for (ri = rm->info; ri; ri = ri->next) |
| 6813 | { |
| 6814 | if (header) |
| 6815 | { |
| 6816 | 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] | 6817 | AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6818 | |
| 6819 | header = 0; |
| 6820 | } |
| 6821 | display++; |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6822 | |
| 6823 | if (pathtype == BGP_PATH_ALL || |
| 6824 | (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) || |
| 6825 | (pathtype == BGP_PATH_MULTIPATH && |
| 6826 | (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)))) |
| 6827 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6828 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6829 | |
| 6830 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6831 | } |
| 6832 | } |
| 6833 | } |
| 6834 | } |
| 6835 | else |
| 6836 | { |
| 6837 | header = 1; |
| 6838 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6839 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6840 | { |
| 6841 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6842 | { |
| 6843 | for (ri = rn->info; ri; ri = ri->next) |
| 6844 | { |
| 6845 | if (header) |
| 6846 | { |
| 6847 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6848 | header = 0; |
| 6849 | } |
| 6850 | display++; |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6851 | |
| 6852 | if (pathtype == BGP_PATH_ALL || |
| 6853 | (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) || |
| 6854 | (pathtype == BGP_PATH_MULTIPATH && |
| 6855 | (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)))) |
| 6856 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6857 | } |
| 6858 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6859 | |
| 6860 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6861 | } |
| 6862 | } |
| 6863 | |
| 6864 | if (! display) |
| 6865 | { |
| 6866 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6867 | return CMD_WARNING; |
| 6868 | } |
| 6869 | |
| 6870 | return CMD_SUCCESS; |
| 6871 | } |
| 6872 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6873 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6874 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6875 | 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] | 6876 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6877 | int prefix_check, enum bgp_path_type pathtype) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6878 | { |
| 6879 | struct bgp *bgp; |
| 6880 | |
| 6881 | /* BGP structure lookup. */ |
| 6882 | if (view_name) |
| 6883 | { |
| 6884 | bgp = bgp_lookup_by_name (view_name); |
| 6885 | if (bgp == NULL) |
| 6886 | { |
| 6887 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6888 | return CMD_WARNING; |
| 6889 | } |
| 6890 | } |
| 6891 | else |
| 6892 | { |
| 6893 | bgp = bgp_get_default (); |
| 6894 | if (bgp == NULL) |
| 6895 | { |
| 6896 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6897 | return CMD_WARNING; |
| 6898 | } |
| 6899 | } |
| 6900 | |
| 6901 | 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] | 6902 | afi, safi, prd, prefix_check, pathtype); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6903 | } |
| 6904 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6905 | /* BGP route print out function. */ |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 6906 | DEFUN (show_ip_bgp, |
| 6907 | show_ip_bgp_cmd, |
| 6908 | "show ip bgp", |
| 6909 | SHOW_STR |
| 6910 | IP_STR |
| 6911 | BGP_STR) |
| 6912 | { |
| 6913 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6914 | } |
| 6915 | |
| 6916 | DEFUN (show_ip_bgp_ipv4, |
| 6917 | show_ip_bgp_ipv4_cmd, |
| 6918 | "show ip bgp ipv4 (unicast|multicast)", |
| 6919 | SHOW_STR |
| 6920 | IP_STR |
| 6921 | BGP_STR |
| 6922 | "Address family\n" |
| 6923 | "Address Family modifier\n" |
| 6924 | "Address Family modifier\n") |
| 6925 | { |
| 6926 | if (strncmp (argv[0], "m", 1) == 0) |
| 6927 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6928 | NULL); |
| 6929 | |
| 6930 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 6931 | } |
| 6932 | |
| 6933 | DEFUN (show_ip_bgp_route, |
| 6934 | show_ip_bgp_route_cmd, |
| 6935 | "show ip bgp A.B.C.D", |
| 6936 | SHOW_STR |
| 6937 | IP_STR |
| 6938 | BGP_STR |
| 6939 | "Network in the BGP routing table to display\n") |
| 6940 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6941 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
| 6942 | } |
| 6943 | |
| 6944 | DEFUN (show_ip_bgp_route_pathtype, |
| 6945 | show_ip_bgp_route_pathtype_cmd, |
| 6946 | "show ip bgp A.B.C.D (bestpath|multipath)", |
| 6947 | SHOW_STR |
| 6948 | IP_STR |
| 6949 | BGP_STR |
| 6950 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 6951 | "Display only the bestpath\n" |
| 6952 | "Display only multipaths\n") |
| 6953 | { |
| 6954 | if (strncmp (argv[1], "b", 1) == 0) |
| 6955 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 6956 | else |
| 6957 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH); |
| 6958 | } |
| 6959 | |
| 6960 | DEFUN (show_bgp_ipv4_safi_route_pathtype, |
| 6961 | show_bgp_ipv4_safi_route_pathtype_cmd, |
| 6962 | "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath)", |
| 6963 | SHOW_STR |
| 6964 | BGP_STR |
| 6965 | "Address family\n" |
| 6966 | "Address Family modifier\n" |
| 6967 | "Address Family modifier\n" |
| 6968 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 6969 | "Display only the bestpath\n" |
| 6970 | "Display only multipaths\n") |
| 6971 | { |
| 6972 | if (strncmp (argv[0], "m", 1) == 0) |
| 6973 | if (strncmp (argv[2], "b", 1) == 0) |
| 6974 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 6975 | else |
| 6976 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH); |
| 6977 | else |
| 6978 | if (strncmp (argv[2], "b", 1) == 0) |
| 6979 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 6980 | else |
| 6981 | 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] | 6982 | } |
| 6983 | |
| 6984 | DEFUN (show_ip_bgp_ipv4_route, |
| 6985 | show_ip_bgp_ipv4_route_cmd, |
| 6986 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6987 | SHOW_STR |
| 6988 | IP_STR |
| 6989 | BGP_STR |
| 6990 | "Address family\n" |
| 6991 | "Address Family modifier\n" |
| 6992 | "Address Family modifier\n" |
| 6993 | "Network in the BGP routing table to display\n") |
| 6994 | { |
| 6995 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6996 | 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] | 6997 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 6998 | 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] | 6999 | } |
| 7000 | |
| 7001 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 7002 | show_ip_bgp_vpnv4_all_route_cmd, |
| 7003 | "show ip bgp vpnv4 all A.B.C.D", |
| 7004 | SHOW_STR |
| 7005 | IP_STR |
| 7006 | BGP_STR |
| 7007 | "Display VPNv4 NLRI specific information\n" |
| 7008 | "Display information about all VPNv4 NLRIs\n" |
| 7009 | "Network in the BGP routing table to display\n") |
| 7010 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7011 | 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] | 7012 | } |
| 7013 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7014 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7015 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 7016 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 7017 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 7018 | SHOW_STR |
| 7019 | IP_STR |
| 7020 | BGP_STR |
| 7021 | "Display VPNv4 NLRI specific information\n" |
| 7022 | "Display information for a route distinguisher\n" |
| 7023 | "VPN Route Distinguisher\n" |
| 7024 | "Network in the BGP routing table to display\n") |
| 7025 | { |
| 7026 | int ret; |
| 7027 | struct prefix_rd prd; |
| 7028 | |
| 7029 | ret = str2prefix_rd (argv[0], &prd); |
| 7030 | if (! ret) |
| 7031 | { |
| 7032 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7033 | return CMD_WARNING; |
| 7034 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7035 | 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] | 7036 | } |
| 7037 | |
| 7038 | DEFUN (show_ip_bgp_prefix, |
| 7039 | show_ip_bgp_prefix_cmd, |
| 7040 | "show ip bgp A.B.C.D/M", |
| 7041 | SHOW_STR |
| 7042 | IP_STR |
| 7043 | BGP_STR |
| 7044 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7045 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7046 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
| 7047 | } |
| 7048 | |
| 7049 | DEFUN (show_ip_bgp_prefix_pathtype, |
| 7050 | show_ip_bgp_prefix_pathtype_cmd, |
| 7051 | "show ip bgp A.B.C.D/M (bestpath|multipath)", |
| 7052 | SHOW_STR |
| 7053 | IP_STR |
| 7054 | BGP_STR |
| 7055 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7056 | "Display only the bestpath\n" |
| 7057 | "Display only multipaths\n") |
| 7058 | { |
| 7059 | if (strncmp (argv[1], "b", 1) == 0) |
| 7060 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7061 | else |
| 7062 | 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] | 7063 | } |
| 7064 | |
| 7065 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 7066 | show_ip_bgp_ipv4_prefix_cmd, |
| 7067 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 7068 | SHOW_STR |
| 7069 | IP_STR |
| 7070 | BGP_STR |
| 7071 | "Address family\n" |
| 7072 | "Address Family modifier\n" |
| 7073 | "Address Family modifier\n" |
| 7074 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7075 | { |
| 7076 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7077 | 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] | 7078 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7079 | 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] | 7080 | } |
| 7081 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7082 | DEFUN (show_ip_bgp_ipv4_prefix_pathtype, |
| 7083 | show_ip_bgp_ipv4_prefix_pathtype_cmd, |
| 7084 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath)", |
| 7085 | SHOW_STR |
| 7086 | IP_STR |
| 7087 | BGP_STR |
| 7088 | "Address family\n" |
| 7089 | "Address Family modifier\n" |
| 7090 | "Address Family modifier\n" |
| 7091 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7092 | "Display only the bestpath\n" |
| 7093 | "Display only multipaths\n") |
| 7094 | { |
| 7095 | if (strncmp (argv[0], "m", 1) == 0) |
| 7096 | if (strncmp (argv[2], "b", 1) == 0) |
| 7097 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7098 | else |
| 7099 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH); |
| 7100 | else |
| 7101 | if (strncmp (argv[2], "b", 1) == 0) |
| 7102 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7103 | else |
| 7104 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH); |
| 7105 | } |
| 7106 | |
| 7107 | ALIAS (show_ip_bgp_ipv4_prefix_pathtype, |
| 7108 | show_bgp_ipv4_safi_prefix_pathtype_cmd, |
| 7109 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath)", |
| 7110 | SHOW_STR |
| 7111 | BGP_STR |
| 7112 | "Address family\n" |
| 7113 | "Address Family modifier\n" |
| 7114 | "Address Family modifier\n" |
| 7115 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 7116 | "Display only the bestpath\n" |
| 7117 | "Display only multipaths\n") |
| 7118 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7119 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 7120 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 7121 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 7122 | SHOW_STR |
| 7123 | IP_STR |
| 7124 | BGP_STR |
| 7125 | "Display VPNv4 NLRI specific information\n" |
| 7126 | "Display information about all VPNv4 NLRIs\n" |
| 7127 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7128 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7129 | 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] | 7130 | } |
| 7131 | |
| 7132 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 7133 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 7134 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 7135 | SHOW_STR |
| 7136 | IP_STR |
| 7137 | BGP_STR |
| 7138 | "Display VPNv4 NLRI specific information\n" |
| 7139 | "Display information for a route distinguisher\n" |
| 7140 | "VPN Route Distinguisher\n" |
| 7141 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7142 | { |
| 7143 | int ret; |
| 7144 | struct prefix_rd prd; |
| 7145 | |
| 7146 | ret = str2prefix_rd (argv[0], &prd); |
| 7147 | if (! ret) |
| 7148 | { |
| 7149 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7150 | return CMD_WARNING; |
| 7151 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7152 | 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] | 7153 | } |
| 7154 | |
| 7155 | DEFUN (show_ip_bgp_view, |
| 7156 | show_ip_bgp_view_cmd, |
| 7157 | "show ip bgp view WORD", |
| 7158 | SHOW_STR |
| 7159 | IP_STR |
| 7160 | BGP_STR |
| 7161 | "BGP view\n" |
| 7162 | "View name\n") |
| 7163 | { |
| 7164 | struct bgp *bgp; |
| 7165 | |
| 7166 | /* BGP structure lookup. */ |
| 7167 | bgp = bgp_lookup_by_name (argv[0]); |
| 7168 | if (bgp == NULL) |
| 7169 | { |
| 7170 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7171 | return CMD_WARNING; |
| 7172 | } |
| 7173 | |
| 7174 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 7175 | } |
| 7176 | |
| 7177 | DEFUN (show_ip_bgp_view_route, |
| 7178 | show_ip_bgp_view_route_cmd, |
| 7179 | "show ip bgp view WORD A.B.C.D", |
| 7180 | SHOW_STR |
| 7181 | IP_STR |
| 7182 | BGP_STR |
| 7183 | "BGP view\n" |
| 7184 | "View name\n" |
| 7185 | "Network in the BGP routing table to display\n") |
| 7186 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7187 | 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] | 7188 | } |
| 7189 | |
| 7190 | DEFUN (show_ip_bgp_view_prefix, |
| 7191 | show_ip_bgp_view_prefix_cmd, |
| 7192 | "show ip bgp view WORD A.B.C.D/M", |
| 7193 | SHOW_STR |
| 7194 | IP_STR |
| 7195 | BGP_STR |
| 7196 | "BGP view\n" |
| 7197 | "View name\n" |
| 7198 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7199 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7200 | 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] | 7201 | } |
| 7202 | |
| 7203 | DEFUN (show_bgp, |
| 7204 | show_bgp_cmd, |
| 7205 | "show bgp", |
| 7206 | SHOW_STR |
| 7207 | BGP_STR) |
| 7208 | { |
| 7209 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 7210 | NULL); |
| 7211 | } |
| 7212 | |
| 7213 | ALIAS (show_bgp, |
| 7214 | show_bgp_ipv6_cmd, |
| 7215 | "show bgp ipv6", |
| 7216 | SHOW_STR |
| 7217 | BGP_STR |
| 7218 | "Address family\n") |
| 7219 | |
| 7220 | /* old command */ |
| 7221 | DEFUN (show_ipv6_bgp, |
| 7222 | show_ipv6_bgp_cmd, |
| 7223 | "show ipv6 bgp", |
| 7224 | SHOW_STR |
| 7225 | IP_STR |
| 7226 | BGP_STR) |
| 7227 | { |
| 7228 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 7229 | NULL); |
| 7230 | } |
| 7231 | |
| 7232 | DEFUN (show_bgp_route, |
| 7233 | show_bgp_route_cmd, |
| 7234 | "show bgp X:X::X:X", |
| 7235 | SHOW_STR |
| 7236 | BGP_STR |
| 7237 | "Network in the BGP routing table to display\n") |
| 7238 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7239 | 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] | 7240 | } |
| 7241 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7242 | DEFUN (show_bgp_ipv4_safi, |
| 7243 | show_bgp_ipv4_safi_cmd, |
| 7244 | "show bgp ipv4 (unicast|multicast)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7245 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7246 | BGP_STR |
| 7247 | "Address family\n" |
| 7248 | "Address Family modifier\n" |
| 7249 | "Address Family modifier\n") |
| 7250 | { |
| 7251 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7252 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 7253 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7254 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7255 | 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] | 7256 | } |
| 7257 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7258 | DEFUN (show_bgp_ipv4_safi_route, |
| 7259 | show_bgp_ipv4_safi_route_cmd, |
| 7260 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7261 | SHOW_STR |
| 7262 | BGP_STR |
| 7263 | "Address family\n" |
| 7264 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7265 | "Address Family modifier\n" |
| 7266 | "Network in the BGP routing table to display\n") |
| 7267 | { |
| 7268 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7269 | 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] | 7270 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7271 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
| 7272 | } |
| 7273 | |
| 7274 | DEFUN (show_bgp_route_pathtype, |
| 7275 | show_bgp_route_pathtype_cmd, |
| 7276 | "show bgp X:X::X:X (bestpath|multipath)", |
| 7277 | SHOW_STR |
| 7278 | BGP_STR |
| 7279 | "Network in the BGP routing table to display\n" |
| 7280 | "Display only the bestpath\n" |
| 7281 | "Display only multipaths\n") |
| 7282 | { |
| 7283 | if (strncmp (argv[1], "b", 1) == 0) |
| 7284 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 7285 | else |
| 7286 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH); |
| 7287 | } |
| 7288 | |
| 7289 | ALIAS (show_bgp_route_pathtype, |
| 7290 | show_bgp_ipv6_route_pathtype_cmd, |
| 7291 | "show bgp ipv6 X:X::X:X (bestpath|multipath)", |
| 7292 | SHOW_STR |
| 7293 | BGP_STR |
| 7294 | "Address family\n" |
| 7295 | "Network in the BGP routing table to display\n" |
| 7296 | "Display only the bestpath\n" |
| 7297 | "Display only multipaths\n") |
| 7298 | |
| 7299 | DEFUN (show_bgp_ipv6_safi_route_pathtype, |
| 7300 | show_bgp_ipv6_safi_route_pathtype_cmd, |
| 7301 | "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath)", |
| 7302 | SHOW_STR |
| 7303 | BGP_STR |
| 7304 | "Address family\n" |
| 7305 | "Address Family modifier\n" |
| 7306 | "Address Family modifier\n" |
| 7307 | "Network in the BGP routing table to display\n" |
| 7308 | "Display only the bestpath\n" |
| 7309 | "Display only multipaths\n") |
| 7310 | { |
| 7311 | if (strncmp (argv[0], "m", 1) == 0) |
| 7312 | if (strncmp (argv[2], "b", 1) == 0) |
| 7313 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 7314 | else |
| 7315 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH); |
| 7316 | else |
| 7317 | if (strncmp (argv[2], "b", 1) == 0) |
| 7318 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH); |
| 7319 | else |
| 7320 | 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] | 7321 | } |
| 7322 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7323 | DEFUN (show_bgp_ipv4_vpn_route, |
| 7324 | show_bgp_ipv4_vpn_route_cmd, |
| 7325 | "show bgp ipv4 vpn A.B.C.D", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7326 | SHOW_STR |
| 7327 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7328 | "Address Family\n" |
| 7329 | "Display VPN NLRI specific information\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7330 | "Network in the BGP routing table to display\n") |
| 7331 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7332 | 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] | 7333 | } |
| 7334 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7335 | DEFUN (show_bgp_ipv6_vpn_route, |
| 7336 | show_bgp_ipv6_vpn_route_cmd, |
| 7337 | "show bgp ipv6 vpn X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7338 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7339 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7340 | "Address Family\n" |
| 7341 | "Display VPN NLRI specific information\n" |
| 7342 | "Network in the BGP routing table to display\n") |
| 7343 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7344 | 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] | 7345 | } |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7346 | |
| 7347 | DEFUN (show_bgp_ipv4_vpn_rd_route, |
| 7348 | show_bgp_ipv4_vpn_rd_route_cmd, |
| 7349 | "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 7350 | SHOW_STR |
| 7351 | BGP_STR |
| 7352 | IP_STR |
| 7353 | "Display VPN NLRI specific information\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7354 | "Display information for a route distinguisher\n" |
| 7355 | "VPN Route Distinguisher\n" |
| 7356 | "Network in the BGP routing table to display\n") |
| 7357 | { |
| 7358 | int ret; |
| 7359 | struct prefix_rd prd; |
| 7360 | |
| 7361 | ret = str2prefix_rd (argv[0], &prd); |
| 7362 | if (! ret) |
| 7363 | { |
| 7364 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7365 | return CMD_WARNING; |
| 7366 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7367 | 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] | 7368 | } |
| 7369 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7370 | DEFUN (show_bgp_ipv6_vpn_rd_route, |
| 7371 | show_bgp_ipv6_vpn_rd_route_cmd, |
| 7372 | "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] | 7373 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7374 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7375 | "Address Family\n" |
| 7376 | "Display VPN NLRI specific information\n" |
| 7377 | "Display information for a route distinguisher\n" |
| 7378 | "VPN Route Distinguisher\n" |
| 7379 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7380 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7381 | int ret; |
| 7382 | struct prefix_rd prd; |
| 7383 | |
| 7384 | ret = str2prefix_rd (argv[0], &prd); |
| 7385 | if (! ret) |
| 7386 | { |
| 7387 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7388 | return CMD_WARNING; |
| 7389 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7390 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL); |
| 7391 | } |
| 7392 | |
| 7393 | DEFUN (show_bgp_prefix_pathtype, |
| 7394 | show_bgp_prefix_pathtype_cmd, |
| 7395 | "show bgp X:X::X:X/M (bestpath|multipath)", |
| 7396 | SHOW_STR |
| 7397 | BGP_STR |
| 7398 | "IPv6 prefix <network>/<length>\n" |
| 7399 | "Display only the bestpath\n" |
| 7400 | "Display only multipaths\n") |
| 7401 | { |
| 7402 | if (strncmp (argv[1], "b", 1) == 0) |
| 7403 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7404 | else |
| 7405 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH); |
| 7406 | } |
| 7407 | |
| 7408 | ALIAS (show_bgp_prefix_pathtype, |
| 7409 | show_bgp_ipv6_prefix_pathtype_cmd, |
| 7410 | "show bgp ipv6 X:X::X:X/M (bestpath|multipath)", |
| 7411 | SHOW_STR |
| 7412 | BGP_STR |
| 7413 | "Address family\n" |
| 7414 | "IPv6 prefix <network>/<length>\n" |
| 7415 | "Display only the bestpath\n" |
| 7416 | "Display only multipaths\n") |
| 7417 | |
| 7418 | DEFUN (show_bgp_ipv6_safi_prefix_pathtype, |
| 7419 | show_bgp_ipv6_safi_prefix_pathtype_cmd, |
| 7420 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath)", |
| 7421 | SHOW_STR |
| 7422 | BGP_STR |
| 7423 | "Address family\n" |
| 7424 | "Address Family modifier\n" |
| 7425 | "Address Family modifier\n" |
| 7426 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 7427 | "Display only the bestpath\n" |
| 7428 | "Display only multipaths\n") |
| 7429 | { |
| 7430 | if (strncmp (argv[0], "m", 1) == 0) |
| 7431 | if (strncmp (argv[2], "b", 1) == 0) |
| 7432 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7433 | else |
| 7434 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH); |
| 7435 | else |
| 7436 | if (strncmp (argv[2], "b", 1) == 0) |
| 7437 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH); |
| 7438 | else |
| 7439 | 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] | 7440 | } |
| 7441 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7442 | DEFUN (show_bgp_ipv4_encap_route, |
| 7443 | show_bgp_ipv4_encap_route_cmd, |
| 7444 | "show bgp ipv4 encap A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7445 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7446 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7447 | IP_STR |
| 7448 | "Display ENCAP NLRI specific information\n" |
| 7449 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7450 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7451 | 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] | 7452 | } |
| 7453 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7454 | DEFUN (show_bgp_ipv6_encap_route, |
| 7455 | show_bgp_ipv6_encap_route_cmd, |
| 7456 | "show bgp ipv6 encap X:X::X:X", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7457 | SHOW_STR |
| 7458 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7459 | IP6_STR |
| 7460 | "Display ENCAP NLRI specific information\n" |
| 7461 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7462 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7463 | 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] | 7464 | } |
| 7465 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7466 | DEFUN (show_bgp_ipv4_safi_rd_route, |
| 7467 | show_bgp_ipv4_safi_rd_route_cmd, |
| 7468 | "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] | 7469 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7470 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7471 | "Address Family\n" |
| 7472 | "Address Family Modifier\n" |
| 7473 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7474 | "Display information for a route distinguisher\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7475 | "ENCAP Route Distinguisher\n" |
| 7476 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7477 | { |
| 7478 | int ret; |
| 7479 | struct prefix_rd prd; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7480 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7481 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7482 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7483 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7484 | return CMD_WARNING; |
| 7485 | } |
| 7486 | ret = str2prefix_rd (argv[1], &prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7487 | if (! ret) |
| 7488 | { |
| 7489 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7490 | return CMD_WARNING; |
| 7491 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7492 | 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] | 7493 | } |
| 7494 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7495 | DEFUN (show_bgp_ipv6_safi_rd_route, |
| 7496 | show_bgp_ipv6_safi_rd_route_cmd, |
| 7497 | "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] | 7498 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7499 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7500 | "Address Family\n" |
| 7501 | "Address Family Modifier\n" |
| 7502 | "Address Family Modifier\n" |
| 7503 | "Display information for a route distinguisher\n" |
| 7504 | "ENCAP Route Distinguisher\n" |
| 7505 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7506 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7507 | int ret; |
| 7508 | struct prefix_rd prd; |
| 7509 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7510 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7511 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7512 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7513 | return CMD_WARNING; |
| 7514 | } |
| 7515 | ret = str2prefix_rd (argv[1], &prd); |
| 7516 | if (! ret) |
| 7517 | { |
| 7518 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7519 | return CMD_WARNING; |
| 7520 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7521 | 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] | 7522 | } |
| 7523 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7524 | DEFUN (show_bgp_ipv4_prefix, |
| 7525 | show_bgp_ipv4_prefix_cmd, |
| 7526 | "show bgp ipv4 A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7527 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7528 | BGP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7529 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7530 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7531 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7532 | 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] | 7533 | } |
| 7534 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7535 | DEFUN (show_bgp_ipv4_safi_prefix, |
| 7536 | show_bgp_ipv4_safi_prefix_cmd, |
| 7537 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7538 | SHOW_STR |
| 7539 | BGP_STR |
| 7540 | "Address family\n" |
| 7541 | "Address Family modifier\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7542 | "Address Family modifier\n" |
| 7543 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7544 | { |
| 7545 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7546 | 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] | 7547 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7548 | 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] | 7549 | } |
| 7550 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7551 | DEFUN (show_bgp_ipv4_vpn_prefix, |
| 7552 | show_bgp_ipv4_vpn_prefix_cmd, |
| 7553 | "show bgp ipv4 vpn A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7554 | SHOW_STR |
| 7555 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7556 | IP_STR |
| 7557 | "Display VPN NLRI specific information\n" |
| 7558 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7559 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7560 | 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] | 7561 | } |
| 7562 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7563 | DEFUN (show_bgp_ipv6_vpn_prefix, |
| 7564 | show_bgp_ipv6_vpn_prefix_cmd, |
| 7565 | "show bgp ipv6 vpn X:X::X:X/M", |
| 7566 | SHOW_STR |
| 7567 | BGP_STR |
| 7568 | "Address Family\n" |
| 7569 | "Display VPN NLRI specific information\n" |
| 7570 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7571 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7572 | 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] | 7573 | } |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7574 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7575 | DEFUN (show_bgp_ipv4_encap_prefix, |
| 7576 | show_bgp_ipv4_encap_prefix_cmd, |
| 7577 | "show bgp ipv4 encap A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7578 | SHOW_STR |
| 7579 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7580 | IP_STR |
| 7581 | "Display ENCAP NLRI specific information\n" |
| 7582 | "Display information about ENCAP NLRIs\n" |
| 7583 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7584 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7585 | 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] | 7586 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7587 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7588 | DEFUN (show_bgp_ipv6_encap_prefix, |
| 7589 | show_bgp_ipv6_encap_prefix_cmd, |
| 7590 | "show bgp ipv6 encap X:X::X:X/M", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7591 | SHOW_STR |
| 7592 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7593 | IP_STR |
| 7594 | "Display ENCAP NLRI specific information\n" |
| 7595 | "Display information about ENCAP NLRIs\n" |
| 7596 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7597 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7598 | 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] | 7599 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7600 | |
| 7601 | DEFUN (show_bgp_ipv4_safi_rd_prefix, |
| 7602 | show_bgp_ipv4_safi_rd_prefix_cmd, |
| 7603 | "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 7604 | SHOW_STR |
| 7605 | BGP_STR |
| 7606 | "Address Family\n" |
| 7607 | "Address Family Modifier\n" |
| 7608 | "Address Family Modifier\n" |
| 7609 | "Display information for a route distinguisher\n" |
| 7610 | "ENCAP Route Distinguisher\n" |
| 7611 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7612 | { |
| 7613 | int ret; |
| 7614 | struct prefix_rd prd; |
| 7615 | safi_t safi; |
| 7616 | |
| 7617 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7618 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7619 | return CMD_WARNING; |
| 7620 | } |
| 7621 | |
| 7622 | ret = str2prefix_rd (argv[1], &prd); |
| 7623 | if (! ret) |
| 7624 | { |
| 7625 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7626 | return CMD_WARNING; |
| 7627 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7628 | 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] | 7629 | } |
| 7630 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7631 | DEFUN (show_bgp_ipv6_safi_rd_prefix, |
| 7632 | show_bgp_ipv6_safi_rd_prefix_cmd, |
| 7633 | "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M", |
| 7634 | SHOW_STR |
| 7635 | BGP_STR |
| 7636 | "Address Family\n" |
| 7637 | "Address Family Modifier\n" |
| 7638 | "Address Family Modifier\n" |
| 7639 | "Display information for a route distinguisher\n" |
| 7640 | "ENCAP Route Distinguisher\n" |
| 7641 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7642 | { |
| 7643 | int ret; |
| 7644 | struct prefix_rd prd; |
| 7645 | safi_t safi; |
| 7646 | |
| 7647 | if (bgp_parse_safi(argv[0], &safi)) { |
| 7648 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 7649 | return CMD_WARNING; |
| 7650 | } |
| 7651 | |
| 7652 | ret = str2prefix_rd (argv[1], &prd); |
| 7653 | if (! ret) |
| 7654 | { |
| 7655 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7656 | return CMD_WARNING; |
| 7657 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7658 | 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] | 7659 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7660 | |
| 7661 | DEFUN (show_bgp_afi_safi_view, |
| 7662 | show_bgp_afi_safi_view_cmd, |
| 7663 | "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)", |
| 7664 | SHOW_STR |
| 7665 | BGP_STR |
| 7666 | "BGP view\n" |
| 7667 | "BGP view name\n" |
| 7668 | "Address Family\n" |
| 7669 | "Address Family\n" |
| 7670 | "Address Family Modifier\n" |
| 7671 | "Address Family Modifier\n" |
| 7672 | "Address Family Modifier\n" |
| 7673 | "Address Family Modifier\n" |
| 7674 | ) |
| 7675 | { |
| 7676 | struct bgp *bgp; |
| 7677 | safi_t safi; |
| 7678 | afi_t afi; |
| 7679 | |
| 7680 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7681 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7682 | return CMD_WARNING; |
| 7683 | } |
| 7684 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7685 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7686 | return CMD_WARNING; |
| 7687 | } |
| 7688 | |
| 7689 | /* BGP structure lookup. */ |
| 7690 | bgp = bgp_lookup_by_name (argv[0]); |
| 7691 | if (bgp == NULL) |
| 7692 | { |
| 7693 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7694 | return CMD_WARNING; |
| 7695 | } |
| 7696 | |
| 7697 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL); |
| 7698 | } |
| 7699 | |
| 7700 | DEFUN (show_bgp_view_afi_safi_route, |
| 7701 | show_bgp_view_afi_safi_route_cmd, |
| 7702 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D", |
| 7703 | SHOW_STR |
| 7704 | BGP_STR |
| 7705 | "BGP view\n" |
| 7706 | "View name\n" |
| 7707 | "Address Family\n" |
| 7708 | "Address Family\n" |
| 7709 | "Address Family Modifier\n" |
| 7710 | "Address Family Modifier\n" |
| 7711 | "Address Family Modifier\n" |
| 7712 | "Address Family Modifier\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7713 | "Network in the BGP routing table to display\n") |
| 7714 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7715 | safi_t safi; |
| 7716 | afi_t afi; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7717 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7718 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7719 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7720 | return CMD_WARNING; |
| 7721 | } |
| 7722 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7723 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7724 | return CMD_WARNING; |
| 7725 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7726 | 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] | 7727 | } |
| 7728 | |
| 7729 | DEFUN (show_bgp_view_afi_safi_prefix, |
| 7730 | show_bgp_view_afi_safi_prefix_cmd, |
| 7731 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M", |
| 7732 | SHOW_STR |
| 7733 | BGP_STR |
| 7734 | "BGP view\n" |
| 7735 | "View name\n" |
| 7736 | "Address Family\n" |
| 7737 | "Address Family\n" |
| 7738 | "Address Family Modifier\n" |
| 7739 | "Address Family Modifier\n" |
| 7740 | "Address Family Modifier\n" |
| 7741 | "Address Family Modifier\n" |
| 7742 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7743 | { |
| 7744 | safi_t safi; |
| 7745 | afi_t afi; |
| 7746 | |
| 7747 | if (bgp_parse_afi(argv[1], &afi)) { |
| 7748 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7749 | return CMD_WARNING; |
| 7750 | } |
| 7751 | if (bgp_parse_safi(argv[2], &safi)) { |
| 7752 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 7753 | return CMD_WARNING; |
| 7754 | } |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7755 | 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] | 7756 | } |
| 7757 | |
| 7758 | /* new001 */ |
| 7759 | DEFUN (show_bgp_afi, |
| 7760 | show_bgp_afi_cmd, |
| 7761 | "show bgp (ipv4|ipv6)", |
| 7762 | SHOW_STR |
| 7763 | BGP_STR |
| 7764 | "Address family\n" |
| 7765 | "Address family\n") |
| 7766 | { |
| 7767 | afi_t afi; |
| 7768 | |
| 7769 | if (bgp_parse_afi(argv[0], &afi)) { |
| 7770 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 7771 | return CMD_WARNING; |
| 7772 | } |
| 7773 | return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal, |
| 7774 | NULL); |
| 7775 | } |
| 7776 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 7777 | DEFUN (show_bgp_ipv6_safi, |
| 7778 | show_bgp_ipv6_safi_cmd, |
| 7779 | "show bgp ipv6 (unicast|multicast)", |
| 7780 | SHOW_STR |
| 7781 | BGP_STR |
| 7782 | "Address family\n" |
| 7783 | "Address Family modifier\n" |
| 7784 | "Address Family modifier\n") |
| 7785 | { |
| 7786 | if (strncmp (argv[0], "m", 1) == 0) |
| 7787 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7788 | NULL); |
| 7789 | |
| 7790 | 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] | 7791 | } |
| 7792 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7793 | DEFUN (show_bgp_ipv6_route, |
| 7794 | show_bgp_ipv6_route_cmd, |
| 7795 | "show bgp ipv6 X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7796 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7797 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7798 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7799 | "Network in the BGP routing table to display\n") |
| 7800 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7801 | 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] | 7802 | } |
| 7803 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7804 | DEFUN (show_bgp_ipv6_safi_route, |
| 7805 | show_bgp_ipv6_safi_route_cmd, |
| 7806 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7807 | SHOW_STR |
| 7808 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7809 | "Address family\n" |
| 7810 | "Address Family modifier\n" |
| 7811 | "Address Family modifier\n" |
| 7812 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7813 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7814 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7815 | 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] | 7816 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7817 | 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] | 7818 | } |
| 7819 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7820 | /* old command */ |
| 7821 | DEFUN (show_ipv6_bgp_route, |
| 7822 | show_ipv6_bgp_route_cmd, |
| 7823 | "show ipv6 bgp X:X::X:X", |
| 7824 | SHOW_STR |
| 7825 | IP_STR |
| 7826 | BGP_STR |
| 7827 | "Network in the BGP routing table to display\n") |
| 7828 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7829 | 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] | 7830 | } |
| 7831 | |
| 7832 | DEFUN (show_bgp_prefix, |
| 7833 | show_bgp_prefix_cmd, |
| 7834 | "show bgp X:X::X:X/M", |
| 7835 | SHOW_STR |
| 7836 | BGP_STR |
| 7837 | "IPv6 prefix <network>/<length>\n") |
| 7838 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7839 | 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] | 7840 | } |
| 7841 | |
| 7842 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7843 | /* new002 */ |
| 7844 | DEFUN (show_bgp_ipv6_prefix, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7845 | show_bgp_ipv6_prefix_cmd, |
| 7846 | "show bgp ipv6 X:X::X:X/M", |
| 7847 | SHOW_STR |
| 7848 | BGP_STR |
| 7849 | "Address family\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7850 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7851 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7852 | 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] | 7853 | } |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7854 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 7855 | show_bgp_ipv6_safi_prefix_cmd, |
| 7856 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 7857 | SHOW_STR |
| 7858 | BGP_STR |
| 7859 | "Address family\n" |
| 7860 | "Address Family modifier\n" |
| 7861 | "Address Family modifier\n" |
| 7862 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7863 | { |
| 7864 | if (strncmp (argv[0], "m", 1) == 0) |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7865 | 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] | 7866 | |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7867 | 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] | 7868 | } |
| 7869 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7870 | /* old command */ |
| 7871 | DEFUN (show_ipv6_bgp_prefix, |
| 7872 | show_ipv6_bgp_prefix_cmd, |
| 7873 | "show ipv6 bgp X:X::X:X/M", |
| 7874 | SHOW_STR |
| 7875 | IP_STR |
| 7876 | BGP_STR |
| 7877 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7878 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7879 | 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] | 7880 | } |
| 7881 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7882 | DEFUN (show_bgp_view, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7883 | show_bgp_view_cmd, |
| 7884 | "show bgp view WORD", |
| 7885 | SHOW_STR |
| 7886 | BGP_STR |
| 7887 | "BGP view\n" |
| 7888 | "View name\n") |
| 7889 | { |
| 7890 | struct bgp *bgp; |
| 7891 | |
| 7892 | /* BGP structure lookup. */ |
| 7893 | bgp = bgp_lookup_by_name (argv[0]); |
| 7894 | if (bgp == NULL) |
| 7895 | { |
| 7896 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7897 | return CMD_WARNING; |
| 7898 | } |
| 7899 | |
| 7900 | return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); |
| 7901 | } |
| 7902 | |
| 7903 | DEFUN (show_bgp_view_ipv6, |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7904 | show_bgp_view_ipv6_cmd, |
| 7905 | "show bgp view WORD ipv6", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7906 | SHOW_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7907 | BGP_STR |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7908 | "BGP view\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7909 | "View name\n" |
| 7910 | "Address family\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7911 | { |
| 7912 | struct bgp *bgp; |
| 7913 | |
| 7914 | /* BGP structure lookup. */ |
| 7915 | bgp = bgp_lookup_by_name (argv[0]); |
| 7916 | if (bgp == NULL) |
| 7917 | { |
| 7918 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7919 | return CMD_WARNING; |
| 7920 | } |
| 7921 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7922 | 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] | 7923 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7924 | |
| 7925 | DEFUN (show_bgp_view_route, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7926 | show_bgp_view_route_cmd, |
| 7927 | "show bgp view WORD X:X::X:X", |
| 7928 | SHOW_STR |
| 7929 | BGP_STR |
| 7930 | "BGP view\n" |
| 7931 | "View name\n" |
| 7932 | "Network in the BGP routing table to display\n") |
| 7933 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7934 | 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] | 7935 | } |
| 7936 | |
| 7937 | DEFUN (show_bgp_view_ipv6_route, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7938 | show_bgp_view_ipv6_route_cmd, |
| 7939 | "show bgp view WORD ipv6 X:X::X:X", |
| 7940 | SHOW_STR |
| 7941 | BGP_STR |
| 7942 | "BGP view\n" |
| 7943 | "View name\n" |
| 7944 | "Address family\n" |
| 7945 | "Network in the BGP routing table to display\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7946 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7947 | 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] | 7948 | } |
| 7949 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7950 | /* old command */ |
| 7951 | DEFUN (show_ipv6_mbgp, |
| 7952 | show_ipv6_mbgp_cmd, |
| 7953 | "show ipv6 mbgp", |
| 7954 | SHOW_STR |
| 7955 | IP_STR |
| 7956 | MBGP_STR) |
| 7957 | { |
| 7958 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 7959 | NULL); |
| 7960 | } |
| 7961 | |
| 7962 | /* old command */ |
| 7963 | DEFUN (show_ipv6_mbgp_route, |
| 7964 | show_ipv6_mbgp_route_cmd, |
| 7965 | "show ipv6 mbgp X:X::X:X", |
| 7966 | SHOW_STR |
| 7967 | IP_STR |
| 7968 | MBGP_STR |
| 7969 | "Network in the MBGP routing table to display\n") |
| 7970 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7971 | 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] | 7972 | } |
| 7973 | |
| 7974 | /* old command */ |
| 7975 | DEFUN (show_ipv6_mbgp_prefix, |
| 7976 | show_ipv6_mbgp_prefix_cmd, |
| 7977 | "show ipv6 mbgp X:X::X:X/M", |
| 7978 | SHOW_STR |
| 7979 | IP_STR |
| 7980 | MBGP_STR |
| 7981 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7982 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7983 | 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] | 7984 | } |
| 7985 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 7986 | DEFUN (show_bgp_view_prefix, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 7987 | show_bgp_view_prefix_cmd, |
| 7988 | "show bgp view WORD X:X::X:X/M", |
| 7989 | SHOW_STR |
| 7990 | BGP_STR |
| 7991 | "BGP view\n" |
| 7992 | "View name\n" |
| 7993 | "IPv6 prefix <network>/<length>\n") |
| 7994 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 7995 | 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] | 7996 | } |
| 7997 | |
| 7998 | DEFUN (show_bgp_view_ipv6_prefix, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7999 | show_bgp_view_ipv6_prefix_cmd, |
| 8000 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 8001 | SHOW_STR |
| 8002 | BGP_STR |
| 8003 | "BGP view\n" |
| 8004 | "View name\n" |
| 8005 | "Address family\n" |
| 8006 | "IPv6 prefix <network>/<length>\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8007 | { |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 8008 | 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] | 8009 | } |
| 8010 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8011 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8012 | 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] | 8013 | safi_t safi, enum bgp_show_type type) |
| 8014 | { |
| 8015 | int i; |
| 8016 | struct buffer *b; |
| 8017 | char *regstr; |
| 8018 | int first; |
| 8019 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8020 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8021 | |
| 8022 | first = 0; |
| 8023 | b = buffer_new (1024); |
| 8024 | for (i = 0; i < argc; i++) |
| 8025 | { |
| 8026 | if (first) |
| 8027 | buffer_putc (b, ' '); |
| 8028 | else |
| 8029 | { |
| 8030 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 8031 | continue; |
| 8032 | first = 1; |
| 8033 | } |
| 8034 | |
| 8035 | buffer_putstr (b, argv[i]); |
| 8036 | } |
| 8037 | buffer_putc (b, '\0'); |
| 8038 | |
| 8039 | regstr = buffer_getstr (b); |
| 8040 | buffer_free (b); |
| 8041 | |
| 8042 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 8043 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8044 | if (! regex) |
| 8045 | { |
| 8046 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 8047 | VTY_NEWLINE); |
| 8048 | return CMD_WARNING; |
| 8049 | } |
| 8050 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8051 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 8052 | bgp_regex_free (regex); |
| 8053 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8054 | } |
| 8055 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8056 | |
| 8057 | DEFUN (show_ip_bgp_regexp, |
| 8058 | show_ip_bgp_regexp_cmd, |
| 8059 | "show ip bgp regexp .LINE", |
| 8060 | SHOW_STR |
| 8061 | IP_STR |
| 8062 | BGP_STR |
| 8063 | "Display routes matching the AS path regular expression\n" |
| 8064 | "A regular-expression to match the BGP AS paths\n") |
| 8065 | { |
| 8066 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 8067 | bgp_show_type_regexp); |
| 8068 | } |
| 8069 | |
| 8070 | DEFUN (show_ip_bgp_flap_regexp, |
| 8071 | show_ip_bgp_flap_regexp_cmd, |
| 8072 | "show ip bgp flap-statistics regexp .LINE", |
| 8073 | SHOW_STR |
| 8074 | IP_STR |
| 8075 | BGP_STR |
| 8076 | "Display flap statistics of routes\n" |
| 8077 | "Display routes matching the AS path regular expression\n" |
| 8078 | "A regular-expression to match the BGP AS paths\n") |
| 8079 | { |
| 8080 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 8081 | bgp_show_type_flap_regexp); |
| 8082 | } |
| 8083 | |
| 8084 | ALIAS (show_ip_bgp_flap_regexp, |
| 8085 | show_ip_bgp_damp_flap_regexp_cmd, |
| 8086 | "show ip bgp dampening flap-statistics regexp .LINE", |
| 8087 | SHOW_STR |
| 8088 | IP_STR |
| 8089 | BGP_STR |
| 8090 | "Display detailed information about dampening\n" |
| 8091 | "Display flap statistics of routes\n" |
| 8092 | "Display routes matching the AS path regular expression\n" |
| 8093 | "A regular-expression to match the BGP AS paths\n") |
| 8094 | |
| 8095 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 8096 | show_ip_bgp_ipv4_regexp_cmd, |
| 8097 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 8098 | SHOW_STR |
| 8099 | IP_STR |
| 8100 | BGP_STR |
| 8101 | "Address family\n" |
| 8102 | "Address Family modifier\n" |
| 8103 | "Address Family modifier\n" |
| 8104 | "Display routes matching the AS path regular expression\n" |
| 8105 | "A regular-expression to match the BGP AS paths\n") |
| 8106 | { |
| 8107 | if (strncmp (argv[0], "m", 1) == 0) |
| 8108 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 8109 | bgp_show_type_regexp); |
| 8110 | |
| 8111 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 8112 | bgp_show_type_regexp); |
| 8113 | } |
| 8114 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8115 | DEFUN (show_bgp_regexp, |
| 8116 | show_bgp_regexp_cmd, |
| 8117 | "show bgp regexp .LINE", |
| 8118 | SHOW_STR |
| 8119 | BGP_STR |
| 8120 | "Display routes matching the AS path regular expression\n" |
| 8121 | "A regular-expression to match the BGP AS paths\n") |
| 8122 | { |
| 8123 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 8124 | bgp_show_type_regexp); |
| 8125 | } |
| 8126 | |
| 8127 | /* old command */ |
| 8128 | DEFUN (show_ipv6_bgp_regexp, |
| 8129 | show_ipv6_bgp_regexp_cmd, |
| 8130 | "show ipv6 bgp regexp .LINE", |
| 8131 | SHOW_STR |
| 8132 | IP_STR |
| 8133 | BGP_STR |
| 8134 | "Display routes matching the AS path regular expression\n" |
| 8135 | "A regular-expression to match the BGP AS paths\n") |
| 8136 | { |
| 8137 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 8138 | bgp_show_type_regexp); |
| 8139 | } |
| 8140 | |
| 8141 | /* old command */ |
| 8142 | DEFUN (show_ipv6_mbgp_regexp, |
| 8143 | show_ipv6_mbgp_regexp_cmd, |
| 8144 | "show ipv6 mbgp regexp .LINE", |
| 8145 | SHOW_STR |
| 8146 | IP_STR |
| 8147 | BGP_STR |
| 8148 | "Display routes matching the AS path regular expression\n" |
| 8149 | "A regular-expression to match the MBGP AS paths\n") |
| 8150 | { |
| 8151 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 8152 | bgp_show_type_regexp); |
| 8153 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8154 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8155 | DEFUN (show_bgp_ipv4_safi_flap_regexp, |
| 8156 | show_bgp_ipv4_safi_flap_regexp_cmd, |
| 8157 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8158 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8159 | BGP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8160 | IP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8161 | "Address Family Modifier\n" |
| 8162 | "Address Family Modifier\n" |
| 8163 | "Address Family Modifier\n" |
| 8164 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8165 | "Display flap statistics of routes\n" |
| 8166 | "Display routes matching the AS path regular expression\n" |
| 8167 | "A regular-expression to match the BGP AS paths\n") |
| 8168 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8169 | safi_t safi; |
| 8170 | |
| 8171 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8172 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 8173 | return CMD_WARNING; |
| 8174 | } |
| 8175 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi, |
| 8176 | bgp_show_type_flap_regexp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8177 | } |
| 8178 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8179 | ALIAS (show_bgp_ipv4_safi_flap_regexp, |
| 8180 | show_bgp_ipv4_safi_damp_flap_regexp_cmd, |
| 8181 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8182 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8183 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8184 | IP_STR |
| 8185 | "Address Family Modifier\n" |
| 8186 | "Address Family Modifier\n" |
| 8187 | "Address Family Modifier\n" |
| 8188 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8189 | "Display detailed information about dampening\n" |
| 8190 | "Display flap statistics of routes\n" |
| 8191 | "Display routes matching the AS path regular expression\n" |
| 8192 | "A regular-expression to match the BGP AS paths\n") |
| 8193 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8194 | DEFUN (show_bgp_ipv6_safi_flap_regexp, |
| 8195 | show_bgp_ipv6_safi_flap_regexp_cmd, |
| 8196 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8197 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8198 | BGP_STR |
| 8199 | IPV6_STR |
| 8200 | "Address Family Modifier\n" |
| 8201 | "Address Family Modifier\n" |
| 8202 | "Address Family Modifier\n" |
| 8203 | "Address Family Modifier\n" |
| 8204 | "Display flap statistics of routes\n" |
| 8205 | "Display routes matching the AS path regular expression\n" |
| 8206 | "A regular-expression to match the BGP AS paths\n") |
| 8207 | { |
| 8208 | safi_t safi; |
| 8209 | |
| 8210 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8211 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 8212 | return CMD_WARNING; |
| 8213 | } |
| 8214 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi, |
| 8215 | bgp_show_type_flap_regexp); |
| 8216 | } |
| 8217 | |
| 8218 | ALIAS (show_bgp_ipv6_safi_flap_regexp, |
| 8219 | show_bgp_ipv6_safi_damp_flap_regexp_cmd, |
| 8220 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE", |
| 8221 | SHOW_STR |
| 8222 | BGP_STR |
| 8223 | IPV6_STR |
| 8224 | "Address Family Modifier\n" |
| 8225 | "Address Family Modifier\n" |
| 8226 | "Address Family Modifier\n" |
| 8227 | "Address Family Modifier\n" |
| 8228 | "Display detailed information about dampening\n" |
| 8229 | "Display flap statistics of routes\n" |
| 8230 | "Display routes matching the AS path regular expression\n" |
| 8231 | "A regular-expression to match the BGP AS paths\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8232 | |
| 8233 | DEFUN (show_bgp_ipv4_safi_regexp, |
| 8234 | show_bgp_ipv4_safi_regexp_cmd, |
| 8235 | "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE", |
| 8236 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8237 | BGP_STR |
| 8238 | "Address family\n" |
| 8239 | "Address Family modifier\n" |
| 8240 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8241 | "Address Family modifier\n" |
| 8242 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8243 | "Display routes matching the AS path regular expression\n" |
| 8244 | "A regular-expression to match the BGP AS paths\n") |
| 8245 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8246 | safi_t safi; |
| 8247 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8248 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8249 | return CMD_WARNING; |
| 8250 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8251 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8252 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8253 | bgp_show_type_regexp); |
| 8254 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8255 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8256 | DEFUN (show_bgp_ipv6_safi_regexp, |
| 8257 | show_bgp_ipv6_safi_regexp_cmd, |
| 8258 | "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8259 | SHOW_STR |
| 8260 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8261 | "Address family\n" |
| 8262 | "Address Family modifier\n" |
| 8263 | "Address Family modifier\n" |
| 8264 | "Address Family modifier\n" |
| 8265 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8266 | "Display routes matching the AS path regular expression\n" |
| 8267 | "A regular-expression to match the BGP AS paths\n") |
| 8268 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8269 | safi_t safi; |
| 8270 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8271 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8272 | return CMD_WARNING; |
| 8273 | } |
| 8274 | |
| 8275 | return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8276 | bgp_show_type_regexp); |
| 8277 | } |
| 8278 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8279 | DEFUN (show_bgp_ipv6_regexp, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8280 | show_bgp_ipv6_regexp_cmd, |
| 8281 | "show bgp ipv6 regexp .LINE", |
| 8282 | SHOW_STR |
| 8283 | BGP_STR |
| 8284 | "Address family\n" |
| 8285 | "Display routes matching the AS path regular expression\n" |
| 8286 | "A regular-expression to match the BGP AS paths\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8287 | { |
| 8288 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 8289 | bgp_show_type_regexp); |
| 8290 | } |
| 8291 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8292 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8293 | 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] | 8294 | safi_t safi, enum bgp_show_type type) |
| 8295 | { |
| 8296 | struct prefix_list *plist; |
| 8297 | |
| 8298 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 8299 | if (plist == NULL) |
| 8300 | { |
| 8301 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 8302 | prefix_list_str, VTY_NEWLINE); |
| 8303 | return CMD_WARNING; |
| 8304 | } |
| 8305 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8306 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8307 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8308 | DEFUN (show_ip_bgp_prefix_list, |
| 8309 | show_ip_bgp_prefix_list_cmd, |
| 8310 | "show ip bgp prefix-list WORD", |
| 8311 | SHOW_STR |
| 8312 | IP_STR |
| 8313 | BGP_STR |
| 8314 | "Display routes conforming to the prefix-list\n" |
| 8315 | "IP prefix-list name\n") |
| 8316 | { |
| 8317 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8318 | bgp_show_type_prefix_list); |
| 8319 | } |
| 8320 | |
| 8321 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 8322 | show_ip_bgp_flap_prefix_list_cmd, |
| 8323 | "show ip bgp flap-statistics prefix-list WORD", |
| 8324 | SHOW_STR |
| 8325 | IP_STR |
| 8326 | BGP_STR |
| 8327 | "Display flap statistics of routes\n" |
| 8328 | "Display routes conforming to the prefix-list\n" |
| 8329 | "IP prefix-list name\n") |
| 8330 | { |
| 8331 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8332 | bgp_show_type_flap_prefix_list); |
| 8333 | } |
| 8334 | |
| 8335 | ALIAS (show_ip_bgp_flap_prefix_list, |
| 8336 | show_ip_bgp_damp_flap_prefix_list_cmd, |
| 8337 | "show ip bgp dampening flap-statistics prefix-list WORD", |
| 8338 | SHOW_STR |
| 8339 | IP_STR |
| 8340 | BGP_STR |
| 8341 | "Display detailed information about dampening\n" |
| 8342 | "Display flap statistics of routes\n" |
| 8343 | "Display routes conforming to the prefix-list\n" |
| 8344 | "IP prefix-list name\n") |
| 8345 | |
| 8346 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 8347 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 8348 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 8349 | SHOW_STR |
| 8350 | IP_STR |
| 8351 | BGP_STR |
| 8352 | "Address family\n" |
| 8353 | "Address Family modifier\n" |
| 8354 | "Address Family modifier\n" |
| 8355 | "Display routes conforming to the prefix-list\n" |
| 8356 | "IP prefix-list name\n") |
| 8357 | { |
| 8358 | if (strncmp (argv[0], "m", 1) == 0) |
| 8359 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8360 | bgp_show_type_prefix_list); |
| 8361 | |
| 8362 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8363 | bgp_show_type_prefix_list); |
| 8364 | } |
| 8365 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8366 | DEFUN (show_bgp_prefix_list, |
| 8367 | show_bgp_prefix_list_cmd, |
| 8368 | "show bgp prefix-list WORD", |
| 8369 | SHOW_STR |
| 8370 | BGP_STR |
| 8371 | "Display routes conforming to the prefix-list\n" |
| 8372 | "IPv6 prefix-list name\n") |
| 8373 | { |
| 8374 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8375 | bgp_show_type_prefix_list); |
| 8376 | } |
| 8377 | |
| 8378 | ALIAS (show_bgp_prefix_list, |
| 8379 | show_bgp_ipv6_prefix_list_cmd, |
| 8380 | "show bgp ipv6 prefix-list WORD", |
| 8381 | SHOW_STR |
| 8382 | BGP_STR |
| 8383 | "Address family\n" |
| 8384 | "Display routes conforming to the prefix-list\n" |
| 8385 | "IPv6 prefix-list name\n") |
| 8386 | |
| 8387 | /* old command */ |
| 8388 | DEFUN (show_ipv6_bgp_prefix_list, |
| 8389 | show_ipv6_bgp_prefix_list_cmd, |
| 8390 | "show ipv6 bgp prefix-list WORD", |
| 8391 | SHOW_STR |
| 8392 | IPV6_STR |
| 8393 | BGP_STR |
| 8394 | "Display routes matching the prefix-list\n" |
| 8395 | "IPv6 prefix-list name\n") |
| 8396 | { |
| 8397 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8398 | bgp_show_type_prefix_list); |
| 8399 | } |
| 8400 | |
| 8401 | /* old command */ |
| 8402 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 8403 | show_ipv6_mbgp_prefix_list_cmd, |
| 8404 | "show ipv6 mbgp prefix-list WORD", |
| 8405 | SHOW_STR |
| 8406 | IPV6_STR |
| 8407 | MBGP_STR |
| 8408 | "Display routes matching the prefix-list\n" |
| 8409 | "IPv6 prefix-list name\n") |
| 8410 | { |
| 8411 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8412 | bgp_show_type_prefix_list); |
| 8413 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8414 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8415 | DEFUN (show_bgp_ipv4_prefix_list, |
| 8416 | show_bgp_ipv4_prefix_list_cmd, |
| 8417 | "show bgp ipv4 prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8418 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8419 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame] | 8420 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8421 | "Display routes conforming to the prefix-list\n" |
| 8422 | "IP prefix-list name\n") |
| 8423 | { |
| 8424 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8425 | bgp_show_type_prefix_list); |
| 8426 | } |
| 8427 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8428 | DEFUN (show_bgp_ipv4_safi_flap_prefix_list, |
| 8429 | show_bgp_ipv4_safi_flap_prefix_list_cmd, |
| 8430 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8431 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8432 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8433 | IP_STR |
| 8434 | "Address Family Modifier\n" |
| 8435 | "Address Family Modifier\n" |
| 8436 | "Address Family Modifier\n" |
| 8437 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8438 | "Display flap statistics of routes\n" |
| 8439 | "Display routes conforming to the prefix-list\n" |
| 8440 | "IP prefix-list name\n") |
| 8441 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8442 | safi_t safi; |
| 8443 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8444 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8445 | return CMD_WARNING; |
| 8446 | } |
| 8447 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8448 | bgp_show_type_flap_prefix_list); |
| 8449 | } |
| 8450 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8451 | ALIAS (show_bgp_ipv4_safi_flap_prefix_list, |
| 8452 | show_bgp_ipv4_safi_damp_flap_prefix_list_cmd, |
| 8453 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8454 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8455 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8456 | IP_STR |
| 8457 | "Address Family Modifier\n" |
| 8458 | "Address Family Modifier\n" |
| 8459 | "Address Family Modifier\n" |
| 8460 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8461 | "Display detailed information about dampening\n" |
| 8462 | "Display flap statistics of routes\n" |
| 8463 | "Display routes conforming to the prefix-list\n" |
| 8464 | "IP prefix-list name\n") |
| 8465 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8466 | DEFUN (show_bgp_ipv6_safi_flap_prefix_list, |
| 8467 | show_bgp_ipv6_safi_flap_prefix_list_cmd, |
| 8468 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8469 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8470 | BGP_STR |
| 8471 | IPV6_STR |
| 8472 | "Address Family Modifier\n" |
| 8473 | "Address Family Modifier\n" |
| 8474 | "Address Family Modifier\n" |
| 8475 | "Address Family Modifier\n" |
| 8476 | "Display flap statistics of routes\n" |
| 8477 | "Display routes conforming to the prefix-list\n" |
| 8478 | "IP prefix-list name\n") |
| 8479 | { |
| 8480 | safi_t safi; |
| 8481 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8482 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8483 | return CMD_WARNING; |
| 8484 | } |
| 8485 | return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi, |
| 8486 | bgp_show_type_flap_prefix_list); |
| 8487 | } |
| 8488 | ALIAS (show_bgp_ipv6_safi_flap_prefix_list, |
| 8489 | show_bgp_ipv6_safi_damp_flap_prefix_list_cmd, |
| 8490 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD", |
| 8491 | SHOW_STR |
| 8492 | BGP_STR |
| 8493 | IPV6_STR |
| 8494 | "Address Family Modifier\n" |
| 8495 | "Address Family Modifier\n" |
| 8496 | "Address Family Modifier\n" |
| 8497 | "Address Family Modifier\n" |
| 8498 | "Display detailed information about dampening\n" |
| 8499 | "Display flap statistics of routes\n" |
| 8500 | "Display routes conforming to the prefix-list\n" |
| 8501 | "IP prefix-list name\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8502 | |
| 8503 | DEFUN (show_bgp_ipv4_safi_prefix_list, |
| 8504 | show_bgp_ipv4_safi_prefix_list_cmd, |
| 8505 | "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD", |
| 8506 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8507 | BGP_STR |
| 8508 | "Address family\n" |
| 8509 | "Address Family modifier\n" |
| 8510 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8511 | "Address Family modifier\n" |
| 8512 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8513 | "Display routes conforming to the prefix-list\n" |
| 8514 | "IP prefix-list name\n") |
| 8515 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8516 | safi_t safi; |
| 8517 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8518 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8519 | return CMD_WARNING; |
| 8520 | } |
| 8521 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8522 | bgp_show_type_prefix_list); |
| 8523 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8524 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8525 | DEFUN (show_bgp_ipv6_safi_prefix_list, |
| 8526 | show_bgp_ipv6_safi_prefix_list_cmd, |
| 8527 | "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8528 | SHOW_STR |
| 8529 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8530 | "Address family\n" |
| 8531 | "Address Family modifier\n" |
| 8532 | "Address Family modifier\n" |
| 8533 | "Address Family modifier\n" |
| 8534 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8535 | "Display routes conforming to the prefix-list\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8536 | "IP prefix-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8537 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8538 | safi_t safi; |
| 8539 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8540 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8541 | return CMD_WARNING; |
| 8542 | } |
| 8543 | return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8544 | bgp_show_type_prefix_list); |
| 8545 | } |
| 8546 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8547 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8548 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8549 | safi_t safi, enum bgp_show_type type) |
| 8550 | { |
| 8551 | struct as_list *as_list; |
| 8552 | |
| 8553 | as_list = as_list_lookup (filter); |
| 8554 | if (as_list == NULL) |
| 8555 | { |
| 8556 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 8557 | return CMD_WARNING; |
| 8558 | } |
| 8559 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8560 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8561 | } |
| 8562 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8563 | DEFUN (show_ip_bgp_filter_list, |
| 8564 | show_ip_bgp_filter_list_cmd, |
| 8565 | "show ip bgp filter-list WORD", |
| 8566 | SHOW_STR |
| 8567 | IP_STR |
| 8568 | BGP_STR |
| 8569 | "Display routes conforming to the filter-list\n" |
| 8570 | "Regular expression access list name\n") |
| 8571 | { |
| 8572 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8573 | bgp_show_type_filter_list); |
| 8574 | } |
| 8575 | |
| 8576 | DEFUN (show_ip_bgp_flap_filter_list, |
| 8577 | show_ip_bgp_flap_filter_list_cmd, |
| 8578 | "show ip bgp flap-statistics filter-list WORD", |
| 8579 | SHOW_STR |
| 8580 | IP_STR |
| 8581 | BGP_STR |
| 8582 | "Display flap statistics of routes\n" |
| 8583 | "Display routes conforming to the filter-list\n" |
| 8584 | "Regular expression access list name\n") |
| 8585 | { |
| 8586 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8587 | bgp_show_type_flap_filter_list); |
| 8588 | } |
| 8589 | |
| 8590 | ALIAS (show_ip_bgp_flap_filter_list, |
| 8591 | show_ip_bgp_damp_flap_filter_list_cmd, |
| 8592 | "show ip bgp dampening flap-statistics filter-list WORD", |
| 8593 | SHOW_STR |
| 8594 | IP_STR |
| 8595 | BGP_STR |
| 8596 | "Display detailed information about dampening\n" |
| 8597 | "Display flap statistics of routes\n" |
| 8598 | "Display routes conforming to the filter-list\n" |
| 8599 | "Regular expression access list name\n") |
| 8600 | |
| 8601 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 8602 | show_ip_bgp_ipv4_filter_list_cmd, |
| 8603 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 8604 | SHOW_STR |
| 8605 | IP_STR |
| 8606 | BGP_STR |
| 8607 | "Address family\n" |
| 8608 | "Address Family modifier\n" |
| 8609 | "Address Family modifier\n" |
| 8610 | "Display routes conforming to the filter-list\n" |
| 8611 | "Regular expression access list name\n") |
| 8612 | { |
| 8613 | if (strncmp (argv[0], "m", 1) == 0) |
| 8614 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8615 | bgp_show_type_filter_list); |
| 8616 | |
| 8617 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8618 | bgp_show_type_filter_list); |
| 8619 | } |
| 8620 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8621 | DEFUN (show_bgp_filter_list, |
| 8622 | show_bgp_filter_list_cmd, |
| 8623 | "show bgp filter-list WORD", |
| 8624 | SHOW_STR |
| 8625 | BGP_STR |
| 8626 | "Display routes conforming to the filter-list\n" |
| 8627 | "Regular expression access list name\n") |
| 8628 | { |
| 8629 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8630 | bgp_show_type_filter_list); |
| 8631 | } |
| 8632 | |
| 8633 | /* old command */ |
| 8634 | DEFUN (show_ipv6_bgp_filter_list, |
| 8635 | show_ipv6_bgp_filter_list_cmd, |
| 8636 | "show ipv6 bgp filter-list WORD", |
| 8637 | SHOW_STR |
| 8638 | IPV6_STR |
| 8639 | BGP_STR |
| 8640 | "Display routes conforming to the filter-list\n" |
| 8641 | "Regular expression access list name\n") |
| 8642 | { |
| 8643 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8644 | bgp_show_type_filter_list); |
| 8645 | } |
| 8646 | |
| 8647 | /* old command */ |
| 8648 | DEFUN (show_ipv6_mbgp_filter_list, |
| 8649 | show_ipv6_mbgp_filter_list_cmd, |
| 8650 | "show ipv6 mbgp filter-list WORD", |
| 8651 | SHOW_STR |
| 8652 | IPV6_STR |
| 8653 | MBGP_STR |
| 8654 | "Display routes conforming to the filter-list\n" |
| 8655 | "Regular expression access list name\n") |
| 8656 | { |
| 8657 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8658 | bgp_show_type_filter_list); |
| 8659 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8660 | |
| 8661 | DEFUN (show_ip_bgp_dampening_info, |
| 8662 | show_ip_bgp_dampening_params_cmd, |
| 8663 | "show ip bgp dampening parameters", |
| 8664 | SHOW_STR |
| 8665 | IP_STR |
| 8666 | BGP_STR |
| 8667 | "Display detailed information about dampening\n" |
| 8668 | "Display detail of configured dampening parameters\n") |
| 8669 | { |
| 8670 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); |
| 8671 | } |
| 8672 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8673 | DEFUN (show_bgp_ipv4_filter_list, |
| 8674 | show_bgp_ipv4_filter_list_cmd, |
| 8675 | "show bgp ipv4 filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8676 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8677 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8678 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8679 | "Display routes conforming to the filter-list\n" |
| 8680 | "Regular expression access list name\n") |
| 8681 | { |
| 8682 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8683 | bgp_show_type_filter_list); |
| 8684 | } |
| 8685 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8686 | DEFUN (show_bgp_ipv4_safi_flap_filter_list, |
| 8687 | show_bgp_ipv4_safi_flap_filter_list_cmd, |
| 8688 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8689 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8690 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8691 | IP_STR |
| 8692 | "Address Family modifier\n" |
| 8693 | "Address Family modifier\n" |
| 8694 | "Address Family modifier\n" |
| 8695 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8696 | "Display flap statistics of routes\n" |
| 8697 | "Display routes conforming to the filter-list\n" |
| 8698 | "Regular expression access list name\n") |
| 8699 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8700 | safi_t safi; |
| 8701 | |
| 8702 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8703 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8704 | return CMD_WARNING; |
| 8705 | } |
| 8706 | return bgp_show_filter_list (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8707 | bgp_show_type_flap_filter_list); |
| 8708 | } |
| 8709 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8710 | ALIAS (show_bgp_ipv4_safi_flap_filter_list, |
| 8711 | show_bgp_ipv4_safi_damp_flap_filter_list_cmd, |
| 8712 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8713 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8714 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8715 | IP_STR |
| 8716 | "Address Family modifier\n" |
| 8717 | "Address Family modifier\n" |
| 8718 | "Address Family modifier\n" |
| 8719 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 8720 | "Display detailed information about dampening\n" |
| 8721 | "Display flap statistics of routes\n" |
| 8722 | "Display routes conforming to the filter-list\n" |
| 8723 | "Regular expression access list name\n") |
| 8724 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8725 | DEFUN (show_bgp_ipv6_safi_flap_filter_list, |
| 8726 | show_bgp_ipv6_safi_flap_filter_list_cmd, |
| 8727 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8728 | SHOW_STR |
| 8729 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8730 | IPV6_STR |
| 8731 | "Address Family modifier\n" |
| 8732 | "Address Family modifier\n" |
| 8733 | "Address Family modifier\n" |
| 8734 | "Address Family modifier\n" |
| 8735 | "Display flap statistics of routes\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8736 | "Display routes conforming to the filter-list\n" |
| 8737 | "Regular expression access list name\n") |
| 8738 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8739 | safi_t safi; |
| 8740 | |
| 8741 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8742 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8743 | return CMD_WARNING; |
| 8744 | } |
| 8745 | return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi, |
| 8746 | bgp_show_type_flap_filter_list); |
| 8747 | } |
| 8748 | ALIAS (show_bgp_ipv6_safi_flap_filter_list, |
| 8749 | show_bgp_ipv6_safi_damp_flap_filter_list_cmd, |
| 8750 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD", |
| 8751 | SHOW_STR |
| 8752 | BGP_STR |
| 8753 | IPV6_STR |
| 8754 | "Address Family modifier\n" |
| 8755 | "Address Family modifier\n" |
| 8756 | "Address Family modifier\n" |
| 8757 | "Address Family modifier\n" |
| 8758 | "Display detailed information about dampening\n" |
| 8759 | "Display flap statistics of routes\n" |
| 8760 | "Display routes conforming to the filter-list\n" |
| 8761 | "Regular expression access list name\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8762 | |
| 8763 | DEFUN (show_bgp_ipv4_safi_filter_list, |
| 8764 | show_bgp_ipv4_safi_filter_list_cmd, |
| 8765 | "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD", |
| 8766 | SHOW_STR |
| 8767 | BGP_STR |
| 8768 | "Address Family modifier\n" |
| 8769 | "Address Family modifier\n" |
| 8770 | "Address Family modifier\n" |
| 8771 | "Address Family modifier\n" |
| 8772 | "Display routes conforming to the filter-list\n" |
| 8773 | "Regular expression access list name\n") |
| 8774 | { |
| 8775 | safi_t safi; |
| 8776 | |
| 8777 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8778 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8779 | return CMD_WARNING; |
| 8780 | } |
| 8781 | return bgp_show_filter_list (vty, argv[1], AFI_IP, safi, |
| 8782 | bgp_show_type_filter_list); |
| 8783 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 8784 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 8785 | DEFUN (show_bgp_ipv6_safi_filter_list, |
| 8786 | show_bgp_ipv6_safi_filter_list_cmd, |
| 8787 | "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD", |
| 8788 | SHOW_STR |
| 8789 | BGP_STR |
| 8790 | "Address Family modifier\n" |
| 8791 | "Address Family modifier\n" |
| 8792 | "Address Family modifier\n" |
| 8793 | "Address Family modifier\n" |
| 8794 | "Display routes conforming to the filter-list\n" |
| 8795 | "Regular expression access list name\n") |
| 8796 | { |
| 8797 | safi_t safi; |
| 8798 | |
| 8799 | if (bgp_parse_safi(argv[0], &safi)) { |
| 8800 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 8801 | return CMD_WARNING; |
| 8802 | } |
| 8803 | return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi, |
| 8804 | bgp_show_type_filter_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8805 | } |
| 8806 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8807 | DEFUN (show_bgp_ipv6_filter_list, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8808 | show_bgp_ipv6_filter_list_cmd, |
| 8809 | "show bgp ipv6 filter-list WORD", |
| 8810 | SHOW_STR |
| 8811 | BGP_STR |
| 8812 | "Address family\n" |
| 8813 | "Display routes conforming to the filter-list\n" |
| 8814 | "Regular expression access list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8815 | { |
| 8816 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8817 | bgp_show_type_filter_list); |
| 8818 | } |
| 8819 | |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 8820 | |
| 8821 | DEFUN (show_ip_bgp_ipv4_dampening_parameters, |
| 8822 | show_ip_bgp_ipv4_dampening_parameters_cmd, |
| 8823 | "show ip bgp ipv4 (unicast|multicast) dampening parameters", |
| 8824 | SHOW_STR |
| 8825 | IP_STR |
| 8826 | BGP_STR |
| 8827 | "Address family\n" |
| 8828 | "Address Family modifier\n" |
| 8829 | "Address Family modifier\n" |
| 8830 | "Display detailed information about dampening\n" |
| 8831 | "Display detail of configured dampening parameters\n") |
| 8832 | { |
| 8833 | if (strncmp(argv[0], "m", 1) == 0) |
| 8834 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST); |
| 8835 | |
| 8836 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); |
| 8837 | } |
| 8838 | |
| 8839 | |
| 8840 | DEFUN (show_ip_bgp_ipv4_dampening_flap_stats, |
| 8841 | show_ip_bgp_ipv4_dampening_flap_stats_cmd, |
| 8842 | "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics", |
| 8843 | SHOW_STR |
| 8844 | IP_STR |
| 8845 | BGP_STR |
| 8846 | "Address family\n" |
| 8847 | "Address Family modifier\n" |
| 8848 | "Address Family modifier\n" |
| 8849 | "Display detailed information about dampening\n" |
| 8850 | "Display flap statistics of routes\n") |
| 8851 | { |
| 8852 | if (strncmp(argv[0], "m", 1) == 0) |
| 8853 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8854 | bgp_show_type_flap_statistics, NULL); |
| 8855 | |
| 8856 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8857 | bgp_show_type_flap_statistics, NULL); |
| 8858 | } |
| 8859 | |
| 8860 | DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths, |
| 8861 | show_ip_bgp_ipv4_dampening_dampd_paths_cmd, |
| 8862 | "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths", |
| 8863 | SHOW_STR |
| 8864 | IP_STR |
| 8865 | BGP_STR |
| 8866 | "Address family\n" |
| 8867 | "Address Family modifier\n" |
| 8868 | "Address Family modifier\n" |
| 8869 | "Display detailed information about dampening\n" |
| 8870 | "Display paths suppressed due to dampening\n") |
| 8871 | { |
| 8872 | if (strncmp(argv[0], "m", 1) == 0) |
| 8873 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8874 | bgp_show_type_dampend_paths, NULL); |
| 8875 | |
| 8876 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 8877 | bgp_show_type_dampend_paths, NULL); |
| 8878 | } |
| 8879 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8880 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8881 | 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] | 8882 | safi_t safi, enum bgp_show_type type) |
| 8883 | { |
| 8884 | struct route_map *rmap; |
| 8885 | |
| 8886 | rmap = route_map_lookup_by_name (rmap_str); |
| 8887 | if (! rmap) |
| 8888 | { |
| 8889 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 8890 | rmap_str, VTY_NEWLINE); |
| 8891 | return CMD_WARNING; |
| 8892 | } |
| 8893 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8894 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8895 | } |
| 8896 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 8897 | DEFUN (show_ip_bgp_route_map, |
| 8898 | show_ip_bgp_route_map_cmd, |
| 8899 | "show ip bgp route-map WORD", |
| 8900 | SHOW_STR |
| 8901 | IP_STR |
| 8902 | BGP_STR |
| 8903 | "Display routes matching the route-map\n" |
| 8904 | "A route-map to match on\n") |
| 8905 | { |
| 8906 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8907 | bgp_show_type_route_map); |
| 8908 | } |
| 8909 | |
| 8910 | DEFUN (show_ip_bgp_flap_route_map, |
| 8911 | show_ip_bgp_flap_route_map_cmd, |
| 8912 | "show ip bgp flap-statistics route-map WORD", |
| 8913 | SHOW_STR |
| 8914 | IP_STR |
| 8915 | BGP_STR |
| 8916 | "Display flap statistics of routes\n" |
| 8917 | "Display routes matching the route-map\n" |
| 8918 | "A route-map to match on\n") |
| 8919 | { |
| 8920 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8921 | bgp_show_type_flap_route_map); |
| 8922 | } |
| 8923 | |
| 8924 | ALIAS (show_ip_bgp_flap_route_map, |
| 8925 | show_ip_bgp_damp_flap_route_map_cmd, |
| 8926 | "show ip bgp dampening flap-statistics route-map WORD", |
| 8927 | SHOW_STR |
| 8928 | IP_STR |
| 8929 | BGP_STR |
| 8930 | "Display detailed information about dampening\n" |
| 8931 | "Display flap statistics of routes\n" |
| 8932 | "Display routes matching the route-map\n" |
| 8933 | "A route-map to match on\n") |
| 8934 | |
| 8935 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 8936 | show_ip_bgp_ipv4_route_map_cmd, |
| 8937 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 8938 | SHOW_STR |
| 8939 | IP_STR |
| 8940 | BGP_STR |
| 8941 | "Address family\n" |
| 8942 | "Address Family modifier\n" |
| 8943 | "Address Family modifier\n" |
| 8944 | "Display routes matching the route-map\n" |
| 8945 | "A route-map to match on\n") |
| 8946 | { |
| 8947 | if (strncmp (argv[0], "m", 1) == 0) |
| 8948 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8949 | bgp_show_type_route_map); |
| 8950 | |
| 8951 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8952 | bgp_show_type_route_map); |
| 8953 | } |
| 8954 | |
| 8955 | DEFUN (show_bgp_route_map, |
| 8956 | show_bgp_route_map_cmd, |
| 8957 | "show bgp route-map WORD", |
| 8958 | SHOW_STR |
| 8959 | BGP_STR |
| 8960 | "Display routes matching the route-map\n" |
| 8961 | "A route-map to match on\n") |
| 8962 | { |
| 8963 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8964 | bgp_show_type_route_map); |
| 8965 | } |
| 8966 | |
| 8967 | DEFUN (show_ip_bgp_cidr_only, |
| 8968 | show_ip_bgp_cidr_only_cmd, |
| 8969 | "show ip bgp cidr-only", |
| 8970 | SHOW_STR |
| 8971 | IP_STR |
| 8972 | BGP_STR |
| 8973 | "Display only routes with non-natural netmasks\n") |
| 8974 | { |
| 8975 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 8976 | bgp_show_type_cidr_only, NULL); |
| 8977 | } |
| 8978 | |
| 8979 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 8980 | show_ip_bgp_flap_cidr_only_cmd, |
| 8981 | "show ip bgp flap-statistics cidr-only", |
| 8982 | SHOW_STR |
| 8983 | IP_STR |
| 8984 | BGP_STR |
| 8985 | "Display flap statistics of routes\n" |
| 8986 | "Display only routes with non-natural netmasks\n") |
| 8987 | { |
| 8988 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 8989 | bgp_show_type_flap_cidr_only, NULL); |
| 8990 | } |
| 8991 | |
| 8992 | ALIAS (show_ip_bgp_flap_cidr_only, |
| 8993 | show_ip_bgp_damp_flap_cidr_only_cmd, |
| 8994 | "show ip bgp dampening flap-statistics cidr-only", |
| 8995 | SHOW_STR |
| 8996 | IP_STR |
| 8997 | BGP_STR |
| 8998 | "Display detailed information about dampening\n" |
| 8999 | "Display flap statistics of routes\n" |
| 9000 | "Display only routes with non-natural netmasks\n") |
| 9001 | |
| 9002 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 9003 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 9004 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 9005 | SHOW_STR |
| 9006 | IP_STR |
| 9007 | BGP_STR |
| 9008 | "Address family\n" |
| 9009 | "Address Family modifier\n" |
| 9010 | "Address Family modifier\n" |
| 9011 | "Display only routes with non-natural netmasks\n") |
| 9012 | { |
| 9013 | if (strncmp (argv[0], "m", 1) == 0) |
| 9014 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 9015 | bgp_show_type_cidr_only, NULL); |
| 9016 | |
| 9017 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 9018 | bgp_show_type_cidr_only, NULL); |
| 9019 | } |
| 9020 | |
| 9021 | DEFUN (show_ip_bgp_community_all, |
| 9022 | show_ip_bgp_community_all_cmd, |
| 9023 | "show ip bgp community", |
| 9024 | SHOW_STR |
| 9025 | IP_STR |
| 9026 | BGP_STR |
| 9027 | "Display routes matching the communities\n") |
| 9028 | { |
| 9029 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 9030 | bgp_show_type_community_all, NULL); |
| 9031 | } |
| 9032 | |
| 9033 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 9034 | show_ip_bgp_ipv4_community_all_cmd, |
| 9035 | "show ip bgp ipv4 (unicast|multicast) community", |
| 9036 | SHOW_STR |
| 9037 | IP_STR |
| 9038 | BGP_STR |
| 9039 | "Address family\n" |
| 9040 | "Address Family modifier\n" |
| 9041 | "Address Family modifier\n" |
| 9042 | "Display routes matching the communities\n") |
| 9043 | { |
| 9044 | if (strncmp (argv[0], "m", 1) == 0) |
| 9045 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
| 9046 | bgp_show_type_community_all, NULL); |
| 9047 | |
| 9048 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 9049 | bgp_show_type_community_all, NULL); |
| 9050 | } |
| 9051 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9052 | DEFUN (show_bgp_community_all, |
| 9053 | show_bgp_community_all_cmd, |
| 9054 | "show bgp community", |
| 9055 | SHOW_STR |
| 9056 | BGP_STR |
| 9057 | "Display routes matching the communities\n") |
| 9058 | { |
| 9059 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
| 9060 | bgp_show_type_community_all, NULL); |
| 9061 | } |
| 9062 | |
| 9063 | ALIAS (show_bgp_community_all, |
| 9064 | show_bgp_ipv6_community_all_cmd, |
| 9065 | "show bgp ipv6 community", |
| 9066 | SHOW_STR |
| 9067 | BGP_STR |
| 9068 | "Address family\n" |
| 9069 | "Display routes matching the communities\n") |
| 9070 | |
| 9071 | /* old command */ |
| 9072 | DEFUN (show_ipv6_bgp_community_all, |
| 9073 | show_ipv6_bgp_community_all_cmd, |
| 9074 | "show ipv6 bgp community", |
| 9075 | SHOW_STR |
| 9076 | IPV6_STR |
| 9077 | BGP_STR |
| 9078 | "Display routes matching the communities\n") |
| 9079 | { |
| 9080 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
| 9081 | bgp_show_type_community_all, NULL); |
| 9082 | } |
| 9083 | |
| 9084 | /* old command */ |
| 9085 | DEFUN (show_ipv6_mbgp_community_all, |
| 9086 | show_ipv6_mbgp_community_all_cmd, |
| 9087 | "show ipv6 mbgp community", |
| 9088 | SHOW_STR |
| 9089 | IPV6_STR |
| 9090 | MBGP_STR |
| 9091 | "Display routes matching the communities\n") |
| 9092 | { |
| 9093 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
| 9094 | bgp_show_type_community_all, NULL); |
| 9095 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9096 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9097 | DEFUN (show_bgp_ipv4_route_map, |
| 9098 | show_bgp_ipv4_route_map_cmd, |
| 9099 | "show bgp ipv4 route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9100 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9101 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9102 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9103 | "Display routes matching the route-map\n" |
| 9104 | "A route-map to match on\n") |
| 9105 | { |
| 9106 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9107 | bgp_show_type_route_map); |
| 9108 | } |
| 9109 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9110 | DEFUN (show_bgp_ipv4_safi_flap_route_map, |
| 9111 | show_bgp_ipv4_safi_flap_route_map_cmd, |
| 9112 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9113 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9114 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9115 | IP_STR |
| 9116 | "Address Family Modifier\n" |
| 9117 | "Address Family Modifier\n" |
| 9118 | "Address Family Modifier\n" |
| 9119 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9120 | "Display flap statistics of routes\n" |
| 9121 | "Display routes matching the route-map\n" |
| 9122 | "A route-map to match on\n") |
| 9123 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9124 | safi_t safi; |
| 9125 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9126 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9127 | return CMD_WARNING; |
| 9128 | } |
| 9129 | return bgp_show_route_map (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9130 | bgp_show_type_flap_route_map); |
| 9131 | } |
| 9132 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9133 | ALIAS (show_bgp_ipv4_safi_flap_route_map, |
| 9134 | show_bgp_ipv4_safi_damp_flap_route_map_cmd, |
| 9135 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9136 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9137 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9138 | IP_STR |
| 9139 | "Address Family Modifier\n" |
| 9140 | "Address Family Modifier\n" |
| 9141 | "Address Family Modifier\n" |
| 9142 | "Address Family Modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9143 | "Display detailed information about dampening\n" |
| 9144 | "Display flap statistics of routes\n" |
| 9145 | "Display routes matching the route-map\n" |
| 9146 | "A route-map to match on\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 9147 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9148 | DEFUN (show_bgp_ipv6_safi_flap_route_map, |
| 9149 | show_bgp_ipv6_safi_flap_route_map_cmd, |
| 9150 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9151 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9152 | BGP_STR |
| 9153 | IPV6_STR |
| 9154 | "Address Family Modifier\n" |
| 9155 | "Address Family Modifier\n" |
| 9156 | "Address Family Modifier\n" |
| 9157 | "Address Family Modifier\n" |
| 9158 | "Display flap statistics of routes\n" |
| 9159 | "Display routes matching the route-map\n" |
| 9160 | "A route-map to match on\n") |
| 9161 | { |
| 9162 | safi_t safi; |
| 9163 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9164 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9165 | return CMD_WARNING; |
| 9166 | } |
| 9167 | return bgp_show_route_map (vty, argv[1], AFI_IP6, safi, |
| 9168 | bgp_show_type_flap_route_map); |
| 9169 | } |
| 9170 | ALIAS (show_bgp_ipv6_safi_flap_route_map, |
| 9171 | show_bgp_ipv6_safi_damp_flap_route_map_cmd, |
| 9172 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD", |
| 9173 | SHOW_STR |
| 9174 | BGP_STR |
| 9175 | IPV6_STR |
| 9176 | "Address Family Modifier\n" |
| 9177 | "Address Family Modifier\n" |
| 9178 | "Address Family Modifier\n" |
| 9179 | "Address Family Modifier\n" |
| 9180 | "Display detailed information about dampening\n" |
| 9181 | "Display flap statistics of routes\n" |
| 9182 | "Display routes matching the route-map\n" |
| 9183 | "A route-map to match on\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9184 | |
| 9185 | DEFUN (show_bgp_ipv4_safi_route_map, |
| 9186 | show_bgp_ipv4_safi_route_map_cmd, |
| 9187 | "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD", |
| 9188 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9189 | BGP_STR |
| 9190 | "Address family\n" |
| 9191 | "Address Family modifier\n" |
| 9192 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9193 | "Address Family modifier\n" |
| 9194 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9195 | "Display routes matching the route-map\n" |
| 9196 | "A route-map to match on\n") |
| 9197 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9198 | safi_t safi; |
| 9199 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9200 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9201 | return CMD_WARNING; |
| 9202 | } |
| 9203 | return bgp_show_route_map (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9204 | bgp_show_type_route_map); |
| 9205 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 9206 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9207 | DEFUN (show_bgp_ipv6_safi_route_map, |
| 9208 | show_bgp_ipv6_safi_route_map_cmd, |
| 9209 | "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9210 | SHOW_STR |
| 9211 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9212 | "Address family\n" |
| 9213 | "Address Family modifier\n" |
| 9214 | "Address Family modifier\n" |
| 9215 | "Address Family modifier\n" |
| 9216 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9217 | "Display routes matching the route-map\n" |
| 9218 | "A route-map to match on\n") |
| 9219 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9220 | safi_t safi; |
| 9221 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9222 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9223 | return CMD_WARNING; |
| 9224 | } |
| 9225 | return bgp_show_route_map (vty, argv[1], AFI_IP6, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9226 | bgp_show_type_route_map); |
| 9227 | } |
| 9228 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9229 | DEFUN (show_bgp_ipv6_route_map, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9230 | show_bgp_ipv6_route_map_cmd, |
| 9231 | "show bgp ipv6 route-map WORD", |
| 9232 | SHOW_STR |
| 9233 | BGP_STR |
| 9234 | "Address family\n" |
| 9235 | "Display routes matching the route-map\n" |
| 9236 | "A route-map to match on\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9237 | { |
| 9238 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9239 | bgp_show_type_route_map); |
| 9240 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9241 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9242 | DEFUN (show_bgp_ipv4_cidr_only, |
| 9243 | show_bgp_ipv4_cidr_only_cmd, |
| 9244 | "show bgp ipv4 cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9245 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9246 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9247 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9248 | "Display only routes with non-natural netmasks\n") |
| 9249 | { |
| 9250 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9251 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9252 | } |
| 9253 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9254 | DEFUN (show_bgp_ipv4_safi_flap_cidr_only, |
| 9255 | show_bgp_ipv4_safi_flap_cidr_only_cmd, |
| 9256 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9257 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9258 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9259 | "Address Family\n" |
| 9260 | "Address Family Modifier\n" |
| 9261 | "Address Family Modifier\n" |
| 9262 | "Address Family Modifier\n" |
| 9263 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9264 | "Display flap statistics of routes\n" |
| 9265 | "Display only routes with non-natural netmasks\n") |
| 9266 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9267 | safi_t safi; |
| 9268 | |
| 9269 | if (bgp_parse_safi(argv[0], &safi)) { |
| 9270 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 9271 | return CMD_WARNING; |
| 9272 | } |
| 9273 | 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] | 9274 | } |
| 9275 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9276 | ALIAS (show_bgp_ipv4_safi_flap_cidr_only, |
| 9277 | show_bgp_ipv4_safi_damp_flap_cidr_only_cmd, |
| 9278 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9279 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 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" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9286 | "Display detailed information about dampening\n" |
| 9287 | "Display flap statistics of routes\n" |
| 9288 | "Display only routes with non-natural netmasks\n") |
| 9289 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9290 | DEFUN (show_bgp_ipv4_safi_cidr_only, |
| 9291 | show_bgp_ipv4_safi_cidr_only_cmd, |
| 9292 | "show bgp ipv4 (unicast|multicast) cidr-only", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9293 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9294 | BGP_STR |
| 9295 | "Address family\n" |
| 9296 | "Address Family modifier\n" |
| 9297 | "Address Family modifier\n" |
| 9298 | "Display only routes with non-natural netmasks\n") |
| 9299 | { |
| 9300 | if (strncmp (argv[0], "m", 1) == 0) |
| 9301 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9302 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9303 | |
| 9304 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9305 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9306 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9307 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9308 | /* new046 */ |
| 9309 | DEFUN (show_bgp_afi_safi_community_all, |
| 9310 | show_bgp_afi_safi_community_all_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9311 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9312 | SHOW_STR |
| 9313 | BGP_STR |
| 9314 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9315 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9316 | "Address Family modifier\n" |
| 9317 | "Address Family modifier\n" |
| 9318 | "Address Family modifier\n" |
| 9319 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9320 | "Display routes matching the communities\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9321 | { |
| 9322 | safi_t safi; |
| 9323 | afi_t afi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9324 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9325 | if (bgp_parse_afi(argv[0], &afi)) { |
| 9326 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 9327 | return CMD_WARNING; |
| 9328 | } |
| 9329 | if (bgp_parse_safi(argv[1], &safi)) { |
| 9330 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 9331 | return CMD_WARNING; |
| 9332 | } |
| 9333 | |
| 9334 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL); |
| 9335 | } |
| 9336 | DEFUN (show_bgp_afi_community_all, |
| 9337 | show_bgp_afi_community_all_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9338 | "show bgp (ipv4|ipv6) community", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9339 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9340 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9341 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9342 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9343 | "Display routes matching the communities\n") |
| 9344 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9345 | afi_t afi; |
| 9346 | safi_t safi = SAFI_UNICAST; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9347 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 9348 | if (bgp_parse_afi(argv[0], &afi)) { |
| 9349 | vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE); |
| 9350 | return CMD_WARNING; |
| 9351 | } |
| 9352 | return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9353 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9354 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9355 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9356 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 9357 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9358 | { |
| 9359 | struct community *com; |
| 9360 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9361 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9362 | int i; |
| 9363 | char *str; |
| 9364 | int first = 0; |
| 9365 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9366 | /* BGP structure lookup */ |
| 9367 | if (view_name) |
| 9368 | { |
| 9369 | bgp = bgp_lookup_by_name (view_name); |
| 9370 | if (bgp == NULL) |
| 9371 | { |
| 9372 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9373 | return CMD_WARNING; |
| 9374 | } |
| 9375 | } |
| 9376 | else |
| 9377 | { |
| 9378 | bgp = bgp_get_default (); |
| 9379 | if (bgp == NULL) |
| 9380 | { |
| 9381 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9382 | return CMD_WARNING; |
| 9383 | } |
| 9384 | } |
| 9385 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9386 | b = buffer_new (1024); |
| 9387 | for (i = 0; i < argc; i++) |
| 9388 | { |
| 9389 | if (first) |
| 9390 | buffer_putc (b, ' '); |
| 9391 | else |
| 9392 | { |
| 9393 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 9394 | continue; |
| 9395 | first = 1; |
| 9396 | } |
| 9397 | |
| 9398 | buffer_putstr (b, argv[i]); |
| 9399 | } |
| 9400 | buffer_putc (b, '\0'); |
| 9401 | |
| 9402 | str = buffer_getstr (b); |
| 9403 | buffer_free (b); |
| 9404 | |
| 9405 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 9406 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9407 | if (! com) |
| 9408 | { |
| 9409 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 9410 | return CMD_WARNING; |
| 9411 | } |
| 9412 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9413 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9414 | (exact ? bgp_show_type_community_exact : |
| 9415 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9416 | } |
| 9417 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9418 | DEFUN (show_ip_bgp_community, |
| 9419 | show_ip_bgp_community_cmd, |
| 9420 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9421 | SHOW_STR |
| 9422 | IP_STR |
| 9423 | BGP_STR |
| 9424 | "Display routes matching the communities\n" |
| 9425 | "community number\n" |
| 9426 | "Do not send outside local AS (well-known community)\n" |
| 9427 | "Do not advertise to any peer (well-known community)\n" |
| 9428 | "Do not export to next AS (well-known community)\n") |
| 9429 | { |
| 9430 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 9431 | } |
| 9432 | |
| 9433 | ALIAS (show_ip_bgp_community, |
| 9434 | show_ip_bgp_community2_cmd, |
| 9435 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9436 | SHOW_STR |
| 9437 | IP_STR |
| 9438 | BGP_STR |
| 9439 | "Display routes matching the communities\n" |
| 9440 | "community number\n" |
| 9441 | "Do not send outside local AS (well-known community)\n" |
| 9442 | "Do not advertise to any peer (well-known community)\n" |
| 9443 | "Do not export to next AS (well-known community)\n" |
| 9444 | "community number\n" |
| 9445 | "Do not send outside local AS (well-known community)\n" |
| 9446 | "Do not advertise to any peer (well-known community)\n" |
| 9447 | "Do not export to next AS (well-known community)\n") |
| 9448 | |
| 9449 | ALIAS (show_ip_bgp_community, |
| 9450 | show_ip_bgp_community3_cmd, |
| 9451 | "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)", |
| 9452 | SHOW_STR |
| 9453 | IP_STR |
| 9454 | BGP_STR |
| 9455 | "Display routes matching the communities\n" |
| 9456 | "community number\n" |
| 9457 | "Do not send outside local AS (well-known community)\n" |
| 9458 | "Do not advertise to any peer (well-known community)\n" |
| 9459 | "Do not export to next AS (well-known community)\n" |
| 9460 | "community number\n" |
| 9461 | "Do not send outside local AS (well-known community)\n" |
| 9462 | "Do not advertise to any peer (well-known community)\n" |
| 9463 | "Do not export to next AS (well-known community)\n" |
| 9464 | "community number\n" |
| 9465 | "Do not send outside local AS (well-known community)\n" |
| 9466 | "Do not advertise to any peer (well-known community)\n" |
| 9467 | "Do not export to next AS (well-known community)\n") |
| 9468 | |
| 9469 | ALIAS (show_ip_bgp_community, |
| 9470 | show_ip_bgp_community4_cmd, |
| 9471 | "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)", |
| 9472 | SHOW_STR |
| 9473 | IP_STR |
| 9474 | BGP_STR |
| 9475 | "Display routes matching the communities\n" |
| 9476 | "community number\n" |
| 9477 | "Do not send outside local AS (well-known community)\n" |
| 9478 | "Do not advertise to any peer (well-known community)\n" |
| 9479 | "Do not export to next AS (well-known community)\n" |
| 9480 | "community number\n" |
| 9481 | "Do not send outside local AS (well-known community)\n" |
| 9482 | "Do not advertise to any peer (well-known community)\n" |
| 9483 | "Do not export to next AS (well-known community)\n" |
| 9484 | "community number\n" |
| 9485 | "Do not send outside local AS (well-known community)\n" |
| 9486 | "Do not advertise to any peer (well-known community)\n" |
| 9487 | "Do not export to next AS (well-known community)\n" |
| 9488 | "community number\n" |
| 9489 | "Do not send outside local AS (well-known community)\n" |
| 9490 | "Do not advertise to any peer (well-known community)\n" |
| 9491 | "Do not export to next AS (well-known community)\n") |
| 9492 | |
| 9493 | DEFUN (show_ip_bgp_ipv4_community, |
| 9494 | show_ip_bgp_ipv4_community_cmd, |
| 9495 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 9496 | SHOW_STR |
| 9497 | IP_STR |
| 9498 | BGP_STR |
| 9499 | "Address family\n" |
| 9500 | "Address Family modifier\n" |
| 9501 | "Address Family modifier\n" |
| 9502 | "Display routes matching the communities\n" |
| 9503 | "community number\n" |
| 9504 | "Do not send outside local AS (well-known community)\n" |
| 9505 | "Do not advertise to any peer (well-known community)\n" |
| 9506 | "Do not export to next AS (well-known community)\n") |
| 9507 | { |
| 9508 | if (strncmp (argv[0], "m", 1) == 0) |
| 9509 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 9510 | |
| 9511 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 9512 | } |
| 9513 | |
| 9514 | ALIAS (show_ip_bgp_ipv4_community, |
| 9515 | show_ip_bgp_ipv4_community2_cmd, |
| 9516 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9517 | SHOW_STR |
| 9518 | IP_STR |
| 9519 | BGP_STR |
| 9520 | "Address family\n" |
| 9521 | "Address Family modifier\n" |
| 9522 | "Address Family modifier\n" |
| 9523 | "Display routes matching the communities\n" |
| 9524 | "community number\n" |
| 9525 | "Do not send outside local AS (well-known community)\n" |
| 9526 | "Do not advertise to any peer (well-known community)\n" |
| 9527 | "Do not export to next AS (well-known community)\n" |
| 9528 | "community number\n" |
| 9529 | "Do not send outside local AS (well-known community)\n" |
| 9530 | "Do not advertise to any peer (well-known community)\n" |
| 9531 | "Do not export to next AS (well-known community)\n") |
| 9532 | |
| 9533 | ALIAS (show_ip_bgp_ipv4_community, |
| 9534 | show_ip_bgp_ipv4_community3_cmd, |
| 9535 | "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)", |
| 9536 | SHOW_STR |
| 9537 | IP_STR |
| 9538 | BGP_STR |
| 9539 | "Address family\n" |
| 9540 | "Address Family modifier\n" |
| 9541 | "Address Family modifier\n" |
| 9542 | "Display routes matching the communities\n" |
| 9543 | "community number\n" |
| 9544 | "Do not send outside local AS (well-known community)\n" |
| 9545 | "Do not advertise to any peer (well-known community)\n" |
| 9546 | "Do not export to next AS (well-known community)\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 | |
| 9556 | ALIAS (show_ip_bgp_ipv4_community, |
| 9557 | show_ip_bgp_ipv4_community4_cmd, |
| 9558 | "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)", |
| 9559 | SHOW_STR |
| 9560 | IP_STR |
| 9561 | BGP_STR |
| 9562 | "Address family\n" |
| 9563 | "Address Family modifier\n" |
| 9564 | "Address Family modifier\n" |
| 9565 | "Display routes matching the communities\n" |
| 9566 | "community number\n" |
| 9567 | "Do not send outside local AS (well-known community)\n" |
| 9568 | "Do not advertise to any peer (well-known community)\n" |
| 9569 | "Do not export to next AS (well-known community)\n" |
| 9570 | "community number\n" |
| 9571 | "Do not send outside local AS (well-known community)\n" |
| 9572 | "Do not advertise to any peer (well-known community)\n" |
| 9573 | "Do not export to next AS (well-known community)\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 | "community number\n" |
| 9579 | "Do not send outside local AS (well-known community)\n" |
| 9580 | "Do not advertise to any peer (well-known community)\n" |
| 9581 | "Do not export to next AS (well-known community)\n") |
| 9582 | |
| 9583 | DEFUN (show_ip_bgp_community_exact, |
| 9584 | show_ip_bgp_community_exact_cmd, |
| 9585 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9586 | SHOW_STR |
| 9587 | IP_STR |
| 9588 | BGP_STR |
| 9589 | "Display routes matching the communities\n" |
| 9590 | "community number\n" |
| 9591 | "Do not send outside local AS (well-known community)\n" |
| 9592 | "Do not advertise to any peer (well-known community)\n" |
| 9593 | "Do not export to next AS (well-known community)\n" |
| 9594 | "Exact match of the communities") |
| 9595 | { |
| 9596 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 9597 | } |
| 9598 | |
| 9599 | ALIAS (show_ip_bgp_community_exact, |
| 9600 | show_ip_bgp_community2_exact_cmd, |
| 9601 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9602 | SHOW_STR |
| 9603 | IP_STR |
| 9604 | BGP_STR |
| 9605 | "Display routes matching the communities\n" |
| 9606 | "community number\n" |
| 9607 | "Do not send outside local AS (well-known community)\n" |
| 9608 | "Do not advertise to any peer (well-known community)\n" |
| 9609 | "Do not export to next AS (well-known community)\n" |
| 9610 | "community number\n" |
| 9611 | "Do not send outside local AS (well-known community)\n" |
| 9612 | "Do not advertise to any peer (well-known community)\n" |
| 9613 | "Do not export to next AS (well-known community)\n" |
| 9614 | "Exact match of the communities") |
| 9615 | |
| 9616 | ALIAS (show_ip_bgp_community_exact, |
| 9617 | show_ip_bgp_community3_exact_cmd, |
| 9618 | "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", |
| 9619 | SHOW_STR |
| 9620 | IP_STR |
| 9621 | BGP_STR |
| 9622 | "Display routes matching the communities\n" |
| 9623 | "community number\n" |
| 9624 | "Do not send outside local AS (well-known community)\n" |
| 9625 | "Do not advertise to any peer (well-known community)\n" |
| 9626 | "Do not export to next AS (well-known community)\n" |
| 9627 | "community number\n" |
| 9628 | "Do not send outside local AS (well-known community)\n" |
| 9629 | "Do not advertise to any peer (well-known community)\n" |
| 9630 | "Do not export to next AS (well-known community)\n" |
| 9631 | "community number\n" |
| 9632 | "Do not send outside local AS (well-known community)\n" |
| 9633 | "Do not advertise to any peer (well-known community)\n" |
| 9634 | "Do not export to next AS (well-known community)\n" |
| 9635 | "Exact match of the communities") |
| 9636 | |
| 9637 | ALIAS (show_ip_bgp_community_exact, |
| 9638 | show_ip_bgp_community4_exact_cmd, |
| 9639 | "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", |
| 9640 | SHOW_STR |
| 9641 | IP_STR |
| 9642 | BGP_STR |
| 9643 | "Display routes matching the communities\n" |
| 9644 | "community number\n" |
| 9645 | "Do not send outside local AS (well-known community)\n" |
| 9646 | "Do not advertise to any peer (well-known community)\n" |
| 9647 | "Do not export to next AS (well-known community)\n" |
| 9648 | "community number\n" |
| 9649 | "Do not send outside local AS (well-known community)\n" |
| 9650 | "Do not advertise to any peer (well-known community)\n" |
| 9651 | "Do not export to next AS (well-known community)\n" |
| 9652 | "community number\n" |
| 9653 | "Do not send outside local AS (well-known community)\n" |
| 9654 | "Do not advertise to any peer (well-known community)\n" |
| 9655 | "Do not export to next AS (well-known community)\n" |
| 9656 | "community number\n" |
| 9657 | "Do not send outside local AS (well-known community)\n" |
| 9658 | "Do not advertise to any peer (well-known community)\n" |
| 9659 | "Do not export to next AS (well-known community)\n" |
| 9660 | "Exact match of the communities") |
| 9661 | |
| 9662 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 9663 | show_ip_bgp_ipv4_community_exact_cmd, |
| 9664 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9665 | SHOW_STR |
| 9666 | IP_STR |
| 9667 | BGP_STR |
| 9668 | "Address family\n" |
| 9669 | "Address Family modifier\n" |
| 9670 | "Address Family modifier\n" |
| 9671 | "Display routes matching the communities\n" |
| 9672 | "community number\n" |
| 9673 | "Do not send outside local AS (well-known community)\n" |
| 9674 | "Do not advertise to any peer (well-known community)\n" |
| 9675 | "Do not export to next AS (well-known community)\n" |
| 9676 | "Exact match of the communities") |
| 9677 | { |
| 9678 | if (strncmp (argv[0], "m", 1) == 0) |
| 9679 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 9680 | |
| 9681 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 9682 | } |
| 9683 | |
| 9684 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9685 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 9686 | "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", |
| 9687 | SHOW_STR |
| 9688 | IP_STR |
| 9689 | BGP_STR |
| 9690 | "Address family\n" |
| 9691 | "Address Family modifier\n" |
| 9692 | "Address Family modifier\n" |
| 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 | "Exact match of the communities") |
| 9703 | |
| 9704 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9705 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 9706 | "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", |
| 9707 | SHOW_STR |
| 9708 | IP_STR |
| 9709 | BGP_STR |
| 9710 | "Address family\n" |
| 9711 | "Address Family modifier\n" |
| 9712 | "Address Family modifier\n" |
| 9713 | "Display routes matching the communities\n" |
| 9714 | "community number\n" |
| 9715 | "Do not send outside local AS (well-known community)\n" |
| 9716 | "Do not advertise to any peer (well-known community)\n" |
| 9717 | "Do not export to next AS (well-known community)\n" |
| 9718 | "community number\n" |
| 9719 | "Do not send outside local AS (well-known community)\n" |
| 9720 | "Do not advertise to any peer (well-known community)\n" |
| 9721 | "Do not export to next AS (well-known community)\n" |
| 9722 | "community number\n" |
| 9723 | "Do not send outside local AS (well-known community)\n" |
| 9724 | "Do not advertise to any peer (well-known community)\n" |
| 9725 | "Do not export to next AS (well-known community)\n" |
| 9726 | "Exact match of the communities") |
| 9727 | |
| 9728 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 9729 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 9730 | "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", |
| 9731 | SHOW_STR |
| 9732 | IP_STR |
| 9733 | BGP_STR |
| 9734 | "Address family\n" |
| 9735 | "Address Family modifier\n" |
| 9736 | "Address Family modifier\n" |
| 9737 | "Display routes matching the communities\n" |
| 9738 | "community number\n" |
| 9739 | "Do not send outside local AS (well-known community)\n" |
| 9740 | "Do not advertise to any peer (well-known community)\n" |
| 9741 | "Do not export to next AS (well-known community)\n" |
| 9742 | "community number\n" |
| 9743 | "Do not send outside local AS (well-known community)\n" |
| 9744 | "Do not advertise to any peer (well-known community)\n" |
| 9745 | "Do not export to next AS (well-known community)\n" |
| 9746 | "community number\n" |
| 9747 | "Do not send outside local AS (well-known community)\n" |
| 9748 | "Do not advertise to any peer (well-known community)\n" |
| 9749 | "Do not export to next AS (well-known community)\n" |
| 9750 | "community number\n" |
| 9751 | "Do not send outside local AS (well-known community)\n" |
| 9752 | "Do not advertise to any peer (well-known community)\n" |
| 9753 | "Do not export to next AS (well-known community)\n" |
| 9754 | "Exact match of the communities") |
| 9755 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 9756 | DEFUN (show_bgp_community, |
| 9757 | show_bgp_community_cmd, |
| 9758 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9759 | SHOW_STR |
| 9760 | BGP_STR |
| 9761 | "Display routes matching the communities\n" |
| 9762 | "community number\n" |
| 9763 | "Do not send outside local AS (well-known community)\n" |
| 9764 | "Do not advertise to any peer (well-known community)\n" |
| 9765 | "Do not export to next AS (well-known community)\n") |
| 9766 | { |
| 9767 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 9768 | } |
| 9769 | |
| 9770 | ALIAS (show_bgp_community, |
| 9771 | show_bgp_ipv6_community_cmd, |
| 9772 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 9773 | SHOW_STR |
| 9774 | BGP_STR |
| 9775 | "Address family\n" |
| 9776 | "Display routes matching the communities\n" |
| 9777 | "community number\n" |
| 9778 | "Do not send outside local AS (well-known community)\n" |
| 9779 | "Do not advertise to any peer (well-known community)\n" |
| 9780 | "Do not export to next AS (well-known community)\n") |
| 9781 | |
| 9782 | ALIAS (show_bgp_community, |
| 9783 | show_bgp_community2_cmd, |
| 9784 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9785 | SHOW_STR |
| 9786 | BGP_STR |
| 9787 | "Display routes matching the communities\n" |
| 9788 | "community number\n" |
| 9789 | "Do not send outside local AS (well-known community)\n" |
| 9790 | "Do not advertise to any peer (well-known community)\n" |
| 9791 | "Do not export to next AS (well-known community)\n" |
| 9792 | "community number\n" |
| 9793 | "Do not send outside local AS (well-known community)\n" |
| 9794 | "Do not advertise to any peer (well-known community)\n" |
| 9795 | "Do not export to next AS (well-known community)\n") |
| 9796 | |
| 9797 | ALIAS (show_bgp_community, |
| 9798 | show_bgp_ipv6_community2_cmd, |
| 9799 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9800 | SHOW_STR |
| 9801 | BGP_STR |
| 9802 | "Address family\n" |
| 9803 | "Display routes matching the communities\n" |
| 9804 | "community number\n" |
| 9805 | "Do not send outside local AS (well-known community)\n" |
| 9806 | "Do not advertise to any peer (well-known community)\n" |
| 9807 | "Do not export to next AS (well-known community)\n" |
| 9808 | "community number\n" |
| 9809 | "Do not send outside local AS (well-known community)\n" |
| 9810 | "Do not advertise to any peer (well-known community)\n" |
| 9811 | "Do not export to next AS (well-known community)\n") |
| 9812 | |
| 9813 | ALIAS (show_bgp_community, |
| 9814 | show_bgp_community3_cmd, |
| 9815 | "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)", |
| 9816 | SHOW_STR |
| 9817 | BGP_STR |
| 9818 | "Display routes matching the communities\n" |
| 9819 | "community number\n" |
| 9820 | "Do not send outside local AS (well-known community)\n" |
| 9821 | "Do not advertise to any peer (well-known community)\n" |
| 9822 | "Do not export to next AS (well-known community)\n" |
| 9823 | "community number\n" |
| 9824 | "Do not send outside local AS (well-known community)\n" |
| 9825 | "Do not advertise to any peer (well-known community)\n" |
| 9826 | "Do not export to next AS (well-known community)\n" |
| 9827 | "community number\n" |
| 9828 | "Do not send outside local AS (well-known community)\n" |
| 9829 | "Do not advertise to any peer (well-known community)\n" |
| 9830 | "Do not export to next AS (well-known community)\n") |
| 9831 | |
| 9832 | ALIAS (show_bgp_community, |
| 9833 | show_bgp_ipv6_community3_cmd, |
| 9834 | "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)", |
| 9835 | SHOW_STR |
| 9836 | BGP_STR |
| 9837 | "Address family\n" |
| 9838 | "Display routes matching the communities\n" |
| 9839 | "community number\n" |
| 9840 | "Do not send outside local AS (well-known community)\n" |
| 9841 | "Do not advertise to any peer (well-known community)\n" |
| 9842 | "Do not export to next AS (well-known community)\n" |
| 9843 | "community number\n" |
| 9844 | "Do not send outside local AS (well-known community)\n" |
| 9845 | "Do not advertise to any peer (well-known community)\n" |
| 9846 | "Do not export to next AS (well-known community)\n" |
| 9847 | "community number\n" |
| 9848 | "Do not send outside local AS (well-known community)\n" |
| 9849 | "Do not advertise to any peer (well-known community)\n" |
| 9850 | "Do not export to next AS (well-known community)\n") |
| 9851 | |
| 9852 | ALIAS (show_bgp_community, |
| 9853 | show_bgp_community4_cmd, |
| 9854 | "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)", |
| 9855 | SHOW_STR |
| 9856 | BGP_STR |
| 9857 | "Display routes matching the communities\n" |
| 9858 | "community number\n" |
| 9859 | "Do not send outside local AS (well-known community)\n" |
| 9860 | "Do not advertise to any peer (well-known community)\n" |
| 9861 | "Do not export to next AS (well-known community)\n" |
| 9862 | "community number\n" |
| 9863 | "Do not send outside local AS (well-known community)\n" |
| 9864 | "Do not advertise to any peer (well-known community)\n" |
| 9865 | "Do not export to next AS (well-known community)\n" |
| 9866 | "community number\n" |
| 9867 | "Do not send outside local AS (well-known community)\n" |
| 9868 | "Do not advertise to any peer (well-known community)\n" |
| 9869 | "Do not export to next AS (well-known community)\n" |
| 9870 | "community number\n" |
| 9871 | "Do not send outside local AS (well-known community)\n" |
| 9872 | "Do not advertise to any peer (well-known community)\n" |
| 9873 | "Do not export to next AS (well-known community)\n") |
| 9874 | |
| 9875 | ALIAS (show_bgp_community, |
| 9876 | show_bgp_ipv6_community4_cmd, |
| 9877 | "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)", |
| 9878 | SHOW_STR |
| 9879 | BGP_STR |
| 9880 | "Address family\n" |
| 9881 | "Display routes matching the communities\n" |
| 9882 | "community number\n" |
| 9883 | "Do not send outside local AS (well-known community)\n" |
| 9884 | "Do not advertise to any peer (well-known community)\n" |
| 9885 | "Do not export to next AS (well-known community)\n" |
| 9886 | "community number\n" |
| 9887 | "Do not send outside local AS (well-known community)\n" |
| 9888 | "Do not advertise to any peer (well-known community)\n" |
| 9889 | "Do not export to next AS (well-known community)\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 | |
| 9899 | /* old command */ |
| 9900 | DEFUN (show_ipv6_bgp_community, |
| 9901 | show_ipv6_bgp_community_cmd, |
| 9902 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 9903 | SHOW_STR |
| 9904 | IPV6_STR |
| 9905 | BGP_STR |
| 9906 | "Display routes matching the communities\n" |
| 9907 | "community number\n" |
| 9908 | "Do not send outside local AS (well-known community)\n" |
| 9909 | "Do not advertise to any peer (well-known community)\n" |
| 9910 | "Do not export to next AS (well-known community)\n") |
| 9911 | { |
| 9912 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 9913 | } |
| 9914 | |
| 9915 | /* old command */ |
| 9916 | ALIAS (show_ipv6_bgp_community, |
| 9917 | show_ipv6_bgp_community2_cmd, |
| 9918 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 9919 | SHOW_STR |
| 9920 | IPV6_STR |
| 9921 | BGP_STR |
| 9922 | "Display routes matching the communities\n" |
| 9923 | "community number\n" |
| 9924 | "Do not send outside local AS (well-known community)\n" |
| 9925 | "Do not advertise to any peer (well-known community)\n" |
| 9926 | "Do not export to next AS (well-known community)\n" |
| 9927 | "community number\n" |
| 9928 | "Do not send outside local AS (well-known community)\n" |
| 9929 | "Do not advertise to any peer (well-known community)\n" |
| 9930 | "Do not export to next AS (well-known community)\n") |
| 9931 | |
| 9932 | /* old command */ |
| 9933 | ALIAS (show_ipv6_bgp_community, |
| 9934 | show_ipv6_bgp_community3_cmd, |
| 9935 | "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)", |
| 9936 | SHOW_STR |
| 9937 | IPV6_STR |
| 9938 | BGP_STR |
| 9939 | "Display routes matching the communities\n" |
| 9940 | "community number\n" |
| 9941 | "Do not send outside local AS (well-known community)\n" |
| 9942 | "Do not advertise to any peer (well-known community)\n" |
| 9943 | "Do not export to next AS (well-known community)\n" |
| 9944 | "community number\n" |
| 9945 | "Do not send outside local AS (well-known community)\n" |
| 9946 | "Do not advertise to any peer (well-known community)\n" |
| 9947 | "Do not export to next AS (well-known community)\n" |
| 9948 | "community number\n" |
| 9949 | "Do not send outside local AS (well-known community)\n" |
| 9950 | "Do not advertise to any peer (well-known community)\n" |
| 9951 | "Do not export to next AS (well-known community)\n") |
| 9952 | |
| 9953 | /* old command */ |
| 9954 | ALIAS (show_ipv6_bgp_community, |
| 9955 | show_ipv6_bgp_community4_cmd, |
| 9956 | "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)", |
| 9957 | SHOW_STR |
| 9958 | IPV6_STR |
| 9959 | BGP_STR |
| 9960 | "Display routes matching the communities\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 | "community number\n" |
| 9970 | "Do not send outside local AS (well-known community)\n" |
| 9971 | "Do not advertise to any peer (well-known community)\n" |
| 9972 | "Do not export to next AS (well-known community)\n" |
| 9973 | "community number\n" |
| 9974 | "Do not send outside local AS (well-known community)\n" |
| 9975 | "Do not advertise to any peer (well-known community)\n" |
| 9976 | "Do not export to next AS (well-known community)\n") |
| 9977 | |
| 9978 | DEFUN (show_bgp_community_exact, |
| 9979 | show_bgp_community_exact_cmd, |
| 9980 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9981 | SHOW_STR |
| 9982 | BGP_STR |
| 9983 | "Display routes matching the communities\n" |
| 9984 | "community number\n" |
| 9985 | "Do not send outside local AS (well-known community)\n" |
| 9986 | "Do not advertise to any peer (well-known community)\n" |
| 9987 | "Do not export to next AS (well-known community)\n" |
| 9988 | "Exact match of the communities") |
| 9989 | { |
| 9990 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 9991 | } |
| 9992 | |
| 9993 | ALIAS (show_bgp_community_exact, |
| 9994 | show_bgp_ipv6_community_exact_cmd, |
| 9995 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9996 | SHOW_STR |
| 9997 | BGP_STR |
| 9998 | "Address family\n" |
| 9999 | "Display routes matching the communities\n" |
| 10000 | "community number\n" |
| 10001 | "Do not send outside local AS (well-known community)\n" |
| 10002 | "Do not advertise to any peer (well-known community)\n" |
| 10003 | "Do not export to next AS (well-known community)\n" |
| 10004 | "Exact match of the communities") |
| 10005 | |
| 10006 | ALIAS (show_bgp_community_exact, |
| 10007 | show_bgp_community2_exact_cmd, |
| 10008 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10009 | SHOW_STR |
| 10010 | BGP_STR |
| 10011 | "Display routes matching the communities\n" |
| 10012 | "community number\n" |
| 10013 | "Do not send outside local AS (well-known community)\n" |
| 10014 | "Do not advertise to any peer (well-known community)\n" |
| 10015 | "Do not export to next AS (well-known community)\n" |
| 10016 | "community number\n" |
| 10017 | "Do not send outside local AS (well-known community)\n" |
| 10018 | "Do not advertise to any peer (well-known community)\n" |
| 10019 | "Do not export to next AS (well-known community)\n" |
| 10020 | "Exact match of the communities") |
| 10021 | |
| 10022 | ALIAS (show_bgp_community_exact, |
| 10023 | show_bgp_ipv6_community2_exact_cmd, |
| 10024 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10025 | SHOW_STR |
| 10026 | BGP_STR |
| 10027 | "Address family\n" |
| 10028 | "Display routes matching the communities\n" |
| 10029 | "community number\n" |
| 10030 | "Do not send outside local AS (well-known community)\n" |
| 10031 | "Do not advertise to any peer (well-known community)\n" |
| 10032 | "Do not export to next AS (well-known community)\n" |
| 10033 | "community number\n" |
| 10034 | "Do not send outside local AS (well-known community)\n" |
| 10035 | "Do not advertise to any peer (well-known community)\n" |
| 10036 | "Do not export to next AS (well-known community)\n" |
| 10037 | "Exact match of the communities") |
| 10038 | |
| 10039 | ALIAS (show_bgp_community_exact, |
| 10040 | show_bgp_community3_exact_cmd, |
| 10041 | "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", |
| 10042 | SHOW_STR |
| 10043 | BGP_STR |
| 10044 | "Display routes matching the communities\n" |
| 10045 | "community number\n" |
| 10046 | "Do not send outside local AS (well-known community)\n" |
| 10047 | "Do not advertise to any peer (well-known community)\n" |
| 10048 | "Do not export to next AS (well-known community)\n" |
| 10049 | "community number\n" |
| 10050 | "Do not send outside local AS (well-known community)\n" |
| 10051 | "Do not advertise to any peer (well-known community)\n" |
| 10052 | "Do not export to next AS (well-known community)\n" |
| 10053 | "community number\n" |
| 10054 | "Do not send outside local AS (well-known community)\n" |
| 10055 | "Do not advertise to any peer (well-known community)\n" |
| 10056 | "Do not export to next AS (well-known community)\n" |
| 10057 | "Exact match of the communities") |
| 10058 | |
| 10059 | ALIAS (show_bgp_community_exact, |
| 10060 | show_bgp_ipv6_community3_exact_cmd, |
| 10061 | "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", |
| 10062 | SHOW_STR |
| 10063 | BGP_STR |
| 10064 | "Address family\n" |
| 10065 | "Display routes matching the communities\n" |
| 10066 | "community number\n" |
| 10067 | "Do not send outside local AS (well-known community)\n" |
| 10068 | "Do not advertise to any peer (well-known community)\n" |
| 10069 | "Do not export to next AS (well-known community)\n" |
| 10070 | "community number\n" |
| 10071 | "Do not send outside local AS (well-known community)\n" |
| 10072 | "Do not advertise to any peer (well-known community)\n" |
| 10073 | "Do not export to next AS (well-known community)\n" |
| 10074 | "community number\n" |
| 10075 | "Do not send outside local AS (well-known community)\n" |
| 10076 | "Do not advertise to any peer (well-known community)\n" |
| 10077 | "Do not export to next AS (well-known community)\n" |
| 10078 | "Exact match of the communities") |
| 10079 | |
| 10080 | ALIAS (show_bgp_community_exact, |
| 10081 | show_bgp_community4_exact_cmd, |
| 10082 | "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", |
| 10083 | SHOW_STR |
| 10084 | BGP_STR |
| 10085 | "Display routes matching the communities\n" |
| 10086 | "community number\n" |
| 10087 | "Do not send outside local AS (well-known community)\n" |
| 10088 | "Do not advertise to any peer (well-known community)\n" |
| 10089 | "Do not export to next AS (well-known community)\n" |
| 10090 | "community number\n" |
| 10091 | "Do not send outside local AS (well-known community)\n" |
| 10092 | "Do not advertise to any peer (well-known community)\n" |
| 10093 | "Do not export to next AS (well-known community)\n" |
| 10094 | "community number\n" |
| 10095 | "Do not send outside local AS (well-known community)\n" |
| 10096 | "Do not advertise to any peer (well-known community)\n" |
| 10097 | "Do not export to next AS (well-known community)\n" |
| 10098 | "community number\n" |
| 10099 | "Do not send outside local AS (well-known community)\n" |
| 10100 | "Do not advertise to any peer (well-known community)\n" |
| 10101 | "Do not export to next AS (well-known community)\n" |
| 10102 | "Exact match of the communities") |
| 10103 | |
| 10104 | ALIAS (show_bgp_community_exact, |
| 10105 | show_bgp_ipv6_community4_exact_cmd, |
| 10106 | "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", |
| 10107 | SHOW_STR |
| 10108 | BGP_STR |
| 10109 | "Address family\n" |
| 10110 | "Display routes matching the communities\n" |
| 10111 | "community number\n" |
| 10112 | "Do not send outside local AS (well-known community)\n" |
| 10113 | "Do not advertise to any peer (well-known community)\n" |
| 10114 | "Do not export to next AS (well-known community)\n" |
| 10115 | "community number\n" |
| 10116 | "Do not send outside local AS (well-known community)\n" |
| 10117 | "Do not advertise to any peer (well-known community)\n" |
| 10118 | "Do not export to next AS (well-known community)\n" |
| 10119 | "community number\n" |
| 10120 | "Do not send outside local AS (well-known community)\n" |
| 10121 | "Do not advertise to any peer (well-known community)\n" |
| 10122 | "Do not export to next AS (well-known community)\n" |
| 10123 | "community number\n" |
| 10124 | "Do not send outside local AS (well-known community)\n" |
| 10125 | "Do not advertise to any peer (well-known community)\n" |
| 10126 | "Do not export to next AS (well-known community)\n" |
| 10127 | "Exact match of the communities") |
| 10128 | |
| 10129 | /* old command */ |
| 10130 | DEFUN (show_ipv6_bgp_community_exact, |
| 10131 | show_ipv6_bgp_community_exact_cmd, |
| 10132 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10133 | SHOW_STR |
| 10134 | IPV6_STR |
| 10135 | BGP_STR |
| 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 | "Exact match of the communities") |
| 10142 | { |
| 10143 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 10144 | } |
| 10145 | |
| 10146 | /* old command */ |
| 10147 | ALIAS (show_ipv6_bgp_community_exact, |
| 10148 | show_ipv6_bgp_community2_exact_cmd, |
| 10149 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10150 | SHOW_STR |
| 10151 | IPV6_STR |
| 10152 | BGP_STR |
| 10153 | "Display routes matching the communities\n" |
| 10154 | "community number\n" |
| 10155 | "Do not send outside local AS (well-known community)\n" |
| 10156 | "Do not advertise to any peer (well-known community)\n" |
| 10157 | "Do not export to next AS (well-known community)\n" |
| 10158 | "community number\n" |
| 10159 | "Do not send outside local AS (well-known community)\n" |
| 10160 | "Do not advertise to any peer (well-known community)\n" |
| 10161 | "Do not export to next AS (well-known community)\n" |
| 10162 | "Exact match of the communities") |
| 10163 | |
| 10164 | /* old command */ |
| 10165 | ALIAS (show_ipv6_bgp_community_exact, |
| 10166 | show_ipv6_bgp_community3_exact_cmd, |
| 10167 | "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", |
| 10168 | SHOW_STR |
| 10169 | IPV6_STR |
| 10170 | BGP_STR |
| 10171 | "Display routes matching the communities\n" |
| 10172 | "community number\n" |
| 10173 | "Do not send outside local AS (well-known community)\n" |
| 10174 | "Do not advertise to any peer (well-known community)\n" |
| 10175 | "Do not export to next AS (well-known community)\n" |
| 10176 | "community number\n" |
| 10177 | "Do not send outside local AS (well-known community)\n" |
| 10178 | "Do not advertise to any peer (well-known community)\n" |
| 10179 | "Do not export to next AS (well-known community)\n" |
| 10180 | "community number\n" |
| 10181 | "Do not send outside local AS (well-known community)\n" |
| 10182 | "Do not advertise to any peer (well-known community)\n" |
| 10183 | "Do not export to next AS (well-known community)\n" |
| 10184 | "Exact match of the communities") |
| 10185 | |
| 10186 | /* old command */ |
| 10187 | ALIAS (show_ipv6_bgp_community_exact, |
| 10188 | show_ipv6_bgp_community4_exact_cmd, |
| 10189 | "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", |
| 10190 | SHOW_STR |
| 10191 | IPV6_STR |
| 10192 | BGP_STR |
| 10193 | "Display routes matching the communities\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 | "community number\n" |
| 10199 | "Do not send outside local AS (well-known community)\n" |
| 10200 | "Do not advertise to any peer (well-known community)\n" |
| 10201 | "Do not export to next AS (well-known community)\n" |
| 10202 | "community number\n" |
| 10203 | "Do not send outside local AS (well-known community)\n" |
| 10204 | "Do not advertise to any peer (well-known community)\n" |
| 10205 | "Do not export to next AS (well-known community)\n" |
| 10206 | "community number\n" |
| 10207 | "Do not send outside local AS (well-known community)\n" |
| 10208 | "Do not advertise to any peer (well-known community)\n" |
| 10209 | "Do not export to next AS (well-known community)\n" |
| 10210 | "Exact match of the communities") |
| 10211 | |
| 10212 | /* old command */ |
| 10213 | DEFUN (show_ipv6_mbgp_community, |
| 10214 | show_ipv6_mbgp_community_cmd, |
| 10215 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 10216 | SHOW_STR |
| 10217 | IPV6_STR |
| 10218 | MBGP_STR |
| 10219 | "Display routes matching the communities\n" |
| 10220 | "community number\n" |
| 10221 | "Do not send outside local AS (well-known community)\n" |
| 10222 | "Do not advertise to any peer (well-known community)\n" |
| 10223 | "Do not export to next AS (well-known community)\n") |
| 10224 | { |
| 10225 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 10226 | } |
| 10227 | |
| 10228 | /* old command */ |
| 10229 | ALIAS (show_ipv6_mbgp_community, |
| 10230 | show_ipv6_mbgp_community2_cmd, |
| 10231 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 10232 | SHOW_STR |
| 10233 | IPV6_STR |
| 10234 | MBGP_STR |
| 10235 | "Display routes matching the communities\n" |
| 10236 | "community number\n" |
| 10237 | "Do not send outside local AS (well-known community)\n" |
| 10238 | "Do not advertise to any peer (well-known community)\n" |
| 10239 | "Do not export to next AS (well-known community)\n" |
| 10240 | "community number\n" |
| 10241 | "Do not send outside local AS (well-known community)\n" |
| 10242 | "Do not advertise to any peer (well-known community)\n" |
| 10243 | "Do not export to next AS (well-known community)\n") |
| 10244 | |
| 10245 | /* old command */ |
| 10246 | ALIAS (show_ipv6_mbgp_community, |
| 10247 | show_ipv6_mbgp_community3_cmd, |
| 10248 | "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)", |
| 10249 | SHOW_STR |
| 10250 | IPV6_STR |
| 10251 | MBGP_STR |
| 10252 | "Display routes matching the communities\n" |
| 10253 | "community number\n" |
| 10254 | "Do not send outside local AS (well-known community)\n" |
| 10255 | "Do not advertise to any peer (well-known community)\n" |
| 10256 | "Do not export to next AS (well-known community)\n" |
| 10257 | "community number\n" |
| 10258 | "Do not send outside local AS (well-known community)\n" |
| 10259 | "Do not advertise to any peer (well-known community)\n" |
| 10260 | "Do not export to next AS (well-known community)\n" |
| 10261 | "community number\n" |
| 10262 | "Do not send outside local AS (well-known community)\n" |
| 10263 | "Do not advertise to any peer (well-known community)\n" |
| 10264 | "Do not export to next AS (well-known community)\n") |
| 10265 | |
| 10266 | /* old command */ |
| 10267 | ALIAS (show_ipv6_mbgp_community, |
| 10268 | show_ipv6_mbgp_community4_cmd, |
| 10269 | "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)", |
| 10270 | SHOW_STR |
| 10271 | IPV6_STR |
| 10272 | MBGP_STR |
| 10273 | "Display routes matching the communities\n" |
| 10274 | "community number\n" |
| 10275 | "Do not send outside local AS (well-known community)\n" |
| 10276 | "Do not advertise to any peer (well-known community)\n" |
| 10277 | "Do not export to next AS (well-known community)\n" |
| 10278 | "community number\n" |
| 10279 | "Do not send outside local AS (well-known community)\n" |
| 10280 | "Do not advertise to any peer (well-known community)\n" |
| 10281 | "Do not export to next AS (well-known community)\n" |
| 10282 | "community number\n" |
| 10283 | "Do not send outside local AS (well-known community)\n" |
| 10284 | "Do not advertise to any peer (well-known community)\n" |
| 10285 | "Do not export to next AS (well-known community)\n" |
| 10286 | "community number\n" |
| 10287 | "Do not send outside local AS (well-known community)\n" |
| 10288 | "Do not advertise to any peer (well-known community)\n" |
| 10289 | "Do not export to next AS (well-known community)\n") |
| 10290 | |
| 10291 | /* old command */ |
| 10292 | DEFUN (show_ipv6_mbgp_community_exact, |
| 10293 | show_ipv6_mbgp_community_exact_cmd, |
| 10294 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10295 | SHOW_STR |
| 10296 | IPV6_STR |
| 10297 | MBGP_STR |
| 10298 | "Display routes matching the communities\n" |
| 10299 | "community number\n" |
| 10300 | "Do not send outside local AS (well-known community)\n" |
| 10301 | "Do not advertise to any peer (well-known community)\n" |
| 10302 | "Do not export to next AS (well-known community)\n" |
| 10303 | "Exact match of the communities") |
| 10304 | { |
| 10305 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 10306 | } |
| 10307 | |
| 10308 | /* old command */ |
| 10309 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10310 | show_ipv6_mbgp_community2_exact_cmd, |
| 10311 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 10312 | SHOW_STR |
| 10313 | IPV6_STR |
| 10314 | MBGP_STR |
| 10315 | "Display routes matching the communities\n" |
| 10316 | "community number\n" |
| 10317 | "Do not send outside local AS (well-known community)\n" |
| 10318 | "Do not advertise to any peer (well-known community)\n" |
| 10319 | "Do not export to next AS (well-known community)\n" |
| 10320 | "community number\n" |
| 10321 | "Do not send outside local AS (well-known community)\n" |
| 10322 | "Do not advertise to any peer (well-known community)\n" |
| 10323 | "Do not export to next AS (well-known community)\n" |
| 10324 | "Exact match of the communities") |
| 10325 | |
| 10326 | /* old command */ |
| 10327 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10328 | show_ipv6_mbgp_community3_exact_cmd, |
| 10329 | "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", |
| 10330 | SHOW_STR |
| 10331 | IPV6_STR |
| 10332 | MBGP_STR |
| 10333 | "Display routes matching the communities\n" |
| 10334 | "community number\n" |
| 10335 | "Do not send outside local AS (well-known community)\n" |
| 10336 | "Do not advertise to any peer (well-known community)\n" |
| 10337 | "Do not export to next AS (well-known community)\n" |
| 10338 | "community number\n" |
| 10339 | "Do not send outside local AS (well-known community)\n" |
| 10340 | "Do not advertise to any peer (well-known community)\n" |
| 10341 | "Do not export to next AS (well-known community)\n" |
| 10342 | "community number\n" |
| 10343 | "Do not send outside local AS (well-known community)\n" |
| 10344 | "Do not advertise to any peer (well-known community)\n" |
| 10345 | "Do not export to next AS (well-known community)\n" |
| 10346 | "Exact match of the communities") |
| 10347 | |
| 10348 | /* old command */ |
| 10349 | ALIAS (show_ipv6_mbgp_community_exact, |
| 10350 | show_ipv6_mbgp_community4_exact_cmd, |
| 10351 | "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", |
| 10352 | SHOW_STR |
| 10353 | IPV6_STR |
| 10354 | MBGP_STR |
| 10355 | "Display routes matching the communities\n" |
| 10356 | "community number\n" |
| 10357 | "Do not send outside local AS (well-known community)\n" |
| 10358 | "Do not advertise to any peer (well-known community)\n" |
| 10359 | "Do not export to next AS (well-known community)\n" |
| 10360 | "community number\n" |
| 10361 | "Do not send outside local AS (well-known community)\n" |
| 10362 | "Do not advertise to any peer (well-known community)\n" |
| 10363 | "Do not export to next AS (well-known community)\n" |
| 10364 | "community number\n" |
| 10365 | "Do not send outside local AS (well-known community)\n" |
| 10366 | "Do not advertise to any peer (well-known community)\n" |
| 10367 | "Do not export to next AS (well-known community)\n" |
| 10368 | "community number\n" |
| 10369 | "Do not send outside local AS (well-known community)\n" |
| 10370 | "Do not advertise to any peer (well-known community)\n" |
| 10371 | "Do not export to next AS (well-known community)\n" |
| 10372 | "Exact match of the communities") |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10373 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10374 | DEFUN (show_bgp_ipv4_community, |
| 10375 | show_bgp_ipv4_community_cmd, |
| 10376 | "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10377 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10378 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10379 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10380 | "Display routes matching the communities\n" |
| 10381 | "community number\n" |
| 10382 | "Do not send outside local AS (well-known community)\n" |
| 10383 | "Do not advertise to any peer (well-known community)\n" |
| 10384 | "Do not export to next AS (well-known community)\n") |
| 10385 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10386 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10387 | } |
| 10388 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10389 | ALIAS (show_bgp_ipv4_community, |
| 10390 | show_bgp_ipv4_community2_cmd, |
| 10391 | "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] | 10392 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10393 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10394 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10395 | "Display routes matching the communities\n" |
| 10396 | "community number\n" |
| 10397 | "Do not send outside local AS (well-known community)\n" |
| 10398 | "Do not advertise to any peer (well-known community)\n" |
| 10399 | "Do not export to next AS (well-known community)\n" |
| 10400 | "community number\n" |
| 10401 | "Do not send outside local AS (well-known community)\n" |
| 10402 | "Do not advertise to any peer (well-known community)\n" |
| 10403 | "Do not export to next AS (well-known community)\n") |
| 10404 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10405 | ALIAS (show_bgp_ipv4_community, |
| 10406 | show_bgp_ipv4_community3_cmd, |
| 10407 | "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] | 10408 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10409 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10410 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10411 | "Display routes matching the communities\n" |
| 10412 | "community number\n" |
| 10413 | "Do not send outside local AS (well-known community)\n" |
| 10414 | "Do not advertise to any peer (well-known community)\n" |
| 10415 | "Do not export to next AS (well-known community)\n" |
| 10416 | "community number\n" |
| 10417 | "Do not send outside local AS (well-known community)\n" |
| 10418 | "Do not advertise to any peer (well-known community)\n" |
| 10419 | "Do not export to next AS (well-known community)\n" |
| 10420 | "community number\n" |
| 10421 | "Do not send outside local AS (well-known community)\n" |
| 10422 | "Do not advertise to any peer (well-known community)\n" |
| 10423 | "Do not export to next AS (well-known community)\n") |
| 10424 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10425 | ALIAS (show_bgp_ipv4_community, |
| 10426 | show_bgp_ipv4_community4_cmd, |
| 10427 | "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] | 10428 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10429 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10430 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10431 | "Display routes matching the communities\n" |
| 10432 | "community number\n" |
| 10433 | "Do not send outside local AS (well-known community)\n" |
| 10434 | "Do not advertise to any peer (well-known community)\n" |
| 10435 | "Do not export to next AS (well-known community)\n" |
| 10436 | "community number\n" |
| 10437 | "Do not send outside local AS (well-known community)\n" |
| 10438 | "Do not advertise to any peer (well-known community)\n" |
| 10439 | "Do not export to next AS (well-known community)\n" |
| 10440 | "community number\n" |
| 10441 | "Do not send outside local AS (well-known community)\n" |
| 10442 | "Do not advertise to any peer (well-known community)\n" |
| 10443 | "Do not export to next AS (well-known community)\n" |
| 10444 | "community number\n" |
| 10445 | "Do not send outside local AS (well-known community)\n" |
| 10446 | "Do not advertise to any peer (well-known community)\n" |
| 10447 | "Do not export to next AS (well-known community)\n") |
| 10448 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10449 | DEFUN (show_bgp_ipv4_safi_community, |
| 10450 | show_bgp_ipv4_safi_community_cmd, |
| 10451 | "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] | 10452 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10453 | BGP_STR |
| 10454 | "Address family\n" |
| 10455 | "Address Family modifier\n" |
| 10456 | "Address Family modifier\n" |
| 10457 | "Display routes matching the communities\n" |
| 10458 | "community number\n" |
| 10459 | "Do not send outside local AS (well-known community)\n" |
| 10460 | "Do not advertise to any peer (well-known community)\n" |
| 10461 | "Do not export to next AS (well-known community)\n") |
| 10462 | { |
| 10463 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10464 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10465 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10466 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10467 | } |
| 10468 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10469 | ALIAS (show_bgp_ipv4_safi_community, |
| 10470 | show_bgp_ipv4_safi_community2_cmd, |
| 10471 | "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] | 10472 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10473 | BGP_STR |
| 10474 | "Address family\n" |
| 10475 | "Address Family modifier\n" |
| 10476 | "Address Family modifier\n" |
| 10477 | "Display routes matching the communities\n" |
| 10478 | "community number\n" |
| 10479 | "Do not send outside local AS (well-known community)\n" |
| 10480 | "Do not advertise to any peer (well-known community)\n" |
| 10481 | "Do not export to next AS (well-known community)\n" |
| 10482 | "community number\n" |
| 10483 | "Do not send outside local AS (well-known community)\n" |
| 10484 | "Do not advertise to any peer (well-known community)\n" |
| 10485 | "Do not export to next AS (well-known community)\n") |
| 10486 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10487 | ALIAS (show_bgp_ipv4_safi_community, |
| 10488 | show_bgp_ipv4_safi_community3_cmd, |
| 10489 | "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] | 10490 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10491 | BGP_STR |
| 10492 | "Address family\n" |
| 10493 | "Address Family modifier\n" |
| 10494 | "Address Family modifier\n" |
| 10495 | "Display routes matching the communities\n" |
| 10496 | "community number\n" |
| 10497 | "Do not send outside local AS (well-known community)\n" |
| 10498 | "Do not advertise to any peer (well-known community)\n" |
| 10499 | "Do not export to next AS (well-known community)\n" |
| 10500 | "community number\n" |
| 10501 | "Do not send outside local AS (well-known community)\n" |
| 10502 | "Do not advertise to any peer (well-known community)\n" |
| 10503 | "Do not export to next AS (well-known community)\n" |
| 10504 | "community number\n" |
| 10505 | "Do not send outside local AS (well-known community)\n" |
| 10506 | "Do not advertise to any peer (well-known community)\n" |
| 10507 | "Do not export to next AS (well-known community)\n") |
| 10508 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10509 | ALIAS (show_bgp_ipv4_safi_community, |
| 10510 | show_bgp_ipv4_safi_community4_cmd, |
| 10511 | "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] | 10512 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10513 | BGP_STR |
| 10514 | "Address family\n" |
| 10515 | "Address Family modifier\n" |
| 10516 | "Address Family modifier\n" |
| 10517 | "Display routes matching the communities\n" |
| 10518 | "community number\n" |
| 10519 | "Do not send outside local AS (well-known community)\n" |
| 10520 | "Do not advertise to any peer (well-known community)\n" |
| 10521 | "Do not export to next AS (well-known community)\n" |
| 10522 | "community number\n" |
| 10523 | "Do not send outside local AS (well-known community)\n" |
| 10524 | "Do not advertise to any peer (well-known community)\n" |
| 10525 | "Do not export to next AS (well-known community)\n" |
| 10526 | "community number\n" |
| 10527 | "Do not send outside local AS (well-known community)\n" |
| 10528 | "Do not advertise to any peer (well-known community)\n" |
| 10529 | "Do not export to next AS (well-known community)\n" |
| 10530 | "community number\n" |
| 10531 | "Do not send outside local AS (well-known community)\n" |
| 10532 | "Do not advertise to any peer (well-known community)\n" |
| 10533 | "Do not export to next AS (well-known community)\n") |
| 10534 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10535 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 10536 | show_bgp_view_afi_safi_community_all_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10537 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10538 | SHOW_STR |
| 10539 | BGP_STR |
| 10540 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10541 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10542 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10543 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10544 | "Address Family modifier\n" |
| 10545 | "Address Family modifier\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10546 | "Display routes matching the communities\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10547 | { |
| 10548 | int afi; |
| 10549 | int safi; |
| 10550 | struct bgp *bgp; |
| 10551 | |
| 10552 | /* BGP structure lookup. */ |
| 10553 | bgp = bgp_lookup_by_name (argv[0]); |
| 10554 | if (bgp == NULL) |
| 10555 | { |
| 10556 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10557 | return CMD_WARNING; |
| 10558 | } |
| 10559 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10560 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10561 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10562 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 10563 | } |
| 10564 | |
| 10565 | DEFUN (show_bgp_view_afi_safi_community, |
| 10566 | show_bgp_view_afi_safi_community_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10567 | "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] | 10568 | SHOW_STR |
| 10569 | BGP_STR |
| 10570 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10571 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10572 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10573 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10574 | "Address family modifier\n" |
| 10575 | "Address family modifier\n" |
| 10576 | "Display routes matching the communities\n" |
| 10577 | "community number\n" |
| 10578 | "Do not send outside local AS (well-known community)\n" |
| 10579 | "Do not advertise to any peer (well-known community)\n" |
| 10580 | "Do not export to next AS (well-known community)\n") |
| 10581 | { |
| 10582 | int afi; |
| 10583 | int safi; |
| 10584 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10585 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10586 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10587 | 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] | 10588 | } |
| 10589 | |
| 10590 | ALIAS (show_bgp_view_afi_safi_community, |
| 10591 | show_bgp_view_afi_safi_community2_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10592 | "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] | 10593 | SHOW_STR |
| 10594 | BGP_STR |
| 10595 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10596 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10597 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10598 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10599 | "Address family modifier\n" |
| 10600 | "Address family modifier\n" |
| 10601 | "Display routes matching the communities\n" |
| 10602 | "community number\n" |
| 10603 | "Do not send outside local AS (well-known community)\n" |
| 10604 | "Do not advertise to any peer (well-known community)\n" |
| 10605 | "Do not export to next AS (well-known community)\n" |
| 10606 | "community number\n" |
| 10607 | "Do not send outside local AS (well-known community)\n" |
| 10608 | "Do not advertise to any peer (well-known community)\n" |
| 10609 | "Do not export to next AS (well-known community)\n") |
| 10610 | |
| 10611 | ALIAS (show_bgp_view_afi_safi_community, |
| 10612 | show_bgp_view_afi_safi_community3_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10613 | "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] | 10614 | SHOW_STR |
| 10615 | BGP_STR |
| 10616 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10617 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10618 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10619 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10620 | "Address family modifier\n" |
| 10621 | "Address family modifier\n" |
| 10622 | "Display routes matching the communities\n" |
| 10623 | "community number\n" |
| 10624 | "Do not send outside local AS (well-known community)\n" |
| 10625 | "Do not advertise to any peer (well-known community)\n" |
| 10626 | "Do not export to next AS (well-known community)\n" |
| 10627 | "community number\n" |
| 10628 | "Do not send outside local AS (well-known community)\n" |
| 10629 | "Do not advertise to any peer (well-known community)\n" |
| 10630 | "Do not export to next AS (well-known community)\n" |
| 10631 | "community number\n" |
| 10632 | "Do not send outside local AS (well-known community)\n" |
| 10633 | "Do not advertise to any peer (well-known community)\n" |
| 10634 | "Do not export to next AS (well-known community)\n") |
| 10635 | |
| 10636 | ALIAS (show_bgp_view_afi_safi_community, |
| 10637 | show_bgp_view_afi_safi_community4_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) (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] | 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 | "community number\n" |
| 10653 | "Do not send outside local AS (well-known community)\n" |
| 10654 | "Do not advertise to any peer (well-known community)\n" |
| 10655 | "Do not export to next AS (well-known community)\n" |
| 10656 | "community number\n" |
| 10657 | "Do not send outside local AS (well-known community)\n" |
| 10658 | "Do not advertise to any peer (well-known community)\n" |
| 10659 | "Do not export to next AS (well-known community)\n" |
| 10660 | "community number\n" |
| 10661 | "Do not send outside local AS (well-known community)\n" |
| 10662 | "Do not advertise to any peer (well-known community)\n" |
| 10663 | "Do not export to next AS (well-known community)\n") |
| 10664 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10665 | DEFUN (show_bgp_ipv4_community_exact, |
| 10666 | show_bgp_ipv4_community_exact_cmd, |
| 10667 | "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] | 10668 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10669 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10670 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10671 | "Display routes matching the communities\n" |
| 10672 | "community number\n" |
| 10673 | "Do not send outside local AS (well-known community)\n" |
| 10674 | "Do not advertise to any peer (well-known community)\n" |
| 10675 | "Do not export to next AS (well-known community)\n" |
| 10676 | "Exact match of the communities") |
| 10677 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10678 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10679 | } |
| 10680 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10681 | ALIAS (show_bgp_ipv4_community_exact, |
| 10682 | show_bgp_ipv4_community2_exact_cmd, |
| 10683 | "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] | 10684 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10685 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10686 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10687 | "Display routes matching the communities\n" |
| 10688 | "community number\n" |
| 10689 | "Do not send outside local AS (well-known community)\n" |
| 10690 | "Do not advertise to any peer (well-known community)\n" |
| 10691 | "Do not export to next AS (well-known community)\n" |
| 10692 | "community number\n" |
| 10693 | "Do not send outside local AS (well-known community)\n" |
| 10694 | "Do not advertise to any peer (well-known community)\n" |
| 10695 | "Do not export to next AS (well-known community)\n" |
| 10696 | "Exact match of the communities") |
| 10697 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10698 | ALIAS (show_bgp_ipv4_community_exact, |
| 10699 | show_bgp_ipv4_community3_exact_cmd, |
| 10700 | "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] | 10701 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10702 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10703 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10704 | "Display routes matching the communities\n" |
| 10705 | "community number\n" |
| 10706 | "Do not send outside local AS (well-known community)\n" |
| 10707 | "Do not advertise to any peer (well-known community)\n" |
| 10708 | "Do not export to next AS (well-known community)\n" |
| 10709 | "community number\n" |
| 10710 | "Do not send outside local AS (well-known community)\n" |
| 10711 | "Do not advertise to any peer (well-known community)\n" |
| 10712 | "Do not export to next AS (well-known community)\n" |
| 10713 | "community number\n" |
| 10714 | "Do not send outside local AS (well-known community)\n" |
| 10715 | "Do not advertise to any peer (well-known community)\n" |
| 10716 | "Do not export to next AS (well-known community)\n" |
| 10717 | "Exact match of the communities") |
| 10718 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10719 | ALIAS (show_bgp_ipv4_community_exact, |
| 10720 | show_bgp_ipv4_community4_exact_cmd, |
| 10721 | "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] | 10722 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10723 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10724 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10725 | "Display routes matching the communities\n" |
| 10726 | "community number\n" |
| 10727 | "Do not send outside local AS (well-known community)\n" |
| 10728 | "Do not advertise to any peer (well-known community)\n" |
| 10729 | "Do not export to next AS (well-known community)\n" |
| 10730 | "community number\n" |
| 10731 | "Do not send outside local AS (well-known community)\n" |
| 10732 | "Do not advertise to any peer (well-known community)\n" |
| 10733 | "Do not export to next AS (well-known community)\n" |
| 10734 | "community number\n" |
| 10735 | "Do not send outside local AS (well-known community)\n" |
| 10736 | "Do not advertise to any peer (well-known community)\n" |
| 10737 | "Do not export to next AS (well-known community)\n" |
| 10738 | "community number\n" |
| 10739 | "Do not send outside local AS (well-known community)\n" |
| 10740 | "Do not advertise to any peer (well-known community)\n" |
| 10741 | "Do not export to next AS (well-known community)\n" |
| 10742 | "Exact match of the communities") |
| 10743 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10744 | DEFUN (show_bgp_ipv4_safi_community4_exact, |
| 10745 | show_bgp_ipv4_safi_community_exact_cmd, |
| 10746 | "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] | 10747 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10748 | BGP_STR |
| 10749 | "Address family\n" |
| 10750 | "Address Family modifier\n" |
| 10751 | "Address Family modifier\n" |
| 10752 | "Display routes matching the communities\n" |
| 10753 | "community number\n" |
| 10754 | "Do not send outside local AS (well-known community)\n" |
| 10755 | "Do not advertise to any peer (well-known community)\n" |
| 10756 | "Do not export to next AS (well-known community)\n" |
| 10757 | "Exact match of the communities") |
| 10758 | { |
| 10759 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10760 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10761 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10762 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10763 | } |
| 10764 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10765 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10766 | show_bgp_ipv4_safi_community2_exact_cmd, |
| 10767 | "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] | 10768 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10769 | BGP_STR |
| 10770 | "Address family\n" |
| 10771 | "Address Family modifier\n" |
| 10772 | "Address Family modifier\n" |
| 10773 | "Display routes matching the communities\n" |
| 10774 | "community number\n" |
| 10775 | "Do not send outside local AS (well-known community)\n" |
| 10776 | "Do not advertise to any peer (well-known community)\n" |
| 10777 | "Do not export to next AS (well-known community)\n" |
| 10778 | "community number\n" |
| 10779 | "Do not send outside local AS (well-known community)\n" |
| 10780 | "Do not advertise to any peer (well-known community)\n" |
| 10781 | "Do not export to next AS (well-known community)\n" |
| 10782 | "Exact match of the communities") |
| 10783 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10784 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10785 | show_bgp_ipv4_safi_community3_exact_cmd, |
| 10786 | "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] | 10787 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10788 | BGP_STR |
| 10789 | "Address family\n" |
| 10790 | "Address Family modifier\n" |
| 10791 | "Address Family modifier\n" |
| 10792 | "Display routes matching the communities\n" |
| 10793 | "community number\n" |
| 10794 | "Do not send outside local AS (well-known community)\n" |
| 10795 | "Do not advertise to any peer (well-known community)\n" |
| 10796 | "Do not export to next AS (well-known community)\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 | "Exact match of the communities") |
| 10806 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10807 | ALIAS (show_bgp_ipv4_safi_community4_exact, |
| 10808 | show_bgp_ipv4_safi_community4_exact_cmd, |
| 10809 | "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] | 10810 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10811 | BGP_STR |
| 10812 | "Address family\n" |
| 10813 | "Address Family modifier\n" |
| 10814 | "Address Family modifier\n" |
| 10815 | "Display routes matching the communities\n" |
| 10816 | "community number\n" |
| 10817 | "Do not send outside local AS (well-known community)\n" |
| 10818 | "Do not advertise to any peer (well-known community)\n" |
| 10819 | "Do not export to next AS (well-known community)\n" |
| 10820 | "community number\n" |
| 10821 | "Do not send outside local AS (well-known community)\n" |
| 10822 | "Do not advertise to any peer (well-known community)\n" |
| 10823 | "Do not export to next AS (well-known community)\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 | "community number\n" |
| 10829 | "Do not send outside local AS (well-known community)\n" |
| 10830 | "Do not advertise to any peer (well-known community)\n" |
| 10831 | "Do not export to next AS (well-known community)\n" |
| 10832 | "Exact match of the communities") |
| 10833 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10834 | DEFUN (show_bgp_ipv6_safi_community, |
| 10835 | show_bgp_ipv6_safi_community_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10836 | "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] | 10837 | SHOW_STR |
| 10838 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10839 | "Address family\n" |
| 10840 | "Address family modifier\n" |
| 10841 | "Address family modifier\n" |
| 10842 | "Address family modifier\n" |
| 10843 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10850 | safi_t safi; |
| 10851 | |
| 10852 | if (bgp_parse_safi(argv[0], &safi)) { |
| 10853 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 10854 | return CMD_WARNING; |
| 10855 | } |
| 10856 | 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] | 10857 | } |
| 10858 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10859 | ALIAS (show_bgp_ipv6_safi_community, |
| 10860 | show_bgp_ipv6_safi_community2_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10861 | "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] | 10862 | SHOW_STR |
| 10863 | BGP_STR |
| 10864 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10865 | "Address family modifier\n" |
| 10866 | "Address family modifier\n" |
| 10867 | "Address family modifier\n" |
| 10868 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10869 | "Display routes matching the communities\n" |
| 10870 | "community number\n" |
| 10871 | "Do not send outside local AS (well-known community)\n" |
| 10872 | "Do not advertise to any peer (well-known community)\n" |
| 10873 | "Do not export to next AS (well-known community)\n" |
| 10874 | "community number\n" |
| 10875 | "Do not send outside local AS (well-known community)\n" |
| 10876 | "Do not advertise to any peer (well-known community)\n" |
| 10877 | "Do not export to next AS (well-known community)\n") |
| 10878 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10879 | ALIAS (show_bgp_ipv6_safi_community, |
| 10880 | show_bgp_ipv6_safi_community3_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10881 | "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] | 10882 | SHOW_STR |
| 10883 | BGP_STR |
| 10884 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10885 | "Address family modifier\n" |
| 10886 | "Address family modifier\n" |
| 10887 | "Address family modifier\n" |
| 10888 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10889 | "Display routes matching the communities\n" |
| 10890 | "community number\n" |
| 10891 | "Do not send outside local AS (well-known community)\n" |
| 10892 | "Do not advertise to any peer (well-known community)\n" |
| 10893 | "Do not export to next AS (well-known community)\n" |
| 10894 | "community number\n" |
| 10895 | "Do not send outside local AS (well-known community)\n" |
| 10896 | "Do not advertise to any peer (well-known community)\n" |
| 10897 | "Do not export to next AS (well-known community)\n" |
| 10898 | "community number\n" |
| 10899 | "Do not send outside local AS (well-known community)\n" |
| 10900 | "Do not advertise to any peer (well-known community)\n" |
| 10901 | "Do not export to next AS (well-known community)\n") |
| 10902 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10903 | ALIAS (show_bgp_ipv6_safi_community, |
| 10904 | show_bgp_ipv6_safi_community4_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10905 | "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (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] | 10906 | SHOW_STR |
| 10907 | BGP_STR |
| 10908 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10909 | "Address family modifier\n" |
| 10910 | "Address family modifier\n" |
| 10911 | "Address family modifier\n" |
| 10912 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10913 | "Display routes matching the communities\n" |
| 10914 | "community number\n" |
| 10915 | "Do not send outside local AS (well-known community)\n" |
| 10916 | "Do not advertise to any peer (well-known community)\n" |
| 10917 | "Do not export to next AS (well-known community)\n" |
| 10918 | "community number\n" |
| 10919 | "Do not send outside local AS (well-known community)\n" |
| 10920 | "Do not advertise to any peer (well-known community)\n" |
| 10921 | "Do not export to next AS (well-known community)\n" |
| 10922 | "community number\n" |
| 10923 | "Do not send outside local AS (well-known community)\n" |
| 10924 | "Do not advertise to any peer (well-known community)\n" |
| 10925 | "Do not export to next AS (well-known community)\n" |
| 10926 | "community number\n" |
| 10927 | "Do not send outside local AS (well-known community)\n" |
| 10928 | "Do not advertise to any peer (well-known community)\n" |
| 10929 | "Do not export to next AS (well-known community)\n") |
| 10930 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10931 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10932 | DEFUN (show_bgp_ipv6_safi_community_exact, |
| 10933 | show_bgp_ipv6_safi_community_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10934 | "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] | 10935 | SHOW_STR |
| 10936 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10937 | "Address family\n" |
| 10938 | "Address family modifier\n" |
| 10939 | "Address family modifier\n" |
| 10940 | "Address family modifier\n" |
| 10941 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10942 | "Display routes matching the communities\n" |
| 10943 | "community number\n" |
| 10944 | "Do not send outside local AS (well-known community)\n" |
| 10945 | "Do not advertise to any peer (well-known community)\n" |
| 10946 | "Do not export to next AS (well-known community)\n" |
| 10947 | "Exact match of the communities") |
| 10948 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10949 | safi_t safi; |
| 10950 | |
| 10951 | if (bgp_parse_safi(argv[0], &safi)) { |
| 10952 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 10953 | return CMD_WARNING; |
| 10954 | } |
| 10955 | 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] | 10956 | } |
| 10957 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10958 | |
| 10959 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10960 | show_bgp_ipv6_safi_community2_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10961 | "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] | 10962 | SHOW_STR |
| 10963 | BGP_STR |
| 10964 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10965 | "Address family modifier\n" |
| 10966 | "Address family modifier\n" |
| 10967 | "Address family modifier\n" |
| 10968 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10969 | "Display routes matching the communities\n" |
| 10970 | "community number\n" |
| 10971 | "Do not send outside local AS (well-known community)\n" |
| 10972 | "Do not advertise to any peer (well-known community)\n" |
| 10973 | "Do not export to next AS (well-known community)\n" |
| 10974 | "community number\n" |
| 10975 | "Do not send outside local AS (well-known community)\n" |
| 10976 | "Do not advertise to any peer (well-known community)\n" |
| 10977 | "Do not export to next AS (well-known community)\n" |
| 10978 | "Exact match of the communities") |
| 10979 | |
| 10980 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 10981 | show_bgp_ipv6_safi_community3_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10982 | "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] | 10983 | SHOW_STR |
| 10984 | BGP_STR |
| 10985 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 10986 | "Address family modifier\n" |
| 10987 | "Address family modifier\n" |
| 10988 | "Address family modifier\n" |
| 10989 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10990 | "Display routes matching the communities\n" |
| 10991 | "community number\n" |
| 10992 | "Do not send outside local AS (well-known community)\n" |
| 10993 | "Do not advertise to any peer (well-known community)\n" |
| 10994 | "Do not export to next AS (well-known community)\n" |
| 10995 | "community number\n" |
| 10996 | "Do not send outside local AS (well-known community)\n" |
| 10997 | "Do not advertise to any peer (well-known community)\n" |
| 10998 | "Do not export to next AS (well-known community)\n" |
| 10999 | "community number\n" |
| 11000 | "Do not send outside local AS (well-known community)\n" |
| 11001 | "Do not advertise to any peer (well-known community)\n" |
| 11002 | "Do not export to next AS (well-known community)\n" |
| 11003 | "Exact match of the communities") |
| 11004 | |
| 11005 | ALIAS (show_bgp_community_exact, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11006 | show_bgp_ipv6_safi_community4_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11007 | "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] | 11008 | SHOW_STR |
| 11009 | BGP_STR |
| 11010 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11011 | "Address family modifier\n" |
| 11012 | "Address family modifier\n" |
| 11013 | "Address family modifier\n" |
| 11014 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11015 | "Display routes matching the communities\n" |
| 11016 | "community number\n" |
| 11017 | "Do not send outside local AS (well-known community)\n" |
| 11018 | "Do not advertise to any peer (well-known community)\n" |
| 11019 | "Do not export to next AS (well-known community)\n" |
| 11020 | "community number\n" |
| 11021 | "Do not send outside local AS (well-known community)\n" |
| 11022 | "Do not advertise to any peer (well-known community)\n" |
| 11023 | "Do not export to next AS (well-known community)\n" |
| 11024 | "community number\n" |
| 11025 | "Do not send outside local AS (well-known community)\n" |
| 11026 | "Do not advertise to any peer (well-known community)\n" |
| 11027 | "Do not export to next AS (well-known community)\n" |
| 11028 | "community number\n" |
| 11029 | "Do not send outside local AS (well-known community)\n" |
| 11030 | "Do not advertise to any peer (well-known community)\n" |
| 11031 | "Do not export to next AS (well-known community)\n" |
| 11032 | "Exact match of the communities") |
| 11033 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11034 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11035 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 11036 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11037 | { |
| 11038 | struct community_list *list; |
| 11039 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11040 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11041 | if (list == NULL) |
| 11042 | { |
| 11043 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 11044 | VTY_NEWLINE); |
| 11045 | return CMD_WARNING; |
| 11046 | } |
| 11047 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11048 | return bgp_show (vty, NULL, afi, safi, |
| 11049 | (exact ? bgp_show_type_community_list_exact : |
| 11050 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11051 | } |
| 11052 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11053 | DEFUN (show_ip_bgp_community_list, |
| 11054 | show_ip_bgp_community_list_cmd, |
| 11055 | "show ip bgp community-list (<1-500>|WORD)", |
| 11056 | SHOW_STR |
| 11057 | IP_STR |
| 11058 | BGP_STR |
| 11059 | "Display routes matching the community-list\n" |
| 11060 | "community-list number\n" |
| 11061 | "community-list name\n") |
| 11062 | { |
| 11063 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 11064 | } |
| 11065 | |
| 11066 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 11067 | show_ip_bgp_ipv4_community_list_cmd, |
| 11068 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
| 11069 | SHOW_STR |
| 11070 | IP_STR |
| 11071 | BGP_STR |
| 11072 | "Address family\n" |
| 11073 | "Address Family modifier\n" |
| 11074 | "Address Family modifier\n" |
| 11075 | "Display routes matching the community-list\n" |
| 11076 | "community-list number\n" |
| 11077 | "community-list name\n") |
| 11078 | { |
| 11079 | if (strncmp (argv[0], "m", 1) == 0) |
| 11080 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 11081 | |
| 11082 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 11083 | } |
| 11084 | |
| 11085 | DEFUN (show_ip_bgp_community_list_exact, |
| 11086 | show_ip_bgp_community_list_exact_cmd, |
| 11087 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
| 11088 | SHOW_STR |
| 11089 | IP_STR |
| 11090 | BGP_STR |
| 11091 | "Display routes matching the community-list\n" |
| 11092 | "community-list number\n" |
| 11093 | "community-list name\n" |
| 11094 | "Exact match of the communities\n") |
| 11095 | { |
| 11096 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 11097 | } |
| 11098 | |
| 11099 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 11100 | show_ip_bgp_ipv4_community_list_exact_cmd, |
| 11101 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
| 11102 | SHOW_STR |
| 11103 | IP_STR |
| 11104 | BGP_STR |
| 11105 | "Address family\n" |
| 11106 | "Address Family modifier\n" |
| 11107 | "Address Family modifier\n" |
| 11108 | "Display routes matching the community-list\n" |
| 11109 | "community-list number\n" |
| 11110 | "community-list name\n" |
| 11111 | "Exact match of the communities\n") |
| 11112 | { |
| 11113 | if (strncmp (argv[0], "m", 1) == 0) |
| 11114 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 11115 | |
| 11116 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 11117 | } |
| 11118 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11119 | DEFUN (show_bgp_community_list, |
| 11120 | show_bgp_community_list_cmd, |
| 11121 | "show bgp community-list (<1-500>|WORD)", |
| 11122 | SHOW_STR |
| 11123 | BGP_STR |
| 11124 | "Display routes matching the community-list\n" |
| 11125 | "community-list number\n" |
| 11126 | "community-list name\n") |
| 11127 | { |
| 11128 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 11129 | } |
| 11130 | |
| 11131 | ALIAS (show_bgp_community_list, |
| 11132 | show_bgp_ipv6_community_list_cmd, |
| 11133 | "show bgp ipv6 community-list (<1-500>|WORD)", |
| 11134 | SHOW_STR |
| 11135 | BGP_STR |
| 11136 | "Address family\n" |
| 11137 | "Display routes matching the community-list\n" |
| 11138 | "community-list number\n" |
| 11139 | "community-list name\n") |
| 11140 | |
| 11141 | /* old command */ |
| 11142 | DEFUN (show_ipv6_bgp_community_list, |
| 11143 | show_ipv6_bgp_community_list_cmd, |
| 11144 | "show ipv6 bgp community-list WORD", |
| 11145 | SHOW_STR |
| 11146 | IPV6_STR |
| 11147 | BGP_STR |
| 11148 | "Display routes matching the community-list\n" |
| 11149 | "community-list name\n") |
| 11150 | { |
| 11151 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 11152 | } |
| 11153 | |
| 11154 | /* old command */ |
| 11155 | DEFUN (show_ipv6_mbgp_community_list, |
| 11156 | show_ipv6_mbgp_community_list_cmd, |
| 11157 | "show ipv6 mbgp community-list WORD", |
| 11158 | SHOW_STR |
| 11159 | IPV6_STR |
| 11160 | MBGP_STR |
| 11161 | "Display routes matching the community-list\n" |
| 11162 | "community-list name\n") |
| 11163 | { |
| 11164 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 11165 | } |
| 11166 | |
| 11167 | DEFUN (show_bgp_community_list_exact, |
| 11168 | show_bgp_community_list_exact_cmd, |
| 11169 | "show bgp community-list (<1-500>|WORD) exact-match", |
| 11170 | SHOW_STR |
| 11171 | BGP_STR |
| 11172 | "Display routes matching the community-list\n" |
| 11173 | "community-list number\n" |
| 11174 | "community-list name\n" |
| 11175 | "Exact match of the communities\n") |
| 11176 | { |
| 11177 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 11178 | } |
| 11179 | |
| 11180 | ALIAS (show_bgp_community_list_exact, |
| 11181 | show_bgp_ipv6_community_list_exact_cmd, |
| 11182 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
| 11183 | SHOW_STR |
| 11184 | BGP_STR |
| 11185 | "Address family\n" |
| 11186 | "Display routes matching the community-list\n" |
| 11187 | "community-list number\n" |
| 11188 | "community-list name\n" |
| 11189 | "Exact match of the communities\n") |
| 11190 | |
| 11191 | /* old command */ |
| 11192 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 11193 | show_ipv6_bgp_community_list_exact_cmd, |
| 11194 | "show ipv6 bgp community-list WORD exact-match", |
| 11195 | SHOW_STR |
| 11196 | IPV6_STR |
| 11197 | BGP_STR |
| 11198 | "Display routes matching the community-list\n" |
| 11199 | "community-list name\n" |
| 11200 | "Exact match of the communities\n") |
| 11201 | { |
| 11202 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 11203 | } |
| 11204 | |
| 11205 | /* old command */ |
| 11206 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 11207 | show_ipv6_mbgp_community_list_exact_cmd, |
| 11208 | "show ipv6 mbgp community-list WORD exact-match", |
| 11209 | SHOW_STR |
| 11210 | IPV6_STR |
| 11211 | MBGP_STR |
| 11212 | "Display routes matching the community-list\n" |
| 11213 | "community-list name\n" |
| 11214 | "Exact match of the communities\n") |
| 11215 | { |
| 11216 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 11217 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11218 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11219 | DEFUN (show_bgp_ipv4_community_list, |
| 11220 | show_bgp_ipv4_community_list_cmd, |
| 11221 | "show bgp ipv4 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11222 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11223 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11224 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11225 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11226 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11227 | "community-list name\n") |
| 11228 | { |
| 11229 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 11230 | } |
| 11231 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11232 | DEFUN (show_bgp_ipv4_safi_community_list, |
| 11233 | show_bgp_ipv4_safi_community_list_cmd, |
| 11234 | "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11235 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11236 | BGP_STR |
| 11237 | "Address family\n" |
| 11238 | "Address Family modifier\n" |
| 11239 | "Address Family modifier\n" |
| 11240 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11241 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11242 | "community-list name\n") |
| 11243 | { |
| 11244 | if (strncmp (argv[0], "m", 1) == 0) |
| 11245 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 11246 | |
| 11247 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 11248 | } |
| 11249 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11250 | DEFUN (show_bgp_ipv4_community_list_exact, |
| 11251 | show_bgp_ipv4_community_list_exact_cmd, |
| 11252 | "show bgp ipv4 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11253 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11254 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11255 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11256 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11257 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11258 | "community-list name\n" |
| 11259 | "Exact match of the communities\n") |
| 11260 | { |
| 11261 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 11262 | } |
| 11263 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11264 | DEFUN (show_bgp_ipv4_safi_community_list_exact, |
| 11265 | show_bgp_ipv4_safi_community_list_exact_cmd, |
| 11266 | "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11267 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11268 | BGP_STR |
| 11269 | "Address family\n" |
| 11270 | "Address Family modifier\n" |
| 11271 | "Address Family modifier\n" |
| 11272 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11273 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11274 | "community-list name\n" |
| 11275 | "Exact match of the communities\n") |
| 11276 | { |
| 11277 | if (strncmp (argv[0], "m", 1) == 0) |
| 11278 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 11279 | |
| 11280 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 11281 | } |
| 11282 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11283 | DEFUN (show_bgp_ipv6_safi_community_list, |
| 11284 | show_bgp_ipv6_safi_community_list_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11285 | "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11286 | SHOW_STR |
| 11287 | BGP_STR |
| 11288 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11289 | "Address family modifier\n" |
| 11290 | "Address family modifier\n" |
| 11291 | "Address family modifier\n" |
| 11292 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11293 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11294 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 11295 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11296 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11297 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11298 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11299 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11300 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11301 | return CMD_WARNING; |
| 11302 | } |
| 11303 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11304 | } |
| 11305 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11306 | DEFUN (show_bgp_ipv6_safi_community_list_exact, |
| 11307 | show_bgp_ipv6_safi_community_list_exact_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11308 | "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] | 11309 | SHOW_STR |
| 11310 | BGP_STR |
| 11311 | "Address family\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11312 | "Address family modifier\n" |
| 11313 | "Address family modifier\n" |
| 11314 | "Address family modifier\n" |
| 11315 | "Address family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11316 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 11317 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11318 | "community-list name\n" |
| 11319 | "Exact match of the communities\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11320 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11321 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11322 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11323 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11324 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11325 | return CMD_WARNING; |
| 11326 | } |
| 11327 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11328 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11329 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11330 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11331 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11332 | safi_t safi, enum bgp_show_type type) |
| 11333 | { |
| 11334 | int ret; |
| 11335 | struct prefix *p; |
| 11336 | |
| 11337 | p = prefix_new(); |
| 11338 | |
| 11339 | ret = str2prefix (prefix, p); |
| 11340 | if (! ret) |
| 11341 | { |
| 11342 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 11343 | return CMD_WARNING; |
| 11344 | } |
| 11345 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11346 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 11347 | prefix_free(p); |
| 11348 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11349 | } |
| 11350 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11351 | DEFUN (show_ip_bgp_prefix_longer, |
| 11352 | show_ip_bgp_prefix_longer_cmd, |
| 11353 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 11354 | SHOW_STR |
| 11355 | IP_STR |
| 11356 | BGP_STR |
| 11357 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11358 | "Display route and more specific routes\n") |
| 11359 | { |
| 11360 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11361 | bgp_show_type_prefix_longer); |
| 11362 | } |
| 11363 | |
| 11364 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 11365 | show_ip_bgp_flap_prefix_longer_cmd, |
| 11366 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 11367 | SHOW_STR |
| 11368 | IP_STR |
| 11369 | BGP_STR |
| 11370 | "Display flap statistics of routes\n" |
| 11371 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11372 | "Display route and more specific routes\n") |
| 11373 | { |
| 11374 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11375 | bgp_show_type_flap_prefix_longer); |
| 11376 | } |
| 11377 | |
| 11378 | ALIAS (show_ip_bgp_flap_prefix_longer, |
| 11379 | show_ip_bgp_damp_flap_prefix_longer_cmd, |
| 11380 | "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes", |
| 11381 | SHOW_STR |
| 11382 | IP_STR |
| 11383 | BGP_STR |
| 11384 | "Display detailed information about dampening\n" |
| 11385 | "Display flap statistics of routes\n" |
| 11386 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11387 | "Display route and more specific routes\n") |
| 11388 | |
| 11389 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 11390 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 11391 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 11392 | SHOW_STR |
| 11393 | IP_STR |
| 11394 | BGP_STR |
| 11395 | "Address family\n" |
| 11396 | "Address Family modifier\n" |
| 11397 | "Address Family modifier\n" |
| 11398 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11399 | "Display route and more specific routes\n") |
| 11400 | { |
| 11401 | if (strncmp (argv[0], "m", 1) == 0) |
| 11402 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 11403 | bgp_show_type_prefix_longer); |
| 11404 | |
| 11405 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 11406 | bgp_show_type_prefix_longer); |
| 11407 | } |
| 11408 | |
| 11409 | DEFUN (show_ip_bgp_flap_address, |
| 11410 | show_ip_bgp_flap_address_cmd, |
| 11411 | "show ip bgp flap-statistics A.B.C.D", |
| 11412 | SHOW_STR |
| 11413 | IP_STR |
| 11414 | BGP_STR |
| 11415 | "Display flap statistics of routes\n" |
| 11416 | "Network in the BGP routing table to display\n") |
| 11417 | { |
| 11418 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11419 | bgp_show_type_flap_address); |
| 11420 | } |
| 11421 | |
| 11422 | ALIAS (show_ip_bgp_flap_address, |
| 11423 | show_ip_bgp_damp_flap_address_cmd, |
| 11424 | "show ip bgp dampening flap-statistics A.B.C.D", |
| 11425 | SHOW_STR |
| 11426 | IP_STR |
| 11427 | BGP_STR |
| 11428 | "Display detailed information about dampening\n" |
| 11429 | "Display flap statistics of routes\n" |
| 11430 | "Network in the BGP routing table to display\n") |
| 11431 | |
| 11432 | DEFUN (show_ip_bgp_flap_prefix, |
| 11433 | show_ip_bgp_flap_prefix_cmd, |
| 11434 | "show ip bgp flap-statistics A.B.C.D/M", |
| 11435 | SHOW_STR |
| 11436 | IP_STR |
| 11437 | BGP_STR |
| 11438 | "Display flap statistics of routes\n" |
| 11439 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11440 | { |
| 11441 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11442 | bgp_show_type_flap_prefix); |
| 11443 | } |
| 11444 | |
| 11445 | ALIAS (show_ip_bgp_flap_prefix, |
| 11446 | show_ip_bgp_damp_flap_prefix_cmd, |
| 11447 | "show ip bgp dampening flap-statistics A.B.C.D/M", |
| 11448 | SHOW_STR |
| 11449 | IP_STR |
| 11450 | BGP_STR |
| 11451 | "Display detailed information about dampening\n" |
| 11452 | "Display flap statistics of routes\n" |
| 11453 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11454 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11455 | DEFUN (show_bgp_prefix_longer, |
| 11456 | show_bgp_prefix_longer_cmd, |
| 11457 | "show bgp X:X::X:X/M longer-prefixes", |
| 11458 | SHOW_STR |
| 11459 | BGP_STR |
| 11460 | "IPv6 prefix <network>/<length>\n" |
| 11461 | "Display route and more specific routes\n") |
| 11462 | { |
| 11463 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11464 | bgp_show_type_prefix_longer); |
| 11465 | } |
| 11466 | |
| 11467 | /* old command */ |
| 11468 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 11469 | show_ipv6_bgp_prefix_longer_cmd, |
| 11470 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 11471 | SHOW_STR |
| 11472 | IPV6_STR |
| 11473 | BGP_STR |
| 11474 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 11475 | "Display route and more specific routes\n") |
| 11476 | { |
| 11477 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11478 | bgp_show_type_prefix_longer); |
| 11479 | } |
| 11480 | |
| 11481 | /* old command */ |
| 11482 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 11483 | show_ipv6_mbgp_prefix_longer_cmd, |
| 11484 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 11485 | SHOW_STR |
| 11486 | IPV6_STR |
| 11487 | MBGP_STR |
| 11488 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 11489 | "Display route and more specific routes\n") |
| 11490 | { |
| 11491 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 11492 | bgp_show_type_prefix_longer); |
| 11493 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 11494 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11495 | DEFUN (show_bgp_ipv4_prefix_longer, |
| 11496 | show_bgp_ipv4_prefix_longer_cmd, |
| 11497 | "show bgp ipv4 A.B.C.D/M longer-prefixes", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11498 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11499 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11500 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11501 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11502 | "Display route and more specific routes\n") |
| 11503 | { |
| 11504 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 11505 | bgp_show_type_prefix_longer); |
| 11506 | } |
| 11507 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11508 | DEFUN (show_bgp_ipv4_safi_flap_prefix_longer, |
| 11509 | show_bgp_ipv4_safi_flap_prefix_longer_cmd, |
| 11510 | "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] | 11511 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11512 | BGP_STR |
| 11513 | "Address family\n" |
| 11514 | "Address Family modifier\n" |
| 11515 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11516 | "Address Family modifier\n" |
| 11517 | "Address Family modifier\n" |
| 11518 | "Display flap statistics of routes\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11519 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11520 | "Display route and more specific routes\n") |
| 11521 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11522 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11523 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11524 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11525 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11526 | return CMD_WARNING; |
| 11527 | } |
| 11528 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11529 | bgp_show_type_flap_prefix_longer); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11530 | } |
| 11531 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11532 | ALIAS (show_bgp_ipv4_safi_flap_prefix_longer, |
| 11533 | show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd, |
| 11534 | "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] | 11535 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11536 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11537 | "Address family\n" |
| 11538 | "Address Family modifier\n" |
| 11539 | "Address Family modifier\n" |
| 11540 | "Address Family modifier\n" |
| 11541 | "Address Family modifier\n" |
| 11542 | "Display detailed information about dampening\n" |
| 11543 | "Display flap statistics of routes\n" |
| 11544 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11545 | "Display route and more specific routes\n") |
| 11546 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11547 | DEFUN (show_bgp_ipv6_safi_flap_prefix_longer, |
| 11548 | show_bgp_ipv6_safi_flap_prefix_longer_cmd, |
| 11549 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes", |
| 11550 | SHOW_STR |
| 11551 | BGP_STR |
| 11552 | "Address family\n" |
| 11553 | "Address Family modifier\n" |
| 11554 | "Address Family modifier\n" |
| 11555 | "Address Family modifier\n" |
| 11556 | "Address Family modifier\n" |
| 11557 | "Display flap statistics of routes\n" |
| 11558 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11559 | "Display route and more specific routes\n") |
| 11560 | { |
| 11561 | safi_t safi; |
| 11562 | |
| 11563 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11564 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11565 | return CMD_WARNING; |
| 11566 | } |
| 11567 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi, |
| 11568 | bgp_show_type_flap_prefix_longer); |
| 11569 | } |
| 11570 | ALIAS (show_bgp_ipv6_safi_flap_prefix_longer, |
| 11571 | show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd, |
| 11572 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes", |
| 11573 | SHOW_STR |
| 11574 | BGP_STR |
| 11575 | "Address family\n" |
| 11576 | "Address Family modifier\n" |
| 11577 | "Address Family modifier\n" |
| 11578 | "Address Family modifier\n" |
| 11579 | "Address Family modifier\n" |
| 11580 | "Display detailed information about dampening\n" |
| 11581 | "Display flap statistics of routes\n" |
| 11582 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11583 | "Display route and more specific routes\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11584 | |
| 11585 | DEFUN (show_bgp_ipv4_safi_prefix_longer, |
| 11586 | show_bgp_ipv4_safi_prefix_longer_cmd, |
| 11587 | "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes", |
| 11588 | SHOW_STR |
| 11589 | BGP_STR |
| 11590 | "Address family\n" |
| 11591 | "Address Family modifier\n" |
| 11592 | "Address Family modifier\n" |
| 11593 | "Address Family modifier\n" |
| 11594 | "Address Family modifier\n" |
| 11595 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11596 | "Display route and more specific routes\n") |
| 11597 | { |
| 11598 | safi_t safi; |
| 11599 | |
| 11600 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11601 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11602 | return CMD_WARNING; |
| 11603 | } |
| 11604 | |
| 11605 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11606 | bgp_show_type_prefix_longer); |
| 11607 | } |
| 11608 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11609 | DEFUN (show_bgp_ipv6_safi_prefix_longer, |
| 11610 | show_bgp_ipv6_safi_prefix_longer_cmd, |
| 11611 | "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes", |
| 11612 | SHOW_STR |
| 11613 | BGP_STR |
| 11614 | "Address family\n" |
| 11615 | "Address Family modifier\n" |
| 11616 | "Address Family modifier\n" |
| 11617 | "Address Family modifier\n" |
| 11618 | "Address Family modifier\n" |
| 11619 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 11620 | "Display route and more specific routes\n") |
| 11621 | { |
| 11622 | safi_t safi; |
| 11623 | |
| 11624 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11625 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11626 | return CMD_WARNING; |
| 11627 | } |
| 11628 | |
| 11629 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi, |
| 11630 | bgp_show_type_prefix_longer); |
| 11631 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11632 | |
| 11633 | DEFUN (show_bgp_ipv4_safi_flap_address, |
| 11634 | show_bgp_ipv4_safi_flap_address_cmd, |
| 11635 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D", |
| 11636 | SHOW_STR |
| 11637 | BGP_STR |
| 11638 | "Address family\n" |
| 11639 | "Address Family modifier\n" |
| 11640 | "Address Family modifier\n" |
| 11641 | "Address Family modifier\n" |
| 11642 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11643 | "Display flap statistics of routes\n" |
| 11644 | "Network in the BGP routing table to display\n") |
| 11645 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11646 | safi_t safi; |
| 11647 | |
| 11648 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11649 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 11650 | return CMD_WARNING; |
| 11651 | } |
| 11652 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11653 | bgp_show_type_flap_address); |
| 11654 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11655 | ALIAS (show_bgp_ipv4_safi_flap_address, |
| 11656 | show_bgp_ipv4_safi_damp_flap_address_cmd, |
| 11657 | "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] | 11658 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11659 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11660 | "Address family\n" |
| 11661 | "Address Family modifier\n" |
| 11662 | "Address Family modifier\n" |
| 11663 | "Address Family modifier\n" |
| 11664 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11665 | "Display detailed information about dampening\n" |
| 11666 | "Display flap statistics of routes\n" |
| 11667 | "Network in the BGP routing table to display\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 11668 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11669 | DEFUN (show_bgp_ipv6_flap_address, |
| 11670 | show_bgp_ipv6_flap_address_cmd, |
| 11671 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11672 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11673 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11674 | "Address family\n" |
| 11675 | "Address Family modifier\n" |
| 11676 | "Address Family modifier\n" |
| 11677 | "Address Family modifier\n" |
| 11678 | "Address Family modifier\n" |
| 11679 | "Display flap statistics of routes\n" |
| 11680 | "Network in the BGP routing table to display\n") |
| 11681 | { |
| 11682 | safi_t safi; |
| 11683 | |
| 11684 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11685 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11686 | return CMD_WARNING; |
| 11687 | } |
| 11688 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi, |
| 11689 | bgp_show_type_flap_address); |
| 11690 | } |
| 11691 | ALIAS (show_bgp_ipv6_flap_address, |
| 11692 | show_bgp_ipv6_damp_flap_address_cmd, |
| 11693 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D", |
| 11694 | SHOW_STR |
| 11695 | BGP_STR |
| 11696 | "Address family\n" |
| 11697 | "Address Family modifier\n" |
| 11698 | "Address Family modifier\n" |
| 11699 | "Address Family modifier\n" |
| 11700 | "Address Family modifier\n" |
| 11701 | "Display detailed information about dampening\n" |
| 11702 | "Display flap statistics of routes\n" |
| 11703 | "Network in the BGP routing table to display\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11704 | |
| 11705 | DEFUN (show_bgp_ipv4_safi_flap_prefix, |
| 11706 | show_bgp_ipv4_safi_flap_prefix_cmd, |
| 11707 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M", |
| 11708 | SHOW_STR |
| 11709 | BGP_STR |
| 11710 | "Address family\n" |
| 11711 | "Address Family modifier\n" |
| 11712 | "Address Family modifier\n" |
| 11713 | "Address Family modifier\n" |
| 11714 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11715 | "Display flap statistics of routes\n" |
| 11716 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11717 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11718 | safi_t safi; |
| 11719 | |
| 11720 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11721 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11722 | return CMD_WARNING; |
| 11723 | } |
| 11724 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11725 | bgp_show_type_flap_prefix); |
| 11726 | } |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11727 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11728 | ALIAS (show_bgp_ipv4_safi_flap_prefix, |
| 11729 | show_bgp_ipv4_safi_damp_flap_prefix_cmd, |
| 11730 | "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] | 11731 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11732 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11733 | "Address family\n" |
| 11734 | "Address Family modifier\n" |
| 11735 | "Address Family modifier\n" |
| 11736 | "Address Family modifier\n" |
| 11737 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 11738 | "Display detailed information about dampening\n" |
| 11739 | "Display flap statistics of routes\n" |
| 11740 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11741 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11742 | DEFUN (show_bgp_ipv6_safi_flap_prefix, |
| 11743 | show_bgp_ipv6_safi_flap_prefix_cmd, |
| 11744 | "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] | 11745 | SHOW_STR |
| 11746 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11747 | "Address family\n" |
| 11748 | "Address Family modifier\n" |
| 11749 | "Address Family modifier\n" |
| 11750 | "Address Family modifier\n" |
| 11751 | "Address Family modifier\n" |
| 11752 | "Display flap statistics of routes\n" |
| 11753 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11754 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11755 | safi_t safi; |
| 11756 | |
| 11757 | if (bgp_parse_safi(argv[0], &safi)) { |
| 11758 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE); |
| 11759 | return CMD_WARNING; |
| 11760 | } |
| 11761 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi, |
| 11762 | bgp_show_type_flap_prefix); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11763 | } |
| 11764 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 11765 | ALIAS (show_bgp_ipv6_safi_flap_prefix, |
| 11766 | show_bgp_ipv6_safi_damp_flap_prefix_cmd, |
| 11767 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M", |
| 11768 | SHOW_STR |
| 11769 | BGP_STR |
| 11770 | "Address family\n" |
| 11771 | "Address Family modifier\n" |
| 11772 | "Address Family modifier\n" |
| 11773 | "Address Family modifier\n" |
| 11774 | "Address Family modifier\n" |
| 11775 | "Display detailed information about dampening\n" |
| 11776 | "Display flap statistics of routes\n" |
| 11777 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11778 | |
| 11779 | DEFUN (show_bgp_ipv6_prefix_longer, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11780 | show_bgp_ipv6_prefix_longer_cmd, |
| 11781 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 11782 | SHOW_STR |
| 11783 | BGP_STR |
| 11784 | "Address family\n" |
| 11785 | "IPv6 prefix <network>/<length>\n" |
| 11786 | "Display route and more specific routes\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11787 | { |
| 11788 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 11789 | bgp_show_type_prefix_longer); |
| 11790 | } |
| 11791 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11792 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11793 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 11794 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11795 | { |
| 11796 | int ret; |
| 11797 | struct bgp *bgp; |
| 11798 | struct peer *peer; |
| 11799 | union sockunion su; |
| 11800 | |
| 11801 | /* BGP structure lookup. */ |
| 11802 | if (view_name) |
| 11803 | { |
| 11804 | bgp = bgp_lookup_by_name (view_name); |
| 11805 | if (! bgp) |
| 11806 | { |
| 11807 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 11808 | return NULL; |
| 11809 | } |
| 11810 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 11811 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11812 | { |
| 11813 | bgp = bgp_get_default (); |
| 11814 | if (! bgp) |
| 11815 | { |
| 11816 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11817 | return NULL; |
| 11818 | } |
| 11819 | } |
| 11820 | |
| 11821 | /* Get peer sockunion. */ |
| 11822 | ret = str2sockunion (ip_str, &su); |
| 11823 | if (ret < 0) |
| 11824 | { |
| 11825 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 11826 | return NULL; |
| 11827 | } |
| 11828 | |
| 11829 | /* Peer structure lookup. */ |
| 11830 | peer = peer_lookup (bgp, &su); |
| 11831 | if (! peer) |
| 11832 | { |
| 11833 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 11834 | return NULL; |
| 11835 | } |
| 11836 | |
| 11837 | return peer; |
| 11838 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11839 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11840 | enum bgp_stats |
| 11841 | { |
| 11842 | BGP_STATS_MAXBITLEN = 0, |
| 11843 | BGP_STATS_RIB, |
| 11844 | BGP_STATS_PREFIXES, |
| 11845 | BGP_STATS_TOTPLEN, |
| 11846 | BGP_STATS_UNAGGREGATEABLE, |
| 11847 | BGP_STATS_MAX_AGGREGATEABLE, |
| 11848 | BGP_STATS_AGGREGATES, |
| 11849 | BGP_STATS_SPACE, |
| 11850 | BGP_STATS_ASPATH_COUNT, |
| 11851 | BGP_STATS_ASPATH_MAXHOPS, |
| 11852 | BGP_STATS_ASPATH_TOTHOPS, |
| 11853 | BGP_STATS_ASPATH_MAXSIZE, |
| 11854 | BGP_STATS_ASPATH_TOTSIZE, |
| 11855 | BGP_STATS_ASN_HIGHEST, |
| 11856 | BGP_STATS_MAX, |
| 11857 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11858 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11859 | static const char *table_stats_strs[] = |
| 11860 | { |
| 11861 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 11862 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 11863 | [BGP_STATS_RIB] = "Total Advertisements", |
| 11864 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 11865 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 11866 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 11867 | [BGP_STATS_SPACE] = "Address space advertised", |
| 11868 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 11869 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 11870 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 11871 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 11872 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 11873 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 11874 | [BGP_STATS_MAX] = NULL, |
| 11875 | }; |
| 11876 | |
| 11877 | struct bgp_table_stats |
| 11878 | { |
| 11879 | struct bgp_table *table; |
| 11880 | unsigned long long counts[BGP_STATS_MAX]; |
| 11881 | }; |
| 11882 | |
| 11883 | #if 0 |
| 11884 | #define TALLY_SIGFIG 100000 |
| 11885 | static unsigned long |
| 11886 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 11887 | { |
| 11888 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 11889 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 11890 | unsigned long ret = newtot / count; |
| 11891 | |
| 11892 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 11893 | return ret + 1; |
| 11894 | else |
| 11895 | return ret; |
| 11896 | } |
| 11897 | #endif |
| 11898 | |
| 11899 | static int |
| 11900 | bgp_table_stats_walker (struct thread *t) |
| 11901 | { |
| 11902 | struct bgp_node *rn; |
| 11903 | struct bgp_node *top; |
| 11904 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 11905 | unsigned int space = 0; |
| 11906 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 11907 | if (!(top = bgp_table_top (ts->table))) |
| 11908 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11909 | |
| 11910 | switch (top->p.family) |
| 11911 | { |
| 11912 | case AF_INET: |
| 11913 | space = IPV4_MAX_BITLEN; |
| 11914 | break; |
| 11915 | case AF_INET6: |
| 11916 | space = IPV6_MAX_BITLEN; |
| 11917 | break; |
| 11918 | } |
| 11919 | |
| 11920 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 11921 | |
| 11922 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 11923 | { |
| 11924 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 11925 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11926 | unsigned int rinum = 0; |
| 11927 | |
| 11928 | if (rn == top) |
| 11929 | continue; |
| 11930 | |
| 11931 | if (!rn->info) |
| 11932 | continue; |
| 11933 | |
| 11934 | ts->counts[BGP_STATS_PREFIXES]++; |
| 11935 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 11936 | |
| 11937 | #if 0 |
| 11938 | ts->counts[BGP_STATS_AVGPLEN] |
| 11939 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 11940 | ts->counts[BGP_STATS_AVGPLEN], |
| 11941 | rn->p.prefixlen); |
| 11942 | #endif |
| 11943 | |
| 11944 | /* check if the prefix is included by any other announcements */ |
| 11945 | while (prn && !prn->info) |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 11946 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11947 | |
| 11948 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 11949 | { |
| 11950 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 11951 | /* announced address space */ |
| 11952 | if (space) |
| 11953 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 11954 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11955 | else if (prn->info) |
| 11956 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 11957 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 11958 | for (ri = rn->info; ri; ri = ri->next) |
| 11959 | { |
| 11960 | rinum++; |
| 11961 | ts->counts[BGP_STATS_RIB]++; |
| 11962 | |
| 11963 | if (ri->attr && |
| 11964 | (CHECK_FLAG (ri->attr->flag, |
| 11965 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 11966 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 11967 | |
| 11968 | /* as-path stats */ |
| 11969 | if (ri->attr && ri->attr->aspath) |
| 11970 | { |
| 11971 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 11972 | unsigned int size = aspath_size (ri->attr->aspath); |
| 11973 | as_t highest = aspath_highest (ri->attr->aspath); |
| 11974 | |
| 11975 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 11976 | |
| 11977 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 11978 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 11979 | |
| 11980 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 11981 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 11982 | |
| 11983 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 11984 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 11985 | #if 0 |
| 11986 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 11987 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 11988 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 11989 | hops); |
| 11990 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 11991 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 11992 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 11993 | size); |
| 11994 | #endif |
| 11995 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 11996 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 11997 | } |
| 11998 | } |
| 11999 | } |
| 12000 | return 0; |
| 12001 | } |
| 12002 | |
| 12003 | static int |
| 12004 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 12005 | { |
| 12006 | struct bgp_table_stats ts; |
| 12007 | unsigned int i; |
| 12008 | |
| 12009 | if (!bgp->rib[afi][safi]) |
| 12010 | { |
Donald Sharp | 3c96404 | 2016-01-25 23:38:53 -0500 | [diff] [blame] | 12011 | vty_out (vty, "%% No RIB exists for the specified AFI(%d)/SAFI(%d) %s", |
| 12012 | afi, safi, VTY_NEWLINE); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12013 | return CMD_WARNING; |
| 12014 | } |
| 12015 | |
| 12016 | memset (&ts, 0, sizeof (ts)); |
| 12017 | ts.table = bgp->rib[afi][safi]; |
| 12018 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 12019 | |
| 12020 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 12021 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 12022 | |
| 12023 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 12024 | { |
| 12025 | if (!table_stats_strs[i]) |
| 12026 | continue; |
| 12027 | |
| 12028 | switch (i) |
| 12029 | { |
| 12030 | #if 0 |
| 12031 | case BGP_STATS_ASPATH_AVGHOPS: |
| 12032 | case BGP_STATS_ASPATH_AVGSIZE: |
| 12033 | case BGP_STATS_AVGPLEN: |
| 12034 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12035 | vty_out (vty, "%12.2f", |
| 12036 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 12037 | break; |
| 12038 | #endif |
| 12039 | case BGP_STATS_ASPATH_TOTHOPS: |
| 12040 | case BGP_STATS_ASPATH_TOTSIZE: |
| 12041 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12042 | vty_out (vty, "%12.2f", |
| 12043 | ts.counts[i] ? |
| 12044 | (float)ts.counts[i] / |
| 12045 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 12046 | : 0); |
| 12047 | break; |
| 12048 | case BGP_STATS_TOTPLEN: |
| 12049 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12050 | vty_out (vty, "%12.2f", |
| 12051 | ts.counts[i] ? |
| 12052 | (float)ts.counts[i] / |
| 12053 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 12054 | : 0); |
| 12055 | break; |
| 12056 | case BGP_STATS_SPACE: |
| 12057 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12058 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 12059 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 12060 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 12061 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12062 | vty_out (vty, "%12.2f%s", |
| 12063 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 12064 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12065 | VTY_NEWLINE); |
| 12066 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 12067 | vty_out (vty, "%12.2f%s", |
| 12068 | (float)ts.counts[BGP_STATS_SPACE] / |
| 12069 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 12070 | VTY_NEWLINE); |
| 12071 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 12072 | break; |
| 12073 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 12074 | vty_out (vty, "%12.2f", |
| 12075 | (float)ts.counts[BGP_STATS_SPACE] / |
| 12076 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 12077 | break; |
| 12078 | default: |
| 12079 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 12080 | vty_out (vty, "%12llu", ts.counts[i]); |
| 12081 | } |
| 12082 | |
| 12083 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12084 | } |
| 12085 | return CMD_SUCCESS; |
| 12086 | } |
| 12087 | |
| 12088 | static int |
| 12089 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 12090 | const char *afi_str, const char *safi_str) |
| 12091 | { |
| 12092 | struct bgp *bgp; |
| 12093 | afi_t afi; |
| 12094 | safi_t safi; |
| 12095 | |
| 12096 | if (name) |
| 12097 | bgp = bgp_lookup_by_name (name); |
| 12098 | else |
| 12099 | bgp = bgp_get_default (); |
| 12100 | |
| 12101 | if (!bgp) |
| 12102 | { |
Lou Berger | bf1ae6c | 2016-01-12 13:42:08 -0500 | [diff] [blame] | 12103 | vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12104 | return CMD_WARNING; |
| 12105 | } |
| 12106 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 12107 | { |
| 12108 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 12109 | afi = AFI_IP; |
| 12110 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 12111 | afi = AFI_IP6; |
| 12112 | else |
| 12113 | { |
| 12114 | vty_out (vty, "%% Invalid address family %s%s", |
| 12115 | afi_str, VTY_NEWLINE); |
| 12116 | return CMD_WARNING; |
| 12117 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12118 | switch (safi_str[0]) { |
| 12119 | case 'm': |
| 12120 | safi = SAFI_MULTICAST; |
| 12121 | break; |
| 12122 | case 'u': |
| 12123 | safi = SAFI_UNICAST; |
| 12124 | break; |
| 12125 | case 'v': |
Donald Sharp | 3c96404 | 2016-01-25 23:38:53 -0500 | [diff] [blame] | 12126 | safi = SAFI_MPLS_VPN; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12127 | break; |
| 12128 | case 'e': |
| 12129 | safi = SAFI_ENCAP; |
| 12130 | break; |
| 12131 | default: |
| 12132 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12133 | safi_str, VTY_NEWLINE); |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12134 | return CMD_WARNING; |
| 12135 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12136 | } |
| 12137 | else |
| 12138 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12139 | vty_out (vty, "%% Invalid address family \"%s\"%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12140 | afi_str, VTY_NEWLINE); |
| 12141 | return CMD_WARNING; |
| 12142 | } |
| 12143 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12144 | return bgp_table_stats (vty, bgp, afi, safi); |
| 12145 | } |
| 12146 | |
| 12147 | DEFUN (show_bgp_statistics, |
| 12148 | show_bgp_statistics_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12149 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12150 | SHOW_STR |
| 12151 | BGP_STR |
| 12152 | "Address family\n" |
| 12153 | "Address family\n" |
| 12154 | "Address Family modifier\n" |
| 12155 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12156 | "Address Family modifier\n" |
| 12157 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12158 | "BGP RIB advertisement statistics\n") |
| 12159 | { |
| 12160 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 12161 | } |
| 12162 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12163 | ALIAS (show_bgp_statistics, |
| 12164 | show_bgp_statistics_vpnv4_cmd, |
| 12165 | "show bgp (ipv4) (vpnv4) statistics", |
| 12166 | SHOW_STR |
| 12167 | BGP_STR |
| 12168 | "Address family\n" |
| 12169 | "Address Family modifier\n" |
| 12170 | "BGP RIB advertisement statistics\n") |
| 12171 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12172 | DEFUN (show_bgp_statistics_view, |
| 12173 | show_bgp_statistics_view_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12174 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12175 | SHOW_STR |
| 12176 | BGP_STR |
| 12177 | "BGP view\n" |
| 12178 | "Address family\n" |
| 12179 | "Address family\n" |
| 12180 | "Address Family modifier\n" |
| 12181 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12182 | "Address Family modifier\n" |
| 12183 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12184 | "BGP RIB advertisement statistics\n") |
| 12185 | { |
| 12186 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 12187 | } |
| 12188 | |
| 12189 | ALIAS (show_bgp_statistics_view, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12190 | show_bgp_statistics_view_vpnv4_cmd, |
| 12191 | "show bgp view WORD (ipv4) (vpnv4) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12192 | SHOW_STR |
| 12193 | BGP_STR |
| 12194 | "BGP view\n" |
| 12195 | "Address family\n" |
| 12196 | "Address Family modifier\n" |
| 12197 | "BGP RIB advertisement statistics\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12198 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12199 | enum bgp_pcounts |
| 12200 | { |
| 12201 | PCOUNT_ADJ_IN = 0, |
| 12202 | PCOUNT_DAMPED, |
| 12203 | PCOUNT_REMOVED, |
| 12204 | PCOUNT_HISTORY, |
| 12205 | PCOUNT_STALE, |
| 12206 | PCOUNT_VALID, |
| 12207 | PCOUNT_ALL, |
| 12208 | PCOUNT_COUNTED, |
| 12209 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 12210 | PCOUNT_MAX, |
| 12211 | }; |
| 12212 | |
| 12213 | static const char *pcount_strs[] = |
| 12214 | { |
| 12215 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 12216 | [PCOUNT_DAMPED] = "Damped", |
| 12217 | [PCOUNT_REMOVED] = "Removed", |
| 12218 | [PCOUNT_HISTORY] = "History", |
| 12219 | [PCOUNT_STALE] = "Stale", |
| 12220 | [PCOUNT_VALID] = "Valid", |
| 12221 | [PCOUNT_ALL] = "All RIB", |
| 12222 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 12223 | [PCOUNT_PFCNT] = "Useable", |
| 12224 | [PCOUNT_MAX] = NULL, |
| 12225 | }; |
| 12226 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12227 | struct peer_pcounts |
| 12228 | { |
| 12229 | unsigned int count[PCOUNT_MAX]; |
| 12230 | const struct peer *peer; |
| 12231 | const struct bgp_table *table; |
| 12232 | }; |
| 12233 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12234 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12235 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12236 | { |
| 12237 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12238 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 12239 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12240 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12241 | 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] | 12242 | { |
| 12243 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12244 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12245 | |
| 12246 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 12247 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12248 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12249 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12250 | for (ri = rn->info; ri; ri = ri->next) |
| 12251 | { |
| 12252 | char buf[SU_ADDRSTRLEN]; |
| 12253 | |
| 12254 | if (ri->peer != peer) |
| 12255 | continue; |
| 12256 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12257 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12258 | |
| 12259 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12260 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12261 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12262 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12263 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12264 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12265 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12266 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12267 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12268 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12269 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12270 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12271 | |
| 12272 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 12273 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12274 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12275 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12276 | plog_warn (peer->log, |
| 12277 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 12278 | peer->host, |
| 12279 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 12280 | buf, SU_ADDRSTRLEN), |
| 12281 | rn->p.prefixlen, |
| 12282 | ri->flags); |
| 12283 | } |
| 12284 | else |
| 12285 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 12286 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12287 | plog_warn (peer->log, |
| 12288 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 12289 | peer->host, |
| 12290 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 12291 | buf, SU_ADDRSTRLEN), |
| 12292 | rn->p.prefixlen, |
| 12293 | ri->flags); |
| 12294 | } |
| 12295 | } |
| 12296 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12297 | return 0; |
| 12298 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12299 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12300 | static int |
| 12301 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 12302 | { |
| 12303 | struct peer_pcounts pcounts = { .peer = peer }; |
| 12304 | unsigned int i; |
| 12305 | |
| 12306 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 12307 | || !peer->bgp->rib[afi][safi]) |
| 12308 | { |
| 12309 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 12310 | return CMD_WARNING; |
| 12311 | } |
| 12312 | |
| 12313 | memset (&pcounts, 0, sizeof(pcounts)); |
| 12314 | pcounts.peer = peer; |
| 12315 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 12316 | |
| 12317 | /* in-place call via thread subsystem so as to record execution time |
| 12318 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 12319 | * on just vty_read()). |
| 12320 | */ |
| 12321 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 12322 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12323 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 12324 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 12325 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 12326 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 12327 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 12328 | |
| 12329 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12330 | vty_out (vty, "%20s: %-10d%s", |
| 12331 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12332 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 12333 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12334 | { |
| 12335 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 12336 | peer->host, VTY_NEWLINE); |
| 12337 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 12338 | VTY_NEWLINE); |
| 12339 | } |
| 12340 | |
| 12341 | return CMD_SUCCESS; |
| 12342 | } |
| 12343 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12344 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 12345 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 12346 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12347 | SHOW_STR |
| 12348 | IP_STR |
| 12349 | BGP_STR |
| 12350 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12351 | "Neighbor to display information about\n" |
| 12352 | "Neighbor to display information about\n" |
| 12353 | "Display detailed prefix count information\n") |
| 12354 | { |
| 12355 | struct peer *peer; |
| 12356 | |
| 12357 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12358 | if (! peer) |
| 12359 | return CMD_WARNING; |
| 12360 | |
| 12361 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 12362 | } |
| 12363 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12364 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 12365 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 12366 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12367 | SHOW_STR |
| 12368 | BGP_STR |
| 12369 | "Address family\n" |
| 12370 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12371 | "Neighbor to display information about\n" |
| 12372 | "Neighbor to display information about\n" |
| 12373 | "Display detailed prefix count information\n") |
| 12374 | { |
| 12375 | struct peer *peer; |
| 12376 | |
| 12377 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12378 | if (! peer) |
| 12379 | return CMD_WARNING; |
| 12380 | |
| 12381 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 12382 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12383 | |
| 12384 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 12385 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 12386 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12387 | SHOW_STR |
| 12388 | IP_STR |
| 12389 | BGP_STR |
| 12390 | "Address family\n" |
| 12391 | "Address Family modifier\n" |
| 12392 | "Address Family modifier\n" |
| 12393 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12394 | "Neighbor to display information about\n" |
| 12395 | "Neighbor to display information about\n" |
| 12396 | "Display detailed prefix count information\n") |
| 12397 | { |
| 12398 | struct peer *peer; |
| 12399 | |
| 12400 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12401 | if (! peer) |
| 12402 | return CMD_WARNING; |
| 12403 | |
| 12404 | if (strncmp (argv[0], "m", 1) == 0) |
| 12405 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 12406 | |
| 12407 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 12408 | } |
| 12409 | |
| 12410 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 12411 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 12412 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12413 | SHOW_STR |
| 12414 | IP_STR |
| 12415 | BGP_STR |
| 12416 | "Address family\n" |
| 12417 | "Address Family modifier\n" |
| 12418 | "Address Family modifier\n" |
| 12419 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12420 | "Neighbor to display information about\n" |
| 12421 | "Neighbor to display information about\n" |
| 12422 | "Display detailed prefix count information\n") |
| 12423 | { |
| 12424 | struct peer *peer; |
| 12425 | |
| 12426 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12427 | if (! peer) |
| 12428 | return CMD_WARNING; |
| 12429 | |
| 12430 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 12431 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12432 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12433 | DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts, |
| 12434 | show_bgp_ipv4_safi_neighbor_prefix_counts_cmd, |
| 12435 | "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] | 12436 | SHOW_STR |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12437 | BGP_STR |
| 12438 | "Address family\n" |
| 12439 | "Address Family modifier\n" |
| 12440 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12441 | "Address Family modifier\n" |
| 12442 | "Address Family modifier\n" |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12443 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12444 | "Neighbor to display information about\n" |
| 12445 | "Neighbor to display information about\n" |
| 12446 | "Display detailed prefix count information\n") |
| 12447 | { |
| 12448 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12449 | safi_t safi; |
| 12450 | |
| 12451 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12452 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12453 | return CMD_WARNING; |
| 12454 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12455 | |
| 12456 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12457 | if (! peer) |
| 12458 | return CMD_WARNING; |
| 12459 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12460 | return bgp_peer_counts (vty, peer, AFI_IP, safi); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12461 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 12462 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12463 | DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts, |
| 12464 | show_bgp_ipv6_safi_neighbor_prefix_counts_cmd, |
| 12465 | "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 12466 | SHOW_STR |
| 12467 | BGP_STR |
| 12468 | "Address family\n" |
| 12469 | "Address Family modifier\n" |
| 12470 | "Address Family modifier\n" |
| 12471 | "Address Family modifier\n" |
| 12472 | "Address Family modifier\n" |
| 12473 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12474 | "Neighbor to display information about\n" |
| 12475 | "Neighbor to display information about\n" |
| 12476 | "Display detailed prefix count information\n") |
| 12477 | { |
| 12478 | struct peer *peer; |
| 12479 | safi_t safi; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12480 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12481 | if (bgp_parse_safi(argv[0], &safi)) { |
| 12482 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 12483 | return CMD_WARNING; |
| 12484 | } |
| 12485 | |
| 12486 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12487 | if (! peer) |
| 12488 | return CMD_WARNING; |
| 12489 | |
| 12490 | return bgp_peer_counts (vty, peer, AFI_IP6, safi); |
| 12491 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12492 | |
| 12493 | DEFUN (show_ip_bgp_encap_neighbor_prefix_counts, |
| 12494 | show_ip_bgp_encap_neighbor_prefix_counts_cmd, |
| 12495 | "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] | 12496 | SHOW_STR |
| 12497 | IP_STR |
| 12498 | BGP_STR |
| 12499 | "Address family\n" |
| 12500 | "Address Family modifier\n" |
| 12501 | "Address Family modifier\n" |
| 12502 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12503 | "Neighbor to display information about\n" |
| 12504 | "Neighbor to display information about\n" |
| 12505 | "Display detailed prefix count information\n") |
| 12506 | { |
| 12507 | struct peer *peer; |
| 12508 | |
| 12509 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12510 | if (! peer) |
| 12511 | return CMD_WARNING; |
| 12512 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12513 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 12514 | } |
| 12515 | |
| 12516 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12517 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12518 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 12519 | int in) |
| 12520 | { |
| 12521 | struct bgp_table *table; |
| 12522 | struct bgp_adj_in *ain; |
| 12523 | struct bgp_adj_out *adj; |
| 12524 | unsigned long output_count; |
| 12525 | struct bgp_node *rn; |
| 12526 | int header1 = 1; |
| 12527 | struct bgp *bgp; |
| 12528 | int header2 = 1; |
| 12529 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12530 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12531 | |
| 12532 | if (! bgp) |
| 12533 | return; |
| 12534 | |
| 12535 | table = bgp->rib[afi][safi]; |
| 12536 | |
| 12537 | output_count = 0; |
| 12538 | |
| 12539 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 12540 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 12541 | { |
| 12542 | 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] | 12543 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12544 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12545 | |
| 12546 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 12547 | VTY_NEWLINE, VTY_NEWLINE); |
| 12548 | header1 = 0; |
| 12549 | } |
| 12550 | |
| 12551 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12552 | if (in) |
| 12553 | { |
| 12554 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 12555 | if (ain->peer == peer) |
| 12556 | { |
| 12557 | if (header1) |
| 12558 | { |
| 12559 | 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] | 12560 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12561 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12562 | header1 = 0; |
| 12563 | } |
| 12564 | if (header2) |
| 12565 | { |
| 12566 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 12567 | header2 = 0; |
| 12568 | } |
| 12569 | if (ain->attr) |
| 12570 | { |
| 12571 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 12572 | output_count++; |
| 12573 | } |
| 12574 | } |
| 12575 | } |
| 12576 | else |
| 12577 | { |
| 12578 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 12579 | if (adj->peer == peer) |
| 12580 | { |
| 12581 | if (header1) |
| 12582 | { |
| 12583 | 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] | 12584 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 12585 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12586 | header1 = 0; |
| 12587 | } |
| 12588 | if (header2) |
| 12589 | { |
| 12590 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 12591 | header2 = 0; |
| 12592 | } |
| 12593 | if (adj->attr) |
| 12594 | { |
| 12595 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 12596 | output_count++; |
| 12597 | } |
| 12598 | } |
| 12599 | } |
| 12600 | |
| 12601 | if (output_count != 0) |
| 12602 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 12603 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 12604 | } |
| 12605 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12606 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 12607 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 12608 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12609 | if (! peer || ! peer->afc[afi][safi]) |
| 12610 | { |
| 12611 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 12612 | return CMD_WARNING; |
| 12613 | } |
| 12614 | |
| 12615 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 12616 | { |
| 12617 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 12618 | VTY_NEWLINE); |
| 12619 | return CMD_WARNING; |
| 12620 | } |
| 12621 | |
| 12622 | show_adj_route (vty, peer, afi, safi, in); |
| 12623 | |
| 12624 | return CMD_SUCCESS; |
| 12625 | } |
| 12626 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12627 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 12628 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 12629 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12630 | SHOW_STR |
| 12631 | IP_STR |
| 12632 | BGP_STR |
| 12633 | "BGP view\n" |
| 12634 | "View name\n" |
| 12635 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12636 | "Neighbor to display information about\n" |
| 12637 | "Neighbor to display information about\n" |
| 12638 | "Display the routes advertised to a BGP neighbor\n") |
| 12639 | { |
| 12640 | struct peer *peer; |
| 12641 | |
| 12642 | if (argc == 2) |
| 12643 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12644 | else |
| 12645 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12646 | |
| 12647 | if (! peer) |
| 12648 | return CMD_WARNING; |
| 12649 | |
| 12650 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 12651 | } |
| 12652 | |
| 12653 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
| 12654 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 12655 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12656 | SHOW_STR |
| 12657 | IP_STR |
| 12658 | BGP_STR |
| 12659 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12660 | "Neighbor to display information about\n" |
| 12661 | "Neighbor to display information about\n" |
| 12662 | "Display the routes advertised to a BGP neighbor\n") |
| 12663 | |
| 12664 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 12665 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 12666 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12667 | SHOW_STR |
| 12668 | IP_STR |
| 12669 | BGP_STR |
| 12670 | "Address family\n" |
| 12671 | "Address Family modifier\n" |
| 12672 | "Address Family modifier\n" |
| 12673 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12674 | "Neighbor to display information about\n" |
| 12675 | "Neighbor to display information about\n" |
| 12676 | "Display the routes advertised to a BGP neighbor\n") |
| 12677 | { |
| 12678 | struct peer *peer; |
| 12679 | |
| 12680 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12681 | if (! peer) |
| 12682 | return CMD_WARNING; |
| 12683 | |
| 12684 | if (strncmp (argv[0], "m", 1) == 0) |
| 12685 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 12686 | |
| 12687 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 12688 | } |
| 12689 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12690 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 12691 | show_bgp_view_neighbor_advertised_route_cmd, |
| 12692 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12693 | SHOW_STR |
| 12694 | BGP_STR |
| 12695 | "BGP view\n" |
| 12696 | "View name\n" |
| 12697 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12698 | "Neighbor to display information about\n" |
| 12699 | "Neighbor to display information about\n" |
| 12700 | "Display the routes advertised to a BGP neighbor\n") |
| 12701 | { |
| 12702 | struct peer *peer; |
| 12703 | |
| 12704 | if (argc == 2) |
| 12705 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12706 | else |
| 12707 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12708 | |
| 12709 | if (! peer) |
| 12710 | return CMD_WARNING; |
| 12711 | |
| 12712 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 12713 | } |
| 12714 | |
| 12715 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 12716 | show_bgp_view_neighbor_received_routes_cmd, |
| 12717 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12718 | SHOW_STR |
| 12719 | BGP_STR |
| 12720 | "BGP view\n" |
| 12721 | "View name\n" |
| 12722 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12723 | "Neighbor to display information about\n" |
| 12724 | "Neighbor to display information about\n" |
| 12725 | "Display the received routes from neighbor\n") |
| 12726 | { |
| 12727 | struct peer *peer; |
| 12728 | |
| 12729 | if (argc == 2) |
| 12730 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12731 | else |
| 12732 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12733 | |
| 12734 | if (! peer) |
| 12735 | return CMD_WARNING; |
| 12736 | |
| 12737 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 12738 | } |
| 12739 | |
| 12740 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12741 | show_bgp_neighbor_advertised_route_cmd, |
| 12742 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12743 | SHOW_STR |
| 12744 | BGP_STR |
| 12745 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12746 | "Neighbor to display information about\n" |
| 12747 | "Neighbor to display information about\n" |
| 12748 | "Display the routes advertised to a BGP neighbor\n") |
| 12749 | |
| 12750 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12751 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 12752 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12753 | SHOW_STR |
| 12754 | BGP_STR |
| 12755 | "Address family\n" |
| 12756 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12757 | "Neighbor to display information about\n" |
| 12758 | "Neighbor to display information about\n" |
| 12759 | "Display the routes advertised to a BGP neighbor\n") |
| 12760 | |
| 12761 | /* old command */ |
| 12762 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 12763 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 12764 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12765 | SHOW_STR |
| 12766 | IPV6_STR |
| 12767 | BGP_STR |
| 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 | /* old command */ |
| 12774 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 12775 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 12776 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 12777 | SHOW_STR |
| 12778 | IPV6_STR |
| 12779 | MBGP_STR |
| 12780 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12781 | "Neighbor to display information about\n" |
| 12782 | "Neighbor to display information about\n" |
| 12783 | "Display the routes advertised to a BGP neighbor\n") |
| 12784 | { |
| 12785 | struct peer *peer; |
| 12786 | |
| 12787 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12788 | if (! peer) |
| 12789 | return CMD_WARNING; |
| 12790 | |
| 12791 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
| 12792 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 12793 | |
| 12794 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 12795 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 12796 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12797 | SHOW_STR |
| 12798 | IP_STR |
| 12799 | BGP_STR |
| 12800 | "BGP view\n" |
| 12801 | "View name\n" |
| 12802 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12803 | "Neighbor to display information about\n" |
| 12804 | "Neighbor to display information about\n" |
| 12805 | "Display the received routes from neighbor\n") |
| 12806 | { |
| 12807 | struct peer *peer; |
| 12808 | |
| 12809 | if (argc == 2) |
| 12810 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 12811 | else |
| 12812 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12813 | |
| 12814 | if (! peer) |
| 12815 | return CMD_WARNING; |
| 12816 | |
| 12817 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 12818 | } |
| 12819 | |
| 12820 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
| 12821 | show_ip_bgp_neighbor_received_routes_cmd, |
| 12822 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12823 | SHOW_STR |
| 12824 | IP_STR |
| 12825 | BGP_STR |
| 12826 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12827 | "Neighbor to display information about\n" |
| 12828 | "Neighbor to display information about\n" |
| 12829 | "Display the received routes from neighbor\n") |
| 12830 | |
| 12831 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 12832 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 12833 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12834 | SHOW_STR |
| 12835 | BGP_STR |
| 12836 | "Address family\n" |
| 12837 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12838 | "Neighbor to display information about\n" |
| 12839 | "Neighbor to display information about\n" |
| 12840 | "Display the received routes from neighbor\n") |
| 12841 | |
| 12842 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 12843 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 12844 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12845 | SHOW_STR |
| 12846 | BGP_STR |
| 12847 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12848 | "Neighbor to display information about\n" |
| 12849 | "Neighbor to display information about\n" |
| 12850 | "Display information received from a BGP neighbor\n" |
| 12851 | "Display the prefixlist filter\n") |
| 12852 | { |
| 12853 | char name[BUFSIZ]; |
| 12854 | union sockunion su; |
| 12855 | struct peer *peer; |
| 12856 | int count, ret; |
| 12857 | |
| 12858 | ret = str2sockunion (argv[0], &su); |
| 12859 | if (ret < 0) |
| 12860 | { |
| 12861 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 12862 | return CMD_WARNING; |
| 12863 | } |
| 12864 | |
| 12865 | peer = peer_lookup (NULL, &su); |
| 12866 | if (! peer) |
| 12867 | return CMD_WARNING; |
| 12868 | |
| 12869 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 12870 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 12871 | if (count) |
| 12872 | { |
| 12873 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 12874 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 12875 | } |
| 12876 | |
| 12877 | return CMD_SUCCESS; |
| 12878 | } |
| 12879 | |
| 12880 | /* old command */ |
| 12881 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 12882 | ipv6_bgp_neighbor_received_routes_cmd, |
| 12883 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12884 | SHOW_STR |
| 12885 | IPV6_STR |
| 12886 | BGP_STR |
| 12887 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12888 | "Neighbor to display information about\n" |
| 12889 | "Neighbor to display information about\n" |
| 12890 | "Display the received routes from neighbor\n") |
| 12891 | |
| 12892 | /* old command */ |
| 12893 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 12894 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 12895 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12896 | SHOW_STR |
| 12897 | IPV6_STR |
| 12898 | MBGP_STR |
| 12899 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12900 | "Neighbor to display information about\n" |
| 12901 | "Neighbor to display information about\n" |
| 12902 | "Display the received routes from neighbor\n") |
| 12903 | { |
| 12904 | struct peer *peer; |
| 12905 | |
| 12906 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 12907 | if (! peer) |
| 12908 | return CMD_WARNING; |
| 12909 | |
| 12910 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
| 12911 | } |
| 12912 | |
| 12913 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 12914 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 12915 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 12916 | SHOW_STR |
| 12917 | BGP_STR |
| 12918 | "BGP view\n" |
| 12919 | "View name\n" |
| 12920 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12921 | "Neighbor to display information about\n" |
| 12922 | "Neighbor to display information about\n" |
| 12923 | "Display information received from a BGP neighbor\n" |
| 12924 | "Display the prefixlist filter\n") |
| 12925 | { |
| 12926 | char name[BUFSIZ]; |
| 12927 | union sockunion su; |
| 12928 | struct peer *peer; |
| 12929 | struct bgp *bgp; |
| 12930 | int count, ret; |
| 12931 | |
| 12932 | /* BGP structure lookup. */ |
| 12933 | bgp = bgp_lookup_by_name (argv[0]); |
| 12934 | if (bgp == NULL) |
| 12935 | { |
| 12936 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 12937 | return CMD_WARNING; |
| 12938 | } |
| 12939 | |
| 12940 | ret = str2sockunion (argv[1], &su); |
| 12941 | if (ret < 0) |
| 12942 | { |
| 12943 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 12944 | return CMD_WARNING; |
| 12945 | } |
| 12946 | |
| 12947 | peer = peer_lookup (bgp, &su); |
| 12948 | if (! peer) |
| 12949 | return CMD_WARNING; |
| 12950 | |
| 12951 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 12952 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 12953 | if (count) |
| 12954 | { |
| 12955 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 12956 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 12957 | } |
| 12958 | |
| 12959 | return CMD_SUCCESS; |
| 12960 | } |
| 12961 | |
| 12962 | |
| 12963 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 12964 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 12965 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 12966 | SHOW_STR |
| 12967 | IP_STR |
| 12968 | BGP_STR |
| 12969 | "Address family\n" |
| 12970 | "Address Family modifier\n" |
| 12971 | "Address Family modifier\n" |
| 12972 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12973 | "Neighbor to display information about\n" |
| 12974 | "Neighbor to display information about\n" |
| 12975 | "Display the received routes from neighbor\n") |
| 12976 | { |
| 12977 | struct peer *peer; |
| 12978 | |
| 12979 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 12980 | if (! peer) |
| 12981 | return CMD_WARNING; |
| 12982 | |
| 12983 | if (strncmp (argv[0], "m", 1) == 0) |
| 12984 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 12985 | |
| 12986 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 12987 | } |
| 12988 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12989 | DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route, |
| 12990 | show_bgp_ipv4_safi_neighbor_advertised_route_cmd, |
| 12991 | "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] | 12992 | SHOW_STR |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12993 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 12994 | "Address Family modifier\n" |
| 12995 | "Address Family modifier\n" |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12996 | "Detailed information on TCP and BGP neighbor connections\n" |
| 12997 | "Neighbor to display information about\n" |
| 12998 | "Neighbor to display information about\n" |
| 12999 | "Display the routes advertised to a BGP neighbor\n") |
| 13000 | { |
| 13001 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13002 | safi_t safi; |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13003 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13004 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13005 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13006 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13007 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13008 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13009 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13010 | if (! peer) |
| 13011 | return CMD_WARNING; |
| 13012 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13013 | return peer_adj_routes (vty, peer, AFI_IP, safi, 0); |
| 13014 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13015 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13016 | DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route, |
| 13017 | show_bgp_ipv6_safi_neighbor_advertised_route_cmd, |
| 13018 | "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 13019 | SHOW_STR |
| 13020 | BGP_STR |
| 13021 | "Address Family modifier\n" |
| 13022 | "Address Family modifier\n" |
| 13023 | "Address Family modifier\n" |
| 13024 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13025 | "Neighbor to display information about\n" |
| 13026 | "Neighbor to display information about\n" |
| 13027 | "Display the routes advertised to a BGP neighbor\n") |
| 13028 | { |
| 13029 | struct peer *peer; |
| 13030 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13031 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13032 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13033 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13034 | return CMD_WARNING; |
| 13035 | } |
| 13036 | |
| 13037 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13038 | if (! peer) |
| 13039 | return CMD_WARNING; |
| 13040 | |
| 13041 | return peer_adj_routes (vty, peer, AFI_IP6, safi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13042 | } |
| 13043 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13044 | DEFUN (show_bgp_view_ipv6_neighbor_advertised_route, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13045 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 13046 | "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] | 13047 | SHOW_STR |
| 13048 | BGP_STR |
| 13049 | "BGP view\n" |
| 13050 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13051 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13052 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13053 | "Neighbor to display information about\n" |
| 13054 | "Neighbor to display information about\n" |
| 13055 | "Display the routes advertised to a BGP neighbor\n") |
| 13056 | { |
| 13057 | struct peer *peer; |
| 13058 | |
| 13059 | if (argc == 2) |
| 13060 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13061 | else |
| 13062 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13063 | |
| 13064 | if (! peer) |
| 13065 | return CMD_WARNING; |
| 13066 | |
| 13067 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 13068 | } |
| 13069 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13070 | DEFUN (show_bgp_view_ipv6_neighbor_received_routes, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13071 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 13072 | "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] | 13073 | SHOW_STR |
| 13074 | BGP_STR |
| 13075 | "BGP view\n" |
| 13076 | "View name\n" |
| 13077 | "Address family\n" |
| 13078 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13079 | "Neighbor to display information about\n" |
| 13080 | "Neighbor to display information about\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13081 | "Display the received routes from neighbor\n") |
| 13082 | { |
| 13083 | struct peer *peer; |
| 13084 | |
| 13085 | if (argc == 2) |
| 13086 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13087 | else |
| 13088 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13089 | |
| 13090 | if (! peer) |
| 13091 | return CMD_WARNING; |
| 13092 | |
| 13093 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 13094 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13095 | |
| 13096 | DEFUN (show_bgp_ipv4_safi_neighbor_received_routes, |
| 13097 | show_bgp_ipv4_safi_neighbor_received_routes_cmd, |
| 13098 | "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] | 13099 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13100 | BGP_STR |
| 13101 | "Address family\n" |
| 13102 | "Address Family modifier\n" |
| 13103 | "Address Family modifier\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13104 | "Address Family modifier\n" |
| 13105 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13106 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13107 | "Neighbor to display information about\n" |
| 13108 | "Neighbor to display information about\n" |
| 13109 | "Display the received routes from neighbor\n") |
| 13110 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13111 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13112 | safi_t safi; |
| 13113 | |
| 13114 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13115 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13116 | return CMD_WARNING; |
| 13117 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13118 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13119 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13120 | if (! peer) |
| 13121 | return CMD_WARNING; |
| 13122 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13123 | return peer_adj_routes (vty, peer, AFI_IP, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13124 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13125 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13126 | DEFUN (show_bgp_ipv6_safi_neighbor_received_routes, |
| 13127 | show_bgp_ipv6_safi_neighbor_received_routes_cmd, |
| 13128 | "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 13129 | SHOW_STR |
| 13130 | BGP_STR |
| 13131 | "Address family\n" |
| 13132 | "Address Family modifier\n" |
| 13133 | "Address Family modifier\n" |
| 13134 | "Address Family modifier\n" |
| 13135 | "Address Family modifier\n" |
| 13136 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13137 | "Neighbor to display information about\n" |
| 13138 | "Neighbor to display information about\n" |
| 13139 | "Display the received routes from neighbor\n") |
| 13140 | { |
| 13141 | struct peer *peer; |
| 13142 | safi_t safi; |
| 13143 | |
| 13144 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13145 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13146 | return CMD_WARNING; |
| 13147 | } |
| 13148 | |
| 13149 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13150 | if (! peer) |
| 13151 | return CMD_WARNING; |
| 13152 | |
| 13153 | return peer_adj_routes (vty, peer, AFI_IP6, safi, 1); |
| 13154 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13155 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13156 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 13157 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13158 | "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] | 13159 | SHOW_STR |
| 13160 | BGP_STR |
| 13161 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 13162 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13163 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13164 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13165 | "Address family modifier\n" |
| 13166 | "Address family modifier\n" |
| 13167 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13168 | "Neighbor to display information about\n" |
| 13169 | "Neighbor to display information about\n" |
| 13170 | "Display the advertised routes to neighbor\n" |
| 13171 | "Display the received routes from neighbor\n") |
| 13172 | { |
| 13173 | int afi; |
| 13174 | int safi; |
| 13175 | int in; |
| 13176 | struct peer *peer; |
| 13177 | |
David Lamparter | 94bad67 | 2015-03-03 08:52:22 +0100 | [diff] [blame] | 13178 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13179 | |
| 13180 | if (! peer) |
| 13181 | return CMD_WARNING; |
| 13182 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13183 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 13184 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13185 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13186 | |
| 13187 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 13188 | } |
| 13189 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13190 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 13191 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 13192 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 13193 | SHOW_STR |
| 13194 | IP_STR |
| 13195 | BGP_STR |
| 13196 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13197 | "Neighbor to display information about\n" |
| 13198 | "Neighbor to display information about\n" |
| 13199 | "Display information received from a BGP neighbor\n" |
| 13200 | "Display the prefixlist filter\n") |
| 13201 | { |
| 13202 | char name[BUFSIZ]; |
| 13203 | union sockunion su; |
| 13204 | struct peer *peer; |
| 13205 | int count, ret; |
| 13206 | |
| 13207 | ret = str2sockunion (argv[0], &su); |
| 13208 | if (ret < 0) |
| 13209 | { |
| 13210 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 13211 | return CMD_WARNING; |
| 13212 | } |
| 13213 | |
| 13214 | peer = peer_lookup (NULL, &su); |
| 13215 | if (! peer) |
| 13216 | return CMD_WARNING; |
| 13217 | |
| 13218 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 13219 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13220 | if (count) |
| 13221 | { |
| 13222 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 13223 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13224 | } |
| 13225 | |
| 13226 | return CMD_SUCCESS; |
| 13227 | } |
| 13228 | |
| 13229 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 13230 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 13231 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 13232 | SHOW_STR |
| 13233 | IP_STR |
| 13234 | BGP_STR |
| 13235 | "Address family\n" |
| 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 information received from a BGP neighbor\n" |
| 13242 | "Display the prefixlist filter\n") |
| 13243 | { |
| 13244 | char name[BUFSIZ]; |
| 13245 | union sockunion su; |
| 13246 | struct peer *peer; |
| 13247 | int count, ret; |
| 13248 | |
| 13249 | ret = str2sockunion (argv[1], &su); |
| 13250 | if (ret < 0) |
| 13251 | { |
| 13252 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13253 | return CMD_WARNING; |
| 13254 | } |
| 13255 | |
| 13256 | peer = peer_lookup (NULL, &su); |
| 13257 | if (! peer) |
| 13258 | return CMD_WARNING; |
| 13259 | |
| 13260 | if (strncmp (argv[0], "m", 1) == 0) |
| 13261 | { |
| 13262 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 13263 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13264 | if (count) |
| 13265 | { |
| 13266 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 13267 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13268 | } |
| 13269 | } |
| 13270 | else |
| 13271 | { |
| 13272 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 13273 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13274 | if (count) |
| 13275 | { |
| 13276 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 13277 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13278 | } |
| 13279 | } |
| 13280 | |
| 13281 | return CMD_SUCCESS; |
| 13282 | } |
| 13283 | |
| 13284 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 13285 | show_bgp_neighbor_received_routes_cmd, |
| 13286 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 13287 | SHOW_STR |
| 13288 | BGP_STR |
| 13289 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13290 | "Neighbor to display information about\n" |
| 13291 | "Neighbor to display information about\n" |
| 13292 | "Display the received routes from neighbor\n") |
| 13293 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13294 | DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter, |
| 13295 | show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd, |
| 13296 | "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] | 13297 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13298 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13299 | IP_STR |
| 13300 | "Address Family modifier\n" |
| 13301 | "Address Family modifier\n" |
| 13302 | "Address Family modifier\n" |
| 13303 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13304 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13305 | "Neighbor to display information about\n" |
| 13306 | "Neighbor to display information about\n" |
| 13307 | "Display information received from a BGP neighbor\n" |
| 13308 | "Display the prefixlist filter\n") |
| 13309 | { |
| 13310 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13311 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13312 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13313 | int count, ret; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13314 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13315 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13316 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13317 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13318 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13319 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13320 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13321 | ret = str2sockunion (argv[1], &su); |
| 13322 | if (ret < 0) |
| 13323 | { |
| 13324 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13325 | return CMD_WARNING; |
| 13326 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13327 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13328 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13329 | if (! peer) |
| 13330 | return CMD_WARNING; |
| 13331 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13332 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi); |
| 13333 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 13334 | if (count) { |
| 13335 | vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE); |
| 13336 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 13337 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13338 | |
| 13339 | return CMD_SUCCESS; |
| 13340 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13341 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13342 | DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter, |
| 13343 | show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd, |
| 13344 | "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] | 13345 | SHOW_STR |
| 13346 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13347 | IP_STR |
| 13348 | "Address Family modifier\n" |
| 13349 | "Address Family modifier\n" |
| 13350 | "Address Family modifier\n" |
| 13351 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13352 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13353 | "Neighbor to display information about\n" |
| 13354 | "Neighbor to display information about\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13355 | "Display information received from a BGP neighbor\n" |
| 13356 | "Display the prefixlist filter\n") |
| 13357 | { |
| 13358 | char name[BUFSIZ]; |
| 13359 | union sockunion su; |
| 13360 | struct peer *peer; |
| 13361 | int count, ret; |
| 13362 | safi_t safi; |
| 13363 | |
| 13364 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13365 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13366 | return CMD_WARNING; |
| 13367 | } |
| 13368 | |
| 13369 | ret = str2sockunion (argv[1], &su); |
| 13370 | if (ret < 0) |
| 13371 | { |
| 13372 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13373 | return CMD_WARNING; |
| 13374 | } |
| 13375 | |
| 13376 | peer = peer_lookup (NULL, &su); |
| 13377 | if (! peer) |
| 13378 | return CMD_WARNING; |
| 13379 | |
| 13380 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi); |
| 13381 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13382 | if (count) { |
| 13383 | vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE); |
| 13384 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13385 | } |
| 13386 | |
| 13387 | return CMD_SUCCESS; |
| 13388 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13389 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13390 | DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13391 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 13392 | "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] | 13393 | SHOW_STR |
| 13394 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13395 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13396 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13397 | "Neighbor to display information about\n" |
| 13398 | "Neighbor to display information about\n" |
| 13399 | "Display information received from a BGP neighbor\n" |
| 13400 | "Display the prefixlist filter\n") |
| 13401 | { |
| 13402 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13403 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13404 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13405 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13406 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13407 | ret = str2sockunion (argv[0], &su); |
| 13408 | if (ret < 0) |
| 13409 | { |
| 13410 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 13411 | return CMD_WARNING; |
| 13412 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13413 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13414 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13415 | if (! peer) |
| 13416 | return CMD_WARNING; |
| 13417 | |
| 13418 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 13419 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13420 | if (count) |
| 13421 | { |
| 13422 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 13423 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13424 | } |
| 13425 | |
| 13426 | return CMD_SUCCESS; |
| 13427 | } |
| 13428 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13429 | DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13430 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 13431 | "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] | 13432 | SHOW_STR |
| 13433 | BGP_STR |
| 13434 | "BGP view\n" |
| 13435 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13436 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13437 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13438 | "Neighbor to display information about\n" |
| 13439 | "Neighbor to display information about\n" |
| 13440 | "Display information received from a BGP neighbor\n" |
| 13441 | "Display the prefixlist filter\n") |
| 13442 | { |
| 13443 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13444 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13445 | struct peer *peer; |
| 13446 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13447 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13448 | |
| 13449 | /* BGP structure lookup. */ |
| 13450 | bgp = bgp_lookup_by_name (argv[0]); |
| 13451 | if (bgp == NULL) |
| 13452 | { |
| 13453 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13454 | return CMD_WARNING; |
| 13455 | } |
| 13456 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13457 | ret = str2sockunion (argv[1], &su); |
| 13458 | if (ret < 0) |
| 13459 | { |
| 13460 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 13461 | return CMD_WARNING; |
| 13462 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13463 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 13464 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13465 | if (! peer) |
| 13466 | return CMD_WARNING; |
| 13467 | |
| 13468 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 13469 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 13470 | if (count) |
| 13471 | { |
| 13472 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 13473 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 13474 | } |
| 13475 | |
| 13476 | return CMD_SUCCESS; |
| 13477 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 13478 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 13479 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13480 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13481 | safi_t safi, enum bgp_show_type type) |
| 13482 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13483 | if (! peer || ! peer->afc[afi][safi]) |
| 13484 | { |
| 13485 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13486 | return CMD_WARNING; |
| 13487 | } |
| 13488 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 13489 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13490 | } |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13491 | DEFUN (show_ip_bgp_neighbor_routes, |
| 13492 | show_ip_bgp_neighbor_routes_cmd, |
| 13493 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 13494 | SHOW_STR |
| 13495 | IP_STR |
| 13496 | BGP_STR |
| 13497 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13498 | "Neighbor to display information about\n" |
| 13499 | "Neighbor to display information about\n" |
| 13500 | "Display routes learned from neighbor\n") |
| 13501 | { |
| 13502 | struct peer *peer; |
| 13503 | |
| 13504 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13505 | if (! peer) |
| 13506 | return CMD_WARNING; |
| 13507 | |
| 13508 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13509 | bgp_show_type_neighbor); |
| 13510 | } |
| 13511 | |
| 13512 | DEFUN (show_ip_bgp_neighbor_flap, |
| 13513 | show_ip_bgp_neighbor_flap_cmd, |
| 13514 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 13515 | SHOW_STR |
| 13516 | IP_STR |
| 13517 | BGP_STR |
| 13518 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13519 | "Neighbor to display information about\n" |
| 13520 | "Neighbor to display information about\n" |
| 13521 | "Display flap statistics of the routes learned from neighbor\n") |
| 13522 | { |
| 13523 | struct peer *peer; |
| 13524 | |
| 13525 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13526 | if (! peer) |
| 13527 | return CMD_WARNING; |
| 13528 | |
| 13529 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13530 | bgp_show_type_flap_neighbor); |
| 13531 | } |
| 13532 | |
| 13533 | DEFUN (show_ip_bgp_neighbor_damp, |
| 13534 | show_ip_bgp_neighbor_damp_cmd, |
| 13535 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 13536 | SHOW_STR |
| 13537 | IP_STR |
| 13538 | BGP_STR |
| 13539 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13540 | "Neighbor to display information about\n" |
| 13541 | "Neighbor to display information about\n" |
| 13542 | "Display the dampened routes received from neighbor\n") |
| 13543 | { |
| 13544 | struct peer *peer; |
| 13545 | |
| 13546 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13547 | if (! peer) |
| 13548 | return CMD_WARNING; |
| 13549 | |
| 13550 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13551 | bgp_show_type_damp_neighbor); |
| 13552 | } |
| 13553 | |
| 13554 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 13555 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 13556 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 13557 | SHOW_STR |
| 13558 | IP_STR |
| 13559 | BGP_STR |
| 13560 | "Address family\n" |
| 13561 | "Address Family modifier\n" |
| 13562 | "Address Family modifier\n" |
| 13563 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13564 | "Neighbor to display information about\n" |
| 13565 | "Neighbor to display information about\n" |
| 13566 | "Display routes learned from neighbor\n") |
| 13567 | { |
| 13568 | struct peer *peer; |
| 13569 | |
| 13570 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13571 | if (! peer) |
| 13572 | return CMD_WARNING; |
| 13573 | |
| 13574 | if (strncmp (argv[0], "m", 1) == 0) |
| 13575 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
| 13576 | bgp_show_type_neighbor); |
| 13577 | |
| 13578 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
| 13579 | bgp_show_type_neighbor); |
| 13580 | } |
| 13581 | |
| 13582 | DEFUN (show_ip_bgp_view_rsclient, |
| 13583 | show_ip_bgp_view_rsclient_cmd, |
| 13584 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 13585 | SHOW_STR |
| 13586 | IP_STR |
| 13587 | BGP_STR |
| 13588 | "BGP view\n" |
| 13589 | "View name\n" |
| 13590 | "Information about Route Server Client\n" |
| 13591 | NEIGHBOR_ADDR_STR) |
| 13592 | { |
| 13593 | struct bgp_table *table; |
| 13594 | struct peer *peer; |
| 13595 | |
| 13596 | if (argc == 2) |
| 13597 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13598 | else |
| 13599 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13600 | |
| 13601 | if (! peer) |
| 13602 | return CMD_WARNING; |
| 13603 | |
| 13604 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 13605 | { |
| 13606 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13607 | VTY_NEWLINE); |
| 13608 | return CMD_WARNING; |
| 13609 | } |
| 13610 | |
| 13611 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 13612 | PEER_FLAG_RSERVER_CLIENT)) |
| 13613 | { |
| 13614 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13615 | VTY_NEWLINE); |
| 13616 | return CMD_WARNING; |
| 13617 | } |
| 13618 | |
| 13619 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 13620 | |
| 13621 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 13622 | } |
| 13623 | |
| 13624 | ALIAS (show_ip_bgp_view_rsclient, |
| 13625 | show_ip_bgp_rsclient_cmd, |
| 13626 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 13627 | SHOW_STR |
| 13628 | IP_STR |
| 13629 | BGP_STR |
| 13630 | "Information about Route Server Client\n" |
| 13631 | NEIGHBOR_ADDR_STR) |
| 13632 | |
| 13633 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 13634 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 13635 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 13636 | SHOW_STR |
| 13637 | BGP_STR |
| 13638 | "BGP view\n" |
| 13639 | "View name\n" |
| 13640 | "Address family\n" |
| 13641 | "Address Family modifier\n" |
| 13642 | "Address Family modifier\n" |
| 13643 | "Information about Route Server Client\n" |
| 13644 | NEIGHBOR_ADDR_STR) |
| 13645 | { |
| 13646 | struct bgp_table *table; |
| 13647 | struct peer *peer; |
| 13648 | safi_t safi; |
| 13649 | |
| 13650 | if (argc == 3) { |
| 13651 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 13652 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13653 | } else { |
| 13654 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13655 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13656 | } |
| 13657 | |
| 13658 | if (! peer) |
| 13659 | return CMD_WARNING; |
| 13660 | |
| 13661 | if (! peer->afc[AFI_IP][safi]) |
| 13662 | { |
| 13663 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13664 | VTY_NEWLINE); |
| 13665 | return CMD_WARNING; |
| 13666 | } |
| 13667 | |
| 13668 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 13669 | PEER_FLAG_RSERVER_CLIENT)) |
| 13670 | { |
| 13671 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13672 | VTY_NEWLINE); |
| 13673 | return CMD_WARNING; |
| 13674 | } |
| 13675 | |
| 13676 | table = peer->rib[AFI_IP][safi]; |
| 13677 | |
| 13678 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 13679 | } |
| 13680 | |
| 13681 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 13682 | show_bgp_ipv4_safi_rsclient_cmd, |
| 13683 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 13684 | SHOW_STR |
| 13685 | BGP_STR |
| 13686 | "Address family\n" |
| 13687 | "Address Family modifier\n" |
| 13688 | "Address Family modifier\n" |
| 13689 | "Information about Route Server Client\n" |
| 13690 | NEIGHBOR_ADDR_STR) |
| 13691 | |
| 13692 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 13693 | show_ip_bgp_view_rsclient_route_cmd, |
| 13694 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13695 | SHOW_STR |
| 13696 | IP_STR |
| 13697 | BGP_STR |
| 13698 | "BGP view\n" |
| 13699 | "View name\n" |
| 13700 | "Information about Route Server Client\n" |
| 13701 | NEIGHBOR_ADDR_STR |
| 13702 | "Network in the BGP routing table to display\n") |
| 13703 | { |
| 13704 | struct bgp *bgp; |
| 13705 | struct peer *peer; |
| 13706 | |
| 13707 | /* BGP structure lookup. */ |
| 13708 | if (argc == 3) |
| 13709 | { |
| 13710 | bgp = bgp_lookup_by_name (argv[0]); |
| 13711 | if (bgp == NULL) |
| 13712 | { |
| 13713 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13714 | return CMD_WARNING; |
| 13715 | } |
| 13716 | } |
| 13717 | else |
| 13718 | { |
| 13719 | bgp = bgp_get_default (); |
| 13720 | if (bgp == NULL) |
| 13721 | { |
| 13722 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 13723 | return CMD_WARNING; |
| 13724 | } |
| 13725 | } |
| 13726 | |
| 13727 | if (argc == 3) |
| 13728 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 13729 | else |
| 13730 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 13731 | |
| 13732 | if (! peer) |
| 13733 | return CMD_WARNING; |
| 13734 | |
| 13735 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 13736 | { |
| 13737 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13738 | VTY_NEWLINE); |
| 13739 | return CMD_WARNING; |
| 13740 | } |
| 13741 | |
| 13742 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 13743 | PEER_FLAG_RSERVER_CLIENT)) |
| 13744 | { |
| 13745 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 13746 | VTY_NEWLINE); |
| 13747 | return CMD_WARNING; |
| 13748 | } |
| 13749 | |
| 13750 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 13751 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 13752 | AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 13753 | } |
| 13754 | |
| 13755 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 13756 | show_ip_bgp_rsclient_route_cmd, |
| 13757 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13758 | SHOW_STR |
| 13759 | IP_STR |
| 13760 | BGP_STR |
| 13761 | "Information about Route Server Client\n" |
| 13762 | NEIGHBOR_ADDR_STR |
| 13763 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13764 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13765 | DEFUN (show_bgp_ipv4_safi_neighbor_flap, |
| 13766 | show_bgp_ipv4_safi_neighbor_flap_cmd, |
| 13767 | "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] | 13768 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13769 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13770 | "Address Family Modifier\n" |
| 13771 | "Address Family Modifier\n" |
| 13772 | "Address Family Modifier\n" |
| 13773 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13774 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13775 | "Neighbor to display information about\n" |
| 13776 | "Neighbor to display information about\n" |
| 13777 | "Display flap statistics of the routes learned from neighbor\n") |
| 13778 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13779 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13780 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13781 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13782 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13783 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13784 | return CMD_WARNING; |
| 13785 | } |
| 13786 | |
| 13787 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13788 | if (! peer) |
| 13789 | return CMD_WARNING; |
| 13790 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13791 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13792 | bgp_show_type_flap_neighbor); |
| 13793 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13794 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13795 | DEFUN (show_bgp_ipv6_safi_neighbor_flap, |
| 13796 | show_bgp_ipv6_safi_neighbor_flap_cmd, |
| 13797 | "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] | 13798 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13799 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13800 | "Address Family Modifier\n" |
| 13801 | "Address Family Modifier\n" |
| 13802 | "Address Family Modifier\n" |
| 13803 | "Address Family Modifier\n" |
| 13804 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13805 | "Neighbor to display information about\n" |
| 13806 | "Neighbor to display information about\n" |
| 13807 | "Display flap statistics of the routes learned from neighbor\n") |
| 13808 | { |
| 13809 | struct peer *peer; |
| 13810 | safi_t safi; |
| 13811 | |
| 13812 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13813 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13814 | return CMD_WARNING; |
| 13815 | } |
| 13816 | |
| 13817 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13818 | if (! peer) |
| 13819 | return CMD_WARNING; |
| 13820 | |
| 13821 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13822 | bgp_show_type_flap_neighbor); |
| 13823 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13824 | |
| 13825 | DEFUN (show_bgp_ipv4_safi_neighbor_damp, |
| 13826 | show_bgp_ipv4_safi_neighbor_damp_cmd, |
| 13827 | "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 13828 | SHOW_STR |
| 13829 | BGP_STR |
| 13830 | "Address Family Modifier\n" |
| 13831 | "Address Family Modifier\n" |
| 13832 | "Address Family Modifier\n" |
| 13833 | "Address Family Modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13834 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13835 | "Neighbor to display information about\n" |
| 13836 | "Neighbor to display information about\n" |
| 13837 | "Display the dampened routes received from neighbor\n") |
| 13838 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13839 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13840 | safi_t safi; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13841 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13842 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13843 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13844 | return CMD_WARNING; |
| 13845 | } |
| 13846 | |
| 13847 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13848 | if (! peer) |
| 13849 | return CMD_WARNING; |
| 13850 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13851 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13852 | bgp_show_type_damp_neighbor); |
| 13853 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13854 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13855 | DEFUN (show_bgp_ipv6_safi_neighbor_damp, |
| 13856 | show_bgp_ipv6_safi_neighbor_damp_cmd, |
| 13857 | "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] | 13858 | SHOW_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13859 | BGP_STR |
| 13860 | "Address Family Modifier\n" |
| 13861 | "Address Family Modifier\n" |
| 13862 | "Address Family Modifier\n" |
| 13863 | "Address Family Modifier\n" |
| 13864 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13865 | "Neighbor to display information about\n" |
| 13866 | "Neighbor to display information about\n" |
| 13867 | "Display the dampened routes received from neighbor\n") |
| 13868 | { |
| 13869 | struct peer *peer; |
| 13870 | safi_t safi; |
| 13871 | |
| 13872 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13873 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13874 | return CMD_WARNING; |
| 13875 | } |
| 13876 | |
| 13877 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13878 | if (! peer) |
| 13879 | return CMD_WARNING; |
| 13880 | |
| 13881 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13882 | bgp_show_type_damp_neighbor); |
| 13883 | } |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13884 | |
| 13885 | DEFUN (show_bgp_ipv4_safi_neighbor_routes, |
| 13886 | show_bgp_ipv4_safi_neighbor_routes_cmd, |
| 13887 | "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 13888 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13889 | BGP_STR |
| 13890 | "Address family\n" |
| 13891 | "Address Family modifier\n" |
| 13892 | "Address Family modifier\n" |
| 13893 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13894 | "Neighbor to display information about\n" |
| 13895 | "Neighbor to display information about\n" |
| 13896 | "Display routes learned from neighbor\n") |
| 13897 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13898 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13899 | safi_t safi; |
| 13900 | |
| 13901 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13902 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13903 | return CMD_WARNING; |
| 13904 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13905 | |
| 13906 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13907 | if (! peer) |
| 13908 | return CMD_WARNING; |
| 13909 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13910 | return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13911 | bgp_show_type_neighbor); |
| 13912 | } |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 13913 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13914 | DEFUN (show_bgp_ipv6_safi_neighbor_routes, |
| 13915 | show_bgp_ipv6_safi_neighbor_routes_cmd, |
| 13916 | "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] | 13917 | SHOW_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13918 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13919 | "Address family\n" |
| 13920 | "Address Family modifier\n" |
| 13921 | "Address Family modifier\n" |
| 13922 | "Detailed information on TCP and BGP neighbor connections\n" |
| 13923 | NEIGHBOR_ADDR_STR |
| 13924 | NEIGHBOR_ADDR_STR |
| 13925 | "Display routes learned from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13926 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13927 | struct peer *peer; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13928 | safi_t safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13929 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13930 | if (bgp_parse_safi(argv[0], &safi)) { |
| 13931 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 13932 | return CMD_WARNING; |
| 13933 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13934 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13935 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13936 | if (! peer) |
| 13937 | return CMD_WARNING; |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 13938 | |
| 13939 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi, |
| 13940 | bgp_show_type_neighbor); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13941 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13942 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13943 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 13944 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 13945 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 13946 | SHOW_STR |
| 13947 | BGP_STR |
| 13948 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 13949 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13950 | "Address family\n" |
| 13951 | "Address Family modifier\n" |
| 13952 | "Address Family modifier\n" |
| 13953 | "Information about Route Server Client\n" |
| 13954 | NEIGHBOR_ADDR_STR |
| 13955 | "Network in the BGP routing table to display\n") |
| 13956 | { |
| 13957 | struct bgp *bgp; |
| 13958 | struct peer *peer; |
| 13959 | safi_t safi; |
| 13960 | |
| 13961 | /* BGP structure lookup. */ |
| 13962 | if (argc == 4) |
| 13963 | { |
| 13964 | bgp = bgp_lookup_by_name (argv[0]); |
| 13965 | if (bgp == NULL) |
| 13966 | { |
| 13967 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 13968 | return CMD_WARNING; |
| 13969 | } |
| 13970 | } |
| 13971 | else |
| 13972 | { |
| 13973 | bgp = bgp_get_default (); |
| 13974 | if (bgp == NULL) |
| 13975 | { |
| 13976 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 13977 | return CMD_WARNING; |
| 13978 | } |
| 13979 | } |
| 13980 | |
| 13981 | if (argc == 4) { |
| 13982 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 13983 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13984 | } else { |
| 13985 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 13986 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 13987 | } |
| 13988 | |
| 13989 | if (! peer) |
| 13990 | return CMD_WARNING; |
| 13991 | |
| 13992 | if (! peer->afc[AFI_IP][safi]) |
| 13993 | { |
| 13994 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 13995 | VTY_NEWLINE); |
| 13996 | return CMD_WARNING; |
| 13997 | } |
| 13998 | |
| 13999 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 14000 | PEER_FLAG_RSERVER_CLIENT)) |
| 14001 | { |
| 14002 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14003 | VTY_NEWLINE); |
| 14004 | return CMD_WARNING; |
| 14005 | } |
| 14006 | |
| 14007 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 14008 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14009 | AFI_IP, safi, NULL, 0, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14010 | } |
| 14011 | |
| 14012 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 14013 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 14014 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 14015 | SHOW_STR |
| 14016 | BGP_STR |
| 14017 | "Address family\n" |
| 14018 | "Address Family modifier\n" |
| 14019 | "Address Family modifier\n" |
| 14020 | "Information about Route Server Client\n" |
| 14021 | NEIGHBOR_ADDR_STR |
| 14022 | "Network in the BGP routing table to display\n") |
| 14023 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14024 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14025 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 14026 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 14027 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14028 | SHOW_STR |
| 14029 | BGP_STR |
| 14030 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14031 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14032 | "Address family\n" |
| 14033 | "Address Family modifier\n" |
| 14034 | "Address Family modifier\n" |
| 14035 | "Information about Route Server Client\n" |
| 14036 | NEIGHBOR_ADDR_STR |
| 14037 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 14038 | { |
| 14039 | struct bgp *bgp; |
| 14040 | struct peer *peer; |
| 14041 | safi_t safi; |
| 14042 | |
| 14043 | /* BGP structure lookup. */ |
| 14044 | if (argc == 4) |
| 14045 | { |
| 14046 | bgp = bgp_lookup_by_name (argv[0]); |
| 14047 | if (bgp == NULL) |
| 14048 | { |
| 14049 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14050 | return CMD_WARNING; |
| 14051 | } |
| 14052 | } |
| 14053 | else |
| 14054 | { |
| 14055 | bgp = bgp_get_default (); |
| 14056 | if (bgp == NULL) |
| 14057 | { |
| 14058 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14059 | return CMD_WARNING; |
| 14060 | } |
| 14061 | } |
| 14062 | |
| 14063 | if (argc == 4) { |
| 14064 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14065 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14066 | } else { |
| 14067 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14068 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14069 | } |
| 14070 | |
| 14071 | if (! peer) |
| 14072 | return CMD_WARNING; |
| 14073 | |
| 14074 | if (! peer->afc[AFI_IP][safi]) |
| 14075 | { |
| 14076 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14077 | VTY_NEWLINE); |
| 14078 | return CMD_WARNING; |
| 14079 | } |
| 14080 | |
| 14081 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 14082 | PEER_FLAG_RSERVER_CLIENT)) |
| 14083 | { |
| 14084 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14085 | VTY_NEWLINE); |
| 14086 | return CMD_WARNING; |
| 14087 | } |
| 14088 | |
| 14089 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 14090 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14091 | AFI_IP, safi, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14092 | } |
| 14093 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14094 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 14095 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 14096 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14097 | SHOW_STR |
| 14098 | IP_STR |
| 14099 | BGP_STR |
| 14100 | "BGP view\n" |
| 14101 | "View name\n" |
| 14102 | "Information about Route Server Client\n" |
| 14103 | NEIGHBOR_ADDR_STR |
| 14104 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 14105 | { |
| 14106 | struct bgp *bgp; |
| 14107 | struct peer *peer; |
| 14108 | |
| 14109 | /* BGP structure lookup. */ |
| 14110 | if (argc == 3) |
| 14111 | { |
| 14112 | bgp = bgp_lookup_by_name (argv[0]); |
| 14113 | if (bgp == NULL) |
| 14114 | { |
| 14115 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14116 | return CMD_WARNING; |
| 14117 | } |
| 14118 | } |
| 14119 | else |
| 14120 | { |
| 14121 | bgp = bgp_get_default (); |
| 14122 | if (bgp == NULL) |
| 14123 | { |
| 14124 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14125 | return CMD_WARNING; |
| 14126 | } |
| 14127 | } |
| 14128 | |
| 14129 | if (argc == 3) |
| 14130 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14131 | else |
| 14132 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14133 | |
| 14134 | if (! peer) |
| 14135 | return CMD_WARNING; |
| 14136 | |
| 14137 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 14138 | { |
| 14139 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14140 | VTY_NEWLINE); |
| 14141 | return CMD_WARNING; |
| 14142 | } |
| 14143 | |
| 14144 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 14145 | PEER_FLAG_RSERVER_CLIENT)) |
| 14146 | { |
| 14147 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14148 | VTY_NEWLINE); |
| 14149 | return CMD_WARNING; |
| 14150 | } |
| 14151 | |
| 14152 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 14153 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14154 | AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14155 | } |
| 14156 | |
| 14157 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 14158 | show_ip_bgp_rsclient_prefix_cmd, |
| 14159 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14160 | SHOW_STR |
| 14161 | IP_STR |
| 14162 | BGP_STR |
| 14163 | "Information about Route Server Client\n" |
| 14164 | NEIGHBOR_ADDR_STR |
| 14165 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 14166 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14167 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 14168 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 14169 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 14170 | SHOW_STR |
| 14171 | BGP_STR |
| 14172 | "Address family\n" |
| 14173 | "Address Family modifier\n" |
| 14174 | "Address Family modifier\n" |
| 14175 | "Information about Route Server Client\n" |
| 14176 | NEIGHBOR_ADDR_STR |
| 14177 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14178 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14179 | DEFUN (show_bgp_view_ipv6_neighbor_routes, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14180 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 14181 | "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] | 14182 | SHOW_STR |
| 14183 | BGP_STR |
| 14184 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14185 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14186 | "Address family\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14187 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14188 | "Neighbor to display information about\n" |
| 14189 | "Neighbor to display information about\n" |
| 14190 | "Display routes learned from neighbor\n") |
| 14191 | { |
| 14192 | struct peer *peer; |
| 14193 | |
| 14194 | if (argc == 2) |
| 14195 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14196 | else |
| 14197 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14198 | |
| 14199 | if (! peer) |
| 14200 | return CMD_WARNING; |
| 14201 | |
| 14202 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14203 | bgp_show_type_neighbor); |
| 14204 | } |
| 14205 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14206 | DEFUN (show_bgp_view_neighbor_damp, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14207 | show_bgp_view_neighbor_damp_cmd, |
| 14208 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14209 | SHOW_STR |
| 14210 | BGP_STR |
| 14211 | "BGP view\n" |
| 14212 | "View name\n" |
| 14213 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14214 | "Neighbor to display information about\n" |
| 14215 | "Neighbor to display information about\n" |
| 14216 | "Display the dampened routes received from neighbor\n") |
| 14217 | { |
| 14218 | struct peer *peer; |
| 14219 | |
| 14220 | if (argc == 2) |
| 14221 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14222 | else |
| 14223 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14224 | |
| 14225 | if (! peer) |
| 14226 | return CMD_WARNING; |
| 14227 | |
| 14228 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14229 | bgp_show_type_damp_neighbor); |
| 14230 | } |
| 14231 | |
| 14232 | DEFUN (show_bgp_view_ipv6_neighbor_damp, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14233 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 14234 | "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] | 14235 | SHOW_STR |
| 14236 | BGP_STR |
| 14237 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14238 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14239 | "Address family\n" |
| 14240 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14241 | "Neighbor to display information about\n" |
| 14242 | "Neighbor to display information about\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14243 | "Display the dampened routes received from neighbor\n") |
| 14244 | { |
| 14245 | struct peer *peer; |
| 14246 | |
| 14247 | if (argc == 2) |
| 14248 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14249 | else |
| 14250 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14251 | |
| 14252 | if (! peer) |
| 14253 | return CMD_WARNING; |
| 14254 | |
| 14255 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14256 | bgp_show_type_damp_neighbor); |
| 14257 | } |
| 14258 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14259 | DEFUN (show_bgp_view_ipv6_neighbor_flap, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14260 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 14261 | "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] | 14262 | SHOW_STR |
| 14263 | BGP_STR |
| 14264 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14265 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14266 | "Address family\n" |
| 14267 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14268 | "Neighbor to display information about\n" |
| 14269 | "Neighbor to display information about\n" |
| 14270 | "Display the dampened routes received from neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14271 | { |
| 14272 | struct peer *peer; |
| 14273 | |
| 14274 | if (argc == 2) |
| 14275 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14276 | else |
| 14277 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14278 | |
| 14279 | if (! peer) |
| 14280 | return CMD_WARNING; |
| 14281 | |
| 14282 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14283 | bgp_show_type_flap_neighbor); |
| 14284 | } |
| 14285 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14286 | DEFUN (show_bgp_view_neighbor_flap, |
| 14287 | show_bgp_view_neighbor_flap_cmd, |
| 14288 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14289 | SHOW_STR |
| 14290 | BGP_STR |
| 14291 | "BGP view\n" |
| 14292 | "View name\n" |
| 14293 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14294 | "Neighbor to display information about\n" |
| 14295 | "Neighbor to display information about\n" |
| 14296 | "Display flap statistics of the routes learned from neighbor\n") |
| 14297 | { |
| 14298 | struct peer *peer; |
| 14299 | |
| 14300 | if (argc == 2) |
| 14301 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14302 | else |
| 14303 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14304 | |
| 14305 | if (! peer) |
| 14306 | return CMD_WARNING; |
| 14307 | |
| 14308 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14309 | bgp_show_type_flap_neighbor); |
| 14310 | } |
| 14311 | |
| 14312 | ALIAS (show_bgp_view_neighbor_flap, |
| 14313 | show_bgp_neighbor_flap_cmd, |
| 14314 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14315 | SHOW_STR |
| 14316 | BGP_STR |
| 14317 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14318 | "Neighbor to display information about\n" |
| 14319 | "Neighbor to display information about\n" |
| 14320 | "Display flap statistics of the routes learned from neighbor\n") |
| 14321 | |
| 14322 | ALIAS (show_bgp_view_neighbor_damp, |
| 14323 | show_bgp_neighbor_damp_cmd, |
| 14324 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14325 | SHOW_STR |
| 14326 | BGP_STR |
| 14327 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14328 | "Neighbor to display information about\n" |
| 14329 | "Neighbor to display information about\n" |
| 14330 | "Display the dampened routes received from neighbor\n") |
| 14331 | |
| 14332 | DEFUN (show_bgp_view_neighbor_routes, |
| 14333 | show_bgp_view_neighbor_routes_cmd, |
| 14334 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 14335 | SHOW_STR |
| 14336 | BGP_STR |
| 14337 | "BGP view\n" |
| 14338 | "View name\n" |
| 14339 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14340 | "Neighbor to display information about\n" |
| 14341 | "Neighbor to display information about\n" |
| 14342 | "Display routes learned from neighbor\n") |
| 14343 | { |
| 14344 | struct peer *peer; |
| 14345 | |
| 14346 | if (argc == 2) |
| 14347 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14348 | else |
| 14349 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14350 | |
| 14351 | if (! peer) |
| 14352 | return CMD_WARNING; |
| 14353 | |
| 14354 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 14355 | bgp_show_type_neighbor); |
| 14356 | } |
| 14357 | |
| 14358 | ALIAS (show_bgp_view_neighbor_routes, |
| 14359 | show_bgp_neighbor_routes_cmd, |
| 14360 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14361 | SHOW_STR |
| 14362 | BGP_STR |
| 14363 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14364 | "Neighbor to display information about\n" |
| 14365 | "Neighbor to display information about\n" |
| 14366 | "Display routes learned from neighbor\n") |
| 14367 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14368 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 14369 | show_bgp_ipv6_neighbor_routes_cmd, |
| 14370 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 14371 | SHOW_STR |
| 14372 | BGP_STR |
| 14373 | "Address family\n" |
| 14374 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14375 | "Neighbor to display information about\n" |
| 14376 | "Neighbor to display information about\n" |
| 14377 | "Display routes learned from neighbor\n") |
| 14378 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14379 | /* old command */ |
| 14380 | ALIAS (show_bgp_view_neighbor_routes, |
| 14381 | ipv6_bgp_neighbor_routes_cmd, |
| 14382 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14383 | SHOW_STR |
| 14384 | IPV6_STR |
| 14385 | BGP_STR |
| 14386 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14387 | "Neighbor to display information about\n" |
| 14388 | "Neighbor to display information about\n" |
| 14389 | "Display routes learned from neighbor\n") |
| 14390 | |
| 14391 | /* old command */ |
| 14392 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 14393 | ipv6_mbgp_neighbor_routes_cmd, |
| 14394 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 14395 | SHOW_STR |
| 14396 | IPV6_STR |
| 14397 | MBGP_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 routes learned from neighbor\n") |
| 14402 | { |
| 14403 | struct peer *peer; |
| 14404 | |
| 14405 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14406 | if (! peer) |
| 14407 | return CMD_WARNING; |
| 14408 | |
| 14409 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
| 14410 | bgp_show_type_neighbor); |
| 14411 | } |
| 14412 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14413 | ALIAS (show_bgp_view_neighbor_flap, |
| 14414 | show_bgp_ipv6_neighbor_flap_cmd, |
| 14415 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 14416 | SHOW_STR |
| 14417 | BGP_STR |
| 14418 | "Address family\n" |
| 14419 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14420 | "Neighbor to display information about\n" |
| 14421 | "Neighbor to display information about\n" |
| 14422 | "Display flap statistics of the routes learned from neighbor\n") |
| 14423 | |
| 14424 | ALIAS (show_bgp_view_neighbor_damp, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 14425 | show_bgp_ipv6_neighbor_damp_cmd, |
| 14426 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 14427 | SHOW_STR |
| 14428 | BGP_STR |
| 14429 | "Address family\n" |
| 14430 | "Detailed information on TCP and BGP neighbor connections\n" |
| 14431 | "Neighbor to display information about\n" |
| 14432 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 14433 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14434 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14435 | DEFUN (show_bgp_view_rsclient, |
| 14436 | show_bgp_view_rsclient_cmd, |
| 14437 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 14438 | SHOW_STR |
| 14439 | BGP_STR |
| 14440 | "BGP view\n" |
| 14441 | "View name\n" |
| 14442 | "Information about Route Server Client\n" |
| 14443 | NEIGHBOR_ADDR_STR) |
| 14444 | { |
| 14445 | struct bgp_table *table; |
| 14446 | struct peer *peer; |
| 14447 | |
| 14448 | if (argc == 2) |
| 14449 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14450 | else |
| 14451 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14452 | |
| 14453 | if (! peer) |
| 14454 | return CMD_WARNING; |
| 14455 | |
| 14456 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14457 | { |
| 14458 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14459 | VTY_NEWLINE); |
| 14460 | return CMD_WARNING; |
| 14461 | } |
| 14462 | |
| 14463 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14464 | PEER_FLAG_RSERVER_CLIENT)) |
| 14465 | { |
| 14466 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14467 | VTY_NEWLINE); |
| 14468 | return CMD_WARNING; |
| 14469 | } |
| 14470 | |
| 14471 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 14472 | |
| 14473 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14474 | } |
| 14475 | |
| 14476 | ALIAS (show_bgp_view_rsclient, |
| 14477 | show_bgp_rsclient_cmd, |
| 14478 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 14479 | SHOW_STR |
| 14480 | BGP_STR |
| 14481 | "Information about Route Server Client\n" |
| 14482 | NEIGHBOR_ADDR_STR) |
| 14483 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14484 | DEFUN (show_bgp_view_ipv4_rsclient, |
| 14485 | show_bgp_view_ipv4_rsclient_cmd, |
| 14486 | "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] | 14487 | SHOW_STR |
| 14488 | BGP_STR |
| 14489 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14490 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14491 | "Address Family\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14492 | "Information about Route Server Client\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14493 | NEIGHBOR_ADDR_STR2) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14494 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14495 | struct bgp_table *table; |
| 14496 | struct peer *peer; |
| 14497 | |
| 14498 | if (argc == 2) |
| 14499 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14500 | else |
| 14501 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14502 | |
| 14503 | if (! peer) |
| 14504 | return CMD_WARNING; |
| 14505 | |
| 14506 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 14507 | { |
| 14508 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14509 | VTY_NEWLINE); |
| 14510 | return CMD_WARNING; |
| 14511 | } |
| 14512 | |
| 14513 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 14514 | PEER_FLAG_RSERVER_CLIENT)) |
| 14515 | { |
| 14516 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14517 | VTY_NEWLINE); |
| 14518 | return CMD_WARNING; |
| 14519 | } |
| 14520 | |
| 14521 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 14522 | |
| 14523 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14524 | } |
| 14525 | DEFUN (show_bgp_view_ipv6_rsclient, |
| 14526 | show_bgp_view_ipv6_rsclient_cmd, |
| 14527 | "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)", |
| 14528 | SHOW_STR |
| 14529 | BGP_STR |
| 14530 | "BGP view\n" |
| 14531 | "BGP view name\n" |
| 14532 | "Address Family\n" |
| 14533 | "Information about Route Server Client\n" |
| 14534 | NEIGHBOR_ADDR_STR2) |
| 14535 | { |
| 14536 | struct bgp_table *table; |
| 14537 | struct peer *peer; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14538 | |
| 14539 | if (argc == 2) |
| 14540 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14541 | else |
| 14542 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14543 | |
| 14544 | if (! peer) |
| 14545 | return CMD_WARNING; |
| 14546 | |
| 14547 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14548 | { |
| 14549 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14550 | VTY_NEWLINE); |
| 14551 | return CMD_WARNING; |
| 14552 | } |
| 14553 | |
| 14554 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14555 | PEER_FLAG_RSERVER_CLIENT)) |
| 14556 | { |
| 14557 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14558 | VTY_NEWLINE); |
| 14559 | return CMD_WARNING; |
| 14560 | } |
| 14561 | |
| 14562 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 14563 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 14564 | 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] | 14565 | } |
| 14566 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14567 | ALIAS (show_bgp_view_ipv4_rsclient, |
| 14568 | show_bgp_ipv4_rsclient_cmd, |
| 14569 | "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14570 | SHOW_STR |
| 14571 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14572 | "Address Family\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14573 | "Information about Route Server Client\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14574 | NEIGHBOR_ADDR_STR2) |
| 14575 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14576 | ALIAS (show_bgp_view_ipv6_rsclient, |
| 14577 | show_bgp_ipv6_rsclient_cmd, |
| 14578 | "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)", |
| 14579 | SHOW_STR |
| 14580 | BGP_STR |
| 14581 | "Address Family\n" |
| 14582 | "Information about Route Server Client\n" |
| 14583 | NEIGHBOR_ADDR_STR2) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14584 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14585 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 14586 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 14587 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 14588 | SHOW_STR |
| 14589 | BGP_STR |
| 14590 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14591 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14592 | "Address family\n" |
| 14593 | "Address Family modifier\n" |
| 14594 | "Address Family modifier\n" |
| 14595 | "Information about Route Server Client\n" |
| 14596 | NEIGHBOR_ADDR_STR) |
| 14597 | { |
| 14598 | struct bgp_table *table; |
| 14599 | struct peer *peer; |
| 14600 | safi_t safi; |
| 14601 | |
| 14602 | if (argc == 3) { |
| 14603 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14604 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14605 | } else { |
| 14606 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14607 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14608 | } |
| 14609 | |
| 14610 | if (! peer) |
| 14611 | return CMD_WARNING; |
| 14612 | |
| 14613 | if (! peer->afc[AFI_IP6][safi]) |
| 14614 | { |
| 14615 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14616 | VTY_NEWLINE); |
| 14617 | return CMD_WARNING; |
| 14618 | } |
| 14619 | |
| 14620 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 14621 | PEER_FLAG_RSERVER_CLIENT)) |
| 14622 | { |
| 14623 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14624 | VTY_NEWLINE); |
| 14625 | return CMD_WARNING; |
| 14626 | } |
| 14627 | |
| 14628 | table = peer->rib[AFI_IP6][safi]; |
| 14629 | |
| 14630 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 14631 | } |
| 14632 | |
| 14633 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 14634 | show_bgp_ipv6_safi_rsclient_cmd, |
| 14635 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 14636 | SHOW_STR |
| 14637 | BGP_STR |
| 14638 | "Address family\n" |
| 14639 | "Address Family modifier\n" |
| 14640 | "Address Family modifier\n" |
| 14641 | "Information about Route Server Client\n" |
| 14642 | NEIGHBOR_ADDR_STR) |
| 14643 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14644 | DEFUN (show_bgp_view_rsclient_route, |
| 14645 | show_bgp_view_rsclient_route_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14646 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14647 | SHOW_STR |
| 14648 | BGP_STR |
| 14649 | "BGP view\n" |
| 14650 | "View name\n" |
| 14651 | "Information about Route Server Client\n" |
| 14652 | NEIGHBOR_ADDR_STR |
| 14653 | "Network in the BGP routing table to display\n") |
| 14654 | { |
| 14655 | struct bgp *bgp; |
| 14656 | struct peer *peer; |
| 14657 | |
| 14658 | /* BGP structure lookup. */ |
| 14659 | if (argc == 3) |
| 14660 | { |
| 14661 | bgp = bgp_lookup_by_name (argv[0]); |
| 14662 | if (bgp == NULL) |
| 14663 | { |
| 14664 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14665 | return CMD_WARNING; |
| 14666 | } |
| 14667 | } |
| 14668 | else |
| 14669 | { |
| 14670 | bgp = bgp_get_default (); |
| 14671 | if (bgp == NULL) |
| 14672 | { |
| 14673 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14674 | return CMD_WARNING; |
| 14675 | } |
| 14676 | } |
| 14677 | |
| 14678 | if (argc == 3) |
| 14679 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14680 | else |
| 14681 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14682 | |
| 14683 | if (! peer) |
| 14684 | return CMD_WARNING; |
| 14685 | |
| 14686 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14687 | { |
| 14688 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14689 | VTY_NEWLINE); |
| 14690 | return CMD_WARNING; |
| 14691 | } |
| 14692 | |
| 14693 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14694 | PEER_FLAG_RSERVER_CLIENT)) |
| 14695 | { |
| 14696 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14697 | VTY_NEWLINE); |
| 14698 | return CMD_WARNING; |
| 14699 | } |
| 14700 | |
| 14701 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14702 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14703 | AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14704 | } |
| 14705 | |
| 14706 | DEFUN (show_bgp_view_ipv6_rsclient_route, |
| 14707 | show_bgp_view_ipv6_rsclient_route_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14708 | "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] | 14709 | SHOW_STR |
| 14710 | BGP_STR |
| 14711 | "BGP view\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14712 | "BGP view name\n" |
| 14713 | "IP6_STR" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14714 | "Information about Route Server Client\n" |
| 14715 | NEIGHBOR_ADDR_STR |
| 14716 | "Network in the BGP routing table to display\n") |
| 14717 | { |
| 14718 | struct bgp *bgp; |
| 14719 | struct peer *peer; |
| 14720 | |
| 14721 | /* BGP structure lookup. */ |
| 14722 | if (argc == 3) |
| 14723 | { |
| 14724 | bgp = bgp_lookup_by_name (argv[0]); |
| 14725 | if (bgp == NULL) |
| 14726 | { |
| 14727 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14728 | return CMD_WARNING; |
| 14729 | } |
| 14730 | } |
| 14731 | else |
| 14732 | { |
| 14733 | bgp = bgp_get_default (); |
| 14734 | if (bgp == NULL) |
| 14735 | { |
| 14736 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14737 | return CMD_WARNING; |
| 14738 | } |
| 14739 | } |
| 14740 | |
| 14741 | if (argc == 3) |
| 14742 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14743 | else |
| 14744 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14745 | |
| 14746 | if (! peer) |
| 14747 | return CMD_WARNING; |
| 14748 | |
| 14749 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14750 | { |
| 14751 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14752 | VTY_NEWLINE); |
| 14753 | return CMD_WARNING; |
| 14754 | } |
| 14755 | |
| 14756 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14757 | PEER_FLAG_RSERVER_CLIENT)) |
| 14758 | { |
| 14759 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14760 | VTY_NEWLINE); |
| 14761 | return CMD_WARNING; |
| 14762 | } |
| 14763 | |
| 14764 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14765 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14766 | AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14767 | } |
| 14768 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14769 | ALIAS (show_bgp_view_ipv6_rsclient_route, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14770 | show_bgp_rsclient_route_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14771 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14772 | SHOW_STR |
| 14773 | BGP_STR |
| 14774 | "Information about Route Server Client\n" |
| 14775 | NEIGHBOR_ADDR_STR |
| 14776 | "Network in the BGP routing table to display\n") |
| 14777 | |
| 14778 | ALIAS (show_bgp_view_ipv6_rsclient_route, |
| 14779 | show_bgp_ipv6_rsclient_route_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14780 | "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] | 14781 | SHOW_STR |
| 14782 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14783 | IP6_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14784 | "Information about Route Server Client\n" |
| 14785 | NEIGHBOR_ADDR_STR |
| 14786 | "Network in the BGP routing table to display\n") |
| 14787 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14788 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 14789 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 14790 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14791 | SHOW_STR |
| 14792 | BGP_STR |
| 14793 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14794 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14795 | "Address family\n" |
| 14796 | "Address Family modifier\n" |
| 14797 | "Address Family modifier\n" |
| 14798 | "Information about Route Server Client\n" |
| 14799 | NEIGHBOR_ADDR_STR |
| 14800 | "Network in the BGP routing table to display\n") |
| 14801 | { |
| 14802 | struct bgp *bgp; |
| 14803 | struct peer *peer; |
| 14804 | safi_t safi; |
| 14805 | |
| 14806 | /* BGP structure lookup. */ |
| 14807 | if (argc == 4) |
| 14808 | { |
| 14809 | bgp = bgp_lookup_by_name (argv[0]); |
| 14810 | if (bgp == NULL) |
| 14811 | { |
| 14812 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14813 | return CMD_WARNING; |
| 14814 | } |
| 14815 | } |
| 14816 | else |
| 14817 | { |
| 14818 | bgp = bgp_get_default (); |
| 14819 | if (bgp == NULL) |
| 14820 | { |
| 14821 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14822 | return CMD_WARNING; |
| 14823 | } |
| 14824 | } |
| 14825 | |
| 14826 | if (argc == 4) { |
| 14827 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 14828 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14829 | } else { |
| 14830 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 14831 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 14832 | } |
| 14833 | |
| 14834 | if (! peer) |
| 14835 | return CMD_WARNING; |
| 14836 | |
| 14837 | if (! peer->afc[AFI_IP6][safi]) |
| 14838 | { |
| 14839 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14840 | VTY_NEWLINE); |
| 14841 | return CMD_WARNING; |
| 14842 | } |
| 14843 | |
| 14844 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 14845 | PEER_FLAG_RSERVER_CLIENT)) |
| 14846 | { |
| 14847 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14848 | VTY_NEWLINE); |
| 14849 | return CMD_WARNING; |
| 14850 | } |
| 14851 | |
| 14852 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 14853 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14854 | AFI_IP6, safi, NULL, 0, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 14855 | } |
| 14856 | |
| 14857 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 14858 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 14859 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 14860 | SHOW_STR |
| 14861 | BGP_STR |
| 14862 | "Address family\n" |
| 14863 | "Address Family modifier\n" |
| 14864 | "Address Family modifier\n" |
| 14865 | "Information about Route Server Client\n" |
| 14866 | NEIGHBOR_ADDR_STR |
| 14867 | "Network in the BGP routing table to display\n") |
| 14868 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14869 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14870 | DEFUN (show_bgp_view_rsclient_prefix, |
| 14871 | show_bgp_view_rsclient_prefix_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14872 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 14873 | SHOW_STR |
| 14874 | BGP_STR |
| 14875 | "BGP view\n" |
| 14876 | "View name\n" |
| 14877 | "Information about Route Server Client\n" |
| 14878 | NEIGHBOR_ADDR_STR |
| 14879 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14880 | { |
| 14881 | struct bgp *bgp; |
| 14882 | struct peer *peer; |
| 14883 | |
| 14884 | /* BGP structure lookup. */ |
| 14885 | if (argc == 3) |
| 14886 | { |
| 14887 | bgp = bgp_lookup_by_name (argv[0]); |
| 14888 | if (bgp == NULL) |
| 14889 | { |
| 14890 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14891 | return CMD_WARNING; |
| 14892 | } |
| 14893 | } |
| 14894 | else |
| 14895 | { |
| 14896 | bgp = bgp_get_default (); |
| 14897 | if (bgp == NULL) |
| 14898 | { |
| 14899 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14900 | return CMD_WARNING; |
| 14901 | } |
| 14902 | } |
| 14903 | |
| 14904 | if (argc == 3) |
| 14905 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14906 | else |
| 14907 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14908 | |
| 14909 | if (! peer) |
| 14910 | return CMD_WARNING; |
| 14911 | |
| 14912 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14913 | { |
| 14914 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14915 | VTY_NEWLINE); |
| 14916 | return CMD_WARNING; |
| 14917 | } |
| 14918 | |
| 14919 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14920 | PEER_FLAG_RSERVER_CLIENT)) |
| 14921 | { |
| 14922 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14923 | VTY_NEWLINE); |
| 14924 | return CMD_WARNING; |
| 14925 | } |
| 14926 | |
| 14927 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14928 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14929 | AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14930 | } |
| 14931 | |
| 14932 | DEFUN (show_bgp_view_ipv6_rsclient_prefix, |
| 14933 | show_bgp_view_ipv6_rsclient_prefix_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14934 | "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] | 14935 | SHOW_STR |
| 14936 | BGP_STR |
| 14937 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 14938 | "View name\n" |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 14939 | IP6_STR |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14940 | "Information about Route Server Client\n" |
| 14941 | NEIGHBOR_ADDR_STR |
| 14942 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 14943 | { |
| 14944 | struct bgp *bgp; |
| 14945 | struct peer *peer; |
| 14946 | |
| 14947 | /* BGP structure lookup. */ |
| 14948 | if (argc == 3) |
| 14949 | { |
| 14950 | bgp = bgp_lookup_by_name (argv[0]); |
| 14951 | if (bgp == NULL) |
| 14952 | { |
| 14953 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 14954 | return CMD_WARNING; |
| 14955 | } |
| 14956 | } |
| 14957 | else |
| 14958 | { |
| 14959 | bgp = bgp_get_default (); |
| 14960 | if (bgp == NULL) |
| 14961 | { |
| 14962 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 14963 | return CMD_WARNING; |
| 14964 | } |
| 14965 | } |
| 14966 | |
| 14967 | if (argc == 3) |
| 14968 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 14969 | else |
| 14970 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 14971 | |
| 14972 | if (! peer) |
| 14973 | return CMD_WARNING; |
| 14974 | |
| 14975 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 14976 | { |
| 14977 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 14978 | VTY_NEWLINE); |
| 14979 | return CMD_WARNING; |
| 14980 | } |
| 14981 | |
| 14982 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 14983 | PEER_FLAG_RSERVER_CLIENT)) |
| 14984 | { |
| 14985 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 14986 | VTY_NEWLINE); |
| 14987 | return CMD_WARNING; |
| 14988 | } |
| 14989 | |
| 14990 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 14991 | (argc == 3) ? argv[2] : argv[1], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 14992 | AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14993 | } |
| 14994 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14995 | ALIAS (show_bgp_view_ipv6_rsclient_prefix, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 14996 | show_bgp_rsclient_prefix_cmd, |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 14997 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 14998 | SHOW_STR |
| 14999 | BGP_STR |
| 15000 | "Information about Route Server Client\n" |
| 15001 | NEIGHBOR_ADDR_STR |
| 15002 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15003 | |
| 15004 | ALIAS (show_bgp_view_ipv6_rsclient_prefix, |
| 15005 | show_bgp_ipv6_rsclient_prefix_cmd, |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15006 | "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] | 15007 | SHOW_STR |
| 15008 | BGP_STR |
| 15009 | "Information about Route Server Client\n" |
| 15010 | NEIGHBOR_ADDR_STR |
| 15011 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15012 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15013 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 15014 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 15015 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 15016 | SHOW_STR |
| 15017 | BGP_STR |
| 15018 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 15019 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15020 | "Address family\n" |
| 15021 | "Address Family modifier\n" |
| 15022 | "Address Family modifier\n" |
| 15023 | "Information about Route Server Client\n" |
| 15024 | NEIGHBOR_ADDR_STR |
| 15025 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15026 | { |
| 15027 | struct bgp *bgp; |
| 15028 | struct peer *peer; |
| 15029 | safi_t safi; |
| 15030 | |
| 15031 | /* BGP structure lookup. */ |
| 15032 | if (argc == 4) |
| 15033 | { |
| 15034 | bgp = bgp_lookup_by_name (argv[0]); |
| 15035 | if (bgp == NULL) |
| 15036 | { |
| 15037 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 15038 | return CMD_WARNING; |
| 15039 | } |
| 15040 | } |
| 15041 | else |
| 15042 | { |
| 15043 | bgp = bgp_get_default (); |
| 15044 | if (bgp == NULL) |
| 15045 | { |
| 15046 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 15047 | return CMD_WARNING; |
| 15048 | } |
| 15049 | } |
| 15050 | |
| 15051 | if (argc == 4) { |
| 15052 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 15053 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 15054 | } else { |
| 15055 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 15056 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 15057 | } |
| 15058 | |
| 15059 | if (! peer) |
| 15060 | return CMD_WARNING; |
| 15061 | |
| 15062 | if (! peer->afc[AFI_IP6][safi]) |
| 15063 | { |
| 15064 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 15065 | VTY_NEWLINE); |
| 15066 | return CMD_WARNING; |
| 15067 | } |
| 15068 | |
| 15069 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 15070 | PEER_FLAG_RSERVER_CLIENT)) |
| 15071 | { |
| 15072 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 15073 | VTY_NEWLINE); |
| 15074 | return CMD_WARNING; |
| 15075 | } |
| 15076 | |
| 15077 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 15078 | (argc == 4) ? argv[3] : argv[2], |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 15079 | AFI_IP6, safi, NULL, 1, BGP_PATH_ALL); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 15080 | } |
| 15081 | |
| 15082 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 15083 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 15084 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 15085 | SHOW_STR |
| 15086 | BGP_STR |
| 15087 | "Address family\n" |
| 15088 | "Address Family modifier\n" |
| 15089 | "Address Family modifier\n" |
| 15090 | "Information about Route Server Client\n" |
| 15091 | NEIGHBOR_ADDR_STR |
| 15092 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 15093 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15094 | struct bgp_table *bgp_distance_table; |
| 15095 | |
| 15096 | struct bgp_distance |
| 15097 | { |
| 15098 | /* Distance value for the IP source prefix. */ |
| 15099 | u_char distance; |
| 15100 | |
| 15101 | /* Name of the access-list to be matched. */ |
| 15102 | char *access_list; |
| 15103 | }; |
| 15104 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15105 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 15106 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15107 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 15108 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15109 | } |
| 15110 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15111 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15112 | bgp_distance_free (struct bgp_distance *bdistance) |
| 15113 | { |
| 15114 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 15115 | } |
| 15116 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15117 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 15118 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 15119 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15120 | { |
| 15121 | int ret; |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15122 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15123 | u_char distance; |
| 15124 | struct bgp_node *rn; |
| 15125 | struct bgp_distance *bdistance; |
| 15126 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15127 | ret = str2prefix (ip_str, &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15128 | if (ret == 0) |
| 15129 | { |
| 15130 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 15131 | return CMD_WARNING; |
| 15132 | } |
| 15133 | |
| 15134 | distance = atoi (distance_str); |
| 15135 | |
| 15136 | /* Get BGP distance node. */ |
| 15137 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 15138 | if (rn->info) |
| 15139 | { |
| 15140 | bdistance = rn->info; |
| 15141 | bgp_unlock_node (rn); |
| 15142 | } |
| 15143 | else |
| 15144 | { |
| 15145 | bdistance = bgp_distance_new (); |
| 15146 | rn->info = bdistance; |
| 15147 | } |
| 15148 | |
| 15149 | /* Set distance value. */ |
| 15150 | bdistance->distance = distance; |
| 15151 | |
| 15152 | /* Reset access-list configuration. */ |
| 15153 | if (bdistance->access_list) |
| 15154 | { |
| 15155 | free (bdistance->access_list); |
| 15156 | bdistance->access_list = NULL; |
| 15157 | } |
| 15158 | if (access_list_str) |
| 15159 | bdistance->access_list = strdup (access_list_str); |
| 15160 | |
| 15161 | return CMD_SUCCESS; |
| 15162 | } |
| 15163 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15164 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 15165 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 15166 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15167 | { |
| 15168 | int ret; |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15169 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15170 | u_char distance; |
| 15171 | struct bgp_node *rn; |
| 15172 | struct bgp_distance *bdistance; |
| 15173 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15174 | ret = str2prefix (ip_str, &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15175 | if (ret == 0) |
| 15176 | { |
| 15177 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 15178 | return CMD_WARNING; |
| 15179 | } |
| 15180 | |
| 15181 | distance = atoi (distance_str); |
| 15182 | |
| 15183 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 15184 | if (! rn) |
| 15185 | { |
| 15186 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 15187 | return CMD_WARNING; |
| 15188 | } |
| 15189 | |
| 15190 | bdistance = rn->info; |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 15191 | |
| 15192 | if (bdistance->distance != distance) |
| 15193 | { |
| 15194 | vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); |
| 15195 | return CMD_WARNING; |
| 15196 | } |
| 15197 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15198 | if (bdistance->access_list) |
| 15199 | free (bdistance->access_list); |
| 15200 | bgp_distance_free (bdistance); |
| 15201 | |
| 15202 | rn->info = NULL; |
| 15203 | bgp_unlock_node (rn); |
| 15204 | bgp_unlock_node (rn); |
| 15205 | |
| 15206 | return CMD_SUCCESS; |
| 15207 | } |
| 15208 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15209 | /* Apply BGP information to distance method. */ |
| 15210 | u_char |
| 15211 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 15212 | { |
| 15213 | struct bgp_node *rn; |
| 15214 | struct prefix_ipv4 q; |
| 15215 | struct peer *peer; |
| 15216 | struct bgp_distance *bdistance; |
| 15217 | struct access_list *alist; |
| 15218 | struct bgp_static *bgp_static; |
| 15219 | |
| 15220 | if (! bgp) |
| 15221 | return 0; |
| 15222 | |
| 15223 | if (p->family != AF_INET) |
| 15224 | return 0; |
| 15225 | |
| 15226 | peer = rinfo->peer; |
| 15227 | |
| 15228 | if (peer->su.sa.sa_family != AF_INET) |
| 15229 | return 0; |
| 15230 | |
| 15231 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 15232 | q.family = AF_INET; |
| 15233 | q.prefix = peer->su.sin.sin_addr; |
| 15234 | q.prefixlen = IPV4_MAX_BITLEN; |
| 15235 | |
| 15236 | /* Check source address. */ |
| 15237 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 15238 | if (rn) |
| 15239 | { |
| 15240 | bdistance = rn->info; |
| 15241 | bgp_unlock_node (rn); |
| 15242 | |
| 15243 | if (bdistance->access_list) |
| 15244 | { |
| 15245 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 15246 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 15247 | return bdistance->distance; |
| 15248 | } |
| 15249 | else |
| 15250 | return bdistance->distance; |
| 15251 | } |
| 15252 | |
| 15253 | /* Backdoor check. */ |
| 15254 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 15255 | if (rn) |
| 15256 | { |
| 15257 | bgp_static = rn->info; |
| 15258 | bgp_unlock_node (rn); |
| 15259 | |
| 15260 | if (bgp_static->backdoor) |
| 15261 | { |
| 15262 | if (bgp->distance_local) |
| 15263 | return bgp->distance_local; |
| 15264 | else |
| 15265 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15266 | } |
| 15267 | } |
| 15268 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 15269 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15270 | { |
| 15271 | if (bgp->distance_ebgp) |
| 15272 | return bgp->distance_ebgp; |
| 15273 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 15274 | } |
| 15275 | else |
| 15276 | { |
| 15277 | if (bgp->distance_ibgp) |
| 15278 | return bgp->distance_ibgp; |
| 15279 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15280 | } |
| 15281 | } |
| 15282 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15283 | #ifdef HAVE_IPV6 |
| 15284 | /* Apply BGP information to ipv6 distance method. */ |
| 15285 | u_char |
| 15286 | ipv6_bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 15287 | { |
| 15288 | struct bgp_node *rn; |
| 15289 | struct prefix_ipv6 q; |
| 15290 | struct peer *peer; |
| 15291 | struct bgp_distance *bdistance; |
| 15292 | struct access_list *alist; |
| 15293 | struct bgp_static *bgp_static; |
| 15294 | |
| 15295 | if (! bgp) |
| 15296 | return 0; |
| 15297 | |
| 15298 | if (p->family != AF_INET6) |
| 15299 | return 0; |
| 15300 | |
| 15301 | peer = rinfo->peer; |
| 15302 | |
| 15303 | if (peer->su.sa.sa_family != AF_INET6) |
| 15304 | return 0; |
| 15305 | |
| 15306 | memset (&q, 0, sizeof (struct prefix_ipv6)); |
| 15307 | q.family = AF_INET; |
| 15308 | q.prefix = peer->su.sin6.sin6_addr; |
| 15309 | q.prefixlen = IPV6_MAX_BITLEN; |
| 15310 | |
| 15311 | /* Check source address. */ |
| 15312 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 15313 | if (rn) |
| 15314 | { |
| 15315 | bdistance = rn->info; |
| 15316 | bgp_unlock_node (rn); |
| 15317 | |
| 15318 | if (bdistance->access_list) |
| 15319 | { |
| 15320 | alist = access_list_lookup (AFI_IP6, bdistance->access_list); |
| 15321 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 15322 | return bdistance->distance; |
| 15323 | } |
| 15324 | else |
| 15325 | return bdistance->distance; |
| 15326 | } |
| 15327 | /* Backdoor check. */ |
| 15328 | rn = bgp_node_lookup (bgp->route[AFI_IP6][SAFI_UNICAST], p); |
| 15329 | if (rn) |
| 15330 | { |
| 15331 | bgp_static = rn->info; |
| 15332 | bgp_unlock_node (rn); |
| 15333 | |
| 15334 | if (bgp_static->backdoor) |
| 15335 | { |
| 15336 | if (bgp->ipv6_distance_local) |
| 15337 | return bgp->ipv6_distance_local; |
| 15338 | else |
| 15339 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15340 | } |
| 15341 | } |
| 15342 | |
| 15343 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 15344 | { |
| 15345 | if (bgp->ipv6_distance_ebgp) |
| 15346 | return bgp->ipv6_distance_ebgp; |
| 15347 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 15348 | } |
| 15349 | else |
| 15350 | { |
| 15351 | if (bgp->ipv6_distance_ibgp) |
| 15352 | return bgp->ipv6_distance_ibgp; |
| 15353 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 15354 | } |
| 15355 | } |
| 15356 | #endif /* HAVE_IPV6 */ |
| 15357 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15358 | DEFUN (bgp_distance, |
| 15359 | bgp_distance_cmd, |
| 15360 | "distance bgp <1-255> <1-255> <1-255>", |
| 15361 | "Define an administrative distance\n" |
| 15362 | "BGP distance\n" |
| 15363 | "Distance for routes external to the AS\n" |
| 15364 | "Distance for routes internal to the AS\n" |
| 15365 | "Distance for local routes\n") |
| 15366 | { |
| 15367 | struct bgp *bgp; |
| 15368 | |
| 15369 | bgp = vty->index; |
| 15370 | |
| 15371 | bgp->distance_ebgp = atoi (argv[0]); |
| 15372 | bgp->distance_ibgp = atoi (argv[1]); |
| 15373 | bgp->distance_local = atoi (argv[2]); |
| 15374 | return CMD_SUCCESS; |
| 15375 | } |
| 15376 | |
| 15377 | DEFUN (no_bgp_distance, |
| 15378 | no_bgp_distance_cmd, |
| 15379 | "no distance bgp <1-255> <1-255> <1-255>", |
| 15380 | NO_STR |
| 15381 | "Define an administrative distance\n" |
| 15382 | "BGP distance\n" |
| 15383 | "Distance for routes external to the AS\n" |
| 15384 | "Distance for routes internal to the AS\n" |
| 15385 | "Distance for local routes\n") |
| 15386 | { |
| 15387 | struct bgp *bgp; |
| 15388 | |
| 15389 | bgp = vty->index; |
| 15390 | |
| 15391 | bgp->distance_ebgp= 0; |
| 15392 | bgp->distance_ibgp = 0; |
| 15393 | bgp->distance_local = 0; |
| 15394 | return CMD_SUCCESS; |
| 15395 | } |
| 15396 | |
| 15397 | ALIAS (no_bgp_distance, |
| 15398 | no_bgp_distance2_cmd, |
| 15399 | "no distance bgp", |
| 15400 | NO_STR |
| 15401 | "Define an administrative distance\n" |
| 15402 | "BGP distance\n") |
| 15403 | |
| 15404 | DEFUN (bgp_distance_source, |
| 15405 | bgp_distance_source_cmd, |
| 15406 | "distance <1-255> A.B.C.D/M", |
| 15407 | "Define an administrative distance\n" |
| 15408 | "Administrative distance\n" |
| 15409 | "IP source prefix\n") |
| 15410 | { |
| 15411 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 15412 | return CMD_SUCCESS; |
| 15413 | } |
| 15414 | |
| 15415 | DEFUN (no_bgp_distance_source, |
| 15416 | no_bgp_distance_source_cmd, |
| 15417 | "no distance <1-255> A.B.C.D/M", |
| 15418 | NO_STR |
| 15419 | "Define an administrative distance\n" |
| 15420 | "Administrative distance\n" |
| 15421 | "IP source prefix\n") |
| 15422 | { |
| 15423 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 15424 | return CMD_SUCCESS; |
| 15425 | } |
| 15426 | |
| 15427 | DEFUN (bgp_distance_source_access_list, |
| 15428 | bgp_distance_source_access_list_cmd, |
| 15429 | "distance <1-255> A.B.C.D/M WORD", |
| 15430 | "Define an administrative distance\n" |
| 15431 | "Administrative distance\n" |
| 15432 | "IP source prefix\n" |
| 15433 | "Access list name\n") |
| 15434 | { |
| 15435 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 15436 | return CMD_SUCCESS; |
| 15437 | } |
| 15438 | |
| 15439 | DEFUN (no_bgp_distance_source_access_list, |
| 15440 | no_bgp_distance_source_access_list_cmd, |
| 15441 | "no distance <1-255> A.B.C.D/M WORD", |
| 15442 | NO_STR |
| 15443 | "Define an administrative distance\n" |
| 15444 | "Administrative distance\n" |
| 15445 | "IP source prefix\n" |
| 15446 | "Access list name\n") |
| 15447 | { |
| 15448 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 15449 | return CMD_SUCCESS; |
| 15450 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15451 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 15452 | #ifdef HAVE_IPV6 |
| 15453 | DEFUN (ipv6_bgp_distance, |
| 15454 | ipv6_bgp_distance_cmd, |
| 15455 | "distance bgp <1-255> <1-255> <1-255>", |
| 15456 | "Define an administrative distance\n" |
| 15457 | "BGP distance\n" |
| 15458 | "Distance for routes external to the AS\n" |
| 15459 | "Distance for routes internal to the AS\n" |
| 15460 | "Distance for local routes\n") |
| 15461 | { |
| 15462 | struct bgp *bgp; |
| 15463 | |
| 15464 | bgp = vty->index; |
| 15465 | |
| 15466 | bgp->ipv6_distance_ebgp = atoi (argv[0]); |
| 15467 | bgp->ipv6_distance_ibgp = atoi (argv[1]); |
| 15468 | bgp->ipv6_distance_local = atoi (argv[2]); |
| 15469 | return CMD_SUCCESS; |
| 15470 | } |
| 15471 | |
| 15472 | DEFUN (no_ipv6_bgp_distance, |
| 15473 | no_ipv6_bgp_distance_cmd, |
| 15474 | "no distance bgp <1-255> <1-255> <1-255>", |
| 15475 | NO_STR |
| 15476 | "Define an administrative distance\n" |
| 15477 | "BGP distance\n" |
| 15478 | "Distance for routes external to the AS\n" |
| 15479 | "Distance for routes internal to the AS\n" |
| 15480 | "Distance for local routes\n") |
| 15481 | { |
| 15482 | struct bgp *bgp; |
| 15483 | |
| 15484 | bgp = vty->index; |
| 15485 | |
| 15486 | bgp->ipv6_distance_ebgp= 0; |
| 15487 | bgp->ipv6_distance_ibgp = 0; |
| 15488 | bgp->ipv6_distance_local = 0; |
| 15489 | return CMD_SUCCESS; |
| 15490 | } |
| 15491 | |
| 15492 | ALIAS (no_ipv6_bgp_distance, |
| 15493 | no_ipv6_bgp_distance2_cmd, |
| 15494 | "no distance bgp", |
| 15495 | NO_STR |
| 15496 | "Define an administrative distance\n" |
| 15497 | "BGP distance\n") |
| 15498 | |
| 15499 | DEFUN (ipv6_bgp_distance_source, |
| 15500 | ipv6_bgp_distance_source_cmd, |
| 15501 | "distance <1-255> X:X::X:X/M", |
| 15502 | "Define an administrative distance\n" |
| 15503 | "Administrative distance\n" |
| 15504 | "IP source prefix\n") |
| 15505 | { |
| 15506 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 15507 | return CMD_SUCCESS; |
| 15508 | } |
| 15509 | |
| 15510 | DEFUN (no_ipv6_bgp_distance_source, |
| 15511 | no_ipv6_bgp_distance_source_cmd, |
| 15512 | "no distance <1-255> X:X::X:X/M", |
| 15513 | NO_STR |
| 15514 | "Define an administrative distance\n" |
| 15515 | "Administrative distance\n" |
| 15516 | "IP source prefix\n") |
| 15517 | { |
| 15518 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 15519 | return CMD_SUCCESS; |
| 15520 | } |
| 15521 | |
| 15522 | DEFUN (ipv6_bgp_distance_source_access_list, |
| 15523 | ipv6_bgp_distance_source_access_list_cmd, |
| 15524 | "distance <1-255> X:X::X:X/M WORD", |
| 15525 | "Define an administrative distance\n" |
| 15526 | "Administrative distance\n" |
| 15527 | "IP source prefix\n" |
| 15528 | "Access list name\n") |
| 15529 | { |
| 15530 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 15531 | return CMD_SUCCESS; |
| 15532 | } |
| 15533 | |
| 15534 | DEFUN (no_ipv6_bgp_distance_source_access_list, |
| 15535 | no_ipv6_bgp_distance_source_access_list_cmd, |
| 15536 | "no distance <1-255> X:X::X:X/M WORD", |
| 15537 | NO_STR |
| 15538 | "Define an administrative distance\n" |
| 15539 | "Administrative distance\n" |
| 15540 | "IP source prefix\n" |
| 15541 | "Access list name\n") |
| 15542 | { |
| 15543 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 15544 | return CMD_SUCCESS; |
| 15545 | } |
| 15546 | #endif |
| 15547 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15548 | DEFUN (bgp_damp_set, |
| 15549 | bgp_damp_set_cmd, |
| 15550 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 15551 | "BGP Specific commands\n" |
| 15552 | "Enable route-flap dampening\n" |
| 15553 | "Half-life time for the penalty\n" |
| 15554 | "Value to start reusing a route\n" |
| 15555 | "Value to start suppressing a route\n" |
| 15556 | "Maximum duration to suppress a stable route\n") |
| 15557 | { |
| 15558 | struct bgp *bgp; |
| 15559 | int half = DEFAULT_HALF_LIFE * 60; |
| 15560 | int reuse = DEFAULT_REUSE; |
| 15561 | int suppress = DEFAULT_SUPPRESS; |
| 15562 | int max = 4 * half; |
| 15563 | |
| 15564 | if (argc == 4) |
| 15565 | { |
| 15566 | half = atoi (argv[0]) * 60; |
| 15567 | reuse = atoi (argv[1]); |
| 15568 | suppress = atoi (argv[2]); |
| 15569 | max = atoi (argv[3]) * 60; |
| 15570 | } |
| 15571 | else if (argc == 1) |
| 15572 | { |
| 15573 | half = atoi (argv[0]) * 60; |
| 15574 | max = 4 * half; |
| 15575 | } |
| 15576 | |
| 15577 | bgp = vty->index; |
Balaji | aa7dbb1 | 2015-03-16 16:55:26 +0000 | [diff] [blame] | 15578 | |
| 15579 | if (suppress < reuse) |
| 15580 | { |
| 15581 | vty_out (vty, "Suppress value cannot be less than reuse value %s", |
| 15582 | VTY_NEWLINE); |
| 15583 | return 0; |
| 15584 | } |
| 15585 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15586 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 15587 | half, reuse, suppress, max); |
| 15588 | } |
| 15589 | |
| 15590 | ALIAS (bgp_damp_set, |
| 15591 | bgp_damp_set2_cmd, |
| 15592 | "bgp dampening <1-45>", |
| 15593 | "BGP Specific commands\n" |
| 15594 | "Enable route-flap dampening\n" |
| 15595 | "Half-life time for the penalty\n") |
| 15596 | |
| 15597 | ALIAS (bgp_damp_set, |
| 15598 | bgp_damp_set3_cmd, |
| 15599 | "bgp dampening", |
| 15600 | "BGP Specific commands\n" |
| 15601 | "Enable route-flap dampening\n") |
| 15602 | |
| 15603 | DEFUN (bgp_damp_unset, |
| 15604 | bgp_damp_unset_cmd, |
| 15605 | "no bgp dampening", |
| 15606 | NO_STR |
| 15607 | "BGP Specific commands\n" |
| 15608 | "Enable route-flap dampening\n") |
| 15609 | { |
| 15610 | struct bgp *bgp; |
| 15611 | |
| 15612 | bgp = vty->index; |
| 15613 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 15614 | } |
| 15615 | |
| 15616 | ALIAS (bgp_damp_unset, |
| 15617 | bgp_damp_unset2_cmd, |
| 15618 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 15619 | NO_STR |
| 15620 | "BGP Specific commands\n" |
| 15621 | "Enable route-flap dampening\n" |
| 15622 | "Half-life time for the penalty\n" |
| 15623 | "Value to start reusing a route\n" |
| 15624 | "Value to start suppressing a route\n" |
| 15625 | "Maximum duration to suppress a stable route\n") |
| 15626 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 15627 | DEFUN (show_ip_bgp_dampened_paths, |
| 15628 | show_ip_bgp_dampened_paths_cmd, |
| 15629 | "show ip bgp dampened-paths", |
| 15630 | SHOW_STR |
| 15631 | IP_STR |
| 15632 | BGP_STR |
| 15633 | "Display paths suppressed due to dampening\n") |
| 15634 | { |
| 15635 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 15636 | NULL); |
| 15637 | } |
| 15638 | |
| 15639 | ALIAS (show_ip_bgp_dampened_paths, |
| 15640 | show_ip_bgp_damp_dampened_paths_cmd, |
| 15641 | "show ip bgp dampening dampened-paths", |
| 15642 | SHOW_STR |
| 15643 | IP_STR |
| 15644 | BGP_STR |
| 15645 | "Display detailed information about dampening\n" |
| 15646 | "Display paths suppressed due to dampening\n") |
| 15647 | |
| 15648 | DEFUN (show_ip_bgp_flap_statistics, |
| 15649 | show_ip_bgp_flap_statistics_cmd, |
| 15650 | "show ip bgp flap-statistics", |
| 15651 | SHOW_STR |
| 15652 | IP_STR |
| 15653 | BGP_STR |
| 15654 | "Display flap statistics of routes\n") |
| 15655 | { |
| 15656 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 15657 | bgp_show_type_flap_statistics, NULL); |
| 15658 | } |
| 15659 | |
| 15660 | ALIAS (show_ip_bgp_flap_statistics, |
| 15661 | show_ip_bgp_damp_flap_statistics_cmd, |
| 15662 | "show ip bgp dampening flap-statistics", |
| 15663 | SHOW_STR |
| 15664 | IP_STR |
| 15665 | BGP_STR |
| 15666 | "Display detailed information about dampening\n" |
| 15667 | "Display flap statistics of routes\n") |
| 15668 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15669 | DEFUN (show_bgp_ipv4_safi_dampened_paths, |
| 15670 | show_bgp_ipv4_safi_dampened_paths_cmd, |
| 15671 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15672 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15673 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15674 | IP_STR |
| 15675 | "Address Family modifier\n" |
| 15676 | "Address Family modifier\n" |
| 15677 | "Address Family modifier\n" |
| 15678 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15679 | "Display paths suppressed due to dampening\n") |
| 15680 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15681 | safi_t safi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15682 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15683 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15684 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15685 | return CMD_WARNING; |
| 15686 | } |
| 15687 | |
| 15688 | return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL); |
| 15689 | } |
| 15690 | ALIAS (show_bgp_ipv4_safi_dampened_paths, |
| 15691 | show_bgp_ipv4_safi_damp_dampened_paths_cmd, |
| 15692 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15693 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15694 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15695 | IP_STR |
| 15696 | "Address Family modifier\n" |
| 15697 | "Address Family modifier\n" |
| 15698 | "Address Family modifier\n" |
| 15699 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15700 | "Display detailed information about dampening\n" |
| 15701 | "Display paths suppressed due to dampening\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 15702 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15703 | DEFUN (show_bgp_ipv6_safi_dampened_paths, |
| 15704 | show_bgp_ipv6_safi_dampened_paths_cmd, |
| 15705 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15706 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15707 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15708 | IPV6_STR |
| 15709 | "Address Family modifier\n" |
| 15710 | "Address Family modifier\n" |
| 15711 | "Address Family modifier\n" |
| 15712 | "Address Family modifier\n" |
| 15713 | "Display paths suppressed due to dampening\n") |
| 15714 | { |
| 15715 | safi_t safi; |
| 15716 | |
| 15717 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15718 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15719 | return CMD_WARNING; |
| 15720 | } |
| 15721 | |
| 15722 | return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL); |
| 15723 | } |
| 15724 | ALIAS (show_bgp_ipv6_safi_dampened_paths, |
| 15725 | show_bgp_ipv6_safi_damp_dampened_paths_cmd, |
| 15726 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths", |
| 15727 | SHOW_STR |
| 15728 | BGP_STR |
| 15729 | IPV6_STR |
| 15730 | "Address Family modifier\n" |
| 15731 | "Address Family modifier\n" |
| 15732 | "Address Family modifier\n" |
| 15733 | "Address Family modifier\n" |
| 15734 | "Display detailed information about dampening\n" |
| 15735 | "Display paths suppressed due to dampening\n") |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15736 | |
| 15737 | DEFUN (show_bgp_ipv4_safi_flap_statistics, |
| 15738 | show_bgp_ipv4_safi_flap_statistics_cmd, |
| 15739 | "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics", |
| 15740 | SHOW_STR |
| 15741 | BGP_STR |
| 15742 | "Address Family\n" |
| 15743 | "Address Family modifier\n" |
| 15744 | "Address Family modifier\n" |
| 15745 | "Address Family modifier\n" |
| 15746 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15747 | "Display flap statistics of routes\n") |
| 15748 | { |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15749 | safi_t safi; |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15750 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15751 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15752 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15753 | return CMD_WARNING; |
| 15754 | } |
| 15755 | |
| 15756 | return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL); |
| 15757 | } |
| 15758 | ALIAS (show_bgp_ipv4_safi_flap_statistics, |
| 15759 | show_bgp_ipv4_safi_damp_flap_statistics_cmd, |
| 15760 | "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics", |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15761 | SHOW_STR |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15762 | BGP_STR |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15763 | "Address Family\n" |
| 15764 | "Address Family modifier\n" |
| 15765 | "Address Family modifier\n" |
| 15766 | "Address Family modifier\n" |
| 15767 | "Address Family modifier\n" |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15768 | "Display detailed information about dampening\n" |
| 15769 | "Display flap statistics of routes\n") |
Lou Berger | 205e674 | 2016-01-12 13:42:11 -0500 | [diff] [blame] | 15770 | |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 15771 | DEFUN (show_bgp_ipv6_safi_flap_statistics, |
| 15772 | show_bgp_ipv6_safi_flap_statistics_cmd, |
| 15773 | "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics", |
| 15774 | SHOW_STR |
| 15775 | BGP_STR |
| 15776 | "Address Family\n" |
| 15777 | "Address Family modifier\n" |
| 15778 | "Address Family modifier\n" |
| 15779 | "Address Family modifier\n" |
| 15780 | "Address Family modifier\n" |
| 15781 | "Display flap statistics of routes\n") |
| 15782 | { |
| 15783 | safi_t safi; |
| 15784 | |
| 15785 | if (bgp_parse_safi(argv[0], &safi)) { |
| 15786 | vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); |
| 15787 | return CMD_WARNING; |
| 15788 | } |
| 15789 | |
| 15790 | return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL); |
| 15791 | } |
| 15792 | ALIAS (show_bgp_ipv6_safi_flap_statistics, |
| 15793 | show_bgp_ipv6_safi_damp_flap_statistics_cmd, |
| 15794 | "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics", |
| 15795 | SHOW_STR |
| 15796 | BGP_STR |
| 15797 | "Address Family\n" |
| 15798 | "Address Family modifier\n" |
| 15799 | "Address Family modifier\n" |
| 15800 | "Address Family modifier\n" |
| 15801 | "Address Family modifier\n" |
| 15802 | "Display detailed information about dampening\n" |
| 15803 | "Display flap statistics of routes\n") |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 15804 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15805 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15806 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 15807 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 15808 | const char *ip_str, afi_t afi, safi_t safi, |
| 15809 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15810 | { |
| 15811 | int ret; |
| 15812 | struct prefix match; |
| 15813 | struct bgp_node *rn; |
| 15814 | struct bgp_node *rm; |
| 15815 | struct bgp_info *ri; |
| 15816 | struct bgp_info *ri_temp; |
| 15817 | struct bgp *bgp; |
| 15818 | struct bgp_table *table; |
| 15819 | |
| 15820 | /* BGP structure lookup. */ |
| 15821 | if (view_name) |
| 15822 | { |
| 15823 | bgp = bgp_lookup_by_name (view_name); |
| 15824 | if (bgp == NULL) |
| 15825 | { |
| 15826 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 15827 | return CMD_WARNING; |
| 15828 | } |
| 15829 | } |
| 15830 | else |
| 15831 | { |
| 15832 | bgp = bgp_get_default (); |
| 15833 | if (bgp == NULL) |
| 15834 | { |
| 15835 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 15836 | return CMD_WARNING; |
| 15837 | } |
| 15838 | } |
| 15839 | |
| 15840 | /* Check IP address argument. */ |
| 15841 | ret = str2prefix (ip_str, &match); |
| 15842 | if (! ret) |
| 15843 | { |
| 15844 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 15845 | return CMD_WARNING; |
| 15846 | } |
| 15847 | |
| 15848 | match.family = afi2family (afi); |
| 15849 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15850 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15851 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15852 | 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] | 15853 | { |
| 15854 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 15855 | continue; |
| 15856 | |
| 15857 | if ((table = rn->info) != NULL) |
| 15858 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 15859 | { |
| 15860 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 15861 | { |
| 15862 | ri = rm->info; |
| 15863 | while (ri) |
| 15864 | { |
| 15865 | if (ri->extra && ri->extra->damp_info) |
| 15866 | { |
| 15867 | ri_temp = ri->next; |
| 15868 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 15869 | ri = ri_temp; |
| 15870 | } |
| 15871 | else |
| 15872 | ri = ri->next; |
| 15873 | } |
| 15874 | } |
| 15875 | |
| 15876 | bgp_unlock_node (rm); |
| 15877 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15878 | } |
| 15879 | } |
| 15880 | else |
| 15881 | { |
| 15882 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 15883 | { |
| 15884 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 15885 | { |
| 15886 | ri = rn->info; |
| 15887 | while (ri) |
| 15888 | { |
| 15889 | if (ri->extra && ri->extra->damp_info) |
| 15890 | { |
| 15891 | ri_temp = ri->next; |
| 15892 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 15893 | ri = ri_temp; |
| 15894 | } |
| 15895 | else |
| 15896 | ri = ri->next; |
| 15897 | } |
| 15898 | } |
| 15899 | |
| 15900 | bgp_unlock_node (rn); |
| 15901 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15902 | } |
| 15903 | |
| 15904 | return CMD_SUCCESS; |
| 15905 | } |
| 15906 | |
| 15907 | DEFUN (clear_ip_bgp_dampening, |
| 15908 | clear_ip_bgp_dampening_cmd, |
| 15909 | "clear ip bgp dampening", |
| 15910 | CLEAR_STR |
| 15911 | IP_STR |
| 15912 | BGP_STR |
| 15913 | "Clear route flap dampening information\n") |
| 15914 | { |
| 15915 | bgp_damp_info_clean (); |
| 15916 | return CMD_SUCCESS; |
| 15917 | } |
| 15918 | |
| 15919 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 15920 | clear_ip_bgp_dampening_prefix_cmd, |
| 15921 | "clear ip bgp dampening A.B.C.D/M", |
| 15922 | CLEAR_STR |
| 15923 | IP_STR |
| 15924 | BGP_STR |
| 15925 | "Clear route flap dampening information\n" |
| 15926 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 15927 | { |
| 15928 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 15929 | SAFI_UNICAST, NULL, 1); |
| 15930 | } |
| 15931 | |
| 15932 | DEFUN (clear_ip_bgp_dampening_address, |
| 15933 | clear_ip_bgp_dampening_address_cmd, |
| 15934 | "clear ip bgp dampening A.B.C.D", |
| 15935 | CLEAR_STR |
| 15936 | IP_STR |
| 15937 | BGP_STR |
| 15938 | "Clear route flap dampening information\n" |
| 15939 | "Network to clear damping information\n") |
| 15940 | { |
| 15941 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 15942 | SAFI_UNICAST, NULL, 0); |
| 15943 | } |
| 15944 | |
| 15945 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 15946 | clear_ip_bgp_dampening_address_mask_cmd, |
| 15947 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 15948 | CLEAR_STR |
| 15949 | IP_STR |
| 15950 | BGP_STR |
| 15951 | "Clear route flap dampening information\n" |
| 15952 | "Network to clear damping information\n" |
| 15953 | "Network mask\n") |
| 15954 | { |
| 15955 | int ret; |
| 15956 | char prefix_str[BUFSIZ]; |
| 15957 | |
| 15958 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 15959 | if (! ret) |
| 15960 | { |
| 15961 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 15962 | return CMD_WARNING; |
| 15963 | } |
| 15964 | |
| 15965 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 15966 | SAFI_UNICAST, NULL, 0); |
| 15967 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 15968 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 15969 | /* also used for encap safi */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 15970 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 15971 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 15972 | afi_t afi, safi_t safi, int *write) |
| 15973 | { |
| 15974 | struct bgp_node *prn; |
| 15975 | struct bgp_node *rn; |
| 15976 | struct bgp_table *table; |
| 15977 | struct prefix *p; |
| 15978 | struct prefix_rd *prd; |
| 15979 | struct bgp_static *bgp_static; |
| 15980 | u_int32_t label; |
| 15981 | char buf[SU_ADDRSTRLEN]; |
| 15982 | char rdbuf[RD_ADDRSTRLEN]; |
| 15983 | |
| 15984 | /* Network configuration. */ |
| 15985 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 15986 | if ((table = prn->info) != NULL) |
| 15987 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 15988 | if ((bgp_static = rn->info) != NULL) |
| 15989 | { |
| 15990 | p = &rn->p; |
| 15991 | prd = (struct prefix_rd *) &prn->p; |
| 15992 | |
| 15993 | /* "address-family" display. */ |
| 15994 | bgp_config_write_family_header (vty, afi, safi, write); |
| 15995 | |
| 15996 | /* "network" configuration display. */ |
| 15997 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 15998 | label = decode_label (bgp_static->tag); |
| 15999 | |
| 16000 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 16001 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16002 | p->prefixlen, |
| 16003 | rdbuf, label); |
| 16004 | vty_out (vty, "%s", VTY_NEWLINE); |
| 16005 | } |
| 16006 | return 0; |
| 16007 | } |
| 16008 | |
| 16009 | /* Configuration of static route announcement and aggregate |
| 16010 | information. */ |
| 16011 | int |
| 16012 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 16013 | afi_t afi, safi_t safi, int *write) |
| 16014 | { |
| 16015 | struct bgp_node *rn; |
| 16016 | struct prefix *p; |
| 16017 | struct bgp_static *bgp_static; |
| 16018 | struct bgp_aggregate *bgp_aggregate; |
| 16019 | char buf[SU_ADDRSTRLEN]; |
| 16020 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 16021 | if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16022 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 16023 | |
| 16024 | /* Network configuration. */ |
| 16025 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 16026 | if ((bgp_static = rn->info) != NULL) |
| 16027 | { |
| 16028 | p = &rn->p; |
| 16029 | |
| 16030 | /* "address-family" display. */ |
| 16031 | bgp_config_write_family_header (vty, afi, safi, write); |
| 16032 | |
| 16033 | /* "network" configuration display. */ |
| 16034 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 16035 | { |
| 16036 | u_int32_t destination; |
| 16037 | struct in_addr netmask; |
| 16038 | |
| 16039 | destination = ntohl (p->u.prefix4.s_addr); |
| 16040 | masklen2ip (p->prefixlen, &netmask); |
| 16041 | vty_out (vty, " network %s", |
| 16042 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 16043 | |
| 16044 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 16045 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 16046 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 16047 | || p->u.prefix4.s_addr == 0) |
| 16048 | { |
| 16049 | /* Natural mask is not display. */ |
| 16050 | } |
| 16051 | else |
| 16052 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 16053 | } |
| 16054 | else |
| 16055 | { |
| 16056 | vty_out (vty, " network %s/%d", |
| 16057 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16058 | p->prefixlen); |
| 16059 | } |
| 16060 | |
| 16061 | if (bgp_static->rmap.name) |
| 16062 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 16063 | else |
| 16064 | { |
| 16065 | if (bgp_static->backdoor) |
| 16066 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 16067 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16068 | |
| 16069 | vty_out (vty, "%s", VTY_NEWLINE); |
| 16070 | } |
| 16071 | |
| 16072 | /* Aggregate-address configuration. */ |
| 16073 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 16074 | if ((bgp_aggregate = rn->info) != NULL) |
| 16075 | { |
| 16076 | p = &rn->p; |
| 16077 | |
| 16078 | /* "address-family" display. */ |
| 16079 | bgp_config_write_family_header (vty, afi, safi, write); |
| 16080 | |
| 16081 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 16082 | { |
| 16083 | struct in_addr netmask; |
| 16084 | |
| 16085 | masklen2ip (p->prefixlen, &netmask); |
| 16086 | vty_out (vty, " aggregate-address %s %s", |
| 16087 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16088 | inet_ntoa (netmask)); |
| 16089 | } |
| 16090 | else |
| 16091 | { |
| 16092 | vty_out (vty, " aggregate-address %s/%d", |
| 16093 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 16094 | p->prefixlen); |
| 16095 | } |
| 16096 | |
| 16097 | if (bgp_aggregate->as_set) |
| 16098 | vty_out (vty, " as-set"); |
| 16099 | |
| 16100 | if (bgp_aggregate->summary_only) |
| 16101 | vty_out (vty, " summary-only"); |
| 16102 | |
| 16103 | vty_out (vty, "%s", VTY_NEWLINE); |
| 16104 | } |
| 16105 | |
| 16106 | return 0; |
| 16107 | } |
| 16108 | |
| 16109 | int |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16110 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp, |
| 16111 | afi_t afi, safi_t safi, int *write) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16112 | { |
| 16113 | struct bgp_node *rn; |
| 16114 | struct bgp_distance *bdistance; |
| 16115 | |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16116 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 16117 | { |
| 16118 | /* Distance configuration. */ |
| 16119 | if (bgp->distance_ebgp |
| 16120 | && bgp->distance_ibgp |
| 16121 | && bgp->distance_local |
| 16122 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 16123 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 16124 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 16125 | vty_out (vty, " distance bgp %d %d %d%s", |
| 16126 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 16127 | VTY_NEWLINE); |
| 16128 | |
| 16129 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 16130 | if ((bdistance = rn->info) != NULL) |
| 16131 | { |
| 16132 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 16133 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 16134 | bdistance->access_list ? bdistance->access_list : "", |
| 16135 | VTY_NEWLINE); |
| 16136 | } |
| 16137 | } |
| 16138 | |
| 16139 | #ifdef HAVE_IPV6 |
| 16140 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
| 16141 | { |
| 16142 | bgp_config_write_family_header (vty, afi, safi, write); |
| 16143 | if (bgp->ipv6_distance_ebgp |
| 16144 | && bgp->ipv6_distance_ibgp |
| 16145 | && bgp->ipv6_distance_local |
| 16146 | && (bgp->ipv6_distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 16147 | || bgp->ipv6_distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 16148 | || bgp->ipv6_distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 16149 | vty_out (vty, " distance bgp %d %d %d%s", |
| 16150 | bgp->ipv6_distance_ebgp, bgp->ipv6_distance_ibgp, bgp->ipv6_distance_local, |
| 16151 | VTY_NEWLINE); |
| 16152 | |
| 16153 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 16154 | if ((bdistance = rn->info) != NULL) |
| 16155 | { |
| 16156 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 16157 | inet6_ntoa (rn->p.u.prefix6), rn->p.prefixlen, |
| 16158 | bdistance->access_list ? bdistance->access_list : "", |
| 16159 | VTY_NEWLINE); |
| 16160 | } |
| 16161 | } |
| 16162 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16163 | |
| 16164 | return 0; |
| 16165 | } |
| 16166 | |
| 16167 | /* Allocate routing table structure and install commands. */ |
| 16168 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 16169 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16170 | { |
| 16171 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 16172 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16173 | |
| 16174 | /* IPv4 BGP commands. */ |
| 16175 | install_element (BGP_NODE, &bgp_network_cmd); |
| 16176 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 16177 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 16178 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 16179 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 16180 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 16181 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 16182 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 16183 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 16184 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 16185 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 16186 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 16187 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 16188 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 16189 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 16190 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 16191 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 16192 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 16193 | |
| 16194 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 16195 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 16196 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 16197 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 16198 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 16199 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 16200 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 16201 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 16202 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 16203 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 16204 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 16205 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 16206 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 16207 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 16208 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 16209 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 16210 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 16211 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 16212 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 16213 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16214 | |
| 16215 | /* IPv4 unicast configuration. */ |
| 16216 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 16217 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 16218 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 16219 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 16220 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 16221 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16222 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16223 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 16224 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 16225 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 16226 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 16227 | 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] | 16228 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16229 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 16230 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 16231 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 16232 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 16233 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 16234 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 16235 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 16236 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 16237 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 16238 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 16239 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 16240 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 16241 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 16242 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 16243 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 16244 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 16245 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 16246 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 16247 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 16248 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16249 | |
| 16250 | /* IPv4 multicast configuration. */ |
| 16251 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 16252 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 16253 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 16254 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 16255 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 16256 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 16257 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 16258 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 16259 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 16260 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 16261 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 16262 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 16263 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 16264 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 16265 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 16266 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 16267 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 16268 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 16269 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 16270 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 16271 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 16272 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 16273 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 16274 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 16275 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 16276 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 16277 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 16278 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 16279 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 16280 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 16281 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 16282 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 16283 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16284 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16285 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16286 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd); |
| 16287 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd); |
| 16288 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); |
| 16289 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); |
| 16290 | install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd); |
| 16291 | install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd); |
| 16292 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd); |
| 16293 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd); |
| 16294 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16295 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16296 | install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd); |
| 16297 | install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd); |
| 16298 | install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd); |
| 16299 | install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd); |
| 16300 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); |
| 16301 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); |
| 16302 | install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd); |
| 16303 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd); |
| 16304 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd); |
| 16305 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd); |
| 16306 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd); |
| 16307 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd); |
| 16308 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd); |
| 16309 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd); |
| 16310 | install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd); |
| 16311 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd); |
| 16312 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd); |
| 16313 | install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd); |
| 16314 | install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd); |
| 16315 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd); |
| 16316 | install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd); |
| 16317 | install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd); |
| 16318 | install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd); |
| 16319 | install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd); |
| 16320 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd); |
| 16321 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd); |
| 16322 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd); |
| 16323 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16324 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 16325 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 16326 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 16327 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 16328 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16329 | install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd); |
| 16330 | install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd); |
| 16331 | install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd); |
| 16332 | install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd); |
| 16333 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd); |
| 16334 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd); |
| 16335 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd); |
| 16336 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd); |
| 16337 | install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd); |
| 16338 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd); |
| 16339 | install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd); |
| 16340 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd); |
| 16341 | install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd); |
| 16342 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd); |
| 16343 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd); |
| 16344 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd); |
| 16345 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd); |
| 16346 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd); |
| 16347 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16348 | 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] | 16349 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd); |
| 16350 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd); |
| 16351 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd); |
| 16352 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd); |
| 16353 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd); |
| 16354 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd); |
| 16355 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd); |
| 16356 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd); |
| 16357 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd); |
| 16358 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd); |
| 16359 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd); |
| 16360 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd); |
| 16361 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd); |
| 16362 | install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd); |
| 16363 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd); |
| 16364 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd); |
| 16365 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd); |
| 16366 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd); |
| 16367 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd); |
| 16368 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd); |
| 16369 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd); |
| 16370 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd); |
| 16371 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd); |
| 16372 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd); |
| 16373 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd); |
| 16374 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd); |
| 16375 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd); |
| 16376 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd); |
| 16377 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd); |
| 16378 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd); |
| 16379 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd); |
| 16380 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd); |
| 16381 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd); |
| 16382 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd); |
| 16383 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd); |
| 16384 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd); |
| 16385 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd); |
| 16386 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd); |
| 16387 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd); |
| 16388 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd); |
| 16389 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd); |
| 16390 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd); |
| 16391 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd); |
| 16392 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd); |
| 16393 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16394 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16395 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16396 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16397 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16398 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16399 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16400 | |
| 16401 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16402 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16403 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); |
| 16404 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); |
| 16405 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd); |
| 16406 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd); |
| 16407 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16408 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16409 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd); |
| 16410 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd); |
| 16411 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd); |
| 16412 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd); |
| 16413 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); |
| 16414 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); |
| 16415 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd); |
| 16416 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd); |
| 16417 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd); |
| 16418 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd); |
| 16419 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd); |
| 16420 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd); |
| 16421 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd); |
| 16422 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd); |
| 16423 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd); |
| 16424 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16425 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 16426 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 16427 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 16428 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 16429 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16430 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd); |
| 16431 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd); |
| 16432 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd); |
| 16433 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd); |
| 16434 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd); |
| 16435 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd); |
| 16436 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd); |
| 16437 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16438 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16439 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16440 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16441 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16442 | |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16443 | /* BGP dampening clear commands */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16444 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 16445 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 16446 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 16447 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 16448 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16449 | /* New config IPv6 BGP commands. */ |
| 16450 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 16451 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 16452 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 16453 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 16454 | |
| 16455 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 16456 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 16457 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 16458 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 16459 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 16460 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 16461 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 16462 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16463 | /* Old config IPv6 BGP commands. */ |
| 16464 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 16465 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 16466 | |
| 16467 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 16468 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 16469 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 16470 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 16471 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16472 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16473 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16474 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16475 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16476 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16477 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16478 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16479 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16480 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16481 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd); |
| 16482 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd); |
| 16483 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd); |
| 16484 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd); |
| 16485 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd); |
| 16486 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd); |
| 16487 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd); |
| 16488 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16489 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16490 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16491 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16492 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16493 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16494 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16495 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16496 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16497 | install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd); |
| 16498 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16499 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16500 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16501 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16502 | install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16503 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16504 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16505 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16506 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16507 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16508 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16509 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16510 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16511 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 16512 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16513 | install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd); |
| 16514 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16515 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16516 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16517 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16518 | install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16519 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16520 | |
| 16521 | /* Restricted: |
| 16522 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 16523 | */ |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16524 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16525 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16526 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16527 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16528 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd); |
| 16529 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd); |
| 16530 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd); |
| 16531 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd); |
| 16532 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd); |
| 16533 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd); |
| 16534 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd); |
| 16535 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd); |
| 16536 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16537 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16538 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16539 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16540 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16541 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 16542 | 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] | 16543 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16544 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16545 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 16546 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16547 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 16548 | /* Statistics */ |
| 16549 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
Lou Berger | 651b402 | 2016-01-12 13:42:07 -0500 | [diff] [blame] | 16550 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16551 | |
| 16552 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 16553 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 16554 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 16555 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 16556 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 16557 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 16558 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
Roman Hoog Antink | 6184c39 | 2014-03-17 14:01:42 +0100 | [diff] [blame] | 16559 | #ifdef HAVE_IPV6 |
| 16560 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_cmd); |
| 16561 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_cmd); |
| 16562 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance2_cmd); |
| 16563 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_cmd); |
| 16564 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_cmd); |
| 16565 | install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_access_list_cmd); |
| 16566 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_access_list_cmd); |
| 16567 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16568 | |
| 16569 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 16570 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 16571 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 16572 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 16573 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 16574 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 16575 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 16576 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 16577 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 16578 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Balaji | 9145f0e | 2016-01-20 22:59:27 +0530 | [diff] [blame] | 16579 | |
| 16580 | /* IPv4 Multicast Mode */ |
| 16581 | install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd); |
| 16582 | install_element (BGP_IPV4M_NODE, &bgp_damp_set2_cmd); |
| 16583 | install_element (BGP_IPV4M_NODE, &bgp_damp_set3_cmd); |
| 16584 | install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd); |
| 16585 | install_element (BGP_IPV4M_NODE, &bgp_damp_unset2_cmd); |
| 16586 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16587 | |
| 16588 | /* Deprecated AS-Pathlimit commands */ |
| 16589 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 16590 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 16591 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16592 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16593 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16594 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16595 | |
| 16596 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 16597 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16598 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16599 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16600 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16601 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16602 | |
| 16603 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 16604 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 16605 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16606 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16607 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16608 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16609 | |
| 16610 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 16611 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16612 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16613 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16614 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16615 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16616 | |
| 16617 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 16618 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 16619 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 16620 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 16621 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 16622 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 16623 | |
| 16624 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 16625 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 16626 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 16627 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 16628 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 16629 | 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] | 16630 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 16631 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 16632 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16633 | |
| 16634 | /* old style commands */ |
| 16635 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 16636 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 16637 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16638 | install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd); |
| 16639 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16640 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 16641 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 16642 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 16643 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 16644 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16645 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
| 16646 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); |
| 16647 | install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16648 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 16649 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 16650 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 16651 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 16652 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 16653 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 16654 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 16655 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 16656 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 16657 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 16658 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 16659 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 16660 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 16661 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 16662 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 16663 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 16664 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 16665 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 16666 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 16667 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 16668 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 16669 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 16670 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 16671 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 16672 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 16673 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 16674 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 16675 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 16676 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 16677 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 16678 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 16679 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 16680 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 16681 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 16682 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 16683 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 16684 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 16685 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 16686 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 16687 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 16688 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 16689 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 16690 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 16691 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 16692 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 16693 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 16694 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 16695 | install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 16696 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16697 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 9c52cae | 2016-01-20 22:59:26 +0530 | [diff] [blame] | 16698 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd); |
| 16699 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16700 | install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
| 16701 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 16702 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
| 16703 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 16704 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd); |
| 16705 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 16706 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 16707 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
| 16708 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 16709 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 16710 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
| 16711 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 16712 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
| 16713 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 16714 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
| 16715 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 16716 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
| 16717 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 16718 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
| 16719 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
| 16720 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 16721 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 16722 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 16723 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
| 16724 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 16725 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 16726 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16727 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16728 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16729 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd); |
| 16730 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16731 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 16732 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 16733 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 16734 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16735 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); |
| 16736 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd); |
| 16737 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16738 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 16739 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 16740 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 16741 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 16742 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 16743 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 16744 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 16745 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 16746 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 16747 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 16748 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 16749 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 16750 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 16751 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 16752 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 16753 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 16754 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 16755 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 16756 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 16757 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 16758 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 16759 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 16760 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 16761 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16762 | |
| 16763 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 16764 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 16765 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16766 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16767 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 16768 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 16769 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 16770 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16771 | install_element (VIEW_NODE, &show_bgp_route_pathtype_cmd); |
| 16772 | install_element (VIEW_NODE, &show_bgp_ipv6_route_pathtype_cmd); |
| 16773 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); |
| 16774 | install_element (VIEW_NODE, &show_bgp_prefix_pathtype_cmd); |
| 16775 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); |
| 16776 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16777 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 16778 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 16779 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 16780 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 16781 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 16782 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 16783 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 16784 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 16785 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 16786 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 16787 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 16788 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 16789 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 16790 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 16791 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd); |
| 16792 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 16793 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd); |
| 16794 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 16795 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 16796 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 16797 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 16798 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 16799 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 16800 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 16801 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
| 16802 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 16803 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 16804 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 16805 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 16806 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 16807 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 16808 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 16809 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 16810 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 16811 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16812 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16813 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 16814 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16815 | install_element (RESTRICTED_NODE, &show_bgp_route_pathtype_cmd); |
| 16816 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_pathtype_cmd); |
| 16817 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); |
| 16818 | install_element (RESTRICTED_NODE, &show_bgp_prefix_pathtype_cmd); |
| 16819 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_pathtype_cmd); |
| 16820 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16821 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 16822 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 16823 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 16824 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 16825 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 16826 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 16827 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 16828 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 16829 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 16830 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 16831 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
Daniel Walton | 59fe0ee | 2015-05-19 17:58:11 -0700 | [diff] [blame] | 16832 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16833 | install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
| 16834 | install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16835 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16836 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 16837 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 16838 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 16839 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 16840 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 16841 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 16842 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 16843 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 16844 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 16845 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 16846 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 16847 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 16848 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 16849 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 16850 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 16851 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 16852 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 16853 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 16854 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 16855 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 16856 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 16857 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 16858 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 16859 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 16860 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 16861 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 16862 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 16863 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 16864 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 16865 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 16866 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 16867 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 16868 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 16869 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 16870 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 16871 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16872 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16873 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16874 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16875 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16876 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16877 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16878 | /* old with name safi collision */ |
| 16879 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 16880 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 16881 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 16882 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 16883 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 16884 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 16885 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 16886 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 16887 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 16888 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 16889 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 16890 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 16891 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 16892 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 16893 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 16894 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
Donald Sharp | 68b45cc | 2016-03-11 14:27:13 -0500 | [diff] [blame] | 16895 | |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16896 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 16897 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16898 | |
| 16899 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
| 16900 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
| 16901 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
| 16902 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Lou Berger | f9b6c39 | 2016-01-12 13:42:09 -0500 | [diff] [blame] | 16903 | |
| 16904 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
| 16905 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
| 16906 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
| 16907 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 16908 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 16909 | |
| 16910 | void |
| 16911 | bgp_route_finish (void) |
| 16912 | { |
| 16913 | bgp_table_unlock (bgp_distance_table); |
| 16914 | bgp_distance_table = NULL; |
| 16915 | } |