paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* BGP routing information |
| 2 | Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro |
| 3 | |
| 4 | This file is part of GNU Zebra. |
| 5 | |
| 6 | GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | under the terms of the GNU General Public License as published by the |
| 8 | Free Software Foundation; either version 2, or (at your option) any |
| 9 | later version. |
| 10 | |
| 11 | GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 19 | 02111-1307, USA. */ |
| 20 | |
| 21 | #include <zebra.h> |
| 22 | |
| 23 | #include "prefix.h" |
| 24 | #include "linklist.h" |
| 25 | #include "memory.h" |
| 26 | #include "command.h" |
| 27 | #include "stream.h" |
| 28 | #include "filter.h" |
| 29 | #include "str.h" |
| 30 | #include "log.h" |
| 31 | #include "routemap.h" |
| 32 | #include "buffer.h" |
| 33 | #include "sockunion.h" |
| 34 | #include "plist.h" |
| 35 | #include "thread.h" |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 36 | #include "workqueue.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 37 | |
| 38 | #include "bgpd/bgpd.h" |
| 39 | #include "bgpd/bgp_table.h" |
| 40 | #include "bgpd/bgp_route.h" |
| 41 | #include "bgpd/bgp_attr.h" |
| 42 | #include "bgpd/bgp_debug.h" |
| 43 | #include "bgpd/bgp_aspath.h" |
| 44 | #include "bgpd/bgp_regex.h" |
| 45 | #include "bgpd/bgp_community.h" |
| 46 | #include "bgpd/bgp_ecommunity.h" |
| 47 | #include "bgpd/bgp_clist.h" |
| 48 | #include "bgpd/bgp_packet.h" |
| 49 | #include "bgpd/bgp_filter.h" |
| 50 | #include "bgpd/bgp_fsm.h" |
| 51 | #include "bgpd/bgp_mplsvpn.h" |
| 52 | #include "bgpd/bgp_nexthop.h" |
| 53 | #include "bgpd/bgp_damp.h" |
| 54 | #include "bgpd/bgp_advertise.h" |
| 55 | #include "bgpd/bgp_zebra.h" |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 56 | #include "bgpd/bgp_vty.h" |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 57 | #include "bgpd/bgp_mpath.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 58 | |
| 59 | /* Extern from bgp_dump.c */ |
Stephen Hemminger | dde7258 | 2009-05-08 15:19:07 -0700 | [diff] [blame] | 60 | extern const char *bgp_origin_str[]; |
| 61 | extern const char *bgp_origin_long_str[]; |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 62 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 63 | static struct bgp_node * |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 64 | bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 65 | struct prefix_rd *prd) |
| 66 | { |
| 67 | struct bgp_node *rn; |
| 68 | struct bgp_node *prn = NULL; |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 69 | |
| 70 | assert (table); |
| 71 | if (!table) |
| 72 | return NULL; |
| 73 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 74 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 75 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 76 | prn = bgp_node_get (table, (struct prefix *) prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 77 | |
| 78 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 79 | prn->info = bgp_table_init (afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 80 | else |
| 81 | bgp_unlock_node (prn); |
| 82 | table = prn->info; |
| 83 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 84 | |
| 85 | rn = bgp_node_get (table, p); |
| 86 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 87 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 88 | rn->prn = prn; |
| 89 | |
| 90 | return rn; |
| 91 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 92 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 93 | /* Allocate bgp_info_extra */ |
| 94 | static struct bgp_info_extra * |
| 95 | bgp_info_extra_new (void) |
| 96 | { |
| 97 | struct bgp_info_extra *new; |
| 98 | new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra)); |
| 99 | return new; |
| 100 | } |
| 101 | |
| 102 | static void |
| 103 | bgp_info_extra_free (struct bgp_info_extra **extra) |
| 104 | { |
| 105 | if (extra && *extra) |
| 106 | { |
| 107 | if ((*extra)->damp_info) |
| 108 | bgp_damp_info_free ((*extra)->damp_info, 0); |
| 109 | |
| 110 | (*extra)->damp_info = NULL; |
| 111 | |
| 112 | XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra); |
| 113 | |
| 114 | *extra = NULL; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /* Get bgp_info extra information for the given bgp_info, lazy allocated |
| 119 | * if required. |
| 120 | */ |
| 121 | struct bgp_info_extra * |
| 122 | bgp_info_extra_get (struct bgp_info *ri) |
| 123 | { |
| 124 | if (!ri->extra) |
| 125 | ri->extra = bgp_info_extra_new(); |
| 126 | return ri->extra; |
| 127 | } |
| 128 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 129 | /* Allocate new bgp info structure. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 130 | static struct bgp_info * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 131 | bgp_info_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 132 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 133 | return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | /* Free bgp route information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 137 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 138 | bgp_info_free (struct bgp_info *binfo) |
| 139 | { |
| 140 | if (binfo->attr) |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 141 | bgp_attr_unintern (&binfo->attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 142 | |
| 143 | bgp_info_extra_free (&binfo->extra); |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 144 | bgp_info_mpath_free (&binfo->mpath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 145 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 146 | peer_unlock (binfo->peer); /* bgp_info peer reference */ |
| 147 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 148 | XFREE (MTYPE_BGP_ROUTE, binfo); |
| 149 | } |
| 150 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 151 | struct bgp_info * |
| 152 | bgp_info_lock (struct bgp_info *binfo) |
| 153 | { |
| 154 | binfo->lock++; |
| 155 | return binfo; |
| 156 | } |
| 157 | |
| 158 | struct bgp_info * |
| 159 | bgp_info_unlock (struct bgp_info *binfo) |
| 160 | { |
| 161 | assert (binfo && binfo->lock > 0); |
| 162 | binfo->lock--; |
| 163 | |
| 164 | if (binfo->lock == 0) |
| 165 | { |
| 166 | #if 0 |
| 167 | zlog_debug ("%s: unlocked and freeing", __func__); |
| 168 | zlog_backtrace (LOG_DEBUG); |
| 169 | #endif |
| 170 | bgp_info_free (binfo); |
| 171 | return NULL; |
| 172 | } |
| 173 | |
| 174 | #if 0 |
| 175 | if (binfo->lock == 1) |
| 176 | { |
| 177 | zlog_debug ("%s: unlocked to 1", __func__); |
| 178 | zlog_backtrace (LOG_DEBUG); |
| 179 | } |
| 180 | #endif |
| 181 | |
| 182 | return binfo; |
| 183 | } |
| 184 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 185 | void |
| 186 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) |
| 187 | { |
| 188 | struct bgp_info *top; |
| 189 | |
| 190 | top = rn->info; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 191 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 192 | ri->next = rn->info; |
| 193 | ri->prev = NULL; |
| 194 | if (top) |
| 195 | top->prev = ri; |
| 196 | rn->info = ri; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 197 | |
| 198 | bgp_info_lock (ri); |
| 199 | bgp_lock_node (rn); |
| 200 | peer_lock (ri->peer); /* bgp_info peer reference */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 201 | } |
| 202 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 203 | /* Do the actual removal of info from RIB, for use by bgp_process |
| 204 | completion callback *only* */ |
| 205 | static void |
| 206 | bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 207 | { |
| 208 | if (ri->next) |
| 209 | ri->next->prev = ri->prev; |
| 210 | if (ri->prev) |
| 211 | ri->prev->next = ri->next; |
| 212 | else |
| 213 | rn->info = ri->next; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 214 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 215 | bgp_info_mpath_dequeue (ri); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 216 | bgp_info_unlock (ri); |
| 217 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 218 | } |
| 219 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 220 | void |
| 221 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) |
| 222 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 223 | bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED); |
| 224 | /* set of previous already took care of pcount */ |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 225 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 226 | } |
| 227 | |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 228 | /* undo the effects of a previous call to bgp_info_delete; typically |
| 229 | called when a route is deleted and then quickly re-added before the |
| 230 | deletion has been processed */ |
| 231 | static void |
| 232 | bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri) |
| 233 | { |
| 234 | bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED); |
| 235 | /* unset of previous already took care of pcount */ |
| 236 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 237 | } |
| 238 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 239 | /* Adjust pcount as required */ |
| 240 | static void |
| 241 | bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) |
| 242 | { |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 243 | struct bgp_table *table; |
| 244 | |
| 245 | assert (rn && bgp_node_table (rn)); |
Paul Jakma | 6f58544 | 2006-10-22 19:13:07 +0000 | [diff] [blame] | 246 | assert (ri && ri->peer && ri->peer->bgp); |
| 247 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 248 | table = bgp_node_table (rn); |
| 249 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 250 | /* Ignore 'pcount' for RS-client tables */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 251 | if (table->type != BGP_TABLE_MAIN |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 252 | || ri->peer == ri->peer->bgp->peer_self) |
| 253 | return; |
| 254 | |
| 255 | if (BGP_INFO_HOLDDOWN (ri) |
| 256 | && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 257 | { |
| 258 | |
| 259 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 260 | |
| 261 | /* slight hack, but more robust against errors. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 262 | if (ri->peer->pcount[table->afi][table->safi]) |
| 263 | ri->peer->pcount[table->afi][table->safi]--; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 264 | else |
| 265 | { |
| 266 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", |
| 267 | __func__, ri->peer->host); |
| 268 | zlog_backtrace (LOG_WARNING); |
| 269 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); |
| 270 | } |
| 271 | } |
| 272 | else if (!BGP_INFO_HOLDDOWN (ri) |
| 273 | && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 274 | { |
| 275 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 276 | ri->peer->pcount[table->afi][table->safi]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 277 | } |
| 278 | } |
| 279 | |
| 280 | |
| 281 | /* Set/unset bgp_info flags, adjusting any other state as needed. |
| 282 | * This is here primarily to keep prefix-count in check. |
| 283 | */ |
| 284 | void |
| 285 | bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 286 | { |
| 287 | SET_FLAG (ri->flags, flag); |
| 288 | |
| 289 | /* early bath if we know it's not a flag that changes useability state */ |
| 290 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 291 | return; |
| 292 | |
| 293 | bgp_pcount_adjust (rn, ri); |
| 294 | } |
| 295 | |
| 296 | void |
| 297 | bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) |
| 298 | { |
| 299 | UNSET_FLAG (ri->flags, flag); |
| 300 | |
| 301 | /* early bath if we know it's not a flag that changes useability state */ |
| 302 | if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) |
| 303 | return; |
| 304 | |
| 305 | bgp_pcount_adjust (rn, ri); |
| 306 | } |
| 307 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 308 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 309 | missing-as-worst" is specified, treat it as the worst value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 310 | static u_int32_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 311 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
| 312 | { |
| 313 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 314 | return attr->med; |
| 315 | else |
| 316 | { |
| 317 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 318 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 319 | else |
| 320 | return 0; |
| 321 | } |
| 322 | } |
| 323 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 324 | /* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist |
| 325 | * is preferred, or 0 if they are the same (usually will only occur if |
| 326 | * multipath is enabled */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 327 | static int |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 328 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 329 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 330 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 331 | struct attr *newattr, *existattr; |
| 332 | struct attr_extra *newattre, *existattre; |
| 333 | bgp_peer_sort_t new_sort; |
| 334 | bgp_peer_sort_t exist_sort; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 335 | u_int32_t new_pref; |
| 336 | u_int32_t exist_pref; |
| 337 | u_int32_t new_med; |
| 338 | u_int32_t exist_med; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 339 | u_int32_t new_weight; |
| 340 | u_int32_t exist_weight; |
| 341 | uint32_t newm, existm; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 342 | struct in_addr new_id; |
| 343 | struct in_addr exist_id; |
| 344 | int new_cluster; |
| 345 | int exist_cluster; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 346 | int internal_as_route; |
| 347 | int confed_as_route; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 348 | int ret; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 349 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 350 | /* 0. Null check. */ |
| 351 | if (new == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 352 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 353 | if (exist == NULL) |
| 354 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 355 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 356 | newattr = new->attr; |
| 357 | existattr = exist->attr; |
| 358 | newattre = newattr->extra; |
| 359 | existattre = existattr->extra; |
| 360 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 361 | /* 1. Weight check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 362 | new_weight = exist_weight = 0; |
| 363 | |
| 364 | if (newattre) |
| 365 | new_weight = newattre->weight; |
| 366 | if (existattre) |
| 367 | exist_weight = existattre->weight; |
| 368 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 369 | if (new_weight > exist_weight) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 370 | return -1; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 371 | if (new_weight < exist_weight) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 372 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 373 | |
| 374 | /* 2. Local preference check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 375 | new_pref = exist_pref = bgp->default_local_pref; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 376 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 377 | if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 378 | new_pref = newattr->local_pref; |
| 379 | if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 380 | exist_pref = existattr->local_pref; |
| 381 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 382 | if (new_pref > exist_pref) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 383 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 384 | if (new_pref < exist_pref) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 385 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 386 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 387 | /* 3. Local route check. We prefer: |
| 388 | * - BGP_ROUTE_STATIC |
| 389 | * - BGP_ROUTE_AGGREGATE |
| 390 | * - BGP_ROUTE_REDISTRIBUTE |
| 391 | */ |
| 392 | if (! (new->sub_type == BGP_ROUTE_NORMAL)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 393 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 394 | if (! (exist->sub_type == BGP_ROUTE_NORMAL)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 395 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 396 | |
| 397 | /* 4. AS path length check. */ |
| 398 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 399 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 400 | int exist_hops = aspath_count_hops (existattr->aspath); |
| 401 | int exist_confeds = aspath_count_confeds (existattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 402 | |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 403 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
| 404 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 405 | int aspath_hops; |
| 406 | |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 407 | aspath_hops = aspath_count_hops (newattr->aspath); |
| 408 | aspath_hops += aspath_count_confeds (newattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 409 | |
| 410 | if ( aspath_hops < (exist_hops + exist_confeds)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 411 | return -1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 412 | if ( aspath_hops > (exist_hops + exist_confeds)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 413 | return 1; |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 414 | } |
| 415 | else |
| 416 | { |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 417 | int newhops = aspath_count_hops (newattr->aspath); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 418 | |
| 419 | if (newhops < exist_hops) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 420 | return -1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 421 | if (newhops > exist_hops) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 422 | return 1; |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 423 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | /* 5. Origin check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 427 | if (newattr->origin < existattr->origin) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 428 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 429 | if (newattr->origin > existattr->origin) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 430 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 431 | |
| 432 | /* 6. MED check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 433 | internal_as_route = (aspath_count_hops (newattr->aspath) == 0 |
| 434 | && aspath_count_hops (existattr->aspath) == 0); |
| 435 | confed_as_route = (aspath_count_confeds (newattr->aspath) > 0 |
| 436 | && aspath_count_confeds (existattr->aspath) > 0 |
| 437 | && aspath_count_hops (newattr->aspath) == 0 |
| 438 | && aspath_count_hops (existattr->aspath) == 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 439 | |
| 440 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 441 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 442 | && confed_as_route) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 443 | || aspath_cmp_left (newattr->aspath, existattr->aspath) |
| 444 | || aspath_cmp_left_confed (newattr->aspath, existattr->aspath) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 445 | || internal_as_route) |
| 446 | { |
| 447 | new_med = bgp_med_value (new->attr, bgp); |
| 448 | exist_med = bgp_med_value (exist->attr, bgp); |
| 449 | |
| 450 | if (new_med < exist_med) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 451 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 452 | if (new_med > exist_med) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 453 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | /* 7. Peer type check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 457 | new_sort = new->peer->sort; |
| 458 | exist_sort = exist->peer->sort; |
| 459 | |
| 460 | if (new_sort == BGP_PEER_EBGP |
| 461 | && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 462 | return -1; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 463 | if (exist_sort == BGP_PEER_EBGP |
| 464 | && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 465 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 466 | |
| 467 | /* 8. IGP metric check. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 468 | newm = existm = 0; |
| 469 | |
| 470 | if (new->extra) |
| 471 | newm = new->extra->igpmetric; |
| 472 | if (exist->extra) |
| 473 | existm = exist->extra->igpmetric; |
| 474 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 475 | if (newm < existm) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 476 | return -1; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 477 | if (newm > existm) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 478 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 479 | |
| 480 | /* 9. Maximum path check. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 481 | if (bgp_mpath_is_configured (bgp, afi, safi)) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 482 | { |
Pradosh Mohapatra | 2fdd455 | 2013-09-07 07:02:36 +0000 | [diff] [blame] | 483 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) |
| 484 | { |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 485 | /* |
| 486 | * For the two paths, all comparison steps till IGP metric |
| 487 | * have succeeded - including AS_PATH hop count. Since 'bgp |
| 488 | * bestpath as-path multipath-relax' knob is on, we don't need |
| 489 | * an exact match of AS_PATH. Thus, mark the paths are equal. |
| 490 | * That will trigger both these paths to get into the multipath |
| 491 | * array. |
| 492 | */ |
| 493 | return 0; |
Pradosh Mohapatra | 2fdd455 | 2013-09-07 07:02:36 +0000 | [diff] [blame] | 494 | } |
| 495 | else if (new->peer->sort == BGP_PEER_IBGP) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 496 | { |
| 497 | if (aspath_cmp (new->attr->aspath, exist->attr->aspath)) |
| 498 | return 0; |
| 499 | } |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 500 | else if (new->peer->as == exist->peer->as) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 501 | return 0; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 502 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 503 | |
| 504 | /* 10. If both paths are external, prefer the path that was received |
| 505 | first (the oldest one). This step minimizes route-flap, since a |
| 506 | newer path won't displace an older one, even if it was the |
| 507 | preferred route based on the additional decision criteria below. */ |
| 508 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 509 | && new_sort == BGP_PEER_EBGP |
| 510 | && exist_sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 511 | { |
| 512 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 513 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 514 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 515 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 516 | } |
| 517 | |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 518 | /* 11. Router-ID comparision. */ |
| 519 | /* If one of the paths is "stale", the corresponding peer router-id will |
| 520 | * be 0 and would always win over the other path. If originator id is |
| 521 | * used for the comparision, it will decide which path is better. |
| 522 | */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 523 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 524 | new_id.s_addr = newattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 525 | else |
| 526 | new_id.s_addr = new->peer->remote_id.s_addr; |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 527 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 528 | exist_id.s_addr = existattre->originator_id.s_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 529 | else |
| 530 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 531 | |
| 532 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 533 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 534 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 535 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 536 | |
| 537 | /* 12. Cluster length comparision. */ |
Jorge Boncompte [DTI2] | 8ff5631 | 2012-05-07 16:52:56 +0000 | [diff] [blame] | 538 | new_cluster = exist_cluster = 0; |
| 539 | |
| 540 | if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 541 | new_cluster = newattre->cluster->length; |
| 542 | if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 543 | exist_cluster = existattre->cluster->length; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 544 | |
| 545 | if (new_cluster < exist_cluster) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 546 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 547 | if (new_cluster > exist_cluster) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 548 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 549 | |
| 550 | /* 13. Neighbor address comparision. */ |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 551 | /* Do this only if neither path is "stale" as stale paths do not have |
| 552 | * valid peer information (as the connection may or may not be up). |
| 553 | */ |
| 554 | if (CHECK_FLAG (exist->flags, BGP_INFO_STALE)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 555 | return -1; |
vivek | bd4b7f1 | 2014-09-30 15:54:45 -0700 | [diff] [blame] | 556 | if (CHECK_FLAG (new->flags, BGP_INFO_STALE)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 557 | return 1; |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 558 | /* locally configured routes to advertise do not have su_remote */ |
| 559 | if (new->peer->su_remote == NULL) |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 560 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 561 | if (exist->peer->su_remote == NULL) |
| 562 | return -1; |
Timo Teräs | 2820a01 | 2015-06-24 15:27:21 +0300 | [diff] [blame] | 563 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 564 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 565 | |
| 566 | if (ret == 1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 567 | return 1; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 568 | if (ret == -1) |
| 569 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 570 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 571 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 572 | } |
| 573 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 574 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 575 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 576 | afi_t afi, safi_t safi) |
| 577 | { |
| 578 | struct bgp_filter *filter; |
| 579 | |
| 580 | filter = &peer->filter[afi][safi]; |
| 581 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 582 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 583 | if (BGP_DEBUG (update, UPDATE_IN) \ |
| 584 | && !(F ## _IN (filter))) \ |
| 585 | plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ |
| 586 | peer->host, #f, F ## _IN_NAME(filter)); |
| 587 | |
| 588 | if (DISTRIBUTE_IN_NAME (filter)) { |
| 589 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 590 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 591 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 592 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 593 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 594 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 595 | if (PREFIX_LIST_IN_NAME (filter)) { |
| 596 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 597 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 598 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 599 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 600 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 601 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 602 | if (FILTER_LIST_IN_NAME (filter)) { |
| 603 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 604 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 605 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 606 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 607 | } |
| 608 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 609 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 610 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 611 | } |
| 612 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 613 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 614 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 615 | afi_t afi, safi_t safi) |
| 616 | { |
| 617 | struct bgp_filter *filter; |
| 618 | |
| 619 | filter = &peer->filter[afi][safi]; |
| 620 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 621 | #define FILTER_EXIST_WARN(F,f,filter) \ |
| 622 | if (BGP_DEBUG (update, UPDATE_OUT) \ |
| 623 | && !(F ## _OUT (filter))) \ |
| 624 | plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ |
| 625 | peer->host, #f, F ## _OUT_NAME(filter)); |
| 626 | |
| 627 | if (DISTRIBUTE_OUT_NAME (filter)) { |
| 628 | FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); |
| 629 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 630 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 631 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 632 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 633 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 634 | if (PREFIX_LIST_OUT_NAME (filter)) { |
| 635 | FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); |
| 636 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 637 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 638 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 639 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 640 | |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 641 | if (FILTER_LIST_OUT_NAME (filter)) { |
| 642 | FILTER_EXIST_WARN(FILTER_LIST, as, filter); |
| 643 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 644 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 645 | return FILTER_DENY; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 646 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 647 | |
| 648 | return FILTER_PERMIT; |
Paul Jakma | 650f76c | 2009-06-25 18:06:31 +0100 | [diff] [blame] | 649 | #undef FILTER_EXIST_WARN |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 653 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 654 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 655 | { |
| 656 | if (attr->community) |
| 657 | { |
| 658 | /* NO_ADVERTISE check. */ |
| 659 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 660 | return 1; |
| 661 | |
| 662 | /* NO_EXPORT check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 663 | if (peer->sort == BGP_PEER_EBGP && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 664 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 665 | return 1; |
| 666 | |
| 667 | /* NO_EXPORT_SUBCONFED check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 668 | if (peer->sort == BGP_PEER_EBGP |
| 669 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 670 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 671 | return 1; |
| 672 | } |
| 673 | return 0; |
| 674 | } |
| 675 | |
| 676 | /* Route reflection loop check. */ |
| 677 | static int |
| 678 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 679 | { |
| 680 | struct in_addr cluster_id; |
| 681 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 682 | if (attr->extra && attr->extra->cluster) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 683 | { |
| 684 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 685 | cluster_id = peer->bgp->cluster_id; |
| 686 | else |
| 687 | cluster_id = peer->bgp->router_id; |
| 688 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 689 | if (cluster_loop_check (attr->extra->cluster, cluster_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 690 | return 1; |
| 691 | } |
| 692 | return 0; |
| 693 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 694 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 695 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 696 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 697 | afi_t afi, safi_t safi) |
| 698 | { |
| 699 | struct bgp_filter *filter; |
| 700 | struct bgp_info info; |
| 701 | route_map_result_t ret; |
| 702 | |
| 703 | filter = &peer->filter[afi][safi]; |
| 704 | |
| 705 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 706 | if (peer->weight) |
| 707 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 708 | |
| 709 | /* Route map apply. */ |
| 710 | if (ROUTE_MAP_IN_NAME (filter)) |
| 711 | { |
| 712 | /* Duplicate current value to new strucutre for modification. */ |
| 713 | info.peer = peer; |
| 714 | info.attr = attr; |
| 715 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 716 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 717 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 718 | /* Apply BGP route map to the attribute. */ |
| 719 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 720 | |
| 721 | peer->rmap_type = 0; |
| 722 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 723 | if (ret == RMAP_DENYMATCH) |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 724 | /* caller has multiple error paths with bgp_attr_flush() */ |
| 725 | return RMAP_DENY; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 726 | } |
| 727 | return RMAP_PERMIT; |
| 728 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 729 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 730 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 731 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 732 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 733 | { |
| 734 | struct bgp_filter *filter; |
| 735 | struct bgp_info info; |
| 736 | route_map_result_t ret; |
| 737 | |
| 738 | filter = &peer->filter[afi][safi]; |
| 739 | |
| 740 | /* Route map apply. */ |
| 741 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 742 | { |
| 743 | /* Duplicate current value to new strucutre for modification. */ |
| 744 | info.peer = rsclient; |
| 745 | info.attr = attr; |
| 746 | |
| 747 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 748 | |
| 749 | /* Apply BGP route map to the attribute. */ |
| 750 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 751 | |
| 752 | rsclient->rmap_type = 0; |
| 753 | |
| 754 | if (ret == RMAP_DENYMATCH) |
| 755 | { |
| 756 | /* Free newly generated AS path and community by route-map. */ |
| 757 | bgp_attr_flush (attr); |
| 758 | return RMAP_DENY; |
| 759 | } |
| 760 | } |
| 761 | return RMAP_PERMIT; |
| 762 | } |
| 763 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 764 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 765 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 766 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 767 | { |
| 768 | struct bgp_filter *filter; |
| 769 | struct bgp_info info; |
| 770 | route_map_result_t ret; |
| 771 | |
| 772 | filter = &rsclient->filter[afi][safi]; |
| 773 | |
| 774 | /* Apply default weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 775 | if (peer->weight) |
| 776 | (bgp_attr_extra_get (attr))->weight = peer->weight; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 777 | |
| 778 | /* Route map apply. */ |
| 779 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 780 | { |
| 781 | /* Duplicate current value to new strucutre for modification. */ |
| 782 | info.peer = peer; |
| 783 | info.attr = attr; |
| 784 | |
| 785 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 786 | |
| 787 | /* Apply BGP route map to the attribute. */ |
| 788 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 789 | |
| 790 | peer->rmap_type = 0; |
| 791 | |
| 792 | if (ret == RMAP_DENYMATCH) |
| 793 | { |
| 794 | /* Free newly generated AS path and community by route-map. */ |
| 795 | bgp_attr_flush (attr); |
| 796 | return RMAP_DENY; |
| 797 | } |
| 798 | } |
| 799 | return RMAP_PERMIT; |
| 800 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 801 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 802 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 803 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 804 | struct attr *attr, afi_t afi, safi_t safi) |
| 805 | { |
| 806 | int ret; |
| 807 | char buf[SU_ADDRSTRLEN]; |
| 808 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 809 | struct peer *from; |
| 810 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 811 | int transparent; |
| 812 | int reflect; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 813 | struct attr *riattr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 814 | |
| 815 | from = ri->peer; |
| 816 | filter = &peer->filter[afi][safi]; |
| 817 | bgp = peer->bgp; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 818 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 819 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 820 | if (DISABLE_BGP_ANNOUNCE) |
| 821 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 822 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 823 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 824 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 825 | return 0; |
| 826 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 827 | /* Do not send back route to sender. */ |
| 828 | if (from == peer) |
| 829 | return 0; |
| 830 | |
| 831 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 832 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 833 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 834 | return 0; |
| 835 | |
| 836 | /* Default route check. */ |
| 837 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 838 | { |
| 839 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 840 | return 0; |
| 841 | #ifdef HAVE_IPV6 |
| 842 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 843 | return 0; |
| 844 | #endif /* HAVE_IPV6 */ |
| 845 | } |
| 846 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 847 | /* Transparency check. */ |
| 848 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 849 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 850 | transparent = 1; |
| 851 | else |
| 852 | transparent = 0; |
| 853 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 854 | /* If community is not disabled check the no-export and local. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 855 | if (! transparent && bgp_community_filter (peer, riattr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 856 | return 0; |
| 857 | |
| 858 | /* If the attribute has originator-id and it is same as remote |
| 859 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 860 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 861 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 862 | if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 863 | { |
| 864 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 865 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 866 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 867 | peer->host, |
| 868 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 869 | p->prefixlen); |
| 870 | return 0; |
| 871 | } |
| 872 | } |
| 873 | |
| 874 | /* ORF prefix-list filter check */ |
| 875 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 876 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 877 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 878 | if (peer->orf_plist[afi][safi]) |
| 879 | { |
| 880 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 881 | return 0; |
| 882 | } |
| 883 | |
| 884 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 885 | if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 886 | { |
| 887 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 888 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 889 | "%s [Update:SEND] %s/%d is filtered", |
| 890 | peer->host, |
| 891 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 892 | p->prefixlen); |
| 893 | return 0; |
| 894 | } |
| 895 | |
| 896 | #ifdef BGP_SEND_ASPATH_CHECK |
| 897 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 898 | if (aspath_loop_check (riattr->aspath, peer->as)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 899 | { |
| 900 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 901 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 902 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 903 | peer->host, peer->as); |
| 904 | return 0; |
| 905 | } |
| 906 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 907 | |
| 908 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 909 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 910 | { |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 911 | if (aspath_loop_check(riattr->aspath, bgp->confed_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 912 | { |
| 913 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 914 | zlog (peer->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 915 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 916 | peer->host, |
| 917 | bgp->confed_id); |
| 918 | return 0; |
| 919 | } |
| 920 | } |
| 921 | |
| 922 | /* Route-Reflect check. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 923 | if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 924 | reflect = 1; |
| 925 | else |
| 926 | reflect = 0; |
| 927 | |
| 928 | /* IBGP reflection check. */ |
| 929 | if (reflect) |
| 930 | { |
| 931 | /* A route from a Client peer. */ |
| 932 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 933 | { |
| 934 | /* Reflect to all the Non-Client peers and also to the |
| 935 | Client peers other than the originator. Originator check |
| 936 | is already done. So there is noting to do. */ |
| 937 | /* no bgp client-to-client reflection check. */ |
| 938 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 939 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 940 | return 0; |
| 941 | } |
| 942 | else |
| 943 | { |
| 944 | /* A route from a Non-client peer. Reflect to all other |
| 945 | clients. */ |
| 946 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 947 | return 0; |
| 948 | } |
| 949 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 950 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 951 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 952 | bgp_attr_dup (attr, riattr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 953 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 954 | /* If local-preference is not set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 955 | if ((peer->sort == BGP_PEER_IBGP |
| 956 | || peer->sort == BGP_PEER_CONFED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 957 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 958 | { |
| 959 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 960 | attr->local_pref = bgp->default_local_pref; |
| 961 | } |
| 962 | |
Pradosh Mohapatra | 689bb66 | 2013-09-07 07:13:37 +0000 | [diff] [blame] | 963 | /* If originator-id is not set and the route is to be reflected, |
| 964 | set the originator id */ |
| 965 | if (peer && from && peer->sort == BGP_PEER_IBGP && |
| 966 | from->sort == BGP_PEER_IBGP && |
| 967 | (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) |
| 968 | { |
| 969 | attr->extra = bgp_attr_extra_get(attr); |
| 970 | IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id)); |
| 971 | SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID); |
| 972 | } |
| 973 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 974 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 975 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 976 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 977 | { |
| 978 | if (ri->peer != bgp->peer_self && ! transparent |
| 979 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 980 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 981 | } |
| 982 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 983 | |
| 984 | #define NEXTHOP_IS_V4 (\ |
| 985 | (safi != SAFI_ENCAP && p->family == AF_INET) || \ |
| 986 | (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 4)) |
| 987 | |
| 988 | #ifdef HAVE_IPV6 |
| 989 | #define NEXTHOP_IS_V6 (\ |
| 990 | (safi != SAFI_ENCAP && p->family == AF_INET6) || \ |
| 991 | (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16)) |
| 992 | #endif |
| 993 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 994 | /* next-hop-set */ |
Timo Teräs | 9e7a53c | 2014-04-24 10:22:37 +0300 | [diff] [blame] | 995 | if (transparent |
| 996 | || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 997 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 998 | && ((NEXTHOP_IS_V4 && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 999 | #ifdef HAVE_IPV6 |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1000 | || (NEXTHOP_IS_V6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1001 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 1002 | #endif /* HAVE_IPV6 */ |
| 1003 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1004 | { |
| 1005 | /* NEXT-HOP Unchanged. */ |
| 1006 | } |
| 1007 | 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] | 1008 | || (NEXTHOP_IS_V4 && attr->nexthop.s_addr == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1009 | #ifdef HAVE_IPV6 |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1010 | || (NEXTHOP_IS_V6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1011 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1012 | #endif /* HAVE_IPV6 */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1013 | || (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1014 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 1015 | { |
| 1016 | /* Set IPv4 nexthop. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1017 | if (NEXTHOP_IS_V4) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1018 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1019 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1020 | memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4, |
| 1021 | IPV4_MAX_BYTELEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1022 | else |
| 1023 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1024 | } |
| 1025 | #ifdef HAVE_IPV6 |
| 1026 | /* Set IPv6 nexthop. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1027 | if (NEXTHOP_IS_V6) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1028 | { |
| 1029 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1030 | memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1031 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1032 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1033 | } |
| 1034 | #endif /* HAVE_IPV6 */ |
| 1035 | } |
| 1036 | |
| 1037 | #ifdef HAVE_IPV6 |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1038 | if (p->family == AF_INET6 && safi != SAFI_ENCAP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1039 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1040 | /* Left nexthop_local unchanged if so configured. */ |
| 1041 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 1042 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1043 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1044 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) |
| 1045 | attr->extra->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1046 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1047 | attr->extra->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1048 | } |
| 1049 | |
| 1050 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 1051 | else |
| 1052 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1053 | /* Link-local address should not be transit to different peer. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1054 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1055 | |
| 1056 | /* Set link-local address for shared network peer. */ |
| 1057 | if (peer->shared_network |
| 1058 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 1059 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1060 | memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1061 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1062 | attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1063 | } |
| 1064 | |
| 1065 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 1066 | address.*/ |
| 1067 | if (reflect) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1068 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1069 | |
| 1070 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 1071 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1072 | attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1073 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1074 | |
| 1075 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1076 | #endif /* HAVE_IPV6 */ |
| 1077 | |
| 1078 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1079 | if (peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1080 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1081 | && aspath_private_as_check (attr->aspath)) |
| 1082 | attr->aspath = aspath_empty_get (); |
| 1083 | |
| 1084 | /* Route map & unsuppress-map apply. */ |
| 1085 | if (ROUTE_MAP_OUT_NAME (filter) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1086 | || (ri->extra && ri->extra->suppress) ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1087 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 1088 | struct bgp_info info; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1089 | struct attr dummy_attr; |
| 1090 | struct attr_extra dummy_extra; |
| 1091 | |
| 1092 | dummy_attr.extra = &dummy_extra; |
| 1093 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1094 | info.peer = peer; |
| 1095 | info.attr = attr; |
| 1096 | |
| 1097 | /* The route reflector is not allowed to modify the attributes |
| 1098 | of the reflected IBGP routes. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1099 | if (from->sort == BGP_PEER_IBGP |
| 1100 | && peer->sort == BGP_PEER_IBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1101 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1102 | bgp_attr_dup (&dummy_attr, attr); |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1103 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1104 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1105 | |
| 1106 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1107 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1108 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1109 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1110 | else |
| 1111 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1112 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 1113 | peer->rmap_type = 0; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1114 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1115 | if (ret == RMAP_DENYMATCH) |
| 1116 | { |
| 1117 | bgp_attr_flush (attr); |
| 1118 | return 0; |
| 1119 | } |
| 1120 | } |
| 1121 | return 1; |
| 1122 | } |
| 1123 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1124 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1125 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 1126 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1127 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1128 | int ret; |
| 1129 | char buf[SU_ADDRSTRLEN]; |
| 1130 | struct bgp_filter *filter; |
| 1131 | struct bgp_info info; |
| 1132 | struct peer *from; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1133 | struct attr *riattr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1134 | |
| 1135 | from = ri->peer; |
| 1136 | filter = &rsclient->filter[afi][safi]; |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1137 | riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1138 | |
Paul Jakma | 750e814 | 2008-07-22 21:11:48 +0000 | [diff] [blame] | 1139 | if (DISABLE_BGP_ANNOUNCE) |
| 1140 | return 0; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1141 | |
| 1142 | /* Do not send back route to sender. */ |
| 1143 | if (from == rsclient) |
| 1144 | return 0; |
| 1145 | |
| 1146 | /* Aggregate-address suppress check. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1147 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1148 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 1149 | return 0; |
| 1150 | |
| 1151 | /* Default route check. */ |
| 1152 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 1153 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 1154 | { |
| 1155 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 1156 | return 0; |
| 1157 | #ifdef HAVE_IPV6 |
| 1158 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 1159 | return 0; |
| 1160 | #endif /* HAVE_IPV6 */ |
| 1161 | } |
| 1162 | |
| 1163 | /* If the attribute has originator-id and it is same as remote |
| 1164 | peer's id. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1165 | if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1166 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1167 | if (IPV4_ADDR_SAME (&rsclient->remote_id, |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1168 | &riattr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1169 | { |
| 1170 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1171 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1172 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 1173 | rsclient->host, |
| 1174 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1175 | p->prefixlen); |
| 1176 | return 0; |
| 1177 | } |
| 1178 | } |
| 1179 | |
| 1180 | /* ORF prefix-list filter check */ |
| 1181 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 1182 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 1183 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 1184 | if (rsclient->orf_plist[afi][safi]) |
| 1185 | { |
| 1186 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 1187 | return 0; |
| 1188 | } |
| 1189 | |
| 1190 | /* Output filter check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1191 | if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1192 | { |
| 1193 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1194 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1195 | "%s [Update:SEND] %s/%d is filtered", |
| 1196 | rsclient->host, |
| 1197 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1198 | p->prefixlen); |
| 1199 | return 0; |
| 1200 | } |
| 1201 | |
| 1202 | #ifdef BGP_SEND_ASPATH_CHECK |
| 1203 | /* AS path loop check. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1204 | if (aspath_loop_check (riattr->aspath, rsclient->as)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1205 | { |
| 1206 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1207 | zlog (rsclient->log, LOG_DEBUG, |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 1208 | "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1209 | rsclient->host, rsclient->as); |
| 1210 | return 0; |
| 1211 | } |
| 1212 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 1213 | |
| 1214 | /* For modify attribute, copy it to temporary structure. */ |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1215 | bgp_attr_dup (attr, riattr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1216 | |
| 1217 | /* next-hop-set */ |
| 1218 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1219 | #ifdef HAVE_IPV6 |
| 1220 | || (p->family == AF_INET6 && |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1221 | IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1222 | #endif /* HAVE_IPV6 */ |
| 1223 | ) |
| 1224 | { |
| 1225 | /* Set IPv4 nexthop. */ |
| 1226 | if (p->family == AF_INET) |
| 1227 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 1228 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1229 | memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1230 | IPV4_MAX_BYTELEN); |
| 1231 | else |
| 1232 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1233 | } |
| 1234 | #ifdef HAVE_IPV6 |
| 1235 | /* Set IPv6 nexthop. */ |
| 1236 | if (p->family == AF_INET6) |
| 1237 | { |
| 1238 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1239 | memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1240 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1241 | attr->extra->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1242 | } |
| 1243 | #endif /* HAVE_IPV6 */ |
| 1244 | } |
| 1245 | |
| 1246 | #ifdef HAVE_IPV6 |
| 1247 | if (p->family == AF_INET6) |
| 1248 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1249 | struct attr_extra *attre = attr->extra; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1250 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1251 | /* Left nexthop_local unchanged if so configured. */ |
| 1252 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1253 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1254 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1255 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1256 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1257 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1258 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1259 | } |
| 1260 | |
| 1261 | /* Default nexthop_local treatment for RS-Clients */ |
| 1262 | else |
| 1263 | { |
| 1264 | /* Announcer and RS-Client are both in the same network */ |
| 1265 | if (rsclient->shared_network && from->shared_network && |
| 1266 | (rsclient->ifindex == from->ifindex)) |
| 1267 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1268 | if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) |
| 1269 | attre->mp_nexthop_len=32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1270 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1271 | attre->mp_nexthop_len=16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1272 | } |
| 1273 | |
| 1274 | /* Set link-local address for shared network peer. */ |
| 1275 | else if (rsclient->shared_network |
| 1276 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1277 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1278 | memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1279 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1280 | attre->mp_nexthop_len = 32; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1281 | } |
| 1282 | |
| 1283 | else |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1284 | attre->mp_nexthop_len = 16; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1285 | } |
| 1286 | |
| 1287 | } |
| 1288 | #endif /* HAVE_IPV6 */ |
| 1289 | |
| 1290 | |
| 1291 | /* If this is EBGP peer and remove-private-AS is set. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 1292 | if (rsclient->sort == BGP_PEER_EBGP |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1293 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1294 | && aspath_private_as_check (attr->aspath)) |
| 1295 | attr->aspath = aspath_empty_get (); |
| 1296 | |
| 1297 | /* Route map & unsuppress-map apply. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1298 | if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) ) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1299 | { |
| 1300 | info.peer = rsclient; |
| 1301 | info.attr = attr; |
| 1302 | |
| 1303 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1304 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1305 | if (ri->extra && ri->extra->suppress) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1306 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1307 | else |
| 1308 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1309 | |
| 1310 | rsclient->rmap_type = 0; |
| 1311 | |
| 1312 | if (ret == RMAP_DENYMATCH) |
| 1313 | { |
| 1314 | bgp_attr_flush (attr); |
| 1315 | return 0; |
| 1316 | } |
| 1317 | } |
| 1318 | |
| 1319 | return 1; |
| 1320 | } |
| 1321 | |
| 1322 | struct bgp_info_pair |
| 1323 | { |
| 1324 | struct bgp_info *old; |
| 1325 | struct bgp_info *new; |
| 1326 | }; |
| 1327 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1328 | static void |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1329 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1330 | struct bgp_info_pair *result, |
| 1331 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1332 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1333 | struct bgp_info *new_select; |
| 1334 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1335 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1336 | struct bgp_info *ri1; |
| 1337 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1338 | struct bgp_info *nextri = NULL; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1339 | int cmpret, do_mpath; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1340 | struct list mp_list; |
Paul Jakma | 91b9e85 | 2015-12-01 14:32:11 +0000 | [diff] [blame] | 1341 | |
| 1342 | result->old = result->new = NULL; |
| 1343 | |
| 1344 | if (rn->info == NULL) |
| 1345 | { |
| 1346 | char buf[PREFIX_STRLEN]; |
| 1347 | zlog_warn ("%s: Called for route_node %s with no routing entries!", |
| 1348 | __func__, |
| 1349 | prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf))); |
| 1350 | return; |
| 1351 | } |
| 1352 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1353 | bgp_mp_list_init (&mp_list); |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1354 | do_mpath = bgp_mpath_is_configured (bgp, afi, safi); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1355 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1356 | /* bgp deterministic-med */ |
| 1357 | new_select = NULL; |
| 1358 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1359 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1360 | { |
| 1361 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1362 | continue; |
| 1363 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1364 | continue; |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1365 | if (ri1->peer && ri1->peer != bgp->peer_self) |
| 1366 | if (ri1->peer->status != Established) |
| 1367 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1368 | |
| 1369 | new_select = ri1; |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1370 | if (do_mpath) |
| 1371 | bgp_mp_list_add (&mp_list, ri1); |
| 1372 | old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1373 | if (ri1->next) |
| 1374 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1375 | { |
| 1376 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1377 | continue; |
| 1378 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1379 | continue; |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1380 | if (ri2->peer && |
| 1381 | ri2->peer != bgp->peer_self && |
| 1382 | !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT)) |
| 1383 | if (ri2->peer->status != Established) |
| 1384 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1385 | |
| 1386 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1387 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1388 | ri2->attr->aspath)) |
| 1389 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1390 | if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED)) |
| 1391 | old_select = ri2; |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1392 | if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi)) |
| 1393 | == -1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1394 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1395 | bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1396 | new_select = ri2; |
| 1397 | } |
| 1398 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1399 | if (do_mpath) |
| 1400 | { |
| 1401 | if (cmpret != 0) |
| 1402 | bgp_mp_list_clear (&mp_list); |
| 1403 | |
| 1404 | if (cmpret == 0 || cmpret == -1) |
| 1405 | bgp_mp_list_add (&mp_list, ri2); |
| 1406 | } |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1407 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1408 | bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1409 | } |
| 1410 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1411 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK); |
| 1412 | bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1413 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1414 | 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] | 1415 | bgp_mp_list_clear (&mp_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1416 | } |
| 1417 | |
| 1418 | /* Check old selected route and new selected route. */ |
| 1419 | old_select = NULL; |
| 1420 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1421 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1422 | { |
| 1423 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1424 | old_select = ri; |
| 1425 | |
| 1426 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1427 | { |
| 1428 | /* reap REMOVED routes, if needs be |
| 1429 | * selected route must stay for a while longer though |
| 1430 | */ |
| 1431 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1432 | && (ri != old_select)) |
| 1433 | bgp_info_reap (rn, ri); |
| 1434 | |
| 1435 | continue; |
| 1436 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1437 | |
Dinesh G Dutt | 234e5c8 | 2015-02-01 00:56:12 -0800 | [diff] [blame] | 1438 | if (ri->peer && |
| 1439 | ri->peer != bgp->peer_self && |
| 1440 | !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT)) |
| 1441 | if (ri->peer->status != Established) |
| 1442 | continue; |
| 1443 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1444 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1445 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1446 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1447 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1448 | continue; |
| 1449 | } |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1450 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK); |
| 1451 | bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1452 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1453 | if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1) |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1454 | { |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1455 | if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1456 | bgp_mp_dmed_deselect (new_select); |
| 1457 | |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1458 | new_select = ri; |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1459 | } |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1460 | else if (cmpret == 1 && do_mpath |
| 1461 | && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1462 | bgp_mp_dmed_deselect (ri); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1463 | |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1464 | if (do_mpath) |
| 1465 | { |
| 1466 | if (cmpret != 0) |
| 1467 | bgp_mp_list_clear (&mp_list); |
| 1468 | |
| 1469 | if (cmpret == 0 || cmpret == -1) |
| 1470 | bgp_mp_list_add (&mp_list, ri); |
| 1471 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1472 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1473 | |
Josh Bailey | 6918e74 | 2011-07-20 20:48:20 -0700 | [diff] [blame] | 1474 | if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1475 | 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] | 1476 | |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 1477 | bgp_info_mpath_aggregate_update (new_select, old_select); |
Josh Bailey | 96450fa | 2011-07-20 20:45:12 -0700 | [diff] [blame] | 1478 | bgp_mp_list_clear (&mp_list); |
| 1479 | |
| 1480 | result->old = old_select; |
| 1481 | result->new = new_select; |
| 1482 | |
| 1483 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1484 | } |
| 1485 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1486 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1487 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1488 | struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1489 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1490 | struct prefix *p; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1491 | struct attr attr; |
| 1492 | struct attr_extra extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1493 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1494 | memset (&attr, 0, sizeof(struct attr)); |
| 1495 | memset (&extra, 0, sizeof(struct attr_extra)); |
| 1496 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1497 | p = &rn->p; |
| 1498 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1499 | /* Announce route to Established peer. */ |
| 1500 | if (peer->status != Established) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1501 | return 0; |
| 1502 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1503 | /* Address family configuration check. */ |
| 1504 | if (! peer->afc_nego[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1505 | return 0; |
| 1506 | |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1507 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1508 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1509 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1510 | return 0; |
| 1511 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1512 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 1513 | attr.extra = &extra; |
| 1514 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1515 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1516 | { |
| 1517 | case BGP_TABLE_MAIN: |
| 1518 | /* Announcement to peer->conf. If the route is filtered, |
| 1519 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1520 | if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi)) |
| 1521 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1522 | else |
| 1523 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1524 | break; |
| 1525 | case BGP_TABLE_RSCLIENT: |
| 1526 | /* Announcement to peer->conf. If the route is filtered, |
| 1527 | withdraw it. */ |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1528 | if (selected && |
| 1529 | bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) |
| 1530 | bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); |
| 1531 | else |
| 1532 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1533 | break; |
| 1534 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1535 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1536 | bgp_attr_flush (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1537 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1538 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1539 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1540 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1541 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1542 | struct bgp *bgp; |
| 1543 | struct bgp_node *rn; |
| 1544 | afi_t afi; |
| 1545 | safi_t safi; |
| 1546 | }; |
| 1547 | |
| 1548 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1549 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1550 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1551 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1552 | struct bgp *bgp = pq->bgp; |
| 1553 | struct bgp_node *rn = pq->rn; |
| 1554 | afi_t afi = pq->afi; |
| 1555 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1556 | struct bgp_info *new_select; |
| 1557 | struct bgp_info *old_select; |
| 1558 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1559 | struct listnode *node, *nnode; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1560 | struct peer *rsclient = bgp_node_table (rn)->owner; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1561 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1562 | /* Best path selection. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1563 | bgp_best_selection (bgp, rn, &old_and_new, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1564 | new_select = old_and_new.new; |
| 1565 | old_select = old_and_new.old; |
| 1566 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1567 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1568 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1569 | if (rsclient->group) |
| 1570 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1571 | { |
| 1572 | /* Nothing to do. */ |
| 1573 | if (old_select && old_select == new_select) |
| 1574 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1575 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1576 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1577 | if (old_select) |
| 1578 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
| 1579 | if (new_select) |
| 1580 | { |
| 1581 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1582 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1583 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
| 1584 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1585 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1586 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1587 | afi, safi); |
| 1588 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1589 | } |
| 1590 | else |
| 1591 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1592 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1593 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1594 | if (new_select) |
| 1595 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1596 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1597 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1598 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1599 | } |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1600 | bgp_process_announce_selected (rsclient, new_select, rn, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1601 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1602 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1603 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1604 | bgp_info_reap (rn, old_select); |
| 1605 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1606 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1607 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1608 | } |
| 1609 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1610 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1611 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1612 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1613 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1614 | struct bgp *bgp = pq->bgp; |
| 1615 | struct bgp_node *rn = pq->rn; |
| 1616 | afi_t afi = pq->afi; |
| 1617 | safi_t safi = pq->safi; |
| 1618 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1619 | struct bgp_info *new_select; |
| 1620 | struct bgp_info *old_select; |
| 1621 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1622 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1623 | struct peer *peer; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1624 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1625 | /* Best path selection. */ |
Paul Jakma | 6d4742b | 2015-11-25 17:14:37 +0000 | [diff] [blame] | 1626 | bgp_best_selection (bgp, rn, &old_and_new, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1627 | old_select = old_and_new.old; |
| 1628 | new_select = old_and_new.new; |
| 1629 | |
| 1630 | /* Nothing to do. */ |
| 1631 | if (old_select && old_select == new_select) |
| 1632 | { |
| 1633 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1634 | { |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1635 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) || |
| 1636 | CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG)) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1637 | bgp_zebra_announce (p, old_select, bgp, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1638 | |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1639 | UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1640 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1641 | return WQ_SUCCESS; |
| 1642 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1643 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1644 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1645 | if (old_select) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1646 | bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1647 | if (new_select) |
| 1648 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1649 | bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED); |
| 1650 | bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED); |
Josh Bailey | 8196f13 | 2011-07-20 20:47:07 -0700 | [diff] [blame] | 1651 | UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG); |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1652 | } |
| 1653 | |
| 1654 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1655 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1656 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1657 | { |
Paul Jakma | 9eda90c | 2007-08-30 13:36:17 +0000 | [diff] [blame] | 1658 | bgp_process_announce_selected (peer, new_select, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1659 | } |
| 1660 | |
| 1661 | /* FIB update. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1662 | if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name && |
| 1663 | ! bgp_option_check (BGP_OPT_NO_FIB))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1664 | { |
| 1665 | if (new_select |
| 1666 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1667 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1668 | bgp_zebra_announce (p, new_select, bgp, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1669 | else |
| 1670 | { |
| 1671 | /* Withdraw the route from the kernel. */ |
| 1672 | if (old_select |
| 1673 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1674 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1675 | bgp_zebra_withdraw (p, old_select, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1676 | } |
| 1677 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1678 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 1679 | /* Reap old select bgp_info, if it has been removed */ |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1680 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1681 | bgp_info_reap (rn, old_select); |
| 1682 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1683 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1684 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1685 | } |
| 1686 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1687 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1688 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1689 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1690 | struct bgp_process_queue *pq = data; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1691 | struct bgp_table *table = bgp_node_table (pq->rn); |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1692 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1693 | bgp_unlock (pq->bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1694 | bgp_unlock_node (pq->rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1695 | bgp_table_unlock (table); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1696 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1697 | } |
| 1698 | |
| 1699 | static void |
| 1700 | bgp_process_queue_init (void) |
| 1701 | { |
| 1702 | bm->process_main_queue |
| 1703 | = work_queue_new (bm->master, "process_main_queue"); |
| 1704 | bm->process_rsclient_queue |
| 1705 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1706 | |
| 1707 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1708 | { |
| 1709 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1710 | exit (1); |
| 1711 | } |
| 1712 | |
| 1713 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1714 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1715 | bm->process_main_queue->spec.max_retries = 0; |
| 1716 | bm->process_main_queue->spec.hold = 50; |
| 1717 | |
Paul Jakma | 838bbde | 2010-01-08 14:05:32 +0000 | [diff] [blame] | 1718 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
David Lamparter | d43f8b3 | 2015-03-03 08:54:54 +0100 | [diff] [blame] | 1719 | bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del; |
| 1720 | bm->process_rsclient_queue->spec.max_retries = 0; |
| 1721 | bm->process_rsclient_queue->spec.hold = 50; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1722 | } |
| 1723 | |
| 1724 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1725 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1726 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1727 | struct bgp_process_queue *pqnode; |
| 1728 | |
| 1729 | /* already scheduled for processing? */ |
| 1730 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1731 | return; |
| 1732 | |
Paul Jakma | 91b9e85 | 2015-12-01 14:32:11 +0000 | [diff] [blame] | 1733 | if (rn->info == NULL) |
| 1734 | { |
| 1735 | /* XXX: Perhaps remove before next release, after we've flushed out |
| 1736 | * any obvious cases |
| 1737 | */ |
| 1738 | assert (rn->info != NULL); |
| 1739 | char buf[PREFIX_STRLEN]; |
| 1740 | zlog_warn ("%s: Called for route_node %s with no routing entries!", |
| 1741 | __func__, |
| 1742 | prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf))); |
| 1743 | return; |
| 1744 | } |
| 1745 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1746 | if ( (bm->process_main_queue == NULL) || |
| 1747 | (bm->process_rsclient_queue == NULL) ) |
| 1748 | bgp_process_queue_init (); |
| 1749 | |
| 1750 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1751 | sizeof (struct bgp_process_queue)); |
| 1752 | if (!pqnode) |
| 1753 | return; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1754 | |
| 1755 | /* all unlocked in bgp_processq_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1756 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1757 | pqnode->rn = bgp_lock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1758 | pqnode->bgp = bgp; |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 1759 | bgp_lock (bgp); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1760 | pqnode->afi = afi; |
| 1761 | pqnode->safi = safi; |
| 1762 | |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 1763 | switch (bgp_node_table (rn)->type) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1764 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1765 | case BGP_TABLE_MAIN: |
| 1766 | work_queue_add (bm->process_main_queue, pqnode); |
| 1767 | break; |
| 1768 | case BGP_TABLE_RSCLIENT: |
| 1769 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1770 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1771 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1772 | |
Stephen Hemminger | 07ff4dc | 2013-01-04 22:29:20 +0000 | [diff] [blame] | 1773 | SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1774 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1775 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1776 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1777 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1778 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1779 | { |
| 1780 | struct peer *peer; |
| 1781 | |
| 1782 | peer = THREAD_ARG (thread); |
| 1783 | peer->t_pmax_restart = NULL; |
| 1784 | |
| 1785 | if (BGP_DEBUG (events, EVENTS)) |
| 1786 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1787 | peer->host); |
| 1788 | |
| 1789 | peer_clear (peer); |
| 1790 | |
| 1791 | return 0; |
| 1792 | } |
| 1793 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1794 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1795 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1796 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1797 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1798 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1799 | return 0; |
| 1800 | |
| 1801 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1802 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1803 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1804 | && ! always) |
| 1805 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1806 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1807 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1808 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1809 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1810 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1811 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1812 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1813 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1814 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1815 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1816 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1817 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1818 | |
| 1819 | if (safi == SAFI_MPLS_VPN) |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 1820 | safi = SAFI_MPLS_LABELED_VPN; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1821 | |
| 1822 | ndata[0] = (afi >> 8); |
| 1823 | ndata[1] = afi; |
| 1824 | ndata[2] = safi; |
| 1825 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1826 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1827 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1828 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1829 | |
| 1830 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1831 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1832 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1833 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1834 | |
| 1835 | /* restart timer start */ |
| 1836 | if (peer->pmax_restart[afi][safi]) |
| 1837 | { |
| 1838 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1839 | |
| 1840 | if (BGP_DEBUG (events, EVENTS)) |
| 1841 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1842 | peer->host, peer->v_pmax_restart); |
| 1843 | |
| 1844 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1845 | peer->v_pmax_restart); |
| 1846 | } |
| 1847 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1848 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1849 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1850 | else |
| 1851 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1852 | |
| 1853 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1854 | { |
| 1855 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1856 | && ! always) |
| 1857 | return 0; |
| 1858 | |
| 1859 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1860 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1861 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1862 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1863 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1864 | } |
| 1865 | else |
| 1866 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1867 | return 0; |
| 1868 | } |
| 1869 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1870 | /* Unconditionally remove the route from the RIB, without taking |
| 1871 | * damping into consideration (eg, because the session went down) |
| 1872 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1873 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1874 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1875 | afi_t afi, safi_t safi) |
| 1876 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1877 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1878 | |
| 1879 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1880 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1881 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1882 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1883 | } |
| 1884 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1885 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1886 | 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] | 1887 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1888 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1889 | int status = BGP_DAMP_NONE; |
| 1890 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1891 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1892 | * the bgp_info in the RIB for historical reference. |
| 1893 | */ |
| 1894 | 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] | 1895 | && peer->sort == BGP_PEER_EBGP) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1896 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1897 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1898 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1899 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1900 | return; |
| 1901 | } |
| 1902 | |
| 1903 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1904 | } |
| 1905 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1906 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1907 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1908 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1909 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1910 | { |
| 1911 | struct bgp_node *rn; |
| 1912 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1913 | struct attr new_attr; |
| 1914 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1915 | struct attr *attr_new; |
| 1916 | struct attr *attr_new2; |
| 1917 | struct bgp_info *ri; |
| 1918 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1919 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1920 | char buf[SU_ADDRSTRLEN]; |
| 1921 | |
| 1922 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1923 | if (peer == rsclient) |
| 1924 | return; |
| 1925 | |
| 1926 | bgp = peer->bgp; |
| 1927 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1928 | |
| 1929 | /* Check previously received route. */ |
| 1930 | for (ri = rn->info; ri; ri = ri->next) |
| 1931 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1932 | break; |
| 1933 | |
| 1934 | /* AS path loop check. */ |
Milan Kocian | 000e157 | 2013-10-18 07:59:38 +0000 | [diff] [blame] | 1935 | if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi]) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1936 | { |
| 1937 | reason = "as-path contains our own AS;"; |
| 1938 | goto filtered; |
| 1939 | } |
| 1940 | |
| 1941 | /* Route reflector originator ID check. */ |
| 1942 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1943 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1944 | { |
| 1945 | reason = "originator is us;"; |
| 1946 | goto filtered; |
| 1947 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1948 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1949 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1950 | bgp_attr_dup (&new_attr, attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1951 | |
| 1952 | /* Apply export policy. */ |
| 1953 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1954 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1955 | { |
| 1956 | reason = "export-policy;"; |
| 1957 | goto filtered; |
| 1958 | } |
| 1959 | |
| 1960 | attr_new2 = bgp_attr_intern (&new_attr); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1961 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1962 | /* Apply import policy. */ |
| 1963 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1964 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1965 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1966 | |
| 1967 | reason = "import-policy;"; |
| 1968 | goto filtered; |
| 1969 | } |
| 1970 | |
| 1971 | attr_new = bgp_attr_intern (&new_attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1972 | bgp_attr_unintern (&attr_new2); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1973 | |
| 1974 | /* IPv4 unicast next hop check. */ |
G.Balaji | 5a616c0 | 2011-11-26 21:58:42 +0400 | [diff] [blame] | 1975 | if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1976 | { |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1977 | /* 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] | 1978 | if (new_attr.nexthop.s_addr == 0 |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 1979 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1980 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 1981 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1982 | |
| 1983 | reason = "martian next-hop;"; |
| 1984 | goto filtered; |
| 1985 | } |
| 1986 | } |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 1987 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1988 | /* If the update is implicit withdraw. */ |
| 1989 | if (ri) |
| 1990 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 1991 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1992 | |
| 1993 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 1994 | if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED) |
| 1995 | && attrhash_cmp (ri->attr, attr_new)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1996 | { |
| 1997 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 1998 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1999 | |
| 2000 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2001 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2002 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 2003 | peer->host, |
| 2004 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2005 | p->prefixlen, rsclient->host); |
| 2006 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2007 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2008 | bgp_attr_unintern (&attr_new); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2009 | bgp_attr_flush(&new_attr); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2010 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2011 | } |
| 2012 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2013 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2014 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2015 | bgp_info_restore (rn, ri); |
| 2016 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2017 | /* Received Logging. */ |
| 2018 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2019 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2020 | peer->host, |
| 2021 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2022 | p->prefixlen, rsclient->host); |
| 2023 | |
| 2024 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2025 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2026 | |
| 2027 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2028 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2029 | ri->attr = attr_new; |
| 2030 | |
| 2031 | /* Update MPLS tag. */ |
| 2032 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2033 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2034 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2035 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2036 | |
| 2037 | /* Process change. */ |
| 2038 | bgp_process (bgp, rn, afi, safi); |
| 2039 | bgp_unlock_node (rn); |
| 2040 | |
| 2041 | return; |
| 2042 | } |
| 2043 | |
| 2044 | /* Received Logging. */ |
| 2045 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2046 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2047 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2048 | peer->host, |
| 2049 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2050 | p->prefixlen, rsclient->host); |
| 2051 | } |
| 2052 | |
| 2053 | /* Make new BGP info. */ |
| 2054 | new = bgp_info_new (); |
| 2055 | new->type = type; |
| 2056 | new->sub_type = sub_type; |
| 2057 | new->peer = peer; |
| 2058 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2059 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2060 | |
| 2061 | /* Update MPLS tag. */ |
| 2062 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2063 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2064 | |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2065 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2066 | |
| 2067 | /* Register new BGP information. */ |
| 2068 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2069 | |
| 2070 | /* route_node_get lock */ |
| 2071 | bgp_unlock_node (rn); |
| 2072 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2073 | /* Process change. */ |
| 2074 | bgp_process (bgp, rn, afi, safi); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2075 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2076 | return; |
| 2077 | |
| 2078 | filtered: |
| 2079 | |
| 2080 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2081 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2082 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2083 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 2084 | peer->host, |
| 2085 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2086 | p->prefixlen, rsclient->host, reason); |
| 2087 | |
| 2088 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2089 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2090 | |
| 2091 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2092 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2093 | return; |
| 2094 | } |
| 2095 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2096 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2097 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 2098 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 2099 | struct prefix_rd *prd, u_char *tag) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2100 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2101 | struct bgp_node *rn; |
| 2102 | struct bgp_info *ri; |
| 2103 | char buf[SU_ADDRSTRLEN]; |
| 2104 | |
| 2105 | if (rsclient == peer) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2106 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2107 | |
| 2108 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 2109 | |
| 2110 | /* Lookup withdrawn route. */ |
| 2111 | for (ri = rn->info; ri; ri = ri->next) |
| 2112 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2113 | break; |
| 2114 | |
| 2115 | /* Withdraw specified route from routing table. */ |
| 2116 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2117 | bgp_rib_withdraw (rn, ri, peer, afi, safi, prd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2118 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2119 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2120 | "%s Can't find the route %s/%d", peer->host, |
| 2121 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2122 | p->prefixlen); |
| 2123 | |
| 2124 | /* Unlock bgp_node_get() lock. */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2125 | bgp_unlock_node (rn); |
| 2126 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2127 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2128 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2129 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2130 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2131 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2132 | { |
| 2133 | int ret; |
| 2134 | int aspath_loop_count = 0; |
| 2135 | struct bgp_node *rn; |
| 2136 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2137 | struct attr new_attr; |
| 2138 | struct attr_extra new_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2139 | struct attr *attr_new; |
| 2140 | struct bgp_info *ri; |
| 2141 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2142 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2143 | char buf[SU_ADDRSTRLEN]; |
| 2144 | |
| 2145 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2146 | 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] | 2147 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2148 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 2149 | Adj-RIBs-In. */ |
Jorge Boncompte [DTI2] | 343aa82 | 2012-05-07 16:53:08 +0000 | [diff] [blame] | 2150 | if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2151 | && peer != bgp->peer_self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2152 | bgp_adj_in_set (rn, peer, attr); |
| 2153 | |
| 2154 | /* Check previously received route. */ |
| 2155 | for (ri = rn->info; ri; ri = ri->next) |
| 2156 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2157 | break; |
| 2158 | |
| 2159 | /* AS path local-as loop check. */ |
| 2160 | if (peer->change_local_as) |
| 2161 | { |
| 2162 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 2163 | aspath_loop_count = 1; |
| 2164 | |
| 2165 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 2166 | { |
| 2167 | reason = "as-path contains our own AS;"; |
| 2168 | goto filtered; |
| 2169 | } |
| 2170 | } |
| 2171 | |
| 2172 | /* AS path loop check. */ |
| 2173 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 2174 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 2175 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 2176 | > peer->allowas_in[afi][safi])) |
| 2177 | { |
| 2178 | reason = "as-path contains our own AS;"; |
| 2179 | goto filtered; |
| 2180 | } |
| 2181 | |
| 2182 | /* Route reflector originator ID check. */ |
| 2183 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2184 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2185 | { |
| 2186 | reason = "originator is us;"; |
| 2187 | goto filtered; |
| 2188 | } |
| 2189 | |
| 2190 | /* Route reflector cluster ID check. */ |
| 2191 | if (bgp_cluster_filter (peer, attr)) |
| 2192 | { |
| 2193 | reason = "reflected from the same cluster;"; |
| 2194 | goto filtered; |
| 2195 | } |
| 2196 | |
| 2197 | /* Apply incoming filter. */ |
| 2198 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 2199 | { |
| 2200 | reason = "filter;"; |
| 2201 | goto filtered; |
| 2202 | } |
| 2203 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2204 | new_attr.extra = &new_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2205 | bgp_attr_dup (&new_attr, attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2206 | |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2207 | /* Apply incoming route-map. |
| 2208 | * NB: new_attr may now contain newly allocated values from route-map "set" |
| 2209 | * commands, so we need bgp_attr_flush in the error paths, until we intern |
| 2210 | * the attr (which takes over the memory references) */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2211 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2212 | { |
| 2213 | reason = "route-map;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2214 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2215 | goto filtered; |
| 2216 | } |
| 2217 | |
| 2218 | /* IPv4 unicast next hop check. */ |
| 2219 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 2220 | { |
| 2221 | /* If the peer is EBGP and nexthop is not on connected route, |
| 2222 | discard it. */ |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2223 | if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1 |
Denis Ovsienko | 8e80bdf | 2011-08-05 18:52:52 +0400 | [diff] [blame] | 2224 | && ! bgp_nexthop_onlink (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2225 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2226 | { |
| 2227 | reason = "non-connected next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2228 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2229 | goto filtered; |
| 2230 | } |
| 2231 | |
Denis Ovsienko | 733cd9e | 2011-12-17 19:39:30 +0400 | [diff] [blame] | 2232 | /* 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] | 2233 | must not be my own address. */ |
Jorge Boncompte [DTI2] | 10f9bf3 | 2012-05-07 16:52:52 +0000 | [diff] [blame] | 2234 | if (new_attr.nexthop.s_addr == 0 |
| 2235 | || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) |
| 2236 | || bgp_nexthop_self (&new_attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2237 | { |
| 2238 | reason = "martian next-hop;"; |
David Lamparter | c460e57 | 2014-06-04 00:54:58 +0200 | [diff] [blame] | 2239 | bgp_attr_flush (&new_attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2240 | goto filtered; |
| 2241 | } |
| 2242 | } |
| 2243 | |
| 2244 | attr_new = bgp_attr_intern (&new_attr); |
| 2245 | |
| 2246 | /* If the update is implicit withdraw. */ |
| 2247 | if (ri) |
| 2248 | { |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2249 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2250 | |
| 2251 | /* Same attribute comes in. */ |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2252 | if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 2253 | && attrhash_cmp (ri->attr, attr_new)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2254 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2255 | bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2256 | |
| 2257 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2258 | && peer->sort == BGP_PEER_EBGP |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2259 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2260 | { |
| 2261 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2262 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2263 | peer->host, |
| 2264 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2265 | p->prefixlen); |
| 2266 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2267 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 2268 | { |
| 2269 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2270 | bgp_process (bgp, rn, afi, safi); |
| 2271 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2272 | } |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2273 | else /* Duplicate - odd */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2274 | { |
| 2275 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2276 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2277 | "%s rcvd %s/%d...duplicate ignored", |
| 2278 | peer->host, |
| 2279 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2280 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2281 | |
| 2282 | /* graceful restart STALE flag unset. */ |
| 2283 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2284 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2285 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2286 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2287 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2288 | } |
| 2289 | |
| 2290 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2291 | bgp_attr_unintern (&attr_new); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2292 | bgp_attr_flush (&new_attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2293 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2294 | return 0; |
| 2295 | } |
| 2296 | |
Paul Jakma | 16d2e24 | 2007-04-10 19:32:10 +0000 | [diff] [blame] | 2297 | /* Withdraw/Announce before we fully processed the withdraw */ |
| 2298 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 2299 | { |
| 2300 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2301 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing", |
| 2302 | peer->host, |
| 2303 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2304 | p->prefixlen); |
| 2305 | bgp_info_restore (rn, ri); |
| 2306 | } |
| 2307 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2308 | /* Received Logging. */ |
| 2309 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2310 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2311 | peer->host, |
| 2312 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2313 | p->prefixlen); |
| 2314 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2315 | /* graceful restart STALE flag unset. */ |
| 2316 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2317 | bgp_info_unset_flag (rn, ri, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2318 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2319 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2320 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2321 | |
| 2322 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2323 | * only if update is accepted, they'll increment below. |
| 2324 | */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2325 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2326 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2327 | /* Update bgp route dampening information. */ |
| 2328 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2329 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2330 | { |
| 2331 | /* This is implicit withdraw so we should update dampening |
| 2332 | information. */ |
| 2333 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2334 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2335 | } |
| 2336 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2337 | /* Update to new attribute. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2338 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2339 | ri->attr = attr_new; |
| 2340 | |
| 2341 | /* Update MPLS tag. */ |
| 2342 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2343 | memcpy ((bgp_info_extra_get (ri))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2344 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2345 | bgp_attr_flush (&new_attr); |
| 2346 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2347 | /* Update bgp route dampening information. */ |
| 2348 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2349 | && peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2350 | { |
| 2351 | /* Now we do normal update dampening. */ |
| 2352 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2353 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2354 | { |
| 2355 | bgp_unlock_node (rn); |
| 2356 | return 0; |
| 2357 | } |
| 2358 | } |
| 2359 | |
| 2360 | /* Nexthop reachability check. */ |
| 2361 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2362 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2363 | && (peer->sort == BGP_PEER_IBGP |
| 2364 | || peer->sort == BGP_PEER_CONFED |
| 2365 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2366 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2367 | { |
| 2368 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2369 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2370 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2371 | bgp_info_unset_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2372 | } |
| 2373 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2374 | bgp_info_set_flag (rn, ri, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2375 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2376 | bgp_attr_flush (&new_attr); |
| 2377 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2378 | /* Process change. */ |
| 2379 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2380 | |
| 2381 | bgp_process (bgp, rn, afi, safi); |
| 2382 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2383 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2384 | return 0; |
| 2385 | } |
| 2386 | |
| 2387 | /* Received Logging. */ |
| 2388 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2389 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2390 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2391 | peer->host, |
| 2392 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2393 | p->prefixlen); |
| 2394 | } |
| 2395 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2396 | /* Make new BGP info. */ |
| 2397 | new = bgp_info_new (); |
| 2398 | new->type = type; |
| 2399 | new->sub_type = sub_type; |
| 2400 | new->peer = peer; |
| 2401 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 2402 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2403 | |
| 2404 | /* Update MPLS tag. */ |
| 2405 | if (safi == SAFI_MPLS_VPN) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2406 | memcpy ((bgp_info_extra_get (new))->tag, tag, 3); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2407 | |
| 2408 | /* Nexthop reachability check. */ |
| 2409 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2410 | && safi == SAFI_UNICAST |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 2411 | && (peer->sort == BGP_PEER_IBGP |
| 2412 | || peer->sort == BGP_PEER_CONFED |
| 2413 | || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2414 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2415 | { |
| 2416 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2417 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2418 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2419 | bgp_info_unset_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2420 | } |
| 2421 | else |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2422 | bgp_info_set_flag (rn, new, BGP_INFO_VALID); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2423 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2424 | /* Increment prefix */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2425 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2426 | |
| 2427 | /* Register new BGP information. */ |
| 2428 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2429 | |
| 2430 | /* route_node_get lock */ |
| 2431 | bgp_unlock_node (rn); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2432 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2433 | bgp_attr_flush (&new_attr); |
| 2434 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2435 | /* If maximum prefix count is configured and current prefix |
| 2436 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2437 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2438 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2439 | |
| 2440 | /* Process change. */ |
| 2441 | bgp_process (bgp, rn, afi, safi); |
| 2442 | |
| 2443 | return 0; |
| 2444 | |
| 2445 | /* This BGP update is filtered. Log the reason then update BGP |
| 2446 | entry. */ |
| 2447 | filtered: |
| 2448 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2449 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2450 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2451 | peer->host, |
| 2452 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2453 | p->prefixlen, reason); |
| 2454 | |
| 2455 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2456 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2457 | |
| 2458 | bgp_unlock_node (rn); |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2459 | bgp_attr_flush (&new_attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2460 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2461 | return 0; |
| 2462 | } |
| 2463 | |
| 2464 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2465 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2466 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2467 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2468 | { |
| 2469 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2470 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2471 | struct bgp *bgp; |
| 2472 | int ret; |
| 2473 | |
| 2474 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2475 | soft_reconfig); |
| 2476 | |
| 2477 | bgp = peer->bgp; |
| 2478 | |
| 2479 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2480 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2481 | { |
| 2482 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2483 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2484 | sub_type, prd, tag); |
| 2485 | } |
| 2486 | |
| 2487 | return ret; |
| 2488 | } |
| 2489 | |
| 2490 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2491 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2492 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2493 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2494 | { |
| 2495 | struct bgp *bgp; |
| 2496 | char buf[SU_ADDRSTRLEN]; |
| 2497 | struct bgp_node *rn; |
| 2498 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2499 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2500 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2501 | |
| 2502 | bgp = peer->bgp; |
| 2503 | |
David Lamparter | 4584c23 | 2015-04-13 09:50:00 +0200 | [diff] [blame] | 2504 | /* Lookup node. */ |
| 2505 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
| 2506 | |
| 2507 | /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all |
| 2508 | * routes that are filtered. This tanks out Quagga RS pretty badly due to |
| 2509 | * the iteration over all RS clients. |
| 2510 | * Since we need to remove the entry from adj_in anyway, do that first and |
| 2511 | * if there was no entry, we don't need to do anything more. */ |
| 2512 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2513 | && peer != bgp->peer_self) |
| 2514 | if (!bgp_adj_in_unset (rn, peer)) |
| 2515 | { |
| 2516 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2517 | zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d " |
| 2518 | "not in adj-in", peer->host, |
| 2519 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2520 | p->prefixlen); |
| 2521 | bgp_unlock_node (rn); |
| 2522 | return 0; |
| 2523 | } |
| 2524 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2525 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2526 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2527 | { |
| 2528 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2529 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2530 | } |
| 2531 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2532 | /* Logging. */ |
| 2533 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2534 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2535 | peer->host, |
| 2536 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2537 | p->prefixlen); |
| 2538 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2539 | /* Lookup withdrawn route. */ |
| 2540 | for (ri = rn->info; ri; ri = ri->next) |
| 2541 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2542 | break; |
| 2543 | |
| 2544 | /* Withdraw specified route from routing table. */ |
| 2545 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 2546 | bgp_rib_withdraw (rn, ri, peer, afi, safi, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2547 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2548 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2549 | "%s Can't find the route %s/%d", peer->host, |
| 2550 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2551 | p->prefixlen); |
| 2552 | |
| 2553 | /* Unlock bgp_node_get() lock. */ |
| 2554 | bgp_unlock_node (rn); |
| 2555 | |
| 2556 | return 0; |
| 2557 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2558 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2559 | void |
| 2560 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2561 | { |
| 2562 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 2563 | struct attr attr; |
Jorge Boncompte [DTI2] | 577ac57 | 2012-05-07 16:53:06 +0000 | [diff] [blame] | 2564 | struct aspath *aspath; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2565 | struct prefix p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2566 | struct peer *from; |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2567 | struct bgp_node *rn; |
| 2568 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2569 | int ret = RMAP_DENYMATCH; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2570 | |
Paul Jakma | b249702 | 2007-06-14 11:17:58 +0000 | [diff] [blame] | 2571 | if (!(afi == AFI_IP || afi == AFI_IP6)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2572 | return; |
| 2573 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2574 | bgp = peer->bgp; |
| 2575 | from = bgp->peer_self; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2576 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2577 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2578 | aspath = attr.aspath; |
| 2579 | attr.local_pref = bgp->default_local_pref; |
| 2580 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2581 | |
| 2582 | if (afi == AFI_IP) |
| 2583 | str2prefix ("0.0.0.0/0", &p); |
| 2584 | #ifdef HAVE_IPV6 |
| 2585 | else if (afi == AFI_IP6) |
| 2586 | { |
Jorge Boncompte [DTI2] | 6182d65 | 2012-05-07 16:53:02 +0000 | [diff] [blame] | 2587 | struct attr_extra *ae = attr.extra; |
| 2588 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2589 | str2prefix ("::/0", &p); |
| 2590 | |
| 2591 | /* IPv6 global nexthop must be included. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2592 | memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2593 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2594 | ae->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2595 | |
| 2596 | /* If the peer is on shared nextwork and we have link-local |
| 2597 | nexthop set it. */ |
| 2598 | if (peer->shared_network |
| 2599 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2600 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2601 | memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2602 | IPV6_MAX_BYTELEN); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2603 | ae->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2604 | } |
| 2605 | } |
| 2606 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2607 | |
| 2608 | if (peer->default_rmap[afi][safi].name) |
| 2609 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2610 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2611 | for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn)) |
| 2612 | { |
| 2613 | for (ri = rn->info; ri; ri = ri->next) |
| 2614 | { |
| 2615 | struct attr dummy_attr; |
| 2616 | struct attr_extra dummy_extra; |
| 2617 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2618 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2619 | /* Provide dummy so the route-map can't modify the attributes */ |
| 2620 | dummy_attr.extra = &dummy_extra; |
| 2621 | bgp_attr_dup(&dummy_attr, ri->attr); |
| 2622 | info.peer = ri->peer; |
| 2623 | info.attr = &dummy_attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2624 | |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2625 | ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p, |
| 2626 | RMAP_BGP, &info); |
| 2627 | |
| 2628 | /* The route map might have set attributes. If we don't flush them |
| 2629 | * here, they will be leaked. */ |
| 2630 | bgp_attr_flush(&dummy_attr); |
| 2631 | if (ret != RMAP_DENYMATCH) |
| 2632 | break; |
| 2633 | } |
| 2634 | if (ret != RMAP_DENYMATCH) |
| 2635 | break; |
| 2636 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2637 | bgp->peer_self->rmap_type = 0; |
| 2638 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2639 | if (ret == RMAP_DENYMATCH) |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2640 | withdraw = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2641 | } |
| 2642 | |
| 2643 | if (withdraw) |
| 2644 | { |
| 2645 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2646 | bgp_default_withdraw_send (peer, afi, safi); |
| 2647 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2648 | } |
| 2649 | else |
| 2650 | { |
Christian Franke | dcab1bb | 2012-12-07 16:45:52 +0000 | [diff] [blame] | 2651 | if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2652 | { |
| 2653 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2654 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2655 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2656 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2657 | |
| 2658 | bgp_attr_extra_free (&attr); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 2659 | aspath_unintern (&aspath); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2660 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2661 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2662 | static void |
| 2663 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2664 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2665 | { |
| 2666 | struct bgp_node *rn; |
| 2667 | struct bgp_info *ri; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2668 | struct attr attr; |
| 2669 | struct attr_extra extra; |
| 2670 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2671 | memset(&extra, 0, sizeof(extra)); |
| 2672 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2673 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2674 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2675 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2676 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2677 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2678 | bgp_default_originate (peer, afi, safi, 0); |
| 2679 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 2680 | /* It's initialized in bgp_announce_[check|check_rsclient]() */ |
| 2681 | attr.extra = &extra; |
| 2682 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2683 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2684 | for (ri = rn->info; ri; ri = ri->next) |
| 2685 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2686 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2687 | if ( (rsclient) ? |
| 2688 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2689 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2690 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2691 | else |
| 2692 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2693 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2694 | |
| 2695 | bgp_attr_flush_encap(&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2696 | } |
| 2697 | |
| 2698 | void |
| 2699 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2700 | { |
| 2701 | struct bgp_node *rn; |
| 2702 | struct bgp_table *table; |
| 2703 | |
| 2704 | if (peer->status != Established) |
| 2705 | return; |
| 2706 | |
| 2707 | if (! peer->afc_nego[afi][safi]) |
| 2708 | return; |
| 2709 | |
| 2710 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2711 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2712 | return; |
| 2713 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2714 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2715 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2716 | else |
| 2717 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2718 | rn = bgp_route_next(rn)) |
| 2719 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2720 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2721 | |
| 2722 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2723 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2724 | } |
| 2725 | |
| 2726 | void |
| 2727 | bgp_announce_route_all (struct peer *peer) |
| 2728 | { |
| 2729 | afi_t afi; |
| 2730 | safi_t safi; |
| 2731 | |
| 2732 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2733 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2734 | bgp_announce_route (peer, afi, safi); |
| 2735 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2736 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2737 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2738 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2739 | safi_t safi, struct bgp_table *table, struct prefix_rd *prd) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2740 | { |
| 2741 | struct bgp_node *rn; |
| 2742 | struct bgp_adj_in *ain; |
| 2743 | |
| 2744 | if (! table) |
| 2745 | table = rsclient->bgp->rib[afi][safi]; |
| 2746 | |
| 2747 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2748 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2749 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2750 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2751 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2752 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2753 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2754 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2755 | } |
| 2756 | } |
| 2757 | |
| 2758 | void |
| 2759 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2760 | { |
| 2761 | struct bgp_table *table; |
| 2762 | struct bgp_node *rn; |
| 2763 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2764 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2765 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2766 | |
| 2767 | else |
| 2768 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2769 | rn = bgp_route_next (rn)) |
| 2770 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2771 | { |
| 2772 | struct prefix_rd prd; |
| 2773 | prd.family = AF_UNSPEC; |
| 2774 | prd.prefixlen = 64; |
| 2775 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2776 | |
| 2777 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd); |
| 2778 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2779 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2780 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2781 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2782 | 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] | 2783 | struct bgp_table *table, struct prefix_rd *prd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2784 | { |
| 2785 | int ret; |
| 2786 | struct bgp_node *rn; |
| 2787 | struct bgp_adj_in *ain; |
| 2788 | |
| 2789 | if (! table) |
| 2790 | table = peer->bgp->rib[afi][safi]; |
| 2791 | |
| 2792 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2793 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2794 | { |
| 2795 | if (ain->peer == peer) |
| 2796 | { |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2797 | struct bgp_info *ri = rn->info; |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2798 | u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL; |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2799 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2800 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2801 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
Christian Franke | d53d8fd | 2013-01-28 07:14:43 +0100 | [diff] [blame] | 2802 | prd, tag, 1); |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2803 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2804 | if (ret < 0) |
| 2805 | { |
| 2806 | bgp_unlock_node (rn); |
| 2807 | return; |
| 2808 | } |
| 2809 | continue; |
| 2810 | } |
| 2811 | } |
| 2812 | } |
| 2813 | |
| 2814 | void |
| 2815 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2816 | { |
| 2817 | struct bgp_node *rn; |
| 2818 | struct bgp_table *table; |
| 2819 | |
| 2820 | if (peer->status != Established) |
| 2821 | return; |
| 2822 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 2823 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2824 | bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2825 | else |
| 2826 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2827 | rn = bgp_route_next (rn)) |
| 2828 | if ((table = rn->info) != NULL) |
Jorge Boncompte [DTI2] | 8692c50 | 2012-05-07 15:17:34 +0000 | [diff] [blame] | 2829 | { |
| 2830 | struct prefix_rd prd; |
| 2831 | prd.family = AF_UNSPEC; |
| 2832 | prd.prefixlen = 64; |
| 2833 | memcpy(&prd.val, rn->p.u.val, 8); |
| 2834 | |
| 2835 | bgp_soft_reconfig_table (peer, afi, safi, table, &prd); |
| 2836 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2837 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2838 | |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2839 | |
| 2840 | struct bgp_clear_node_queue |
| 2841 | { |
| 2842 | struct bgp_node *rn; |
| 2843 | enum bgp_clear_route_type purpose; |
| 2844 | }; |
| 2845 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2846 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2847 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2848 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2849 | struct bgp_clear_node_queue *cnq = data; |
| 2850 | struct bgp_node *rn = cnq->rn; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2851 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2852 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2853 | afi_t afi = bgp_node_table (rn)->afi; |
| 2854 | safi_t safi = bgp_node_table (rn)->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2855 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2856 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2857 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2858 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2859 | if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2860 | { |
| 2861 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2862 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2863 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2864 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 2865 | && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
| 2866 | bgp_info_set_flag (rn, ri, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2867 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2868 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2869 | break; |
| 2870 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2871 | return WQ_SUCCESS; |
| 2872 | } |
| 2873 | |
| 2874 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2875 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2876 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2877 | struct bgp_clear_node_queue *cnq = data; |
| 2878 | struct bgp_node *rn = cnq->rn; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2879 | struct bgp_table *table = bgp_node_table (rn); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2880 | |
| 2881 | bgp_unlock_node (rn); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2882 | bgp_table_unlock (table); |
| 2883 | XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2884 | } |
| 2885 | |
| 2886 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2887 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2888 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2889 | struct peer *peer = wq->spec.data; |
| 2890 | |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2891 | /* Tickle FSM to start moving again */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 2892 | BGP_EVENT_ADD (peer, Clearing_Completed); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2893 | |
| 2894 | peer_unlock (peer); /* bgp_clear_route */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2895 | } |
| 2896 | |
| 2897 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2898 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2899 | { |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2900 | char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2901 | |
Paul Jakma | a294365 | 2009-07-21 14:02:04 +0100 | [diff] [blame] | 2902 | snprintf (wname, sizeof(wname), "clear %s", peer->host); |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2903 | #undef CLEAR_QUEUE_NAME_LEN |
| 2904 | |
| 2905 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2906 | { |
| 2907 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2908 | exit (1); |
| 2909 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2910 | peer->clear_node_queue->spec.hold = 10; |
| 2911 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2912 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2913 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2914 | peer->clear_node_queue->spec.max_retries = 0; |
| 2915 | |
| 2916 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2917 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2918 | } |
| 2919 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2920 | static void |
| 2921 | 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] | 2922 | struct bgp_table *table, struct peer *rsclient, |
| 2923 | enum bgp_clear_route_type purpose) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2924 | { |
| 2925 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2926 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2927 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2928 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2929 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2930 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2931 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2932 | if (! table) |
| 2933 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2934 | |
| 2935 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2936 | { |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2937 | struct bgp_info *ri; |
| 2938 | struct bgp_adj_in *ain; |
| 2939 | struct bgp_adj_out *aout; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2940 | |
| 2941 | /* XXX:TODO: This is suboptimal, every non-empty route_node is |
| 2942 | * queued for every clearing peer, regardless of whether it is |
| 2943 | * relevant to the peer at hand. |
| 2944 | * |
| 2945 | * Overview: There are 3 different indices which need to be |
| 2946 | * scrubbed, potentially, when a peer is removed: |
| 2947 | * |
| 2948 | * 1 peer's routes visible via the RIB (ie accepted routes) |
| 2949 | * 2 peer's routes visible by the (optional) peer's adj-in index |
| 2950 | * 3 other routes visible by the peer's adj-out index |
| 2951 | * |
| 2952 | * 3 there is no hurry in scrubbing, once the struct peer is |
| 2953 | * removed from bgp->peer, we could just GC such deleted peer's |
| 2954 | * adj-outs at our leisure. |
| 2955 | * |
| 2956 | * 1 and 2 must be 'scrubbed' in some way, at least made |
| 2957 | * invisible via RIB index before peer session is allowed to be |
| 2958 | * brought back up. So one needs to know when such a 'search' is |
| 2959 | * complete. |
| 2960 | * |
| 2961 | * Ideally: |
| 2962 | * |
| 2963 | * - there'd be a single global queue or a single RIB walker |
| 2964 | * - rather than tracking which route_nodes still need to be |
| 2965 | * examined on a peer basis, we'd track which peers still |
| 2966 | * aren't cleared |
| 2967 | * |
| 2968 | * Given that our per-peer prefix-counts now should be reliable, |
| 2969 | * this may actually be achievable. It doesn't seem to be a huge |
| 2970 | * problem at this time, |
| 2971 | */ |
Jorge Boncompte [DTI2] | 24e50f2 | 2012-05-07 15:17:33 +0000 | [diff] [blame] | 2972 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2973 | if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2974 | { |
| 2975 | bgp_adj_in_remove (rn, ain); |
| 2976 | bgp_unlock_node (rn); |
| 2977 | break; |
| 2978 | } |
| 2979 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2980 | if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
| 2981 | { |
| 2982 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2983 | bgp_unlock_node (rn); |
| 2984 | break; |
| 2985 | } |
| 2986 | |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2987 | for (ri = rn->info; ri; ri = ri->next) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2988 | if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 2989 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2990 | struct bgp_clear_node_queue *cnq; |
| 2991 | |
| 2992 | /* both unlocked in bgp_clear_node_queue_del */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 2993 | bgp_table_lock (bgp_node_table (rn)); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 2994 | bgp_lock_node (rn); |
| 2995 | cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE, |
| 2996 | sizeof (struct bgp_clear_node_queue)); |
| 2997 | cnq->rn = rn; |
| 2998 | cnq->purpose = purpose; |
| 2999 | work_queue_add (peer->clear_node_queue, cnq); |
| 3000 | break; |
Paul Jakma | f2c31ac | 2007-02-22 17:48:42 +0000 | [diff] [blame] | 3001 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 3002 | } |
| 3003 | return; |
| 3004 | } |
| 3005 | |
| 3006 | void |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3007 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, |
| 3008 | enum bgp_clear_route_type purpose) |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 3009 | { |
| 3010 | struct bgp_node *rn; |
| 3011 | struct bgp_table *table; |
| 3012 | struct peer *rsclient; |
| 3013 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 3014 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3015 | if (peer->clear_node_queue == NULL) |
| 3016 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3017 | |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 3018 | /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to |
| 3019 | * Idle until it receives a Clearing_Completed event. This protects |
| 3020 | * against peers which flap faster than we can we clear, which could |
| 3021 | * lead to: |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3022 | * |
| 3023 | * a) race with routes from the new session being installed before |
| 3024 | * clear_route_node visits the node (to delete the route of that |
| 3025 | * peer) |
| 3026 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 3027 | * on the process_main queue. Fast-flapping could cause that queue |
| 3028 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3029 | */ |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3030 | |
| 3031 | /* lock peer in assumption that clear-node-queue will get nodes; if so, |
| 3032 | * the unlock will happen upon work-queue completion; other wise, the |
| 3033 | * unlock happens at the end of this function. |
| 3034 | */ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 3035 | if (!peer->clear_node_queue->thread) |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3036 | peer_lock (peer); /* bgp_clear_node_complete */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3037 | switch (purpose) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3038 | { |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3039 | case BGP_CLEAR_ROUTE_NORMAL: |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3040 | if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3041 | bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose); |
| 3042 | else |
| 3043 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 3044 | rn = bgp_route_next (rn)) |
| 3045 | if ((table = rn->info) != NULL) |
| 3046 | bgp_clear_route_table (peer, afi, safi, table, NULL, purpose); |
| 3047 | |
| 3048 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
| 3049 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], |
| 3050 | PEER_FLAG_RSERVER_CLIENT)) |
| 3051 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose); |
| 3052 | break; |
| 3053 | |
| 3054 | case BGP_CLEAR_ROUTE_MY_RSCLIENT: |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3055 | /* |
| 3056 | * gpz 091009: TBD why don't we have special handling for |
| 3057 | * SAFI_MPLS_VPN here in the original quagga code? |
| 3058 | * (and, by extension, for SAFI_ENCAP) |
| 3059 | */ |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3060 | bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose); |
| 3061 | break; |
| 3062 | |
| 3063 | default: |
| 3064 | assert (0); |
| 3065 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3066 | } |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3067 | |
| 3068 | /* unlock if no nodes got added to the clear-node-queue. */ |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 3069 | if (!peer->clear_node_queue->thread) |
Donald Sharp | 7ef4221 | 2015-03-30 06:32:52 -0700 | [diff] [blame] | 3070 | peer_unlock (peer); |
| 3071 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3072 | } |
| 3073 | |
| 3074 | void |
| 3075 | bgp_clear_route_all (struct peer *peer) |
| 3076 | { |
| 3077 | afi_t afi; |
| 3078 | safi_t safi; |
| 3079 | |
| 3080 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3081 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 3082 | bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3083 | } |
| 3084 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3085 | /* |
| 3086 | * Finish freeing things when exiting |
| 3087 | */ |
| 3088 | static void |
| 3089 | bgp_drain_workqueue_immediate (struct work_queue *wq) |
| 3090 | { |
| 3091 | if (!wq) |
| 3092 | return; |
| 3093 | |
| 3094 | if (!wq->thread) |
| 3095 | { |
| 3096 | /* |
| 3097 | * no thread implies no queued items |
| 3098 | */ |
| 3099 | assert(!wq->items->count); |
| 3100 | return; |
| 3101 | } |
| 3102 | |
| 3103 | while (wq->items->count) |
| 3104 | { |
| 3105 | if (wq->thread) |
| 3106 | thread_cancel(wq->thread); |
| 3107 | work_queue_run(wq->thread); |
| 3108 | } |
| 3109 | } |
| 3110 | |
| 3111 | /* |
| 3112 | * Special function to process clear node queue when bgpd is exiting |
| 3113 | * and the thread scheduler is no longer running. |
| 3114 | */ |
| 3115 | void |
| 3116 | bgp_peer_clear_node_queue_drain_immediate(struct peer *peer) |
| 3117 | { |
| 3118 | if (!peer) |
| 3119 | return; |
| 3120 | |
| 3121 | bgp_drain_workqueue_immediate(peer->clear_node_queue); |
| 3122 | } |
| 3123 | |
| 3124 | /* |
| 3125 | * The work queues are not specific to a BGP instance, but the |
| 3126 | * items in them refer to BGP instances, so this should be called |
| 3127 | * before each BGP instance is deleted. |
| 3128 | */ |
| 3129 | void |
| 3130 | bgp_process_queues_drain_immediate(void) |
| 3131 | { |
| 3132 | bgp_drain_workqueue_immediate(bm->process_main_queue); |
| 3133 | bgp_drain_workqueue_immediate(bm->process_rsclient_queue); |
| 3134 | } |
| 3135 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3136 | void |
| 3137 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 3138 | { |
| 3139 | struct bgp_table *table; |
| 3140 | struct bgp_node *rn; |
| 3141 | struct bgp_adj_in *ain; |
| 3142 | |
| 3143 | table = peer->bgp->rib[afi][safi]; |
| 3144 | |
| 3145 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3146 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 3147 | if (ain->peer == peer) |
| 3148 | { |
| 3149 | bgp_adj_in_remove (rn, ain); |
| 3150 | bgp_unlock_node (rn); |
| 3151 | break; |
| 3152 | } |
| 3153 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 3154 | |
| 3155 | void |
| 3156 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 3157 | { |
| 3158 | struct bgp_node *rn; |
| 3159 | struct bgp_info *ri; |
| 3160 | struct bgp_table *table; |
| 3161 | |
| 3162 | table = peer->bgp->rib[afi][safi]; |
| 3163 | |
| 3164 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3165 | { |
| 3166 | for (ri = rn->info; ri; ri = ri->next) |
| 3167 | if (ri->peer == peer) |
| 3168 | { |
| 3169 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 3170 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 3171 | break; |
| 3172 | } |
| 3173 | } |
| 3174 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3175 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3176 | static void |
| 3177 | bgp_cleanup_table(struct bgp_table *table, safi_t safi) |
| 3178 | { |
| 3179 | struct bgp_node *rn; |
| 3180 | struct bgp_info *ri; |
| 3181 | struct bgp_info *next; |
| 3182 | |
| 3183 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 3184 | for (ri = rn->info; ri; ri = next) |
| 3185 | { |
| 3186 | next = ri->next; |
| 3187 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 3188 | && ri->type == ZEBRA_ROUTE_BGP |
| 3189 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 3190 | bgp_zebra_withdraw (&rn->p, ri, safi); |
| 3191 | } |
| 3192 | } |
| 3193 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3194 | /* Delete all kernel routes. */ |
| 3195 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3196 | bgp_cleanup_routes (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3197 | { |
| 3198 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3199 | struct listnode *node, *nnode; |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3200 | afi_t afi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3201 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3202 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3203 | { |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3204 | for (afi = AFI_IP; afi < AFI_MAX; ++afi) |
| 3205 | { |
| 3206 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3207 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3208 | bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3209 | |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3210 | /* |
| 3211 | * VPN and ENCAP tables are two-level (RD is top level) |
| 3212 | */ |
| 3213 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn; |
| 3214 | rn = bgp_route_next (rn)) |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3215 | { |
| 3216 | if (rn->info) |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3217 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3218 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN); |
| 3219 | bgp_table_finish ((struct bgp_table **)&(rn->info)); |
| 3220 | rn->info = NULL; |
| 3221 | bgp_unlock_node(rn); |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3222 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3223 | } |
| 3224 | |
| 3225 | for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn; |
| 3226 | rn = bgp_route_next (rn)) |
| 3227 | { |
| 3228 | if (rn->info) |
| 3229 | { |
| 3230 | bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP); |
| 3231 | bgp_table_finish ((struct bgp_table **)&(rn->info)); |
| 3232 | rn->info = NULL; |
| 3233 | bgp_unlock_node(rn); |
| 3234 | } |
| 3235 | } |
Lou Berger | 82dd707 | 2016-01-12 13:41:57 -0500 | [diff] [blame] | 3236 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3237 | } |
| 3238 | } |
| 3239 | |
| 3240 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3241 | bgp_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3242 | { |
| 3243 | vty_reset (); |
| 3244 | bgp_zclient_reset (); |
| 3245 | access_list_reset (); |
| 3246 | prefix_list_reset (); |
| 3247 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3248 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3249 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 3250 | value. */ |
| 3251 | int |
| 3252 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 3253 | { |
| 3254 | u_char *pnt; |
| 3255 | u_char *lim; |
| 3256 | struct prefix p; |
| 3257 | int psize; |
| 3258 | int ret; |
| 3259 | |
| 3260 | /* Check peer status. */ |
| 3261 | if (peer->status != Established) |
| 3262 | return 0; |
| 3263 | |
| 3264 | pnt = packet->nlri; |
| 3265 | lim = pnt + packet->length; |
| 3266 | |
| 3267 | for (; pnt < lim; pnt += psize) |
| 3268 | { |
| 3269 | /* Clear prefix structure. */ |
| 3270 | memset (&p, 0, sizeof (struct prefix)); |
| 3271 | |
| 3272 | /* Fetch prefix length. */ |
| 3273 | p.prefixlen = *pnt++; |
| 3274 | p.family = afi2family (packet->afi); |
| 3275 | |
| 3276 | /* Already checked in nlri_sanity_check(). We do double check |
| 3277 | here. */ |
| 3278 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 3279 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 3280 | return -1; |
| 3281 | |
| 3282 | /* Packet size overflow check. */ |
| 3283 | psize = PSIZE (p.prefixlen); |
| 3284 | |
| 3285 | /* When packet overflow occur return immediately. */ |
| 3286 | if (pnt + psize > lim) |
| 3287 | return -1; |
| 3288 | |
| 3289 | /* Fetch prefix from NLRI packet. */ |
| 3290 | memcpy (&p.u.prefix, pnt, psize); |
| 3291 | |
| 3292 | /* Check address. */ |
| 3293 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 3294 | { |
| 3295 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 3296 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3297 | /* |
| 3298 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 3299 | * If a BGP router receives an UPDATE message with a |
| 3300 | * semantically incorrect NLRI field, in which a prefix is |
| 3301 | * semantically incorrect (eg. an unexpected multicast IP |
| 3302 | * address), it should ignore the prefix. |
| 3303 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3304 | zlog (peer->log, LOG_ERR, |
| 3305 | "IPv4 unicast NLRI is multicast address %s", |
| 3306 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 3307 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3308 | return -1; |
| 3309 | } |
| 3310 | } |
| 3311 | |
| 3312 | #ifdef HAVE_IPV6 |
| 3313 | /* Check address. */ |
| 3314 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 3315 | { |
| 3316 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3317 | { |
| 3318 | char buf[BUFSIZ]; |
| 3319 | |
| 3320 | zlog (peer->log, LOG_WARNING, |
| 3321 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 3322 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 3323 | |
| 3324 | continue; |
| 3325 | } |
| 3326 | } |
| 3327 | #endif /* HAVE_IPV6 */ |
| 3328 | |
| 3329 | /* Normal process. */ |
| 3330 | if (attr) |
| 3331 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 3332 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 3333 | else |
| 3334 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 3335 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 3336 | |
| 3337 | /* Address family configuration mismatch or maximum-prefix count |
| 3338 | overflow. */ |
| 3339 | if (ret < 0) |
| 3340 | return -1; |
| 3341 | } |
| 3342 | |
| 3343 | /* Packet length consistency check. */ |
| 3344 | if (pnt != lim) |
| 3345 | return -1; |
| 3346 | |
| 3347 | return 0; |
| 3348 | } |
| 3349 | |
| 3350 | /* NLRI encode syntax check routine. */ |
| 3351 | int |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 3352 | bgp_nlri_sanity_check (struct peer *peer, int afi, safi_t safi, |
| 3353 | u_char *pnt, bgp_size_t length) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3354 | { |
| 3355 | u_char *end; |
| 3356 | u_char prefixlen; |
| 3357 | int psize; |
| 3358 | |
| 3359 | end = pnt + length; |
| 3360 | |
| 3361 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 3362 | syntactic validity. If the field is syntactically incorrect, |
| 3363 | then the Error Subcode is set to Invalid Network Field. */ |
| 3364 | |
| 3365 | while (pnt < end) |
| 3366 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3367 | int badlength; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3368 | prefixlen = *pnt++; |
| 3369 | |
| 3370 | /* Prefix length check. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 3371 | badlength = 0; |
| 3372 | if (safi == SAFI_ENCAP) { |
| 3373 | if (prefixlen > 128) |
| 3374 | badlength = 1; |
| 3375 | } else { |
| 3376 | if ((afi == AFI_IP && prefixlen > 32) || |
| 3377 | (afi == AFI_IP6 && prefixlen > 128)) { |
| 3378 | |
| 3379 | badlength = 1; |
| 3380 | } |
| 3381 | } |
| 3382 | if (badlength) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3383 | { |
| 3384 | plog_err (peer->log, |
| 3385 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 3386 | peer->host, prefixlen); |
| 3387 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3388 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3389 | return -1; |
| 3390 | } |
| 3391 | |
| 3392 | /* Packet size overflow check. */ |
| 3393 | psize = PSIZE (prefixlen); |
| 3394 | |
| 3395 | if (pnt + psize > end) |
| 3396 | { |
| 3397 | plog_err (peer->log, |
| 3398 | "%s [Error] Update packet error" |
| 3399 | " (prefix data overflow prefix size is %d)", |
| 3400 | peer->host, psize); |
| 3401 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3402 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3403 | return -1; |
| 3404 | } |
| 3405 | |
| 3406 | pnt += psize; |
| 3407 | } |
| 3408 | |
| 3409 | /* Packet length consistency check. */ |
| 3410 | if (pnt != end) |
| 3411 | { |
| 3412 | plog_err (peer->log, |
| 3413 | "%s [Error] Update packet error" |
| 3414 | " (prefix length mismatch with total length)", |
| 3415 | peer->host); |
| 3416 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 3417 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 3418 | return -1; |
| 3419 | } |
| 3420 | return 0; |
| 3421 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3422 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3423 | static struct bgp_static * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 3424 | bgp_static_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3425 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 3426 | return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3427 | } |
| 3428 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3429 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3430 | bgp_static_free (struct bgp_static *bgp_static) |
| 3431 | { |
| 3432 | if (bgp_static->rmap.name) |
| 3433 | free (bgp_static->rmap.name); |
| 3434 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 3435 | } |
| 3436 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3437 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3438 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 3439 | struct prefix *p, afi_t afi, safi_t safi) |
| 3440 | { |
| 3441 | struct bgp_node *rn; |
| 3442 | struct bgp_info *ri; |
| 3443 | |
| 3444 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3445 | |
| 3446 | /* Check selected route and self inserted route. */ |
| 3447 | for (ri = rn->info; ri; ri = ri->next) |
| 3448 | if (ri->peer == bgp->peer_self |
| 3449 | && ri->type == ZEBRA_ROUTE_BGP |
| 3450 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3451 | break; |
| 3452 | |
| 3453 | /* Withdraw static BGP route from routing table. */ |
| 3454 | if (ri) |
| 3455 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3456 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3457 | bgp_process (bgp, rn, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3458 | } |
| 3459 | |
| 3460 | /* Unlock bgp_node_lookup. */ |
| 3461 | bgp_unlock_node (rn); |
| 3462 | } |
| 3463 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3464 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3465 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3466 | struct bgp_static *bgp_static, |
| 3467 | afi_t afi, safi_t safi) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3468 | { |
| 3469 | struct bgp_node *rn; |
| 3470 | struct bgp_info *ri; |
| 3471 | struct bgp_info *new; |
| 3472 | struct bgp_info info; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3473 | struct attr *attr_new; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3474 | struct attr attr; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3475 | struct attr new_attr; |
| 3476 | struct attr_extra new_extra; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3477 | struct bgp *bgp; |
| 3478 | int ret; |
| 3479 | char buf[SU_ADDRSTRLEN]; |
| 3480 | |
| 3481 | bgp = rsclient->bgp; |
| 3482 | |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3483 | assert (bgp_static); |
| 3484 | if (!bgp_static) |
| 3485 | return; |
| 3486 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3487 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 3488 | |
| 3489 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | 06e110f | 2006-05-12 23:29:22 +0000 | [diff] [blame] | 3490 | |
| 3491 | attr.nexthop = bgp_static->igpnexthop; |
| 3492 | attr.med = bgp_static->igpmetric; |
| 3493 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3494 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3495 | if (bgp_static->atomic) |
| 3496 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3497 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3498 | /* Apply network route-map for export to this rsclient. */ |
| 3499 | if (bgp_static->rmap.name) |
| 3500 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3501 | struct attr attr_tmp = attr; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3502 | info.peer = rsclient; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3503 | info.attr = &attr_tmp; |
| 3504 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3505 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 3506 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3507 | |
| 3508 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3509 | |
| 3510 | rsclient->rmap_type = 0; |
| 3511 | |
| 3512 | if (ret == RMAP_DENYMATCH) |
| 3513 | { |
| 3514 | /* Free uninterned attribute. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3515 | bgp_attr_flush (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3516 | |
| 3517 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3518 | aspath_unintern (&attr.aspath); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3519 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3520 | bgp_attr_extra_free (&attr); |
| 3521 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3522 | return; |
| 3523 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3524 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3525 | } |
| 3526 | else |
| 3527 | attr_new = bgp_attr_intern (&attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 3528 | |
| 3529 | new_attr.extra = &new_extra; |
Stephen Hemminger | 7badc26 | 2010-08-05 10:26:31 -0700 | [diff] [blame] | 3530 | bgp_attr_dup(&new_attr, attr_new); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3531 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3532 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3533 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3534 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) |
| 3535 | == RMAP_DENY) |
| 3536 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3537 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 3538 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 3539 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3540 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 3541 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 3542 | p->prefixlen, rsclient->host); |
| 3543 | |
| 3544 | bgp->peer_self->rmap_type = 0; |
| 3545 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3546 | bgp_attr_unintern (&attr_new); |
| 3547 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3548 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3549 | |
| 3550 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 3551 | |
| 3552 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3553 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3554 | |
| 3555 | bgp->peer_self->rmap_type = 0; |
| 3556 | |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3557 | bgp_attr_unintern (&attr_new); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3558 | attr_new = bgp_attr_intern (&new_attr); |
| 3559 | |
| 3560 | for (ri = rn->info; ri; ri = ri->next) |
| 3561 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3562 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3563 | break; |
| 3564 | |
| 3565 | if (ri) |
| 3566 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3567 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3568 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3569 | { |
| 3570 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3571 | bgp_attr_unintern (&attr_new); |
| 3572 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3573 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3574 | return; |
| 3575 | } |
| 3576 | else |
| 3577 | { |
| 3578 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3579 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3580 | |
| 3581 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3582 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3583 | bgp_info_restore(rn, ri); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3584 | bgp_attr_unintern (&ri->attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3585 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3586 | ri->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3587 | |
| 3588 | /* Process change. */ |
| 3589 | bgp_process (bgp, rn, afi, safi); |
| 3590 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3591 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3592 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3593 | return; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3594 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3595 | } |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3596 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3597 | /* Make new BGP info. */ |
| 3598 | new = bgp_info_new (); |
| 3599 | new->type = ZEBRA_ROUTE_BGP; |
| 3600 | new->sub_type = BGP_ROUTE_STATIC; |
| 3601 | new->peer = bgp->peer_self; |
| 3602 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3603 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3604 | new->uptime = bgp_clock (); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3605 | |
| 3606 | /* Register new BGP information. */ |
| 3607 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3608 | |
| 3609 | /* route_node_get lock */ |
| 3610 | bgp_unlock_node (rn); |
| 3611 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3612 | /* Process change. */ |
| 3613 | bgp_process (bgp, rn, afi, safi); |
| 3614 | |
| 3615 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3616 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3617 | bgp_attr_extra_free (&attr); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3618 | } |
| 3619 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3620 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3621 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3622 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3623 | { |
| 3624 | struct bgp_node *rn; |
| 3625 | struct bgp_info *ri; |
| 3626 | struct bgp_info *new; |
| 3627 | struct bgp_info info; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 3628 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3629 | struct attr *attr_new; |
| 3630 | int ret; |
| 3631 | |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3632 | assert (bgp_static); |
| 3633 | if (!bgp_static) |
| 3634 | return; |
| 3635 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3636 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3637 | |
| 3638 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
Paul Jakma | dd8103a | 2006-05-12 23:27:30 +0000 | [diff] [blame] | 3639 | |
| 3640 | attr.nexthop = bgp_static->igpnexthop; |
| 3641 | attr.med = bgp_static->igpmetric; |
| 3642 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3643 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3644 | if (bgp_static->atomic) |
| 3645 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 3646 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3647 | /* Apply route-map. */ |
| 3648 | if (bgp_static->rmap.name) |
| 3649 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3650 | struct attr attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3651 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3652 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3653 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3654 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3655 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3656 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3657 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3658 | bgp->peer_self->rmap_type = 0; |
| 3659 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3660 | if (ret == RMAP_DENYMATCH) |
| 3661 | { |
| 3662 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3663 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3664 | |
| 3665 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3666 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3667 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3668 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3669 | return; |
| 3670 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3671 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3672 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3673 | else |
| 3674 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3675 | |
| 3676 | for (ri = rn->info; ri; ri = ri->next) |
| 3677 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3678 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3679 | break; |
| 3680 | |
| 3681 | if (ri) |
| 3682 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3683 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3684 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3685 | { |
| 3686 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3687 | bgp_attr_unintern (&attr_new); |
| 3688 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3689 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3690 | return; |
| 3691 | } |
| 3692 | else |
| 3693 | { |
| 3694 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3695 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3696 | |
| 3697 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 3698 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3699 | bgp_info_restore(rn, ri); |
| 3700 | else |
| 3701 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3702 | bgp_attr_unintern (&ri->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3703 | ri->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3704 | ri->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3705 | |
| 3706 | /* Process change. */ |
| 3707 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3708 | bgp_process (bgp, rn, afi, safi); |
| 3709 | bgp_unlock_node (rn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3710 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3711 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3712 | return; |
| 3713 | } |
| 3714 | } |
| 3715 | |
| 3716 | /* Make new BGP info. */ |
| 3717 | new = bgp_info_new (); |
| 3718 | new->type = ZEBRA_ROUTE_BGP; |
| 3719 | new->sub_type = BGP_ROUTE_STATIC; |
| 3720 | new->peer = bgp->peer_self; |
| 3721 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3722 | new->attr = attr_new; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 3723 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3724 | |
| 3725 | /* Aggregate address increment. */ |
| 3726 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3727 | |
| 3728 | /* Register new BGP information. */ |
| 3729 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3730 | |
| 3731 | /* route_node_get lock */ |
| 3732 | bgp_unlock_node (rn); |
| 3733 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3734 | /* Process change. */ |
| 3735 | bgp_process (bgp, rn, afi, safi); |
| 3736 | |
| 3737 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 3738 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 3739 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3740 | } |
| 3741 | |
| 3742 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3743 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3744 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3745 | { |
| 3746 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3747 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3748 | |
| 3749 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3750 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3751 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3752 | { |
Paul Jakma | da5b30f | 2006-05-08 14:37:17 +0000 | [diff] [blame] | 3753 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 3754 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3755 | } |
| 3756 | } |
| 3757 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3758 | void |
| 3759 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3760 | safi_t safi) |
| 3761 | { |
| 3762 | struct bgp_node *rn; |
| 3763 | struct bgp_info *ri; |
| 3764 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3765 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3766 | |
| 3767 | /* Check selected route and self inserted route. */ |
| 3768 | for (ri = rn->info; ri; ri = ri->next) |
| 3769 | if (ri->peer == bgp->peer_self |
| 3770 | && ri->type == ZEBRA_ROUTE_BGP |
| 3771 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3772 | break; |
| 3773 | |
| 3774 | /* Withdraw static BGP route from routing table. */ |
| 3775 | if (ri) |
| 3776 | { |
| 3777 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3778 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3779 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3780 | } |
| 3781 | |
| 3782 | /* Unlock bgp_node_lookup. */ |
| 3783 | bgp_unlock_node (rn); |
| 3784 | } |
| 3785 | |
| 3786 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3787 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3788 | { |
| 3789 | struct bgp_static *bgp_static; |
| 3790 | struct bgp *bgp; |
| 3791 | struct bgp_node *rn; |
| 3792 | struct prefix *p; |
| 3793 | |
| 3794 | bgp = rsclient->bgp; |
| 3795 | |
| 3796 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3797 | if ((bgp_static = rn->info) != NULL) |
| 3798 | { |
| 3799 | p = &rn->p; |
| 3800 | |
| 3801 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3802 | afi, safi); |
| 3803 | } |
| 3804 | } |
| 3805 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3806 | /* |
| 3807 | * Used for SAFI_MPLS_VPN and SAFI_ENCAP |
| 3808 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3809 | static void |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3810 | bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3811 | safi_t safi, struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3812 | { |
| 3813 | struct bgp_node *rn; |
| 3814 | struct bgp_info *ri; |
| 3815 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3816 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3817 | |
| 3818 | /* Check selected route and self inserted route. */ |
| 3819 | for (ri = rn->info; ri; ri = ri->next) |
| 3820 | if (ri->peer == bgp->peer_self |
| 3821 | && ri->type == ZEBRA_ROUTE_BGP |
| 3822 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3823 | break; |
| 3824 | |
| 3825 | /* Withdraw static BGP route from routing table. */ |
| 3826 | if (ri) |
| 3827 | { |
| 3828 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3829 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 3830 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3831 | } |
| 3832 | |
| 3833 | /* Unlock bgp_node_lookup. */ |
| 3834 | bgp_unlock_node (rn); |
| 3835 | } |
| 3836 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 3837 | static void |
| 3838 | bgp_static_update_safi (struct bgp *bgp, struct prefix *p, |
| 3839 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3840 | { |
| 3841 | struct bgp_node *rn; |
| 3842 | struct bgp_info *new; |
| 3843 | struct attr *attr_new; |
| 3844 | struct attr attr = { 0 }; |
| 3845 | struct bgp_info *ri; |
| 3846 | |
| 3847 | assert (bgp_static); |
| 3848 | |
| 3849 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd); |
| 3850 | |
| 3851 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 3852 | |
| 3853 | attr.nexthop = bgp_static->igpnexthop; |
| 3854 | attr.med = bgp_static->igpmetric; |
| 3855 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 3856 | |
| 3857 | /* Apply route-map. */ |
| 3858 | if (bgp_static->rmap.name) |
| 3859 | { |
| 3860 | struct attr attr_tmp = attr; |
| 3861 | struct bgp_info info; |
| 3862 | int ret; |
| 3863 | |
| 3864 | info.peer = bgp->peer_self; |
| 3865 | info.attr = &attr_tmp; |
| 3866 | |
| 3867 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3868 | |
| 3869 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 3870 | |
| 3871 | bgp->peer_self->rmap_type = 0; |
| 3872 | |
| 3873 | if (ret == RMAP_DENYMATCH) |
| 3874 | { |
| 3875 | /* Free uninterned attribute. */ |
| 3876 | bgp_attr_flush (&attr_tmp); |
| 3877 | |
| 3878 | /* Unintern original. */ |
| 3879 | aspath_unintern (&attr.aspath); |
| 3880 | bgp_attr_extra_free (&attr); |
| 3881 | bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd, |
| 3882 | bgp_static->tag); |
| 3883 | return; |
| 3884 | } |
| 3885 | |
| 3886 | attr_new = bgp_attr_intern (&attr_tmp); |
| 3887 | } |
| 3888 | else |
| 3889 | { |
| 3890 | attr_new = bgp_attr_intern (&attr); |
| 3891 | } |
| 3892 | |
| 3893 | for (ri = rn->info; ri; ri = ri->next) |
| 3894 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3895 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3896 | break; |
| 3897 | |
| 3898 | if (ri) |
| 3899 | { |
| 3900 | if (attrhash_cmp (ri->attr, attr_new) && |
| 3901 | !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3902 | { |
| 3903 | bgp_unlock_node (rn); |
| 3904 | bgp_attr_unintern (&attr_new); |
| 3905 | aspath_unintern (&attr.aspath); |
| 3906 | bgp_attr_extra_free (&attr); |
| 3907 | return; |
| 3908 | } |
| 3909 | else |
| 3910 | { |
| 3911 | /* The attribute is changed. */ |
| 3912 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
| 3913 | |
| 3914 | /* Rewrite BGP route information. */ |
| 3915 | if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) |
| 3916 | bgp_info_restore(rn, ri); |
| 3917 | else |
| 3918 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 3919 | bgp_attr_unintern (&ri->attr); |
| 3920 | ri->attr = attr_new; |
| 3921 | ri->uptime = bgp_clock (); |
| 3922 | |
| 3923 | /* Process change. */ |
| 3924 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3925 | bgp_process (bgp, rn, afi, safi); |
| 3926 | bgp_unlock_node (rn); |
| 3927 | aspath_unintern (&attr.aspath); |
| 3928 | bgp_attr_extra_free (&attr); |
| 3929 | return; |
| 3930 | } |
| 3931 | } |
| 3932 | |
| 3933 | |
| 3934 | /* Make new BGP info. */ |
| 3935 | new = bgp_info_new (); |
| 3936 | new->type = ZEBRA_ROUTE_BGP; |
| 3937 | new->sub_type = BGP_ROUTE_STATIC; |
| 3938 | new->peer = bgp->peer_self; |
| 3939 | new->attr = attr_new; |
| 3940 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3941 | new->uptime = bgp_clock (); |
| 3942 | new->extra = bgp_info_extra_new(); |
| 3943 | memcpy (new->extra->tag, bgp_static->tag, 3); |
| 3944 | |
| 3945 | /* Aggregate address increment. */ |
| 3946 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3947 | |
| 3948 | /* Register new BGP information. */ |
| 3949 | bgp_info_add (rn, new); |
| 3950 | |
| 3951 | /* route_node_get lock */ |
| 3952 | bgp_unlock_node (rn); |
| 3953 | |
| 3954 | /* Process change. */ |
| 3955 | bgp_process (bgp, rn, afi, safi); |
| 3956 | |
| 3957 | /* Unintern original. */ |
| 3958 | aspath_unintern (&attr.aspath); |
| 3959 | bgp_attr_extra_free (&attr); |
| 3960 | } |
| 3961 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3962 | /* Configure static BGP network. When user don't run zebra, static |
| 3963 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3964 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3965 | 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] | 3966 | afi_t afi, safi_t safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3967 | { |
| 3968 | int ret; |
| 3969 | struct prefix p; |
| 3970 | struct bgp_static *bgp_static; |
| 3971 | struct bgp_node *rn; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3972 | u_char need_update = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3973 | |
| 3974 | /* Convert IP prefix string to struct prefix. */ |
| 3975 | ret = str2prefix (ip_str, &p); |
| 3976 | if (! ret) |
| 3977 | { |
| 3978 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3979 | return CMD_WARNING; |
| 3980 | } |
| 3981 | #ifdef HAVE_IPV6 |
| 3982 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3983 | { |
| 3984 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3985 | VTY_NEWLINE); |
| 3986 | return CMD_WARNING; |
| 3987 | } |
| 3988 | #endif /* HAVE_IPV6 */ |
| 3989 | |
| 3990 | apply_mask (&p); |
| 3991 | |
| 3992 | /* Set BGP static route configuration. */ |
| 3993 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3994 | |
| 3995 | if (rn->info) |
| 3996 | { |
| 3997 | /* Configuration change. */ |
| 3998 | bgp_static = rn->info; |
| 3999 | |
| 4000 | /* Check previous routes are installed into BGP. */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4001 | if (bgp_static->valid && bgp_static->backdoor != backdoor) |
| 4002 | need_update = 1; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4003 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4004 | bgp_static->backdoor = backdoor; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4005 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4006 | if (rmap) |
| 4007 | { |
| 4008 | if (bgp_static->rmap.name) |
| 4009 | free (bgp_static->rmap.name); |
| 4010 | bgp_static->rmap.name = strdup (rmap); |
| 4011 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 4012 | } |
| 4013 | else |
| 4014 | { |
| 4015 | if (bgp_static->rmap.name) |
| 4016 | free (bgp_static->rmap.name); |
| 4017 | bgp_static->rmap.name = NULL; |
| 4018 | bgp_static->rmap.map = NULL; |
| 4019 | bgp_static->valid = 0; |
| 4020 | } |
| 4021 | bgp_unlock_node (rn); |
| 4022 | } |
| 4023 | else |
| 4024 | { |
| 4025 | /* New configuration. */ |
| 4026 | bgp_static = bgp_static_new (); |
| 4027 | bgp_static->backdoor = backdoor; |
| 4028 | bgp_static->valid = 0; |
| 4029 | bgp_static->igpmetric = 0; |
| 4030 | bgp_static->igpnexthop.s_addr = 0; |
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 | if (rmap) |
| 4033 | { |
| 4034 | if (bgp_static->rmap.name) |
| 4035 | free (bgp_static->rmap.name); |
| 4036 | bgp_static->rmap.name = strdup (rmap); |
| 4037 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 4038 | } |
| 4039 | rn->info = bgp_static; |
| 4040 | } |
| 4041 | |
| 4042 | /* If BGP scan is not enabled, we should install this route here. */ |
| 4043 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 4044 | { |
| 4045 | bgp_static->valid = 1; |
| 4046 | |
| 4047 | if (need_update) |
| 4048 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 4049 | |
| 4050 | if (! bgp_static->backdoor) |
| 4051 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 4052 | } |
| 4053 | |
| 4054 | return CMD_SUCCESS; |
| 4055 | } |
| 4056 | |
| 4057 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4058 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4059 | 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] | 4060 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4061 | { |
| 4062 | int ret; |
| 4063 | struct prefix p; |
| 4064 | struct bgp_static *bgp_static; |
| 4065 | struct bgp_node *rn; |
| 4066 | |
| 4067 | /* Convert IP prefix string to struct prefix. */ |
| 4068 | ret = str2prefix (ip_str, &p); |
| 4069 | if (! ret) |
| 4070 | { |
| 4071 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4072 | return CMD_WARNING; |
| 4073 | } |
| 4074 | #ifdef HAVE_IPV6 |
| 4075 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 4076 | { |
| 4077 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 4078 | VTY_NEWLINE); |
| 4079 | return CMD_WARNING; |
| 4080 | } |
| 4081 | #endif /* HAVE_IPV6 */ |
| 4082 | |
| 4083 | apply_mask (&p); |
| 4084 | |
| 4085 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 4086 | if (! rn) |
| 4087 | { |
| 4088 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 4089 | VTY_NEWLINE); |
| 4090 | return CMD_WARNING; |
| 4091 | } |
| 4092 | |
| 4093 | bgp_static = rn->info; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4094 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4095 | /* Update BGP RIB. */ |
| 4096 | if (! bgp_static->backdoor) |
| 4097 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 4098 | |
| 4099 | /* Clear configuration. */ |
| 4100 | bgp_static_free (bgp_static); |
| 4101 | rn->info = NULL; |
| 4102 | bgp_unlock_node (rn); |
| 4103 | bgp_unlock_node (rn); |
| 4104 | |
| 4105 | return CMD_SUCCESS; |
| 4106 | } |
| 4107 | |
| 4108 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 4109 | instance. */ |
| 4110 | void |
| 4111 | bgp_static_delete (struct bgp *bgp) |
| 4112 | { |
| 4113 | afi_t afi; |
| 4114 | safi_t safi; |
| 4115 | struct bgp_node *rn; |
| 4116 | struct bgp_node *rm; |
| 4117 | struct bgp_table *table; |
| 4118 | struct bgp_static *bgp_static; |
| 4119 | |
| 4120 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 4121 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 4122 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 4123 | if (rn->info != NULL) |
| 4124 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4125 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4126 | { |
| 4127 | table = rn->info; |
| 4128 | |
| 4129 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 4130 | { |
| 4131 | bgp_static = rn->info; |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4132 | bgp_static_withdraw_safi (bgp, &rm->p, |
| 4133 | AFI_IP, safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4134 | (struct prefix_rd *)&rn->p, |
| 4135 | bgp_static->tag); |
| 4136 | bgp_static_free (bgp_static); |
| 4137 | rn->info = NULL; |
| 4138 | bgp_unlock_node (rn); |
| 4139 | } |
| 4140 | } |
| 4141 | else |
| 4142 | { |
| 4143 | bgp_static = rn->info; |
| 4144 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 4145 | bgp_static_free (bgp_static); |
| 4146 | rn->info = NULL; |
| 4147 | bgp_unlock_node (rn); |
| 4148 | } |
| 4149 | } |
| 4150 | } |
| 4151 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4152 | /* |
| 4153 | * gpz 110624 |
| 4154 | * Currently this is used to set static routes for VPN and ENCAP. |
| 4155 | * I think it can probably be factored with bgp_static_set. |
| 4156 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4157 | int |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4158 | bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str, |
| 4159 | const char *rd_str, const char *tag_str, |
| 4160 | const char *rmap_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4161 | { |
| 4162 | int ret; |
| 4163 | struct prefix p; |
| 4164 | struct prefix_rd prd; |
| 4165 | struct bgp *bgp; |
| 4166 | struct bgp_node *prn; |
| 4167 | struct bgp_node *rn; |
| 4168 | struct bgp_table *table; |
| 4169 | struct bgp_static *bgp_static; |
| 4170 | u_char tag[3]; |
| 4171 | |
| 4172 | bgp = vty->index; |
| 4173 | |
| 4174 | ret = str2prefix (ip_str, &p); |
| 4175 | if (! ret) |
| 4176 | { |
| 4177 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4178 | return CMD_WARNING; |
| 4179 | } |
| 4180 | apply_mask (&p); |
| 4181 | |
| 4182 | ret = str2prefix_rd (rd_str, &prd); |
| 4183 | if (! ret) |
| 4184 | { |
| 4185 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4186 | return CMD_WARNING; |
| 4187 | } |
| 4188 | |
| 4189 | ret = str2tag (tag_str, tag); |
| 4190 | if (! ret) |
| 4191 | { |
| 4192 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4193 | return CMD_WARNING; |
| 4194 | } |
| 4195 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4196 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4197 | (struct prefix *)&prd); |
| 4198 | if (prn->info == NULL) |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4199 | prn->info = bgp_table_init (AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4200 | else |
| 4201 | bgp_unlock_node (prn); |
| 4202 | table = prn->info; |
| 4203 | |
| 4204 | rn = bgp_node_get (table, &p); |
| 4205 | |
| 4206 | if (rn->info) |
| 4207 | { |
| 4208 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 4209 | bgp_unlock_node (rn); |
| 4210 | } |
| 4211 | else |
| 4212 | { |
| 4213 | /* New configuration. */ |
| 4214 | bgp_static = bgp_static_new (); |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4215 | bgp_static->backdoor = 0; |
| 4216 | bgp_static->valid = 0; |
| 4217 | bgp_static->igpmetric = 0; |
| 4218 | bgp_static->igpnexthop.s_addr = 0; |
| 4219 | memcpy(bgp_static->tag, tag, 3); |
| 4220 | bgp_static->prd = prd; |
| 4221 | |
| 4222 | if (rmap_str) |
| 4223 | { |
| 4224 | if (bgp_static->rmap.name) |
| 4225 | free (bgp_static->rmap.name); |
| 4226 | bgp_static->rmap.name = strdup (rmap_str); |
| 4227 | bgp_static->rmap.map = route_map_lookup_by_name (rmap_str); |
| 4228 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4229 | rn->info = bgp_static; |
| 4230 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4231 | bgp_static->valid = 1; |
| 4232 | bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4233 | } |
| 4234 | |
| 4235 | return CMD_SUCCESS; |
| 4236 | } |
| 4237 | |
| 4238 | /* Configure static BGP network. */ |
| 4239 | int |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4240 | bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str, |
| 4241 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4242 | { |
| 4243 | int ret; |
| 4244 | struct bgp *bgp; |
| 4245 | struct prefix p; |
| 4246 | struct prefix_rd prd; |
| 4247 | struct bgp_node *prn; |
| 4248 | struct bgp_node *rn; |
| 4249 | struct bgp_table *table; |
| 4250 | struct bgp_static *bgp_static; |
| 4251 | u_char tag[3]; |
| 4252 | |
| 4253 | bgp = vty->index; |
| 4254 | |
| 4255 | /* Convert IP prefix string to struct prefix. */ |
| 4256 | ret = str2prefix (ip_str, &p); |
| 4257 | if (! ret) |
| 4258 | { |
| 4259 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 4260 | return CMD_WARNING; |
| 4261 | } |
| 4262 | apply_mask (&p); |
| 4263 | |
| 4264 | ret = str2prefix_rd (rd_str, &prd); |
| 4265 | if (! ret) |
| 4266 | { |
| 4267 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 4268 | return CMD_WARNING; |
| 4269 | } |
| 4270 | |
| 4271 | ret = str2tag (tag_str, tag); |
| 4272 | if (! ret) |
| 4273 | { |
| 4274 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 4275 | return CMD_WARNING; |
| 4276 | } |
| 4277 | |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4278 | prn = bgp_node_get (bgp->route[AFI_IP][safi], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4279 | (struct prefix *)&prd); |
| 4280 | if (prn->info == NULL) |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4281 | prn->info = bgp_table_init (AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4282 | else |
| 4283 | bgp_unlock_node (prn); |
| 4284 | table = prn->info; |
| 4285 | |
| 4286 | rn = bgp_node_lookup (table, &p); |
| 4287 | |
| 4288 | if (rn) |
| 4289 | { |
Lou Berger | a76d9ca | 2016-01-12 13:41:53 -0500 | [diff] [blame] | 4290 | bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4291 | |
| 4292 | bgp_static = rn->info; |
| 4293 | bgp_static_free (bgp_static); |
| 4294 | rn->info = NULL; |
| 4295 | bgp_unlock_node (rn); |
| 4296 | bgp_unlock_node (rn); |
| 4297 | } |
| 4298 | else |
| 4299 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 4300 | |
| 4301 | return CMD_SUCCESS; |
| 4302 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4303 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4304 | DEFUN (bgp_network, |
| 4305 | bgp_network_cmd, |
| 4306 | "network A.B.C.D/M", |
| 4307 | "Specify a network to announce via BGP\n" |
| 4308 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4309 | { |
| 4310 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4311 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4312 | } |
| 4313 | |
| 4314 | DEFUN (bgp_network_route_map, |
| 4315 | bgp_network_route_map_cmd, |
| 4316 | "network A.B.C.D/M route-map WORD", |
| 4317 | "Specify a network to announce via BGP\n" |
| 4318 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4319 | "Route-map to modify the attributes\n" |
| 4320 | "Name of the route map\n") |
| 4321 | { |
| 4322 | return bgp_static_set (vty, vty->index, argv[0], |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4323 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4324 | } |
| 4325 | |
| 4326 | DEFUN (bgp_network_backdoor, |
| 4327 | bgp_network_backdoor_cmd, |
| 4328 | "network A.B.C.D/M backdoor", |
| 4329 | "Specify a network to announce via BGP\n" |
| 4330 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4331 | "Specify a BGP backdoor route\n") |
| 4332 | { |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4333 | 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] | 4334 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4335 | } |
| 4336 | |
| 4337 | DEFUN (bgp_network_mask, |
| 4338 | bgp_network_mask_cmd, |
| 4339 | "network A.B.C.D mask A.B.C.D", |
| 4340 | "Specify a network to announce via BGP\n" |
| 4341 | "Network number\n" |
| 4342 | "Network mask\n" |
| 4343 | "Network mask\n") |
| 4344 | { |
| 4345 | int ret; |
| 4346 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4347 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4348 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4349 | if (! ret) |
| 4350 | { |
| 4351 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4352 | return CMD_WARNING; |
| 4353 | } |
| 4354 | |
| 4355 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4356 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4357 | } |
| 4358 | |
| 4359 | DEFUN (bgp_network_mask_route_map, |
| 4360 | bgp_network_mask_route_map_cmd, |
| 4361 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 4362 | "Specify a network to announce via BGP\n" |
| 4363 | "Network number\n" |
| 4364 | "Network mask\n" |
| 4365 | "Network mask\n" |
| 4366 | "Route-map to modify the attributes\n" |
| 4367 | "Name of the route map\n") |
| 4368 | { |
| 4369 | int ret; |
| 4370 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4371 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4372 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4373 | if (! ret) |
| 4374 | { |
| 4375 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4376 | return CMD_WARNING; |
| 4377 | } |
| 4378 | |
| 4379 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4380 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4381 | } |
| 4382 | |
| 4383 | DEFUN (bgp_network_mask_backdoor, |
| 4384 | bgp_network_mask_backdoor_cmd, |
| 4385 | "network A.B.C.D mask A.B.C.D backdoor", |
| 4386 | "Specify a network to announce via BGP\n" |
| 4387 | "Network number\n" |
| 4388 | "Network mask\n" |
| 4389 | "Network mask\n" |
| 4390 | "Specify a BGP backdoor route\n") |
| 4391 | { |
| 4392 | int ret; |
| 4393 | char prefix_str[BUFSIZ]; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4394 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4395 | ret = netmask_str2prefix_str (argv[0], argv[1], 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 (bgp_network_mask_natural, |
| 4407 | bgp_network_mask_natural_cmd, |
| 4408 | "network A.B.C.D", |
| 4409 | "Specify a network to announce via BGP\n" |
| 4410 | "Network number\n") |
| 4411 | { |
| 4412 | int ret; |
| 4413 | char prefix_str[BUFSIZ]; |
| 4414 | |
| 4415 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4416 | if (! ret) |
| 4417 | { |
| 4418 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4419 | return CMD_WARNING; |
| 4420 | } |
| 4421 | |
| 4422 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4423 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4424 | } |
| 4425 | |
| 4426 | DEFUN (bgp_network_mask_natural_route_map, |
| 4427 | bgp_network_mask_natural_route_map_cmd, |
| 4428 | "network A.B.C.D route-map WORD", |
| 4429 | "Specify a network to announce via BGP\n" |
| 4430 | "Network number\n" |
| 4431 | "Route-map to modify the attributes\n" |
| 4432 | "Name of the route map\n") |
| 4433 | { |
| 4434 | int ret; |
| 4435 | char prefix_str[BUFSIZ]; |
| 4436 | |
| 4437 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4438 | if (! ret) |
| 4439 | { |
| 4440 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4441 | return CMD_WARNING; |
| 4442 | } |
| 4443 | |
| 4444 | return bgp_static_set (vty, vty->index, prefix_str, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4445 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4446 | } |
| 4447 | |
| 4448 | DEFUN (bgp_network_mask_natural_backdoor, |
| 4449 | bgp_network_mask_natural_backdoor_cmd, |
| 4450 | "network A.B.C.D backdoor", |
| 4451 | "Specify a network to announce via BGP\n" |
| 4452 | "Network number\n" |
| 4453 | "Specify a BGP backdoor route\n") |
| 4454 | { |
| 4455 | int ret; |
| 4456 | char prefix_str[BUFSIZ]; |
| 4457 | |
| 4458 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4459 | if (! ret) |
| 4460 | { |
| 4461 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4462 | return CMD_WARNING; |
| 4463 | } |
| 4464 | |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 4465 | 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] | 4466 | NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4467 | } |
| 4468 | |
| 4469 | DEFUN (no_bgp_network, |
| 4470 | no_bgp_network_cmd, |
| 4471 | "no network A.B.C.D/M", |
| 4472 | NO_STR |
| 4473 | "Specify a network to announce via BGP\n" |
| 4474 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 4475 | { |
| 4476 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 4477 | bgp_node_safi (vty)); |
| 4478 | } |
| 4479 | |
| 4480 | ALIAS (no_bgp_network, |
| 4481 | no_bgp_network_route_map_cmd, |
| 4482 | "no network A.B.C.D/M route-map WORD", |
| 4483 | NO_STR |
| 4484 | "Specify a network to announce via BGP\n" |
| 4485 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4486 | "Route-map to modify the attributes\n" |
| 4487 | "Name of the route map\n") |
| 4488 | |
| 4489 | ALIAS (no_bgp_network, |
| 4490 | no_bgp_network_backdoor_cmd, |
| 4491 | "no network A.B.C.D/M backdoor", |
| 4492 | NO_STR |
| 4493 | "Specify a network to announce via BGP\n" |
| 4494 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4495 | "Specify a BGP backdoor route\n") |
| 4496 | |
| 4497 | DEFUN (no_bgp_network_mask, |
| 4498 | no_bgp_network_mask_cmd, |
| 4499 | "no network A.B.C.D mask A.B.C.D", |
| 4500 | NO_STR |
| 4501 | "Specify a network to announce via BGP\n" |
| 4502 | "Network number\n" |
| 4503 | "Network mask\n" |
| 4504 | "Network mask\n") |
| 4505 | { |
| 4506 | int ret; |
| 4507 | char prefix_str[BUFSIZ]; |
| 4508 | |
| 4509 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4510 | if (! ret) |
| 4511 | { |
| 4512 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4513 | return CMD_WARNING; |
| 4514 | } |
| 4515 | |
| 4516 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4517 | bgp_node_safi (vty)); |
| 4518 | } |
| 4519 | |
| 4520 | ALIAS (no_bgp_network_mask, |
| 4521 | no_bgp_network_mask_route_map_cmd, |
| 4522 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 4523 | NO_STR |
| 4524 | "Specify a network to announce via BGP\n" |
| 4525 | "Network number\n" |
| 4526 | "Network mask\n" |
| 4527 | "Network mask\n" |
| 4528 | "Route-map to modify the attributes\n" |
| 4529 | "Name of the route map\n") |
| 4530 | |
| 4531 | ALIAS (no_bgp_network_mask, |
| 4532 | no_bgp_network_mask_backdoor_cmd, |
| 4533 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 4534 | NO_STR |
| 4535 | "Specify a network to announce via BGP\n" |
| 4536 | "Network number\n" |
| 4537 | "Network mask\n" |
| 4538 | "Network mask\n" |
| 4539 | "Specify a BGP backdoor route\n") |
| 4540 | |
| 4541 | DEFUN (no_bgp_network_mask_natural, |
| 4542 | no_bgp_network_mask_natural_cmd, |
| 4543 | "no network A.B.C.D", |
| 4544 | NO_STR |
| 4545 | "Specify a network to announce via BGP\n" |
| 4546 | "Network number\n") |
| 4547 | { |
| 4548 | int ret; |
| 4549 | char prefix_str[BUFSIZ]; |
| 4550 | |
| 4551 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 4552 | if (! ret) |
| 4553 | { |
| 4554 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4555 | return CMD_WARNING; |
| 4556 | } |
| 4557 | |
| 4558 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 4559 | bgp_node_safi (vty)); |
| 4560 | } |
| 4561 | |
| 4562 | ALIAS (no_bgp_network_mask_natural, |
| 4563 | no_bgp_network_mask_natural_route_map_cmd, |
| 4564 | "no network A.B.C.D route-map WORD", |
| 4565 | NO_STR |
| 4566 | "Specify a network to announce via BGP\n" |
| 4567 | "Network number\n" |
| 4568 | "Route-map to modify the attributes\n" |
| 4569 | "Name of the route map\n") |
| 4570 | |
| 4571 | ALIAS (no_bgp_network_mask_natural, |
| 4572 | no_bgp_network_mask_natural_backdoor_cmd, |
| 4573 | "no network A.B.C.D backdoor", |
| 4574 | NO_STR |
| 4575 | "Specify a network to announce via BGP\n" |
| 4576 | "Network number\n" |
| 4577 | "Specify a BGP backdoor route\n") |
| 4578 | |
| 4579 | #ifdef HAVE_IPV6 |
| 4580 | DEFUN (ipv6_bgp_network, |
| 4581 | ipv6_bgp_network_cmd, |
| 4582 | "network X:X::X:X/M", |
| 4583 | "Specify a network to announce via BGP\n" |
| 4584 | "IPv6 prefix <network>/<length>\n") |
| 4585 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4586 | 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] | 4587 | NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4588 | } |
| 4589 | |
| 4590 | DEFUN (ipv6_bgp_network_route_map, |
| 4591 | ipv6_bgp_network_route_map_cmd, |
| 4592 | "network X:X::X:X/M route-map WORD", |
| 4593 | "Specify a network to announce via BGP\n" |
| 4594 | "IPv6 prefix <network>/<length>\n" |
| 4595 | "Route-map to modify the attributes\n" |
| 4596 | "Name of the route map\n") |
| 4597 | { |
| 4598 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4599 | bgp_node_safi (vty), argv[1], 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4600 | } |
| 4601 | |
| 4602 | DEFUN (no_ipv6_bgp_network, |
| 4603 | no_ipv6_bgp_network_cmd, |
| 4604 | "no network X:X::X:X/M", |
| 4605 | NO_STR |
| 4606 | "Specify a network to announce via BGP\n" |
| 4607 | "IPv6 prefix <network>/<length>\n") |
| 4608 | { |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 4609 | 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] | 4610 | } |
| 4611 | |
| 4612 | ALIAS (no_ipv6_bgp_network, |
| 4613 | no_ipv6_bgp_network_route_map_cmd, |
| 4614 | "no network X:X::X:X/M route-map WORD", |
| 4615 | NO_STR |
| 4616 | "Specify a network to announce via BGP\n" |
| 4617 | "IPv6 prefix <network>/<length>\n" |
| 4618 | "Route-map to modify the attributes\n" |
| 4619 | "Name of the route map\n") |
| 4620 | |
| 4621 | ALIAS (ipv6_bgp_network, |
| 4622 | old_ipv6_bgp_network_cmd, |
| 4623 | "ipv6 bgp network X:X::X:X/M", |
| 4624 | IPV6_STR |
| 4625 | BGP_STR |
| 4626 | "Specify a network to announce via BGP\n" |
| 4627 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4628 | |
| 4629 | ALIAS (no_ipv6_bgp_network, |
| 4630 | old_no_ipv6_bgp_network_cmd, |
| 4631 | "no ipv6 bgp network X:X::X:X/M", |
| 4632 | NO_STR |
| 4633 | IPV6_STR |
| 4634 | BGP_STR |
| 4635 | "Specify a network to announce via BGP\n" |
| 4636 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 4637 | #endif /* HAVE_IPV6 */ |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4638 | |
| 4639 | /* stubs for removed AS-Pathlimit commands, kept for config compatibility */ |
| 4640 | ALIAS_DEPRECATED (bgp_network, |
| 4641 | bgp_network_ttl_cmd, |
| 4642 | "network A.B.C.D/M pathlimit <0-255>", |
| 4643 | "Specify a network to announce via BGP\n" |
| 4644 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4645 | "AS-Path hopcount limit attribute\n" |
| 4646 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4647 | ALIAS_DEPRECATED (bgp_network_backdoor, |
| 4648 | bgp_network_backdoor_ttl_cmd, |
| 4649 | "network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4650 | "Specify a network to announce via BGP\n" |
| 4651 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4652 | "Specify a BGP backdoor route\n" |
| 4653 | "AS-Path hopcount limit attribute\n" |
| 4654 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4655 | ALIAS_DEPRECATED (bgp_network_mask, |
| 4656 | bgp_network_mask_ttl_cmd, |
| 4657 | "network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4658 | "Specify a network to announce via BGP\n" |
| 4659 | "Network number\n" |
| 4660 | "Network mask\n" |
| 4661 | "Network mask\n" |
| 4662 | "AS-Path hopcount limit attribute\n" |
| 4663 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4664 | ALIAS_DEPRECATED (bgp_network_mask_backdoor, |
| 4665 | bgp_network_mask_backdoor_ttl_cmd, |
| 4666 | "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4667 | "Specify a network to announce via BGP\n" |
| 4668 | "Network number\n" |
| 4669 | "Network mask\n" |
| 4670 | "Network mask\n" |
| 4671 | "Specify a BGP backdoor route\n" |
| 4672 | "AS-Path hopcount limit attribute\n" |
| 4673 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4674 | ALIAS_DEPRECATED (bgp_network_mask_natural, |
| 4675 | bgp_network_mask_natural_ttl_cmd, |
| 4676 | "network A.B.C.D pathlimit <0-255>", |
| 4677 | "Specify a network to announce via BGP\n" |
| 4678 | "Network number\n" |
| 4679 | "AS-Path hopcount limit attribute\n" |
| 4680 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4681 | ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor, |
| 4682 | bgp_network_mask_natural_backdoor_ttl_cmd, |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 4683 | "network A.B.C.D backdoor pathlimit <1-255>", |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4684 | "Specify a network to announce via BGP\n" |
| 4685 | "Network number\n" |
| 4686 | "Specify a BGP backdoor route\n" |
| 4687 | "AS-Path hopcount limit attribute\n" |
| 4688 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4689 | ALIAS_DEPRECATED (no_bgp_network, |
| 4690 | no_bgp_network_ttl_cmd, |
| 4691 | "no network A.B.C.D/M pathlimit <0-255>", |
| 4692 | NO_STR |
| 4693 | "Specify a network to announce via BGP\n" |
| 4694 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4695 | "AS-Path hopcount limit attribute\n" |
| 4696 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4697 | ALIAS_DEPRECATED (no_bgp_network, |
| 4698 | no_bgp_network_backdoor_ttl_cmd, |
| 4699 | "no network A.B.C.D/M backdoor pathlimit <0-255>", |
| 4700 | NO_STR |
| 4701 | "Specify a network to announce via BGP\n" |
| 4702 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 4703 | "Specify a BGP backdoor route\n" |
| 4704 | "AS-Path hopcount limit attribute\n" |
| 4705 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4706 | ALIAS_DEPRECATED (no_bgp_network, |
| 4707 | no_bgp_network_mask_ttl_cmd, |
| 4708 | "no network A.B.C.D mask A.B.C.D pathlimit <0-255>", |
| 4709 | NO_STR |
| 4710 | "Specify a network to announce via BGP\n" |
| 4711 | "Network number\n" |
| 4712 | "Network mask\n" |
| 4713 | "Network mask\n" |
| 4714 | "AS-Path hopcount limit attribute\n" |
| 4715 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4716 | ALIAS_DEPRECATED (no_bgp_network_mask, |
| 4717 | no_bgp_network_mask_backdoor_ttl_cmd, |
| 4718 | "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>", |
| 4719 | NO_STR |
| 4720 | "Specify a network to announce via BGP\n" |
| 4721 | "Network number\n" |
| 4722 | "Network mask\n" |
| 4723 | "Network mask\n" |
| 4724 | "Specify a BGP backdoor route\n" |
| 4725 | "AS-Path hopcount limit attribute\n" |
| 4726 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4727 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4728 | no_bgp_network_mask_natural_ttl_cmd, |
| 4729 | "no network A.B.C.D pathlimit <0-255>", |
| 4730 | NO_STR |
| 4731 | "Specify a network to announce via BGP\n" |
| 4732 | "Network number\n" |
| 4733 | "AS-Path hopcount limit attribute\n" |
| 4734 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4735 | ALIAS_DEPRECATED (no_bgp_network_mask_natural, |
| 4736 | no_bgp_network_mask_natural_backdoor_ttl_cmd, |
| 4737 | "no network A.B.C.D backdoor pathlimit <0-255>", |
| 4738 | NO_STR |
| 4739 | "Specify a network to announce via BGP\n" |
| 4740 | "Network number\n" |
| 4741 | "Specify a BGP backdoor route\n" |
| 4742 | "AS-Path hopcount limit attribute\n" |
| 4743 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4744 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 4745 | ALIAS_DEPRECATED (ipv6_bgp_network, |
| 4746 | ipv6_bgp_network_ttl_cmd, |
| 4747 | "network X:X::X:X/M pathlimit <0-255>", |
| 4748 | "Specify a network to announce via BGP\n" |
| 4749 | "IPv6 prefix <network>/<length>\n" |
| 4750 | "AS-Path hopcount limit attribute\n" |
| 4751 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
| 4752 | ALIAS_DEPRECATED (no_ipv6_bgp_network, |
| 4753 | no_ipv6_bgp_network_ttl_cmd, |
| 4754 | "no network X:X::X:X/M pathlimit <0-255>", |
| 4755 | NO_STR |
| 4756 | "Specify a network to announce via BGP\n" |
| 4757 | "IPv6 prefix <network>/<length>\n" |
| 4758 | "AS-Path hopcount limit attribute\n" |
| 4759 | "AS-Pathlimit TTL, in number of AS-Path hops\n") |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 4760 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4761 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4762 | /* Aggreagete address: |
| 4763 | |
| 4764 | advertise-map Set condition to advertise attribute |
| 4765 | as-set Generate AS set path information |
| 4766 | attribute-map Set attributes of aggregate |
| 4767 | route-map Set parameters of aggregate |
| 4768 | summary-only Filter more specific routes from updates |
| 4769 | suppress-map Conditionally filter more specific routes from updates |
| 4770 | <cr> |
| 4771 | */ |
| 4772 | struct bgp_aggregate |
| 4773 | { |
| 4774 | /* Summary-only flag. */ |
| 4775 | u_char summary_only; |
| 4776 | |
| 4777 | /* AS set generation. */ |
| 4778 | u_char as_set; |
| 4779 | |
| 4780 | /* Route-map for aggregated route. */ |
| 4781 | struct route_map *map; |
| 4782 | |
| 4783 | /* Suppress-count. */ |
| 4784 | unsigned long count; |
| 4785 | |
| 4786 | /* SAFI configuration. */ |
| 4787 | safi_t safi; |
| 4788 | }; |
| 4789 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4790 | static struct bgp_aggregate * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 4791 | bgp_aggregate_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4792 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 4793 | return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4794 | } |
| 4795 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4796 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4797 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 4798 | { |
| 4799 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 4800 | } |
| 4801 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4802 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4803 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 4804 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 4805 | struct bgp_aggregate *aggregate) |
| 4806 | { |
| 4807 | struct bgp_table *table; |
| 4808 | struct bgp_node *top; |
| 4809 | struct bgp_node *rn; |
| 4810 | u_char origin; |
| 4811 | struct aspath *aspath = NULL; |
| 4812 | struct aspath *asmerge = NULL; |
| 4813 | struct community *community = NULL; |
| 4814 | struct community *commerge = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4815 | struct bgp_info *ri; |
| 4816 | struct bgp_info *new; |
| 4817 | int first = 1; |
| 4818 | unsigned long match = 0; |
| 4819 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4820 | /* ORIGIN attribute: If at least one route among routes that are |
| 4821 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4822 | aggregated route must have the ORIGIN attribute with the value |
| 4823 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4824 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4825 | route must have the origin attribute with the value EGP. In all |
| 4826 | other case the value of the ORIGIN attribute of the aggregated |
| 4827 | route is INTERNAL. */ |
| 4828 | origin = BGP_ORIGIN_IGP; |
| 4829 | |
| 4830 | table = bgp->rib[afi][safi]; |
| 4831 | |
| 4832 | top = bgp_node_get (table, p); |
| 4833 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4834 | if (rn->p.prefixlen > p->prefixlen) |
| 4835 | { |
| 4836 | match = 0; |
| 4837 | |
| 4838 | for (ri = rn->info; ri; ri = ri->next) |
| 4839 | { |
| 4840 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4841 | continue; |
| 4842 | |
| 4843 | if (del && ri == del) |
| 4844 | continue; |
| 4845 | |
| 4846 | if (! rinew && first) |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 4847 | first = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4848 | |
| 4849 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4850 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4851 | || ri->attr->med != med) |
| 4852 | { |
| 4853 | if (aspath) |
| 4854 | aspath_free (aspath); |
| 4855 | if (community) |
| 4856 | community_free (community); |
| 4857 | bgp_unlock_node (rn); |
| 4858 | bgp_unlock_node (top); |
| 4859 | return; |
| 4860 | } |
| 4861 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4862 | |
| 4863 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4864 | { |
| 4865 | if (aggregate->summary_only) |
| 4866 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4867 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 4868 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4869 | match++; |
| 4870 | } |
| 4871 | |
| 4872 | aggregate->count++; |
| 4873 | |
| 4874 | if (aggregate->as_set) |
| 4875 | { |
| 4876 | if (origin < ri->attr->origin) |
| 4877 | origin = ri->attr->origin; |
| 4878 | |
| 4879 | if (aspath) |
| 4880 | { |
| 4881 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4882 | aspath_free (aspath); |
| 4883 | aspath = asmerge; |
| 4884 | } |
| 4885 | else |
| 4886 | aspath = aspath_dup (ri->attr->aspath); |
| 4887 | |
| 4888 | if (ri->attr->community) |
| 4889 | { |
| 4890 | if (community) |
| 4891 | { |
| 4892 | commerge = community_merge (community, |
| 4893 | ri->attr->community); |
| 4894 | community = community_uniq_sort (commerge); |
| 4895 | community_free (commerge); |
| 4896 | } |
| 4897 | else |
| 4898 | community = community_dup (ri->attr->community); |
| 4899 | } |
| 4900 | } |
| 4901 | } |
| 4902 | } |
| 4903 | if (match) |
| 4904 | bgp_process (bgp, rn, afi, safi); |
| 4905 | } |
| 4906 | bgp_unlock_node (top); |
| 4907 | |
| 4908 | if (rinew) |
| 4909 | { |
| 4910 | aggregate->count++; |
| 4911 | |
| 4912 | if (aggregate->summary_only) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 4913 | (bgp_info_extra_get (rinew))->suppress++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4914 | |
| 4915 | if (aggregate->as_set) |
| 4916 | { |
| 4917 | if (origin < rinew->attr->origin) |
| 4918 | origin = rinew->attr->origin; |
| 4919 | |
| 4920 | if (aspath) |
| 4921 | { |
| 4922 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4923 | aspath_free (aspath); |
| 4924 | aspath = asmerge; |
| 4925 | } |
| 4926 | else |
| 4927 | aspath = aspath_dup (rinew->attr->aspath); |
| 4928 | |
| 4929 | if (rinew->attr->community) |
| 4930 | { |
| 4931 | if (community) |
| 4932 | { |
| 4933 | commerge = community_merge (community, |
| 4934 | rinew->attr->community); |
| 4935 | community = community_uniq_sort (commerge); |
| 4936 | community_free (commerge); |
| 4937 | } |
| 4938 | else |
| 4939 | community = community_dup (rinew->attr->community); |
| 4940 | } |
| 4941 | } |
| 4942 | } |
| 4943 | |
| 4944 | if (aggregate->count > 0) |
| 4945 | { |
| 4946 | rn = bgp_node_get (table, p); |
| 4947 | new = bgp_info_new (); |
| 4948 | new->type = ZEBRA_ROUTE_BGP; |
| 4949 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4950 | new->peer = bgp->peer_self; |
| 4951 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4952 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 4953 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4954 | |
| 4955 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4956 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4957 | bgp_process (bgp, rn, afi, safi); |
| 4958 | } |
| 4959 | else |
| 4960 | { |
| 4961 | if (aspath) |
| 4962 | aspath_free (aspath); |
| 4963 | if (community) |
| 4964 | community_free (community); |
| 4965 | } |
| 4966 | } |
| 4967 | |
| 4968 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4969 | struct bgp_aggregate *); |
| 4970 | |
| 4971 | void |
| 4972 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4973 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4974 | { |
| 4975 | struct bgp_node *child; |
| 4976 | struct bgp_node *rn; |
| 4977 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4978 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4979 | |
| 4980 | /* MPLS-VPN aggregation is not yet supported. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 4981 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4982 | return; |
| 4983 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4984 | table = bgp->aggregate[afi][safi]; |
| 4985 | |
| 4986 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4987 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 4988 | return; |
| 4989 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4990 | if (p->prefixlen == 0) |
| 4991 | return; |
| 4992 | |
| 4993 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4994 | return; |
| 4995 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 4996 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4997 | |
| 4998 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 4999 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5000 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 5001 | { |
| 5002 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 5003 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5004 | } |
| 5005 | bgp_unlock_node (child); |
| 5006 | } |
| 5007 | |
| 5008 | void |
| 5009 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 5010 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 5011 | { |
| 5012 | struct bgp_node *child; |
| 5013 | struct bgp_node *rn; |
| 5014 | struct bgp_aggregate *aggregate; |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 5015 | struct bgp_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5016 | |
| 5017 | /* MPLS-VPN aggregation is not yet supported. */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5018 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5019 | return; |
| 5020 | |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 5021 | table = bgp->aggregate[afi][safi]; |
| 5022 | |
| 5023 | /* No aggregates configured. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 5024 | if (bgp_table_top_nolock (table) == NULL) |
Jorge Boncompte [DTI2] | f018db8 | 2012-05-07 16:53:10 +0000 | [diff] [blame] | 5025 | return; |
| 5026 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5027 | if (p->prefixlen == 0) |
| 5028 | return; |
| 5029 | |
Jorge Boncompte [DTI2] | bb782fb | 2012-06-20 16:34:01 +0200 | [diff] [blame] | 5030 | child = bgp_node_get (table, p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5031 | |
| 5032 | /* Aggregate address configuration check. */ |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 5033 | for (rn = child; rn; rn = bgp_node_parent_nolock (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5034 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 5035 | { |
| 5036 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 5037 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5038 | } |
| 5039 | bgp_unlock_node (child); |
| 5040 | } |
| 5041 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5042 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5043 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 5044 | struct bgp_aggregate *aggregate) |
| 5045 | { |
| 5046 | struct bgp_table *table; |
| 5047 | struct bgp_node *top; |
| 5048 | struct bgp_node *rn; |
| 5049 | struct bgp_info *new; |
| 5050 | struct bgp_info *ri; |
| 5051 | unsigned long match; |
| 5052 | u_char origin = BGP_ORIGIN_IGP; |
| 5053 | struct aspath *aspath = NULL; |
| 5054 | struct aspath *asmerge = NULL; |
| 5055 | struct community *community = NULL; |
| 5056 | struct community *commerge = NULL; |
| 5057 | |
| 5058 | table = bgp->rib[afi][safi]; |
| 5059 | |
| 5060 | /* Sanity check. */ |
| 5061 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 5062 | return; |
| 5063 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 5064 | return; |
| 5065 | |
| 5066 | /* If routes exists below this node, generate aggregate routes. */ |
| 5067 | top = bgp_node_get (table, p); |
| 5068 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 5069 | if (rn->p.prefixlen > p->prefixlen) |
| 5070 | { |
| 5071 | match = 0; |
| 5072 | |
| 5073 | for (ri = rn->info; ri; ri = ri->next) |
| 5074 | { |
| 5075 | if (BGP_INFO_HOLDDOWN (ri)) |
| 5076 | continue; |
| 5077 | |
| 5078 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 5079 | { |
| 5080 | /* summary-only aggregate route suppress aggregated |
| 5081 | route announcement. */ |
| 5082 | if (aggregate->summary_only) |
| 5083 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5084 | (bgp_info_extra_get (ri))->suppress++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5085 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5086 | match++; |
| 5087 | } |
| 5088 | /* as-set aggregate route generate origin, as path, |
| 5089 | community aggregation. */ |
| 5090 | if (aggregate->as_set) |
| 5091 | { |
| 5092 | if (origin < ri->attr->origin) |
| 5093 | origin = ri->attr->origin; |
| 5094 | |
| 5095 | if (aspath) |
| 5096 | { |
| 5097 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 5098 | aspath_free (aspath); |
| 5099 | aspath = asmerge; |
| 5100 | } |
| 5101 | else |
| 5102 | aspath = aspath_dup (ri->attr->aspath); |
| 5103 | |
| 5104 | if (ri->attr->community) |
| 5105 | { |
| 5106 | if (community) |
| 5107 | { |
| 5108 | commerge = community_merge (community, |
| 5109 | ri->attr->community); |
| 5110 | community = community_uniq_sort (commerge); |
| 5111 | community_free (commerge); |
| 5112 | } |
| 5113 | else |
| 5114 | community = community_dup (ri->attr->community); |
| 5115 | } |
| 5116 | } |
| 5117 | aggregate->count++; |
| 5118 | } |
| 5119 | } |
| 5120 | |
| 5121 | /* If this node is suppressed, process the change. */ |
| 5122 | if (match) |
| 5123 | bgp_process (bgp, rn, afi, safi); |
| 5124 | } |
| 5125 | bgp_unlock_node (top); |
| 5126 | |
| 5127 | /* Add aggregate route to BGP table. */ |
| 5128 | if (aggregate->count) |
| 5129 | { |
| 5130 | rn = bgp_node_get (table, p); |
| 5131 | |
| 5132 | new = bgp_info_new (); |
| 5133 | new->type = ZEBRA_ROUTE_BGP; |
| 5134 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 5135 | new->peer = bgp->peer_self; |
| 5136 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5137 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5138 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5139 | |
| 5140 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5141 | bgp_unlock_node (rn); |
| 5142 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5143 | /* Process change. */ |
| 5144 | bgp_process (bgp, rn, afi, safi); |
| 5145 | } |
Denil Vira | e2a9258 | 2015-08-11 13:34:59 -0700 | [diff] [blame] | 5146 | else |
| 5147 | { |
| 5148 | if (aspath) |
| 5149 | aspath_free (aspath); |
| 5150 | if (community) |
| 5151 | community_free (community); |
| 5152 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5153 | } |
| 5154 | |
| 5155 | void |
| 5156 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 5157 | safi_t safi, struct bgp_aggregate *aggregate) |
| 5158 | { |
| 5159 | struct bgp_table *table; |
| 5160 | struct bgp_node *top; |
| 5161 | struct bgp_node *rn; |
| 5162 | struct bgp_info *ri; |
| 5163 | unsigned long match; |
| 5164 | |
| 5165 | table = bgp->rib[afi][safi]; |
| 5166 | |
| 5167 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 5168 | return; |
| 5169 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 5170 | return; |
| 5171 | |
| 5172 | /* If routes exists below this node, generate aggregate routes. */ |
| 5173 | top = bgp_node_get (table, p); |
| 5174 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 5175 | if (rn->p.prefixlen > p->prefixlen) |
| 5176 | { |
| 5177 | match = 0; |
| 5178 | |
| 5179 | for (ri = rn->info; ri; ri = ri->next) |
| 5180 | { |
| 5181 | if (BGP_INFO_HOLDDOWN (ri)) |
| 5182 | continue; |
| 5183 | |
| 5184 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 5185 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5186 | if (aggregate->summary_only && ri->extra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5187 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5188 | ri->extra->suppress--; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5189 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5190 | if (ri->extra->suppress == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5191 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5192 | bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5193 | match++; |
| 5194 | } |
| 5195 | } |
| 5196 | aggregate->count--; |
| 5197 | } |
| 5198 | } |
| 5199 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5200 | /* If this node was suppressed, process the change. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5201 | if (match) |
| 5202 | bgp_process (bgp, rn, afi, safi); |
| 5203 | } |
| 5204 | bgp_unlock_node (top); |
| 5205 | |
| 5206 | /* Delete aggregate route from BGP table. */ |
| 5207 | rn = bgp_node_get (table, p); |
| 5208 | |
| 5209 | for (ri = rn->info; ri; ri = ri->next) |
| 5210 | if (ri->peer == bgp->peer_self |
| 5211 | && ri->type == ZEBRA_ROUTE_BGP |
| 5212 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 5213 | break; |
| 5214 | |
| 5215 | /* Withdraw static BGP route from routing table. */ |
| 5216 | if (ri) |
| 5217 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5218 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5219 | bgp_process (bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5220 | } |
| 5221 | |
| 5222 | /* Unlock bgp_node_lookup. */ |
| 5223 | bgp_unlock_node (rn); |
| 5224 | } |
| 5225 | |
| 5226 | /* Aggregate route attribute. */ |
| 5227 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 5228 | #define AGGREGATE_AS_SET 1 |
| 5229 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5230 | static int |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5231 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 5232 | afi_t afi, safi_t safi) |
| 5233 | { |
| 5234 | int ret; |
| 5235 | struct prefix p; |
| 5236 | struct bgp_node *rn; |
| 5237 | struct bgp *bgp; |
| 5238 | struct bgp_aggregate *aggregate; |
| 5239 | |
| 5240 | /* Convert string to prefix structure. */ |
| 5241 | ret = str2prefix (prefix_str, &p); |
| 5242 | if (!ret) |
| 5243 | { |
| 5244 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5245 | return CMD_WARNING; |
| 5246 | } |
| 5247 | apply_mask (&p); |
| 5248 | |
| 5249 | /* Get BGP structure. */ |
| 5250 | bgp = vty->index; |
| 5251 | |
| 5252 | /* Old configuration check. */ |
| 5253 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 5254 | if (! rn) |
| 5255 | { |
| 5256 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 5257 | VTY_NEWLINE); |
| 5258 | return CMD_WARNING; |
| 5259 | } |
| 5260 | |
| 5261 | aggregate = rn->info; |
| 5262 | if (aggregate->safi & SAFI_UNICAST) |
| 5263 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5264 | if (aggregate->safi & SAFI_MULTICAST) |
| 5265 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5266 | |
| 5267 | /* Unlock aggregate address configuration. */ |
| 5268 | rn->info = NULL; |
| 5269 | bgp_aggregate_free (aggregate); |
| 5270 | bgp_unlock_node (rn); |
| 5271 | bgp_unlock_node (rn); |
| 5272 | |
| 5273 | return CMD_SUCCESS; |
| 5274 | } |
| 5275 | |
| 5276 | static int |
| 5277 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5278 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5279 | u_char summary_only, u_char as_set) |
| 5280 | { |
| 5281 | int ret; |
| 5282 | struct prefix p; |
| 5283 | struct bgp_node *rn; |
| 5284 | struct bgp *bgp; |
| 5285 | struct bgp_aggregate *aggregate; |
| 5286 | |
| 5287 | /* Convert string to prefix structure. */ |
| 5288 | ret = str2prefix (prefix_str, &p); |
| 5289 | if (!ret) |
| 5290 | { |
| 5291 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 5292 | return CMD_WARNING; |
| 5293 | } |
| 5294 | apply_mask (&p); |
| 5295 | |
| 5296 | /* Get BGP structure. */ |
| 5297 | bgp = vty->index; |
| 5298 | |
| 5299 | /* Old configuration check. */ |
| 5300 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 5301 | |
| 5302 | if (rn->info) |
| 5303 | { |
| 5304 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5305 | /* try to remove the old entry */ |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5306 | ret = bgp_aggregate_unset (vty, prefix_str, afi, safi); |
| 5307 | if (ret) |
| 5308 | { |
Robert Bays | 368473f | 2010-08-05 10:26:29 -0700 | [diff] [blame] | 5309 | vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE); |
| 5310 | bgp_unlock_node (rn); |
Robert Bays | f6269b4 | 2010-08-05 10:26:28 -0700 | [diff] [blame] | 5311 | return CMD_WARNING; |
| 5312 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5313 | } |
| 5314 | |
| 5315 | /* Make aggregate address structure. */ |
| 5316 | aggregate = bgp_aggregate_new (); |
| 5317 | aggregate->summary_only = summary_only; |
| 5318 | aggregate->as_set = as_set; |
| 5319 | aggregate->safi = safi; |
| 5320 | rn->info = aggregate; |
| 5321 | |
| 5322 | /* Aggregate address insert into BGP routing table. */ |
| 5323 | if (safi & SAFI_UNICAST) |
| 5324 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 5325 | if (safi & SAFI_MULTICAST) |
| 5326 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 5327 | |
| 5328 | return CMD_SUCCESS; |
| 5329 | } |
| 5330 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5331 | DEFUN (aggregate_address, |
| 5332 | aggregate_address_cmd, |
| 5333 | "aggregate-address A.B.C.D/M", |
| 5334 | "Configure BGP aggregate entries\n" |
| 5335 | "Aggregate prefix\n") |
| 5336 | { |
| 5337 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 5338 | } |
| 5339 | |
| 5340 | DEFUN (aggregate_address_mask, |
| 5341 | aggregate_address_mask_cmd, |
| 5342 | "aggregate-address A.B.C.D A.B.C.D", |
| 5343 | "Configure BGP aggregate entries\n" |
| 5344 | "Aggregate address\n" |
| 5345 | "Aggregate mask\n") |
| 5346 | { |
| 5347 | int ret; |
| 5348 | char prefix_str[BUFSIZ]; |
| 5349 | |
| 5350 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5351 | |
| 5352 | if (! ret) |
| 5353 | { |
| 5354 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5355 | return CMD_WARNING; |
| 5356 | } |
| 5357 | |
| 5358 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5359 | 0, 0); |
| 5360 | } |
| 5361 | |
| 5362 | DEFUN (aggregate_address_summary_only, |
| 5363 | aggregate_address_summary_only_cmd, |
| 5364 | "aggregate-address A.B.C.D/M summary-only", |
| 5365 | "Configure BGP aggregate entries\n" |
| 5366 | "Aggregate prefix\n" |
| 5367 | "Filter more specific routes from updates\n") |
| 5368 | { |
| 5369 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5370 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5371 | } |
| 5372 | |
| 5373 | DEFUN (aggregate_address_mask_summary_only, |
| 5374 | aggregate_address_mask_summary_only_cmd, |
| 5375 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5376 | "Configure BGP aggregate entries\n" |
| 5377 | "Aggregate address\n" |
| 5378 | "Aggregate mask\n" |
| 5379 | "Filter more specific routes from updates\n") |
| 5380 | { |
| 5381 | int ret; |
| 5382 | char prefix_str[BUFSIZ]; |
| 5383 | |
| 5384 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5385 | |
| 5386 | if (! ret) |
| 5387 | { |
| 5388 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5389 | return CMD_WARNING; |
| 5390 | } |
| 5391 | |
| 5392 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5393 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5394 | } |
| 5395 | |
| 5396 | DEFUN (aggregate_address_as_set, |
| 5397 | aggregate_address_as_set_cmd, |
| 5398 | "aggregate-address A.B.C.D/M as-set", |
| 5399 | "Configure BGP aggregate entries\n" |
| 5400 | "Aggregate prefix\n" |
| 5401 | "Generate AS set path information\n") |
| 5402 | { |
| 5403 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5404 | 0, AGGREGATE_AS_SET); |
| 5405 | } |
| 5406 | |
| 5407 | DEFUN (aggregate_address_mask_as_set, |
| 5408 | aggregate_address_mask_as_set_cmd, |
| 5409 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 5410 | "Configure BGP aggregate entries\n" |
| 5411 | "Aggregate address\n" |
| 5412 | "Aggregate mask\n" |
| 5413 | "Generate AS set path information\n") |
| 5414 | { |
| 5415 | int ret; |
| 5416 | char prefix_str[BUFSIZ]; |
| 5417 | |
| 5418 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5419 | |
| 5420 | if (! ret) |
| 5421 | { |
| 5422 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5423 | return CMD_WARNING; |
| 5424 | } |
| 5425 | |
| 5426 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5427 | 0, AGGREGATE_AS_SET); |
| 5428 | } |
| 5429 | |
| 5430 | |
| 5431 | DEFUN (aggregate_address_as_set_summary, |
| 5432 | aggregate_address_as_set_summary_cmd, |
| 5433 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 5434 | "Configure BGP aggregate entries\n" |
| 5435 | "Aggregate prefix\n" |
| 5436 | "Generate AS set path information\n" |
| 5437 | "Filter more specific routes from updates\n") |
| 5438 | { |
| 5439 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 5440 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5441 | } |
| 5442 | |
| 5443 | ALIAS (aggregate_address_as_set_summary, |
| 5444 | aggregate_address_summary_as_set_cmd, |
| 5445 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 5446 | "Configure BGP aggregate entries\n" |
| 5447 | "Aggregate prefix\n" |
| 5448 | "Filter more specific routes from updates\n" |
| 5449 | "Generate AS set path information\n") |
| 5450 | |
| 5451 | DEFUN (aggregate_address_mask_as_set_summary, |
| 5452 | aggregate_address_mask_as_set_summary_cmd, |
| 5453 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5454 | "Configure BGP aggregate entries\n" |
| 5455 | "Aggregate address\n" |
| 5456 | "Aggregate mask\n" |
| 5457 | "Generate AS set path information\n" |
| 5458 | "Filter more specific routes from updates\n") |
| 5459 | { |
| 5460 | int ret; |
| 5461 | char prefix_str[BUFSIZ]; |
| 5462 | |
| 5463 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5464 | |
| 5465 | if (! ret) |
| 5466 | { |
| 5467 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5468 | return CMD_WARNING; |
| 5469 | } |
| 5470 | |
| 5471 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 5472 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 5473 | } |
| 5474 | |
| 5475 | ALIAS (aggregate_address_mask_as_set_summary, |
| 5476 | aggregate_address_mask_summary_as_set_cmd, |
| 5477 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5478 | "Configure BGP aggregate entries\n" |
| 5479 | "Aggregate address\n" |
| 5480 | "Aggregate mask\n" |
| 5481 | "Filter more specific routes from updates\n" |
| 5482 | "Generate AS set path information\n") |
| 5483 | |
| 5484 | DEFUN (no_aggregate_address, |
| 5485 | no_aggregate_address_cmd, |
| 5486 | "no aggregate-address A.B.C.D/M", |
| 5487 | NO_STR |
| 5488 | "Configure BGP aggregate entries\n" |
| 5489 | "Aggregate prefix\n") |
| 5490 | { |
| 5491 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 5492 | } |
| 5493 | |
| 5494 | ALIAS (no_aggregate_address, |
| 5495 | no_aggregate_address_summary_only_cmd, |
| 5496 | "no aggregate-address A.B.C.D/M summary-only", |
| 5497 | NO_STR |
| 5498 | "Configure BGP aggregate entries\n" |
| 5499 | "Aggregate prefix\n" |
| 5500 | "Filter more specific routes from updates\n") |
| 5501 | |
| 5502 | ALIAS (no_aggregate_address, |
| 5503 | no_aggregate_address_as_set_cmd, |
| 5504 | "no aggregate-address A.B.C.D/M as-set", |
| 5505 | NO_STR |
| 5506 | "Configure BGP aggregate entries\n" |
| 5507 | "Aggregate prefix\n" |
| 5508 | "Generate AS set path information\n") |
| 5509 | |
| 5510 | ALIAS (no_aggregate_address, |
| 5511 | no_aggregate_address_as_set_summary_cmd, |
| 5512 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 5513 | NO_STR |
| 5514 | "Configure BGP aggregate entries\n" |
| 5515 | "Aggregate prefix\n" |
| 5516 | "Generate AS set path information\n" |
| 5517 | "Filter more specific routes from updates\n") |
| 5518 | |
| 5519 | ALIAS (no_aggregate_address, |
| 5520 | no_aggregate_address_summary_as_set_cmd, |
| 5521 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 5522 | NO_STR |
| 5523 | "Configure BGP aggregate entries\n" |
| 5524 | "Aggregate prefix\n" |
| 5525 | "Filter more specific routes from updates\n" |
| 5526 | "Generate AS set path information\n") |
| 5527 | |
| 5528 | DEFUN (no_aggregate_address_mask, |
| 5529 | no_aggregate_address_mask_cmd, |
| 5530 | "no aggregate-address A.B.C.D A.B.C.D", |
| 5531 | NO_STR |
| 5532 | "Configure BGP aggregate entries\n" |
| 5533 | "Aggregate address\n" |
| 5534 | "Aggregate mask\n") |
| 5535 | { |
| 5536 | int ret; |
| 5537 | char prefix_str[BUFSIZ]; |
| 5538 | |
| 5539 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 5540 | |
| 5541 | if (! ret) |
| 5542 | { |
| 5543 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 5544 | return CMD_WARNING; |
| 5545 | } |
| 5546 | |
| 5547 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 5548 | } |
| 5549 | |
| 5550 | ALIAS (no_aggregate_address_mask, |
| 5551 | no_aggregate_address_mask_summary_only_cmd, |
| 5552 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 5553 | NO_STR |
| 5554 | "Configure BGP aggregate entries\n" |
| 5555 | "Aggregate address\n" |
| 5556 | "Aggregate mask\n" |
| 5557 | "Filter more specific routes from updates\n") |
| 5558 | |
| 5559 | ALIAS (no_aggregate_address_mask, |
| 5560 | no_aggregate_address_mask_as_set_cmd, |
| 5561 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 5562 | NO_STR |
| 5563 | "Configure BGP aggregate entries\n" |
| 5564 | "Aggregate address\n" |
| 5565 | "Aggregate mask\n" |
| 5566 | "Generate AS set path information\n") |
| 5567 | |
| 5568 | ALIAS (no_aggregate_address_mask, |
| 5569 | no_aggregate_address_mask_as_set_summary_cmd, |
| 5570 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 5571 | NO_STR |
| 5572 | "Configure BGP aggregate entries\n" |
| 5573 | "Aggregate address\n" |
| 5574 | "Aggregate mask\n" |
| 5575 | "Generate AS set path information\n" |
| 5576 | "Filter more specific routes from updates\n") |
| 5577 | |
| 5578 | ALIAS (no_aggregate_address_mask, |
| 5579 | no_aggregate_address_mask_summary_as_set_cmd, |
| 5580 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 5581 | NO_STR |
| 5582 | "Configure BGP aggregate entries\n" |
| 5583 | "Aggregate address\n" |
| 5584 | "Aggregate mask\n" |
| 5585 | "Filter more specific routes from updates\n" |
| 5586 | "Generate AS set path information\n") |
| 5587 | |
| 5588 | #ifdef HAVE_IPV6 |
| 5589 | DEFUN (ipv6_aggregate_address, |
| 5590 | ipv6_aggregate_address_cmd, |
| 5591 | "aggregate-address X:X::X:X/M", |
| 5592 | "Configure BGP aggregate entries\n" |
| 5593 | "Aggregate prefix\n") |
| 5594 | { |
| 5595 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 5596 | } |
| 5597 | |
| 5598 | DEFUN (ipv6_aggregate_address_summary_only, |
| 5599 | ipv6_aggregate_address_summary_only_cmd, |
| 5600 | "aggregate-address X:X::X:X/M summary-only", |
| 5601 | "Configure BGP aggregate entries\n" |
| 5602 | "Aggregate prefix\n" |
| 5603 | "Filter more specific routes from updates\n") |
| 5604 | { |
| 5605 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 5606 | AGGREGATE_SUMMARY_ONLY, 0); |
| 5607 | } |
| 5608 | |
| 5609 | DEFUN (no_ipv6_aggregate_address, |
| 5610 | no_ipv6_aggregate_address_cmd, |
| 5611 | "no aggregate-address X:X::X:X/M", |
| 5612 | NO_STR |
| 5613 | "Configure BGP aggregate entries\n" |
| 5614 | "Aggregate prefix\n") |
| 5615 | { |
| 5616 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5617 | } |
| 5618 | |
| 5619 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 5620 | no_ipv6_aggregate_address_summary_only_cmd, |
| 5621 | "no aggregate-address X:X::X:X/M summary-only", |
| 5622 | NO_STR |
| 5623 | "Configure BGP aggregate entries\n" |
| 5624 | "Aggregate prefix\n" |
| 5625 | "Filter more specific routes from updates\n") |
| 5626 | { |
| 5627 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 5628 | } |
| 5629 | |
| 5630 | ALIAS (ipv6_aggregate_address, |
| 5631 | old_ipv6_aggregate_address_cmd, |
| 5632 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 5633 | IPV6_STR |
| 5634 | BGP_STR |
| 5635 | "Configure BGP aggregate entries\n" |
| 5636 | "Aggregate prefix\n") |
| 5637 | |
| 5638 | ALIAS (ipv6_aggregate_address_summary_only, |
| 5639 | old_ipv6_aggregate_address_summary_only_cmd, |
| 5640 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5641 | IPV6_STR |
| 5642 | BGP_STR |
| 5643 | "Configure BGP aggregate entries\n" |
| 5644 | "Aggregate prefix\n" |
| 5645 | "Filter more specific routes from updates\n") |
| 5646 | |
| 5647 | ALIAS (no_ipv6_aggregate_address, |
| 5648 | old_no_ipv6_aggregate_address_cmd, |
| 5649 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 5650 | NO_STR |
| 5651 | IPV6_STR |
| 5652 | BGP_STR |
| 5653 | "Configure BGP aggregate entries\n" |
| 5654 | "Aggregate prefix\n") |
| 5655 | |
| 5656 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 5657 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 5658 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 5659 | NO_STR |
| 5660 | IPV6_STR |
| 5661 | BGP_STR |
| 5662 | "Configure BGP aggregate entries\n" |
| 5663 | "Aggregate prefix\n" |
| 5664 | "Filter more specific routes from updates\n") |
| 5665 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5666 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5667 | /* Redistribute route treatment. */ |
| 5668 | void |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5669 | bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop, |
| 5670 | const struct in6_addr *nexthop6, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5671 | u_int32_t metric, u_char type) |
| 5672 | { |
| 5673 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5674 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5675 | struct bgp_info *new; |
| 5676 | struct bgp_info *bi; |
| 5677 | struct bgp_info info; |
| 5678 | struct bgp_node *bn; |
Jorge Boncompte [DTI2] | e16a413 | 2012-05-07 16:52:57 +0000 | [diff] [blame] | 5679 | struct attr attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5680 | struct attr *new_attr; |
| 5681 | afi_t afi; |
| 5682 | int ret; |
| 5683 | |
| 5684 | /* Make default attribute. */ |
| 5685 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 5686 | if (nexthop) |
| 5687 | attr.nexthop = *nexthop; |
| 5688 | |
Stephen Hemminger | f04a80a | 2011-12-06 14:51:10 +0400 | [diff] [blame] | 5689 | #ifdef HAVE_IPV6 |
| 5690 | if (nexthop6) |
| 5691 | { |
| 5692 | struct attr_extra *extra = bgp_attr_extra_get(&attr); |
| 5693 | extra->mp_nexthop_global = *nexthop6; |
| 5694 | extra->mp_nexthop_len = 16; |
| 5695 | } |
| 5696 | #endif |
| 5697 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5698 | attr.med = metric; |
| 5699 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 5700 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5701 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5702 | { |
| 5703 | afi = family2afi (p->family); |
| 5704 | |
| 5705 | if (bgp->redist[afi][type]) |
| 5706 | { |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5707 | struct attr attr_new; |
| 5708 | struct attr_extra extra_new; |
| 5709 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5710 | /* Copy attribute for modification. */ |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5711 | attr_new.extra = &extra_new; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5712 | bgp_attr_dup (&attr_new, &attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5713 | |
| 5714 | if (bgp->redist_metric_flag[afi][type]) |
| 5715 | attr_new.med = bgp->redist_metric[afi][type]; |
| 5716 | |
| 5717 | /* Apply route-map. */ |
Daniel Walton | 1994dc8 | 2015-09-17 10:15:59 -0400 | [diff] [blame] | 5718 | if (bgp->rmap[afi][type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5719 | { |
| 5720 | info.peer = bgp->peer_self; |
| 5721 | info.attr = &attr_new; |
| 5722 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5723 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 5724 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5725 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 5726 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5727 | |
| 5728 | bgp->peer_self->rmap_type = 0; |
| 5729 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5730 | if (ret == RMAP_DENYMATCH) |
| 5731 | { |
| 5732 | /* Free uninterned attribute. */ |
| 5733 | bgp_attr_flush (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5734 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5735 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5736 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5737 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5738 | bgp_redistribute_delete (p, type); |
| 5739 | return; |
| 5740 | } |
| 5741 | } |
| 5742 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5743 | bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], |
| 5744 | afi, SAFI_UNICAST, p, NULL); |
| 5745 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5746 | new_attr = bgp_attr_intern (&attr_new); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 5747 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5748 | for (bi = bn->info; bi; bi = bi->next) |
| 5749 | if (bi->peer == bgp->peer_self |
| 5750 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 5751 | break; |
| 5752 | |
| 5753 | if (bi) |
| 5754 | { |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5755 | if (attrhash_cmp (bi->attr, new_attr) && |
| 5756 | !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5757 | { |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5758 | bgp_attr_unintern (&new_attr); |
| 5759 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5760 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5761 | bgp_unlock_node (bn); |
| 5762 | return; |
| 5763 | } |
| 5764 | else |
| 5765 | { |
| 5766 | /* The attribute is changed. */ |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5767 | bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5768 | |
| 5769 | /* Rewrite BGP route information. */ |
Andrew J. Schorr | 8d45210 | 2006-11-28 19:50:46 +0000 | [diff] [blame] | 5770 | if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) |
| 5771 | bgp_info_restore(bn, bi); |
| 5772 | else |
| 5773 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5774 | bgp_attr_unintern (&bi->attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5775 | bi->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5776 | bi->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5777 | |
| 5778 | /* Process change. */ |
| 5779 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 5780 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5781 | bgp_unlock_node (bn); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5782 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5783 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5784 | return; |
| 5785 | } |
| 5786 | } |
| 5787 | |
| 5788 | new = bgp_info_new (); |
| 5789 | new->type = type; |
| 5790 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 5791 | new->peer = bgp->peer_self; |
| 5792 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 5793 | new->attr = new_attr; |
Stephen Hemminger | 6595788 | 2010-01-15 16:22:10 +0300 | [diff] [blame] | 5794 | new->uptime = bgp_clock (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5795 | |
| 5796 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 5797 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 5798 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5799 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 5800 | } |
| 5801 | } |
| 5802 | |
| 5803 | /* Unintern original. */ |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 5804 | aspath_unintern (&attr.aspath); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5805 | bgp_attr_extra_free (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5806 | } |
| 5807 | |
| 5808 | void |
| 5809 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 5810 | { |
| 5811 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5812 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5813 | afi_t afi; |
| 5814 | struct bgp_node *rn; |
| 5815 | struct bgp_info *ri; |
| 5816 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5817 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5818 | { |
| 5819 | afi = family2afi (p->family); |
| 5820 | |
| 5821 | if (bgp->redist[afi][type]) |
| 5822 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5823 | 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] | 5824 | |
| 5825 | for (ri = rn->info; ri; ri = ri->next) |
| 5826 | if (ri->peer == bgp->peer_self |
| 5827 | && ri->type == type) |
| 5828 | break; |
| 5829 | |
| 5830 | if (ri) |
| 5831 | { |
| 5832 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5833 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5834 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5835 | } |
| 5836 | bgp_unlock_node (rn); |
| 5837 | } |
| 5838 | } |
| 5839 | } |
| 5840 | |
| 5841 | /* Withdraw specified route type's route. */ |
| 5842 | void |
| 5843 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 5844 | { |
| 5845 | struct bgp_node *rn; |
| 5846 | struct bgp_info *ri; |
| 5847 | struct bgp_table *table; |
| 5848 | |
| 5849 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5850 | |
| 5851 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5852 | { |
| 5853 | for (ri = rn->info; ri; ri = ri->next) |
| 5854 | if (ri->peer == bgp->peer_self |
| 5855 | && ri->type == type) |
| 5856 | break; |
| 5857 | |
| 5858 | if (ri) |
| 5859 | { |
| 5860 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5861 | bgp_info_delete (rn, ri); |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 5862 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5863 | } |
| 5864 | } |
| 5865 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 5866 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5867 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5868 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5869 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5870 | { |
| 5871 | int len; |
| 5872 | u_int32_t destination; |
| 5873 | char buf[BUFSIZ]; |
| 5874 | |
| 5875 | if (p->family == AF_INET) |
| 5876 | { |
| 5877 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5878 | destination = ntohl (p->u.prefix4.s_addr); |
| 5879 | |
| 5880 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5881 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5882 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5883 | || p->u.prefix4.s_addr == 0) |
| 5884 | { |
| 5885 | /* When mask is natural, mask is not displayed. */ |
| 5886 | } |
| 5887 | else |
| 5888 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5889 | } |
| 5890 | else |
| 5891 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5892 | p->prefixlen); |
| 5893 | |
| 5894 | len = 17 - len; |
| 5895 | if (len < 1) |
| 5896 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5897 | else |
| 5898 | vty_out (vty, "%*s", len, " "); |
| 5899 | } |
| 5900 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5901 | enum bgp_display_type |
| 5902 | { |
| 5903 | normal_list, |
| 5904 | }; |
| 5905 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5906 | /* Print the short form route status for a bgp_info */ |
| 5907 | static void |
| 5908 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5909 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5910 | /* Route status display. */ |
| 5911 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5912 | vty_out (vty, "R"); |
| 5913 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5914 | vty_out (vty, "S"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 5915 | else if (binfo->extra && binfo->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5916 | vty_out (vty, "s"); |
| 5917 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5918 | vty_out (vty, "*"); |
| 5919 | else |
| 5920 | vty_out (vty, " "); |
| 5921 | |
| 5922 | /* Selected */ |
| 5923 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5924 | vty_out (vty, "h"); |
| 5925 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5926 | vty_out (vty, "d"); |
| 5927 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5928 | vty_out (vty, ">"); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 5929 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH)) |
| 5930 | vty_out (vty, "="); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5931 | else |
| 5932 | vty_out (vty, " "); |
| 5933 | |
| 5934 | /* Internal route. */ |
| 5935 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5936 | vty_out (vty, "i"); |
| 5937 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5938 | vty_out (vty, " "); |
| 5939 | } |
| 5940 | |
| 5941 | /* called from terminal list command */ |
| 5942 | void |
| 5943 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5944 | struct bgp_info *binfo, int display, safi_t safi) |
| 5945 | { |
| 5946 | struct attr *attr; |
| 5947 | |
| 5948 | /* short status lead text */ |
| 5949 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5950 | |
| 5951 | /* print prefix and mask */ |
| 5952 | if (! display) |
| 5953 | route_vty_out_route (p, vty); |
| 5954 | else |
| 5955 | vty_out (vty, "%*s", 17, " "); |
| 5956 | |
| 5957 | /* Print attribute */ |
| 5958 | attr = binfo->attr; |
| 5959 | if (attr) |
| 5960 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5961 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5962 | /* |
| 5963 | * NEXTHOP start |
| 5964 | */ |
| 5965 | |
| 5966 | /* |
| 5967 | * For ENCAP routes, nexthop address family is not |
| 5968 | * neccessarily the same as the prefix address family. |
| 5969 | * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field |
| 5970 | */ |
| 5971 | if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) { |
| 5972 | if (attr->extra) { |
| 5973 | char buf[BUFSIZ]; |
| 5974 | int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len); |
| 5975 | |
| 5976 | switch (af) { |
| 5977 | case AF_INET: |
| 5978 | vty_out (vty, "%s", inet_ntop(af, |
| 5979 | &attr->extra->mp_nexthop_global_in, buf, BUFSIZ)); |
| 5980 | break; |
| 5981 | #if HAVE_IPV6 |
| 5982 | case AF_INET6: |
| 5983 | vty_out (vty, "%s", inet_ntop(af, |
| 5984 | &attr->extra->mp_nexthop_global, buf, BUFSIZ)); |
| 5985 | break; |
| 5986 | #endif |
| 5987 | |
| 5988 | default: |
| 5989 | vty_out(vty, "?"); |
| 5990 | } |
| 5991 | } else { |
| 5992 | vty_out(vty, "?"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5993 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 5994 | } else { |
| 5995 | |
| 5996 | if (p->family == AF_INET) |
| 5997 | { |
| 5998 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5999 | } |
| 6000 | #ifdef HAVE_IPV6 |
| 6001 | else if (p->family == AF_INET6) |
| 6002 | { |
| 6003 | int len; |
| 6004 | char buf[BUFSIZ]; |
| 6005 | |
| 6006 | len = vty_out (vty, "%s", |
| 6007 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6008 | buf, BUFSIZ)); |
| 6009 | len = 16 - len; |
| 6010 | if (len < 1) |
| 6011 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 6012 | else |
| 6013 | vty_out (vty, "%*s", len, " "); |
| 6014 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6015 | #endif /* HAVE_IPV6 */ |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6016 | else |
| 6017 | { |
| 6018 | vty_out(vty, "?"); |
| 6019 | } |
| 6020 | } |
| 6021 | |
| 6022 | /* |
| 6023 | * NEXTHOP end |
| 6024 | */ |
| 6025 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6026 | |
| 6027 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6028 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6029 | else |
| 6030 | vty_out (vty, " "); |
| 6031 | |
| 6032 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6033 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6034 | else |
| 6035 | vty_out (vty, " "); |
| 6036 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6037 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6038 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6039 | /* Print aspath */ |
| 6040 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6041 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6042 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6043 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6044 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6045 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6046 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6047 | } |
| 6048 | |
| 6049 | /* called from terminal list command */ |
| 6050 | void |
| 6051 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 6052 | struct attr *attr, safi_t safi) |
| 6053 | { |
| 6054 | /* Route status display. */ |
| 6055 | vty_out (vty, "*"); |
| 6056 | vty_out (vty, ">"); |
| 6057 | vty_out (vty, " "); |
| 6058 | |
| 6059 | /* print prefix and mask */ |
| 6060 | route_vty_out_route (p, vty); |
| 6061 | |
| 6062 | /* Print attribute */ |
| 6063 | if (attr) |
| 6064 | { |
| 6065 | if (p->family == AF_INET) |
| 6066 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6067 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6068 | vty_out (vty, "%-16s", |
| 6069 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6070 | else |
| 6071 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6072 | } |
| 6073 | #ifdef HAVE_IPV6 |
| 6074 | else if (p->family == AF_INET6) |
| 6075 | { |
| 6076 | int len; |
| 6077 | char buf[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6078 | |
| 6079 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6080 | |
| 6081 | len = vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6082 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6083 | buf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6084 | len = 16 - len; |
| 6085 | if (len < 1) |
| 6086 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 6087 | else |
| 6088 | vty_out (vty, "%*s", len, " "); |
| 6089 | } |
| 6090 | #endif /* HAVE_IPV6 */ |
| 6091 | |
| 6092 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6093 | vty_out (vty, "%10u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6094 | else |
| 6095 | vty_out (vty, " "); |
| 6096 | |
| 6097 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6098 | vty_out (vty, "%7u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6099 | else |
| 6100 | vty_out (vty, " "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6101 | |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6102 | vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6103 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6104 | /* Print aspath */ |
| 6105 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6106 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6107 | |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6108 | /* Print origin */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6109 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6110 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6111 | |
| 6112 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6113 | } |
| 6114 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6115 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6116 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 6117 | struct bgp_info *binfo, int display, safi_t safi) |
| 6118 | { |
| 6119 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6120 | u_int32_t label = 0; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6121 | |
| 6122 | if (!binfo->extra) |
| 6123 | return; |
| 6124 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6125 | /* short status lead text */ |
| 6126 | route_vty_short_status_out (vty, binfo); |
| 6127 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6128 | /* print prefix and mask */ |
| 6129 | if (! display) |
| 6130 | route_vty_out_route (p, vty); |
| 6131 | else |
| 6132 | vty_out (vty, "%*s", 17, " "); |
| 6133 | |
| 6134 | /* Print attribute */ |
| 6135 | attr = binfo->attr; |
| 6136 | if (attr) |
| 6137 | { |
| 6138 | if (p->family == AF_INET) |
| 6139 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6140 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6141 | vty_out (vty, "%-16s", |
| 6142 | inet_ntoa (attr->extra->mp_nexthop_global_in)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6143 | else |
| 6144 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 6145 | } |
| 6146 | #ifdef HAVE_IPV6 |
| 6147 | else if (p->family == AF_INET6) |
| 6148 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6149 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6150 | char buf[BUFSIZ]; |
| 6151 | char buf1[BUFSIZ]; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6152 | if (attr->extra->mp_nexthop_len == 16) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6153 | vty_out (vty, "%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6154 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6155 | buf, BUFSIZ)); |
| 6156 | else if (attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6157 | vty_out (vty, "%s(%s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6158 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 6159 | buf, BUFSIZ), |
| 6160 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 6161 | buf1, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6162 | |
| 6163 | } |
| 6164 | #endif /* HAVE_IPV6 */ |
| 6165 | } |
| 6166 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6167 | label = decode_label (binfo->extra->tag); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6168 | |
| 6169 | vty_out (vty, "notag/%d", label); |
| 6170 | |
| 6171 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6172 | } |
| 6173 | |
| 6174 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6175 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6176 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 6177 | struct bgp_info *binfo, int display, safi_t safi) |
| 6178 | { |
| 6179 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6180 | int len; |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6181 | char timebuf[BGP_UPTIME_LEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6182 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6183 | /* short status lead text */ |
| 6184 | route_vty_short_status_out (vty, binfo); |
| 6185 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6186 | /* print prefix and mask */ |
| 6187 | if (! display) |
| 6188 | route_vty_out_route (p, vty); |
| 6189 | else |
| 6190 | vty_out (vty, "%*s", 17, " "); |
| 6191 | |
| 6192 | len = vty_out (vty, "%s", binfo->peer->host); |
| 6193 | len = 17 - len; |
| 6194 | if (len < 1) |
| 6195 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 6196 | else |
| 6197 | vty_out (vty, "%*s", len, " "); |
| 6198 | |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6199 | 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] | 6200 | |
| 6201 | /* Print attribute */ |
| 6202 | attr = binfo->attr; |
| 6203 | if (attr) |
| 6204 | { |
| 6205 | /* Print aspath */ |
| 6206 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6207 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6208 | |
| 6209 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6210 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6211 | } |
| 6212 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6213 | } |
| 6214 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6215 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6216 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6217 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 6218 | struct bgp_info *binfo, int display, safi_t safi) |
| 6219 | { |
| 6220 | struct attr *attr; |
| 6221 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6222 | char timebuf[BGP_UPTIME_LEN]; |
| 6223 | int len; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6224 | |
| 6225 | if (!binfo->extra) |
| 6226 | return; |
| 6227 | |
| 6228 | bdi = binfo->extra->damp_info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6229 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6230 | /* short status lead text */ |
| 6231 | route_vty_short_status_out (vty, binfo); |
| 6232 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6233 | /* print prefix and mask */ |
| 6234 | if (! display) |
| 6235 | route_vty_out_route (p, vty); |
| 6236 | else |
| 6237 | vty_out (vty, "%*s", 17, " "); |
| 6238 | |
| 6239 | len = vty_out (vty, "%s", binfo->peer->host); |
| 6240 | len = 16 - len; |
| 6241 | if (len < 1) |
| 6242 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 6243 | else |
| 6244 | vty_out (vty, "%*s", len, " "); |
| 6245 | |
| 6246 | len = vty_out (vty, "%d", bdi->flap); |
| 6247 | len = 5 - len; |
| 6248 | if (len < 1) |
| 6249 | vty_out (vty, " "); |
| 6250 | else |
| 6251 | vty_out (vty, "%*s ", len, " "); |
| 6252 | |
| 6253 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 6254 | timebuf, BGP_UPTIME_LEN)); |
| 6255 | |
| 6256 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 6257 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
Chris Caputo | 50aef6f | 2009-06-23 06:06:49 +0000 | [diff] [blame] | 6258 | 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] | 6259 | else |
| 6260 | vty_out (vty, "%*s ", 8, " "); |
| 6261 | |
| 6262 | /* Print attribute */ |
| 6263 | attr = binfo->attr; |
| 6264 | if (attr) |
| 6265 | { |
| 6266 | /* Print aspath */ |
| 6267 | if (attr->aspath) |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6268 | aspath_print_vty (vty, "%s", attr->aspath, " "); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6269 | |
| 6270 | /* Print origin */ |
Paul Jakma | b2518c1 | 2006-05-12 23:48:40 +0000 | [diff] [blame] | 6271 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6272 | } |
| 6273 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6274 | } |
| 6275 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6276 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6277 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 6278 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 6279 | { |
| 6280 | char buf[INET6_ADDRSTRLEN]; |
| 6281 | char buf1[BUFSIZ]; |
| 6282 | struct attr *attr; |
| 6283 | int sockunion_vty_out (struct vty *, union sockunion *); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6284 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6285 | time_t tbuf; |
| 6286 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6287 | |
| 6288 | attr = binfo->attr; |
| 6289 | |
| 6290 | if (attr) |
| 6291 | { |
| 6292 | /* Line1 display AS-path, Aggregator */ |
| 6293 | if (attr->aspath) |
| 6294 | { |
| 6295 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 6296 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6297 | vty_out (vty, "Local"); |
| 6298 | else |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 6299 | aspath_print_vty (vty, "%s", attr->aspath, ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6300 | } |
| 6301 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 6302 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 6303 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6304 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 6305 | vty_out (vty, ", (stale)"); |
| 6306 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 6307 | vty_out (vty, ", (aggregated by %u %s)", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6308 | attr->extra->aggregator_as, |
| 6309 | inet_ntoa (attr->extra->aggregator_addr)); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6310 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 6311 | vty_out (vty, ", (Received from a RR-client)"); |
| 6312 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 6313 | vty_out (vty, ", (Received from a RS-client)"); |
| 6314 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6315 | vty_out (vty, ", (history entry)"); |
| 6316 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 6317 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6318 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6319 | |
| 6320 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 6321 | if (p->family == AF_INET) |
| 6322 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6323 | vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ? |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6324 | inet_ntoa (attr->extra->mp_nexthop_global_in) : |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6325 | inet_ntoa (attr->nexthop)); |
| 6326 | } |
| 6327 | #ifdef HAVE_IPV6 |
| 6328 | else |
| 6329 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6330 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6331 | vty_out (vty, " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6332 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6333 | buf, INET6_ADDRSTRLEN)); |
| 6334 | } |
| 6335 | #endif /* HAVE_IPV6 */ |
| 6336 | |
| 6337 | if (binfo->peer == bgp->peer_self) |
| 6338 | { |
| 6339 | vty_out (vty, " from %s ", |
| 6340 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 6341 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 6342 | } |
| 6343 | else |
| 6344 | { |
| 6345 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 6346 | vty_out (vty, " (inaccessible)"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6347 | else if (binfo->extra && binfo->extra->igpmetric) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 6348 | vty_out (vty, " (metric %u)", binfo->extra->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 6349 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6350 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6351 | vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6352 | else |
| 6353 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 6354 | } |
| 6355 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6356 | |
| 6357 | #ifdef HAVE_IPV6 |
| 6358 | /* display nexthop local */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6359 | if (attr->extra && attr->extra->mp_nexthop_len == 32) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6360 | { |
| 6361 | vty_out (vty, " (%s)%s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6362 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6363 | buf, INET6_ADDRSTRLEN), |
| 6364 | VTY_NEWLINE); |
| 6365 | } |
| 6366 | #endif /* HAVE_IPV6 */ |
| 6367 | |
| 6368 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 6369 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 6370 | |
| 6371 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6372 | vty_out (vty, ", metric %u", attr->med); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6373 | |
| 6374 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6375 | vty_out (vty, ", localpref %u", attr->local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6376 | else |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6377 | vty_out (vty, ", localpref %u", bgp->default_local_pref); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6378 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6379 | if (attr->extra && attr->extra->weight != 0) |
Wataru Tanitsu | c099baf | 2010-09-10 09:47:56 -0700 | [diff] [blame] | 6380 | vty_out (vty, ", weight %u", attr->extra->weight); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6381 | |
| 6382 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 6383 | vty_out (vty, ", valid"); |
| 6384 | |
| 6385 | if (binfo->peer != bgp->peer_self) |
| 6386 | { |
| 6387 | if (binfo->peer->as == binfo->peer->local_as) |
| 6388 | vty_out (vty, ", internal"); |
| 6389 | else |
| 6390 | vty_out (vty, ", %s", |
| 6391 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 6392 | } |
| 6393 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 6394 | vty_out (vty, ", aggregated, local"); |
| 6395 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 6396 | vty_out (vty, ", sourced"); |
| 6397 | else |
| 6398 | vty_out (vty, ", sourced, local"); |
| 6399 | |
| 6400 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 6401 | vty_out (vty, ", atomic-aggregate"); |
| 6402 | |
Josh Bailey | de8d5df | 2011-07-20 20:46:01 -0700 | [diff] [blame] | 6403 | if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) || |
| 6404 | (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) && |
| 6405 | bgp_info_mpath_count (binfo))) |
| 6406 | vty_out (vty, ", multipath"); |
| 6407 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6408 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 6409 | vty_out (vty, ", best"); |
| 6410 | |
| 6411 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6412 | |
| 6413 | /* Line 4 display Community */ |
| 6414 | if (attr->community) |
| 6415 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 6416 | VTY_NEWLINE); |
| 6417 | |
| 6418 | /* Line 5 display Extended-community */ |
| 6419 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6420 | vty_out (vty, " Extended Community: %s%s", |
| 6421 | attr->extra->ecommunity->str, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6422 | |
| 6423 | /* Line 6 display Originator, Cluster-id */ |
| 6424 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 6425 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 6426 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6427 | assert (attr->extra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6428 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6429 | vty_out (vty, " Originator: %s", |
| 6430 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6431 | |
| 6432 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 6433 | { |
| 6434 | int i; |
| 6435 | vty_out (vty, ", Cluster list: "); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6436 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
| 6437 | vty_out (vty, "%s ", |
| 6438 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6439 | } |
| 6440 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6441 | } |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 6442 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6443 | if (binfo->extra && binfo->extra->damp_info) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6444 | bgp_damp_info_vty (vty, binfo); |
| 6445 | |
| 6446 | /* Line 7 display Uptime */ |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6447 | #ifdef HAVE_CLOCK_MONOTONIC |
| 6448 | tbuf = time(NULL) - (bgp_clock() - binfo->uptime); |
Vladimir L Ivanov | 213b6cd | 2010-10-21 14:59:54 +0400 | [diff] [blame] | 6449 | vty_out (vty, " Last update: %s", ctime(&tbuf)); |
John Kemp | 30b0017 | 2011-03-18 17:52:18 +0300 | [diff] [blame] | 6450 | #else |
| 6451 | vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); |
| 6452 | #endif /* HAVE_CLOCK_MONOTONIC */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6453 | } |
| 6454 | vty_out (vty, "%s", VTY_NEWLINE); |
Boian Bonev | b366b51 | 2013-09-09 16:41:35 +0000 | [diff] [blame] | 6455 | } |
| 6456 | |
| 6457 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\ |
| 6458 | "h history, * valid, > best, = multipath,%s"\ |
| 6459 | " i internal, r RIB-failure, S Stale, R Removed%s" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6460 | #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] | 6461 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 6462 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 6463 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 6464 | |
| 6465 | enum bgp_show_type |
| 6466 | { |
| 6467 | bgp_show_type_normal, |
| 6468 | bgp_show_type_regexp, |
| 6469 | bgp_show_type_prefix_list, |
| 6470 | bgp_show_type_filter_list, |
| 6471 | bgp_show_type_route_map, |
| 6472 | bgp_show_type_neighbor, |
| 6473 | bgp_show_type_cidr_only, |
| 6474 | bgp_show_type_prefix_longer, |
| 6475 | bgp_show_type_community_all, |
| 6476 | bgp_show_type_community, |
| 6477 | bgp_show_type_community_exact, |
| 6478 | bgp_show_type_community_list, |
| 6479 | bgp_show_type_community_list_exact, |
| 6480 | bgp_show_type_flap_statistics, |
| 6481 | bgp_show_type_flap_address, |
| 6482 | bgp_show_type_flap_prefix, |
| 6483 | bgp_show_type_flap_cidr_only, |
| 6484 | bgp_show_type_flap_regexp, |
| 6485 | bgp_show_type_flap_filter_list, |
| 6486 | bgp_show_type_flap_prefix_list, |
| 6487 | bgp_show_type_flap_prefix_longer, |
| 6488 | bgp_show_type_flap_route_map, |
| 6489 | bgp_show_type_flap_neighbor, |
| 6490 | bgp_show_type_dampend_paths, |
| 6491 | bgp_show_type_damp_neighbor |
| 6492 | }; |
| 6493 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6494 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6495 | 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] | 6496 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6497 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6498 | struct bgp_info *ri; |
| 6499 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6500 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6501 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6502 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6503 | |
| 6504 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6505 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6506 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6507 | /* Start processing of routes. */ |
| 6508 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 6509 | if (rn->info != NULL) |
| 6510 | { |
| 6511 | display = 0; |
| 6512 | |
| 6513 | for (ri = rn->info; ri; ri = ri->next) |
| 6514 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6515 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6516 | || type == bgp_show_type_flap_address |
| 6517 | || type == bgp_show_type_flap_prefix |
| 6518 | || type == bgp_show_type_flap_cidr_only |
| 6519 | || type == bgp_show_type_flap_regexp |
| 6520 | || type == bgp_show_type_flap_filter_list |
| 6521 | || type == bgp_show_type_flap_prefix_list |
| 6522 | || type == bgp_show_type_flap_prefix_longer |
| 6523 | || type == bgp_show_type_flap_route_map |
| 6524 | || type == bgp_show_type_flap_neighbor |
| 6525 | || type == bgp_show_type_dampend_paths |
| 6526 | || type == bgp_show_type_damp_neighbor) |
| 6527 | { |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6528 | if (!(ri->extra && ri->extra->damp_info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6529 | continue; |
| 6530 | } |
| 6531 | if (type == bgp_show_type_regexp |
| 6532 | || type == bgp_show_type_flap_regexp) |
| 6533 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6534 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6535 | |
| 6536 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 6537 | continue; |
| 6538 | } |
| 6539 | if (type == bgp_show_type_prefix_list |
| 6540 | || type == bgp_show_type_flap_prefix_list) |
| 6541 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6542 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6543 | |
| 6544 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 6545 | continue; |
| 6546 | } |
| 6547 | if (type == bgp_show_type_filter_list |
| 6548 | || type == bgp_show_type_flap_filter_list) |
| 6549 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6550 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6551 | |
| 6552 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 6553 | continue; |
| 6554 | } |
| 6555 | if (type == bgp_show_type_route_map |
| 6556 | || type == bgp_show_type_flap_route_map) |
| 6557 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6558 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6559 | struct bgp_info binfo; |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6560 | struct attr dummy_attr; |
| 6561 | struct attr_extra dummy_extra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6562 | int ret; |
| 6563 | |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6564 | dummy_attr.extra = &dummy_extra; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6565 | bgp_attr_dup (&dummy_attr, ri->attr); |
Jorge Boncompte [DTI2] | 558d1fe | 2012-05-07 16:53:05 +0000 | [diff] [blame] | 6566 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6567 | binfo.peer = ri->peer; |
| 6568 | binfo.attr = &dummy_attr; |
| 6569 | |
| 6570 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6571 | if (ret == RMAP_DENYMATCH) |
| 6572 | continue; |
| 6573 | } |
| 6574 | if (type == bgp_show_type_neighbor |
| 6575 | || type == bgp_show_type_flap_neighbor |
| 6576 | || type == bgp_show_type_damp_neighbor) |
| 6577 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6578 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6579 | |
| 6580 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 6581 | continue; |
| 6582 | } |
| 6583 | if (type == bgp_show_type_cidr_only |
| 6584 | || type == bgp_show_type_flap_cidr_only) |
| 6585 | { |
| 6586 | u_int32_t destination; |
| 6587 | |
| 6588 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 6589 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 6590 | continue; |
| 6591 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 6592 | continue; |
| 6593 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 6594 | continue; |
| 6595 | } |
| 6596 | if (type == bgp_show_type_prefix_longer |
| 6597 | || type == bgp_show_type_flap_prefix_longer) |
| 6598 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6599 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6600 | |
| 6601 | if (! prefix_match (p, &rn->p)) |
| 6602 | continue; |
| 6603 | } |
| 6604 | if (type == bgp_show_type_community_all) |
| 6605 | { |
| 6606 | if (! ri->attr->community) |
| 6607 | continue; |
| 6608 | } |
| 6609 | if (type == bgp_show_type_community) |
| 6610 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6611 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6612 | |
| 6613 | if (! ri->attr->community || |
| 6614 | ! community_match (ri->attr->community, com)) |
| 6615 | continue; |
| 6616 | } |
| 6617 | if (type == bgp_show_type_community_exact) |
| 6618 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6619 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6620 | |
| 6621 | if (! ri->attr->community || |
| 6622 | ! community_cmp (ri->attr->community, com)) |
| 6623 | continue; |
| 6624 | } |
| 6625 | if (type == bgp_show_type_community_list) |
| 6626 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6627 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6628 | |
| 6629 | if (! community_list_match (ri->attr->community, list)) |
| 6630 | continue; |
| 6631 | } |
| 6632 | if (type == bgp_show_type_community_list_exact) |
| 6633 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6634 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6635 | |
| 6636 | if (! community_list_exact_match (ri->attr->community, list)) |
| 6637 | continue; |
| 6638 | } |
| 6639 | if (type == bgp_show_type_flap_address |
| 6640 | || type == bgp_show_type_flap_prefix) |
| 6641 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6642 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6643 | |
| 6644 | if (! prefix_match (&rn->p, p)) |
| 6645 | continue; |
| 6646 | |
| 6647 | if (type == bgp_show_type_flap_prefix) |
| 6648 | if (p->prefixlen != rn->p.prefixlen) |
| 6649 | continue; |
| 6650 | } |
| 6651 | if (type == bgp_show_type_dampend_paths |
| 6652 | || type == bgp_show_type_damp_neighbor) |
| 6653 | { |
| 6654 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 6655 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 6656 | continue; |
| 6657 | } |
| 6658 | |
| 6659 | if (header) |
| 6660 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 6661 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 6662 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 6663 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6664 | if (type == bgp_show_type_dampend_paths |
| 6665 | || type == bgp_show_type_damp_neighbor) |
| 6666 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 6667 | else if (type == bgp_show_type_flap_statistics |
| 6668 | || type == bgp_show_type_flap_address |
| 6669 | || type == bgp_show_type_flap_prefix |
| 6670 | || type == bgp_show_type_flap_cidr_only |
| 6671 | || type == bgp_show_type_flap_regexp |
| 6672 | || type == bgp_show_type_flap_filter_list |
| 6673 | || type == bgp_show_type_flap_prefix_list |
| 6674 | || type == bgp_show_type_flap_prefix_longer |
| 6675 | || type == bgp_show_type_flap_route_map |
| 6676 | || type == bgp_show_type_flap_neighbor) |
| 6677 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 6678 | else |
| 6679 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6680 | header = 0; |
| 6681 | } |
| 6682 | |
| 6683 | if (type == bgp_show_type_dampend_paths |
| 6684 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6685 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6686 | else if (type == bgp_show_type_flap_statistics |
| 6687 | || type == bgp_show_type_flap_address |
| 6688 | || type == bgp_show_type_flap_prefix |
| 6689 | || type == bgp_show_type_flap_cidr_only |
| 6690 | || type == bgp_show_type_flap_regexp |
| 6691 | || type == bgp_show_type_flap_filter_list |
| 6692 | || type == bgp_show_type_flap_prefix_list |
| 6693 | || type == bgp_show_type_flap_prefix_longer |
| 6694 | || type == bgp_show_type_flap_route_map |
| 6695 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6696 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6697 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6698 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6699 | display++; |
| 6700 | } |
| 6701 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6702 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6703 | } |
| 6704 | |
| 6705 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6706 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6707 | { |
| 6708 | if (type == bgp_show_type_normal) |
| 6709 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 6710 | } |
| 6711 | else |
| 6712 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6713 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6714 | |
| 6715 | return CMD_SUCCESS; |
| 6716 | } |
| 6717 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6718 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6719 | 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] | 6720 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6721 | { |
| 6722 | struct bgp_table *table; |
| 6723 | |
| 6724 | if (bgp == NULL) { |
| 6725 | bgp = bgp_get_default (); |
| 6726 | } |
| 6727 | |
| 6728 | if (bgp == NULL) |
| 6729 | { |
| 6730 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6731 | return CMD_WARNING; |
| 6732 | } |
| 6733 | |
| 6734 | |
| 6735 | table = bgp->rib[afi][safi]; |
| 6736 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6737 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6738 | } |
| 6739 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6740 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6741 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6742 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 6743 | struct bgp_node *rn, |
| 6744 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 6745 | { |
| 6746 | struct bgp_info *ri; |
| 6747 | struct prefix *p; |
| 6748 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6749 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6750 | char buf1[INET6_ADDRSTRLEN]; |
| 6751 | char buf2[INET6_ADDRSTRLEN]; |
| 6752 | int count = 0; |
| 6753 | int best = 0; |
| 6754 | int suppress = 0; |
| 6755 | int no_export = 0; |
| 6756 | int no_advertise = 0; |
| 6757 | int local_as = 0; |
| 6758 | int first = 0; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6759 | int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6760 | |
| 6761 | p = &rn->p; |
| 6762 | 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] | 6763 | (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 6764 | printrd ? ":" : "", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6765 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 6766 | p->prefixlen, VTY_NEWLINE); |
| 6767 | |
| 6768 | for (ri = rn->info; ri; ri = ri->next) |
| 6769 | { |
| 6770 | count++; |
| 6771 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 6772 | { |
| 6773 | best = count; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 6774 | if (ri->extra && ri->extra->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6775 | suppress = 1; |
| 6776 | if (ri->attr->community != NULL) |
| 6777 | { |
| 6778 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 6779 | no_advertise = 1; |
| 6780 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 6781 | no_export = 1; |
| 6782 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 6783 | local_as = 1; |
| 6784 | } |
| 6785 | } |
| 6786 | } |
| 6787 | |
| 6788 | vty_out (vty, "Paths: (%d available", count); |
| 6789 | if (best) |
| 6790 | { |
| 6791 | vty_out (vty, ", best #%d", best); |
| 6792 | if (safi == SAFI_UNICAST) |
| 6793 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 6794 | } |
| 6795 | else |
| 6796 | vty_out (vty, ", no best path"); |
| 6797 | if (no_advertise) |
| 6798 | vty_out (vty, ", not advertised to any peer"); |
| 6799 | else if (no_export) |
| 6800 | vty_out (vty, ", not advertised to EBGP peer"); |
| 6801 | else if (local_as) |
| 6802 | vty_out (vty, ", not advertised outside local AS"); |
| 6803 | if (suppress) |
| 6804 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 6805 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 6806 | |
| 6807 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6808 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6809 | { |
| 6810 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 6811 | { |
| 6812 | if (! first) |
| 6813 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 6814 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 6815 | first = 1; |
| 6816 | } |
| 6817 | } |
| 6818 | if (! first) |
| 6819 | vty_out (vty, " Not advertised to any peer"); |
| 6820 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6821 | } |
| 6822 | |
| 6823 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6824 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6825 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6826 | struct bgp_table *rib, const char *ip_str, |
| 6827 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6828 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6829 | { |
| 6830 | int ret; |
| 6831 | int header; |
| 6832 | int display = 0; |
| 6833 | struct prefix match; |
| 6834 | struct bgp_node *rn; |
| 6835 | struct bgp_node *rm; |
| 6836 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6837 | struct bgp_table *table; |
| 6838 | |
Lou Berger | 050defe | 2016-01-12 13:41:59 -0500 | [diff] [blame] | 6839 | memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6840 | /* Check IP address argument. */ |
| 6841 | ret = str2prefix (ip_str, &match); |
| 6842 | if (! ret) |
| 6843 | { |
| 6844 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 6845 | return CMD_WARNING; |
| 6846 | } |
| 6847 | |
| 6848 | match.family = afi2family (afi); |
| 6849 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6850 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6851 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6852 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6853 | { |
| 6854 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 6855 | continue; |
| 6856 | |
| 6857 | if ((table = rn->info) != NULL) |
| 6858 | { |
| 6859 | header = 1; |
| 6860 | |
| 6861 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 6862 | { |
| 6863 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6864 | { |
| 6865 | bgp_unlock_node (rm); |
| 6866 | continue; |
| 6867 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6868 | |
| 6869 | for (ri = rm->info; ri; ri = ri->next) |
| 6870 | { |
| 6871 | if (header) |
| 6872 | { |
| 6873 | 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] | 6874 | AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6875 | |
| 6876 | header = 0; |
| 6877 | } |
| 6878 | display++; |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 6879 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6880 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6881 | |
| 6882 | bgp_unlock_node (rm); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6883 | } |
| 6884 | } |
| 6885 | } |
| 6886 | } |
| 6887 | else |
| 6888 | { |
| 6889 | header = 1; |
| 6890 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6891 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6892 | { |
| 6893 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 6894 | { |
| 6895 | for (ri = rn->info; ri; ri = ri->next) |
| 6896 | { |
| 6897 | if (header) |
| 6898 | { |
| 6899 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 6900 | header = 0; |
| 6901 | } |
| 6902 | display++; |
| 6903 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 6904 | } |
| 6905 | } |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 6906 | |
| 6907 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6908 | } |
| 6909 | } |
| 6910 | |
| 6911 | if (! display) |
| 6912 | { |
| 6913 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 6914 | return CMD_WARNING; |
| 6915 | } |
| 6916 | |
| 6917 | return CMD_SUCCESS; |
| 6918 | } |
| 6919 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 6920 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6921 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6922 | 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] | 6923 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6924 | int prefix_check) |
| 6925 | { |
| 6926 | struct bgp *bgp; |
| 6927 | |
| 6928 | /* BGP structure lookup. */ |
| 6929 | if (view_name) |
| 6930 | { |
| 6931 | bgp = bgp_lookup_by_name (view_name); |
| 6932 | if (bgp == NULL) |
| 6933 | { |
| 6934 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6935 | return CMD_WARNING; |
| 6936 | } |
| 6937 | } |
| 6938 | else |
| 6939 | { |
| 6940 | bgp = bgp_get_default (); |
| 6941 | if (bgp == NULL) |
| 6942 | { |
| 6943 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6944 | return CMD_WARNING; |
| 6945 | } |
| 6946 | } |
| 6947 | |
| 6948 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6949 | afi, safi, prd, prefix_check); |
| 6950 | } |
| 6951 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6952 | /* BGP route print out function. */ |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 6953 | DEFUN (show_bgp_ipv4_safi, |
| 6954 | show_bgp_ipv4_safi_cmd, |
| 6955 | "show bgp ipv4 (unicast|multicast)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6956 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6957 | BGP_STR |
| 6958 | "Address family\n" |
| 6959 | "Address Family modifier\n" |
| 6960 | "Address Family modifier\n") |
| 6961 | { |
| 6962 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6963 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6964 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6965 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6966 | 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] | 6967 | } |
| 6968 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 6969 | DEFUN (show_bgp_ipv4_safi_route, |
| 6970 | show_bgp_ipv4_safi_route_cmd, |
| 6971 | "show bgp ipv4 (unicast|multicast) A.B.C.D", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6972 | SHOW_STR |
| 6973 | BGP_STR |
| 6974 | "Address family\n" |
| 6975 | "Address Family modifier\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6976 | "Address Family modifier\n" |
| 6977 | "Network in the BGP routing table to display\n") |
| 6978 | { |
| 6979 | if (strncmp (argv[0], "m", 1) == 0) |
| 6980 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6981 | |
| 6982 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6983 | } |
| 6984 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 6985 | DEFUN (show_bgp_ipv4_vpn_route, |
| 6986 | show_bgp_ipv4_vpn_route_cmd, |
| 6987 | "show bgp ipv4 vpn A.B.C.D", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 6988 | SHOW_STR |
| 6989 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 6990 | "Address Family\n" |
| 6991 | "Display VPN NLRI specific information\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6992 | "Network in the BGP routing table to display\n") |
| 6993 | { |
| 6994 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6995 | } |
| 6996 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 6997 | #ifdef HAVE_IPV6 |
| 6998 | DEFUN (show_bgp_ipv6_vpn_route, |
| 6999 | show_bgp_ipv6_vpn_route_cmd, |
| 7000 | "show bgp ipv6 vpn X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7001 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7002 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7003 | "Address Family\n" |
| 7004 | "Display VPN NLRI specific information\n" |
| 7005 | "Network in the BGP routing table to display\n") |
| 7006 | { |
| 7007 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0); |
| 7008 | } |
| 7009 | #endif |
| 7010 | |
| 7011 | DEFUN (show_bgp_ipv4_vpn_rd_route, |
| 7012 | show_bgp_ipv4_vpn_rd_route_cmd, |
| 7013 | "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 7014 | SHOW_STR |
| 7015 | BGP_STR |
| 7016 | IP_STR |
| 7017 | "Display VPN NLRI specific information\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7018 | "Display information for a route distinguisher\n" |
| 7019 | "VPN Route Distinguisher\n" |
| 7020 | "Network in the BGP routing table to display\n") |
| 7021 | { |
| 7022 | int ret; |
| 7023 | struct prefix_rd prd; |
| 7024 | |
| 7025 | ret = str2prefix_rd (argv[0], &prd); |
| 7026 | if (! ret) |
| 7027 | { |
| 7028 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7029 | return CMD_WARNING; |
| 7030 | } |
| 7031 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 7032 | } |
| 7033 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7034 | DEFUN (show_bgp_ipv6_vpn_rd_route, |
| 7035 | show_bgp_ipv6_vpn_rd_route_cmd, |
| 7036 | "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] | 7037 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7038 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7039 | "Address Family\n" |
| 7040 | "Display VPN NLRI specific information\n" |
| 7041 | "Display information for a route distinguisher\n" |
| 7042 | "VPN Route Distinguisher\n" |
| 7043 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7044 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7045 | int ret; |
| 7046 | struct prefix_rd prd; |
| 7047 | |
| 7048 | ret = str2prefix_rd (argv[0], &prd); |
| 7049 | if (! ret) |
| 7050 | { |
| 7051 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7052 | return CMD_WARNING; |
| 7053 | } |
| 7054 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7055 | } |
| 7056 | |
| 7057 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 7058 | show_ip_bgp_ipv4_prefix_cmd, |
| 7059 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 7060 | SHOW_STR |
| 7061 | IP_STR |
| 7062 | BGP_STR |
| 7063 | "Address family\n" |
| 7064 | "Address Family modifier\n" |
| 7065 | "Address Family modifier\n" |
| 7066 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7067 | { |
| 7068 | if (strncmp (argv[0], "m", 1) == 0) |
| 7069 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 7070 | |
| 7071 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 7072 | } |
| 7073 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7074 | ALIAS (show_ip_bgp_ipv4_prefix, |
| 7075 | show_bgp_ipv4_safi_prefix_cmd, |
| 7076 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 7077 | SHOW_STR |
| 7078 | BGP_STR |
| 7079 | "Address family\n" |
| 7080 | "Address Family modifier\n" |
| 7081 | "Address Family modifier\n" |
| 7082 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7083 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7084 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 7085 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 7086 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 7087 | SHOW_STR |
| 7088 | IP_STR |
| 7089 | BGP_STR |
| 7090 | "Display VPNv4 NLRI specific information\n" |
| 7091 | "Display information about all VPNv4 NLRIs\n" |
| 7092 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7093 | { |
| 7094 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 7095 | } |
| 7096 | |
| 7097 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 7098 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 7099 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 7100 | SHOW_STR |
| 7101 | IP_STR |
| 7102 | BGP_STR |
| 7103 | "Display VPNv4 NLRI specific information\n" |
| 7104 | "Display information for a route distinguisher\n" |
| 7105 | "VPN Route Distinguisher\n" |
| 7106 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7107 | { |
| 7108 | int ret; |
| 7109 | struct prefix_rd prd; |
| 7110 | |
| 7111 | ret = str2prefix_rd (argv[0], &prd); |
| 7112 | if (! ret) |
| 7113 | { |
| 7114 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 7115 | return CMD_WARNING; |
| 7116 | } |
| 7117 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 7118 | } |
| 7119 | |
| 7120 | DEFUN (show_ip_bgp_view, |
| 7121 | show_ip_bgp_view_cmd, |
| 7122 | "show ip bgp view WORD", |
| 7123 | SHOW_STR |
| 7124 | IP_STR |
| 7125 | BGP_STR |
| 7126 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 7127 | "View name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7128 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7129 | struct bgp *bgp; |
| 7130 | |
| 7131 | /* BGP structure lookup. */ |
| 7132 | bgp = bgp_lookup_by_name (argv[0]); |
| 7133 | if (bgp == NULL) |
| 7134 | { |
| 7135 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7136 | return CMD_WARNING; |
| 7137 | } |
| 7138 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7139 | return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7140 | } |
| 7141 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7142 | DEFUN (show_bgp_ipv4_prefix, |
| 7143 | show_bgp_ipv4_prefix_cmd, |
| 7144 | "show bgp ipv4 A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7145 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7146 | BGP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7147 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7148 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7149 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7150 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7151 | } |
| 7152 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7153 | DEFUN (show_bgp_ipv4_safi_prefix, |
| 7154 | show_bgp_ipv4_safi_prefix_cmd, |
| 7155 | "show bgp ipv4 (unicast|multicast) A.B.C.D/M", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7156 | SHOW_STR |
| 7157 | BGP_STR |
| 7158 | "Address family\n" |
| 7159 | "Address Family modifier\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7160 | "Address Family modifier\n" |
| 7161 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7162 | { |
| 7163 | if (strncmp (argv[0], "m", 1) == 0) |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7164 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7165 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7166 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7167 | } |
| 7168 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7169 | DEFUN (show_bgp_ipv4_vpn_prefix, |
| 7170 | show_bgp_ipv4_vpn_prefix_cmd, |
| 7171 | "show bgp ipv4 vpn A.B.C.D/M", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7172 | SHOW_STR |
| 7173 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7174 | IP_STR |
| 7175 | "Display VPN NLRI specific information\n" |
| 7176 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7177 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7178 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7179 | } |
| 7180 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7181 | #ifdef HAVE_IPV6 |
| 7182 | DEFUN (show_bgp_ipv6_vpn_prefix, |
| 7183 | show_bgp_ipv6_vpn_prefix_cmd, |
| 7184 | "show bgp ipv6 vpn X:X::X:X/M", |
| 7185 | SHOW_STR |
| 7186 | BGP_STR |
| 7187 | "Address Family\n" |
| 7188 | "Display VPN NLRI specific information\n" |
| 7189 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 7190 | { |
| 7191 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 1); |
| 7192 | } |
| 7193 | #endif |
| 7194 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7195 | ALIAS (show_bgp_route, |
| 7196 | show_bgp_ipv6_route_cmd, |
| 7197 | "show bgp ipv6 X:X::X:X", |
| 7198 | SHOW_STR |
| 7199 | BGP_STR |
| 7200 | "Address family\n" |
| 7201 | "Network in the BGP routing table to display\n") |
| 7202 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7203 | DEFUN (show_bgp_ipv6_safi_route, |
| 7204 | show_bgp_ipv6_safi_route_cmd, |
| 7205 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
| 7206 | SHOW_STR |
| 7207 | BGP_STR |
| 7208 | "Address family\n" |
| 7209 | "Address Family modifier\n" |
| 7210 | "Address Family modifier\n" |
| 7211 | "Network in the BGP routing table to display\n") |
| 7212 | { |
| 7213 | if (strncmp (argv[0], "m", 1) == 0) |
| 7214 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7215 | |
| 7216 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7217 | } |
| 7218 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7219 | DEFUN (show_bgp_ipv6_route, |
| 7220 | show_bgp_ipv6_route_cmd, |
| 7221 | "show bgp ipv6 X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7222 | SHOW_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7223 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7224 | "Address family\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7225 | "Network in the BGP routing table to display\n") |
| 7226 | { |
| 7227 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 7228 | } |
| 7229 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7230 | DEFUN (show_bgp_ipv6_safi_route, |
| 7231 | show_bgp_ipv6_safi_route_cmd, |
| 7232 | "show bgp ipv6 (unicast|multicast) X:X::X:X", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7233 | SHOW_STR |
| 7234 | BGP_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7235 | "Address family\n" |
| 7236 | "Address Family modifier\n" |
| 7237 | "Address Family modifier\n" |
| 7238 | "Network in the BGP routing table to display\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7239 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7240 | if (strncmp (argv[0], "m", 1) == 0) |
| 7241 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 7242 | |
| 7243 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7244 | } |
| 7245 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7246 | /* new002 */ |
| 7247 | DEFUN (show_bgp_ipv6_prefix, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7248 | show_bgp_ipv6_prefix_cmd, |
| 7249 | "show bgp ipv6 X:X::X:X/M", |
| 7250 | SHOW_STR |
| 7251 | BGP_STR |
| 7252 | "Address family\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7253 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7254 | { |
| 7255 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7256 | } |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7257 | DEFUN (show_bgp_ipv6_safi_prefix, |
| 7258 | show_bgp_ipv6_safi_prefix_cmd, |
| 7259 | "show bgp ipv6 (unicast|multicast) X:X::X:X/M", |
| 7260 | SHOW_STR |
| 7261 | BGP_STR |
| 7262 | "Address family\n" |
| 7263 | "Address Family modifier\n" |
| 7264 | "Address Family modifier\n" |
| 7265 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 7266 | { |
| 7267 | if (strncmp (argv[0], "m", 1) == 0) |
| 7268 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 7269 | |
| 7270 | return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 7271 | } |
| 7272 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7273 | DEFUN (show_bgp_view, |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7274 | show_bgp_view_ipv6_cmd, |
| 7275 | "show bgp view WORD ipv6", |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7276 | SHOW_STR |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7277 | BGP_STR |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7278 | "BGP view\n" |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7279 | "View name\n" |
| 7280 | "Address family\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7281 | { |
| 7282 | struct bgp *bgp; |
| 7283 | |
| 7284 | /* BGP structure lookup. */ |
| 7285 | bgp = bgp_lookup_by_name (argv[0]); |
| 7286 | if (bgp == NULL) |
| 7287 | { |
| 7288 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 7289 | return CMD_WARNING; |
| 7290 | } |
| 7291 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7292 | 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] | 7293 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7294 | |
| 7295 | DEFUN (show_bgp_view_route, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7296 | show_bgp_view_ipv6_route_cmd, |
| 7297 | "show bgp view WORD ipv6 X:X::X:X", |
| 7298 | SHOW_STR |
| 7299 | BGP_STR |
| 7300 | "BGP view\n" |
| 7301 | "View name\n" |
| 7302 | "Address family\n" |
| 7303 | "Network in the BGP routing table to display\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7304 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7305 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7306 | } |
| 7307 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7308 | DEFUN (show_bgp_view_prefix, |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 7309 | show_bgp_view_ipv6_prefix_cmd, |
| 7310 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 7311 | SHOW_STR |
| 7312 | BGP_STR |
| 7313 | "BGP view\n" |
| 7314 | "View name\n" |
| 7315 | "Address family\n" |
| 7316 | "IPv6 prefix <network>/<length>\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7317 | { |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7318 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7319 | } |
| 7320 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7321 | #endif |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7322 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7323 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7324 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7325 | 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] | 7326 | safi_t safi, enum bgp_show_type type) |
| 7327 | { |
| 7328 | int i; |
| 7329 | struct buffer *b; |
| 7330 | char *regstr; |
| 7331 | int first; |
| 7332 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7333 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7334 | |
| 7335 | first = 0; |
| 7336 | b = buffer_new (1024); |
| 7337 | for (i = 0; i < argc; i++) |
| 7338 | { |
| 7339 | if (first) |
| 7340 | buffer_putc (b, ' '); |
| 7341 | else |
| 7342 | { |
| 7343 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7344 | continue; |
| 7345 | first = 1; |
| 7346 | } |
| 7347 | |
| 7348 | buffer_putstr (b, argv[i]); |
| 7349 | } |
| 7350 | buffer_putc (b, '\0'); |
| 7351 | |
| 7352 | regstr = buffer_getstr (b); |
| 7353 | buffer_free (b); |
| 7354 | |
| 7355 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7356 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7357 | if (! regex) |
| 7358 | { |
| 7359 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 7360 | VTY_NEWLINE); |
| 7361 | return CMD_WARNING; |
| 7362 | } |
| 7363 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7364 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 7365 | bgp_regex_free (regex); |
| 7366 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7367 | } |
| 7368 | |
| 7369 | DEFUN (show_ip_bgp_regexp, |
| 7370 | show_ip_bgp_regexp_cmd, |
| 7371 | "show ip bgp regexp .LINE", |
| 7372 | SHOW_STR |
| 7373 | IP_STR |
| 7374 | BGP_STR |
| 7375 | "Display routes matching the AS path regular expression\n" |
| 7376 | "A regular-expression to match the BGP AS paths\n") |
| 7377 | { |
| 7378 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7379 | bgp_show_type_regexp); |
| 7380 | } |
| 7381 | |
| 7382 | DEFUN (show_ip_bgp_flap_regexp, |
| 7383 | show_ip_bgp_flap_regexp_cmd, |
| 7384 | "show ip bgp flap-statistics regexp .LINE", |
| 7385 | SHOW_STR |
| 7386 | IP_STR |
| 7387 | BGP_STR |
| 7388 | "Display flap statistics of routes\n" |
| 7389 | "Display routes matching the AS path regular expression\n" |
| 7390 | "A regular-expression to match the BGP AS paths\n") |
| 7391 | { |
| 7392 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7393 | bgp_show_type_flap_regexp); |
| 7394 | } |
| 7395 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7396 | ALIAS (show_ip_bgp_flap_regexp, |
| 7397 | show_ip_bgp_damp_flap_regexp_cmd, |
| 7398 | "show ip bgp dampening flap-statistics regexp .LINE", |
| 7399 | SHOW_STR |
| 7400 | IP_STR |
| 7401 | BGP_STR |
| 7402 | "Display detailed information about dampening\n" |
| 7403 | "Display flap statistics of routes\n" |
| 7404 | "Display routes matching the AS path regular expression\n" |
| 7405 | "A regular-expression to match the BGP AS paths\n") |
| 7406 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7407 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 7408 | show_ip_bgp_ipv4_regexp_cmd, |
| 7409 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 7410 | SHOW_STR |
| 7411 | IP_STR |
| 7412 | BGP_STR |
| 7413 | "Address family\n" |
| 7414 | "Address Family modifier\n" |
| 7415 | "Address Family modifier\n" |
| 7416 | "Display routes matching the AS path regular expression\n" |
| 7417 | "A regular-expression to match the BGP AS paths\n") |
| 7418 | { |
| 7419 | if (strncmp (argv[0], "m", 1) == 0) |
| 7420 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 7421 | bgp_show_type_regexp); |
| 7422 | |
| 7423 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 7424 | bgp_show_type_regexp); |
| 7425 | } |
| 7426 | |
| 7427 | #ifdef HAVE_IPV6 |
| 7428 | DEFUN (show_bgp_regexp, |
| 7429 | show_bgp_regexp_cmd, |
| 7430 | "show bgp regexp .LINE", |
| 7431 | SHOW_STR |
| 7432 | BGP_STR |
| 7433 | "Display routes matching the AS path regular expression\n" |
| 7434 | "A regular-expression to match the BGP AS paths\n") |
| 7435 | { |
| 7436 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7437 | bgp_show_type_regexp); |
| 7438 | } |
| 7439 | |
| 7440 | ALIAS (show_bgp_regexp, |
| 7441 | show_bgp_ipv6_regexp_cmd, |
| 7442 | "show bgp ipv6 regexp .LINE", |
| 7443 | SHOW_STR |
| 7444 | BGP_STR |
| 7445 | "Address family\n" |
| 7446 | "Display routes matching the AS path regular expression\n" |
| 7447 | "A regular-expression to match the BGP AS paths\n") |
| 7448 | |
| 7449 | /* old command */ |
| 7450 | DEFUN (show_ipv6_bgp_regexp, |
| 7451 | show_ipv6_bgp_regexp_cmd, |
| 7452 | "show ipv6 bgp regexp .LINE", |
| 7453 | SHOW_STR |
| 7454 | IP_STR |
| 7455 | BGP_STR |
| 7456 | "Display routes matching the AS path regular expression\n" |
| 7457 | "A regular-expression to match the BGP AS paths\n") |
| 7458 | { |
| 7459 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 7460 | bgp_show_type_regexp); |
| 7461 | } |
| 7462 | |
| 7463 | /* old command */ |
| 7464 | DEFUN (show_ipv6_mbgp_regexp, |
| 7465 | show_ipv6_mbgp_regexp_cmd, |
| 7466 | "show ipv6 mbgp regexp .LINE", |
| 7467 | SHOW_STR |
| 7468 | IP_STR |
| 7469 | BGP_STR |
| 7470 | "Display routes matching the AS path regular expression\n" |
| 7471 | "A regular-expression to match the MBGP AS paths\n") |
| 7472 | { |
| 7473 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 7474 | bgp_show_type_regexp); |
| 7475 | } |
| 7476 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7477 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7478 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7479 | 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] | 7480 | safi_t safi, enum bgp_show_type type) |
| 7481 | { |
| 7482 | struct prefix_list *plist; |
| 7483 | |
| 7484 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 7485 | if (plist == NULL) |
| 7486 | { |
| 7487 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 7488 | prefix_list_str, VTY_NEWLINE); |
| 7489 | return CMD_WARNING; |
| 7490 | } |
| 7491 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7492 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7493 | } |
| 7494 | |
Lou Berger | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7495 | DEFUN (show_bgp_ipv4_prefix_list, |
| 7496 | show_bgp_ipv4_prefix_list_cmd, |
| 7497 | "show bgp ipv4 prefix-list WORD", |
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 | 35c3686 | 2016-01-12 13:42:06 -0500 | [diff] [blame^] | 7500 | IP_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7501 | "Display routes conforming to the prefix-list\n" |
| 7502 | "IP prefix-list name\n") |
| 7503 | { |
| 7504 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7505 | bgp_show_type_prefix_list); |
| 7506 | } |
| 7507 | |
| 7508 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 7509 | show_ip_bgp_flap_prefix_list_cmd, |
| 7510 | "show ip bgp flap-statistics prefix-list WORD", |
| 7511 | SHOW_STR |
| 7512 | IP_STR |
| 7513 | BGP_STR |
| 7514 | "Display flap statistics of routes\n" |
| 7515 | "Display routes conforming to the prefix-list\n" |
| 7516 | "IP prefix-list name\n") |
| 7517 | { |
| 7518 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7519 | bgp_show_type_flap_prefix_list); |
| 7520 | } |
| 7521 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7522 | ALIAS (show_ip_bgp_flap_prefix_list, |
| 7523 | show_ip_bgp_damp_flap_prefix_list_cmd, |
| 7524 | "show ip bgp dampening flap-statistics prefix-list WORD", |
| 7525 | SHOW_STR |
| 7526 | IP_STR |
| 7527 | BGP_STR |
| 7528 | "Display detailed information about dampening\n" |
| 7529 | "Display flap statistics of routes\n" |
| 7530 | "Display routes conforming to the prefix-list\n" |
| 7531 | "IP prefix-list name\n") |
| 7532 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7533 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 7534 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 7535 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 7536 | SHOW_STR |
| 7537 | IP_STR |
| 7538 | BGP_STR |
| 7539 | "Address family\n" |
| 7540 | "Address Family modifier\n" |
| 7541 | "Address Family modifier\n" |
| 7542 | "Display routes conforming to the prefix-list\n" |
| 7543 | "IP prefix-list name\n") |
| 7544 | { |
| 7545 | if (strncmp (argv[0], "m", 1) == 0) |
| 7546 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7547 | bgp_show_type_prefix_list); |
| 7548 | |
| 7549 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7550 | bgp_show_type_prefix_list); |
| 7551 | } |
| 7552 | |
| 7553 | #ifdef HAVE_IPV6 |
| 7554 | DEFUN (show_bgp_prefix_list, |
| 7555 | show_bgp_prefix_list_cmd, |
| 7556 | "show bgp prefix-list WORD", |
| 7557 | SHOW_STR |
| 7558 | BGP_STR |
| 7559 | "Display routes conforming to the prefix-list\n" |
| 7560 | "IPv6 prefix-list name\n") |
| 7561 | { |
| 7562 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7563 | bgp_show_type_prefix_list); |
| 7564 | } |
| 7565 | |
| 7566 | ALIAS (show_bgp_prefix_list, |
| 7567 | show_bgp_ipv6_prefix_list_cmd, |
| 7568 | "show bgp ipv6 prefix-list WORD", |
| 7569 | SHOW_STR |
| 7570 | BGP_STR |
| 7571 | "Address family\n" |
| 7572 | "Display routes conforming to the prefix-list\n" |
| 7573 | "IPv6 prefix-list name\n") |
| 7574 | |
| 7575 | /* old command */ |
| 7576 | DEFUN (show_ipv6_bgp_prefix_list, |
| 7577 | show_ipv6_bgp_prefix_list_cmd, |
| 7578 | "show ipv6 bgp prefix-list WORD", |
| 7579 | SHOW_STR |
| 7580 | IPV6_STR |
| 7581 | BGP_STR |
| 7582 | "Display routes matching the prefix-list\n" |
| 7583 | "IPv6 prefix-list name\n") |
| 7584 | { |
| 7585 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7586 | bgp_show_type_prefix_list); |
| 7587 | } |
| 7588 | |
| 7589 | /* old command */ |
| 7590 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 7591 | show_ipv6_mbgp_prefix_list_cmd, |
| 7592 | "show ipv6 mbgp prefix-list WORD", |
| 7593 | SHOW_STR |
| 7594 | IPV6_STR |
| 7595 | MBGP_STR |
| 7596 | "Display routes matching the prefix-list\n" |
| 7597 | "IPv6 prefix-list name\n") |
| 7598 | { |
| 7599 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7600 | bgp_show_type_prefix_list); |
| 7601 | } |
| 7602 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7603 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7604 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7605 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7606 | safi_t safi, enum bgp_show_type type) |
| 7607 | { |
| 7608 | struct as_list *as_list; |
| 7609 | |
| 7610 | as_list = as_list_lookup (filter); |
| 7611 | if (as_list == NULL) |
| 7612 | { |
| 7613 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 7614 | return CMD_WARNING; |
| 7615 | } |
| 7616 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7617 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7618 | } |
| 7619 | |
| 7620 | DEFUN (show_ip_bgp_filter_list, |
| 7621 | show_ip_bgp_filter_list_cmd, |
| 7622 | "show ip bgp filter-list WORD", |
| 7623 | SHOW_STR |
| 7624 | IP_STR |
| 7625 | BGP_STR |
| 7626 | "Display routes conforming to the filter-list\n" |
| 7627 | "Regular expression access list name\n") |
| 7628 | { |
| 7629 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7630 | bgp_show_type_filter_list); |
| 7631 | } |
| 7632 | |
| 7633 | DEFUN (show_ip_bgp_flap_filter_list, |
| 7634 | show_ip_bgp_flap_filter_list_cmd, |
| 7635 | "show ip bgp flap-statistics filter-list WORD", |
| 7636 | SHOW_STR |
| 7637 | IP_STR |
| 7638 | BGP_STR |
| 7639 | "Display flap statistics of routes\n" |
| 7640 | "Display routes conforming to the filter-list\n" |
| 7641 | "Regular expression access list name\n") |
| 7642 | { |
| 7643 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7644 | bgp_show_type_flap_filter_list); |
| 7645 | } |
| 7646 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7647 | ALIAS (show_ip_bgp_flap_filter_list, |
| 7648 | show_ip_bgp_damp_flap_filter_list_cmd, |
| 7649 | "show ip bgp dampening flap-statistics filter-list WORD", |
| 7650 | SHOW_STR |
| 7651 | IP_STR |
| 7652 | BGP_STR |
| 7653 | "Display detailed information about dampening\n" |
| 7654 | "Display flap statistics of routes\n" |
| 7655 | "Display routes conforming to the filter-list\n" |
| 7656 | "Regular expression access list name\n") |
| 7657 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7658 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 7659 | show_ip_bgp_ipv4_filter_list_cmd, |
| 7660 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 7661 | SHOW_STR |
| 7662 | IP_STR |
| 7663 | BGP_STR |
| 7664 | "Address family\n" |
| 7665 | "Address Family modifier\n" |
| 7666 | "Address Family modifier\n" |
| 7667 | "Display routes conforming to the filter-list\n" |
| 7668 | "Regular expression access list name\n") |
| 7669 | { |
| 7670 | if (strncmp (argv[0], "m", 1) == 0) |
| 7671 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7672 | bgp_show_type_filter_list); |
| 7673 | |
| 7674 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7675 | bgp_show_type_filter_list); |
| 7676 | } |
| 7677 | |
| 7678 | #ifdef HAVE_IPV6 |
| 7679 | DEFUN (show_bgp_filter_list, |
| 7680 | show_bgp_filter_list_cmd, |
| 7681 | "show bgp filter-list WORD", |
| 7682 | SHOW_STR |
| 7683 | BGP_STR |
| 7684 | "Display routes conforming to the filter-list\n" |
| 7685 | "Regular expression access list name\n") |
| 7686 | { |
| 7687 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7688 | bgp_show_type_filter_list); |
| 7689 | } |
| 7690 | |
| 7691 | ALIAS (show_bgp_filter_list, |
| 7692 | show_bgp_ipv6_filter_list_cmd, |
| 7693 | "show bgp ipv6 filter-list WORD", |
| 7694 | SHOW_STR |
| 7695 | BGP_STR |
| 7696 | "Address family\n" |
| 7697 | "Display routes conforming to the filter-list\n" |
| 7698 | "Regular expression access list name\n") |
| 7699 | |
| 7700 | /* old command */ |
| 7701 | DEFUN (show_ipv6_bgp_filter_list, |
| 7702 | show_ipv6_bgp_filter_list_cmd, |
| 7703 | "show ipv6 bgp filter-list WORD", |
| 7704 | SHOW_STR |
| 7705 | IPV6_STR |
| 7706 | BGP_STR |
| 7707 | "Display routes conforming to the filter-list\n" |
| 7708 | "Regular expression access list name\n") |
| 7709 | { |
| 7710 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7711 | bgp_show_type_filter_list); |
| 7712 | } |
| 7713 | |
| 7714 | /* old command */ |
| 7715 | DEFUN (show_ipv6_mbgp_filter_list, |
| 7716 | show_ipv6_mbgp_filter_list_cmd, |
| 7717 | "show ipv6 mbgp filter-list WORD", |
| 7718 | SHOW_STR |
| 7719 | IPV6_STR |
| 7720 | MBGP_STR |
| 7721 | "Display routes conforming to the filter-list\n" |
| 7722 | "Regular expression access list name\n") |
| 7723 | { |
| 7724 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 7725 | bgp_show_type_filter_list); |
| 7726 | } |
| 7727 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7728 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7729 | DEFUN (show_ip_bgp_dampening_info, |
| 7730 | show_ip_bgp_dampening_params_cmd, |
| 7731 | "show ip bgp dampening parameters", |
| 7732 | SHOW_STR |
| 7733 | IP_STR |
| 7734 | BGP_STR |
| 7735 | "Display detailed information about dampening\n" |
| 7736 | "Display detail of configured dampening parameters\n") |
| 7737 | { |
| 7738 | return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); |
| 7739 | } |
| 7740 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7741 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7742 | 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] | 7743 | safi_t safi, enum bgp_show_type type) |
| 7744 | { |
| 7745 | struct route_map *rmap; |
| 7746 | |
| 7747 | rmap = route_map_lookup_by_name (rmap_str); |
| 7748 | if (! rmap) |
| 7749 | { |
| 7750 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 7751 | rmap_str, VTY_NEWLINE); |
| 7752 | return CMD_WARNING; |
| 7753 | } |
| 7754 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7755 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7756 | } |
| 7757 | |
| 7758 | DEFUN (show_ip_bgp_route_map, |
| 7759 | show_ip_bgp_route_map_cmd, |
| 7760 | "show ip bgp route-map WORD", |
| 7761 | SHOW_STR |
| 7762 | IP_STR |
| 7763 | BGP_STR |
| 7764 | "Display routes matching the route-map\n" |
| 7765 | "A route-map to match on\n") |
| 7766 | { |
| 7767 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7768 | bgp_show_type_route_map); |
| 7769 | } |
| 7770 | |
| 7771 | DEFUN (show_ip_bgp_flap_route_map, |
| 7772 | show_ip_bgp_flap_route_map_cmd, |
| 7773 | "show ip bgp flap-statistics route-map WORD", |
| 7774 | SHOW_STR |
| 7775 | IP_STR |
| 7776 | BGP_STR |
| 7777 | "Display flap statistics of routes\n" |
| 7778 | "Display routes matching the route-map\n" |
| 7779 | "A route-map to match on\n") |
| 7780 | { |
| 7781 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 7782 | bgp_show_type_flap_route_map); |
| 7783 | } |
| 7784 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7785 | ALIAS (show_ip_bgp_flap_route_map, |
| 7786 | show_ip_bgp_damp_flap_route_map_cmd, |
| 7787 | "show ip bgp dampening flap-statistics route-map WORD", |
| 7788 | SHOW_STR |
| 7789 | IP_STR |
| 7790 | BGP_STR |
| 7791 | "Display detailed information about dampening\n" |
| 7792 | "Display flap statistics of routes\n" |
| 7793 | "Display routes matching the route-map\n" |
| 7794 | "A route-map to match on\n") |
| 7795 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7796 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 7797 | show_ip_bgp_ipv4_route_map_cmd, |
| 7798 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 7799 | SHOW_STR |
| 7800 | IP_STR |
| 7801 | BGP_STR |
| 7802 | "Address family\n" |
| 7803 | "Address Family modifier\n" |
| 7804 | "Address Family modifier\n" |
| 7805 | "Display routes matching the route-map\n" |
| 7806 | "A route-map to match on\n") |
| 7807 | { |
| 7808 | if (strncmp (argv[0], "m", 1) == 0) |
| 7809 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 7810 | bgp_show_type_route_map); |
| 7811 | |
| 7812 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 7813 | bgp_show_type_route_map); |
| 7814 | } |
| 7815 | |
| 7816 | DEFUN (show_bgp_route_map, |
| 7817 | show_bgp_route_map_cmd, |
| 7818 | "show bgp route-map WORD", |
| 7819 | SHOW_STR |
| 7820 | BGP_STR |
| 7821 | "Display routes matching the route-map\n" |
| 7822 | "A route-map to match on\n") |
| 7823 | { |
| 7824 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 7825 | bgp_show_type_route_map); |
| 7826 | } |
| 7827 | |
| 7828 | ALIAS (show_bgp_route_map, |
| 7829 | show_bgp_ipv6_route_map_cmd, |
| 7830 | "show bgp ipv6 route-map WORD", |
| 7831 | SHOW_STR |
| 7832 | BGP_STR |
| 7833 | "Address family\n" |
| 7834 | "Display routes matching the route-map\n" |
| 7835 | "A route-map to match on\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7836 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7837 | DEFUN (show_ip_bgp_cidr_only, |
| 7838 | show_ip_bgp_cidr_only_cmd, |
| 7839 | "show ip bgp cidr-only", |
| 7840 | SHOW_STR |
| 7841 | IP_STR |
| 7842 | BGP_STR |
| 7843 | "Display only routes with non-natural netmasks\n") |
| 7844 | { |
| 7845 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7846 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7847 | } |
| 7848 | |
| 7849 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 7850 | show_ip_bgp_flap_cidr_only_cmd, |
| 7851 | "show ip bgp flap-statistics cidr-only", |
| 7852 | SHOW_STR |
| 7853 | IP_STR |
| 7854 | BGP_STR |
| 7855 | "Display flap statistics of routes\n" |
| 7856 | "Display only routes with non-natural netmasks\n") |
| 7857 | { |
| 7858 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7859 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7860 | } |
| 7861 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 7862 | ALIAS (show_ip_bgp_flap_cidr_only, |
| 7863 | show_ip_bgp_damp_flap_cidr_only_cmd, |
| 7864 | "show ip bgp dampening flap-statistics cidr-only", |
| 7865 | SHOW_STR |
| 7866 | IP_STR |
| 7867 | BGP_STR |
| 7868 | "Display detailed information about dampening\n" |
| 7869 | "Display flap statistics of routes\n" |
| 7870 | "Display only routes with non-natural netmasks\n") |
| 7871 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7872 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 7873 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 7874 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 7875 | SHOW_STR |
| 7876 | IP_STR |
| 7877 | BGP_STR |
| 7878 | "Address family\n" |
| 7879 | "Address Family modifier\n" |
| 7880 | "Address Family modifier\n" |
| 7881 | "Display only routes with non-natural netmasks\n") |
| 7882 | { |
| 7883 | if (strncmp (argv[0], "m", 1) == 0) |
| 7884 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7885 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7886 | |
| 7887 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7888 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7889 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7890 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7891 | DEFUN (show_ip_bgp_community_all, |
| 7892 | show_ip_bgp_community_all_cmd, |
| 7893 | "show ip bgp community", |
| 7894 | SHOW_STR |
| 7895 | IP_STR |
| 7896 | BGP_STR |
| 7897 | "Display routes matching the communities\n") |
| 7898 | { |
| 7899 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7900 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7901 | } |
| 7902 | |
| 7903 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 7904 | show_ip_bgp_ipv4_community_all_cmd, |
| 7905 | "show ip bgp ipv4 (unicast|multicast) community", |
| 7906 | SHOW_STR |
| 7907 | IP_STR |
| 7908 | BGP_STR |
| 7909 | "Address family\n" |
| 7910 | "Address Family modifier\n" |
| 7911 | "Address Family modifier\n" |
| 7912 | "Display routes matching the communities\n") |
| 7913 | { |
| 7914 | if (strncmp (argv[0], "m", 1) == 0) |
| 7915 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7916 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7917 | |
| 7918 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7919 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7920 | } |
| 7921 | |
| 7922 | #ifdef HAVE_IPV6 |
| 7923 | DEFUN (show_bgp_community_all, |
| 7924 | show_bgp_community_all_cmd, |
| 7925 | "show bgp community", |
| 7926 | SHOW_STR |
| 7927 | BGP_STR |
| 7928 | "Display routes matching the communities\n") |
| 7929 | { |
| 7930 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7931 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7932 | } |
| 7933 | |
| 7934 | ALIAS (show_bgp_community_all, |
| 7935 | show_bgp_ipv6_community_all_cmd, |
| 7936 | "show bgp ipv6 community", |
| 7937 | SHOW_STR |
| 7938 | BGP_STR |
| 7939 | "Address family\n" |
| 7940 | "Display routes matching the communities\n") |
| 7941 | |
| 7942 | /* old command */ |
| 7943 | DEFUN (show_ipv6_bgp_community_all, |
| 7944 | show_ipv6_bgp_community_all_cmd, |
| 7945 | "show ipv6 bgp community", |
| 7946 | SHOW_STR |
| 7947 | IPV6_STR |
| 7948 | BGP_STR |
| 7949 | "Display routes matching the communities\n") |
| 7950 | { |
| 7951 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7952 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7953 | } |
| 7954 | |
| 7955 | /* old command */ |
| 7956 | DEFUN (show_ipv6_mbgp_community_all, |
| 7957 | show_ipv6_mbgp_community_all_cmd, |
| 7958 | "show ipv6 mbgp community", |
| 7959 | SHOW_STR |
| 7960 | IPV6_STR |
| 7961 | MBGP_STR |
| 7962 | "Display routes matching the communities\n") |
| 7963 | { |
| 7964 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7965 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7966 | } |
| 7967 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7968 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7969 | static int |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7970 | bgp_show_community (struct vty *vty, const char *view_name, int argc, |
| 7971 | const char **argv, int exact, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7972 | { |
| 7973 | struct community *com; |
| 7974 | struct buffer *b; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7975 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7976 | int i; |
| 7977 | char *str; |
| 7978 | int first = 0; |
| 7979 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 7980 | /* BGP structure lookup */ |
| 7981 | if (view_name) |
| 7982 | { |
| 7983 | bgp = bgp_lookup_by_name (view_name); |
| 7984 | if (bgp == NULL) |
| 7985 | { |
| 7986 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 7987 | return CMD_WARNING; |
| 7988 | } |
| 7989 | } |
| 7990 | else |
| 7991 | { |
| 7992 | bgp = bgp_get_default (); |
| 7993 | if (bgp == NULL) |
| 7994 | { |
| 7995 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 7996 | return CMD_WARNING; |
| 7997 | } |
| 7998 | } |
| 7999 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8000 | b = buffer_new (1024); |
| 8001 | for (i = 0; i < argc; i++) |
| 8002 | { |
| 8003 | if (first) |
| 8004 | buffer_putc (b, ' '); |
| 8005 | else |
| 8006 | { |
| 8007 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 8008 | continue; |
| 8009 | first = 1; |
| 8010 | } |
| 8011 | |
| 8012 | buffer_putstr (b, argv[i]); |
| 8013 | } |
| 8014 | buffer_putc (b, '\0'); |
| 8015 | |
| 8016 | str = buffer_getstr (b); |
| 8017 | buffer_free (b); |
| 8018 | |
| 8019 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 8020 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8021 | if (! com) |
| 8022 | { |
| 8023 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 8024 | return CMD_WARNING; |
| 8025 | } |
| 8026 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8027 | return bgp_show (vty, bgp, afi, safi, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8028 | (exact ? bgp_show_type_community_exact : |
| 8029 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8030 | } |
| 8031 | |
| 8032 | DEFUN (show_ip_bgp_community, |
| 8033 | show_ip_bgp_community_cmd, |
| 8034 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8035 | SHOW_STR |
| 8036 | IP_STR |
| 8037 | BGP_STR |
| 8038 | "Display routes matching the communities\n" |
| 8039 | "community number\n" |
| 8040 | "Do not send outside local AS (well-known community)\n" |
| 8041 | "Do not advertise to any peer (well-known community)\n" |
| 8042 | "Do not export to next AS (well-known community)\n") |
| 8043 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8044 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8045 | } |
| 8046 | |
| 8047 | ALIAS (show_ip_bgp_community, |
| 8048 | show_ip_bgp_community2_cmd, |
| 8049 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8050 | SHOW_STR |
| 8051 | IP_STR |
| 8052 | BGP_STR |
| 8053 | "Display routes matching the communities\n" |
| 8054 | "community number\n" |
| 8055 | "Do not send outside local AS (well-known community)\n" |
| 8056 | "Do not advertise to any peer (well-known community)\n" |
| 8057 | "Do not export to next AS (well-known community)\n" |
| 8058 | "community number\n" |
| 8059 | "Do not send outside local AS (well-known community)\n" |
| 8060 | "Do not advertise to any peer (well-known community)\n" |
| 8061 | "Do not export to next AS (well-known community)\n") |
| 8062 | |
| 8063 | ALIAS (show_ip_bgp_community, |
| 8064 | show_ip_bgp_community3_cmd, |
| 8065 | "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)", |
| 8066 | SHOW_STR |
| 8067 | IP_STR |
| 8068 | BGP_STR |
| 8069 | "Display routes matching the communities\n" |
| 8070 | "community number\n" |
| 8071 | "Do not send outside local AS (well-known community)\n" |
| 8072 | "Do not advertise to any peer (well-known community)\n" |
| 8073 | "Do not export to next AS (well-known community)\n" |
| 8074 | "community number\n" |
| 8075 | "Do not send outside local AS (well-known community)\n" |
| 8076 | "Do not advertise to any peer (well-known community)\n" |
| 8077 | "Do not export to next AS (well-known community)\n" |
| 8078 | "community number\n" |
| 8079 | "Do not send outside local AS (well-known community)\n" |
| 8080 | "Do not advertise to any peer (well-known community)\n" |
| 8081 | "Do not export to next AS (well-known community)\n") |
| 8082 | |
| 8083 | ALIAS (show_ip_bgp_community, |
| 8084 | show_ip_bgp_community4_cmd, |
| 8085 | "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)", |
| 8086 | SHOW_STR |
| 8087 | IP_STR |
| 8088 | BGP_STR |
| 8089 | "Display routes matching the communities\n" |
| 8090 | "community number\n" |
| 8091 | "Do not send outside local AS (well-known community)\n" |
| 8092 | "Do not advertise to any peer (well-known community)\n" |
| 8093 | "Do not export to next AS (well-known community)\n" |
| 8094 | "community number\n" |
| 8095 | "Do not send outside local AS (well-known community)\n" |
| 8096 | "Do not advertise to any peer (well-known community)\n" |
| 8097 | "Do not export to next AS (well-known community)\n" |
| 8098 | "community number\n" |
| 8099 | "Do not send outside local AS (well-known community)\n" |
| 8100 | "Do not advertise to any peer (well-known community)\n" |
| 8101 | "Do not export to next AS (well-known community)\n" |
| 8102 | "community number\n" |
| 8103 | "Do not send outside local AS (well-known community)\n" |
| 8104 | "Do not advertise to any peer (well-known community)\n" |
| 8105 | "Do not export to next AS (well-known community)\n") |
| 8106 | |
| 8107 | DEFUN (show_ip_bgp_ipv4_community, |
| 8108 | show_ip_bgp_ipv4_community_cmd, |
| 8109 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 8110 | SHOW_STR |
| 8111 | IP_STR |
| 8112 | BGP_STR |
| 8113 | "Address family\n" |
| 8114 | "Address Family modifier\n" |
| 8115 | "Address Family modifier\n" |
| 8116 | "Display routes matching the communities\n" |
| 8117 | "community number\n" |
| 8118 | "Do not send outside local AS (well-known community)\n" |
| 8119 | "Do not advertise to any peer (well-known community)\n" |
| 8120 | "Do not export to next AS (well-known community)\n") |
| 8121 | { |
| 8122 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8123 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8124 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8125 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8126 | } |
| 8127 | |
| 8128 | ALIAS (show_ip_bgp_ipv4_community, |
| 8129 | show_ip_bgp_ipv4_community2_cmd, |
| 8130 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8131 | SHOW_STR |
| 8132 | IP_STR |
| 8133 | BGP_STR |
| 8134 | "Address family\n" |
| 8135 | "Address Family modifier\n" |
| 8136 | "Address Family modifier\n" |
| 8137 | "Display routes matching the communities\n" |
| 8138 | "community number\n" |
| 8139 | "Do not send outside local AS (well-known community)\n" |
| 8140 | "Do not advertise to any peer (well-known community)\n" |
| 8141 | "Do not export to next AS (well-known community)\n" |
| 8142 | "community number\n" |
| 8143 | "Do not send outside local AS (well-known community)\n" |
| 8144 | "Do not advertise to any peer (well-known community)\n" |
| 8145 | "Do not export to next AS (well-known community)\n") |
| 8146 | |
| 8147 | ALIAS (show_ip_bgp_ipv4_community, |
| 8148 | show_ip_bgp_ipv4_community3_cmd, |
| 8149 | "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)", |
| 8150 | SHOW_STR |
| 8151 | IP_STR |
| 8152 | BGP_STR |
| 8153 | "Address family\n" |
| 8154 | "Address Family modifier\n" |
| 8155 | "Address Family modifier\n" |
| 8156 | "Display routes matching the communities\n" |
| 8157 | "community number\n" |
| 8158 | "Do not send outside local AS (well-known community)\n" |
| 8159 | "Do not advertise to any peer (well-known community)\n" |
| 8160 | "Do not export to next AS (well-known community)\n" |
| 8161 | "community number\n" |
| 8162 | "Do not send outside local AS (well-known community)\n" |
| 8163 | "Do not advertise to any peer (well-known community)\n" |
| 8164 | "Do not export to next AS (well-known community)\n" |
| 8165 | "community number\n" |
| 8166 | "Do not send outside local AS (well-known community)\n" |
| 8167 | "Do not advertise to any peer (well-known community)\n" |
| 8168 | "Do not export to next AS (well-known community)\n") |
| 8169 | |
| 8170 | ALIAS (show_ip_bgp_ipv4_community, |
| 8171 | show_ip_bgp_ipv4_community4_cmd, |
| 8172 | "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)", |
| 8173 | SHOW_STR |
| 8174 | IP_STR |
| 8175 | BGP_STR |
| 8176 | "Address family\n" |
| 8177 | "Address Family modifier\n" |
| 8178 | "Address Family modifier\n" |
| 8179 | "Display routes matching the communities\n" |
| 8180 | "community number\n" |
| 8181 | "Do not send outside local AS (well-known community)\n" |
| 8182 | "Do not advertise to any peer (well-known community)\n" |
| 8183 | "Do not export to next AS (well-known community)\n" |
| 8184 | "community number\n" |
| 8185 | "Do not send outside local AS (well-known community)\n" |
| 8186 | "Do not advertise to any peer (well-known community)\n" |
| 8187 | "Do not export to next AS (well-known community)\n" |
| 8188 | "community number\n" |
| 8189 | "Do not send outside local AS (well-known community)\n" |
| 8190 | "Do not advertise to any peer (well-known community)\n" |
| 8191 | "Do not export to next AS (well-known community)\n" |
| 8192 | "community number\n" |
| 8193 | "Do not send outside local AS (well-known community)\n" |
| 8194 | "Do not advertise to any peer (well-known community)\n" |
| 8195 | "Do not export to next AS (well-known community)\n") |
| 8196 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8197 | DEFUN (show_bgp_view_afi_safi_community_all, |
| 8198 | show_bgp_view_afi_safi_community_all_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8199 | "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community", |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8200 | SHOW_STR |
| 8201 | BGP_STR |
| 8202 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8203 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8204 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8205 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8206 | "Address Family modifier\n" |
| 8207 | "Address Family modifier\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8208 | "Display routes matching the communities\n") |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8209 | { |
| 8210 | int afi; |
| 8211 | int safi; |
| 8212 | struct bgp *bgp; |
| 8213 | |
| 8214 | /* BGP structure lookup. */ |
| 8215 | bgp = bgp_lookup_by_name (argv[0]); |
| 8216 | if (bgp == NULL) |
| 8217 | { |
| 8218 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 8219 | return CMD_WARNING; |
| 8220 | } |
| 8221 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8222 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 8223 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8224 | return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL); |
| 8225 | } |
| 8226 | |
| 8227 | DEFUN (show_bgp_view_afi_safi_community, |
| 8228 | show_bgp_view_afi_safi_community_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8229 | "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] | 8230 | SHOW_STR |
| 8231 | BGP_STR |
| 8232 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8233 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8234 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8235 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8236 | "Address family modifier\n" |
| 8237 | "Address family modifier\n" |
| 8238 | "Display routes matching the communities\n" |
| 8239 | "community number\n" |
| 8240 | "Do not send outside local AS (well-known community)\n" |
| 8241 | "Do not advertise to any peer (well-known community)\n" |
| 8242 | "Do not export to next AS (well-known community)\n") |
| 8243 | { |
| 8244 | int afi; |
| 8245 | int safi; |
| 8246 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8247 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 8248 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 8249 | 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] | 8250 | } |
| 8251 | |
| 8252 | ALIAS (show_bgp_view_afi_safi_community, |
| 8253 | show_bgp_view_afi_safi_community2_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8254 | "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] | 8255 | SHOW_STR |
| 8256 | BGP_STR |
| 8257 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8258 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8259 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8260 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8261 | "Address family modifier\n" |
| 8262 | "Address family modifier\n" |
| 8263 | "Display routes matching the communities\n" |
| 8264 | "community number\n" |
| 8265 | "Do not send outside local AS (well-known community)\n" |
| 8266 | "Do not advertise to any peer (well-known community)\n" |
| 8267 | "Do not export to next AS (well-known community)\n" |
| 8268 | "community number\n" |
| 8269 | "Do not send outside local AS (well-known community)\n" |
| 8270 | "Do not advertise to any peer (well-known community)\n" |
| 8271 | "Do not export to next AS (well-known community)\n") |
| 8272 | |
| 8273 | ALIAS (show_bgp_view_afi_safi_community, |
| 8274 | show_bgp_view_afi_safi_community3_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8275 | "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] | 8276 | SHOW_STR |
| 8277 | BGP_STR |
| 8278 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8279 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8280 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8281 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8282 | "Address family modifier\n" |
| 8283 | "Address family modifier\n" |
| 8284 | "Display routes matching the communities\n" |
| 8285 | "community number\n" |
| 8286 | "Do not send outside local AS (well-known community)\n" |
| 8287 | "Do not advertise to any peer (well-known community)\n" |
| 8288 | "Do not export to next AS (well-known community)\n" |
| 8289 | "community number\n" |
| 8290 | "Do not send outside local AS (well-known community)\n" |
| 8291 | "Do not advertise to any peer (well-known community)\n" |
| 8292 | "Do not export to next AS (well-known community)\n" |
| 8293 | "community number\n" |
| 8294 | "Do not send outside local AS (well-known community)\n" |
| 8295 | "Do not advertise to any peer (well-known community)\n" |
| 8296 | "Do not export to next AS (well-known community)\n") |
| 8297 | |
| 8298 | ALIAS (show_bgp_view_afi_safi_community, |
| 8299 | show_bgp_view_afi_safi_community4_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8300 | "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] | 8301 | SHOW_STR |
| 8302 | BGP_STR |
| 8303 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 8304 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8305 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8306 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8307 | "Address family modifier\n" |
| 8308 | "Address family modifier\n" |
| 8309 | "Display routes matching the communities\n" |
| 8310 | "community number\n" |
| 8311 | "Do not send outside local AS (well-known community)\n" |
| 8312 | "Do not advertise to any peer (well-known community)\n" |
| 8313 | "Do not export to next AS (well-known community)\n" |
| 8314 | "community number\n" |
| 8315 | "Do not send outside local AS (well-known community)\n" |
| 8316 | "Do not advertise to any peer (well-known community)\n" |
| 8317 | "Do not export to next AS (well-known community)\n" |
| 8318 | "community number\n" |
| 8319 | "Do not send outside local AS (well-known community)\n" |
| 8320 | "Do not advertise to any peer (well-known community)\n" |
| 8321 | "Do not export to next AS (well-known community)\n" |
| 8322 | "community number\n" |
| 8323 | "Do not send outside local AS (well-known community)\n" |
| 8324 | "Do not advertise to any peer (well-known community)\n" |
| 8325 | "Do not export to next AS (well-known community)\n") |
| 8326 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8327 | DEFUN (show_ip_bgp_community_exact, |
| 8328 | show_ip_bgp_community_exact_cmd, |
| 8329 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8330 | SHOW_STR |
| 8331 | IP_STR |
| 8332 | BGP_STR |
| 8333 | "Display routes matching the communities\n" |
| 8334 | "community number\n" |
| 8335 | "Do not send outside local AS (well-known community)\n" |
| 8336 | "Do not advertise to any peer (well-known community)\n" |
| 8337 | "Do not export to next AS (well-known community)\n" |
| 8338 | "Exact match of the communities") |
| 8339 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8340 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8341 | } |
| 8342 | |
| 8343 | ALIAS (show_ip_bgp_community_exact, |
| 8344 | show_ip_bgp_community2_exact_cmd, |
| 8345 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8346 | SHOW_STR |
| 8347 | IP_STR |
| 8348 | BGP_STR |
| 8349 | "Display routes matching the communities\n" |
| 8350 | "community number\n" |
| 8351 | "Do not send outside local AS (well-known community)\n" |
| 8352 | "Do not advertise to any peer (well-known community)\n" |
| 8353 | "Do not export to next AS (well-known community)\n" |
| 8354 | "community number\n" |
| 8355 | "Do not send outside local AS (well-known community)\n" |
| 8356 | "Do not advertise to any peer (well-known community)\n" |
| 8357 | "Do not export to next AS (well-known community)\n" |
| 8358 | "Exact match of the communities") |
| 8359 | |
| 8360 | ALIAS (show_ip_bgp_community_exact, |
| 8361 | show_ip_bgp_community3_exact_cmd, |
| 8362 | "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", |
| 8363 | SHOW_STR |
| 8364 | IP_STR |
| 8365 | BGP_STR |
| 8366 | "Display routes matching the communities\n" |
| 8367 | "community number\n" |
| 8368 | "Do not send outside local AS (well-known community)\n" |
| 8369 | "Do not advertise to any peer (well-known community)\n" |
| 8370 | "Do not export to next AS (well-known community)\n" |
| 8371 | "community number\n" |
| 8372 | "Do not send outside local AS (well-known community)\n" |
| 8373 | "Do not advertise to any peer (well-known community)\n" |
| 8374 | "Do not export to next AS (well-known community)\n" |
| 8375 | "community number\n" |
| 8376 | "Do not send outside local AS (well-known community)\n" |
| 8377 | "Do not advertise to any peer (well-known community)\n" |
| 8378 | "Do not export to next AS (well-known community)\n" |
| 8379 | "Exact match of the communities") |
| 8380 | |
| 8381 | ALIAS (show_ip_bgp_community_exact, |
| 8382 | show_ip_bgp_community4_exact_cmd, |
| 8383 | "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", |
| 8384 | SHOW_STR |
| 8385 | IP_STR |
| 8386 | BGP_STR |
| 8387 | "Display routes matching the communities\n" |
| 8388 | "community number\n" |
| 8389 | "Do not send outside local AS (well-known community)\n" |
| 8390 | "Do not advertise to any peer (well-known community)\n" |
| 8391 | "Do not export to next AS (well-known community)\n" |
| 8392 | "community number\n" |
| 8393 | "Do not send outside local AS (well-known community)\n" |
| 8394 | "Do not advertise to any peer (well-known community)\n" |
| 8395 | "Do not export to next AS (well-known community)\n" |
| 8396 | "community number\n" |
| 8397 | "Do not send outside local AS (well-known community)\n" |
| 8398 | "Do not advertise to any peer (well-known community)\n" |
| 8399 | "Do not export to next AS (well-known community)\n" |
| 8400 | "community number\n" |
| 8401 | "Do not send outside local AS (well-known community)\n" |
| 8402 | "Do not advertise to any peer (well-known community)\n" |
| 8403 | "Do not export to next AS (well-known community)\n" |
| 8404 | "Exact match of the communities") |
| 8405 | |
| 8406 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 8407 | show_ip_bgp_ipv4_community_exact_cmd, |
| 8408 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8409 | SHOW_STR |
| 8410 | IP_STR |
| 8411 | BGP_STR |
| 8412 | "Address family\n" |
| 8413 | "Address Family modifier\n" |
| 8414 | "Address Family modifier\n" |
| 8415 | "Display routes matching the communities\n" |
| 8416 | "community number\n" |
| 8417 | "Do not send outside local AS (well-known community)\n" |
| 8418 | "Do not advertise to any peer (well-known community)\n" |
| 8419 | "Do not export to next AS (well-known community)\n" |
| 8420 | "Exact match of the communities") |
| 8421 | { |
| 8422 | if (strncmp (argv[0], "m", 1) == 0) |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8423 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8424 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8425 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8426 | } |
| 8427 | |
| 8428 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8429 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 8430 | "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", |
| 8431 | SHOW_STR |
| 8432 | IP_STR |
| 8433 | BGP_STR |
| 8434 | "Address family\n" |
| 8435 | "Address Family modifier\n" |
| 8436 | "Address Family modifier\n" |
| 8437 | "Display routes matching the communities\n" |
| 8438 | "community number\n" |
| 8439 | "Do not send outside local AS (well-known community)\n" |
| 8440 | "Do not advertise to any peer (well-known community)\n" |
| 8441 | "Do not export to next AS (well-known community)\n" |
| 8442 | "community number\n" |
| 8443 | "Do not send outside local AS (well-known community)\n" |
| 8444 | "Do not advertise to any peer (well-known community)\n" |
| 8445 | "Do not export to next AS (well-known community)\n" |
| 8446 | "Exact match of the communities") |
| 8447 | |
| 8448 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8449 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 8450 | "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", |
| 8451 | SHOW_STR |
| 8452 | IP_STR |
| 8453 | BGP_STR |
| 8454 | "Address family\n" |
| 8455 | "Address Family modifier\n" |
| 8456 | "Address Family modifier\n" |
| 8457 | "Display routes matching the communities\n" |
| 8458 | "community number\n" |
| 8459 | "Do not send outside local AS (well-known community)\n" |
| 8460 | "Do not advertise to any peer (well-known community)\n" |
| 8461 | "Do not export to next AS (well-known community)\n" |
| 8462 | "community number\n" |
| 8463 | "Do not send outside local AS (well-known community)\n" |
| 8464 | "Do not advertise to any peer (well-known community)\n" |
| 8465 | "Do not export to next AS (well-known community)\n" |
| 8466 | "community number\n" |
| 8467 | "Do not send outside local AS (well-known community)\n" |
| 8468 | "Do not advertise to any peer (well-known community)\n" |
| 8469 | "Do not export to next AS (well-known community)\n" |
| 8470 | "Exact match of the communities") |
| 8471 | |
| 8472 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 8473 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 8474 | "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", |
| 8475 | SHOW_STR |
| 8476 | IP_STR |
| 8477 | BGP_STR |
| 8478 | "Address family\n" |
| 8479 | "Address Family modifier\n" |
| 8480 | "Address Family modifier\n" |
| 8481 | "Display routes matching the communities\n" |
| 8482 | "community number\n" |
| 8483 | "Do not send outside local AS (well-known community)\n" |
| 8484 | "Do not advertise to any peer (well-known community)\n" |
| 8485 | "Do not export to next AS (well-known community)\n" |
| 8486 | "community number\n" |
| 8487 | "Do not send outside local AS (well-known community)\n" |
| 8488 | "Do not advertise to any peer (well-known community)\n" |
| 8489 | "Do not export to next AS (well-known community)\n" |
| 8490 | "community number\n" |
| 8491 | "Do not send outside local AS (well-known community)\n" |
| 8492 | "Do not advertise to any peer (well-known community)\n" |
| 8493 | "Do not export to next AS (well-known community)\n" |
| 8494 | "community number\n" |
| 8495 | "Do not send outside local AS (well-known community)\n" |
| 8496 | "Do not advertise to any peer (well-known community)\n" |
| 8497 | "Do not export to next AS (well-known community)\n" |
| 8498 | "Exact match of the communities") |
| 8499 | |
| 8500 | #ifdef HAVE_IPV6 |
| 8501 | DEFUN (show_bgp_community, |
| 8502 | show_bgp_community_cmd, |
| 8503 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8504 | SHOW_STR |
| 8505 | BGP_STR |
| 8506 | "Display routes matching the communities\n" |
| 8507 | "community number\n" |
| 8508 | "Do not send outside local AS (well-known community)\n" |
| 8509 | "Do not advertise to any peer (well-known community)\n" |
| 8510 | "Do not export to next AS (well-known community)\n") |
| 8511 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8512 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8513 | } |
| 8514 | |
| 8515 | ALIAS (show_bgp_community, |
| 8516 | show_bgp_ipv6_community_cmd, |
| 8517 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 8518 | SHOW_STR |
| 8519 | BGP_STR |
| 8520 | "Address family\n" |
| 8521 | "Display routes matching the communities\n" |
| 8522 | "community number\n" |
| 8523 | "Do not send outside local AS (well-known community)\n" |
| 8524 | "Do not advertise to any peer (well-known community)\n" |
| 8525 | "Do not export to next AS (well-known community)\n") |
| 8526 | |
| 8527 | ALIAS (show_bgp_community, |
| 8528 | show_bgp_community2_cmd, |
| 8529 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8530 | SHOW_STR |
| 8531 | BGP_STR |
| 8532 | "Display routes matching the communities\n" |
| 8533 | "community number\n" |
| 8534 | "Do not send outside local AS (well-known community)\n" |
| 8535 | "Do not advertise to any peer (well-known community)\n" |
| 8536 | "Do not export to next AS (well-known community)\n" |
| 8537 | "community number\n" |
| 8538 | "Do not send outside local AS (well-known community)\n" |
| 8539 | "Do not advertise to any peer (well-known community)\n" |
| 8540 | "Do not export to next AS (well-known community)\n") |
| 8541 | |
| 8542 | ALIAS (show_bgp_community, |
| 8543 | show_bgp_ipv6_community2_cmd, |
| 8544 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8545 | SHOW_STR |
| 8546 | BGP_STR |
| 8547 | "Address family\n" |
| 8548 | "Display routes matching the communities\n" |
| 8549 | "community number\n" |
| 8550 | "Do not send outside local AS (well-known community)\n" |
| 8551 | "Do not advertise to any peer (well-known community)\n" |
| 8552 | "Do not export to next AS (well-known community)\n" |
| 8553 | "community number\n" |
| 8554 | "Do not send outside local AS (well-known community)\n" |
| 8555 | "Do not advertise to any peer (well-known community)\n" |
| 8556 | "Do not export to next AS (well-known community)\n") |
| 8557 | |
| 8558 | ALIAS (show_bgp_community, |
| 8559 | show_bgp_community3_cmd, |
| 8560 | "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)", |
| 8561 | SHOW_STR |
| 8562 | BGP_STR |
| 8563 | "Display routes matching the communities\n" |
| 8564 | "community number\n" |
| 8565 | "Do not send outside local AS (well-known community)\n" |
| 8566 | "Do not advertise to any peer (well-known community)\n" |
| 8567 | "Do not export to next AS (well-known community)\n" |
| 8568 | "community number\n" |
| 8569 | "Do not send outside local AS (well-known community)\n" |
| 8570 | "Do not advertise to any peer (well-known community)\n" |
| 8571 | "Do not export to next AS (well-known community)\n" |
| 8572 | "community number\n" |
| 8573 | "Do not send outside local AS (well-known community)\n" |
| 8574 | "Do not advertise to any peer (well-known community)\n" |
| 8575 | "Do not export to next AS (well-known community)\n") |
| 8576 | |
| 8577 | ALIAS (show_bgp_community, |
| 8578 | show_bgp_ipv6_community3_cmd, |
| 8579 | "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)", |
| 8580 | SHOW_STR |
| 8581 | BGP_STR |
| 8582 | "Address family\n" |
| 8583 | "Display routes matching the communities\n" |
| 8584 | "community number\n" |
| 8585 | "Do not send outside local AS (well-known community)\n" |
| 8586 | "Do not advertise to any peer (well-known community)\n" |
| 8587 | "Do not export to next AS (well-known community)\n" |
| 8588 | "community number\n" |
| 8589 | "Do not send outside local AS (well-known community)\n" |
| 8590 | "Do not advertise to any peer (well-known community)\n" |
| 8591 | "Do not export to next AS (well-known community)\n" |
| 8592 | "community number\n" |
| 8593 | "Do not send outside local AS (well-known community)\n" |
| 8594 | "Do not advertise to any peer (well-known community)\n" |
| 8595 | "Do not export to next AS (well-known community)\n") |
| 8596 | |
| 8597 | ALIAS (show_bgp_community, |
| 8598 | show_bgp_community4_cmd, |
| 8599 | "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)", |
| 8600 | SHOW_STR |
| 8601 | BGP_STR |
| 8602 | "Display routes matching the communities\n" |
| 8603 | "community number\n" |
| 8604 | "Do not send outside local AS (well-known community)\n" |
| 8605 | "Do not advertise to any peer (well-known community)\n" |
| 8606 | "Do not export to next AS (well-known community)\n" |
| 8607 | "community number\n" |
| 8608 | "Do not send outside local AS (well-known community)\n" |
| 8609 | "Do not advertise to any peer (well-known community)\n" |
| 8610 | "Do not export to next AS (well-known community)\n" |
| 8611 | "community number\n" |
| 8612 | "Do not send outside local AS (well-known community)\n" |
| 8613 | "Do not advertise to any peer (well-known community)\n" |
| 8614 | "Do not export to next AS (well-known community)\n" |
| 8615 | "community number\n" |
| 8616 | "Do not send outside local AS (well-known community)\n" |
| 8617 | "Do not advertise to any peer (well-known community)\n" |
| 8618 | "Do not export to next AS (well-known community)\n") |
| 8619 | |
| 8620 | ALIAS (show_bgp_community, |
| 8621 | show_bgp_ipv6_community4_cmd, |
| 8622 | "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)", |
| 8623 | SHOW_STR |
| 8624 | BGP_STR |
| 8625 | "Address family\n" |
| 8626 | "Display routes matching the communities\n" |
| 8627 | "community number\n" |
| 8628 | "Do not send outside local AS (well-known community)\n" |
| 8629 | "Do not advertise to any peer (well-known community)\n" |
| 8630 | "Do not export to next AS (well-known community)\n" |
| 8631 | "community number\n" |
| 8632 | "Do not send outside local AS (well-known community)\n" |
| 8633 | "Do not advertise to any peer (well-known community)\n" |
| 8634 | "Do not export to next AS (well-known community)\n" |
| 8635 | "community number\n" |
| 8636 | "Do not send outside local AS (well-known community)\n" |
| 8637 | "Do not advertise to any peer (well-known community)\n" |
| 8638 | "Do not export to next AS (well-known community)\n" |
| 8639 | "community number\n" |
| 8640 | "Do not send outside local AS (well-known community)\n" |
| 8641 | "Do not advertise to any peer (well-known community)\n" |
| 8642 | "Do not export to next AS (well-known community)\n") |
| 8643 | |
| 8644 | /* old command */ |
| 8645 | DEFUN (show_ipv6_bgp_community, |
| 8646 | show_ipv6_bgp_community_cmd, |
| 8647 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8648 | SHOW_STR |
| 8649 | IPV6_STR |
| 8650 | BGP_STR |
| 8651 | "Display routes matching the communities\n" |
| 8652 | "community number\n" |
| 8653 | "Do not send outside local AS (well-known community)\n" |
| 8654 | "Do not advertise to any peer (well-known community)\n" |
| 8655 | "Do not export to next AS (well-known community)\n") |
| 8656 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8657 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8658 | } |
| 8659 | |
| 8660 | /* old command */ |
| 8661 | ALIAS (show_ipv6_bgp_community, |
| 8662 | show_ipv6_bgp_community2_cmd, |
| 8663 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8664 | SHOW_STR |
| 8665 | IPV6_STR |
| 8666 | BGP_STR |
| 8667 | "Display routes matching the communities\n" |
| 8668 | "community number\n" |
| 8669 | "Do not send outside local AS (well-known community)\n" |
| 8670 | "Do not advertise to any peer (well-known community)\n" |
| 8671 | "Do not export to next AS (well-known community)\n" |
| 8672 | "community number\n" |
| 8673 | "Do not send outside local AS (well-known community)\n" |
| 8674 | "Do not advertise to any peer (well-known community)\n" |
| 8675 | "Do not export to next AS (well-known community)\n") |
| 8676 | |
| 8677 | /* old command */ |
| 8678 | ALIAS (show_ipv6_bgp_community, |
| 8679 | show_ipv6_bgp_community3_cmd, |
| 8680 | "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)", |
| 8681 | SHOW_STR |
| 8682 | IPV6_STR |
| 8683 | BGP_STR |
| 8684 | "Display routes matching the communities\n" |
| 8685 | "community number\n" |
| 8686 | "Do not send outside local AS (well-known community)\n" |
| 8687 | "Do not advertise to any peer (well-known community)\n" |
| 8688 | "Do not export to next AS (well-known community)\n" |
| 8689 | "community number\n" |
| 8690 | "Do not send outside local AS (well-known community)\n" |
| 8691 | "Do not advertise to any peer (well-known community)\n" |
| 8692 | "Do not export to next AS (well-known community)\n" |
| 8693 | "community number\n" |
| 8694 | "Do not send outside local AS (well-known community)\n" |
| 8695 | "Do not advertise to any peer (well-known community)\n" |
| 8696 | "Do not export to next AS (well-known community)\n") |
| 8697 | |
| 8698 | /* old command */ |
| 8699 | ALIAS (show_ipv6_bgp_community, |
| 8700 | show_ipv6_bgp_community4_cmd, |
| 8701 | "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)", |
| 8702 | SHOW_STR |
| 8703 | IPV6_STR |
| 8704 | BGP_STR |
| 8705 | "Display routes matching the communities\n" |
| 8706 | "community number\n" |
| 8707 | "Do not send outside local AS (well-known community)\n" |
| 8708 | "Do not advertise to any peer (well-known community)\n" |
| 8709 | "Do not export to next AS (well-known community)\n" |
| 8710 | "community number\n" |
| 8711 | "Do not send outside local AS (well-known community)\n" |
| 8712 | "Do not advertise to any peer (well-known community)\n" |
| 8713 | "Do not export to next AS (well-known community)\n" |
| 8714 | "community number\n" |
| 8715 | "Do not send outside local AS (well-known community)\n" |
| 8716 | "Do not advertise to any peer (well-known community)\n" |
| 8717 | "Do not export to next AS (well-known community)\n" |
| 8718 | "community number\n" |
| 8719 | "Do not send outside local AS (well-known community)\n" |
| 8720 | "Do not advertise to any peer (well-known community)\n" |
| 8721 | "Do not export to next AS (well-known community)\n") |
| 8722 | |
| 8723 | DEFUN (show_bgp_community_exact, |
| 8724 | show_bgp_community_exact_cmd, |
| 8725 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8726 | SHOW_STR |
| 8727 | BGP_STR |
| 8728 | "Display routes matching the communities\n" |
| 8729 | "community number\n" |
| 8730 | "Do not send outside local AS (well-known community)\n" |
| 8731 | "Do not advertise to any peer (well-known community)\n" |
| 8732 | "Do not export to next AS (well-known community)\n" |
| 8733 | "Exact match of the communities") |
| 8734 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8735 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8736 | } |
| 8737 | |
| 8738 | ALIAS (show_bgp_community_exact, |
| 8739 | show_bgp_ipv6_community_exact_cmd, |
| 8740 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8741 | SHOW_STR |
| 8742 | BGP_STR |
| 8743 | "Address family\n" |
| 8744 | "Display routes matching the communities\n" |
| 8745 | "community number\n" |
| 8746 | "Do not send outside local AS (well-known community)\n" |
| 8747 | "Do not advertise to any peer (well-known community)\n" |
| 8748 | "Do not export to next AS (well-known community)\n" |
| 8749 | "Exact match of the communities") |
| 8750 | |
| 8751 | ALIAS (show_bgp_community_exact, |
| 8752 | show_bgp_community2_exact_cmd, |
| 8753 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8754 | SHOW_STR |
| 8755 | BGP_STR |
| 8756 | "Display routes matching the communities\n" |
| 8757 | "community number\n" |
| 8758 | "Do not send outside local AS (well-known community)\n" |
| 8759 | "Do not advertise to any peer (well-known community)\n" |
| 8760 | "Do not export to next AS (well-known community)\n" |
| 8761 | "community number\n" |
| 8762 | "Do not send outside local AS (well-known community)\n" |
| 8763 | "Do not advertise to any peer (well-known community)\n" |
| 8764 | "Do not export to next AS (well-known community)\n" |
| 8765 | "Exact match of the communities") |
| 8766 | |
| 8767 | ALIAS (show_bgp_community_exact, |
| 8768 | show_bgp_ipv6_community2_exact_cmd, |
| 8769 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8770 | SHOW_STR |
| 8771 | BGP_STR |
| 8772 | "Address family\n" |
| 8773 | "Display routes matching the communities\n" |
| 8774 | "community number\n" |
| 8775 | "Do not send outside local AS (well-known community)\n" |
| 8776 | "Do not advertise to any peer (well-known community)\n" |
| 8777 | "Do not export to next AS (well-known community)\n" |
| 8778 | "community number\n" |
| 8779 | "Do not send outside local AS (well-known community)\n" |
| 8780 | "Do not advertise to any peer (well-known community)\n" |
| 8781 | "Do not export to next AS (well-known community)\n" |
| 8782 | "Exact match of the communities") |
| 8783 | |
| 8784 | ALIAS (show_bgp_community_exact, |
| 8785 | show_bgp_community3_exact_cmd, |
| 8786 | "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", |
| 8787 | SHOW_STR |
| 8788 | BGP_STR |
| 8789 | "Display routes matching the communities\n" |
| 8790 | "community number\n" |
| 8791 | "Do not send outside local AS (well-known community)\n" |
| 8792 | "Do not advertise to any peer (well-known community)\n" |
| 8793 | "Do not export to next AS (well-known community)\n" |
| 8794 | "community number\n" |
| 8795 | "Do not send outside local AS (well-known community)\n" |
| 8796 | "Do not advertise to any peer (well-known community)\n" |
| 8797 | "Do not export to next AS (well-known community)\n" |
| 8798 | "community number\n" |
| 8799 | "Do not send outside local AS (well-known community)\n" |
| 8800 | "Do not advertise to any peer (well-known community)\n" |
| 8801 | "Do not export to next AS (well-known community)\n" |
| 8802 | "Exact match of the communities") |
| 8803 | |
| 8804 | ALIAS (show_bgp_community_exact, |
| 8805 | show_bgp_ipv6_community3_exact_cmd, |
| 8806 | "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", |
| 8807 | SHOW_STR |
| 8808 | BGP_STR |
| 8809 | "Address family\n" |
| 8810 | "Display routes matching the communities\n" |
| 8811 | "community number\n" |
| 8812 | "Do not send outside local AS (well-known community)\n" |
| 8813 | "Do not advertise to any peer (well-known community)\n" |
| 8814 | "Do not export to next AS (well-known community)\n" |
| 8815 | "community number\n" |
| 8816 | "Do not send outside local AS (well-known community)\n" |
| 8817 | "Do not advertise to any peer (well-known community)\n" |
| 8818 | "Do not export to next AS (well-known community)\n" |
| 8819 | "community number\n" |
| 8820 | "Do not send outside local AS (well-known community)\n" |
| 8821 | "Do not advertise to any peer (well-known community)\n" |
| 8822 | "Do not export to next AS (well-known community)\n" |
| 8823 | "Exact match of the communities") |
| 8824 | |
| 8825 | ALIAS (show_bgp_community_exact, |
| 8826 | show_bgp_community4_exact_cmd, |
| 8827 | "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", |
| 8828 | SHOW_STR |
| 8829 | BGP_STR |
| 8830 | "Display routes matching the communities\n" |
| 8831 | "community number\n" |
| 8832 | "Do not send outside local AS (well-known community)\n" |
| 8833 | "Do not advertise to any peer (well-known community)\n" |
| 8834 | "Do not export to next AS (well-known community)\n" |
| 8835 | "community number\n" |
| 8836 | "Do not send outside local AS (well-known community)\n" |
| 8837 | "Do not advertise to any peer (well-known community)\n" |
| 8838 | "Do not export to next AS (well-known community)\n" |
| 8839 | "community number\n" |
| 8840 | "Do not send outside local AS (well-known community)\n" |
| 8841 | "Do not advertise to any peer (well-known community)\n" |
| 8842 | "Do not export to next AS (well-known community)\n" |
| 8843 | "community number\n" |
| 8844 | "Do not send outside local AS (well-known community)\n" |
| 8845 | "Do not advertise to any peer (well-known community)\n" |
| 8846 | "Do not export to next AS (well-known community)\n" |
| 8847 | "Exact match of the communities") |
| 8848 | |
| 8849 | ALIAS (show_bgp_community_exact, |
| 8850 | show_bgp_ipv6_community4_exact_cmd, |
| 8851 | "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", |
| 8852 | SHOW_STR |
| 8853 | BGP_STR |
| 8854 | "Address family\n" |
| 8855 | "Display routes matching the communities\n" |
| 8856 | "community number\n" |
| 8857 | "Do not send outside local AS (well-known community)\n" |
| 8858 | "Do not advertise to any peer (well-known community)\n" |
| 8859 | "Do not export to next AS (well-known community)\n" |
| 8860 | "community number\n" |
| 8861 | "Do not send outside local AS (well-known community)\n" |
| 8862 | "Do not advertise to any peer (well-known community)\n" |
| 8863 | "Do not export to next AS (well-known community)\n" |
| 8864 | "community number\n" |
| 8865 | "Do not send outside local AS (well-known community)\n" |
| 8866 | "Do not advertise to any peer (well-known community)\n" |
| 8867 | "Do not export to next AS (well-known community)\n" |
| 8868 | "community number\n" |
| 8869 | "Do not send outside local AS (well-known community)\n" |
| 8870 | "Do not advertise to any peer (well-known community)\n" |
| 8871 | "Do not export to next AS (well-known community)\n" |
| 8872 | "Exact match of the communities") |
| 8873 | |
| 8874 | /* old command */ |
| 8875 | DEFUN (show_ipv6_bgp_community_exact, |
| 8876 | show_ipv6_bgp_community_exact_cmd, |
| 8877 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8878 | SHOW_STR |
| 8879 | IPV6_STR |
| 8880 | BGP_STR |
| 8881 | "Display routes matching the communities\n" |
| 8882 | "community number\n" |
| 8883 | "Do not send outside local AS (well-known community)\n" |
| 8884 | "Do not advertise to any peer (well-known community)\n" |
| 8885 | "Do not export to next AS (well-known community)\n" |
| 8886 | "Exact match of the communities") |
| 8887 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8888 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8889 | } |
| 8890 | |
| 8891 | /* old command */ |
| 8892 | ALIAS (show_ipv6_bgp_community_exact, |
| 8893 | show_ipv6_bgp_community2_exact_cmd, |
| 8894 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 8895 | SHOW_STR |
| 8896 | IPV6_STR |
| 8897 | BGP_STR |
| 8898 | "Display routes matching the communities\n" |
| 8899 | "community number\n" |
| 8900 | "Do not send outside local AS (well-known community)\n" |
| 8901 | "Do not advertise to any peer (well-known community)\n" |
| 8902 | "Do not export to next AS (well-known community)\n" |
| 8903 | "community number\n" |
| 8904 | "Do not send outside local AS (well-known community)\n" |
| 8905 | "Do not advertise to any peer (well-known community)\n" |
| 8906 | "Do not export to next AS (well-known community)\n" |
| 8907 | "Exact match of the communities") |
| 8908 | |
| 8909 | /* old command */ |
| 8910 | ALIAS (show_ipv6_bgp_community_exact, |
| 8911 | show_ipv6_bgp_community3_exact_cmd, |
| 8912 | "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", |
| 8913 | SHOW_STR |
| 8914 | IPV6_STR |
| 8915 | BGP_STR |
| 8916 | "Display routes matching the communities\n" |
| 8917 | "community number\n" |
| 8918 | "Do not send outside local AS (well-known community)\n" |
| 8919 | "Do not advertise to any peer (well-known community)\n" |
| 8920 | "Do not export to next AS (well-known community)\n" |
| 8921 | "community number\n" |
| 8922 | "Do not send outside local AS (well-known community)\n" |
| 8923 | "Do not advertise to any peer (well-known community)\n" |
| 8924 | "Do not export to next AS (well-known community)\n" |
| 8925 | "community number\n" |
| 8926 | "Do not send outside local AS (well-known community)\n" |
| 8927 | "Do not advertise to any peer (well-known community)\n" |
| 8928 | "Do not export to next AS (well-known community)\n" |
| 8929 | "Exact match of the communities") |
| 8930 | |
| 8931 | /* old command */ |
| 8932 | ALIAS (show_ipv6_bgp_community_exact, |
| 8933 | show_ipv6_bgp_community4_exact_cmd, |
| 8934 | "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", |
| 8935 | SHOW_STR |
| 8936 | IPV6_STR |
| 8937 | BGP_STR |
| 8938 | "Display routes matching the communities\n" |
| 8939 | "community number\n" |
| 8940 | "Do not send outside local AS (well-known community)\n" |
| 8941 | "Do not advertise to any peer (well-known community)\n" |
| 8942 | "Do not export to next AS (well-known community)\n" |
| 8943 | "community number\n" |
| 8944 | "Do not send outside local AS (well-known community)\n" |
| 8945 | "Do not advertise to any peer (well-known community)\n" |
| 8946 | "Do not export to next AS (well-known community)\n" |
| 8947 | "community number\n" |
| 8948 | "Do not send outside local AS (well-known community)\n" |
| 8949 | "Do not advertise to any peer (well-known community)\n" |
| 8950 | "Do not export to next AS (well-known community)\n" |
| 8951 | "community number\n" |
| 8952 | "Do not send outside local AS (well-known community)\n" |
| 8953 | "Do not advertise to any peer (well-known community)\n" |
| 8954 | "Do not export to next AS (well-known community)\n" |
| 8955 | "Exact match of the communities") |
| 8956 | |
| 8957 | /* old command */ |
| 8958 | DEFUN (show_ipv6_mbgp_community, |
| 8959 | show_ipv6_mbgp_community_cmd, |
| 8960 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 8961 | SHOW_STR |
| 8962 | IPV6_STR |
| 8963 | MBGP_STR |
| 8964 | "Display routes matching the communities\n" |
| 8965 | "community number\n" |
| 8966 | "Do not send outside local AS (well-known community)\n" |
| 8967 | "Do not advertise to any peer (well-known community)\n" |
| 8968 | "Do not export to next AS (well-known community)\n") |
| 8969 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 8970 | return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8971 | } |
| 8972 | |
| 8973 | /* old command */ |
| 8974 | ALIAS (show_ipv6_mbgp_community, |
| 8975 | show_ipv6_mbgp_community2_cmd, |
| 8976 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 8977 | SHOW_STR |
| 8978 | IPV6_STR |
| 8979 | MBGP_STR |
| 8980 | "Display routes matching the communities\n" |
| 8981 | "community number\n" |
| 8982 | "Do not send outside local AS (well-known community)\n" |
| 8983 | "Do not advertise to any peer (well-known community)\n" |
| 8984 | "Do not export to next AS (well-known community)\n" |
| 8985 | "community number\n" |
| 8986 | "Do not send outside local AS (well-known community)\n" |
| 8987 | "Do not advertise to any peer (well-known community)\n" |
| 8988 | "Do not export to next AS (well-known community)\n") |
| 8989 | |
| 8990 | /* old command */ |
| 8991 | ALIAS (show_ipv6_mbgp_community, |
| 8992 | show_ipv6_mbgp_community3_cmd, |
| 8993 | "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)", |
| 8994 | SHOW_STR |
| 8995 | IPV6_STR |
| 8996 | MBGP_STR |
| 8997 | "Display routes matching the communities\n" |
| 8998 | "community number\n" |
| 8999 | "Do not send outside local AS (well-known community)\n" |
| 9000 | "Do not advertise to any peer (well-known community)\n" |
| 9001 | "Do not export to next AS (well-known community)\n" |
| 9002 | "community number\n" |
| 9003 | "Do not send outside local AS (well-known community)\n" |
| 9004 | "Do not advertise to any peer (well-known community)\n" |
| 9005 | "Do not export to next AS (well-known community)\n" |
| 9006 | "community number\n" |
| 9007 | "Do not send outside local AS (well-known community)\n" |
| 9008 | "Do not advertise to any peer (well-known community)\n" |
| 9009 | "Do not export to next AS (well-known community)\n") |
| 9010 | |
| 9011 | /* old command */ |
| 9012 | ALIAS (show_ipv6_mbgp_community, |
| 9013 | show_ipv6_mbgp_community4_cmd, |
| 9014 | "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)", |
| 9015 | SHOW_STR |
| 9016 | IPV6_STR |
| 9017 | MBGP_STR |
| 9018 | "Display routes matching the communities\n" |
| 9019 | "community number\n" |
| 9020 | "Do not send outside local AS (well-known community)\n" |
| 9021 | "Do not advertise to any peer (well-known community)\n" |
| 9022 | "Do not export to next AS (well-known community)\n" |
| 9023 | "community number\n" |
| 9024 | "Do not send outside local AS (well-known community)\n" |
| 9025 | "Do not advertise to any peer (well-known community)\n" |
| 9026 | "Do not export to next AS (well-known community)\n" |
| 9027 | "community number\n" |
| 9028 | "Do not send outside local AS (well-known community)\n" |
| 9029 | "Do not advertise to any peer (well-known community)\n" |
| 9030 | "Do not export to next AS (well-known community)\n" |
| 9031 | "community number\n" |
| 9032 | "Do not send outside local AS (well-known community)\n" |
| 9033 | "Do not advertise to any peer (well-known community)\n" |
| 9034 | "Do not export to next AS (well-known community)\n") |
| 9035 | |
| 9036 | /* old command */ |
| 9037 | DEFUN (show_ipv6_mbgp_community_exact, |
| 9038 | show_ipv6_mbgp_community_exact_cmd, |
| 9039 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9040 | SHOW_STR |
| 9041 | IPV6_STR |
| 9042 | MBGP_STR |
| 9043 | "Display routes matching the communities\n" |
| 9044 | "community number\n" |
| 9045 | "Do not send outside local AS (well-known community)\n" |
| 9046 | "Do not advertise to any peer (well-known community)\n" |
| 9047 | "Do not export to next AS (well-known community)\n" |
| 9048 | "Exact match of the communities") |
| 9049 | { |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 9050 | return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9051 | } |
| 9052 | |
| 9053 | /* old command */ |
| 9054 | ALIAS (show_ipv6_mbgp_community_exact, |
| 9055 | show_ipv6_mbgp_community2_exact_cmd, |
| 9056 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 9057 | SHOW_STR |
| 9058 | IPV6_STR |
| 9059 | MBGP_STR |
| 9060 | "Display routes matching the communities\n" |
| 9061 | "community number\n" |
| 9062 | "Do not send outside local AS (well-known community)\n" |
| 9063 | "Do not advertise to any peer (well-known community)\n" |
| 9064 | "Do not export to next AS (well-known community)\n" |
| 9065 | "community number\n" |
| 9066 | "Do not send outside local AS (well-known community)\n" |
| 9067 | "Do not advertise to any peer (well-known community)\n" |
| 9068 | "Do not export to next AS (well-known community)\n" |
| 9069 | "Exact match of the communities") |
| 9070 | |
| 9071 | /* old command */ |
| 9072 | ALIAS (show_ipv6_mbgp_community_exact, |
| 9073 | show_ipv6_mbgp_community3_exact_cmd, |
| 9074 | "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", |
| 9075 | SHOW_STR |
| 9076 | IPV6_STR |
| 9077 | MBGP_STR |
| 9078 | "Display routes matching the communities\n" |
| 9079 | "community number\n" |
| 9080 | "Do not send outside local AS (well-known community)\n" |
| 9081 | "Do not advertise to any peer (well-known community)\n" |
| 9082 | "Do not export to next AS (well-known community)\n" |
| 9083 | "community number\n" |
| 9084 | "Do not send outside local AS (well-known community)\n" |
| 9085 | "Do not advertise to any peer (well-known community)\n" |
| 9086 | "Do not export to next AS (well-known community)\n" |
| 9087 | "community number\n" |
| 9088 | "Do not send outside local AS (well-known community)\n" |
| 9089 | "Do not advertise to any peer (well-known community)\n" |
| 9090 | "Do not export to next AS (well-known community)\n" |
| 9091 | "Exact match of the communities") |
| 9092 | |
| 9093 | /* old command */ |
| 9094 | ALIAS (show_ipv6_mbgp_community_exact, |
| 9095 | show_ipv6_mbgp_community4_exact_cmd, |
| 9096 | "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", |
| 9097 | SHOW_STR |
| 9098 | IPV6_STR |
| 9099 | MBGP_STR |
| 9100 | "Display routes matching the communities\n" |
| 9101 | "community number\n" |
| 9102 | "Do not send outside local AS (well-known community)\n" |
| 9103 | "Do not advertise to any peer (well-known community)\n" |
| 9104 | "Do not export to next AS (well-known community)\n" |
| 9105 | "community number\n" |
| 9106 | "Do not send outside local AS (well-known community)\n" |
| 9107 | "Do not advertise to any peer (well-known community)\n" |
| 9108 | "Do not export to next AS (well-known community)\n" |
| 9109 | "community number\n" |
| 9110 | "Do not send outside local AS (well-known community)\n" |
| 9111 | "Do not advertise to any peer (well-known community)\n" |
| 9112 | "Do not export to next AS (well-known community)\n" |
| 9113 | "community number\n" |
| 9114 | "Do not send outside local AS (well-known community)\n" |
| 9115 | "Do not advertise to any peer (well-known community)\n" |
| 9116 | "Do not export to next AS (well-known community)\n" |
| 9117 | "Exact match of the communities") |
| 9118 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9119 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9120 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9121 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
Michael Lambert | 4c9641b | 2010-07-22 13:20:55 -0400 | [diff] [blame] | 9122 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9123 | { |
| 9124 | struct community_list *list; |
| 9125 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9126 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9127 | if (list == NULL) |
| 9128 | { |
| 9129 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 9130 | VTY_NEWLINE); |
| 9131 | return CMD_WARNING; |
| 9132 | } |
| 9133 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9134 | return bgp_show (vty, NULL, afi, safi, |
| 9135 | (exact ? bgp_show_type_community_list_exact : |
| 9136 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9137 | } |
| 9138 | |
| 9139 | DEFUN (show_ip_bgp_community_list, |
| 9140 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9141 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9142 | SHOW_STR |
| 9143 | IP_STR |
| 9144 | BGP_STR |
| 9145 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9146 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9147 | "community-list name\n") |
| 9148 | { |
| 9149 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 9150 | } |
| 9151 | |
| 9152 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 9153 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9154 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9155 | SHOW_STR |
| 9156 | IP_STR |
| 9157 | BGP_STR |
| 9158 | "Address family\n" |
| 9159 | "Address Family modifier\n" |
| 9160 | "Address Family modifier\n" |
| 9161 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9162 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9163 | "community-list name\n") |
| 9164 | { |
| 9165 | if (strncmp (argv[0], "m", 1) == 0) |
| 9166 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 9167 | |
| 9168 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 9169 | } |
| 9170 | |
| 9171 | DEFUN (show_ip_bgp_community_list_exact, |
| 9172 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9173 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9174 | SHOW_STR |
| 9175 | IP_STR |
| 9176 | BGP_STR |
| 9177 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9178 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9179 | "community-list name\n" |
| 9180 | "Exact match of the communities\n") |
| 9181 | { |
| 9182 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 9183 | } |
| 9184 | |
| 9185 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 9186 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9187 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9188 | SHOW_STR |
| 9189 | IP_STR |
| 9190 | BGP_STR |
| 9191 | "Address family\n" |
| 9192 | "Address Family modifier\n" |
| 9193 | "Address Family modifier\n" |
| 9194 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9195 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9196 | "community-list name\n" |
| 9197 | "Exact match of the communities\n") |
| 9198 | { |
| 9199 | if (strncmp (argv[0], "m", 1) == 0) |
| 9200 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 9201 | |
| 9202 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 9203 | } |
| 9204 | |
| 9205 | #ifdef HAVE_IPV6 |
| 9206 | DEFUN (show_bgp_community_list, |
| 9207 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9208 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9209 | SHOW_STR |
| 9210 | BGP_STR |
| 9211 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9212 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9213 | "community-list name\n") |
| 9214 | { |
| 9215 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 9216 | } |
| 9217 | |
| 9218 | ALIAS (show_bgp_community_list, |
| 9219 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9220 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9221 | SHOW_STR |
| 9222 | BGP_STR |
| 9223 | "Address family\n" |
| 9224 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9225 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 9226 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9227 | |
| 9228 | /* old command */ |
| 9229 | DEFUN (show_ipv6_bgp_community_list, |
| 9230 | show_ipv6_bgp_community_list_cmd, |
| 9231 | "show ipv6 bgp community-list WORD", |
| 9232 | SHOW_STR |
| 9233 | IPV6_STR |
| 9234 | BGP_STR |
| 9235 | "Display routes matching the community-list\n" |
| 9236 | "community-list name\n") |
| 9237 | { |
| 9238 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 9239 | } |
| 9240 | |
| 9241 | /* old command */ |
| 9242 | DEFUN (show_ipv6_mbgp_community_list, |
| 9243 | show_ipv6_mbgp_community_list_cmd, |
| 9244 | "show ipv6 mbgp community-list WORD", |
| 9245 | SHOW_STR |
| 9246 | IPV6_STR |
| 9247 | MBGP_STR |
| 9248 | "Display routes matching the community-list\n" |
| 9249 | "community-list name\n") |
| 9250 | { |
| 9251 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 9252 | } |
| 9253 | |
| 9254 | DEFUN (show_bgp_community_list_exact, |
| 9255 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9256 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9257 | SHOW_STR |
| 9258 | BGP_STR |
| 9259 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9260 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9261 | "community-list name\n" |
| 9262 | "Exact match of the communities\n") |
| 9263 | { |
| 9264 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9265 | } |
| 9266 | |
| 9267 | ALIAS (show_bgp_community_list_exact, |
| 9268 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9269 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9270 | SHOW_STR |
| 9271 | BGP_STR |
| 9272 | "Address family\n" |
| 9273 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 9274 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9275 | "community-list name\n" |
| 9276 | "Exact match of the communities\n") |
| 9277 | |
| 9278 | /* old command */ |
| 9279 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 9280 | show_ipv6_bgp_community_list_exact_cmd, |
| 9281 | "show ipv6 bgp community-list WORD exact-match", |
| 9282 | SHOW_STR |
| 9283 | IPV6_STR |
| 9284 | BGP_STR |
| 9285 | "Display routes matching the community-list\n" |
| 9286 | "community-list name\n" |
| 9287 | "Exact match of the communities\n") |
| 9288 | { |
| 9289 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 9290 | } |
| 9291 | |
| 9292 | /* old command */ |
| 9293 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 9294 | show_ipv6_mbgp_community_list_exact_cmd, |
| 9295 | "show ipv6 mbgp community-list WORD exact-match", |
| 9296 | SHOW_STR |
| 9297 | IPV6_STR |
| 9298 | MBGP_STR |
| 9299 | "Display routes matching the community-list\n" |
| 9300 | "community-list name\n" |
| 9301 | "Exact match of the communities\n") |
| 9302 | { |
| 9303 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 9304 | } |
| 9305 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9306 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9307 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9308 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9309 | safi_t safi, enum bgp_show_type type) |
| 9310 | { |
| 9311 | int ret; |
| 9312 | struct prefix *p; |
| 9313 | |
| 9314 | p = prefix_new(); |
| 9315 | |
| 9316 | ret = str2prefix (prefix, p); |
| 9317 | if (! ret) |
| 9318 | { |
| 9319 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 9320 | return CMD_WARNING; |
| 9321 | } |
| 9322 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9323 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 9324 | prefix_free(p); |
| 9325 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9326 | } |
| 9327 | |
| 9328 | DEFUN (show_ip_bgp_prefix_longer, |
| 9329 | show_ip_bgp_prefix_longer_cmd, |
| 9330 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 9331 | SHOW_STR |
| 9332 | IP_STR |
| 9333 | BGP_STR |
| 9334 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9335 | "Display route and more specific routes\n") |
| 9336 | { |
| 9337 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9338 | bgp_show_type_prefix_longer); |
| 9339 | } |
| 9340 | |
| 9341 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 9342 | show_ip_bgp_flap_prefix_longer_cmd, |
| 9343 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 9344 | SHOW_STR |
| 9345 | IP_STR |
| 9346 | BGP_STR |
| 9347 | "Display flap statistics of routes\n" |
| 9348 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9349 | "Display route and more specific routes\n") |
| 9350 | { |
| 9351 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9352 | bgp_show_type_flap_prefix_longer); |
| 9353 | } |
| 9354 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9355 | ALIAS (show_ip_bgp_flap_prefix_longer, |
| 9356 | show_ip_bgp_damp_flap_prefix_longer_cmd, |
| 9357 | "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes", |
| 9358 | SHOW_STR |
| 9359 | IP_STR |
| 9360 | BGP_STR |
| 9361 | "Display detailed information about dampening\n" |
| 9362 | "Display flap statistics of routes\n" |
| 9363 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9364 | "Display route and more specific routes\n") |
| 9365 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9366 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 9367 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 9368 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 9369 | SHOW_STR |
| 9370 | IP_STR |
| 9371 | BGP_STR |
| 9372 | "Address family\n" |
| 9373 | "Address Family modifier\n" |
| 9374 | "Address Family modifier\n" |
| 9375 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 9376 | "Display route and more specific routes\n") |
| 9377 | { |
| 9378 | if (strncmp (argv[0], "m", 1) == 0) |
| 9379 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 9380 | bgp_show_type_prefix_longer); |
| 9381 | |
| 9382 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 9383 | bgp_show_type_prefix_longer); |
| 9384 | } |
| 9385 | |
| 9386 | DEFUN (show_ip_bgp_flap_address, |
| 9387 | show_ip_bgp_flap_address_cmd, |
| 9388 | "show ip bgp flap-statistics A.B.C.D", |
| 9389 | SHOW_STR |
| 9390 | IP_STR |
| 9391 | BGP_STR |
| 9392 | "Display flap statistics of routes\n" |
| 9393 | "Network in the BGP routing table to display\n") |
| 9394 | { |
| 9395 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9396 | bgp_show_type_flap_address); |
| 9397 | } |
| 9398 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9399 | ALIAS (show_ip_bgp_flap_address, |
| 9400 | show_ip_bgp_damp_flap_address_cmd, |
| 9401 | "show ip bgp dampening flap-statistics A.B.C.D", |
| 9402 | SHOW_STR |
| 9403 | IP_STR |
| 9404 | BGP_STR |
| 9405 | "Display detailed information about dampening\n" |
| 9406 | "Display flap statistics of routes\n" |
| 9407 | "Network in the BGP routing table to display\n") |
| 9408 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9409 | DEFUN (show_ip_bgp_flap_prefix, |
| 9410 | show_ip_bgp_flap_prefix_cmd, |
| 9411 | "show ip bgp flap-statistics A.B.C.D/M", |
| 9412 | SHOW_STR |
| 9413 | IP_STR |
| 9414 | BGP_STR |
| 9415 | "Display flap statistics of routes\n" |
| 9416 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9417 | { |
| 9418 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 9419 | bgp_show_type_flap_prefix); |
| 9420 | } |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 9421 | |
| 9422 | ALIAS (show_ip_bgp_flap_prefix, |
| 9423 | show_ip_bgp_damp_flap_prefix_cmd, |
| 9424 | "show ip bgp dampening flap-statistics A.B.C.D/M", |
| 9425 | SHOW_STR |
| 9426 | IP_STR |
| 9427 | BGP_STR |
| 9428 | "Display detailed information about dampening\n" |
| 9429 | "Display flap statistics of routes\n" |
| 9430 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9431 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9432 | #ifdef HAVE_IPV6 |
| 9433 | DEFUN (show_bgp_prefix_longer, |
| 9434 | show_bgp_prefix_longer_cmd, |
| 9435 | "show bgp X:X::X:X/M longer-prefixes", |
| 9436 | SHOW_STR |
| 9437 | BGP_STR |
| 9438 | "IPv6 prefix <network>/<length>\n" |
| 9439 | "Display route and more specific routes\n") |
| 9440 | { |
| 9441 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9442 | bgp_show_type_prefix_longer); |
| 9443 | } |
| 9444 | |
| 9445 | ALIAS (show_bgp_prefix_longer, |
| 9446 | show_bgp_ipv6_prefix_longer_cmd, |
| 9447 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 9448 | SHOW_STR |
| 9449 | BGP_STR |
| 9450 | "Address family\n" |
| 9451 | "IPv6 prefix <network>/<length>\n" |
| 9452 | "Display route and more specific routes\n") |
| 9453 | |
| 9454 | /* old command */ |
| 9455 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 9456 | show_ipv6_bgp_prefix_longer_cmd, |
| 9457 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 9458 | SHOW_STR |
| 9459 | IPV6_STR |
| 9460 | BGP_STR |
| 9461 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9462 | "Display route and more specific routes\n") |
| 9463 | { |
| 9464 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 9465 | bgp_show_type_prefix_longer); |
| 9466 | } |
| 9467 | |
| 9468 | /* old command */ |
| 9469 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 9470 | show_ipv6_mbgp_prefix_longer_cmd, |
| 9471 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 9472 | SHOW_STR |
| 9473 | IPV6_STR |
| 9474 | MBGP_STR |
| 9475 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 9476 | "Display route and more specific routes\n") |
| 9477 | { |
| 9478 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 9479 | bgp_show_type_prefix_longer); |
| 9480 | } |
| 9481 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9482 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9483 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9484 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 9485 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9486 | { |
| 9487 | int ret; |
| 9488 | struct bgp *bgp; |
| 9489 | struct peer *peer; |
| 9490 | union sockunion su; |
| 9491 | |
| 9492 | /* BGP structure lookup. */ |
| 9493 | if (view_name) |
| 9494 | { |
| 9495 | bgp = bgp_lookup_by_name (view_name); |
| 9496 | if (! bgp) |
| 9497 | { |
| 9498 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 9499 | return NULL; |
| 9500 | } |
| 9501 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 9502 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9503 | { |
| 9504 | bgp = bgp_get_default (); |
| 9505 | if (! bgp) |
| 9506 | { |
| 9507 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9508 | return NULL; |
| 9509 | } |
| 9510 | } |
| 9511 | |
| 9512 | /* Get peer sockunion. */ |
| 9513 | ret = str2sockunion (ip_str, &su); |
| 9514 | if (ret < 0) |
| 9515 | { |
| 9516 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 9517 | return NULL; |
| 9518 | } |
| 9519 | |
| 9520 | /* Peer structure lookup. */ |
| 9521 | peer = peer_lookup (bgp, &su); |
| 9522 | if (! peer) |
| 9523 | { |
| 9524 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 9525 | return NULL; |
| 9526 | } |
| 9527 | |
| 9528 | return peer; |
| 9529 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9530 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9531 | enum bgp_stats |
| 9532 | { |
| 9533 | BGP_STATS_MAXBITLEN = 0, |
| 9534 | BGP_STATS_RIB, |
| 9535 | BGP_STATS_PREFIXES, |
| 9536 | BGP_STATS_TOTPLEN, |
| 9537 | BGP_STATS_UNAGGREGATEABLE, |
| 9538 | BGP_STATS_MAX_AGGREGATEABLE, |
| 9539 | BGP_STATS_AGGREGATES, |
| 9540 | BGP_STATS_SPACE, |
| 9541 | BGP_STATS_ASPATH_COUNT, |
| 9542 | BGP_STATS_ASPATH_MAXHOPS, |
| 9543 | BGP_STATS_ASPATH_TOTHOPS, |
| 9544 | BGP_STATS_ASPATH_MAXSIZE, |
| 9545 | BGP_STATS_ASPATH_TOTSIZE, |
| 9546 | BGP_STATS_ASN_HIGHEST, |
| 9547 | BGP_STATS_MAX, |
| 9548 | }; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9549 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9550 | static const char *table_stats_strs[] = |
| 9551 | { |
| 9552 | [BGP_STATS_PREFIXES] = "Total Prefixes", |
| 9553 | [BGP_STATS_TOTPLEN] = "Average prefix length", |
| 9554 | [BGP_STATS_RIB] = "Total Advertisements", |
| 9555 | [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", |
| 9556 | [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", |
| 9557 | [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", |
| 9558 | [BGP_STATS_SPACE] = "Address space advertised", |
| 9559 | [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", |
| 9560 | [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", |
| 9561 | [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", |
| 9562 | [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", |
| 9563 | [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", |
| 9564 | [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", |
| 9565 | [BGP_STATS_MAX] = NULL, |
| 9566 | }; |
| 9567 | |
| 9568 | struct bgp_table_stats |
| 9569 | { |
| 9570 | struct bgp_table *table; |
| 9571 | unsigned long long counts[BGP_STATS_MAX]; |
| 9572 | }; |
| 9573 | |
| 9574 | #if 0 |
| 9575 | #define TALLY_SIGFIG 100000 |
| 9576 | static unsigned long |
| 9577 | ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) |
| 9578 | { |
| 9579 | unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); |
| 9580 | unsigned long res = (newtot * TALLY_SIGFIG) / count; |
| 9581 | unsigned long ret = newtot / count; |
| 9582 | |
| 9583 | if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) |
| 9584 | return ret + 1; |
| 9585 | else |
| 9586 | return ret; |
| 9587 | } |
| 9588 | #endif |
| 9589 | |
| 9590 | static int |
| 9591 | bgp_table_stats_walker (struct thread *t) |
| 9592 | { |
| 9593 | struct bgp_node *rn; |
| 9594 | struct bgp_node *top; |
| 9595 | struct bgp_table_stats *ts = THREAD_ARG (t); |
| 9596 | unsigned int space = 0; |
| 9597 | |
Paul Jakma | 53d9f67 | 2006-10-15 23:41:16 +0000 | [diff] [blame] | 9598 | if (!(top = bgp_table_top (ts->table))) |
| 9599 | return 0; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9600 | |
| 9601 | switch (top->p.family) |
| 9602 | { |
| 9603 | case AF_INET: |
| 9604 | space = IPV4_MAX_BITLEN; |
| 9605 | break; |
| 9606 | case AF_INET6: |
| 9607 | space = IPV6_MAX_BITLEN; |
| 9608 | break; |
| 9609 | } |
| 9610 | |
| 9611 | ts->counts[BGP_STATS_MAXBITLEN] = space; |
| 9612 | |
| 9613 | for (rn = top; rn; rn = bgp_route_next (rn)) |
| 9614 | { |
| 9615 | struct bgp_info *ri; |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9616 | struct bgp_node *prn = bgp_node_parent_nolock (rn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9617 | unsigned int rinum = 0; |
| 9618 | |
| 9619 | if (rn == top) |
| 9620 | continue; |
| 9621 | |
| 9622 | if (!rn->info) |
| 9623 | continue; |
| 9624 | |
| 9625 | ts->counts[BGP_STATS_PREFIXES]++; |
| 9626 | ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; |
| 9627 | |
| 9628 | #if 0 |
| 9629 | ts->counts[BGP_STATS_AVGPLEN] |
| 9630 | = ravg_tally (ts->counts[BGP_STATS_PREFIXES], |
| 9631 | ts->counts[BGP_STATS_AVGPLEN], |
| 9632 | rn->p.prefixlen); |
| 9633 | #endif |
| 9634 | |
| 9635 | /* check if the prefix is included by any other announcements */ |
| 9636 | while (prn && !prn->info) |
Avneesh Sachdev | 6717404 | 2012-08-17 08:19:49 -0700 | [diff] [blame] | 9637 | prn = bgp_node_parent_nolock (prn); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9638 | |
| 9639 | if (prn == NULL || prn == top) |
Paul Jakma | 8383a9b | 2006-09-14 03:06:54 +0000 | [diff] [blame] | 9640 | { |
| 9641 | ts->counts[BGP_STATS_UNAGGREGATEABLE]++; |
| 9642 | /* announced address space */ |
| 9643 | if (space) |
| 9644 | ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); |
| 9645 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9646 | else if (prn->info) |
| 9647 | ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; |
| 9648 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9649 | for (ri = rn->info; ri; ri = ri->next) |
| 9650 | { |
| 9651 | rinum++; |
| 9652 | ts->counts[BGP_STATS_RIB]++; |
| 9653 | |
| 9654 | if (ri->attr && |
| 9655 | (CHECK_FLAG (ri->attr->flag, |
| 9656 | ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) |
| 9657 | ts->counts[BGP_STATS_AGGREGATES]++; |
| 9658 | |
| 9659 | /* as-path stats */ |
| 9660 | if (ri->attr && ri->attr->aspath) |
| 9661 | { |
| 9662 | unsigned int hops = aspath_count_hops (ri->attr->aspath); |
| 9663 | unsigned int size = aspath_size (ri->attr->aspath); |
| 9664 | as_t highest = aspath_highest (ri->attr->aspath); |
| 9665 | |
| 9666 | ts->counts[BGP_STATS_ASPATH_COUNT]++; |
| 9667 | |
| 9668 | if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) |
| 9669 | ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; |
| 9670 | |
| 9671 | if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) |
| 9672 | ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; |
| 9673 | |
| 9674 | ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; |
| 9675 | ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; |
| 9676 | #if 0 |
| 9677 | ts->counts[BGP_STATS_ASPATH_AVGHOPS] |
| 9678 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9679 | ts->counts[BGP_STATS_ASPATH_AVGHOPS], |
| 9680 | hops); |
| 9681 | ts->counts[BGP_STATS_ASPATH_AVGSIZE] |
| 9682 | = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], |
| 9683 | ts->counts[BGP_STATS_ASPATH_AVGSIZE], |
| 9684 | size); |
| 9685 | #endif |
| 9686 | if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) |
| 9687 | ts->counts[BGP_STATS_ASN_HIGHEST] = highest; |
| 9688 | } |
| 9689 | } |
| 9690 | } |
| 9691 | return 0; |
| 9692 | } |
| 9693 | |
| 9694 | static int |
| 9695 | bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) |
| 9696 | { |
| 9697 | struct bgp_table_stats ts; |
| 9698 | unsigned int i; |
| 9699 | |
| 9700 | if (!bgp->rib[afi][safi]) |
| 9701 | { |
| 9702 | vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); |
| 9703 | return CMD_WARNING; |
| 9704 | } |
| 9705 | |
| 9706 | memset (&ts, 0, sizeof (ts)); |
| 9707 | ts.table = bgp->rib[afi][safi]; |
| 9708 | thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); |
| 9709 | |
| 9710 | vty_out (vty, "BGP %s RIB statistics%s%s", |
| 9711 | afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); |
| 9712 | |
| 9713 | for (i = 0; i < BGP_STATS_MAX; i++) |
| 9714 | { |
| 9715 | if (!table_stats_strs[i]) |
| 9716 | continue; |
| 9717 | |
| 9718 | switch (i) |
| 9719 | { |
| 9720 | #if 0 |
| 9721 | case BGP_STATS_ASPATH_AVGHOPS: |
| 9722 | case BGP_STATS_ASPATH_AVGSIZE: |
| 9723 | case BGP_STATS_AVGPLEN: |
| 9724 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9725 | vty_out (vty, "%12.2f", |
| 9726 | (float)ts.counts[i] / (float)TALLY_SIGFIG); |
| 9727 | break; |
| 9728 | #endif |
| 9729 | case BGP_STATS_ASPATH_TOTHOPS: |
| 9730 | case BGP_STATS_ASPATH_TOTSIZE: |
| 9731 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9732 | vty_out (vty, "%12.2f", |
| 9733 | ts.counts[i] ? |
| 9734 | (float)ts.counts[i] / |
| 9735 | (float)ts.counts[BGP_STATS_ASPATH_COUNT] |
| 9736 | : 0); |
| 9737 | break; |
| 9738 | case BGP_STATS_TOTPLEN: |
| 9739 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9740 | vty_out (vty, "%12.2f", |
| 9741 | ts.counts[i] ? |
| 9742 | (float)ts.counts[i] / |
| 9743 | (float)ts.counts[BGP_STATS_PREFIXES] |
| 9744 | : 0); |
| 9745 | break; |
| 9746 | case BGP_STATS_SPACE: |
| 9747 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9748 | vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); |
| 9749 | if (ts.counts[BGP_STATS_MAXBITLEN] < 9) |
| 9750 | break; |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 9751 | vty_out (vty, "%30s: ", "%% announced "); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9752 | vty_out (vty, "%12.2f%s", |
| 9753 | 100 * (float)ts.counts[BGP_STATS_SPACE] / |
Paul Jakma | 56395af | 2006-10-27 16:58:20 +0000 | [diff] [blame] | 9754 | (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9755 | VTY_NEWLINE); |
| 9756 | vty_out (vty, "%30s: ", "/8 equivalent "); |
| 9757 | vty_out (vty, "%12.2f%s", |
| 9758 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9759 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), |
| 9760 | VTY_NEWLINE); |
| 9761 | if (ts.counts[BGP_STATS_MAXBITLEN] < 25) |
| 9762 | break; |
| 9763 | vty_out (vty, "%30s: ", "/24 equivalent "); |
| 9764 | vty_out (vty, "%12.2f", |
| 9765 | (float)ts.counts[BGP_STATS_SPACE] / |
| 9766 | (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); |
| 9767 | break; |
| 9768 | default: |
| 9769 | vty_out (vty, "%-30s: ", table_stats_strs[i]); |
| 9770 | vty_out (vty, "%12llu", ts.counts[i]); |
| 9771 | } |
| 9772 | |
| 9773 | vty_out (vty, "%s", VTY_NEWLINE); |
| 9774 | } |
| 9775 | return CMD_SUCCESS; |
| 9776 | } |
| 9777 | |
| 9778 | static int |
| 9779 | bgp_table_stats_vty (struct vty *vty, const char *name, |
| 9780 | const char *afi_str, const char *safi_str) |
| 9781 | { |
| 9782 | struct bgp *bgp; |
| 9783 | afi_t afi; |
| 9784 | safi_t safi; |
| 9785 | |
| 9786 | if (name) |
| 9787 | bgp = bgp_lookup_by_name (name); |
| 9788 | else |
| 9789 | bgp = bgp_get_default (); |
| 9790 | |
| 9791 | if (!bgp) |
| 9792 | { |
| 9793 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); |
| 9794 | return CMD_WARNING; |
| 9795 | } |
| 9796 | if (strncmp (afi_str, "ipv", 3) == 0) |
| 9797 | { |
| 9798 | if (strncmp (afi_str, "ipv4", 4) == 0) |
| 9799 | afi = AFI_IP; |
| 9800 | else if (strncmp (afi_str, "ipv6", 4) == 0) |
| 9801 | afi = AFI_IP6; |
| 9802 | else |
| 9803 | { |
| 9804 | vty_out (vty, "%% Invalid address family %s%s", |
| 9805 | afi_str, VTY_NEWLINE); |
| 9806 | return CMD_WARNING; |
| 9807 | } |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 9808 | switch (safi_str[0]) { |
| 9809 | case 'm': |
| 9810 | safi = SAFI_MULTICAST; |
| 9811 | break; |
| 9812 | case 'u': |
| 9813 | safi = SAFI_UNICAST; |
| 9814 | break; |
| 9815 | case 'v': |
| 9816 | safi = SAFI_MPLS_LABELED_VPN; |
| 9817 | break; |
| 9818 | case 'e': |
| 9819 | safi = SAFI_ENCAP; |
| 9820 | break; |
| 9821 | default: |
| 9822 | vty_out (vty, "%% Invalid subsequent address family %s%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9823 | safi_str, VTY_NEWLINE); |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 9824 | return CMD_WARNING; |
| 9825 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9826 | } |
| 9827 | else |
| 9828 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 9829 | vty_out (vty, "%% Invalid address family \"%s\"%s", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9830 | afi_str, VTY_NEWLINE); |
| 9831 | return CMD_WARNING; |
| 9832 | } |
| 9833 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9834 | return bgp_table_stats (vty, bgp, afi, safi); |
| 9835 | } |
| 9836 | |
| 9837 | DEFUN (show_bgp_statistics, |
| 9838 | show_bgp_statistics_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 9839 | "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9840 | SHOW_STR |
| 9841 | BGP_STR |
| 9842 | "Address family\n" |
| 9843 | "Address family\n" |
| 9844 | "Address Family modifier\n" |
| 9845 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 9846 | "Address Family modifier\n" |
| 9847 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9848 | "BGP RIB advertisement statistics\n") |
| 9849 | { |
| 9850 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9851 | } |
| 9852 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9853 | DEFUN (show_bgp_statistics_view, |
| 9854 | show_bgp_statistics_view_cmd, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 9855 | "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9856 | SHOW_STR |
| 9857 | BGP_STR |
| 9858 | "BGP view\n" |
| 9859 | "Address family\n" |
| 9860 | "Address family\n" |
| 9861 | "Address Family modifier\n" |
| 9862 | "Address Family modifier\n" |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 9863 | "Address Family modifier\n" |
| 9864 | "Address Family modifier\n" |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9865 | "BGP RIB advertisement statistics\n") |
| 9866 | { |
| 9867 | return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); |
| 9868 | } |
| 9869 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 9870 | #if 0 /* added as options to above command */ |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9871 | ALIAS (show_bgp_statistics_view, |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 9872 | show_bgp_statistics_view_encap_cmd, |
| 9873 | "show bgp view WORD (ipv4) (encap) statistics", |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9874 | SHOW_STR |
| 9875 | BGP_STR |
| 9876 | "BGP view\n" |
| 9877 | "Address family\n" |
| 9878 | "Address Family modifier\n" |
| 9879 | "BGP RIB advertisement statistics\n") |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 9880 | #endif |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 9881 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9882 | enum bgp_pcounts |
| 9883 | { |
| 9884 | PCOUNT_ADJ_IN = 0, |
| 9885 | PCOUNT_DAMPED, |
| 9886 | PCOUNT_REMOVED, |
| 9887 | PCOUNT_HISTORY, |
| 9888 | PCOUNT_STALE, |
| 9889 | PCOUNT_VALID, |
| 9890 | PCOUNT_ALL, |
| 9891 | PCOUNT_COUNTED, |
| 9892 | PCOUNT_PFCNT, /* the figure we display to users */ |
| 9893 | PCOUNT_MAX, |
| 9894 | }; |
| 9895 | |
| 9896 | static const char *pcount_strs[] = |
| 9897 | { |
| 9898 | [PCOUNT_ADJ_IN] = "Adj-in", |
| 9899 | [PCOUNT_DAMPED] = "Damped", |
| 9900 | [PCOUNT_REMOVED] = "Removed", |
| 9901 | [PCOUNT_HISTORY] = "History", |
| 9902 | [PCOUNT_STALE] = "Stale", |
| 9903 | [PCOUNT_VALID] = "Valid", |
| 9904 | [PCOUNT_ALL] = "All RIB", |
| 9905 | [PCOUNT_COUNTED] = "PfxCt counted", |
| 9906 | [PCOUNT_PFCNT] = "Useable", |
| 9907 | [PCOUNT_MAX] = NULL, |
| 9908 | }; |
| 9909 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9910 | struct peer_pcounts |
| 9911 | { |
| 9912 | unsigned int count[PCOUNT_MAX]; |
| 9913 | const struct peer *peer; |
| 9914 | const struct bgp_table *table; |
| 9915 | }; |
| 9916 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9917 | static int |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9918 | bgp_peer_count_walker (struct thread *t) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9919 | { |
| 9920 | struct bgp_node *rn; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9921 | struct peer_pcounts *pc = THREAD_ARG (t); |
| 9922 | const struct peer *peer = pc->peer; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9923 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9924 | 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] | 9925 | { |
| 9926 | struct bgp_adj_in *ain; |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9927 | struct bgp_info *ri; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9928 | |
| 9929 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 9930 | if (ain->peer == peer) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9931 | pc->count[PCOUNT_ADJ_IN]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9932 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9933 | for (ri = rn->info; ri; ri = ri->next) |
| 9934 | { |
| 9935 | char buf[SU_ADDRSTRLEN]; |
| 9936 | |
| 9937 | if (ri->peer != peer) |
| 9938 | continue; |
| 9939 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9940 | pc->count[PCOUNT_ALL]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9941 | |
| 9942 | if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9943 | pc->count[PCOUNT_DAMPED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9944 | if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9945 | pc->count[PCOUNT_HISTORY]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9946 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9947 | pc->count[PCOUNT_REMOVED]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9948 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9949 | pc->count[PCOUNT_STALE]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9950 | if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9951 | pc->count[PCOUNT_VALID]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9952 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9953 | pc->count[PCOUNT_PFCNT]++; |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9954 | |
| 9955 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) |
| 9956 | { |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9957 | pc->count[PCOUNT_COUNTED]++; |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9958 | if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9959 | plog_warn (peer->log, |
| 9960 | "%s [pcount] %s/%d is counted but flags 0x%x", |
| 9961 | peer->host, |
| 9962 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9963 | buf, SU_ADDRSTRLEN), |
| 9964 | rn->p.prefixlen, |
| 9965 | ri->flags); |
| 9966 | } |
| 9967 | else |
| 9968 | { |
Paul Jakma | 1a392d4 | 2006-09-07 00:24:49 +0000 | [diff] [blame] | 9969 | if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9970 | plog_warn (peer->log, |
| 9971 | "%s [pcount] %s/%d not counted but flags 0x%x", |
| 9972 | peer->host, |
| 9973 | inet_ntop(rn->p.family, &rn->p.u.prefix, |
| 9974 | buf, SU_ADDRSTRLEN), |
| 9975 | rn->p.prefixlen, |
| 9976 | ri->flags); |
| 9977 | } |
| 9978 | } |
| 9979 | } |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9980 | return 0; |
| 9981 | } |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 9982 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 9983 | static int |
| 9984 | bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) |
| 9985 | { |
| 9986 | struct peer_pcounts pcounts = { .peer = peer }; |
| 9987 | unsigned int i; |
| 9988 | |
| 9989 | if (!peer || !peer->bgp || !peer->afc[afi][safi] |
| 9990 | || !peer->bgp->rib[afi][safi]) |
| 9991 | { |
| 9992 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 9993 | return CMD_WARNING; |
| 9994 | } |
| 9995 | |
| 9996 | memset (&pcounts, 0, sizeof(pcounts)); |
| 9997 | pcounts.peer = peer; |
| 9998 | pcounts.table = peer->bgp->rib[afi][safi]; |
| 9999 | |
| 10000 | /* in-place call via thread subsystem so as to record execution time |
| 10001 | * stats for the thread-walk (i.e. ensure this can't be blamed on |
| 10002 | * on just vty_read()). |
| 10003 | */ |
| 10004 | thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); |
| 10005 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 10006 | vty_out (vty, "Prefix counts for %s, %s%s", |
| 10007 | peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); |
| 10008 | vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); |
| 10009 | vty_out (vty, "%sCounts from RIB table walk:%s%s", |
| 10010 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 10011 | |
| 10012 | for (i = 0; i < PCOUNT_MAX; i++) |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 10013 | vty_out (vty, "%20s: %-10d%s", |
| 10014 | pcount_strs[i], pcounts.count[i], VTY_NEWLINE); |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 10015 | |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 10016 | if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 10017 | { |
| 10018 | vty_out (vty, "%s [pcount] PfxCt drift!%s", |
| 10019 | peer->host, VTY_NEWLINE); |
| 10020 | vty_out (vty, "Please report this bug, with the above command output%s", |
| 10021 | VTY_NEWLINE); |
| 10022 | } |
| 10023 | |
| 10024 | return CMD_SUCCESS; |
| 10025 | } |
| 10026 | |
| 10027 | DEFUN (show_ip_bgp_neighbor_prefix_counts, |
| 10028 | show_ip_bgp_neighbor_prefix_counts_cmd, |
| 10029 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 10030 | SHOW_STR |
| 10031 | IP_STR |
| 10032 | BGP_STR |
| 10033 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10034 | "Neighbor to display information about\n" |
| 10035 | "Neighbor to display information about\n" |
| 10036 | "Display detailed prefix count information\n") |
| 10037 | { |
| 10038 | struct peer *peer; |
| 10039 | |
| 10040 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10041 | if (! peer) |
| 10042 | return CMD_WARNING; |
| 10043 | |
| 10044 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 10045 | } |
| 10046 | |
| 10047 | DEFUN (show_bgp_ipv6_neighbor_prefix_counts, |
| 10048 | show_bgp_ipv6_neighbor_prefix_counts_cmd, |
| 10049 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 10050 | SHOW_STR |
| 10051 | BGP_STR |
| 10052 | "Address family\n" |
| 10053 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10054 | "Neighbor to display information about\n" |
| 10055 | "Neighbor to display information about\n" |
| 10056 | "Display detailed prefix count information\n") |
| 10057 | { |
| 10058 | struct peer *peer; |
| 10059 | |
| 10060 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10061 | if (! peer) |
| 10062 | return CMD_WARNING; |
| 10063 | |
| 10064 | return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); |
| 10065 | } |
| 10066 | |
| 10067 | DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, |
| 10068 | show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, |
| 10069 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 10070 | SHOW_STR |
| 10071 | IP_STR |
| 10072 | BGP_STR |
| 10073 | "Address family\n" |
| 10074 | "Address Family modifier\n" |
| 10075 | "Address Family modifier\n" |
| 10076 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10077 | "Neighbor to display information about\n" |
| 10078 | "Neighbor to display information about\n" |
| 10079 | "Display detailed prefix count information\n") |
| 10080 | { |
| 10081 | struct peer *peer; |
| 10082 | |
| 10083 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10084 | if (! peer) |
| 10085 | return CMD_WARNING; |
| 10086 | |
| 10087 | if (strncmp (argv[0], "m", 1) == 0) |
| 10088 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST); |
| 10089 | |
| 10090 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); |
| 10091 | } |
| 10092 | |
| 10093 | DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, |
| 10094 | show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, |
| 10095 | "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts", |
| 10096 | SHOW_STR |
| 10097 | IP_STR |
| 10098 | BGP_STR |
| 10099 | "Address family\n" |
| 10100 | "Address Family modifier\n" |
| 10101 | "Address Family modifier\n" |
| 10102 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10103 | "Neighbor to display information about\n" |
| 10104 | "Neighbor to display information about\n" |
| 10105 | "Display detailed prefix count information\n") |
| 10106 | { |
| 10107 | struct peer *peer; |
| 10108 | |
| 10109 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10110 | if (! peer) |
| 10111 | return CMD_WARNING; |
| 10112 | |
| 10113 | return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); |
| 10114 | } |
| 10115 | |
| 10116 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10117 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10118 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 10119 | int in) |
| 10120 | { |
| 10121 | struct bgp_table *table; |
| 10122 | struct bgp_adj_in *ain; |
| 10123 | struct bgp_adj_out *adj; |
| 10124 | unsigned long output_count; |
| 10125 | struct bgp_node *rn; |
| 10126 | int header1 = 1; |
| 10127 | struct bgp *bgp; |
| 10128 | int header2 = 1; |
| 10129 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10130 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10131 | |
| 10132 | if (! bgp) |
| 10133 | return; |
| 10134 | |
| 10135 | table = bgp->rib[afi][safi]; |
| 10136 | |
| 10137 | output_count = 0; |
| 10138 | |
| 10139 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 10140 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 10141 | { |
| 10142 | 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] | 10143 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 10144 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10145 | |
| 10146 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 10147 | VTY_NEWLINE, VTY_NEWLINE); |
| 10148 | header1 = 0; |
| 10149 | } |
| 10150 | |
| 10151 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 10152 | if (in) |
| 10153 | { |
| 10154 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 10155 | if (ain->peer == peer) |
| 10156 | { |
| 10157 | if (header1) |
| 10158 | { |
| 10159 | 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] | 10160 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 10161 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10162 | header1 = 0; |
| 10163 | } |
| 10164 | if (header2) |
| 10165 | { |
| 10166 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 10167 | header2 = 0; |
| 10168 | } |
| 10169 | if (ain->attr) |
| 10170 | { |
| 10171 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 10172 | output_count++; |
| 10173 | } |
| 10174 | } |
| 10175 | } |
| 10176 | else |
| 10177 | { |
| 10178 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 10179 | if (adj->peer == peer) |
| 10180 | { |
| 10181 | if (header1) |
| 10182 | { |
| 10183 | 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] | 10184 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 10185 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10186 | header1 = 0; |
| 10187 | } |
| 10188 | if (header2) |
| 10189 | { |
| 10190 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 10191 | header2 = 0; |
| 10192 | } |
| 10193 | if (adj->attr) |
| 10194 | { |
| 10195 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 10196 | output_count++; |
| 10197 | } |
| 10198 | } |
| 10199 | } |
| 10200 | |
| 10201 | if (output_count != 0) |
| 10202 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 10203 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 10204 | } |
| 10205 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10206 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10207 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 10208 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10209 | if (! peer || ! peer->afc[afi][safi]) |
| 10210 | { |
| 10211 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 10212 | return CMD_WARNING; |
| 10213 | } |
| 10214 | |
| 10215 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 10216 | { |
| 10217 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 10218 | VTY_NEWLINE); |
| 10219 | return CMD_WARNING; |
| 10220 | } |
| 10221 | |
| 10222 | show_adj_route (vty, peer, afi, safi, in); |
| 10223 | |
| 10224 | return CMD_SUCCESS; |
| 10225 | } |
| 10226 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10227 | DEFUN (show_ip_bgp_view_neighbor_advertised_route, |
| 10228 | show_ip_bgp_view_neighbor_advertised_route_cmd, |
| 10229 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10230 | SHOW_STR |
| 10231 | IP_STR |
| 10232 | BGP_STR |
| 10233 | "BGP view\n" |
| 10234 | "View name\n" |
| 10235 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10236 | "Neighbor to display information about\n" |
| 10237 | "Neighbor to display information about\n" |
| 10238 | "Display the routes advertised to a BGP neighbor\n") |
| 10239 | { |
| 10240 | struct peer *peer; |
| 10241 | |
| 10242 | if (argc == 2) |
| 10243 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10244 | else |
| 10245 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10246 | |
| 10247 | if (! peer) |
| 10248 | return CMD_WARNING; |
| 10249 | |
| 10250 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
| 10251 | } |
| 10252 | |
| 10253 | ALIAS (show_ip_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10254 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 10255 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10256 | SHOW_STR |
| 10257 | IP_STR |
| 10258 | BGP_STR |
| 10259 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10260 | "Neighbor to display information about\n" |
| 10261 | "Neighbor to display information about\n" |
| 10262 | "Display the routes advertised to a BGP neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10263 | |
| 10264 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 10265 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 10266 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10267 | SHOW_STR |
| 10268 | IP_STR |
| 10269 | BGP_STR |
| 10270 | "Address family\n" |
| 10271 | "Address Family modifier\n" |
| 10272 | "Address Family modifier\n" |
| 10273 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10274 | "Neighbor to display information about\n" |
| 10275 | "Neighbor to display information about\n" |
| 10276 | "Display the routes advertised to a BGP neighbor\n") |
| 10277 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10278 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10279 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10280 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10281 | if (! peer) |
| 10282 | return CMD_WARNING; |
| 10283 | |
| 10284 | if (strncmp (argv[0], "m", 1) == 0) |
| 10285 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 10286 | |
| 10287 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10288 | } |
| 10289 | |
| 10290 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10291 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 10292 | show_bgp_view_neighbor_advertised_route_cmd, |
| 10293 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10294 | SHOW_STR |
| 10295 | BGP_STR |
| 10296 | "BGP view\n" |
| 10297 | "View name\n" |
| 10298 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10299 | "Neighbor to display information about\n" |
| 10300 | "Neighbor to display information about\n" |
| 10301 | "Display the routes advertised to a BGP neighbor\n") |
| 10302 | { |
| 10303 | struct peer *peer; |
| 10304 | |
| 10305 | if (argc == 2) |
| 10306 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10307 | else |
| 10308 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10309 | |
| 10310 | if (! peer) |
| 10311 | return CMD_WARNING; |
| 10312 | |
| 10313 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 10314 | } |
| 10315 | |
| 10316 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 10317 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 10318 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10319 | SHOW_STR |
| 10320 | BGP_STR |
| 10321 | "BGP view\n" |
| 10322 | "View name\n" |
| 10323 | "Address family\n" |
| 10324 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10325 | "Neighbor to display information about\n" |
| 10326 | "Neighbor to display information about\n" |
| 10327 | "Display the routes advertised to a BGP neighbor\n") |
| 10328 | |
| 10329 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 10330 | show_bgp_view_neighbor_received_routes_cmd, |
| 10331 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10332 | SHOW_STR |
| 10333 | BGP_STR |
| 10334 | "BGP view\n" |
| 10335 | "View name\n" |
| 10336 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10337 | "Neighbor to display information about\n" |
| 10338 | "Neighbor to display information about\n" |
| 10339 | "Display the received routes from neighbor\n") |
| 10340 | { |
| 10341 | struct peer *peer; |
| 10342 | |
| 10343 | if (argc == 2) |
| 10344 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10345 | else |
| 10346 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10347 | |
| 10348 | if (! peer) |
| 10349 | return CMD_WARNING; |
| 10350 | |
| 10351 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 10352 | } |
| 10353 | |
| 10354 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 10355 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 10356 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10357 | SHOW_STR |
| 10358 | BGP_STR |
| 10359 | "BGP view\n" |
| 10360 | "View name\n" |
| 10361 | "Address family\n" |
| 10362 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10363 | "Neighbor to display information about\n" |
| 10364 | "Neighbor to display information about\n" |
| 10365 | "Display the received routes from neighbor\n") |
| 10366 | |
| 10367 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10368 | show_bgp_neighbor_advertised_route_cmd, |
| 10369 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10370 | SHOW_STR |
| 10371 | BGP_STR |
| 10372 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10373 | "Neighbor to display information about\n" |
| 10374 | "Neighbor to display information about\n" |
| 10375 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10376 | |
| 10377 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10378 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 10379 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10380 | SHOW_STR |
| 10381 | BGP_STR |
| 10382 | "Address family\n" |
| 10383 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10384 | "Neighbor to display information about\n" |
| 10385 | "Neighbor to display information about\n" |
| 10386 | "Display the routes advertised to a BGP neighbor\n") |
| 10387 | |
| 10388 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10389 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10390 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 10391 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10392 | SHOW_STR |
| 10393 | IPV6_STR |
| 10394 | BGP_STR |
| 10395 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10396 | "Neighbor to display information about\n" |
| 10397 | "Neighbor to display information about\n" |
| 10398 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10399 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10400 | /* old command */ |
| 10401 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 10402 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 10403 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 10404 | SHOW_STR |
| 10405 | IPV6_STR |
| 10406 | MBGP_STR |
| 10407 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10408 | "Neighbor to display information about\n" |
| 10409 | "Neighbor to display information about\n" |
| 10410 | "Display the routes advertised to a BGP neighbor\n") |
| 10411 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10412 | struct peer *peer; |
| 10413 | |
| 10414 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10415 | if (! peer) |
| 10416 | return CMD_WARNING; |
| 10417 | |
| 10418 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10419 | } |
| 10420 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 10421 | |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 10422 | DEFUN (show_ip_bgp_view_neighbor_received_routes, |
| 10423 | show_ip_bgp_view_neighbor_received_routes_cmd, |
| 10424 | "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10425 | SHOW_STR |
| 10426 | IP_STR |
| 10427 | BGP_STR |
| 10428 | "BGP view\n" |
| 10429 | "View name\n" |
| 10430 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10431 | "Neighbor to display information about\n" |
| 10432 | "Neighbor to display information about\n" |
| 10433 | "Display the received routes from neighbor\n") |
| 10434 | { |
| 10435 | struct peer *peer; |
| 10436 | |
| 10437 | if (argc == 2) |
| 10438 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10439 | else |
| 10440 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10441 | |
| 10442 | if (! peer) |
| 10443 | return CMD_WARNING; |
| 10444 | |
| 10445 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
| 10446 | } |
| 10447 | |
| 10448 | ALIAS (show_ip_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10449 | show_ip_bgp_neighbor_received_routes_cmd, |
| 10450 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10451 | SHOW_STR |
| 10452 | IP_STR |
| 10453 | BGP_STR |
| 10454 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10455 | "Neighbor to display information about\n" |
| 10456 | "Neighbor to display information about\n" |
| 10457 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10458 | |
| 10459 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 10460 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 10461 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10462 | SHOW_STR |
| 10463 | IP_STR |
| 10464 | BGP_STR |
| 10465 | "Address family\n" |
| 10466 | "Address Family modifier\n" |
| 10467 | "Address Family modifier\n" |
| 10468 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10469 | "Neighbor to display information about\n" |
| 10470 | "Neighbor to display information about\n" |
| 10471 | "Display the received routes from neighbor\n") |
| 10472 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10473 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10474 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10475 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10476 | if (! peer) |
| 10477 | return CMD_WARNING; |
| 10478 | |
| 10479 | if (strncmp (argv[0], "m", 1) == 0) |
| 10480 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 10481 | |
| 10482 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10483 | } |
| 10484 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10485 | DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes, |
| 10486 | show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd, |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10487 | "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] | 10488 | SHOW_STR |
| 10489 | BGP_STR |
| 10490 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10491 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10492 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10493 | "Address family\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10494 | "Address family modifier\n" |
| 10495 | "Address family modifier\n" |
| 10496 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10497 | "Neighbor to display information about\n" |
| 10498 | "Neighbor to display information about\n" |
| 10499 | "Display the advertised routes to neighbor\n" |
| 10500 | "Display the received routes from neighbor\n") |
| 10501 | { |
| 10502 | int afi; |
| 10503 | int safi; |
| 10504 | int in; |
| 10505 | struct peer *peer; |
| 10506 | |
David Lamparter | 94bad67 | 2015-03-03 08:52:22 +0100 | [diff] [blame] | 10507 | peer = peer_lookup_in_view (vty, argv[0], argv[3]); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10508 | |
| 10509 | if (! peer) |
| 10510 | return CMD_WARNING; |
| 10511 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10512 | afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; |
| 10513 | safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10514 | in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0; |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10515 | |
| 10516 | return peer_adj_routes (vty, peer, afi, safi, in); |
| 10517 | } |
| 10518 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10519 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 10520 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 10521 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10522 | SHOW_STR |
| 10523 | IP_STR |
| 10524 | BGP_STR |
| 10525 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10526 | "Neighbor to display information about\n" |
| 10527 | "Neighbor to display information about\n" |
| 10528 | "Display information received from a BGP neighbor\n" |
| 10529 | "Display the prefixlist filter\n") |
| 10530 | { |
| 10531 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10532 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10533 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10534 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10535 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10536 | ret = str2sockunion (argv[0], &su); |
| 10537 | if (ret < 0) |
| 10538 | { |
| 10539 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10540 | return CMD_WARNING; |
| 10541 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10542 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10543 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10544 | if (! peer) |
| 10545 | return CMD_WARNING; |
| 10546 | |
| 10547 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10548 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10549 | if (count) |
| 10550 | { |
| 10551 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10552 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10553 | } |
| 10554 | |
| 10555 | return CMD_SUCCESS; |
| 10556 | } |
| 10557 | |
| 10558 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 10559 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 10560 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10561 | SHOW_STR |
| 10562 | IP_STR |
| 10563 | BGP_STR |
| 10564 | "Address family\n" |
| 10565 | "Address Family modifier\n" |
| 10566 | "Address Family modifier\n" |
| 10567 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10568 | "Neighbor to display information about\n" |
| 10569 | "Neighbor to display information about\n" |
| 10570 | "Display information received from a BGP neighbor\n" |
| 10571 | "Display the prefixlist filter\n") |
| 10572 | { |
| 10573 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10574 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10575 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10576 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10577 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10578 | ret = str2sockunion (argv[1], &su); |
| 10579 | if (ret < 0) |
| 10580 | { |
| 10581 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10582 | return CMD_WARNING; |
| 10583 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10584 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10585 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10586 | if (! peer) |
| 10587 | return CMD_WARNING; |
| 10588 | |
| 10589 | if (strncmp (argv[0], "m", 1) == 0) |
| 10590 | { |
| 10591 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 10592 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10593 | if (count) |
| 10594 | { |
| 10595 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 10596 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10597 | } |
| 10598 | } |
| 10599 | else |
| 10600 | { |
| 10601 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 10602 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 10603 | if (count) |
| 10604 | { |
| 10605 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 10606 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 10607 | } |
| 10608 | } |
| 10609 | |
| 10610 | return CMD_SUCCESS; |
| 10611 | } |
| 10612 | |
| 10613 | |
| 10614 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10615 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10616 | show_bgp_neighbor_received_routes_cmd, |
| 10617 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10618 | SHOW_STR |
| 10619 | BGP_STR |
| 10620 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10621 | "Neighbor to display information about\n" |
| 10622 | "Neighbor to display information about\n" |
| 10623 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10624 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10625 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10626 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 10627 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10628 | SHOW_STR |
| 10629 | BGP_STR |
| 10630 | "Address family\n" |
| 10631 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10632 | "Neighbor to display information about\n" |
| 10633 | "Neighbor to display information about\n" |
| 10634 | "Display the received routes from neighbor\n") |
| 10635 | |
| 10636 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 10637 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 10638 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10639 | SHOW_STR |
| 10640 | BGP_STR |
| 10641 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10642 | "Neighbor to display information about\n" |
| 10643 | "Neighbor to display information about\n" |
| 10644 | "Display information received from a BGP neighbor\n" |
| 10645 | "Display the prefixlist filter\n") |
| 10646 | { |
| 10647 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10648 | union sockunion su; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10649 | struct peer *peer; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10650 | int count, ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10651 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10652 | ret = str2sockunion (argv[0], &su); |
| 10653 | if (ret < 0) |
| 10654 | { |
| 10655 | vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); |
| 10656 | return CMD_WARNING; |
| 10657 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10658 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10659 | peer = peer_lookup (NULL, &su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10660 | if (! peer) |
| 10661 | return CMD_WARNING; |
| 10662 | |
| 10663 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10664 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10665 | if (count) |
| 10666 | { |
| 10667 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10668 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10669 | } |
| 10670 | |
| 10671 | return CMD_SUCCESS; |
| 10672 | } |
| 10673 | |
| 10674 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 10675 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 10676 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10677 | SHOW_STR |
| 10678 | BGP_STR |
| 10679 | "Address family\n" |
| 10680 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10681 | "Neighbor to display information about\n" |
| 10682 | "Neighbor to display information about\n" |
| 10683 | "Display information received from a BGP neighbor\n" |
| 10684 | "Display the prefixlist filter\n") |
| 10685 | |
| 10686 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10687 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10688 | ipv6_bgp_neighbor_received_routes_cmd, |
| 10689 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10690 | SHOW_STR |
| 10691 | IPV6_STR |
| 10692 | BGP_STR |
| 10693 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10694 | "Neighbor to display information about\n" |
| 10695 | "Neighbor to display information about\n" |
| 10696 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10697 | |
| 10698 | /* old command */ |
| 10699 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 10700 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 10701 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 10702 | SHOW_STR |
| 10703 | IPV6_STR |
| 10704 | MBGP_STR |
| 10705 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10706 | "Neighbor to display information about\n" |
| 10707 | "Neighbor to display information about\n" |
| 10708 | "Display the received routes from neighbor\n") |
| 10709 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10710 | struct peer *peer; |
| 10711 | |
| 10712 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10713 | if (! peer) |
| 10714 | return CMD_WARNING; |
| 10715 | |
| 10716 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10717 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10718 | |
| 10719 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 10720 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 10721 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10722 | SHOW_STR |
| 10723 | BGP_STR |
| 10724 | "BGP view\n" |
| 10725 | "View name\n" |
| 10726 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10727 | "Neighbor to display information about\n" |
| 10728 | "Neighbor to display information about\n" |
| 10729 | "Display information received from a BGP neighbor\n" |
| 10730 | "Display the prefixlist filter\n") |
| 10731 | { |
| 10732 | char name[BUFSIZ]; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10733 | union sockunion su; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10734 | struct peer *peer; |
| 10735 | struct bgp *bgp; |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10736 | int count, ret; |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10737 | |
| 10738 | /* BGP structure lookup. */ |
| 10739 | bgp = bgp_lookup_by_name (argv[0]); |
| 10740 | if (bgp == NULL) |
| 10741 | { |
| 10742 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 10743 | return CMD_WARNING; |
| 10744 | } |
| 10745 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10746 | ret = str2sockunion (argv[1], &su); |
| 10747 | if (ret < 0) |
| 10748 | { |
| 10749 | vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE); |
| 10750 | return CMD_WARNING; |
| 10751 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10752 | |
Jorge Boncompte [DTI2] | c63b83f | 2012-04-10 16:57:24 +0200 | [diff] [blame] | 10753 | peer = peer_lookup (bgp, &su); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10754 | if (! peer) |
| 10755 | return CMD_WARNING; |
| 10756 | |
| 10757 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 10758 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 10759 | if (count) |
| 10760 | { |
| 10761 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 10762 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 10763 | } |
| 10764 | |
| 10765 | return CMD_SUCCESS; |
| 10766 | } |
| 10767 | |
| 10768 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 10769 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 10770 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 10771 | SHOW_STR |
| 10772 | BGP_STR |
| 10773 | "BGP view\n" |
| 10774 | "View name\n" |
| 10775 | "Address family\n" |
| 10776 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10777 | "Neighbor to display information about\n" |
| 10778 | "Neighbor to display information about\n" |
| 10779 | "Display information received from a BGP neighbor\n" |
| 10780 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10781 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 10782 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10783 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10784 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10785 | safi_t safi, enum bgp_show_type type) |
| 10786 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10787 | if (! peer || ! peer->afc[afi][safi]) |
| 10788 | { |
| 10789 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10790 | return CMD_WARNING; |
| 10791 | } |
| 10792 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10793 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10794 | } |
| 10795 | |
| 10796 | DEFUN (show_ip_bgp_neighbor_routes, |
| 10797 | show_ip_bgp_neighbor_routes_cmd, |
| 10798 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 10799 | SHOW_STR |
| 10800 | IP_STR |
| 10801 | BGP_STR |
| 10802 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10803 | "Neighbor to display information about\n" |
| 10804 | "Neighbor to display information about\n" |
| 10805 | "Display routes learned from neighbor\n") |
| 10806 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10807 | struct peer *peer; |
| 10808 | |
| 10809 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10810 | if (! peer) |
| 10811 | return CMD_WARNING; |
| 10812 | |
| 10813 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10814 | bgp_show_type_neighbor); |
| 10815 | } |
| 10816 | |
| 10817 | DEFUN (show_ip_bgp_neighbor_flap, |
| 10818 | show_ip_bgp_neighbor_flap_cmd, |
| 10819 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 10820 | SHOW_STR |
| 10821 | IP_STR |
| 10822 | BGP_STR |
| 10823 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10824 | "Neighbor to display information about\n" |
| 10825 | "Neighbor to display information about\n" |
| 10826 | "Display flap statistics of the routes learned from neighbor\n") |
| 10827 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10828 | struct peer *peer; |
| 10829 | |
| 10830 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10831 | if (! peer) |
| 10832 | return CMD_WARNING; |
| 10833 | |
| 10834 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10835 | bgp_show_type_flap_neighbor); |
| 10836 | } |
| 10837 | |
| 10838 | DEFUN (show_ip_bgp_neighbor_damp, |
| 10839 | show_ip_bgp_neighbor_damp_cmd, |
| 10840 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 10841 | SHOW_STR |
| 10842 | IP_STR |
| 10843 | BGP_STR |
| 10844 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10845 | "Neighbor to display information about\n" |
| 10846 | "Neighbor to display information about\n" |
| 10847 | "Display the dampened routes received from neighbor\n") |
| 10848 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10849 | struct peer *peer; |
| 10850 | |
| 10851 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10852 | if (! peer) |
| 10853 | return CMD_WARNING; |
| 10854 | |
| 10855 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10856 | bgp_show_type_damp_neighbor); |
| 10857 | } |
| 10858 | |
| 10859 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 10860 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 10861 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 10862 | SHOW_STR |
| 10863 | IP_STR |
| 10864 | BGP_STR |
| 10865 | "Address family\n" |
| 10866 | "Address Family modifier\n" |
| 10867 | "Address Family modifier\n" |
| 10868 | "Detailed information on TCP and BGP neighbor connections\n" |
| 10869 | "Neighbor to display information about\n" |
| 10870 | "Neighbor to display information about\n" |
| 10871 | "Display routes learned from neighbor\n") |
| 10872 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10873 | struct peer *peer; |
| 10874 | |
| 10875 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10876 | if (! peer) |
| 10877 | return CMD_WARNING; |
| 10878 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10879 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10880 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10881 | bgp_show_type_neighbor); |
| 10882 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10883 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10884 | bgp_show_type_neighbor); |
| 10885 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10886 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10887 | DEFUN (show_ip_bgp_view_rsclient, |
| 10888 | show_ip_bgp_view_rsclient_cmd, |
| 10889 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 10890 | SHOW_STR |
| 10891 | IP_STR |
| 10892 | BGP_STR |
| 10893 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10894 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10895 | "Information about Route Server Client\n" |
| 10896 | NEIGHBOR_ADDR_STR) |
| 10897 | { |
| 10898 | struct bgp_table *table; |
| 10899 | struct peer *peer; |
| 10900 | |
| 10901 | if (argc == 2) |
| 10902 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 10903 | else |
| 10904 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 10905 | |
| 10906 | if (! peer) |
| 10907 | return CMD_WARNING; |
| 10908 | |
| 10909 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 10910 | { |
| 10911 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10912 | VTY_NEWLINE); |
| 10913 | return CMD_WARNING; |
| 10914 | } |
| 10915 | |
| 10916 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 10917 | PEER_FLAG_RSERVER_CLIENT)) |
| 10918 | { |
| 10919 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10920 | VTY_NEWLINE); |
| 10921 | return CMD_WARNING; |
| 10922 | } |
| 10923 | |
| 10924 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 10925 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10926 | 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] | 10927 | } |
| 10928 | |
| 10929 | ALIAS (show_ip_bgp_view_rsclient, |
| 10930 | show_ip_bgp_rsclient_cmd, |
| 10931 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 10932 | SHOW_STR |
| 10933 | IP_STR |
| 10934 | BGP_STR |
| 10935 | "Information about Route Server Client\n" |
| 10936 | NEIGHBOR_ADDR_STR) |
| 10937 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10938 | DEFUN (show_bgp_view_ipv4_safi_rsclient, |
| 10939 | show_bgp_view_ipv4_safi_rsclient_cmd, |
| 10940 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10941 | SHOW_STR |
| 10942 | BGP_STR |
| 10943 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 10944 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 10945 | "Address family\n" |
| 10946 | "Address Family modifier\n" |
| 10947 | "Address Family modifier\n" |
| 10948 | "Information about Route Server Client\n" |
| 10949 | NEIGHBOR_ADDR_STR) |
| 10950 | { |
| 10951 | struct bgp_table *table; |
| 10952 | struct peer *peer; |
| 10953 | safi_t safi; |
| 10954 | |
| 10955 | if (argc == 3) { |
| 10956 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 10957 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10958 | } else { |
| 10959 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 10960 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 10961 | } |
| 10962 | |
| 10963 | if (! peer) |
| 10964 | return CMD_WARNING; |
| 10965 | |
| 10966 | if (! peer->afc[AFI_IP][safi]) |
| 10967 | { |
| 10968 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 10969 | VTY_NEWLINE); |
| 10970 | return CMD_WARNING; |
| 10971 | } |
| 10972 | |
| 10973 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 10974 | PEER_FLAG_RSERVER_CLIENT)) |
| 10975 | { |
| 10976 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 10977 | VTY_NEWLINE); |
| 10978 | return CMD_WARNING; |
| 10979 | } |
| 10980 | |
| 10981 | table = peer->rib[AFI_IP][safi]; |
| 10982 | |
| 10983 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 10984 | } |
| 10985 | |
| 10986 | ALIAS (show_bgp_view_ipv4_safi_rsclient, |
| 10987 | show_bgp_ipv4_safi_rsclient_cmd, |
| 10988 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 10989 | SHOW_STR |
| 10990 | BGP_STR |
| 10991 | "Address family\n" |
| 10992 | "Address Family modifier\n" |
| 10993 | "Address Family modifier\n" |
| 10994 | "Information about Route Server Client\n" |
| 10995 | NEIGHBOR_ADDR_STR) |
| 10996 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10997 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 10998 | show_ip_bgp_view_rsclient_route_cmd, |
Michael Lambert | a8bf6f5 | 2008-09-24 17:23:11 +0100 | [diff] [blame] | 10999 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11000 | SHOW_STR |
| 11001 | IP_STR |
| 11002 | BGP_STR |
| 11003 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11004 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11005 | "Information about Route Server Client\n" |
| 11006 | NEIGHBOR_ADDR_STR |
| 11007 | "Network in the BGP routing table to display\n") |
| 11008 | { |
| 11009 | struct bgp *bgp; |
| 11010 | struct peer *peer; |
| 11011 | |
| 11012 | /* BGP structure lookup. */ |
| 11013 | if (argc == 3) |
| 11014 | { |
| 11015 | bgp = bgp_lookup_by_name (argv[0]); |
| 11016 | if (bgp == NULL) |
| 11017 | { |
| 11018 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11019 | return CMD_WARNING; |
| 11020 | } |
| 11021 | } |
| 11022 | else |
| 11023 | { |
| 11024 | bgp = bgp_get_default (); |
| 11025 | if (bgp == NULL) |
| 11026 | { |
| 11027 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11028 | return CMD_WARNING; |
| 11029 | } |
| 11030 | } |
| 11031 | |
| 11032 | if (argc == 3) |
| 11033 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11034 | else |
| 11035 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11036 | |
| 11037 | if (! peer) |
| 11038 | return CMD_WARNING; |
| 11039 | |
| 11040 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 11041 | { |
| 11042 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11043 | VTY_NEWLINE); |
| 11044 | return CMD_WARNING; |
| 11045 | } |
| 11046 | |
| 11047 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 11048 | PEER_FLAG_RSERVER_CLIENT)) |
| 11049 | { |
| 11050 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11051 | VTY_NEWLINE); |
| 11052 | return CMD_WARNING; |
| 11053 | } |
| 11054 | |
| 11055 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 11056 | (argc == 3) ? argv[2] : argv[1], |
| 11057 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 11058 | } |
| 11059 | |
| 11060 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 11061 | show_ip_bgp_rsclient_route_cmd, |
| 11062 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 11063 | SHOW_STR |
| 11064 | IP_STR |
| 11065 | BGP_STR |
| 11066 | "Information about Route Server Client\n" |
| 11067 | NEIGHBOR_ADDR_STR |
| 11068 | "Network in the BGP routing table to display\n") |
| 11069 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11070 | DEFUN (show_bgp_view_ipv4_safi_rsclient_route, |
| 11071 | show_bgp_view_ipv4_safi_rsclient_route_cmd, |
| 11072 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 11073 | SHOW_STR |
| 11074 | BGP_STR |
| 11075 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11076 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11077 | "Address family\n" |
| 11078 | "Address Family modifier\n" |
| 11079 | "Address Family modifier\n" |
| 11080 | "Information about Route Server Client\n" |
| 11081 | NEIGHBOR_ADDR_STR |
| 11082 | "Network in the BGP routing table to display\n") |
| 11083 | { |
| 11084 | struct bgp *bgp; |
| 11085 | struct peer *peer; |
| 11086 | safi_t safi; |
| 11087 | |
| 11088 | /* BGP structure lookup. */ |
| 11089 | if (argc == 4) |
| 11090 | { |
| 11091 | bgp = bgp_lookup_by_name (argv[0]); |
| 11092 | if (bgp == NULL) |
| 11093 | { |
| 11094 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11095 | return CMD_WARNING; |
| 11096 | } |
| 11097 | } |
| 11098 | else |
| 11099 | { |
| 11100 | bgp = bgp_get_default (); |
| 11101 | if (bgp == NULL) |
| 11102 | { |
| 11103 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11104 | return CMD_WARNING; |
| 11105 | } |
| 11106 | } |
| 11107 | |
| 11108 | if (argc == 4) { |
| 11109 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11110 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11111 | } else { |
| 11112 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11113 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11114 | } |
| 11115 | |
| 11116 | if (! peer) |
| 11117 | return CMD_WARNING; |
| 11118 | |
| 11119 | if (! peer->afc[AFI_IP][safi]) |
| 11120 | { |
| 11121 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11122 | VTY_NEWLINE); |
| 11123 | return CMD_WARNING; |
| 11124 | } |
| 11125 | |
| 11126 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 11127 | PEER_FLAG_RSERVER_CLIENT)) |
| 11128 | { |
| 11129 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11130 | VTY_NEWLINE); |
| 11131 | return CMD_WARNING; |
| 11132 | } |
| 11133 | |
| 11134 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 11135 | (argc == 4) ? argv[3] : argv[2], |
| 11136 | AFI_IP, safi, NULL, 0); |
| 11137 | } |
| 11138 | |
| 11139 | ALIAS (show_bgp_view_ipv4_safi_rsclient_route, |
| 11140 | show_bgp_ipv4_safi_rsclient_route_cmd, |
| 11141 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 11142 | SHOW_STR |
| 11143 | BGP_STR |
| 11144 | "Address family\n" |
| 11145 | "Address Family modifier\n" |
| 11146 | "Address Family modifier\n" |
| 11147 | "Information about Route Server Client\n" |
| 11148 | NEIGHBOR_ADDR_STR |
| 11149 | "Network in the BGP routing table to display\n") |
| 11150 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11151 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 11152 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 11153 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11154 | SHOW_STR |
| 11155 | IP_STR |
| 11156 | BGP_STR |
| 11157 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11158 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11159 | "Information about Route Server Client\n" |
| 11160 | NEIGHBOR_ADDR_STR |
| 11161 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11162 | { |
| 11163 | struct bgp *bgp; |
| 11164 | struct peer *peer; |
| 11165 | |
| 11166 | /* BGP structure lookup. */ |
| 11167 | if (argc == 3) |
| 11168 | { |
| 11169 | bgp = bgp_lookup_by_name (argv[0]); |
| 11170 | if (bgp == NULL) |
| 11171 | { |
| 11172 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11173 | return CMD_WARNING; |
| 11174 | } |
| 11175 | } |
| 11176 | else |
| 11177 | { |
| 11178 | bgp = bgp_get_default (); |
| 11179 | if (bgp == NULL) |
| 11180 | { |
| 11181 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11182 | return CMD_WARNING; |
| 11183 | } |
| 11184 | } |
| 11185 | |
| 11186 | if (argc == 3) |
| 11187 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11188 | else |
| 11189 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11190 | |
| 11191 | if (! peer) |
| 11192 | return CMD_WARNING; |
| 11193 | |
| 11194 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 11195 | { |
| 11196 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11197 | VTY_NEWLINE); |
| 11198 | return CMD_WARNING; |
| 11199 | } |
| 11200 | |
| 11201 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 11202 | PEER_FLAG_RSERVER_CLIENT)) |
| 11203 | { |
| 11204 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11205 | VTY_NEWLINE); |
| 11206 | return CMD_WARNING; |
| 11207 | } |
| 11208 | |
| 11209 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 11210 | (argc == 3) ? argv[2] : argv[1], |
| 11211 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 11212 | } |
| 11213 | |
| 11214 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 11215 | show_ip_bgp_rsclient_prefix_cmd, |
| 11216 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11217 | SHOW_STR |
| 11218 | IP_STR |
| 11219 | BGP_STR |
| 11220 | "Information about Route Server Client\n" |
| 11221 | NEIGHBOR_ADDR_STR |
| 11222 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11223 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11224 | DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 11225 | show_bgp_view_ipv4_safi_rsclient_prefix_cmd, |
| 11226 | "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11227 | SHOW_STR |
| 11228 | BGP_STR |
| 11229 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11230 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11231 | "Address family\n" |
| 11232 | "Address Family modifier\n" |
| 11233 | "Address Family modifier\n" |
| 11234 | "Information about Route Server Client\n" |
| 11235 | NEIGHBOR_ADDR_STR |
| 11236 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 11237 | { |
| 11238 | struct bgp *bgp; |
| 11239 | struct peer *peer; |
| 11240 | safi_t safi; |
| 11241 | |
| 11242 | /* BGP structure lookup. */ |
| 11243 | if (argc == 4) |
| 11244 | { |
| 11245 | bgp = bgp_lookup_by_name (argv[0]); |
| 11246 | if (bgp == NULL) |
| 11247 | { |
| 11248 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11249 | return CMD_WARNING; |
| 11250 | } |
| 11251 | } |
| 11252 | else |
| 11253 | { |
| 11254 | bgp = bgp_get_default (); |
| 11255 | if (bgp == NULL) |
| 11256 | { |
| 11257 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11258 | return CMD_WARNING; |
| 11259 | } |
| 11260 | } |
| 11261 | |
| 11262 | if (argc == 4) { |
| 11263 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11264 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11265 | } else { |
| 11266 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11267 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11268 | } |
| 11269 | |
| 11270 | if (! peer) |
| 11271 | return CMD_WARNING; |
| 11272 | |
| 11273 | if (! peer->afc[AFI_IP][safi]) |
| 11274 | { |
| 11275 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11276 | VTY_NEWLINE); |
| 11277 | return CMD_WARNING; |
| 11278 | } |
| 11279 | |
| 11280 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], |
| 11281 | PEER_FLAG_RSERVER_CLIENT)) |
| 11282 | { |
| 11283 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11284 | VTY_NEWLINE); |
| 11285 | return CMD_WARNING; |
| 11286 | } |
| 11287 | |
| 11288 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi], |
| 11289 | (argc == 4) ? argv[3] : argv[2], |
| 11290 | AFI_IP, safi, NULL, 1); |
| 11291 | } |
| 11292 | |
| 11293 | ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix, |
| 11294 | show_bgp_ipv4_safi_rsclient_prefix_cmd, |
| 11295 | "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 11296 | SHOW_STR |
| 11297 | BGP_STR |
| 11298 | "Address family\n" |
| 11299 | "Address Family modifier\n" |
| 11300 | "Address Family modifier\n" |
| 11301 | "Information about Route Server Client\n" |
| 11302 | NEIGHBOR_ADDR_STR |
| 11303 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11304 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11305 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11306 | DEFUN (show_bgp_view_neighbor_routes, |
| 11307 | show_bgp_view_neighbor_routes_cmd, |
| 11308 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 11309 | SHOW_STR |
| 11310 | BGP_STR |
| 11311 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11312 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11313 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11314 | "Neighbor to display information about\n" |
| 11315 | "Neighbor to display information about\n" |
| 11316 | "Display routes learned from neighbor\n") |
| 11317 | { |
| 11318 | struct peer *peer; |
| 11319 | |
| 11320 | if (argc == 2) |
| 11321 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11322 | else |
| 11323 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11324 | |
| 11325 | if (! peer) |
| 11326 | return CMD_WARNING; |
| 11327 | |
| 11328 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11329 | bgp_show_type_neighbor); |
| 11330 | } |
| 11331 | |
| 11332 | ALIAS (show_bgp_view_neighbor_routes, |
| 11333 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 11334 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11335 | SHOW_STR |
| 11336 | BGP_STR |
| 11337 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11338 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11339 | "Address family\n" |
| 11340 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11341 | "Neighbor to display information about\n" |
| 11342 | "Neighbor to display information about\n" |
| 11343 | "Display routes learned from neighbor\n") |
| 11344 | |
| 11345 | DEFUN (show_bgp_view_neighbor_damp, |
| 11346 | show_bgp_view_neighbor_damp_cmd, |
| 11347 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11348 | SHOW_STR |
| 11349 | BGP_STR |
| 11350 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11351 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11352 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11353 | "Neighbor to display information about\n" |
| 11354 | "Neighbor to display information about\n" |
| 11355 | "Display the dampened routes received from neighbor\n") |
| 11356 | { |
| 11357 | struct peer *peer; |
| 11358 | |
| 11359 | if (argc == 2) |
| 11360 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11361 | else |
| 11362 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11363 | |
| 11364 | if (! peer) |
| 11365 | return CMD_WARNING; |
| 11366 | |
| 11367 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11368 | bgp_show_type_damp_neighbor); |
| 11369 | } |
| 11370 | |
| 11371 | ALIAS (show_bgp_view_neighbor_damp, |
| 11372 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 11373 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11374 | SHOW_STR |
| 11375 | BGP_STR |
| 11376 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11377 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11378 | "Address family\n" |
| 11379 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11380 | "Neighbor to display information about\n" |
| 11381 | "Neighbor to display information about\n" |
| 11382 | "Display the dampened routes received from neighbor\n") |
| 11383 | |
| 11384 | DEFUN (show_bgp_view_neighbor_flap, |
| 11385 | show_bgp_view_neighbor_flap_cmd, |
| 11386 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11387 | SHOW_STR |
| 11388 | BGP_STR |
| 11389 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11390 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11391 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11392 | "Neighbor to display information about\n" |
| 11393 | "Neighbor to display information about\n" |
| 11394 | "Display flap statistics of the routes learned from neighbor\n") |
| 11395 | { |
| 11396 | struct peer *peer; |
| 11397 | |
| 11398 | if (argc == 2) |
| 11399 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11400 | else |
| 11401 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11402 | |
| 11403 | if (! peer) |
| 11404 | return CMD_WARNING; |
| 11405 | |
| 11406 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 11407 | bgp_show_type_flap_neighbor); |
| 11408 | } |
| 11409 | |
| 11410 | ALIAS (show_bgp_view_neighbor_flap, |
| 11411 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 11412 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11413 | SHOW_STR |
| 11414 | BGP_STR |
| 11415 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11416 | "View name\n" |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11417 | "Address family\n" |
| 11418 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11419 | "Neighbor to display information about\n" |
| 11420 | "Neighbor to display information about\n" |
| 11421 | "Display flap statistics of the routes learned from neighbor\n") |
| 11422 | |
| 11423 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11424 | show_bgp_neighbor_routes_cmd, |
| 11425 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11426 | SHOW_STR |
| 11427 | BGP_STR |
| 11428 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11429 | "Neighbor to display information about\n" |
| 11430 | "Neighbor to display information about\n" |
| 11431 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11432 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11433 | |
| 11434 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11435 | show_bgp_ipv6_neighbor_routes_cmd, |
| 11436 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 11437 | SHOW_STR |
| 11438 | BGP_STR |
| 11439 | "Address family\n" |
| 11440 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11441 | "Neighbor to display information about\n" |
| 11442 | "Neighbor to display information about\n" |
| 11443 | "Display routes learned from neighbor\n") |
| 11444 | |
| 11445 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11446 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11447 | ipv6_bgp_neighbor_routes_cmd, |
| 11448 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11449 | SHOW_STR |
| 11450 | IPV6_STR |
| 11451 | BGP_STR |
| 11452 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11453 | "Neighbor to display information about\n" |
| 11454 | "Neighbor to display information about\n" |
| 11455 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11456 | |
| 11457 | /* old command */ |
| 11458 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 11459 | ipv6_mbgp_neighbor_routes_cmd, |
| 11460 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 11461 | SHOW_STR |
| 11462 | IPV6_STR |
| 11463 | MBGP_STR |
| 11464 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11465 | "Neighbor to display information about\n" |
| 11466 | "Neighbor to display information about\n" |
| 11467 | "Display routes learned from neighbor\n") |
| 11468 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11469 | struct peer *peer; |
| 11470 | |
| 11471 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11472 | if (! peer) |
| 11473 | return CMD_WARNING; |
| 11474 | |
| 11475 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11476 | bgp_show_type_neighbor); |
| 11477 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 11478 | |
| 11479 | ALIAS (show_bgp_view_neighbor_flap, |
| 11480 | show_bgp_neighbor_flap_cmd, |
| 11481 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11482 | SHOW_STR |
| 11483 | BGP_STR |
| 11484 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11485 | "Neighbor to display information about\n" |
| 11486 | "Neighbor to display information about\n" |
| 11487 | "Display flap statistics of the routes learned from neighbor\n") |
| 11488 | |
| 11489 | ALIAS (show_bgp_view_neighbor_flap, |
| 11490 | show_bgp_ipv6_neighbor_flap_cmd, |
| 11491 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 11492 | SHOW_STR |
| 11493 | BGP_STR |
| 11494 | "Address family\n" |
| 11495 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11496 | "Neighbor to display information about\n" |
| 11497 | "Neighbor to display information about\n" |
| 11498 | "Display flap statistics of the routes learned from neighbor\n") |
| 11499 | |
| 11500 | ALIAS (show_bgp_view_neighbor_damp, |
| 11501 | show_bgp_neighbor_damp_cmd, |
| 11502 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11503 | SHOW_STR |
| 11504 | BGP_STR |
| 11505 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11506 | "Neighbor to display information about\n" |
| 11507 | "Neighbor to display information about\n" |
| 11508 | "Display the dampened routes received from neighbor\n") |
| 11509 | |
| 11510 | ALIAS (show_bgp_view_neighbor_damp, |
| 11511 | show_bgp_ipv6_neighbor_damp_cmd, |
| 11512 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 11513 | SHOW_STR |
| 11514 | BGP_STR |
| 11515 | "Address family\n" |
| 11516 | "Detailed information on TCP and BGP neighbor connections\n" |
| 11517 | "Neighbor to display information about\n" |
| 11518 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 11519 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11520 | |
| 11521 | DEFUN (show_bgp_view_rsclient, |
| 11522 | show_bgp_view_rsclient_cmd, |
| 11523 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 11524 | SHOW_STR |
| 11525 | BGP_STR |
| 11526 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11527 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11528 | "Information about Route Server Client\n" |
| 11529 | NEIGHBOR_ADDR_STR) |
| 11530 | { |
| 11531 | struct bgp_table *table; |
| 11532 | struct peer *peer; |
| 11533 | |
| 11534 | if (argc == 2) |
| 11535 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11536 | else |
| 11537 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11538 | |
| 11539 | if (! peer) |
| 11540 | return CMD_WARNING; |
| 11541 | |
| 11542 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11543 | { |
| 11544 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11545 | VTY_NEWLINE); |
| 11546 | return CMD_WARNING; |
| 11547 | } |
| 11548 | |
| 11549 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11550 | PEER_FLAG_RSERVER_CLIENT)) |
| 11551 | { |
| 11552 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11553 | VTY_NEWLINE); |
| 11554 | return CMD_WARNING; |
| 11555 | } |
| 11556 | |
| 11557 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 11558 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 11559 | 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] | 11560 | } |
| 11561 | |
| 11562 | ALIAS (show_bgp_view_rsclient, |
| 11563 | show_bgp_rsclient_cmd, |
| 11564 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 11565 | SHOW_STR |
| 11566 | BGP_STR |
| 11567 | "Information about Route Server Client\n" |
| 11568 | NEIGHBOR_ADDR_STR) |
| 11569 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11570 | DEFUN (show_bgp_view_ipv6_safi_rsclient, |
| 11571 | show_bgp_view_ipv6_safi_rsclient_cmd, |
| 11572 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11573 | SHOW_STR |
| 11574 | BGP_STR |
| 11575 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11576 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11577 | "Address family\n" |
| 11578 | "Address Family modifier\n" |
| 11579 | "Address Family modifier\n" |
| 11580 | "Information about Route Server Client\n" |
| 11581 | NEIGHBOR_ADDR_STR) |
| 11582 | { |
| 11583 | struct bgp_table *table; |
| 11584 | struct peer *peer; |
| 11585 | safi_t safi; |
| 11586 | |
| 11587 | if (argc == 3) { |
| 11588 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11589 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11590 | } else { |
| 11591 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11592 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11593 | } |
| 11594 | |
| 11595 | if (! peer) |
| 11596 | return CMD_WARNING; |
| 11597 | |
| 11598 | if (! peer->afc[AFI_IP6][safi]) |
| 11599 | { |
| 11600 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11601 | VTY_NEWLINE); |
| 11602 | return CMD_WARNING; |
| 11603 | } |
| 11604 | |
| 11605 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11606 | PEER_FLAG_RSERVER_CLIENT)) |
| 11607 | { |
| 11608 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11609 | VTY_NEWLINE); |
| 11610 | return CMD_WARNING; |
| 11611 | } |
| 11612 | |
| 11613 | table = peer->rib[AFI_IP6][safi]; |
| 11614 | |
| 11615 | return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL); |
| 11616 | } |
| 11617 | |
| 11618 | ALIAS (show_bgp_view_ipv6_safi_rsclient, |
| 11619 | show_bgp_ipv6_safi_rsclient_cmd, |
| 11620 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)", |
| 11621 | SHOW_STR |
| 11622 | BGP_STR |
| 11623 | "Address family\n" |
| 11624 | "Address Family modifier\n" |
| 11625 | "Address Family modifier\n" |
| 11626 | "Information about Route Server Client\n" |
| 11627 | NEIGHBOR_ADDR_STR) |
| 11628 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11629 | DEFUN (show_bgp_view_rsclient_route, |
| 11630 | show_bgp_view_rsclient_route_cmd, |
| 11631 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11632 | SHOW_STR |
| 11633 | BGP_STR |
| 11634 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11635 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11636 | "Information about Route Server Client\n" |
| 11637 | NEIGHBOR_ADDR_STR |
| 11638 | "Network in the BGP routing table to display\n") |
| 11639 | { |
| 11640 | struct bgp *bgp; |
| 11641 | struct peer *peer; |
| 11642 | |
| 11643 | /* BGP structure lookup. */ |
| 11644 | if (argc == 3) |
| 11645 | { |
| 11646 | bgp = bgp_lookup_by_name (argv[0]); |
| 11647 | if (bgp == NULL) |
| 11648 | { |
| 11649 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11650 | return CMD_WARNING; |
| 11651 | } |
| 11652 | } |
| 11653 | else |
| 11654 | { |
| 11655 | bgp = bgp_get_default (); |
| 11656 | if (bgp == NULL) |
| 11657 | { |
| 11658 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11659 | return CMD_WARNING; |
| 11660 | } |
| 11661 | } |
| 11662 | |
| 11663 | if (argc == 3) |
| 11664 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11665 | else |
| 11666 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11667 | |
| 11668 | if (! peer) |
| 11669 | return CMD_WARNING; |
| 11670 | |
| 11671 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11672 | { |
| 11673 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11674 | VTY_NEWLINE); |
| 11675 | return CMD_WARNING; |
| 11676 | } |
| 11677 | |
| 11678 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11679 | PEER_FLAG_RSERVER_CLIENT)) |
| 11680 | { |
| 11681 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11682 | VTY_NEWLINE); |
| 11683 | return CMD_WARNING; |
| 11684 | } |
| 11685 | |
| 11686 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11687 | (argc == 3) ? argv[2] : argv[1], |
| 11688 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 11689 | } |
| 11690 | |
| 11691 | ALIAS (show_bgp_view_rsclient_route, |
| 11692 | show_bgp_rsclient_route_cmd, |
| 11693 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11694 | SHOW_STR |
| 11695 | BGP_STR |
| 11696 | "Information about Route Server Client\n" |
| 11697 | NEIGHBOR_ADDR_STR |
| 11698 | "Network in the BGP routing table to display\n") |
| 11699 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11700 | DEFUN (show_bgp_view_ipv6_safi_rsclient_route, |
| 11701 | show_bgp_view_ipv6_safi_rsclient_route_cmd, |
| 11702 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11703 | SHOW_STR |
| 11704 | BGP_STR |
| 11705 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11706 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11707 | "Address family\n" |
| 11708 | "Address Family modifier\n" |
| 11709 | "Address Family modifier\n" |
| 11710 | "Information about Route Server Client\n" |
| 11711 | NEIGHBOR_ADDR_STR |
| 11712 | "Network in the BGP routing table to display\n") |
| 11713 | { |
| 11714 | struct bgp *bgp; |
| 11715 | struct peer *peer; |
| 11716 | safi_t safi; |
| 11717 | |
| 11718 | /* BGP structure lookup. */ |
| 11719 | if (argc == 4) |
| 11720 | { |
| 11721 | bgp = bgp_lookup_by_name (argv[0]); |
| 11722 | if (bgp == NULL) |
| 11723 | { |
| 11724 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11725 | return CMD_WARNING; |
| 11726 | } |
| 11727 | } |
| 11728 | else |
| 11729 | { |
| 11730 | bgp = bgp_get_default (); |
| 11731 | if (bgp == NULL) |
| 11732 | { |
| 11733 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11734 | return CMD_WARNING; |
| 11735 | } |
| 11736 | } |
| 11737 | |
| 11738 | if (argc == 4) { |
| 11739 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11740 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11741 | } else { |
| 11742 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11743 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11744 | } |
| 11745 | |
| 11746 | if (! peer) |
| 11747 | return CMD_WARNING; |
| 11748 | |
| 11749 | if (! peer->afc[AFI_IP6][safi]) |
| 11750 | { |
| 11751 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11752 | VTY_NEWLINE); |
| 11753 | return CMD_WARNING; |
| 11754 | } |
| 11755 | |
| 11756 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11757 | PEER_FLAG_RSERVER_CLIENT)) |
| 11758 | { |
| 11759 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11760 | VTY_NEWLINE); |
| 11761 | return CMD_WARNING; |
| 11762 | } |
| 11763 | |
| 11764 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11765 | (argc == 4) ? argv[3] : argv[2], |
| 11766 | AFI_IP6, safi, NULL, 0); |
| 11767 | } |
| 11768 | |
| 11769 | ALIAS (show_bgp_view_ipv6_safi_rsclient_route, |
| 11770 | show_bgp_ipv6_safi_rsclient_route_cmd, |
| 11771 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 11772 | SHOW_STR |
| 11773 | BGP_STR |
| 11774 | "Address family\n" |
| 11775 | "Address Family modifier\n" |
| 11776 | "Address Family modifier\n" |
| 11777 | "Information about Route Server Client\n" |
| 11778 | NEIGHBOR_ADDR_STR |
| 11779 | "Network in the BGP routing table to display\n") |
| 11780 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11781 | DEFUN (show_bgp_view_rsclient_prefix, |
| 11782 | show_bgp_view_rsclient_prefix_cmd, |
| 11783 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11784 | SHOW_STR |
| 11785 | BGP_STR |
| 11786 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11787 | "View name\n" |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 11788 | "Information about Route Server Client\n" |
| 11789 | NEIGHBOR_ADDR_STR |
| 11790 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11791 | { |
| 11792 | struct bgp *bgp; |
| 11793 | struct peer *peer; |
| 11794 | |
| 11795 | /* BGP structure lookup. */ |
| 11796 | if (argc == 3) |
| 11797 | { |
| 11798 | bgp = bgp_lookup_by_name (argv[0]); |
| 11799 | if (bgp == NULL) |
| 11800 | { |
| 11801 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11802 | return CMD_WARNING; |
| 11803 | } |
| 11804 | } |
| 11805 | else |
| 11806 | { |
| 11807 | bgp = bgp_get_default (); |
| 11808 | if (bgp == NULL) |
| 11809 | { |
| 11810 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11811 | return CMD_WARNING; |
| 11812 | } |
| 11813 | } |
| 11814 | |
| 11815 | if (argc == 3) |
| 11816 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 11817 | else |
| 11818 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 11819 | |
| 11820 | if (! peer) |
| 11821 | return CMD_WARNING; |
| 11822 | |
| 11823 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 11824 | { |
| 11825 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11826 | VTY_NEWLINE); |
| 11827 | return CMD_WARNING; |
| 11828 | } |
| 11829 | |
| 11830 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 11831 | PEER_FLAG_RSERVER_CLIENT)) |
| 11832 | { |
| 11833 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11834 | VTY_NEWLINE); |
| 11835 | return CMD_WARNING; |
| 11836 | } |
| 11837 | |
| 11838 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 11839 | (argc == 3) ? argv[2] : argv[1], |
| 11840 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 11841 | } |
| 11842 | |
| 11843 | ALIAS (show_bgp_view_rsclient_prefix, |
| 11844 | show_bgp_rsclient_prefix_cmd, |
| 11845 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11846 | SHOW_STR |
| 11847 | BGP_STR |
| 11848 | "Information about Route Server Client\n" |
| 11849 | NEIGHBOR_ADDR_STR |
| 11850 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11851 | |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11852 | DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11853 | show_bgp_view_ipv6_safi_rsclient_prefix_cmd, |
| 11854 | "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11855 | SHOW_STR |
| 11856 | BGP_STR |
| 11857 | "BGP view\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 11858 | "View name\n" |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 11859 | "Address family\n" |
| 11860 | "Address Family modifier\n" |
| 11861 | "Address Family modifier\n" |
| 11862 | "Information about Route Server Client\n" |
| 11863 | NEIGHBOR_ADDR_STR |
| 11864 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11865 | { |
| 11866 | struct bgp *bgp; |
| 11867 | struct peer *peer; |
| 11868 | safi_t safi; |
| 11869 | |
| 11870 | /* BGP structure lookup. */ |
| 11871 | if (argc == 4) |
| 11872 | { |
| 11873 | bgp = bgp_lookup_by_name (argv[0]); |
| 11874 | if (bgp == NULL) |
| 11875 | { |
| 11876 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 11877 | return CMD_WARNING; |
| 11878 | } |
| 11879 | } |
| 11880 | else |
| 11881 | { |
| 11882 | bgp = bgp_get_default (); |
| 11883 | if (bgp == NULL) |
| 11884 | { |
| 11885 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 11886 | return CMD_WARNING; |
| 11887 | } |
| 11888 | } |
| 11889 | |
| 11890 | if (argc == 4) { |
| 11891 | peer = peer_lookup_in_view (vty, argv[0], argv[2]); |
| 11892 | safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11893 | } else { |
| 11894 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 11895 | safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; |
| 11896 | } |
| 11897 | |
| 11898 | if (! peer) |
| 11899 | return CMD_WARNING; |
| 11900 | |
| 11901 | if (! peer->afc[AFI_IP6][safi]) |
| 11902 | { |
| 11903 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 11904 | VTY_NEWLINE); |
| 11905 | return CMD_WARNING; |
| 11906 | } |
| 11907 | |
| 11908 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi], |
| 11909 | PEER_FLAG_RSERVER_CLIENT)) |
| 11910 | { |
| 11911 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 11912 | VTY_NEWLINE); |
| 11913 | return CMD_WARNING; |
| 11914 | } |
| 11915 | |
| 11916 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi], |
| 11917 | (argc == 4) ? argv[3] : argv[2], |
| 11918 | AFI_IP6, safi, NULL, 1); |
| 11919 | } |
| 11920 | |
| 11921 | ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix, |
| 11922 | show_bgp_ipv6_safi_rsclient_prefix_cmd, |
| 11923 | "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 11924 | SHOW_STR |
| 11925 | BGP_STR |
| 11926 | "Address family\n" |
| 11927 | "Address Family modifier\n" |
| 11928 | "Address Family modifier\n" |
| 11929 | "Information about Route Server Client\n" |
| 11930 | NEIGHBOR_ADDR_STR |
| 11931 | "IP prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 11932 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11933 | #endif /* HAVE_IPV6 */ |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 11934 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11935 | struct bgp_table *bgp_distance_table; |
| 11936 | |
| 11937 | struct bgp_distance |
| 11938 | { |
| 11939 | /* Distance value for the IP source prefix. */ |
| 11940 | u_char distance; |
| 11941 | |
| 11942 | /* Name of the access-list to be matched. */ |
| 11943 | char *access_list; |
| 11944 | }; |
| 11945 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11946 | static struct bgp_distance * |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 11947 | bgp_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11948 | { |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 11949 | return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11950 | } |
| 11951 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11952 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11953 | bgp_distance_free (struct bgp_distance *bdistance) |
| 11954 | { |
| 11955 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 11956 | } |
| 11957 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 11958 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 11959 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 11960 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 11961 | { |
| 11962 | int ret; |
| 11963 | struct prefix_ipv4 p; |
| 11964 | u_char distance; |
| 11965 | struct bgp_node *rn; |
| 11966 | struct bgp_distance *bdistance; |
| 11967 | |
| 11968 | ret = str2prefix_ipv4 (ip_str, &p); |
| 11969 | if (ret == 0) |
| 11970 | { |
| 11971 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 11972 | return CMD_WARNING; |
| 11973 | } |
| 11974 | |
| 11975 | distance = atoi (distance_str); |
| 11976 | |
| 11977 | /* Get BGP distance node. */ |
| 11978 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 11979 | if (rn->info) |
| 11980 | { |
| 11981 | bdistance = rn->info; |
| 11982 | bgp_unlock_node (rn); |
| 11983 | } |
| 11984 | else |
| 11985 | { |
| 11986 | bdistance = bgp_distance_new (); |
| 11987 | rn->info = bdistance; |
| 11988 | } |
| 11989 | |
| 11990 | /* Set distance value. */ |
| 11991 | bdistance->distance = distance; |
| 11992 | |
| 11993 | /* Reset access-list configuration. */ |
| 11994 | if (bdistance->access_list) |
| 11995 | { |
| 11996 | free (bdistance->access_list); |
| 11997 | bdistance->access_list = NULL; |
| 11998 | } |
| 11999 | if (access_list_str) |
| 12000 | bdistance->access_list = strdup (access_list_str); |
| 12001 | |
| 12002 | return CMD_SUCCESS; |
| 12003 | } |
| 12004 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12005 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 12006 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 12007 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12008 | { |
| 12009 | int ret; |
| 12010 | struct prefix_ipv4 p; |
| 12011 | u_char distance; |
| 12012 | struct bgp_node *rn; |
| 12013 | struct bgp_distance *bdistance; |
| 12014 | |
| 12015 | ret = str2prefix_ipv4 (ip_str, &p); |
| 12016 | if (ret == 0) |
| 12017 | { |
| 12018 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 12019 | return CMD_WARNING; |
| 12020 | } |
| 12021 | |
| 12022 | distance = atoi (distance_str); |
| 12023 | |
| 12024 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 12025 | if (! rn) |
| 12026 | { |
| 12027 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 12028 | return CMD_WARNING; |
| 12029 | } |
| 12030 | |
| 12031 | bdistance = rn->info; |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 12032 | |
| 12033 | if (bdistance->distance != distance) |
| 12034 | { |
| 12035 | vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); |
| 12036 | return CMD_WARNING; |
| 12037 | } |
| 12038 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12039 | if (bdistance->access_list) |
| 12040 | free (bdistance->access_list); |
| 12041 | bgp_distance_free (bdistance); |
| 12042 | |
| 12043 | rn->info = NULL; |
| 12044 | bgp_unlock_node (rn); |
| 12045 | bgp_unlock_node (rn); |
| 12046 | |
| 12047 | return CMD_SUCCESS; |
| 12048 | } |
| 12049 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12050 | /* Apply BGP information to distance method. */ |
| 12051 | u_char |
| 12052 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 12053 | { |
| 12054 | struct bgp_node *rn; |
| 12055 | struct prefix_ipv4 q; |
| 12056 | struct peer *peer; |
| 12057 | struct bgp_distance *bdistance; |
| 12058 | struct access_list *alist; |
| 12059 | struct bgp_static *bgp_static; |
| 12060 | |
| 12061 | if (! bgp) |
| 12062 | return 0; |
| 12063 | |
| 12064 | if (p->family != AF_INET) |
| 12065 | return 0; |
| 12066 | |
| 12067 | peer = rinfo->peer; |
| 12068 | |
| 12069 | if (peer->su.sa.sa_family != AF_INET) |
| 12070 | return 0; |
| 12071 | |
| 12072 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 12073 | q.family = AF_INET; |
| 12074 | q.prefix = peer->su.sin.sin_addr; |
| 12075 | q.prefixlen = IPV4_MAX_BITLEN; |
| 12076 | |
| 12077 | /* Check source address. */ |
| 12078 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 12079 | if (rn) |
| 12080 | { |
| 12081 | bdistance = rn->info; |
| 12082 | bgp_unlock_node (rn); |
| 12083 | |
| 12084 | if (bdistance->access_list) |
| 12085 | { |
| 12086 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 12087 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 12088 | return bdistance->distance; |
| 12089 | } |
| 12090 | else |
| 12091 | return bdistance->distance; |
| 12092 | } |
| 12093 | |
| 12094 | /* Backdoor check. */ |
| 12095 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 12096 | if (rn) |
| 12097 | { |
| 12098 | bgp_static = rn->info; |
| 12099 | bgp_unlock_node (rn); |
| 12100 | |
| 12101 | if (bgp_static->backdoor) |
| 12102 | { |
| 12103 | if (bgp->distance_local) |
| 12104 | return bgp->distance_local; |
| 12105 | else |
| 12106 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 12107 | } |
| 12108 | } |
| 12109 | |
Jorge Boncompte [DTI2] | 6d85b15 | 2012-05-07 16:52:54 +0000 | [diff] [blame] | 12110 | if (peer->sort == BGP_PEER_EBGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12111 | { |
| 12112 | if (bgp->distance_ebgp) |
| 12113 | return bgp->distance_ebgp; |
| 12114 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 12115 | } |
| 12116 | else |
| 12117 | { |
| 12118 | if (bgp->distance_ibgp) |
| 12119 | return bgp->distance_ibgp; |
| 12120 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 12121 | } |
| 12122 | } |
| 12123 | |
| 12124 | DEFUN (bgp_distance, |
| 12125 | bgp_distance_cmd, |
| 12126 | "distance bgp <1-255> <1-255> <1-255>", |
| 12127 | "Define an administrative distance\n" |
| 12128 | "BGP distance\n" |
| 12129 | "Distance for routes external to the AS\n" |
| 12130 | "Distance for routes internal to the AS\n" |
| 12131 | "Distance for local routes\n") |
| 12132 | { |
| 12133 | struct bgp *bgp; |
| 12134 | |
| 12135 | bgp = vty->index; |
| 12136 | |
| 12137 | bgp->distance_ebgp = atoi (argv[0]); |
| 12138 | bgp->distance_ibgp = atoi (argv[1]); |
| 12139 | bgp->distance_local = atoi (argv[2]); |
| 12140 | return CMD_SUCCESS; |
| 12141 | } |
| 12142 | |
| 12143 | DEFUN (no_bgp_distance, |
| 12144 | no_bgp_distance_cmd, |
| 12145 | "no distance bgp <1-255> <1-255> <1-255>", |
| 12146 | NO_STR |
| 12147 | "Define an administrative distance\n" |
| 12148 | "BGP distance\n" |
| 12149 | "Distance for routes external to the AS\n" |
| 12150 | "Distance for routes internal to the AS\n" |
| 12151 | "Distance for local routes\n") |
| 12152 | { |
| 12153 | struct bgp *bgp; |
| 12154 | |
| 12155 | bgp = vty->index; |
| 12156 | |
| 12157 | bgp->distance_ebgp= 0; |
| 12158 | bgp->distance_ibgp = 0; |
| 12159 | bgp->distance_local = 0; |
| 12160 | return CMD_SUCCESS; |
| 12161 | } |
| 12162 | |
| 12163 | ALIAS (no_bgp_distance, |
| 12164 | no_bgp_distance2_cmd, |
| 12165 | "no distance bgp", |
| 12166 | NO_STR |
| 12167 | "Define an administrative distance\n" |
| 12168 | "BGP distance\n") |
| 12169 | |
| 12170 | DEFUN (bgp_distance_source, |
| 12171 | bgp_distance_source_cmd, |
| 12172 | "distance <1-255> A.B.C.D/M", |
| 12173 | "Define an administrative distance\n" |
| 12174 | "Administrative distance\n" |
| 12175 | "IP source prefix\n") |
| 12176 | { |
| 12177 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 12178 | return CMD_SUCCESS; |
| 12179 | } |
| 12180 | |
| 12181 | DEFUN (no_bgp_distance_source, |
| 12182 | no_bgp_distance_source_cmd, |
| 12183 | "no distance <1-255> A.B.C.D/M", |
| 12184 | NO_STR |
| 12185 | "Define an administrative distance\n" |
| 12186 | "Administrative distance\n" |
| 12187 | "IP source prefix\n") |
| 12188 | { |
| 12189 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 12190 | return CMD_SUCCESS; |
| 12191 | } |
| 12192 | |
| 12193 | DEFUN (bgp_distance_source_access_list, |
| 12194 | bgp_distance_source_access_list_cmd, |
| 12195 | "distance <1-255> A.B.C.D/M WORD", |
| 12196 | "Define an administrative distance\n" |
| 12197 | "Administrative distance\n" |
| 12198 | "IP source prefix\n" |
| 12199 | "Access list name\n") |
| 12200 | { |
| 12201 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 12202 | return CMD_SUCCESS; |
| 12203 | } |
| 12204 | |
| 12205 | DEFUN (no_bgp_distance_source_access_list, |
| 12206 | no_bgp_distance_source_access_list_cmd, |
| 12207 | "no distance <1-255> A.B.C.D/M WORD", |
| 12208 | NO_STR |
| 12209 | "Define an administrative distance\n" |
| 12210 | "Administrative distance\n" |
| 12211 | "IP source prefix\n" |
| 12212 | "Access list name\n") |
| 12213 | { |
| 12214 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 12215 | return CMD_SUCCESS; |
| 12216 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12217 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12218 | DEFUN (bgp_damp_set, |
| 12219 | bgp_damp_set_cmd, |
| 12220 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 12221 | "BGP Specific commands\n" |
| 12222 | "Enable route-flap dampening\n" |
| 12223 | "Half-life time for the penalty\n" |
| 12224 | "Value to start reusing a route\n" |
| 12225 | "Value to start suppressing a route\n" |
| 12226 | "Maximum duration to suppress a stable route\n") |
| 12227 | { |
| 12228 | struct bgp *bgp; |
| 12229 | int half = DEFAULT_HALF_LIFE * 60; |
| 12230 | int reuse = DEFAULT_REUSE; |
| 12231 | int suppress = DEFAULT_SUPPRESS; |
| 12232 | int max = 4 * half; |
| 12233 | |
| 12234 | if (argc == 4) |
| 12235 | { |
| 12236 | half = atoi (argv[0]) * 60; |
| 12237 | reuse = atoi (argv[1]); |
| 12238 | suppress = atoi (argv[2]); |
| 12239 | max = atoi (argv[3]) * 60; |
| 12240 | } |
| 12241 | else if (argc == 1) |
| 12242 | { |
| 12243 | half = atoi (argv[0]) * 60; |
| 12244 | max = 4 * half; |
| 12245 | } |
| 12246 | |
| 12247 | bgp = vty->index; |
Balaji | aa7dbb1 | 2015-03-16 16:55:26 +0000 | [diff] [blame] | 12248 | |
| 12249 | if (suppress < reuse) |
| 12250 | { |
| 12251 | vty_out (vty, "Suppress value cannot be less than reuse value %s", |
| 12252 | VTY_NEWLINE); |
| 12253 | return 0; |
| 12254 | } |
| 12255 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12256 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 12257 | half, reuse, suppress, max); |
| 12258 | } |
| 12259 | |
| 12260 | ALIAS (bgp_damp_set, |
| 12261 | bgp_damp_set2_cmd, |
| 12262 | "bgp dampening <1-45>", |
| 12263 | "BGP Specific commands\n" |
| 12264 | "Enable route-flap dampening\n" |
| 12265 | "Half-life time for the penalty\n") |
| 12266 | |
| 12267 | ALIAS (bgp_damp_set, |
| 12268 | bgp_damp_set3_cmd, |
| 12269 | "bgp dampening", |
| 12270 | "BGP Specific commands\n" |
| 12271 | "Enable route-flap dampening\n") |
| 12272 | |
| 12273 | DEFUN (bgp_damp_unset, |
| 12274 | bgp_damp_unset_cmd, |
| 12275 | "no bgp dampening", |
| 12276 | NO_STR |
| 12277 | "BGP Specific commands\n" |
| 12278 | "Enable route-flap dampening\n") |
| 12279 | { |
| 12280 | struct bgp *bgp; |
| 12281 | |
| 12282 | bgp = vty->index; |
| 12283 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 12284 | } |
| 12285 | |
| 12286 | ALIAS (bgp_damp_unset, |
| 12287 | bgp_damp_unset2_cmd, |
| 12288 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 12289 | NO_STR |
| 12290 | "BGP Specific commands\n" |
| 12291 | "Enable route-flap dampening\n" |
| 12292 | "Half-life time for the penalty\n" |
| 12293 | "Value to start reusing a route\n" |
| 12294 | "Value to start suppressing a route\n" |
| 12295 | "Maximum duration to suppress a stable route\n") |
| 12296 | |
| 12297 | DEFUN (show_ip_bgp_dampened_paths, |
| 12298 | show_ip_bgp_dampened_paths_cmd, |
| 12299 | "show ip bgp dampened-paths", |
| 12300 | SHOW_STR |
| 12301 | IP_STR |
| 12302 | BGP_STR |
| 12303 | "Display paths suppressed due to dampening\n") |
| 12304 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12305 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 12306 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12307 | } |
| 12308 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12309 | ALIAS (show_ip_bgp_dampened_paths, |
| 12310 | show_ip_bgp_damp_dampened_paths_cmd, |
| 12311 | "show ip bgp dampening dampened-paths", |
| 12312 | SHOW_STR |
| 12313 | IP_STR |
| 12314 | BGP_STR |
| 12315 | "Display detailed information about dampening\n" |
| 12316 | "Display paths suppressed due to dampening\n") |
| 12317 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12318 | DEFUN (show_ip_bgp_flap_statistics, |
| 12319 | show_ip_bgp_flap_statistics_cmd, |
| 12320 | "show ip bgp flap-statistics", |
| 12321 | SHOW_STR |
| 12322 | IP_STR |
| 12323 | BGP_STR |
| 12324 | "Display flap statistics of routes\n") |
| 12325 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 12326 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 12327 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12328 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12329 | |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12330 | ALIAS (show_ip_bgp_flap_statistics, |
| 12331 | show_ip_bgp_damp_flap_statistics_cmd, |
| 12332 | "show ip bgp dampening flap-statistics", |
| 12333 | SHOW_STR |
| 12334 | IP_STR |
| 12335 | BGP_STR |
| 12336 | "Display detailed information about dampening\n" |
| 12337 | "Display flap statistics of routes\n") |
| 12338 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12339 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12340 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 12341 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 12342 | const char *ip_str, afi_t afi, safi_t safi, |
| 12343 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12344 | { |
| 12345 | int ret; |
| 12346 | struct prefix match; |
| 12347 | struct bgp_node *rn; |
| 12348 | struct bgp_node *rm; |
| 12349 | struct bgp_info *ri; |
| 12350 | struct bgp_info *ri_temp; |
| 12351 | struct bgp *bgp; |
| 12352 | struct bgp_table *table; |
| 12353 | |
| 12354 | /* BGP structure lookup. */ |
| 12355 | if (view_name) |
| 12356 | { |
| 12357 | bgp = bgp_lookup_by_name (view_name); |
| 12358 | if (bgp == NULL) |
| 12359 | { |
| 12360 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 12361 | return CMD_WARNING; |
| 12362 | } |
| 12363 | } |
| 12364 | else |
| 12365 | { |
| 12366 | bgp = bgp_get_default (); |
| 12367 | if (bgp == NULL) |
| 12368 | { |
| 12369 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 12370 | return CMD_WARNING; |
| 12371 | } |
| 12372 | } |
| 12373 | |
| 12374 | /* Check IP address argument. */ |
| 12375 | ret = str2prefix (ip_str, &match); |
| 12376 | if (! ret) |
| 12377 | { |
| 12378 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 12379 | return CMD_WARNING; |
| 12380 | } |
| 12381 | |
| 12382 | match.family = afi2family (afi); |
| 12383 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12384 | if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12385 | { |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12386 | 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] | 12387 | { |
| 12388 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 12389 | continue; |
| 12390 | |
| 12391 | if ((table = rn->info) != NULL) |
| 12392 | if ((rm = bgp_node_match (table, &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12393 | { |
| 12394 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 12395 | { |
| 12396 | ri = rm->info; |
| 12397 | while (ri) |
| 12398 | { |
| 12399 | if (ri->extra && ri->extra->damp_info) |
| 12400 | { |
| 12401 | ri_temp = ri->next; |
| 12402 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12403 | ri = ri_temp; |
| 12404 | } |
| 12405 | else |
| 12406 | ri = ri->next; |
| 12407 | } |
| 12408 | } |
| 12409 | |
| 12410 | bgp_unlock_node (rm); |
| 12411 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12412 | } |
| 12413 | } |
| 12414 | else |
| 12415 | { |
| 12416 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
Chris Caputo | 6c88b44 | 2010-07-27 16:28:55 +0000 | [diff] [blame] | 12417 | { |
| 12418 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 12419 | { |
| 12420 | ri = rn->info; |
| 12421 | while (ri) |
| 12422 | { |
| 12423 | if (ri->extra && ri->extra->damp_info) |
| 12424 | { |
| 12425 | ri_temp = ri->next; |
| 12426 | bgp_damp_info_free (ri->extra->damp_info, 1); |
| 12427 | ri = ri_temp; |
| 12428 | } |
| 12429 | else |
| 12430 | ri = ri->next; |
| 12431 | } |
| 12432 | } |
| 12433 | |
| 12434 | bgp_unlock_node (rn); |
| 12435 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12436 | } |
| 12437 | |
| 12438 | return CMD_SUCCESS; |
| 12439 | } |
| 12440 | |
| 12441 | DEFUN (clear_ip_bgp_dampening, |
| 12442 | clear_ip_bgp_dampening_cmd, |
| 12443 | "clear ip bgp dampening", |
| 12444 | CLEAR_STR |
| 12445 | IP_STR |
| 12446 | BGP_STR |
| 12447 | "Clear route flap dampening information\n") |
| 12448 | { |
| 12449 | bgp_damp_info_clean (); |
| 12450 | return CMD_SUCCESS; |
| 12451 | } |
| 12452 | |
| 12453 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 12454 | clear_ip_bgp_dampening_prefix_cmd, |
| 12455 | "clear ip bgp dampening A.B.C.D/M", |
| 12456 | CLEAR_STR |
| 12457 | IP_STR |
| 12458 | BGP_STR |
| 12459 | "Clear route flap dampening information\n" |
| 12460 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 12461 | { |
| 12462 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12463 | SAFI_UNICAST, NULL, 1); |
| 12464 | } |
| 12465 | |
| 12466 | DEFUN (clear_ip_bgp_dampening_address, |
| 12467 | clear_ip_bgp_dampening_address_cmd, |
| 12468 | "clear ip bgp dampening A.B.C.D", |
| 12469 | CLEAR_STR |
| 12470 | IP_STR |
| 12471 | BGP_STR |
| 12472 | "Clear route flap dampening information\n" |
| 12473 | "Network to clear damping information\n") |
| 12474 | { |
| 12475 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 12476 | SAFI_UNICAST, NULL, 0); |
| 12477 | } |
| 12478 | |
| 12479 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 12480 | clear_ip_bgp_dampening_address_mask_cmd, |
| 12481 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 12482 | CLEAR_STR |
| 12483 | IP_STR |
| 12484 | BGP_STR |
| 12485 | "Clear route flap dampening information\n" |
| 12486 | "Network to clear damping information\n" |
| 12487 | "Network mask\n") |
| 12488 | { |
| 12489 | int ret; |
| 12490 | char prefix_str[BUFSIZ]; |
| 12491 | |
| 12492 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 12493 | if (! ret) |
| 12494 | { |
| 12495 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 12496 | return CMD_WARNING; |
| 12497 | } |
| 12498 | |
| 12499 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 12500 | SAFI_UNICAST, NULL, 0); |
| 12501 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 12502 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12503 | /* also used for encap safi */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 12504 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12505 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 12506 | afi_t afi, safi_t safi, int *write) |
| 12507 | { |
| 12508 | struct bgp_node *prn; |
| 12509 | struct bgp_node *rn; |
| 12510 | struct bgp_table *table; |
| 12511 | struct prefix *p; |
| 12512 | struct prefix_rd *prd; |
| 12513 | struct bgp_static *bgp_static; |
| 12514 | u_int32_t label; |
| 12515 | char buf[SU_ADDRSTRLEN]; |
| 12516 | char rdbuf[RD_ADDRSTRLEN]; |
| 12517 | |
| 12518 | /* Network configuration. */ |
| 12519 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 12520 | if ((table = prn->info) != NULL) |
| 12521 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 12522 | if ((bgp_static = rn->info) != NULL) |
| 12523 | { |
| 12524 | p = &rn->p; |
| 12525 | prd = (struct prefix_rd *) &prn->p; |
| 12526 | |
| 12527 | /* "address-family" display. */ |
| 12528 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12529 | |
| 12530 | /* "network" configuration display. */ |
| 12531 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 12532 | label = decode_label (bgp_static->tag); |
| 12533 | |
| 12534 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 12535 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12536 | p->prefixlen, |
| 12537 | rdbuf, label); |
| 12538 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12539 | } |
| 12540 | return 0; |
| 12541 | } |
| 12542 | |
| 12543 | /* Configuration of static route announcement and aggregate |
| 12544 | information. */ |
| 12545 | int |
| 12546 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 12547 | afi_t afi, safi_t safi, int *write) |
| 12548 | { |
| 12549 | struct bgp_node *rn; |
| 12550 | struct prefix *p; |
| 12551 | struct bgp_static *bgp_static; |
| 12552 | struct bgp_aggregate *bgp_aggregate; |
| 12553 | char buf[SU_ADDRSTRLEN]; |
| 12554 | |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 12555 | if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12556 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 12557 | |
| 12558 | /* Network configuration. */ |
| 12559 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12560 | if ((bgp_static = rn->info) != NULL) |
| 12561 | { |
| 12562 | p = &rn->p; |
| 12563 | |
| 12564 | /* "address-family" display. */ |
| 12565 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12566 | |
| 12567 | /* "network" configuration display. */ |
| 12568 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12569 | { |
| 12570 | u_int32_t destination; |
| 12571 | struct in_addr netmask; |
| 12572 | |
| 12573 | destination = ntohl (p->u.prefix4.s_addr); |
| 12574 | masklen2ip (p->prefixlen, &netmask); |
| 12575 | vty_out (vty, " network %s", |
| 12576 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 12577 | |
| 12578 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 12579 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 12580 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 12581 | || p->u.prefix4.s_addr == 0) |
| 12582 | { |
| 12583 | /* Natural mask is not display. */ |
| 12584 | } |
| 12585 | else |
| 12586 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 12587 | } |
| 12588 | else |
| 12589 | { |
| 12590 | vty_out (vty, " network %s/%d", |
| 12591 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12592 | p->prefixlen); |
| 12593 | } |
| 12594 | |
| 12595 | if (bgp_static->rmap.name) |
| 12596 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12597 | else |
| 12598 | { |
| 12599 | if (bgp_static->backdoor) |
| 12600 | vty_out (vty, " backdoor"); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 12601 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12602 | |
| 12603 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12604 | } |
| 12605 | |
| 12606 | /* Aggregate-address configuration. */ |
| 12607 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 12608 | if ((bgp_aggregate = rn->info) != NULL) |
| 12609 | { |
| 12610 | p = &rn->p; |
| 12611 | |
| 12612 | /* "address-family" display. */ |
| 12613 | bgp_config_write_family_header (vty, afi, safi, write); |
| 12614 | |
| 12615 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 12616 | { |
| 12617 | struct in_addr netmask; |
| 12618 | |
| 12619 | masklen2ip (p->prefixlen, &netmask); |
| 12620 | vty_out (vty, " aggregate-address %s %s", |
| 12621 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12622 | inet_ntoa (netmask)); |
| 12623 | } |
| 12624 | else |
| 12625 | { |
| 12626 | vty_out (vty, " aggregate-address %s/%d", |
| 12627 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 12628 | p->prefixlen); |
| 12629 | } |
| 12630 | |
| 12631 | if (bgp_aggregate->as_set) |
| 12632 | vty_out (vty, " as-set"); |
| 12633 | |
| 12634 | if (bgp_aggregate->summary_only) |
| 12635 | vty_out (vty, " summary-only"); |
| 12636 | |
| 12637 | vty_out (vty, "%s", VTY_NEWLINE); |
| 12638 | } |
| 12639 | |
| 12640 | return 0; |
| 12641 | } |
| 12642 | |
| 12643 | int |
| 12644 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 12645 | { |
| 12646 | struct bgp_node *rn; |
| 12647 | struct bgp_distance *bdistance; |
| 12648 | |
| 12649 | /* Distance configuration. */ |
| 12650 | if (bgp->distance_ebgp |
| 12651 | && bgp->distance_ibgp |
| 12652 | && bgp->distance_local |
| 12653 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 12654 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 12655 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 12656 | vty_out (vty, " distance bgp %d %d %d%s", |
| 12657 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 12658 | VTY_NEWLINE); |
| 12659 | |
| 12660 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 12661 | if ((bdistance = rn->info) != NULL) |
| 12662 | { |
| 12663 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 12664 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 12665 | bdistance->access_list ? bdistance->access_list : "", |
| 12666 | VTY_NEWLINE); |
| 12667 | } |
| 12668 | |
| 12669 | return 0; |
| 12670 | } |
| 12671 | |
| 12672 | /* Allocate routing table structure and install commands. */ |
| 12673 | void |
Stephen Hemminger | 66e5cd8 | 2009-02-09 10:14:16 -0800 | [diff] [blame] | 12674 | bgp_route_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12675 | { |
| 12676 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 12677 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12678 | |
| 12679 | /* IPv4 BGP commands. */ |
| 12680 | install_element (BGP_NODE, &bgp_network_cmd); |
| 12681 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 12682 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 12683 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 12684 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 12685 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12686 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 12687 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 12688 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 12689 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 12690 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 12691 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 12692 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 12693 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12694 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12695 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 12696 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 12697 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 12698 | |
| 12699 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 12700 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 12701 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 12702 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12703 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 12704 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 12705 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 12706 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12707 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 12708 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12709 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 12710 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 12711 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 12712 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12713 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12714 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 12715 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12716 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12717 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12718 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12719 | |
| 12720 | /* IPv4 unicast configuration. */ |
| 12721 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 12722 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 12723 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 12724 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 12725 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 12726 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 12727 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12728 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 12729 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 12730 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 12731 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12732 | 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] | 12733 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12734 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 12735 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 12736 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 12737 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12738 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 12739 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 12740 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 12741 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12742 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 12743 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12744 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 12745 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 12746 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 12747 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12748 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12749 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 12750 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12751 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12752 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12753 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12754 | |
| 12755 | /* IPv4 multicast configuration. */ |
| 12756 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 12757 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 12758 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 12759 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 12760 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 12761 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 12762 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 12763 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 12764 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 12765 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 12766 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 12767 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 12768 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 12769 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 12770 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 12771 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 12772 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 12773 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 12774 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 12775 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 12776 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 12777 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 12778 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 12779 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 12780 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 12781 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 12782 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 12783 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 12784 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 12785 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 12786 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 12787 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 12788 | |
| 12789 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 12790 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12791 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12792 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 12793 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12794 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12795 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12796 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12797 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 12798 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12799 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12800 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12801 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12802 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 12803 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 12804 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12805 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 12806 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12807 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12808 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12809 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 12810 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12811 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 12812 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12813 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12814 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12815 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 12816 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12817 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 12818 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 12819 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 12820 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 12821 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12822 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12823 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12824 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12825 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12826 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12827 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12828 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12829 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12830 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 12831 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12832 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12833 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12834 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12835 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12836 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12837 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12838 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 12839 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12840 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12841 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12842 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12843 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12844 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12845 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12846 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12847 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12848 | install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12849 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12850 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12851 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12852 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12853 | install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12854 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12855 | install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12856 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12857 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12858 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12859 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12860 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 12861 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12862 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12863 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 12864 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12865 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12866 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12867 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12868 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12869 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12870 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12871 | install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12872 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 12873 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12874 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12875 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12876 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12877 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12878 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12879 | install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 12880 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 12881 | install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12882 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12883 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12884 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12885 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 12886 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12887 | install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12888 | |
| 12889 | /* Restricted node: VIEW_NODE - (set of dangerous commands) */ |
| 12890 | install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); |
| 12891 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12892 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12893 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12894 | install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); |
| 12895 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12896 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12897 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12898 | install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12899 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd); |
| 12900 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12901 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); |
| 12902 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd); |
| 12903 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd); |
| 12904 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd); |
| 12905 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12906 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12907 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12908 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12909 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12910 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12911 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12912 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12913 | install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12914 | install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); |
| 12915 | install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12916 | install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12917 | install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12918 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12919 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12920 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12921 | install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12922 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12923 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12924 | install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12925 | install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12926 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12927 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 12928 | install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12929 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12930 | |
| 12931 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 12932 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12933 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12934 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 12935 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12936 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12937 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 12938 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 12939 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 12940 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12941 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12942 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 12943 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 12944 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 12945 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 12946 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 12947 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 12948 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 12949 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 12950 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 12951 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 12952 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 12953 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 12954 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 12955 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 12956 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 12957 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 12958 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 12959 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 12960 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 12961 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 12962 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 12963 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 12964 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 12965 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 12966 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12967 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd); |
| 12968 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd); |
| 12969 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd); |
| 12970 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd); |
| 12971 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12972 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 12973 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 12974 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 12975 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 12976 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 12977 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 12978 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 12979 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 12980 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 12981 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 12982 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 12983 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 12984 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 12985 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 12986 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 12987 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 12988 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 12989 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 12990 | install_element (ENABLE_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12991 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 12992 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 12993 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 12994 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12995 | install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12996 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12997 | install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 12998 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 12999 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13000 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 13001 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13002 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 13003 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 13004 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13005 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 13006 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13007 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 13008 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13009 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 13010 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
| 13011 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13012 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 13013 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13014 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
Balaji | 3921cc5 | 2015-05-16 23:12:17 +0530 | [diff] [blame] | 13015 | install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13016 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 13017 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13018 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13019 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13020 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13021 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13022 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13023 | install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd); |
Tomasz Pala | 2a71e9c | 2009-06-24 21:36:50 +0100 | [diff] [blame] | 13024 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd); |
| 13025 | install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13026 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13027 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13028 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13029 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13030 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13031 | install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13032 | |
| 13033 | /* BGP dampening clear commands */ |
| 13034 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 13035 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 13036 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 13037 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 13038 | |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13039 | /* prefix count */ |
| 13040 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); |
| 13041 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); |
| 13042 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13043 | #ifdef HAVE_IPV6 |
Paul Jakma | ff7924f | 2006-09-04 01:10:36 +0000 | [diff] [blame] | 13044 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); |
| 13045 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13046 | /* New config IPv6 BGP commands. */ |
| 13047 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 13048 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 13049 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 13050 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 13051 | |
| 13052 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 13053 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 13054 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 13055 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 13056 | |
G.Balaji | 73bfe0b | 2011-09-23 22:36:20 +0530 | [diff] [blame] | 13057 | install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd); |
| 13058 | install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd); |
| 13059 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13060 | /* Old config IPv6 BGP commands. */ |
| 13061 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 13062 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 13063 | |
| 13064 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 13065 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 13066 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 13067 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 13068 | |
| 13069 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 13070 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13071 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13072 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 13073 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13074 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13075 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 13076 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13077 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13078 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 13079 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 13080 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 13081 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 13082 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 13083 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 13084 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 13085 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 13086 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 13087 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 13088 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 13089 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 13090 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 13091 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 13092 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 13093 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 13094 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 13095 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 13096 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 13097 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 13098 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 13099 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 13100 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 13101 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 13102 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 13103 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 13104 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 13105 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 13106 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 13107 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 13108 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 13109 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 13110 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 13111 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 13112 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 13113 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 13114 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 13115 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 13116 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 13117 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13118 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 13119 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 13120 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 13121 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13122 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13123 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13124 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13125 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13126 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13127 | install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13128 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 13129 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 13130 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 13131 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 13132 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 13133 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 13134 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 13135 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 13136 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 13137 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 13138 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 13139 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 13140 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 13141 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 13142 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 13143 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 13144 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 13145 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13146 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13147 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13148 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13149 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13150 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13151 | install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 13152 | |
| 13153 | /* Restricted: |
| 13154 | * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) |
| 13155 | */ |
| 13156 | install_element (RESTRICTED_NODE, &show_bgp_route_cmd); |
| 13157 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13158 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 13159 | install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); |
| 13160 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13161 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 13162 | install_element (RESTRICTED_NODE, &show_bgp_community_cmd); |
| 13163 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd); |
| 13164 | install_element (RESTRICTED_NODE, &show_bgp_community2_cmd); |
| 13165 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd); |
| 13166 | install_element (RESTRICTED_NODE, &show_bgp_community3_cmd); |
| 13167 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd); |
| 13168 | install_element (RESTRICTED_NODE, &show_bgp_community4_cmd); |
| 13169 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd); |
| 13170 | install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); |
| 13171 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 13172 | install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd); |
| 13173 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 13174 | install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd); |
| 13175 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 13176 | install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd); |
| 13177 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 13178 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13179 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 13180 | install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13181 | install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 13182 | install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd); |
| 13183 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd); |
| 13184 | install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd); |
| 13185 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 13186 | install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 13187 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 13188 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13189 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
Paul Jakma | 62687ff | 2008-08-23 14:27:06 +0100 | [diff] [blame] | 13190 | install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13191 | install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13192 | |
| 13193 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 13194 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13195 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13196 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 13197 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13198 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13199 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 13200 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13201 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13202 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 13203 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 13204 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 13205 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 13206 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 13207 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 13208 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 13209 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 13210 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 13211 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 13212 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 13213 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 13214 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 13215 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 13216 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 13217 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 13218 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 13219 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 13220 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 13221 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 13222 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 13223 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 13224 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 13225 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 13226 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 13227 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 13228 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 13229 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 13230 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 13231 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 13232 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 13233 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 13234 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 13235 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 13236 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 13237 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 13238 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 13239 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 13240 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 13241 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13242 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 13243 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 13244 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 13245 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13246 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13247 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13248 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13249 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13250 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13251 | install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13252 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 13253 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 13254 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 13255 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 13256 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 13257 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 13258 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 13259 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 13260 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 13261 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 13262 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 13263 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 13264 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 13265 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 13266 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 13267 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 13268 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 13269 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13270 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13271 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13272 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13273 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 13274 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
Michael Lambert | 95cbbd2 | 2010-07-23 14:43:04 -0400 | [diff] [blame] | 13275 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13276 | |
| 13277 | /* Statistics */ |
| 13278 | install_element (ENABLE_NODE, &show_bgp_statistics_cmd); |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 13279 | //install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13280 | install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); |
Lou Berger | 298cc2f | 2016-01-12 13:42:02 -0500 | [diff] [blame] | 13281 | //install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); |
Paul Jakma | 2815e61 | 2006-09-14 02:56:07 +0000 | [diff] [blame] | 13282 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13283 | /* old command */ |
| 13284 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 13285 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 13286 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 13287 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 13288 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 13289 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 13290 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 13291 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 13292 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 13293 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 13294 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 13295 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 13296 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 13297 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 13298 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 13299 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 13300 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 13301 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 13302 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 13303 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 13304 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 13305 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 13306 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 13307 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 13308 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 13309 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 13310 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 13311 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 13312 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 13313 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 13314 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 13315 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 13316 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 13317 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 13318 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 13319 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 13320 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13321 | /* old command */ |
| 13322 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 13323 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 13324 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 13325 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 13326 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 13327 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 13328 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 13329 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 13330 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 13331 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 13332 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 13333 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 13334 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 13335 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 13336 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 13337 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 13338 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 13339 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 13340 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 13341 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 13342 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 13343 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 13344 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 13345 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 13346 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 13347 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 13348 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 13349 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 13350 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 13351 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 13352 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 13353 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 13354 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 13355 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 13356 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 13357 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 13358 | |
| 13359 | /* old command */ |
| 13360 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13361 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 13362 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13363 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 13364 | |
| 13365 | /* old command */ |
| 13366 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13367 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 13368 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13369 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 13370 | |
| 13371 | /* old command */ |
| 13372 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13373 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 13374 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13375 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 13376 | #endif /* HAVE_IPV6 */ |
| 13377 | |
| 13378 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 13379 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 13380 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 13381 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 13382 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 13383 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 13384 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 13385 | |
| 13386 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 13387 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 13388 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 13389 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 13390 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 13391 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 13392 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 13393 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 13394 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 13395 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13396 | |
| 13397 | /* Deprecated AS-Pathlimit commands */ |
| 13398 | install_element (BGP_NODE, &bgp_network_ttl_cmd); |
| 13399 | install_element (BGP_NODE, &bgp_network_mask_ttl_cmd); |
| 13400 | install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13401 | install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13402 | install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13403 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13404 | |
| 13405 | install_element (BGP_NODE, &no_bgp_network_ttl_cmd); |
| 13406 | install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13407 | install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13408 | install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13409 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13410 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13411 | |
| 13412 | install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd); |
| 13413 | install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd); |
| 13414 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13415 | install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13416 | install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13417 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13418 | |
| 13419 | install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd); |
| 13420 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13421 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13422 | install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13423 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13424 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13425 | |
| 13426 | install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd); |
| 13427 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd); |
| 13428 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd); |
| 13429 | install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd); |
| 13430 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd); |
| 13431 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd); |
| 13432 | |
| 13433 | install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd); |
| 13434 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd); |
| 13435 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd); |
| 13436 | install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd); |
| 13437 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd); |
| 13438 | 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] | 13439 | |
| 13440 | #ifdef HAVE_IPV6 |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 13441 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd); |
| 13442 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd); |
Paul Jakma | 3bde17f | 2011-03-23 10:30:30 +0000 | [diff] [blame] | 13443 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 13444 | } |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 13445 | |
| 13446 | void |
| 13447 | bgp_route_finish (void) |
| 13448 | { |
| 13449 | bgp_table_unlock (bgp_distance_table); |
| 13450 | bgp_distance_table = NULL; |
| 13451 | } |