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" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 57 | |
| 58 | /* Extern from bgp_dump.c */ |
| 59 | extern char *bgp_origin_str[]; |
| 60 | extern char *bgp_origin_long_str[]; |
| 61 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 62 | static struct bgp_node * |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 63 | 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] | 64 | struct prefix_rd *prd) |
| 65 | { |
| 66 | struct bgp_node *rn; |
| 67 | struct bgp_node *prn = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 68 | |
| 69 | if (safi == SAFI_MPLS_VPN) |
| 70 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 71 | prn = bgp_node_get (table, (struct prefix *) prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 72 | |
| 73 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 74 | prn->info = bgp_table_init (afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 75 | else |
| 76 | bgp_unlock_node (prn); |
| 77 | table = prn->info; |
| 78 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 79 | |
| 80 | rn = bgp_node_get (table, p); |
| 81 | |
| 82 | if (safi == SAFI_MPLS_VPN) |
| 83 | rn->prn = prn; |
| 84 | |
| 85 | return rn; |
| 86 | } |
| 87 | |
| 88 | /* Allocate new bgp info structure. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 89 | static struct bgp_info * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 90 | bgp_info_new () |
| 91 | { |
| 92 | struct bgp_info *new; |
| 93 | |
| 94 | new = XMALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); |
| 95 | memset (new, 0, sizeof (struct bgp_info)); |
| 96 | |
| 97 | return new; |
| 98 | } |
| 99 | |
| 100 | /* Free bgp route information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 101 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 102 | bgp_info_free (struct bgp_info *binfo) |
| 103 | { |
| 104 | if (binfo->attr) |
| 105 | bgp_attr_unintern (binfo->attr); |
| 106 | |
| 107 | if (binfo->damp_info) |
| 108 | bgp_damp_info_free (binfo->damp_info, 0); |
| 109 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 110 | peer_unlock (binfo->peer); /* bgp_info peer reference */ |
| 111 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 112 | XFREE (MTYPE_BGP_ROUTE, binfo); |
| 113 | } |
| 114 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 115 | struct bgp_info * |
| 116 | bgp_info_lock (struct bgp_info *binfo) |
| 117 | { |
| 118 | binfo->lock++; |
| 119 | return binfo; |
| 120 | } |
| 121 | |
| 122 | struct bgp_info * |
| 123 | bgp_info_unlock (struct bgp_info *binfo) |
| 124 | { |
| 125 | assert (binfo && binfo->lock > 0); |
| 126 | binfo->lock--; |
| 127 | |
| 128 | if (binfo->lock == 0) |
| 129 | { |
| 130 | #if 0 |
| 131 | zlog_debug ("%s: unlocked and freeing", __func__); |
| 132 | zlog_backtrace (LOG_DEBUG); |
| 133 | #endif |
| 134 | bgp_info_free (binfo); |
| 135 | return NULL; |
| 136 | } |
| 137 | |
| 138 | #if 0 |
| 139 | if (binfo->lock == 1) |
| 140 | { |
| 141 | zlog_debug ("%s: unlocked to 1", __func__); |
| 142 | zlog_backtrace (LOG_DEBUG); |
| 143 | } |
| 144 | #endif |
| 145 | |
| 146 | return binfo; |
| 147 | } |
| 148 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 149 | void |
| 150 | bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) |
| 151 | { |
| 152 | struct bgp_info *top; |
| 153 | |
| 154 | top = rn->info; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 155 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 156 | ri->next = rn->info; |
| 157 | ri->prev = NULL; |
| 158 | if (top) |
| 159 | top->prev = ri; |
| 160 | rn->info = ri; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 161 | |
| 162 | bgp_info_lock (ri); |
| 163 | bgp_lock_node (rn); |
| 164 | peer_lock (ri->peer); /* bgp_info peer reference */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 165 | } |
| 166 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 167 | /* Do the actual removal of info from RIB, for use by bgp_process |
| 168 | completion callback *only* */ |
| 169 | static void |
| 170 | bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 171 | { |
| 172 | if (ri->next) |
| 173 | ri->next->prev = ri->prev; |
| 174 | if (ri->prev) |
| 175 | ri->prev->next = ri->next; |
| 176 | else |
| 177 | rn->info = ri->next; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 178 | |
| 179 | bgp_info_unlock (ri); |
| 180 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 181 | } |
| 182 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 183 | void |
| 184 | bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri) |
| 185 | { |
| 186 | /* leave info in place for now in place for now, |
| 187 | * bgp_process will reap it later. */ |
| 188 | SET_FLAG (ri->flags, BGP_INFO_REMOVED); |
| 189 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 190 | } |
| 191 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 192 | /* Get MED value. If MED value is missing and "bgp bestpath |
| 193 | missing-as-worst" is specified, treat it as the worst value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 194 | static u_int32_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 195 | bgp_med_value (struct attr *attr, struct bgp *bgp) |
| 196 | { |
| 197 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 198 | return attr->med; |
| 199 | else |
| 200 | { |
| 201 | if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 202 | return BGP_MED_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 203 | else |
| 204 | return 0; |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | /* Compare two bgp route entity. br is preferable then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 209 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 210 | bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist) |
| 211 | { |
| 212 | u_int32_t new_pref; |
| 213 | u_int32_t exist_pref; |
| 214 | u_int32_t new_med; |
| 215 | u_int32_t exist_med; |
| 216 | struct in_addr new_id; |
| 217 | struct in_addr exist_id; |
| 218 | int new_cluster; |
| 219 | int exist_cluster; |
| 220 | int internal_as_route = 0; |
| 221 | int confed_as_route = 0; |
| 222 | int ret; |
| 223 | |
| 224 | /* 0. Null check. */ |
| 225 | if (new == NULL) |
| 226 | return 0; |
| 227 | if (exist == NULL) |
| 228 | return 1; |
| 229 | |
| 230 | /* 1. Weight check. */ |
| 231 | if (new->attr->weight > exist->attr->weight) |
| 232 | return 1; |
| 233 | if (new->attr->weight < exist->attr->weight) |
| 234 | return 0; |
| 235 | |
| 236 | /* 2. Local preference check. */ |
| 237 | if (new->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 238 | new_pref = new->attr->local_pref; |
| 239 | else |
| 240 | new_pref = bgp->default_local_pref; |
| 241 | |
| 242 | if (exist->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 243 | exist_pref = exist->attr->local_pref; |
| 244 | else |
| 245 | exist_pref = bgp->default_local_pref; |
| 246 | |
| 247 | if (new_pref > exist_pref) |
| 248 | return 1; |
| 249 | if (new_pref < exist_pref) |
| 250 | return 0; |
| 251 | |
| 252 | /* 3. Local route check. */ |
| 253 | if (new->sub_type == BGP_ROUTE_STATIC) |
| 254 | return 1; |
| 255 | if (exist->sub_type == BGP_ROUTE_STATIC) |
| 256 | return 0; |
| 257 | |
| 258 | if (new->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 259 | return 1; |
| 260 | if (exist->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 261 | return 0; |
| 262 | |
| 263 | if (new->sub_type == BGP_ROUTE_AGGREGATE) |
| 264 | return 1; |
| 265 | if (exist->sub_type == BGP_ROUTE_AGGREGATE) |
| 266 | return 0; |
| 267 | |
| 268 | /* 4. AS path length check. */ |
| 269 | if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) |
| 270 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 271 | int exist_hops = aspath_count_hops (exist->attr->aspath); |
| 272 | int exist_confeds = aspath_count_confeds (exist->attr->aspath); |
| 273 | |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 274 | if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) |
| 275 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 276 | int aspath_hops; |
| 277 | |
| 278 | aspath_hops = aspath_count_hops (new->attr->aspath); |
| 279 | aspath_hops += aspath_count_confeds (new->attr->aspath); |
| 280 | |
| 281 | if ( aspath_hops < (exist_hops + exist_confeds)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 282 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 283 | if ( aspath_hops > (exist_hops + exist_confeds)) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 284 | return 0; |
| 285 | } |
| 286 | else |
| 287 | { |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 288 | int newhops = aspath_count_hops (new->attr->aspath); |
| 289 | |
| 290 | if (newhops < exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 291 | return 1; |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 292 | if (newhops > exist_hops) |
hasso | 6811845 | 2005-04-08 15:40:36 +0000 | [diff] [blame] | 293 | return 0; |
| 294 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | /* 5. Origin check. */ |
| 298 | if (new->attr->origin < exist->attr->origin) |
| 299 | return 1; |
| 300 | if (new->attr->origin > exist->attr->origin) |
| 301 | return 0; |
| 302 | |
| 303 | /* 6. MED check. */ |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 304 | internal_as_route = (aspath_count_hops (new->attr->aspath) == 0 |
| 305 | && aspath_count_hops (exist->attr->aspath) == 0); |
| 306 | confed_as_route = (aspath_count_confeds (new->attr->aspath) > 0 |
| 307 | && aspath_count_confeds (exist->attr->aspath) > 0 |
| 308 | && aspath_count_hops (new->attr->aspath) == 0 |
| 309 | && aspath_count_hops (exist->attr->aspath) == 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 310 | |
| 311 | if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) |
| 312 | || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) |
| 313 | && confed_as_route) |
| 314 | || aspath_cmp_left (new->attr->aspath, exist->attr->aspath) |
| 315 | || aspath_cmp_left_confed (new->attr->aspath, exist->attr->aspath) |
| 316 | || internal_as_route) |
| 317 | { |
| 318 | new_med = bgp_med_value (new->attr, bgp); |
| 319 | exist_med = bgp_med_value (exist->attr, bgp); |
| 320 | |
| 321 | if (new_med < exist_med) |
| 322 | return 1; |
| 323 | if (new_med > exist_med) |
| 324 | return 0; |
| 325 | } |
| 326 | |
| 327 | /* 7. Peer type check. */ |
| 328 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 329 | && peer_sort (exist->peer) == BGP_PEER_IBGP) |
| 330 | return 1; |
| 331 | if (peer_sort (new->peer) == BGP_PEER_EBGP |
| 332 | && peer_sort (exist->peer) == BGP_PEER_CONFED) |
| 333 | return 1; |
| 334 | if (peer_sort (new->peer) == BGP_PEER_IBGP |
| 335 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 336 | return 0; |
| 337 | if (peer_sort (new->peer) == BGP_PEER_CONFED |
| 338 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 339 | return 0; |
| 340 | |
| 341 | /* 8. IGP metric check. */ |
| 342 | if (new->igpmetric < exist->igpmetric) |
| 343 | return 1; |
| 344 | if (new->igpmetric > exist->igpmetric) |
| 345 | return 0; |
| 346 | |
| 347 | /* 9. Maximum path check. */ |
| 348 | |
| 349 | /* 10. If both paths are external, prefer the path that was received |
| 350 | first (the oldest one). This step minimizes route-flap, since a |
| 351 | newer path won't displace an older one, even if it was the |
| 352 | preferred route based on the additional decision criteria below. */ |
| 353 | if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID) |
| 354 | && peer_sort (new->peer) == BGP_PEER_EBGP |
| 355 | && peer_sort (exist->peer) == BGP_PEER_EBGP) |
| 356 | { |
| 357 | if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) |
| 358 | return 1; |
| 359 | if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) |
| 360 | return 0; |
| 361 | } |
| 362 | |
| 363 | /* 11. Rourter-ID comparision. */ |
| 364 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 365 | new_id.s_addr = new->attr->originator_id.s_addr; |
| 366 | else |
| 367 | new_id.s_addr = new->peer->remote_id.s_addr; |
| 368 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 369 | exist_id.s_addr = exist->attr->originator_id.s_addr; |
| 370 | else |
| 371 | exist_id.s_addr = exist->peer->remote_id.s_addr; |
| 372 | |
| 373 | if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) |
| 374 | return 1; |
| 375 | if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) |
| 376 | return 0; |
| 377 | |
| 378 | /* 12. Cluster length comparision. */ |
| 379 | if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 380 | new_cluster = new->attr->cluster->length; |
| 381 | else |
| 382 | new_cluster = 0; |
| 383 | if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 384 | exist_cluster = exist->attr->cluster->length; |
| 385 | else |
| 386 | exist_cluster = 0; |
| 387 | |
| 388 | if (new_cluster < exist_cluster) |
| 389 | return 1; |
| 390 | if (new_cluster > exist_cluster) |
| 391 | return 0; |
| 392 | |
| 393 | /* 13. Neighbor address comparision. */ |
| 394 | ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote); |
| 395 | |
| 396 | if (ret == 1) |
| 397 | return 0; |
| 398 | if (ret == -1) |
| 399 | return 1; |
| 400 | |
| 401 | return 1; |
| 402 | } |
| 403 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 404 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 405 | bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 406 | afi_t afi, safi_t safi) |
| 407 | { |
| 408 | struct bgp_filter *filter; |
| 409 | |
| 410 | filter = &peer->filter[afi][safi]; |
| 411 | |
| 412 | if (DISTRIBUTE_IN_NAME (filter)) |
| 413 | if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) |
| 414 | return FILTER_DENY; |
| 415 | |
| 416 | if (PREFIX_LIST_IN_NAME (filter)) |
| 417 | if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) |
| 418 | return FILTER_DENY; |
| 419 | |
| 420 | if (FILTER_LIST_IN_NAME (filter)) |
| 421 | if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) |
| 422 | return FILTER_DENY; |
| 423 | |
| 424 | return FILTER_PERMIT; |
| 425 | } |
| 426 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 427 | static enum filter_type |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 428 | bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, |
| 429 | afi_t afi, safi_t safi) |
| 430 | { |
| 431 | struct bgp_filter *filter; |
| 432 | |
| 433 | filter = &peer->filter[afi][safi]; |
| 434 | |
| 435 | if (DISTRIBUTE_OUT_NAME (filter)) |
| 436 | if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) |
| 437 | return FILTER_DENY; |
| 438 | |
| 439 | if (PREFIX_LIST_OUT_NAME (filter)) |
| 440 | if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) |
| 441 | return FILTER_DENY; |
| 442 | |
| 443 | if (FILTER_LIST_OUT_NAME (filter)) |
| 444 | if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) |
| 445 | return FILTER_DENY; |
| 446 | |
| 447 | return FILTER_PERMIT; |
| 448 | } |
| 449 | |
| 450 | /* If community attribute includes no_export then return 1. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 451 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 452 | bgp_community_filter (struct peer *peer, struct attr *attr) |
| 453 | { |
| 454 | if (attr->community) |
| 455 | { |
| 456 | /* NO_ADVERTISE check. */ |
| 457 | if (community_include (attr->community, COMMUNITY_NO_ADVERTISE)) |
| 458 | return 1; |
| 459 | |
| 460 | /* NO_EXPORT check. */ |
| 461 | if (peer_sort (peer) == BGP_PEER_EBGP && |
| 462 | community_include (attr->community, COMMUNITY_NO_EXPORT)) |
| 463 | return 1; |
| 464 | |
| 465 | /* NO_EXPORT_SUBCONFED check. */ |
| 466 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 467 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 468 | if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) |
| 469 | return 1; |
| 470 | } |
| 471 | return 0; |
| 472 | } |
| 473 | |
| 474 | /* Route reflection loop check. */ |
| 475 | static int |
| 476 | bgp_cluster_filter (struct peer *peer, struct attr *attr) |
| 477 | { |
| 478 | struct in_addr cluster_id; |
| 479 | |
| 480 | if (attr->cluster) |
| 481 | { |
| 482 | if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) |
| 483 | cluster_id = peer->bgp->cluster_id; |
| 484 | else |
| 485 | cluster_id = peer->bgp->router_id; |
| 486 | |
| 487 | if (cluster_loop_check (attr->cluster, cluster_id)) |
| 488 | return 1; |
| 489 | } |
| 490 | return 0; |
| 491 | } |
| 492 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 493 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 494 | bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, |
| 495 | afi_t afi, safi_t safi) |
| 496 | { |
| 497 | struct bgp_filter *filter; |
| 498 | struct bgp_info info; |
| 499 | route_map_result_t ret; |
| 500 | |
| 501 | filter = &peer->filter[afi][safi]; |
| 502 | |
| 503 | /* Apply default weight value. */ |
| 504 | attr->weight = peer->weight; |
| 505 | |
| 506 | /* Route map apply. */ |
| 507 | if (ROUTE_MAP_IN_NAME (filter)) |
| 508 | { |
| 509 | /* Duplicate current value to new strucutre for modification. */ |
| 510 | info.peer = peer; |
| 511 | info.attr = attr; |
| 512 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 513 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); |
| 514 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 515 | /* Apply BGP route map to the attribute. */ |
| 516 | ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 517 | |
| 518 | peer->rmap_type = 0; |
| 519 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 520 | if (ret == RMAP_DENYMATCH) |
| 521 | { |
| 522 | /* Free newly generated AS path and community by route-map. */ |
| 523 | bgp_attr_flush (attr); |
| 524 | return RMAP_DENY; |
| 525 | } |
| 526 | } |
| 527 | return RMAP_PERMIT; |
| 528 | } |
| 529 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 530 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 531 | bgp_export_modifier (struct peer *rsclient, struct peer *peer, |
| 532 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 533 | { |
| 534 | struct bgp_filter *filter; |
| 535 | struct bgp_info info; |
| 536 | route_map_result_t ret; |
| 537 | |
| 538 | filter = &peer->filter[afi][safi]; |
| 539 | |
| 540 | /* Route map apply. */ |
| 541 | if (ROUTE_MAP_EXPORT_NAME (filter)) |
| 542 | { |
| 543 | /* Duplicate current value to new strucutre for modification. */ |
| 544 | info.peer = rsclient; |
| 545 | info.attr = attr; |
| 546 | |
| 547 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 548 | |
| 549 | /* Apply BGP route map to the attribute. */ |
| 550 | ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info); |
| 551 | |
| 552 | rsclient->rmap_type = 0; |
| 553 | |
| 554 | if (ret == RMAP_DENYMATCH) |
| 555 | { |
| 556 | /* Free newly generated AS path and community by route-map. */ |
| 557 | bgp_attr_flush (attr); |
| 558 | return RMAP_DENY; |
| 559 | } |
| 560 | } |
| 561 | return RMAP_PERMIT; |
| 562 | } |
| 563 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 564 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 565 | bgp_import_modifier (struct peer *rsclient, struct peer *peer, |
| 566 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
| 567 | { |
| 568 | struct bgp_filter *filter; |
| 569 | struct bgp_info info; |
| 570 | route_map_result_t ret; |
| 571 | |
| 572 | filter = &rsclient->filter[afi][safi]; |
| 573 | |
| 574 | /* Apply default weight value. */ |
| 575 | attr->weight = peer->weight; |
| 576 | |
| 577 | /* Route map apply. */ |
| 578 | if (ROUTE_MAP_IMPORT_NAME (filter)) |
| 579 | { |
| 580 | /* Duplicate current value to new strucutre for modification. */ |
| 581 | info.peer = peer; |
| 582 | info.attr = attr; |
| 583 | |
| 584 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT); |
| 585 | |
| 586 | /* Apply BGP route map to the attribute. */ |
| 587 | ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info); |
| 588 | |
| 589 | peer->rmap_type = 0; |
| 590 | |
| 591 | if (ret == RMAP_DENYMATCH) |
| 592 | { |
| 593 | /* Free newly generated AS path and community by route-map. */ |
| 594 | bgp_attr_flush (attr); |
| 595 | return RMAP_DENY; |
| 596 | } |
| 597 | } |
| 598 | return RMAP_PERMIT; |
| 599 | } |
| 600 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 601 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 602 | bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, |
| 603 | struct attr *attr, afi_t afi, safi_t safi) |
| 604 | { |
| 605 | int ret; |
| 606 | char buf[SU_ADDRSTRLEN]; |
| 607 | struct bgp_filter *filter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 608 | struct peer *from; |
| 609 | struct bgp *bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 610 | int transparent; |
| 611 | int reflect; |
| 612 | |
| 613 | from = ri->peer; |
| 614 | filter = &peer->filter[afi][safi]; |
| 615 | bgp = peer->bgp; |
| 616 | |
| 617 | #ifdef DISABLE_BGP_ANNOUNCE |
| 618 | return 0; |
| 619 | #endif |
| 620 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 621 | /* Do not send announces to RS-clients from the 'normal' bgp_table. */ |
| 622 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 623 | return 0; |
| 624 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 625 | /* Do not send back route to sender. */ |
| 626 | if (from == peer) |
| 627 | return 0; |
| 628 | |
paul | 35be31b | 2004-05-01 18:17:04 +0000 | [diff] [blame] | 629 | /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */ |
| 630 | if (p->family == AF_INET |
| 631 | && IPV4_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) |
| 632 | return 0; |
| 633 | #ifdef HAVE_IPV6 |
| 634 | if (p->family == AF_INET6 |
| 635 | && IPV6_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop)) |
| 636 | return 0; |
| 637 | #endif |
| 638 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 639 | /* Aggregate-address suppress check. */ |
| 640 | if (ri->suppress) |
| 641 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 642 | return 0; |
| 643 | |
| 644 | /* Default route check. */ |
| 645 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 646 | { |
| 647 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 648 | return 0; |
| 649 | #ifdef HAVE_IPV6 |
| 650 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 651 | return 0; |
| 652 | #endif /* HAVE_IPV6 */ |
| 653 | } |
| 654 | |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 655 | /* Transparency check. */ |
| 656 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) |
| 657 | && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 658 | transparent = 1; |
| 659 | else |
| 660 | transparent = 0; |
| 661 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 662 | /* If community is not disabled check the no-export and local. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 663 | if (! transparent && bgp_community_filter (peer, ri->attr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 664 | return 0; |
| 665 | |
| 666 | /* If the attribute has originator-id and it is same as remote |
| 667 | peer's id. */ |
| 668 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 669 | { |
| 670 | if (IPV4_ADDR_SAME (&peer->remote_id, &ri->attr->originator_id)) |
| 671 | { |
| 672 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 673 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 674 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 675 | peer->host, |
| 676 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 677 | p->prefixlen); |
| 678 | return 0; |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | /* ORF prefix-list filter check */ |
| 683 | if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 684 | && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 685 | || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 686 | if (peer->orf_plist[afi][safi]) |
| 687 | { |
| 688 | if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 689 | return 0; |
| 690 | } |
| 691 | |
| 692 | /* Output filter check. */ |
| 693 | if (bgp_output_filter (peer, p, ri->attr, afi, safi) == FILTER_DENY) |
| 694 | { |
| 695 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 696 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 697 | "%s [Update:SEND] %s/%d is filtered", |
| 698 | peer->host, |
| 699 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 700 | p->prefixlen); |
| 701 | return 0; |
| 702 | } |
| 703 | |
| 704 | #ifdef BGP_SEND_ASPATH_CHECK |
| 705 | /* AS path loop check. */ |
| 706 | if (aspath_loop_check (ri->attr->aspath, peer->as)) |
| 707 | { |
| 708 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 709 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 710 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 711 | peer->host, peer->as); |
| 712 | return 0; |
| 713 | } |
| 714 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 715 | |
| 716 | /* If we're a CONFED we need to loop check the CONFED ID too */ |
| 717 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) |
| 718 | { |
| 719 | if (aspath_loop_check(ri->attr->aspath, bgp->confed_id)) |
| 720 | { |
| 721 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 722 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 723 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 724 | peer->host, |
| 725 | bgp->confed_id); |
| 726 | return 0; |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | /* Route-Reflect check. */ |
| 731 | if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP) |
| 732 | reflect = 1; |
| 733 | else |
| 734 | reflect = 0; |
| 735 | |
| 736 | /* IBGP reflection check. */ |
| 737 | if (reflect) |
| 738 | { |
| 739 | /* A route from a Client peer. */ |
| 740 | if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 741 | { |
| 742 | /* Reflect to all the Non-Client peers and also to the |
| 743 | Client peers other than the originator. Originator check |
| 744 | is already done. So there is noting to do. */ |
| 745 | /* no bgp client-to-client reflection check. */ |
| 746 | if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
| 747 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 748 | return 0; |
| 749 | } |
| 750 | else |
| 751 | { |
| 752 | /* A route from a Non-client peer. Reflect to all other |
| 753 | clients. */ |
| 754 | if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 755 | return 0; |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | /* For modify attribute, copy it to temporary structure. */ |
| 760 | *attr = *ri->attr; |
| 761 | |
| 762 | /* If local-preference is not set. */ |
| 763 | if ((peer_sort (peer) == BGP_PEER_IBGP |
| 764 | || peer_sort (peer) == BGP_PEER_CONFED) |
| 765 | && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) |
| 766 | { |
| 767 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 768 | attr->local_pref = bgp->default_local_pref; |
| 769 | } |
| 770 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 771 | /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ |
| 772 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 773 | && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 774 | { |
| 775 | if (ri->peer != bgp->peer_self && ! transparent |
| 776 | && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) |
| 777 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)); |
| 778 | } |
| 779 | |
| 780 | /* next-hop-set */ |
| 781 | if (transparent || reflect |
| 782 | || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) |
| 783 | && ((p->family == AF_INET && attr->nexthop.s_addr) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 784 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 785 | || (p->family == AF_INET6 && |
| 786 | ! IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 787 | #endif /* HAVE_IPV6 */ |
| 788 | ))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 789 | { |
| 790 | /* NEXT-HOP Unchanged. */ |
| 791 | } |
| 792 | else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) |
| 793 | || (p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 794 | #ifdef HAVE_IPV6 |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 795 | || (p->family == AF_INET6 && |
| 796 | IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 797 | #endif /* HAVE_IPV6 */ |
| 798 | || (peer_sort (peer) == BGP_PEER_EBGP |
| 799 | && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0)) |
| 800 | { |
| 801 | /* Set IPv4 nexthop. */ |
| 802 | if (p->family == AF_INET) |
| 803 | { |
| 804 | if (safi == SAFI_MPLS_VPN) |
| 805 | memcpy (&attr->mp_nexthop_global_in, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 806 | else |
| 807 | memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 808 | } |
| 809 | #ifdef HAVE_IPV6 |
| 810 | /* Set IPv6 nexthop. */ |
| 811 | if (p->family == AF_INET6) |
| 812 | { |
| 813 | /* IPv6 global nexthop must be included. */ |
| 814 | memcpy (&attr->mp_nexthop_global, &peer->nexthop.v6_global, |
| 815 | IPV6_MAX_BYTELEN); |
| 816 | attr->mp_nexthop_len = 16; |
| 817 | } |
| 818 | #endif /* HAVE_IPV6 */ |
| 819 | } |
| 820 | |
| 821 | #ifdef HAVE_IPV6 |
| 822 | if (p->family == AF_INET6) |
| 823 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 824 | /* Left nexthop_local unchanged if so configured. */ |
| 825 | if ( CHECK_FLAG (peer->af_flags[afi][safi], |
| 826 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 827 | { |
| 828 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 829 | attr->mp_nexthop_len=32; |
| 830 | else |
| 831 | attr->mp_nexthop_len=16; |
| 832 | } |
| 833 | |
| 834 | /* Default nexthop_local treatment for non-RS-Clients */ |
| 835 | else |
| 836 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 837 | /* Link-local address should not be transit to different peer. */ |
| 838 | attr->mp_nexthop_len = 16; |
| 839 | |
| 840 | /* Set link-local address for shared network peer. */ |
| 841 | if (peer->shared_network |
| 842 | && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 843 | { |
| 844 | memcpy (&attr->mp_nexthop_local, &peer->nexthop.v6_local, |
| 845 | IPV6_MAX_BYTELEN); |
| 846 | attr->mp_nexthop_len = 32; |
| 847 | } |
| 848 | |
| 849 | /* If bgpd act as BGP-4+ route-reflector, do not send link-local |
| 850 | address.*/ |
| 851 | if (reflect) |
| 852 | attr->mp_nexthop_len = 16; |
| 853 | |
| 854 | /* If BGP-4+ link-local nexthop is not link-local nexthop. */ |
| 855 | if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local)) |
| 856 | attr->mp_nexthop_len = 16; |
| 857 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 858 | |
| 859 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 860 | #endif /* HAVE_IPV6 */ |
| 861 | |
| 862 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 863 | if (peer_sort (peer) == BGP_PEER_EBGP |
| 864 | && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 865 | && aspath_private_as_check (attr->aspath)) |
| 866 | attr->aspath = aspath_empty_get (); |
| 867 | |
| 868 | /* Route map & unsuppress-map apply. */ |
| 869 | if (ROUTE_MAP_OUT_NAME (filter) |
| 870 | || ri->suppress) |
| 871 | { |
Paul Jakma | 7c7fa1b | 2006-02-18 10:52:09 +0000 | [diff] [blame] | 872 | struct bgp_info info; |
| 873 | struct attr dummy_attr; |
| 874 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 875 | info.peer = peer; |
| 876 | info.attr = attr; |
| 877 | |
| 878 | /* The route reflector is not allowed to modify the attributes |
| 879 | of the reflected IBGP routes. */ |
| 880 | if (peer_sort (from) == BGP_PEER_IBGP |
| 881 | && peer_sort (peer) == BGP_PEER_IBGP) |
| 882 | { |
| 883 | dummy_attr = *attr; |
| 884 | info.attr = &dummy_attr; |
| 885 | } |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 886 | |
| 887 | SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); |
| 888 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 889 | if (ri->suppress) |
| 890 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 891 | else |
| 892 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 893 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 894 | peer->rmap_type = 0; |
| 895 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 896 | if (ret == RMAP_DENYMATCH) |
| 897 | { |
| 898 | bgp_attr_flush (attr); |
| 899 | return 0; |
| 900 | } |
| 901 | } |
| 902 | return 1; |
| 903 | } |
| 904 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 905 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 906 | bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, |
| 907 | struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 908 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 909 | int ret; |
| 910 | char buf[SU_ADDRSTRLEN]; |
| 911 | struct bgp_filter *filter; |
| 912 | struct bgp_info info; |
| 913 | struct peer *from; |
| 914 | struct bgp *bgp; |
| 915 | |
| 916 | from = ri->peer; |
| 917 | filter = &rsclient->filter[afi][safi]; |
| 918 | bgp = rsclient->bgp; |
| 919 | |
| 920 | #ifdef DISABLE_BGP_ANNOUNCE |
| 921 | return 0; |
| 922 | #endif |
| 923 | |
| 924 | /* Do not send back route to sender. */ |
| 925 | if (from == rsclient) |
| 926 | return 0; |
| 927 | |
| 928 | /* Aggregate-address suppress check. */ |
| 929 | if (ri->suppress) |
| 930 | if (! UNSUPPRESS_MAP_NAME (filter)) |
| 931 | return 0; |
| 932 | |
| 933 | /* Default route check. */ |
| 934 | if (CHECK_FLAG (rsclient->af_sflags[afi][safi], |
| 935 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 936 | { |
| 937 | if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) |
| 938 | return 0; |
| 939 | #ifdef HAVE_IPV6 |
| 940 | else if (p->family == AF_INET6 && p->prefixlen == 0) |
| 941 | return 0; |
| 942 | #endif /* HAVE_IPV6 */ |
| 943 | } |
| 944 | |
| 945 | /* If the attribute has originator-id and it is same as remote |
| 946 | peer's id. */ |
| 947 | if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) |
| 948 | { |
| 949 | if (IPV4_ADDR_SAME (&rsclient->remote_id, &ri->attr->originator_id)) |
| 950 | { |
| 951 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 952 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 953 | "%s [Update:SEND] %s/%d originator-id is same as remote router-id", |
| 954 | rsclient->host, |
| 955 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 956 | p->prefixlen); |
| 957 | return 0; |
| 958 | } |
| 959 | } |
| 960 | |
| 961 | /* ORF prefix-list filter check */ |
| 962 | if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) |
| 963 | && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) |
| 964 | || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) |
| 965 | if (rsclient->orf_plist[afi][safi]) |
| 966 | { |
| 967 | if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY) |
| 968 | return 0; |
| 969 | } |
| 970 | |
| 971 | /* Output filter check. */ |
| 972 | if (bgp_output_filter (rsclient, p, ri->attr, afi, safi) == FILTER_DENY) |
| 973 | { |
| 974 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 975 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 976 | "%s [Update:SEND] %s/%d is filtered", |
| 977 | rsclient->host, |
| 978 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 979 | p->prefixlen); |
| 980 | return 0; |
| 981 | } |
| 982 | |
| 983 | #ifdef BGP_SEND_ASPATH_CHECK |
| 984 | /* AS path loop check. */ |
| 985 | if (aspath_loop_check (ri->attr->aspath, rsclient->as)) |
| 986 | { |
| 987 | if (BGP_DEBUG (filter, FILTER)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 988 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 989 | "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", |
| 990 | rsclient->host, rsclient->as); |
| 991 | return 0; |
| 992 | } |
| 993 | #endif /* BGP_SEND_ASPATH_CHECK */ |
| 994 | |
| 995 | /* For modify attribute, copy it to temporary structure. */ |
| 996 | *attr = *ri->attr; |
| 997 | |
| 998 | /* next-hop-set */ |
| 999 | if ((p->family == AF_INET && attr->nexthop.s_addr == 0) |
| 1000 | #ifdef HAVE_IPV6 |
| 1001 | || (p->family == AF_INET6 && |
| 1002 | IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)) |
| 1003 | #endif /* HAVE_IPV6 */ |
| 1004 | ) |
| 1005 | { |
| 1006 | /* Set IPv4 nexthop. */ |
| 1007 | if (p->family == AF_INET) |
| 1008 | { |
| 1009 | if (safi == SAFI_MPLS_VPN) |
| 1010 | memcpy (&attr->mp_nexthop_global_in, &rsclient->nexthop.v4, |
| 1011 | IPV4_MAX_BYTELEN); |
| 1012 | else |
| 1013 | memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN); |
| 1014 | } |
| 1015 | #ifdef HAVE_IPV6 |
| 1016 | /* Set IPv6 nexthop. */ |
| 1017 | if (p->family == AF_INET6) |
| 1018 | { |
| 1019 | /* IPv6 global nexthop must be included. */ |
| 1020 | memcpy (&attr->mp_nexthop_global, &rsclient->nexthop.v6_global, |
| 1021 | |
| 1022 | IPV6_MAX_BYTELEN); |
| 1023 | attr->mp_nexthop_len = 16; |
| 1024 | } |
| 1025 | #endif /* HAVE_IPV6 */ |
| 1026 | } |
| 1027 | |
| 1028 | #ifdef HAVE_IPV6 |
| 1029 | if (p->family == AF_INET6) |
| 1030 | { |
| 1031 | /* Left nexthop_local unchanged if so configured. */ |
| 1032 | if ( CHECK_FLAG (rsclient->af_flags[afi][safi], |
| 1033 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) |
| 1034 | { |
| 1035 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 1036 | attr->mp_nexthop_len=32; |
| 1037 | else |
| 1038 | attr->mp_nexthop_len=16; |
| 1039 | } |
| 1040 | |
| 1041 | /* Default nexthop_local treatment for RS-Clients */ |
| 1042 | else |
| 1043 | { |
| 1044 | /* Announcer and RS-Client are both in the same network */ |
| 1045 | if (rsclient->shared_network && from->shared_network && |
| 1046 | (rsclient->ifindex == from->ifindex)) |
| 1047 | { |
| 1048 | if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) ) |
| 1049 | attr->mp_nexthop_len=32; |
| 1050 | else |
| 1051 | attr->mp_nexthop_len=16; |
| 1052 | } |
| 1053 | |
| 1054 | /* Set link-local address for shared network peer. */ |
| 1055 | else if (rsclient->shared_network |
| 1056 | && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local)) |
| 1057 | { |
| 1058 | memcpy (&attr->mp_nexthop_local, &rsclient->nexthop.v6_local, |
| 1059 | IPV6_MAX_BYTELEN); |
| 1060 | attr->mp_nexthop_len = 32; |
| 1061 | } |
| 1062 | |
| 1063 | else |
| 1064 | attr->mp_nexthop_len = 16; |
| 1065 | } |
| 1066 | |
| 1067 | } |
| 1068 | #endif /* HAVE_IPV6 */ |
| 1069 | |
| 1070 | |
| 1071 | /* If this is EBGP peer and remove-private-AS is set. */ |
| 1072 | if (peer_sort (rsclient) == BGP_PEER_EBGP |
| 1073 | && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) |
| 1074 | && aspath_private_as_check (attr->aspath)) |
| 1075 | attr->aspath = aspath_empty_get (); |
| 1076 | |
| 1077 | /* Route map & unsuppress-map apply. */ |
| 1078 | if (ROUTE_MAP_OUT_NAME (filter) || ri->suppress) |
| 1079 | { |
| 1080 | info.peer = rsclient; |
| 1081 | info.attr = attr; |
| 1082 | |
| 1083 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT); |
| 1084 | |
| 1085 | if (ri->suppress) |
| 1086 | ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); |
| 1087 | else |
| 1088 | ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); |
| 1089 | |
| 1090 | rsclient->rmap_type = 0; |
| 1091 | |
| 1092 | if (ret == RMAP_DENYMATCH) |
| 1093 | { |
| 1094 | bgp_attr_flush (attr); |
| 1095 | return 0; |
| 1096 | } |
| 1097 | } |
| 1098 | |
| 1099 | return 1; |
| 1100 | } |
| 1101 | |
| 1102 | struct bgp_info_pair |
| 1103 | { |
| 1104 | struct bgp_info *old; |
| 1105 | struct bgp_info *new; |
| 1106 | }; |
| 1107 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1108 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1109 | bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, struct bgp_info_pair *result) |
| 1110 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1111 | struct bgp_info *new_select; |
| 1112 | struct bgp_info *old_select; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1113 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1114 | struct bgp_info *ri1; |
| 1115 | struct bgp_info *ri2; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1116 | struct bgp_info *nextri = NULL; |
| 1117 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1118 | /* bgp deterministic-med */ |
| 1119 | new_select = NULL; |
| 1120 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) |
| 1121 | for (ri1 = rn->info; ri1; ri1 = ri1->next) |
| 1122 | { |
| 1123 | if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK)) |
| 1124 | continue; |
| 1125 | if (BGP_INFO_HOLDDOWN (ri1)) |
| 1126 | continue; |
| 1127 | |
| 1128 | new_select = ri1; |
| 1129 | if (ri1->next) |
| 1130 | for (ri2 = ri1->next; ri2; ri2 = ri2->next) |
| 1131 | { |
| 1132 | if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK)) |
| 1133 | continue; |
| 1134 | if (BGP_INFO_HOLDDOWN (ri2)) |
| 1135 | continue; |
| 1136 | |
| 1137 | if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath) |
| 1138 | || aspath_cmp_left_confed (ri1->attr->aspath, |
| 1139 | ri2->attr->aspath)) |
| 1140 | { |
| 1141 | if (bgp_info_cmp (bgp, ri2, new_select)) |
| 1142 | { |
| 1143 | UNSET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED); |
| 1144 | new_select = ri2; |
| 1145 | } |
| 1146 | |
| 1147 | SET_FLAG (ri2->flags, BGP_INFO_DMED_CHECK); |
| 1148 | } |
| 1149 | } |
| 1150 | SET_FLAG (new_select->flags, BGP_INFO_DMED_CHECK); |
| 1151 | SET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED); |
| 1152 | } |
| 1153 | |
| 1154 | /* Check old selected route and new selected route. */ |
| 1155 | old_select = NULL; |
| 1156 | new_select = NULL; |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1157 | for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1158 | { |
| 1159 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 1160 | old_select = ri; |
| 1161 | |
| 1162 | if (BGP_INFO_HOLDDOWN (ri)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1163 | { |
| 1164 | /* reap REMOVED routes, if needs be |
| 1165 | * selected route must stay for a while longer though |
| 1166 | */ |
| 1167 | if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) |
| 1168 | && (ri != old_select)) |
| 1169 | bgp_info_reap (rn, ri); |
| 1170 | |
| 1171 | continue; |
| 1172 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1173 | |
| 1174 | if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED) |
| 1175 | && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED))) |
| 1176 | { |
| 1177 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK); |
| 1178 | continue; |
| 1179 | } |
| 1180 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK); |
| 1181 | UNSET_FLAG (ri->flags, BGP_INFO_DMED_SELECTED); |
| 1182 | |
| 1183 | if (bgp_info_cmp (bgp, ri, new_select)) |
| 1184 | new_select = ri; |
| 1185 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1186 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1187 | result->old = old_select; |
| 1188 | result->new = new_select; |
| 1189 | |
| 1190 | return; |
| 1191 | } |
| 1192 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1193 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1194 | bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, |
| 1195 | struct bgp_node *rn, struct attr *attr, afi_t afi, safi_t safi) |
| 1196 | { |
| 1197 | struct prefix *p; |
| 1198 | |
| 1199 | p = &rn->p; |
| 1200 | |
| 1201 | /* Announce route to Established peer. */ |
| 1202 | if (peer->status != Established) |
| 1203 | return 0; |
| 1204 | |
| 1205 | /* Address family configuration check. */ |
| 1206 | if (! peer->afc_nego[afi][safi]) |
| 1207 | return 0; |
| 1208 | |
| 1209 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 1210 | if (CHECK_FLAG (peer->af_sflags[afi][safi], |
| 1211 | PEER_STATUS_ORF_WAIT_REFRESH)) |
| 1212 | return 0; |
| 1213 | |
| 1214 | switch (rn->table->type) |
| 1215 | { |
| 1216 | case BGP_TABLE_MAIN: |
| 1217 | /* Announcement to peer->conf. If the route is filtered, |
| 1218 | withdraw it. */ |
| 1219 | if (selected && bgp_announce_check (selected, peer, p, attr, afi, safi)) |
| 1220 | bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected); |
| 1221 | else |
| 1222 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1223 | break; |
| 1224 | case BGP_TABLE_RSCLIENT: |
| 1225 | /* Announcement to peer->conf. If the route is filtered, |
| 1226 | withdraw it. */ |
| 1227 | if (selected && bgp_announce_check_rsclient |
| 1228 | (selected, peer, p, attr, afi, safi)) |
| 1229 | bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected); |
| 1230 | else |
| 1231 | bgp_adj_out_unset (rn, peer, p, afi, safi); |
| 1232 | break; |
| 1233 | } |
| 1234 | return 0; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1235 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1236 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1237 | struct bgp_process_queue |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1238 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1239 | struct bgp *bgp; |
| 1240 | struct bgp_node *rn; |
| 1241 | afi_t afi; |
| 1242 | safi_t safi; |
| 1243 | }; |
| 1244 | |
| 1245 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1246 | bgp_process_rsclient (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1247 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1248 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1249 | struct bgp *bgp = pq->bgp; |
| 1250 | struct bgp_node *rn = pq->rn; |
| 1251 | afi_t afi = pq->afi; |
| 1252 | safi_t safi = pq->safi; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1253 | struct bgp_info *new_select; |
| 1254 | struct bgp_info *old_select; |
| 1255 | struct bgp_info_pair old_and_new; |
| 1256 | struct attr attr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1257 | struct listnode *node, *nnode; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1258 | struct peer *rsclient = rn->table->owner; |
| 1259 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1260 | /* Best path selection. */ |
| 1261 | bgp_best_selection (bgp, rn, &old_and_new); |
| 1262 | new_select = old_and_new.new; |
| 1263 | old_select = old_and_new.old; |
| 1264 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1265 | if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP)) |
| 1266 | { |
| 1267 | for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient)) |
| 1268 | { |
| 1269 | /* Nothing to do. */ |
| 1270 | if (old_select && old_select == new_select) |
| 1271 | if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
| 1272 | continue; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1273 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1274 | if (old_select) |
| 1275 | UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED); |
| 1276 | if (new_select) |
| 1277 | { |
| 1278 | SET_FLAG (new_select->flags, BGP_INFO_SELECTED); |
| 1279 | UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED); |
| 1280 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1281 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1282 | bgp_process_announce_selected (rsclient, new_select, rn, &attr, |
| 1283 | afi, safi); |
| 1284 | } |
| 1285 | } |
| 1286 | else |
| 1287 | { |
hasso | b739579 | 2005-08-26 12:58:38 +0000 | [diff] [blame] | 1288 | if (old_select) |
| 1289 | UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED); |
| 1290 | if (new_select) |
| 1291 | { |
| 1292 | SET_FLAG (new_select->flags, BGP_INFO_SELECTED); |
| 1293 | UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED); |
| 1294 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1295 | bgp_process_announce_selected (rsclient, new_select, rn, |
| 1296 | &attr, afi, safi); |
| 1297 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1298 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1299 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1300 | bgp_info_reap (rn, old_select); |
| 1301 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1302 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1303 | return WQ_SUCCESS; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1304 | } |
| 1305 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1306 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1307 | bgp_process_main (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1308 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1309 | struct bgp_process_queue *pq = data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1310 | struct bgp *bgp = pq->bgp; |
| 1311 | struct bgp_node *rn = pq->rn; |
| 1312 | afi_t afi = pq->afi; |
| 1313 | safi_t safi = pq->safi; |
| 1314 | struct prefix *p = &rn->p; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1315 | struct bgp_info *new_select; |
| 1316 | struct bgp_info *old_select; |
| 1317 | struct bgp_info_pair old_and_new; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1318 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1319 | struct peer *peer; |
| 1320 | struct attr attr; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1321 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1322 | /* Best path selection. */ |
| 1323 | bgp_best_selection (bgp, rn, &old_and_new); |
| 1324 | old_select = old_and_new.old; |
| 1325 | new_select = old_and_new.new; |
| 1326 | |
| 1327 | /* Nothing to do. */ |
| 1328 | if (old_select && old_select == new_select) |
| 1329 | { |
| 1330 | if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1331 | { |
| 1332 | if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED)) |
| 1333 | bgp_zebra_announce (p, old_select, bgp); |
| 1334 | |
| 1335 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1336 | return WQ_SUCCESS; |
| 1337 | } |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1338 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1339 | |
hasso | 338b342 | 2005-02-23 14:27:24 +0000 | [diff] [blame] | 1340 | if (old_select) |
| 1341 | UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED); |
| 1342 | if (new_select) |
| 1343 | { |
| 1344 | SET_FLAG (new_select->flags, BGP_INFO_SELECTED); |
| 1345 | UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED); |
| 1346 | } |
| 1347 | |
| 1348 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1349 | /* Check each BGP peer. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1350 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1351 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1352 | bgp_process_announce_selected (peer, new_select, rn, &attr, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1353 | } |
| 1354 | |
| 1355 | /* FIB update. */ |
| 1356 | if (safi == SAFI_UNICAST && ! bgp->name && |
| 1357 | ! bgp_option_check (BGP_OPT_NO_FIB)) |
| 1358 | { |
| 1359 | if (new_select |
| 1360 | && new_select->type == ZEBRA_ROUTE_BGP |
| 1361 | && new_select->sub_type == BGP_ROUTE_NORMAL) |
| 1362 | bgp_zebra_announce (p, new_select, bgp); |
| 1363 | else |
| 1364 | { |
| 1365 | /* Withdraw the route from the kernel. */ |
| 1366 | if (old_select |
| 1367 | && old_select->type == ZEBRA_ROUTE_BGP |
| 1368 | && old_select->sub_type == BGP_ROUTE_NORMAL) |
| 1369 | bgp_zebra_withdraw (p, old_select); |
| 1370 | } |
| 1371 | } |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1372 | |
| 1373 | /* Reap old select bgp_info, it it has been removed */ |
| 1374 | if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) |
| 1375 | bgp_info_reap (rn, old_select); |
| 1376 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1377 | UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); |
| 1378 | return WQ_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1379 | } |
| 1380 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1381 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1382 | bgp_processq_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1383 | { |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 1384 | struct bgp_process_queue *pq = data; |
| 1385 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1386 | bgp_unlock_node (pq->rn); |
| 1387 | XFREE (MTYPE_BGP_PROCESS_QUEUE, pq); |
| 1388 | } |
| 1389 | |
| 1390 | static void |
| 1391 | bgp_process_queue_init (void) |
| 1392 | { |
| 1393 | bm->process_main_queue |
| 1394 | = work_queue_new (bm->master, "process_main_queue"); |
| 1395 | bm->process_rsclient_queue |
| 1396 | = work_queue_new (bm->master, "process_rsclient_queue"); |
| 1397 | |
| 1398 | if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) |
| 1399 | { |
| 1400 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 1401 | exit (1); |
| 1402 | } |
| 1403 | |
| 1404 | bm->process_main_queue->spec.workfunc = &bgp_process_main; |
| 1405 | bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; |
| 1406 | bm->process_main_queue->spec.del_item_data = &bgp_processq_del; |
| 1407 | bm->process_rsclient_queue->spec.del_item_data |
| 1408 | = bm->process_main_queue->spec.del_item_data; |
| 1409 | bm->process_main_queue->spec.max_retries |
| 1410 | = bm->process_main_queue->spec.max_retries = 0; |
| 1411 | bm->process_rsclient_queue->spec.hold |
| 1412 | = bm->process_main_queue->spec.hold = 500; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1413 | } |
| 1414 | |
| 1415 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1416 | bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) |
| 1417 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1418 | struct bgp_process_queue *pqnode; |
| 1419 | |
| 1420 | /* already scheduled for processing? */ |
| 1421 | if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) |
| 1422 | return; |
| 1423 | |
| 1424 | if ( (bm->process_main_queue == NULL) || |
| 1425 | (bm->process_rsclient_queue == NULL) ) |
| 1426 | bgp_process_queue_init (); |
| 1427 | |
| 1428 | pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, |
| 1429 | sizeof (struct bgp_process_queue)); |
| 1430 | if (!pqnode) |
| 1431 | return; |
| 1432 | |
| 1433 | pqnode->rn = bgp_lock_node (rn); /* unlocked by bgp_processq_del */ |
| 1434 | pqnode->bgp = bgp; |
| 1435 | pqnode->afi = afi; |
| 1436 | pqnode->safi = safi; |
| 1437 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1438 | switch (rn->table->type) |
| 1439 | { |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1440 | case BGP_TABLE_MAIN: |
| 1441 | work_queue_add (bm->process_main_queue, pqnode); |
| 1442 | break; |
| 1443 | case BGP_TABLE_RSCLIENT: |
| 1444 | work_queue_add (bm->process_rsclient_queue, pqnode); |
| 1445 | break; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1446 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1447 | |
| 1448 | return; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1449 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1450 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1451 | static int |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1452 | bgp_maximum_prefix_restart_timer (struct thread *thread) |
| 1453 | { |
| 1454 | struct peer *peer; |
| 1455 | |
| 1456 | peer = THREAD_ARG (thread); |
| 1457 | peer->t_pmax_restart = NULL; |
| 1458 | |
| 1459 | if (BGP_DEBUG (events, EVENTS)) |
| 1460 | zlog_debug ("%s Maximum-prefix restart timer expired, restore peering", |
| 1461 | peer->host); |
| 1462 | |
| 1463 | peer_clear (peer); |
| 1464 | |
| 1465 | return 0; |
| 1466 | } |
| 1467 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1468 | int |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1469 | bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, |
| 1470 | safi_t safi, int always) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1471 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1472 | if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) |
| 1473 | return 0; |
| 1474 | |
| 1475 | if (peer->pcount[afi][safi] > peer->pmax[afi][safi]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1476 | { |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1477 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT) |
| 1478 | && ! always) |
| 1479 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1480 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1481 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1482 | "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, " |
| 1483 | "limit %ld", afi_safi_print (afi, safi), peer->host, |
| 1484 | peer->pcount[afi][safi], peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1485 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1486 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1487 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) |
| 1488 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1489 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1490 | { |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1491 | u_int8_t ndata[7]; |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1492 | |
| 1493 | if (safi == SAFI_MPLS_VPN) |
| 1494 | safi = BGP_SAFI_VPNV4; |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 1495 | |
| 1496 | ndata[0] = (afi >> 8); |
| 1497 | ndata[1] = afi; |
| 1498 | ndata[2] = safi; |
| 1499 | ndata[3] = (peer->pmax[afi][safi] >> 24); |
| 1500 | ndata[4] = (peer->pmax[afi][safi] >> 16); |
| 1501 | ndata[5] = (peer->pmax[afi][safi] >> 8); |
| 1502 | ndata[6] = (peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1503 | |
| 1504 | SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW); |
| 1505 | bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE, |
| 1506 | BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7); |
| 1507 | } |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1508 | |
| 1509 | /* restart timer start */ |
| 1510 | if (peer->pmax_restart[afi][safi]) |
| 1511 | { |
| 1512 | peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60; |
| 1513 | |
| 1514 | if (BGP_DEBUG (events, EVENTS)) |
| 1515 | zlog_debug ("%s Maximum-prefix restart timer started for %d secs", |
| 1516 | peer->host, peer->v_pmax_restart); |
| 1517 | |
| 1518 | BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer, |
| 1519 | peer->v_pmax_restart); |
| 1520 | } |
| 1521 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1522 | return 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1523 | } |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1524 | else |
| 1525 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT); |
| 1526 | |
| 1527 | if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100)) |
| 1528 | { |
| 1529 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD) |
| 1530 | && ! always) |
| 1531 | return 0; |
| 1532 | |
| 1533 | zlog (peer->log, LOG_INFO, |
hasso | 0a486e5 | 2005-02-01 20:57:17 +0000 | [diff] [blame] | 1534 | "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld", |
| 1535 | afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi], |
| 1536 | peer->pmax[afi][safi]); |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 1537 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
| 1538 | } |
| 1539 | else |
| 1540 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1541 | return 0; |
| 1542 | } |
| 1543 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1544 | static void |
| 1545 | bgp_pcount_increment (struct bgp_node *rn, struct bgp_info *ri, |
| 1546 | afi_t afi, safi_t safi) |
| 1547 | { |
| 1548 | assert (ri && rn); |
| 1549 | |
| 1550 | if (!CHECK_FLAG (ri->flags, BGP_INFO_COUNTED) |
| 1551 | && rn->table->type == BGP_TABLE_MAIN) |
| 1552 | { |
| 1553 | SET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 1554 | ri->peer->pcount[afi][safi]++; |
| 1555 | } |
| 1556 | } |
| 1557 | |
| 1558 | static void |
| 1559 | bgp_pcount_decrement (struct bgp_node *rn, struct bgp_info *ri, |
| 1560 | afi_t afi, safi_t safi) |
| 1561 | { |
| 1562 | /* Ignore 'pcount' for RS-client tables */ |
| 1563 | if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED) |
| 1564 | && rn->table->type == BGP_TABLE_MAIN) |
| 1565 | { |
| 1566 | UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); |
| 1567 | |
| 1568 | /* slight hack, but more robust against errors. */ |
| 1569 | if (ri->peer->pcount[afi][safi]) |
| 1570 | ri->peer->pcount[afi][safi]--; |
| 1571 | else |
| 1572 | { |
| 1573 | zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s", |
| 1574 | __func__, ri->peer->host); |
| 1575 | zlog_backtrace (LOG_WARNING); |
| 1576 | zlog_warn ("%s: Please report to Quagga bugzilla", __func__); |
| 1577 | } |
| 1578 | } |
| 1579 | } |
| 1580 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1581 | /* Unconditionally remove the route from the RIB, without taking |
| 1582 | * damping into consideration (eg, because the session went down) |
| 1583 | */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1584 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1585 | bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
| 1586 | afi_t afi, safi_t safi) |
| 1587 | { |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1588 | bgp_pcount_decrement (rn, ri, afi, safi); |
| 1589 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1590 | |
| 1591 | if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1592 | bgp_info_delete (rn, ri); /* keep historical info */ |
| 1593 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1594 | bgp_process (peer->bgp, rn, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1595 | } |
| 1596 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1597 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1598 | bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1599 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1600 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1601 | int status = BGP_DAMP_NONE; |
| 1602 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1603 | /* apply dampening, if result is suppressed, we'll be retaining |
| 1604 | * the bgp_info in the RIB for historical reference. |
| 1605 | */ |
| 1606 | if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1607 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 1608 | if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) |
| 1609 | == BGP_DAMP_SUPPRESSED) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1610 | { |
| 1611 | bgp_pcount_decrement (rn, ri, afi, safi); |
| 1612 | bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); |
| 1613 | return; |
| 1614 | } |
| 1615 | |
| 1616 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1617 | } |
| 1618 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1619 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1620 | bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1621 | struct attr *attr, struct peer *peer, struct prefix *p, int type, |
| 1622 | int sub_type, struct prefix_rd *prd, u_char *tag) |
| 1623 | { |
| 1624 | struct bgp_node *rn; |
| 1625 | struct bgp *bgp; |
| 1626 | struct attr new_attr; |
| 1627 | struct attr *attr_new; |
| 1628 | struct attr *attr_new2; |
| 1629 | struct bgp_info *ri; |
| 1630 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1631 | const char *reason; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1632 | char buf[SU_ADDRSTRLEN]; |
| 1633 | |
| 1634 | /* Do not insert announces from a rsclient into its own 'bgp_table'. */ |
| 1635 | if (peer == rsclient) |
| 1636 | return; |
| 1637 | |
| 1638 | bgp = peer->bgp; |
| 1639 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1640 | |
| 1641 | /* Check previously received route. */ |
| 1642 | for (ri = rn->info; ri; ri = ri->next) |
| 1643 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1644 | break; |
| 1645 | |
| 1646 | /* AS path loop check. */ |
| 1647 | if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi]) |
| 1648 | { |
| 1649 | reason = "as-path contains our own AS;"; |
| 1650 | goto filtered; |
| 1651 | } |
| 1652 | |
| 1653 | /* Route reflector originator ID check. */ |
| 1654 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
| 1655 | && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->originator_id)) |
| 1656 | { |
| 1657 | reason = "originator is us;"; |
| 1658 | goto filtered; |
| 1659 | } |
| 1660 | |
| 1661 | new_attr = *attr; |
| 1662 | |
| 1663 | /* Apply export policy. */ |
| 1664 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) && |
| 1665 | bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1666 | { |
| 1667 | reason = "export-policy;"; |
| 1668 | goto filtered; |
| 1669 | } |
| 1670 | |
| 1671 | attr_new2 = bgp_attr_intern (&new_attr); |
| 1672 | |
| 1673 | /* Apply import policy. */ |
| 1674 | if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1675 | { |
| 1676 | bgp_attr_unintern (attr_new2); |
| 1677 | |
| 1678 | reason = "import-policy;"; |
| 1679 | goto filtered; |
| 1680 | } |
| 1681 | |
| 1682 | attr_new = bgp_attr_intern (&new_attr); |
| 1683 | bgp_attr_unintern (attr_new2); |
| 1684 | |
| 1685 | /* IPv4 unicast next hop check. */ |
| 1686 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 1687 | { |
| 1688 | /* Next hop must not be 0.0.0.0 nor Class E address. */ |
| 1689 | if (new_attr.nexthop.s_addr == 0 |
| 1690 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 1691 | { |
| 1692 | bgp_attr_unintern (attr_new); |
| 1693 | |
| 1694 | reason = "martian next-hop;"; |
| 1695 | goto filtered; |
| 1696 | } |
| 1697 | } |
| 1698 | |
| 1699 | /* If the update is implicit withdraw. */ |
| 1700 | if (ri) |
| 1701 | { |
| 1702 | ri->uptime = time (NULL); |
| 1703 | |
| 1704 | /* Same attribute comes in. */ |
| 1705 | if (attrhash_cmp (ri->attr, attr_new)) |
| 1706 | { |
| 1707 | |
| 1708 | UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1709 | |
| 1710 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1711 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1712 | "%s rcvd %s/%d for RS-client %s...duplicate ignored", |
| 1713 | peer->host, |
| 1714 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1715 | p->prefixlen, rsclient->host); |
| 1716 | |
| 1717 | bgp_unlock_node (rn); |
| 1718 | bgp_attr_unintern (attr_new); |
| 1719 | |
| 1720 | return; |
| 1721 | } |
| 1722 | |
| 1723 | /* Received Logging. */ |
| 1724 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1725 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1726 | peer->host, |
| 1727 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1728 | p->prefixlen, rsclient->host); |
| 1729 | |
| 1730 | /* The attribute is changed. */ |
| 1731 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1732 | |
| 1733 | /* Update to new attribute. */ |
| 1734 | bgp_attr_unintern (ri->attr); |
| 1735 | ri->attr = attr_new; |
| 1736 | |
| 1737 | /* Update MPLS tag. */ |
| 1738 | if (safi == SAFI_MPLS_VPN) |
| 1739 | memcpy (ri->tag, tag, 3); |
| 1740 | |
| 1741 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 1742 | |
| 1743 | /* Process change. */ |
| 1744 | bgp_process (bgp, rn, afi, safi); |
| 1745 | bgp_unlock_node (rn); |
| 1746 | |
| 1747 | return; |
| 1748 | } |
| 1749 | |
| 1750 | /* Received Logging. */ |
| 1751 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 1752 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1753 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1754 | peer->host, |
| 1755 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1756 | p->prefixlen, rsclient->host); |
| 1757 | } |
| 1758 | |
| 1759 | /* Make new BGP info. */ |
| 1760 | new = bgp_info_new (); |
| 1761 | new->type = type; |
| 1762 | new->sub_type = sub_type; |
| 1763 | new->peer = peer; |
| 1764 | new->attr = attr_new; |
| 1765 | new->uptime = time (NULL); |
| 1766 | |
| 1767 | /* Update MPLS tag. */ |
| 1768 | if (safi == SAFI_MPLS_VPN) |
| 1769 | memcpy (new->tag, tag, 3); |
| 1770 | |
| 1771 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 1772 | |
| 1773 | /* Register new BGP information. */ |
| 1774 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 1775 | |
| 1776 | /* route_node_get lock */ |
| 1777 | bgp_unlock_node (rn); |
| 1778 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1779 | /* Process change. */ |
| 1780 | bgp_process (bgp, rn, afi, safi); |
| 1781 | |
| 1782 | return; |
| 1783 | |
| 1784 | filtered: |
| 1785 | |
| 1786 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 1787 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1788 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1789 | "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s", |
| 1790 | peer->host, |
| 1791 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1792 | p->prefixlen, rsclient->host, reason); |
| 1793 | |
| 1794 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1795 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1796 | |
| 1797 | bgp_unlock_node (rn); |
| 1798 | |
| 1799 | return; |
| 1800 | } |
| 1801 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1802 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1803 | bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, |
| 1804 | struct peer *peer, struct prefix *p, int type, int sub_type, |
| 1805 | struct prefix_rd *prd, u_char *tag) |
| 1806 | { |
| 1807 | struct bgp_node *rn; |
| 1808 | struct bgp_info *ri; |
| 1809 | char buf[SU_ADDRSTRLEN]; |
| 1810 | |
| 1811 | if (rsclient == peer) |
| 1812 | return; |
| 1813 | |
| 1814 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd); |
| 1815 | |
| 1816 | /* Lookup withdrawn route. */ |
| 1817 | for (ri = rn->info; ri; ri = ri->next) |
| 1818 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1819 | break; |
| 1820 | |
| 1821 | /* Withdraw specified route from routing table. */ |
| 1822 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 1823 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1824 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1825 | zlog (peer->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1826 | "%s Can't find the route %s/%d", peer->host, |
| 1827 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1828 | p->prefixlen); |
| 1829 | |
| 1830 | /* Unlock bgp_node_get() lock. */ |
| 1831 | bgp_unlock_node (rn); |
| 1832 | } |
| 1833 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1834 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1835 | bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1836 | afi_t afi, safi_t safi, int type, int sub_type, |
| 1837 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 1838 | { |
| 1839 | int ret; |
| 1840 | int aspath_loop_count = 0; |
| 1841 | struct bgp_node *rn; |
| 1842 | struct bgp *bgp; |
| 1843 | struct attr new_attr; |
| 1844 | struct attr *attr_new; |
| 1845 | struct bgp_info *ri; |
| 1846 | struct bgp_info *new; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1847 | const char *reason; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1848 | char buf[SU_ADDRSTRLEN]; |
| 1849 | |
| 1850 | bgp = peer->bgp; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 1851 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1852 | |
| 1853 | /* When peer's soft reconfiguration enabled. Record input packet in |
| 1854 | Adj-RIBs-In. */ |
| 1855 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 1856 | && peer != bgp->peer_self && ! soft_reconfig) |
| 1857 | bgp_adj_in_set (rn, peer, attr); |
| 1858 | |
| 1859 | /* Check previously received route. */ |
| 1860 | for (ri = rn->info; ri; ri = ri->next) |
| 1861 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 1862 | break; |
| 1863 | |
| 1864 | /* AS path local-as loop check. */ |
| 1865 | if (peer->change_local_as) |
| 1866 | { |
| 1867 | if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
| 1868 | aspath_loop_count = 1; |
| 1869 | |
| 1870 | if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) |
| 1871 | { |
| 1872 | reason = "as-path contains our own AS;"; |
| 1873 | goto filtered; |
| 1874 | } |
| 1875 | } |
| 1876 | |
| 1877 | /* AS path loop check. */ |
| 1878 | if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi] |
| 1879 | || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) |
| 1880 | && aspath_loop_check(attr->aspath, bgp->confed_id) |
| 1881 | > peer->allowas_in[afi][safi])) |
| 1882 | { |
| 1883 | reason = "as-path contains our own AS;"; |
| 1884 | goto filtered; |
| 1885 | } |
| 1886 | |
| 1887 | /* Route reflector originator ID check. */ |
| 1888 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID) |
| 1889 | && IPV4_ADDR_SAME (&bgp->router_id, &attr->originator_id)) |
| 1890 | { |
| 1891 | reason = "originator is us;"; |
| 1892 | goto filtered; |
| 1893 | } |
| 1894 | |
| 1895 | /* Route reflector cluster ID check. */ |
| 1896 | if (bgp_cluster_filter (peer, attr)) |
| 1897 | { |
| 1898 | reason = "reflected from the same cluster;"; |
| 1899 | goto filtered; |
| 1900 | } |
| 1901 | |
| 1902 | /* Apply incoming filter. */ |
| 1903 | if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY) |
| 1904 | { |
| 1905 | reason = "filter;"; |
| 1906 | goto filtered; |
| 1907 | } |
| 1908 | |
| 1909 | /* Apply incoming route-map. */ |
| 1910 | new_attr = *attr; |
| 1911 | |
| 1912 | if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY) |
| 1913 | { |
| 1914 | reason = "route-map;"; |
| 1915 | goto filtered; |
| 1916 | } |
| 1917 | |
| 1918 | /* IPv4 unicast next hop check. */ |
| 1919 | if (afi == AFI_IP && safi == SAFI_UNICAST) |
| 1920 | { |
| 1921 | /* If the peer is EBGP and nexthop is not on connected route, |
| 1922 | discard it. */ |
| 1923 | if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1 |
| 1924 | && ! bgp_nexthop_check_ebgp (afi, &new_attr) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 1925 | && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1926 | { |
| 1927 | reason = "non-connected next-hop;"; |
| 1928 | goto filtered; |
| 1929 | } |
| 1930 | |
| 1931 | /* Next hop must not be 0.0.0.0 nor Class E address. Next hop |
| 1932 | must not be my own address. */ |
| 1933 | if (bgp_nexthop_self (afi, &new_attr) |
| 1934 | || new_attr.nexthop.s_addr == 0 |
| 1935 | || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000) |
| 1936 | { |
| 1937 | reason = "martian next-hop;"; |
| 1938 | goto filtered; |
| 1939 | } |
| 1940 | } |
| 1941 | |
| 1942 | attr_new = bgp_attr_intern (&new_attr); |
| 1943 | |
| 1944 | /* If the update is implicit withdraw. */ |
| 1945 | if (ri) |
| 1946 | { |
| 1947 | ri->uptime = time (NULL); |
| 1948 | |
| 1949 | /* Same attribute comes in. */ |
| 1950 | if (attrhash_cmp (ri->attr, attr_new)) |
| 1951 | { |
| 1952 | UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 1953 | |
| 1954 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 1955 | && peer_sort (peer) == BGP_PEER_EBGP |
| 1956 | && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 1957 | { |
| 1958 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1959 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1960 | peer->host, |
| 1961 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1962 | p->prefixlen); |
| 1963 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1964 | bgp_pcount_increment (rn, ri, afi, safi); |
| 1965 | |
| 1966 | if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED) |
| 1967 | { |
| 1968 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 1969 | bgp_process (bgp, rn, afi, safi); |
| 1970 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1971 | } |
| 1972 | else |
| 1973 | { |
| 1974 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1975 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1976 | "%s rcvd %s/%d...duplicate ignored", |
| 1977 | peer->host, |
| 1978 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 1979 | p->prefixlen); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 1980 | |
| 1981 | /* graceful restart STALE flag unset. */ |
| 1982 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 1983 | { |
| 1984 | UNSET_FLAG (ri->flags, BGP_INFO_STALE); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 1985 | bgp_pcount_increment (rn, ri, afi, safi); |
| 1986 | bgp_process (bgp, rn, afi, safi); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 1987 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1988 | } |
| 1989 | |
| 1990 | bgp_unlock_node (rn); |
| 1991 | bgp_attr_unintern (attr_new); |
| 1992 | return 0; |
| 1993 | } |
| 1994 | |
| 1995 | /* Received Logging. */ |
| 1996 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 1997 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1998 | peer->host, |
| 1999 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2000 | p->prefixlen); |
| 2001 | |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2002 | /* graceful restart STALE flag unset. */ |
| 2003 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2004 | UNSET_FLAG (ri->flags, BGP_INFO_STALE); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2005 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2006 | /* The attribute is changed. */ |
| 2007 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2008 | |
| 2009 | /* implicit withdraw, decrement aggregate and pcount here. |
| 2010 | * only if update is accepted, they'll increment below. |
| 2011 | */ |
| 2012 | bgp_pcount_decrement (rn, ri, afi, safi); |
| 2013 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 2014 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2015 | /* Update bgp route dampening information. */ |
| 2016 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 2017 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 2018 | { |
| 2019 | /* This is implicit withdraw so we should update dampening |
| 2020 | information. */ |
| 2021 | if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 2022 | bgp_damp_withdraw (ri, rn, afi, safi, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2023 | } |
| 2024 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2025 | /* Update to new attribute. */ |
| 2026 | bgp_attr_unintern (ri->attr); |
| 2027 | ri->attr = attr_new; |
| 2028 | |
| 2029 | /* Update MPLS tag. */ |
| 2030 | if (safi == SAFI_MPLS_VPN) |
| 2031 | memcpy (ri->tag, tag, 3); |
| 2032 | |
| 2033 | /* Update bgp route dampening information. */ |
| 2034 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) |
| 2035 | && peer_sort (peer) == BGP_PEER_EBGP) |
| 2036 | { |
| 2037 | /* Now we do normal update dampening. */ |
| 2038 | ret = bgp_damp_update (ri, rn, afi, safi); |
| 2039 | if (ret == BGP_DAMP_SUPPRESSED) |
| 2040 | { |
| 2041 | bgp_unlock_node (rn); |
| 2042 | return 0; |
| 2043 | } |
| 2044 | } |
| 2045 | |
| 2046 | /* Nexthop reachability check. */ |
| 2047 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2048 | && safi == SAFI_UNICAST |
| 2049 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 2050 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2051 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2052 | { |
| 2053 | if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL)) |
| 2054 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2055 | else |
| 2056 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2057 | } |
| 2058 | else |
| 2059 | SET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2060 | |
| 2061 | /* Process change. */ |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2062 | bgp_pcount_increment (rn, ri, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2063 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 2064 | |
| 2065 | bgp_process (bgp, rn, afi, safi); |
| 2066 | bgp_unlock_node (rn); |
| 2067 | return 0; |
| 2068 | } |
| 2069 | |
| 2070 | /* Received Logging. */ |
| 2071 | if (BGP_DEBUG (update, UPDATE_IN)) |
| 2072 | { |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2073 | zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2074 | peer->host, |
| 2075 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2076 | p->prefixlen); |
| 2077 | } |
| 2078 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2079 | /* Make new BGP info. */ |
| 2080 | new = bgp_info_new (); |
| 2081 | new->type = type; |
| 2082 | new->sub_type = sub_type; |
| 2083 | new->peer = peer; |
| 2084 | new->attr = attr_new; |
| 2085 | new->uptime = time (NULL); |
| 2086 | |
| 2087 | /* Update MPLS tag. */ |
| 2088 | if (safi == SAFI_MPLS_VPN) |
| 2089 | memcpy (new->tag, tag, 3); |
| 2090 | |
| 2091 | /* Nexthop reachability check. */ |
| 2092 | if ((afi == AFI_IP || afi == AFI_IP6) |
| 2093 | && safi == SAFI_UNICAST |
| 2094 | && (peer_sort (peer) == BGP_PEER_IBGP |
| 2095 | || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) |
hasso | 6ffd207 | 2005-02-02 14:50:11 +0000 | [diff] [blame] | 2096 | || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2097 | { |
| 2098 | if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL)) |
| 2099 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 2100 | else |
| 2101 | UNSET_FLAG (new->flags, BGP_INFO_VALID); |
| 2102 | } |
| 2103 | else |
| 2104 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 2105 | |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2106 | /* Increment prefix */ |
| 2107 | bgp_pcount_increment (rn, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2108 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 2109 | |
| 2110 | /* Register new BGP information. */ |
| 2111 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2112 | |
| 2113 | /* route_node_get lock */ |
| 2114 | bgp_unlock_node (rn); |
| 2115 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2116 | /* If maximum prefix count is configured and current prefix |
| 2117 | count exeed it. */ |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 2118 | if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) |
| 2119 | return -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2120 | |
| 2121 | /* Process change. */ |
| 2122 | bgp_process (bgp, rn, afi, safi); |
| 2123 | |
| 2124 | return 0; |
| 2125 | |
| 2126 | /* This BGP update is filtered. Log the reason then update BGP |
| 2127 | entry. */ |
| 2128 | filtered: |
| 2129 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2130 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2131 | "%s rcvd UPDATE about %s/%d -- DENIED due to: %s", |
| 2132 | peer->host, |
| 2133 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2134 | p->prefixlen, reason); |
| 2135 | |
| 2136 | if (ri) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2137 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2138 | |
| 2139 | bgp_unlock_node (rn); |
| 2140 | |
| 2141 | return 0; |
| 2142 | } |
| 2143 | |
| 2144 | int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2145 | bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, |
| 2146 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2147 | struct prefix_rd *prd, u_char *tag, int soft_reconfig) |
| 2148 | { |
| 2149 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2150 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2151 | struct bgp *bgp; |
| 2152 | int ret; |
| 2153 | |
| 2154 | ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag, |
| 2155 | soft_reconfig); |
| 2156 | |
| 2157 | bgp = peer->bgp; |
| 2158 | |
| 2159 | /* Process the update for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2160 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2161 | { |
| 2162 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2163 | bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type, |
| 2164 | sub_type, prd, tag); |
| 2165 | } |
| 2166 | |
| 2167 | return ret; |
| 2168 | } |
| 2169 | |
| 2170 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2171 | bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2172 | afi_t afi, safi_t safi, int type, int sub_type, |
| 2173 | struct prefix_rd *prd, u_char *tag) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2174 | { |
| 2175 | struct bgp *bgp; |
| 2176 | char buf[SU_ADDRSTRLEN]; |
| 2177 | struct bgp_node *rn; |
| 2178 | struct bgp_info *ri; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2179 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2180 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2181 | |
| 2182 | bgp = peer->bgp; |
| 2183 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2184 | /* Process the withdraw for each RS-client. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2185 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2186 | { |
| 2187 | if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2188 | bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag); |
| 2189 | } |
| 2190 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2191 | /* Logging. */ |
| 2192 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2193 | zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2194 | peer->host, |
| 2195 | inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2196 | p->prefixlen); |
| 2197 | |
| 2198 | /* Lookup node. */ |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2199 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2200 | |
| 2201 | /* If peer is soft reconfiguration enabled. Record input packet for |
| 2202 | further calculation. */ |
| 2203 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) |
| 2204 | && peer != bgp->peer_self) |
| 2205 | bgp_adj_in_unset (rn, peer); |
| 2206 | |
| 2207 | /* Lookup withdrawn route. */ |
| 2208 | for (ri = rn->info; ri; ri = ri->next) |
| 2209 | if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type) |
| 2210 | break; |
| 2211 | |
| 2212 | /* Withdraw specified route from routing table. */ |
| 2213 | if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 2214 | bgp_rib_withdraw (rn, ri, peer, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2215 | else if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2216 | zlog (peer->log, LOG_DEBUG, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2217 | "%s Can't find the route %s/%d", peer->host, |
| 2218 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2219 | p->prefixlen); |
| 2220 | |
| 2221 | /* Unlock bgp_node_get() lock. */ |
| 2222 | bgp_unlock_node (rn); |
| 2223 | |
| 2224 | return 0; |
| 2225 | } |
| 2226 | |
| 2227 | void |
| 2228 | bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) |
| 2229 | { |
| 2230 | struct bgp *bgp; |
| 2231 | struct attr attr; |
| 2232 | struct aspath *aspath; |
| 2233 | struct prefix p; |
| 2234 | struct bgp_info binfo; |
| 2235 | struct peer *from; |
| 2236 | int ret = RMAP_DENYMATCH; |
| 2237 | |
| 2238 | bgp = peer->bgp; |
| 2239 | from = bgp->peer_self; |
| 2240 | |
| 2241 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2242 | aspath = attr.aspath; |
| 2243 | attr.local_pref = bgp->default_local_pref; |
| 2244 | memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); |
| 2245 | |
| 2246 | if (afi == AFI_IP) |
| 2247 | str2prefix ("0.0.0.0/0", &p); |
| 2248 | #ifdef HAVE_IPV6 |
| 2249 | else if (afi == AFI_IP6) |
| 2250 | { |
| 2251 | str2prefix ("::/0", &p); |
| 2252 | |
| 2253 | /* IPv6 global nexthop must be included. */ |
| 2254 | memcpy (&attr.mp_nexthop_global, &peer->nexthop.v6_global, |
| 2255 | IPV6_MAX_BYTELEN); |
| 2256 | attr.mp_nexthop_len = 16; |
| 2257 | |
| 2258 | /* If the peer is on shared nextwork and we have link-local |
| 2259 | nexthop set it. */ |
| 2260 | if (peer->shared_network |
| 2261 | && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) |
| 2262 | { |
| 2263 | memcpy (&attr.mp_nexthop_local, &peer->nexthop.v6_local, |
| 2264 | IPV6_MAX_BYTELEN); |
| 2265 | attr.mp_nexthop_len = 32; |
| 2266 | } |
| 2267 | } |
| 2268 | #endif /* HAVE_IPV6 */ |
| 2269 | else |
| 2270 | return; |
| 2271 | |
| 2272 | if (peer->default_rmap[afi][safi].name) |
| 2273 | { |
| 2274 | binfo.peer = bgp->peer_self; |
| 2275 | binfo.attr = &attr; |
| 2276 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2277 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT); |
| 2278 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2279 | ret = route_map_apply (peer->default_rmap[afi][safi].map, &p, |
| 2280 | RMAP_BGP, &binfo); |
| 2281 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2282 | bgp->peer_self->rmap_type = 0; |
| 2283 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2284 | if (ret == RMAP_DENYMATCH) |
| 2285 | { |
| 2286 | bgp_attr_flush (&attr); |
| 2287 | withdraw = 1; |
| 2288 | } |
| 2289 | } |
| 2290 | |
| 2291 | if (withdraw) |
| 2292 | { |
| 2293 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) |
| 2294 | bgp_default_withdraw_send (peer, afi, safi); |
| 2295 | UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2296 | } |
| 2297 | else |
| 2298 | { |
| 2299 | SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); |
| 2300 | bgp_default_update_send (peer, &attr, afi, safi, from); |
| 2301 | } |
| 2302 | |
| 2303 | aspath_unintern (aspath); |
| 2304 | } |
| 2305 | |
| 2306 | static void |
| 2307 | bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2308 | struct bgp_table *table, int rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2309 | { |
| 2310 | struct bgp_node *rn; |
| 2311 | struct bgp_info *ri; |
| 2312 | struct attr attr; |
| 2313 | |
| 2314 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2315 | table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2316 | |
| 2317 | if (safi != SAFI_MPLS_VPN |
| 2318 | && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) |
| 2319 | bgp_default_originate (peer, afi, safi, 0); |
| 2320 | |
| 2321 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) |
| 2322 | for (ri = rn->info; ri; ri = ri->next) |
| 2323 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) |
| 2324 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2325 | if ( (rsclient) ? |
| 2326 | (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi)) |
| 2327 | : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2328 | bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); |
| 2329 | else |
| 2330 | bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); |
| 2331 | } |
| 2332 | } |
| 2333 | |
| 2334 | void |
| 2335 | bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2336 | { |
| 2337 | struct bgp_node *rn; |
| 2338 | struct bgp_table *table; |
| 2339 | |
| 2340 | if (peer->status != Established) |
| 2341 | return; |
| 2342 | |
| 2343 | if (! peer->afc_nego[afi][safi]) |
| 2344 | return; |
| 2345 | |
| 2346 | /* First update is deferred until ORF or ROUTE-REFRESH is received */ |
| 2347 | if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) |
| 2348 | return; |
| 2349 | |
| 2350 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2351 | bgp_announce_table (peer, afi, safi, NULL, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2352 | else |
| 2353 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2354 | rn = bgp_route_next(rn)) |
| 2355 | if ((table = (rn->info)) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2356 | bgp_announce_table (peer, afi, safi, table, 0); |
| 2357 | |
| 2358 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2359 | bgp_announce_table (peer, afi, safi, NULL, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2360 | } |
| 2361 | |
| 2362 | void |
| 2363 | bgp_announce_route_all (struct peer *peer) |
| 2364 | { |
| 2365 | afi_t afi; |
| 2366 | safi_t safi; |
| 2367 | |
| 2368 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2369 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2370 | bgp_announce_route (peer, afi, safi); |
| 2371 | } |
| 2372 | |
| 2373 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2374 | bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, |
| 2375 | safi_t safi, struct bgp_table *table) |
| 2376 | { |
| 2377 | struct bgp_node *rn; |
| 2378 | struct bgp_adj_in *ain; |
| 2379 | |
| 2380 | if (! table) |
| 2381 | table = rsclient->bgp->rib[afi][safi]; |
| 2382 | |
| 2383 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2384 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2385 | { |
| 2386 | bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer, |
| 2387 | &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 2388 | } |
| 2389 | } |
| 2390 | |
| 2391 | void |
| 2392 | bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 2393 | { |
| 2394 | struct bgp_table *table; |
| 2395 | struct bgp_node *rn; |
| 2396 | |
| 2397 | if (safi != SAFI_MPLS_VPN) |
| 2398 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL); |
| 2399 | |
| 2400 | else |
| 2401 | for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn; |
| 2402 | rn = bgp_route_next (rn)) |
| 2403 | if ((table = rn->info) != NULL) |
| 2404 | bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table); |
| 2405 | } |
| 2406 | |
| 2407 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2408 | bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, |
| 2409 | struct bgp_table *table) |
| 2410 | { |
| 2411 | int ret; |
| 2412 | struct bgp_node *rn; |
| 2413 | struct bgp_adj_in *ain; |
| 2414 | |
| 2415 | if (! table) |
| 2416 | table = peer->bgp->rib[afi][safi]; |
| 2417 | |
| 2418 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2419 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2420 | { |
| 2421 | if (ain->peer == peer) |
| 2422 | { |
| 2423 | ret = bgp_update (peer, &rn->p, ain->attr, afi, safi, |
| 2424 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, |
| 2425 | NULL, NULL, 1); |
| 2426 | if (ret < 0) |
| 2427 | { |
| 2428 | bgp_unlock_node (rn); |
| 2429 | return; |
| 2430 | } |
| 2431 | continue; |
| 2432 | } |
| 2433 | } |
| 2434 | } |
| 2435 | |
| 2436 | void |
| 2437 | bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2438 | { |
| 2439 | struct bgp_node *rn; |
| 2440 | struct bgp_table *table; |
| 2441 | |
| 2442 | if (peer->status != Established) |
| 2443 | return; |
| 2444 | |
| 2445 | if (safi != SAFI_MPLS_VPN) |
| 2446 | bgp_soft_reconfig_table (peer, afi, safi, NULL); |
| 2447 | else |
| 2448 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2449 | rn = bgp_route_next (rn)) |
| 2450 | if ((table = rn->info) != NULL) |
| 2451 | bgp_soft_reconfig_table (peer, afi, safi, table); |
| 2452 | } |
| 2453 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2454 | static wq_item_status |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2455 | bgp_clear_route_node (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2456 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2457 | struct bgp_node *rn = data; |
| 2458 | struct peer *peer = wq->spec.data; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2459 | struct bgp_adj_in *ain; |
| 2460 | struct bgp_adj_out *aout; |
| 2461 | struct bgp_info *ri; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2462 | afi_t afi = rn->table->afi; |
| 2463 | safi_t safi = rn->table->safi; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2464 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2465 | assert (rn && peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2466 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2467 | for (ri = rn->info; ri; ri = ri->next) |
| 2468 | if (ri->peer == peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2469 | { |
| 2470 | /* graceful restart STALE flag set. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2471 | if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT) |
| 2472 | && peer->nsf[afi][safi] |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2473 | && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE) |
| 2474 | && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY) |
paul | 902212c | 2006-02-05 17:51:19 +0000 | [diff] [blame] | 2475 | && ! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 2476 | && ! CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2477 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2478 | bgp_pcount_decrement (rn, ri, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2479 | SET_FLAG (ri->flags, BGP_INFO_STALE); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2480 | } |
| 2481 | else |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2482 | bgp_rib_remove (rn, ri, peer, afi, safi); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2483 | break; |
| 2484 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2485 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 2486 | if (ain->peer == peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2487 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2488 | bgp_adj_in_remove (rn, ain); |
| 2489 | bgp_unlock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2490 | break; |
| 2491 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2492 | for (aout = rn->adj_out; aout; aout = aout->next) |
| 2493 | if (aout->peer == peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2494 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2495 | bgp_adj_out_remove (rn, aout, peer, afi, safi); |
| 2496 | bgp_unlock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2497 | break; |
| 2498 | } |
| 2499 | return WQ_SUCCESS; |
| 2500 | } |
| 2501 | |
| 2502 | static void |
paul | 0fb58d5 | 2005-11-14 14:31:49 +0000 | [diff] [blame] | 2503 | bgp_clear_node_queue_del (struct work_queue *wq, void *data) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2504 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2505 | struct bgp_node *rn = data; |
| 2506 | |
| 2507 | bgp_unlock_node (rn); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2508 | } |
| 2509 | |
| 2510 | static void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2511 | bgp_clear_node_complete (struct work_queue *wq) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2512 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2513 | struct peer *peer = wq->spec.data; |
| 2514 | |
| 2515 | UNSET_FLAG (peer->sflags, PEER_STATUS_CLEARING); |
| 2516 | peer_unlock (peer); /* bgp_clear_node_complete */ |
Paul Jakma | 3e0c78e | 2006-03-06 18:06:53 +0000 | [diff] [blame] | 2517 | |
| 2518 | /* Tickle FSM to start moving again */ |
| 2519 | BGP_EVENT_ADD (peer, BGP_Start); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2520 | } |
| 2521 | |
| 2522 | static void |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2523 | bgp_clear_node_queue_init (struct peer *peer) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2524 | { |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2525 | #define CLEAR_QUEUE_NAME_LEN 26 /* "clear 2001:123:123:123::1" */ |
| 2526 | char wname[CLEAR_QUEUE_NAME_LEN]; |
| 2527 | |
| 2528 | snprintf (wname, CLEAR_QUEUE_NAME_LEN, "clear %s", peer->host); |
| 2529 | #undef CLEAR_QUEUE_NAME_LEN |
| 2530 | |
| 2531 | if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL) |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2532 | { |
| 2533 | zlog_err ("%s: Failed to allocate work queue", __func__); |
| 2534 | exit (1); |
| 2535 | } |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2536 | peer->clear_node_queue->spec.hold = 10; |
| 2537 | peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node; |
| 2538 | peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; |
| 2539 | peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; |
| 2540 | peer->clear_node_queue->spec.max_retries = 0; |
| 2541 | |
| 2542 | /* we only 'lock' this peer reference when the queue is actually active */ |
| 2543 | peer->clear_node_queue->spec.data = peer; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2544 | } |
| 2545 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2546 | static void |
| 2547 | bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2548 | struct bgp_table *table, struct peer *rsclient) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2549 | { |
| 2550 | struct bgp_node *rn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2551 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2552 | if (! table) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2553 | table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2554 | |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2555 | /* If still no table => afi/safi isn't configured at all or smth. */ |
| 2556 | if (! table) |
| 2557 | return; |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2558 | |
| 2559 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2560 | { |
| 2561 | if (rn->info == NULL) |
| 2562 | continue; |
| 2563 | |
| 2564 | bgp_lock_node (rn); /* unlocked: bgp_clear_node_queue_del */ |
| 2565 | work_queue_add (peer->clear_node_queue, rn); |
| 2566 | } |
| 2567 | return; |
| 2568 | } |
| 2569 | |
| 2570 | void |
| 2571 | bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2572 | { |
| 2573 | struct bgp_node *rn; |
| 2574 | struct bgp_table *table; |
| 2575 | struct peer *rsclient; |
| 2576 | struct listnode *node, *nnode; |
hasso | 6cf159b | 2005-03-21 10:28:14 +0000 | [diff] [blame] | 2577 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2578 | if (peer->clear_node_queue == NULL) |
| 2579 | bgp_clear_node_queue_init (peer); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2580 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2581 | /* bgp_fsm.c will not bring CLEARING sessions out of Idle this |
| 2582 | * protects against peers which flap faster than we can we clear, |
| 2583 | * which could lead to: |
| 2584 | * |
| 2585 | * a) race with routes from the new session being installed before |
| 2586 | * clear_route_node visits the node (to delete the route of that |
| 2587 | * peer) |
| 2588 | * b) resource exhaustion, clear_route_node likely leads to an entry |
| 2589 | * on the process_main queue. Fast-flapping could cause that queue |
| 2590 | * to grow and grow. |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2591 | */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 2592 | if (!CHECK_FLAG (peer->sflags, PEER_STATUS_CLEARING)) |
| 2593 | { |
| 2594 | SET_FLAG (peer->sflags, PEER_STATUS_CLEARING); |
| 2595 | peer_lock (peer); /* bgp_clear_node_complete */ |
| 2596 | } |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 2597 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2598 | if (safi != SAFI_MPLS_VPN) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2599 | bgp_clear_route_table (peer, afi, safi, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2600 | else |
| 2601 | for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; |
| 2602 | rn = bgp_route_next (rn)) |
| 2603 | if ((table = rn->info) != NULL) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2604 | bgp_clear_route_table (peer, afi, safi, table, NULL); |
| 2605 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2606 | for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2607 | { |
| 2608 | if (CHECK_FLAG(rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 2609 | bgp_clear_route_table (peer, afi, safi, NULL, rsclient); |
| 2610 | } |
Paul Jakma | 65ca75e | 2006-05-04 08:08:15 +0000 | [diff] [blame] | 2611 | |
| 2612 | /* If no routes were cleared, nothing was added to workqueue, run the |
| 2613 | * completion function now. |
| 2614 | */ |
| 2615 | if (!peer->clear_node_queue->thread) |
| 2616 | bgp_clear_node_complete (peer->clear_node_queue); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2617 | } |
| 2618 | |
| 2619 | void |
| 2620 | bgp_clear_route_all (struct peer *peer) |
| 2621 | { |
| 2622 | afi_t afi; |
| 2623 | safi_t safi; |
| 2624 | |
| 2625 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2626 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2627 | bgp_clear_route (peer, afi, safi); |
| 2628 | } |
| 2629 | |
| 2630 | void |
| 2631 | bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi) |
| 2632 | { |
| 2633 | struct bgp_table *table; |
| 2634 | struct bgp_node *rn; |
| 2635 | struct bgp_adj_in *ain; |
| 2636 | |
| 2637 | table = peer->bgp->rib[afi][safi]; |
| 2638 | |
| 2639 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2640 | for (ain = rn->adj_in; ain ; ain = ain->next) |
| 2641 | if (ain->peer == peer) |
| 2642 | { |
| 2643 | bgp_adj_in_remove (rn, ain); |
| 2644 | bgp_unlock_node (rn); |
| 2645 | break; |
| 2646 | } |
| 2647 | } |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 2648 | |
| 2649 | void |
| 2650 | bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) |
| 2651 | { |
| 2652 | struct bgp_node *rn; |
| 2653 | struct bgp_info *ri; |
| 2654 | struct bgp_table *table; |
| 2655 | |
| 2656 | table = peer->bgp->rib[afi][safi]; |
| 2657 | |
| 2658 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2659 | { |
| 2660 | for (ri = rn->info; ri; ri = ri->next) |
| 2661 | if (ri->peer == peer) |
| 2662 | { |
| 2663 | if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) |
| 2664 | bgp_rib_remove (rn, ri, peer, afi, safi); |
| 2665 | break; |
| 2666 | } |
| 2667 | } |
| 2668 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2669 | |
| 2670 | /* Delete all kernel routes. */ |
| 2671 | void |
paul | 545acaf | 2004-04-20 15:13:15 +0000 | [diff] [blame] | 2672 | bgp_cleanup_routes () |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2673 | { |
| 2674 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2675 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2676 | struct bgp_node *rn; |
| 2677 | struct bgp_table *table; |
| 2678 | struct bgp_info *ri; |
| 2679 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2680 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2681 | { |
| 2682 | table = bgp->rib[AFI_IP][SAFI_UNICAST]; |
| 2683 | |
| 2684 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2685 | for (ri = rn->info; ri; ri = ri->next) |
| 2686 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 2687 | && ri->type == ZEBRA_ROUTE_BGP |
| 2688 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 2689 | bgp_zebra_withdraw (&rn->p, ri); |
| 2690 | |
| 2691 | table = bgp->rib[AFI_IP6][SAFI_UNICAST]; |
| 2692 | |
| 2693 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 2694 | for (ri = rn->info; ri; ri = ri->next) |
| 2695 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) |
| 2696 | && ri->type == ZEBRA_ROUTE_BGP |
| 2697 | && ri->sub_type == BGP_ROUTE_NORMAL) |
| 2698 | bgp_zebra_withdraw (&rn->p, ri); |
| 2699 | } |
| 2700 | } |
| 2701 | |
| 2702 | void |
| 2703 | bgp_reset () |
| 2704 | { |
| 2705 | vty_reset (); |
| 2706 | bgp_zclient_reset (); |
| 2707 | access_list_reset (); |
| 2708 | prefix_list_reset (); |
| 2709 | } |
| 2710 | |
| 2711 | /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr |
| 2712 | value. */ |
| 2713 | int |
| 2714 | bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) |
| 2715 | { |
| 2716 | u_char *pnt; |
| 2717 | u_char *lim; |
| 2718 | struct prefix p; |
| 2719 | int psize; |
| 2720 | int ret; |
| 2721 | |
| 2722 | /* Check peer status. */ |
| 2723 | if (peer->status != Established) |
| 2724 | return 0; |
| 2725 | |
| 2726 | pnt = packet->nlri; |
| 2727 | lim = pnt + packet->length; |
| 2728 | |
| 2729 | for (; pnt < lim; pnt += psize) |
| 2730 | { |
| 2731 | /* Clear prefix structure. */ |
| 2732 | memset (&p, 0, sizeof (struct prefix)); |
| 2733 | |
| 2734 | /* Fetch prefix length. */ |
| 2735 | p.prefixlen = *pnt++; |
| 2736 | p.family = afi2family (packet->afi); |
| 2737 | |
| 2738 | /* Already checked in nlri_sanity_check(). We do double check |
| 2739 | here. */ |
| 2740 | if ((packet->afi == AFI_IP && p.prefixlen > 32) |
| 2741 | || (packet->afi == AFI_IP6 && p.prefixlen > 128)) |
| 2742 | return -1; |
| 2743 | |
| 2744 | /* Packet size overflow check. */ |
| 2745 | psize = PSIZE (p.prefixlen); |
| 2746 | |
| 2747 | /* When packet overflow occur return immediately. */ |
| 2748 | if (pnt + psize > lim) |
| 2749 | return -1; |
| 2750 | |
| 2751 | /* Fetch prefix from NLRI packet. */ |
| 2752 | memcpy (&p.u.prefix, pnt, psize); |
| 2753 | |
| 2754 | /* Check address. */ |
| 2755 | if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST) |
| 2756 | { |
| 2757 | if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) |
| 2758 | { |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 2759 | /* |
| 2760 | * From draft-ietf-idr-bgp4-22, Section 6.3: |
| 2761 | * If a BGP router receives an UPDATE message with a |
| 2762 | * semantically incorrect NLRI field, in which a prefix is |
| 2763 | * semantically incorrect (eg. an unexpected multicast IP |
| 2764 | * address), it should ignore the prefix. |
| 2765 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2766 | zlog (peer->log, LOG_ERR, |
| 2767 | "IPv4 unicast NLRI is multicast address %s", |
| 2768 | inet_ntoa (p.u.prefix4)); |
paul | f5ba387 | 2004-07-09 12:11:31 +0000 | [diff] [blame] | 2769 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2770 | return -1; |
| 2771 | } |
| 2772 | } |
| 2773 | |
| 2774 | #ifdef HAVE_IPV6 |
| 2775 | /* Check address. */ |
| 2776 | if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST) |
| 2777 | { |
| 2778 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 2779 | { |
| 2780 | char buf[BUFSIZ]; |
| 2781 | |
| 2782 | zlog (peer->log, LOG_WARNING, |
| 2783 | "IPv6 link-local NLRI received %s ignore this NLRI", |
| 2784 | inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); |
| 2785 | |
| 2786 | continue; |
| 2787 | } |
| 2788 | } |
| 2789 | #endif /* HAVE_IPV6 */ |
| 2790 | |
| 2791 | /* Normal process. */ |
| 2792 | if (attr) |
| 2793 | ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, |
| 2794 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); |
| 2795 | else |
| 2796 | ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, |
| 2797 | ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); |
| 2798 | |
| 2799 | /* Address family configuration mismatch or maximum-prefix count |
| 2800 | overflow. */ |
| 2801 | if (ret < 0) |
| 2802 | return -1; |
| 2803 | } |
| 2804 | |
| 2805 | /* Packet length consistency check. */ |
| 2806 | if (pnt != lim) |
| 2807 | return -1; |
| 2808 | |
| 2809 | return 0; |
| 2810 | } |
| 2811 | |
| 2812 | /* NLRI encode syntax check routine. */ |
| 2813 | int |
| 2814 | bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, |
| 2815 | bgp_size_t length) |
| 2816 | { |
| 2817 | u_char *end; |
| 2818 | u_char prefixlen; |
| 2819 | int psize; |
| 2820 | |
| 2821 | end = pnt + length; |
| 2822 | |
| 2823 | /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for |
| 2824 | syntactic validity. If the field is syntactically incorrect, |
| 2825 | then the Error Subcode is set to Invalid Network Field. */ |
| 2826 | |
| 2827 | while (pnt < end) |
| 2828 | { |
| 2829 | prefixlen = *pnt++; |
| 2830 | |
| 2831 | /* Prefix length check. */ |
| 2832 | if ((afi == AFI_IP && prefixlen > 32) |
| 2833 | || (afi == AFI_IP6 && prefixlen > 128)) |
| 2834 | { |
| 2835 | plog_err (peer->log, |
| 2836 | "%s [Error] Update packet error (wrong prefix length %d)", |
| 2837 | peer->host, prefixlen); |
| 2838 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2839 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2840 | return -1; |
| 2841 | } |
| 2842 | |
| 2843 | /* Packet size overflow check. */ |
| 2844 | psize = PSIZE (prefixlen); |
| 2845 | |
| 2846 | if (pnt + psize > end) |
| 2847 | { |
| 2848 | plog_err (peer->log, |
| 2849 | "%s [Error] Update packet error" |
| 2850 | " (prefix data overflow prefix size is %d)", |
| 2851 | peer->host, psize); |
| 2852 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2853 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2854 | return -1; |
| 2855 | } |
| 2856 | |
| 2857 | pnt += psize; |
| 2858 | } |
| 2859 | |
| 2860 | /* Packet length consistency check. */ |
| 2861 | if (pnt != end) |
| 2862 | { |
| 2863 | plog_err (peer->log, |
| 2864 | "%s [Error] Update packet error" |
| 2865 | " (prefix length mismatch with total length)", |
| 2866 | peer->host); |
| 2867 | bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, |
| 2868 | BGP_NOTIFY_UPDATE_INVAL_NETWORK); |
| 2869 | return -1; |
| 2870 | } |
| 2871 | return 0; |
| 2872 | } |
| 2873 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2874 | static struct bgp_static * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2875 | bgp_static_new () |
| 2876 | { |
| 2877 | struct bgp_static *new; |
| 2878 | new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); |
| 2879 | memset (new, 0, sizeof (struct bgp_static)); |
| 2880 | return new; |
| 2881 | } |
| 2882 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2883 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2884 | bgp_static_free (struct bgp_static *bgp_static) |
| 2885 | { |
| 2886 | if (bgp_static->rmap.name) |
| 2887 | free (bgp_static->rmap.name); |
| 2888 | XFREE (MTYPE_BGP_STATIC, bgp_static); |
| 2889 | } |
| 2890 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2891 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2892 | bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient, |
| 2893 | struct prefix *p, afi_t afi, safi_t safi) |
| 2894 | { |
| 2895 | struct bgp_node *rn; |
| 2896 | struct bgp_info *ri; |
| 2897 | |
| 2898 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 2899 | |
| 2900 | /* Check selected route and self inserted route. */ |
| 2901 | for (ri = rn->info; ri; ri = ri->next) |
| 2902 | if (ri->peer == bgp->peer_self |
| 2903 | && ri->type == ZEBRA_ROUTE_BGP |
| 2904 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 2905 | break; |
| 2906 | |
| 2907 | /* Withdraw static BGP route from routing table. */ |
| 2908 | if (ri) |
| 2909 | { |
| 2910 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 2911 | bgp_process (bgp, rn, afi, safi); |
| 2912 | bgp_info_delete (rn, ri); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2913 | } |
| 2914 | |
| 2915 | /* Unlock bgp_node_lookup. */ |
| 2916 | bgp_unlock_node (rn); |
| 2917 | } |
| 2918 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2919 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2920 | bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, |
| 2921 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 2922 | { |
| 2923 | struct bgp_node *rn; |
| 2924 | struct bgp_info *ri; |
| 2925 | struct bgp_info *new; |
| 2926 | struct bgp_info info; |
| 2927 | struct attr new_attr; |
| 2928 | struct attr *attr_new; |
| 2929 | struct attr attr; |
| 2930 | struct bgp *bgp; |
| 2931 | int ret; |
| 2932 | char buf[SU_ADDRSTRLEN]; |
| 2933 | |
| 2934 | bgp = rsclient->bgp; |
| 2935 | |
| 2936 | rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL); |
| 2937 | |
| 2938 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 2939 | if (bgp_static) |
| 2940 | { |
| 2941 | attr.nexthop = bgp_static->igpnexthop; |
| 2942 | attr.med = bgp_static->igpmetric; |
| 2943 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 2944 | } |
| 2945 | |
| 2946 | new_attr = attr; |
| 2947 | |
| 2948 | /* Apply network route-map for export to this rsclient. */ |
| 2949 | if (bgp_static->rmap.name) |
| 2950 | { |
| 2951 | info.peer = rsclient; |
| 2952 | info.attr = &new_attr; |
| 2953 | |
| 2954 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); |
| 2955 | SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 2956 | |
| 2957 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
| 2958 | |
| 2959 | rsclient->rmap_type = 0; |
| 2960 | |
| 2961 | if (ret == RMAP_DENYMATCH) |
| 2962 | { |
| 2963 | /* Free uninterned attribute. */ |
| 2964 | bgp_attr_flush (&new_attr); |
| 2965 | |
| 2966 | /* Unintern original. */ |
| 2967 | aspath_unintern (attr.aspath); |
| 2968 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 2969 | |
| 2970 | return; |
| 2971 | } |
| 2972 | attr_new = bgp_attr_intern (&new_attr); |
| 2973 | } |
| 2974 | else |
| 2975 | attr_new = bgp_attr_intern (&attr); |
| 2976 | |
| 2977 | new_attr = *attr_new; |
| 2978 | |
| 2979 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 2980 | |
| 2981 | if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) == RMAP_DENY) |
| 2982 | { |
| 2983 | /* This BGP update is filtered. Log the reason then update BGP entry. */ |
| 2984 | if (BGP_DEBUG (update, UPDATE_IN)) |
ajs | d2c1f16 | 2004-12-08 21:10:20 +0000 | [diff] [blame] | 2985 | zlog (rsclient->log, LOG_DEBUG, |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2986 | "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy", |
| 2987 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 2988 | p->prefixlen, rsclient->host); |
| 2989 | |
| 2990 | bgp->peer_self->rmap_type = 0; |
| 2991 | |
| 2992 | bgp_attr_unintern (attr_new); |
| 2993 | aspath_unintern (attr.aspath); |
| 2994 | |
| 2995 | bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); |
| 2996 | |
| 2997 | return; |
| 2998 | } |
| 2999 | |
| 3000 | bgp->peer_self->rmap_type = 0; |
| 3001 | |
| 3002 | bgp_attr_unintern (attr_new); |
| 3003 | attr_new = bgp_attr_intern (&new_attr); |
| 3004 | |
| 3005 | for (ri = rn->info; ri; ri = ri->next) |
| 3006 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3007 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3008 | break; |
| 3009 | |
| 3010 | if (ri) |
| 3011 | { |
| 3012 | if (attrhash_cmp (ri->attr, attr_new)) |
| 3013 | { |
| 3014 | bgp_unlock_node (rn); |
| 3015 | bgp_attr_unintern (attr_new); |
| 3016 | aspath_unintern (attr.aspath); |
| 3017 | return; |
| 3018 | } |
| 3019 | else |
| 3020 | { |
| 3021 | /* The attribute is changed. */ |
| 3022 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 3023 | |
| 3024 | /* Rewrite BGP route information. */ |
| 3025 | bgp_attr_unintern (ri->attr); |
| 3026 | ri->attr = attr_new; |
| 3027 | ri->uptime = time (NULL); |
| 3028 | |
| 3029 | /* Process change. */ |
| 3030 | bgp_process (bgp, rn, afi, safi); |
| 3031 | bgp_unlock_node (rn); |
| 3032 | aspath_unintern (attr.aspath); |
| 3033 | return; |
| 3034 | } |
| 3035 | } |
| 3036 | |
| 3037 | /* Make new BGP info. */ |
| 3038 | new = bgp_info_new (); |
| 3039 | new->type = ZEBRA_ROUTE_BGP; |
| 3040 | new->sub_type = BGP_ROUTE_STATIC; |
| 3041 | new->peer = bgp->peer_self; |
| 3042 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3043 | new->attr = attr_new; |
| 3044 | new->uptime = time (NULL); |
| 3045 | |
| 3046 | /* Register new BGP information. */ |
| 3047 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3048 | |
| 3049 | /* route_node_get lock */ |
| 3050 | bgp_unlock_node (rn); |
| 3051 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3052 | /* Process change. */ |
| 3053 | bgp_process (bgp, rn, afi, safi); |
| 3054 | |
| 3055 | /* Unintern original. */ |
| 3056 | aspath_unintern (attr.aspath); |
| 3057 | } |
| 3058 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3059 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3060 | bgp_static_update_main (struct bgp *bgp, struct prefix *p, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3061 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3062 | { |
| 3063 | struct bgp_node *rn; |
| 3064 | struct bgp_info *ri; |
| 3065 | struct bgp_info *new; |
| 3066 | struct bgp_info info; |
| 3067 | struct attr attr; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3068 | struct attr attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3069 | struct attr *attr_new; |
| 3070 | int ret; |
| 3071 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3072 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3073 | |
| 3074 | bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); |
| 3075 | if (bgp_static) |
| 3076 | { |
| 3077 | attr.nexthop = bgp_static->igpnexthop; |
| 3078 | attr.med = bgp_static->igpmetric; |
| 3079 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 3080 | } |
| 3081 | |
| 3082 | /* Apply route-map. */ |
| 3083 | if (bgp_static->rmap.name) |
| 3084 | { |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3085 | attr_tmp = attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3086 | info.peer = bgp->peer_self; |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3087 | info.attr = &attr_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3088 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3089 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); |
| 3090 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3091 | ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3092 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3093 | bgp->peer_self->rmap_type = 0; |
| 3094 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3095 | if (ret == RMAP_DENYMATCH) |
| 3096 | { |
| 3097 | /* Free uninterned attribute. */ |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3098 | bgp_attr_flush (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3099 | |
| 3100 | /* Unintern original. */ |
| 3101 | aspath_unintern (attr.aspath); |
| 3102 | bgp_static_withdraw (bgp, p, afi, safi); |
| 3103 | return; |
| 3104 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3105 | attr_new = bgp_attr_intern (&attr_tmp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3106 | } |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 3107 | else |
| 3108 | attr_new = bgp_attr_intern (&attr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3109 | |
| 3110 | for (ri = rn->info; ri; ri = ri->next) |
| 3111 | if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP |
| 3112 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3113 | break; |
| 3114 | |
| 3115 | if (ri) |
| 3116 | { |
| 3117 | if (attrhash_cmp (ri->attr, attr_new)) |
| 3118 | { |
| 3119 | bgp_unlock_node (rn); |
| 3120 | bgp_attr_unintern (attr_new); |
| 3121 | aspath_unintern (attr.aspath); |
| 3122 | return; |
| 3123 | } |
| 3124 | else |
| 3125 | { |
| 3126 | /* The attribute is changed. */ |
| 3127 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 3128 | |
| 3129 | /* Rewrite BGP route information. */ |
| 3130 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 3131 | bgp_attr_unintern (ri->attr); |
| 3132 | ri->attr = attr_new; |
| 3133 | ri->uptime = time (NULL); |
| 3134 | |
| 3135 | /* Process change. */ |
| 3136 | bgp_aggregate_increment (bgp, p, ri, afi, safi); |
| 3137 | bgp_process (bgp, rn, afi, safi); |
| 3138 | bgp_unlock_node (rn); |
| 3139 | aspath_unintern (attr.aspath); |
| 3140 | return; |
| 3141 | } |
| 3142 | } |
| 3143 | |
| 3144 | /* Make new BGP info. */ |
| 3145 | new = bgp_info_new (); |
| 3146 | new->type = ZEBRA_ROUTE_BGP; |
| 3147 | new->sub_type = BGP_ROUTE_STATIC; |
| 3148 | new->peer = bgp->peer_self; |
| 3149 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3150 | new->attr = attr_new; |
| 3151 | new->uptime = time (NULL); |
| 3152 | |
| 3153 | /* Aggregate address increment. */ |
| 3154 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
| 3155 | |
| 3156 | /* Register new BGP information. */ |
| 3157 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3158 | |
| 3159 | /* route_node_get lock */ |
| 3160 | bgp_unlock_node (rn); |
| 3161 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3162 | /* Process change. */ |
| 3163 | bgp_process (bgp, rn, afi, safi); |
| 3164 | |
| 3165 | /* Unintern original. */ |
| 3166 | aspath_unintern (attr.aspath); |
| 3167 | } |
| 3168 | |
| 3169 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3170 | bgp_static_update (struct bgp *bgp, struct prefix *p, |
| 3171 | struct bgp_static *bgp_static, afi_t afi, safi_t safi) |
| 3172 | { |
| 3173 | struct peer *rsclient; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3174 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3175 | |
| 3176 | bgp_static_update_main (bgp, p, bgp_static, afi, safi); |
| 3177 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3178 | for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3179 | { |
| 3180 | bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi); |
| 3181 | } |
| 3182 | } |
| 3183 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3184 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3185 | bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 3186 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 3187 | { |
| 3188 | struct bgp_node *rn; |
| 3189 | struct bgp_info *new; |
| 3190 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3191 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3192 | |
| 3193 | /* Make new BGP info. */ |
| 3194 | new = bgp_info_new (); |
| 3195 | new->type = ZEBRA_ROUTE_BGP; |
| 3196 | new->sub_type = BGP_ROUTE_STATIC; |
| 3197 | new->peer = bgp->peer_self; |
| 3198 | new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP); |
| 3199 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 3200 | new->uptime = time (NULL); |
| 3201 | memcpy (new->tag, tag, 3); |
| 3202 | |
| 3203 | /* Aggregate address increment. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3204 | bgp_aggregate_increment (bgp, p, new, afi, safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3205 | |
| 3206 | /* Register new BGP information. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3207 | bgp_info_add (rn, new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3208 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 3209 | /* route_node_get lock */ |
| 3210 | bgp_unlock_node (rn); |
| 3211 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3212 | /* Process change. */ |
| 3213 | bgp_process (bgp, rn, afi, safi); |
| 3214 | } |
| 3215 | |
| 3216 | void |
| 3217 | bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 3218 | safi_t safi) |
| 3219 | { |
| 3220 | struct bgp_node *rn; |
| 3221 | struct bgp_info *ri; |
| 3222 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3223 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3224 | |
| 3225 | /* Check selected route and self inserted route. */ |
| 3226 | for (ri = rn->info; ri; ri = ri->next) |
| 3227 | if (ri->peer == bgp->peer_self |
| 3228 | && ri->type == ZEBRA_ROUTE_BGP |
| 3229 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3230 | break; |
| 3231 | |
| 3232 | /* Withdraw static BGP route from routing table. */ |
| 3233 | if (ri) |
| 3234 | { |
| 3235 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 3236 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 3237 | bgp_process (bgp, rn, afi, safi); |
| 3238 | bgp_info_delete (rn, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3239 | } |
| 3240 | |
| 3241 | /* Unlock bgp_node_lookup. */ |
| 3242 | bgp_unlock_node (rn); |
| 3243 | } |
| 3244 | |
| 3245 | void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3246 | bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) |
| 3247 | { |
| 3248 | struct bgp_static *bgp_static; |
| 3249 | struct bgp *bgp; |
| 3250 | struct bgp_node *rn; |
| 3251 | struct prefix *p; |
| 3252 | |
| 3253 | bgp = rsclient->bgp; |
| 3254 | |
| 3255 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3256 | if ((bgp_static = rn->info) != NULL) |
| 3257 | { |
| 3258 | p = &rn->p; |
| 3259 | |
| 3260 | bgp_static_update_rsclient (rsclient, p, bgp_static, |
| 3261 | afi, safi); |
| 3262 | } |
| 3263 | } |
| 3264 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3265 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3266 | bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, |
| 3267 | u_char safi, struct prefix_rd *prd, u_char *tag) |
| 3268 | { |
| 3269 | struct bgp_node *rn; |
| 3270 | struct bgp_info *ri; |
| 3271 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3272 | rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3273 | |
| 3274 | /* Check selected route and self inserted route. */ |
| 3275 | for (ri = rn->info; ri; ri = ri->next) |
| 3276 | if (ri->peer == bgp->peer_self |
| 3277 | && ri->type == ZEBRA_ROUTE_BGP |
| 3278 | && ri->sub_type == BGP_ROUTE_STATIC) |
| 3279 | break; |
| 3280 | |
| 3281 | /* Withdraw static BGP route from routing table. */ |
| 3282 | if (ri) |
| 3283 | { |
| 3284 | bgp_aggregate_decrement (bgp, p, ri, afi, safi); |
| 3285 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 3286 | bgp_process (bgp, rn, afi, safi); |
| 3287 | bgp_info_delete (rn, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3288 | } |
| 3289 | |
| 3290 | /* Unlock bgp_node_lookup. */ |
| 3291 | bgp_unlock_node (rn); |
| 3292 | } |
| 3293 | |
| 3294 | /* Configure static BGP network. When user don't run zebra, static |
| 3295 | route should be installed as valid. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3296 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3297 | bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, |
| 3298 | u_int16_t afi, u_char safi, const char *rmap, int backdoor) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3299 | { |
| 3300 | int ret; |
| 3301 | struct prefix p; |
| 3302 | struct bgp_static *bgp_static; |
| 3303 | struct bgp_node *rn; |
| 3304 | int need_update = 0; |
| 3305 | |
| 3306 | /* Convert IP prefix string to struct prefix. */ |
| 3307 | ret = str2prefix (ip_str, &p); |
| 3308 | if (! ret) |
| 3309 | { |
| 3310 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3311 | return CMD_WARNING; |
| 3312 | } |
| 3313 | #ifdef HAVE_IPV6 |
| 3314 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3315 | { |
| 3316 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3317 | VTY_NEWLINE); |
| 3318 | return CMD_WARNING; |
| 3319 | } |
| 3320 | #endif /* HAVE_IPV6 */ |
| 3321 | |
| 3322 | apply_mask (&p); |
| 3323 | |
| 3324 | /* Set BGP static route configuration. */ |
| 3325 | rn = bgp_node_get (bgp->route[afi][safi], &p); |
| 3326 | |
| 3327 | if (rn->info) |
| 3328 | { |
| 3329 | /* Configuration change. */ |
| 3330 | bgp_static = rn->info; |
| 3331 | |
| 3332 | /* Check previous routes are installed into BGP. */ |
| 3333 | if (! bgp_static->backdoor && bgp_static->valid) |
| 3334 | need_update = 1; |
| 3335 | |
| 3336 | bgp_static->backdoor = backdoor; |
| 3337 | if (rmap) |
| 3338 | { |
| 3339 | if (bgp_static->rmap.name) |
| 3340 | free (bgp_static->rmap.name); |
| 3341 | bgp_static->rmap.name = strdup (rmap); |
| 3342 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3343 | } |
| 3344 | else |
| 3345 | { |
| 3346 | if (bgp_static->rmap.name) |
| 3347 | free (bgp_static->rmap.name); |
| 3348 | bgp_static->rmap.name = NULL; |
| 3349 | bgp_static->rmap.map = NULL; |
| 3350 | bgp_static->valid = 0; |
| 3351 | } |
| 3352 | bgp_unlock_node (rn); |
| 3353 | } |
| 3354 | else |
| 3355 | { |
| 3356 | /* New configuration. */ |
| 3357 | bgp_static = bgp_static_new (); |
| 3358 | bgp_static->backdoor = backdoor; |
| 3359 | bgp_static->valid = 0; |
| 3360 | bgp_static->igpmetric = 0; |
| 3361 | bgp_static->igpnexthop.s_addr = 0; |
| 3362 | if (rmap) |
| 3363 | { |
| 3364 | if (bgp_static->rmap.name) |
| 3365 | free (bgp_static->rmap.name); |
| 3366 | bgp_static->rmap.name = strdup (rmap); |
| 3367 | bgp_static->rmap.map = route_map_lookup_by_name (rmap); |
| 3368 | } |
| 3369 | rn->info = bgp_static; |
| 3370 | } |
| 3371 | |
| 3372 | /* If BGP scan is not enabled, we should install this route here. */ |
| 3373 | if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) |
| 3374 | { |
| 3375 | bgp_static->valid = 1; |
| 3376 | |
| 3377 | if (need_update) |
| 3378 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3379 | |
| 3380 | if (! bgp_static->backdoor) |
| 3381 | bgp_static_update (bgp, &p, bgp_static, afi, safi); |
| 3382 | } |
| 3383 | |
| 3384 | return CMD_SUCCESS; |
| 3385 | } |
| 3386 | |
| 3387 | /* Configure static BGP network. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3388 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3389 | bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3390 | u_int16_t afi, u_char safi) |
| 3391 | { |
| 3392 | int ret; |
| 3393 | struct prefix p; |
| 3394 | struct bgp_static *bgp_static; |
| 3395 | struct bgp_node *rn; |
| 3396 | |
| 3397 | /* Convert IP prefix string to struct prefix. */ |
| 3398 | ret = str2prefix (ip_str, &p); |
| 3399 | if (! ret) |
| 3400 | { |
| 3401 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3402 | return CMD_WARNING; |
| 3403 | } |
| 3404 | #ifdef HAVE_IPV6 |
| 3405 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) |
| 3406 | { |
| 3407 | vty_out (vty, "%% Malformed prefix (link-local address)%s", |
| 3408 | VTY_NEWLINE); |
| 3409 | return CMD_WARNING; |
| 3410 | } |
| 3411 | #endif /* HAVE_IPV6 */ |
| 3412 | |
| 3413 | apply_mask (&p); |
| 3414 | |
| 3415 | rn = bgp_node_lookup (bgp->route[afi][safi], &p); |
| 3416 | if (! rn) |
| 3417 | { |
| 3418 | vty_out (vty, "%% Can't find specified static route configuration.%s", |
| 3419 | VTY_NEWLINE); |
| 3420 | return CMD_WARNING; |
| 3421 | } |
| 3422 | |
| 3423 | bgp_static = rn->info; |
| 3424 | |
| 3425 | /* Update BGP RIB. */ |
| 3426 | if (! bgp_static->backdoor) |
| 3427 | bgp_static_withdraw (bgp, &p, afi, safi); |
| 3428 | |
| 3429 | /* Clear configuration. */ |
| 3430 | bgp_static_free (bgp_static); |
| 3431 | rn->info = NULL; |
| 3432 | bgp_unlock_node (rn); |
| 3433 | bgp_unlock_node (rn); |
| 3434 | |
| 3435 | return CMD_SUCCESS; |
| 3436 | } |
| 3437 | |
| 3438 | /* Called from bgp_delete(). Delete all static routes from the BGP |
| 3439 | instance. */ |
| 3440 | void |
| 3441 | bgp_static_delete (struct bgp *bgp) |
| 3442 | { |
| 3443 | afi_t afi; |
| 3444 | safi_t safi; |
| 3445 | struct bgp_node *rn; |
| 3446 | struct bgp_node *rm; |
| 3447 | struct bgp_table *table; |
| 3448 | struct bgp_static *bgp_static; |
| 3449 | |
| 3450 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 3451 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 3452 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 3453 | if (rn->info != NULL) |
| 3454 | { |
| 3455 | if (safi == SAFI_MPLS_VPN) |
| 3456 | { |
| 3457 | table = rn->info; |
| 3458 | |
| 3459 | for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) |
| 3460 | { |
| 3461 | bgp_static = rn->info; |
| 3462 | bgp_static_withdraw_vpnv4 (bgp, &rm->p, |
| 3463 | AFI_IP, SAFI_MPLS_VPN, |
| 3464 | (struct prefix_rd *)&rn->p, |
| 3465 | bgp_static->tag); |
| 3466 | bgp_static_free (bgp_static); |
| 3467 | rn->info = NULL; |
| 3468 | bgp_unlock_node (rn); |
| 3469 | } |
| 3470 | } |
| 3471 | else |
| 3472 | { |
| 3473 | bgp_static = rn->info; |
| 3474 | bgp_static_withdraw (bgp, &rn->p, afi, safi); |
| 3475 | bgp_static_free (bgp_static); |
| 3476 | rn->info = NULL; |
| 3477 | bgp_unlock_node (rn); |
| 3478 | } |
| 3479 | } |
| 3480 | } |
| 3481 | |
| 3482 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3483 | bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, |
| 3484 | const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3485 | { |
| 3486 | int ret; |
| 3487 | struct prefix p; |
| 3488 | struct prefix_rd prd; |
| 3489 | struct bgp *bgp; |
| 3490 | struct bgp_node *prn; |
| 3491 | struct bgp_node *rn; |
| 3492 | struct bgp_table *table; |
| 3493 | struct bgp_static *bgp_static; |
| 3494 | u_char tag[3]; |
| 3495 | |
| 3496 | bgp = vty->index; |
| 3497 | |
| 3498 | ret = str2prefix (ip_str, &p); |
| 3499 | if (! ret) |
| 3500 | { |
| 3501 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3502 | return CMD_WARNING; |
| 3503 | } |
| 3504 | apply_mask (&p); |
| 3505 | |
| 3506 | ret = str2prefix_rd (rd_str, &prd); |
| 3507 | if (! ret) |
| 3508 | { |
| 3509 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3510 | return CMD_WARNING; |
| 3511 | } |
| 3512 | |
| 3513 | ret = str2tag (tag_str, tag); |
| 3514 | if (! ret) |
| 3515 | { |
| 3516 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3517 | return CMD_WARNING; |
| 3518 | } |
| 3519 | |
| 3520 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3521 | (struct prefix *)&prd); |
| 3522 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3523 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3524 | else |
| 3525 | bgp_unlock_node (prn); |
| 3526 | table = prn->info; |
| 3527 | |
| 3528 | rn = bgp_node_get (table, &p); |
| 3529 | |
| 3530 | if (rn->info) |
| 3531 | { |
| 3532 | vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE); |
| 3533 | bgp_unlock_node (rn); |
| 3534 | } |
| 3535 | else |
| 3536 | { |
| 3537 | /* New configuration. */ |
| 3538 | bgp_static = bgp_static_new (); |
| 3539 | bgp_static->valid = 1; |
| 3540 | memcpy (bgp_static->tag, tag, 3); |
| 3541 | rn->info = bgp_static; |
| 3542 | |
| 3543 | bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3544 | } |
| 3545 | |
| 3546 | return CMD_SUCCESS; |
| 3547 | } |
| 3548 | |
| 3549 | /* Configure static BGP network. */ |
| 3550 | int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3551 | bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, |
| 3552 | const char *rd_str, const char *tag_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3553 | { |
| 3554 | int ret; |
| 3555 | struct bgp *bgp; |
| 3556 | struct prefix p; |
| 3557 | struct prefix_rd prd; |
| 3558 | struct bgp_node *prn; |
| 3559 | struct bgp_node *rn; |
| 3560 | struct bgp_table *table; |
| 3561 | struct bgp_static *bgp_static; |
| 3562 | u_char tag[3]; |
| 3563 | |
| 3564 | bgp = vty->index; |
| 3565 | |
| 3566 | /* Convert IP prefix string to struct prefix. */ |
| 3567 | ret = str2prefix (ip_str, &p); |
| 3568 | if (! ret) |
| 3569 | { |
| 3570 | vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); |
| 3571 | return CMD_WARNING; |
| 3572 | } |
| 3573 | apply_mask (&p); |
| 3574 | |
| 3575 | ret = str2prefix_rd (rd_str, &prd); |
| 3576 | if (! ret) |
| 3577 | { |
| 3578 | vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE); |
| 3579 | return CMD_WARNING; |
| 3580 | } |
| 3581 | |
| 3582 | ret = str2tag (tag_str, tag); |
| 3583 | if (! ret) |
| 3584 | { |
| 3585 | vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); |
| 3586 | return CMD_WARNING; |
| 3587 | } |
| 3588 | |
| 3589 | prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN], |
| 3590 | (struct prefix *)&prd); |
| 3591 | if (prn->info == NULL) |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 3592 | prn->info = bgp_table_init (AFI_IP, SAFI_MPLS_VPN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3593 | else |
| 3594 | bgp_unlock_node (prn); |
| 3595 | table = prn->info; |
| 3596 | |
| 3597 | rn = bgp_node_lookup (table, &p); |
| 3598 | |
| 3599 | if (rn) |
| 3600 | { |
| 3601 | bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag); |
| 3602 | |
| 3603 | bgp_static = rn->info; |
| 3604 | bgp_static_free (bgp_static); |
| 3605 | rn->info = NULL; |
| 3606 | bgp_unlock_node (rn); |
| 3607 | bgp_unlock_node (rn); |
| 3608 | } |
| 3609 | else |
| 3610 | vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE); |
| 3611 | |
| 3612 | return CMD_SUCCESS; |
| 3613 | } |
| 3614 | |
| 3615 | DEFUN (bgp_network, |
| 3616 | bgp_network_cmd, |
| 3617 | "network A.B.C.D/M", |
| 3618 | "Specify a network to announce via BGP\n" |
| 3619 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3620 | { |
| 3621 | return bgp_static_set (vty, vty->index, argv[0], |
| 3622 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3623 | } |
| 3624 | |
| 3625 | DEFUN (bgp_network_route_map, |
| 3626 | bgp_network_route_map_cmd, |
| 3627 | "network A.B.C.D/M route-map WORD", |
| 3628 | "Specify a network to announce via BGP\n" |
| 3629 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3630 | "Route-map to modify the attributes\n" |
| 3631 | "Name of the route map\n") |
| 3632 | { |
| 3633 | return bgp_static_set (vty, vty->index, argv[0], |
| 3634 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 3635 | } |
| 3636 | |
| 3637 | DEFUN (bgp_network_backdoor, |
| 3638 | bgp_network_backdoor_cmd, |
| 3639 | "network A.B.C.D/M backdoor", |
| 3640 | "Specify a network to announce via BGP\n" |
| 3641 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3642 | "Specify a BGP backdoor route\n") |
| 3643 | { |
| 3644 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3645 | } |
| 3646 | |
| 3647 | DEFUN (bgp_network_mask, |
| 3648 | bgp_network_mask_cmd, |
| 3649 | "network A.B.C.D mask A.B.C.D", |
| 3650 | "Specify a network to announce via BGP\n" |
| 3651 | "Network number\n" |
| 3652 | "Network mask\n" |
| 3653 | "Network mask\n") |
| 3654 | { |
| 3655 | int ret; |
| 3656 | char prefix_str[BUFSIZ]; |
| 3657 | |
| 3658 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3659 | if (! ret) |
| 3660 | { |
| 3661 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3662 | return CMD_WARNING; |
| 3663 | } |
| 3664 | |
| 3665 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3666 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3667 | } |
| 3668 | |
| 3669 | DEFUN (bgp_network_mask_route_map, |
| 3670 | bgp_network_mask_route_map_cmd, |
| 3671 | "network A.B.C.D mask A.B.C.D route-map WORD", |
| 3672 | "Specify a network to announce via BGP\n" |
| 3673 | "Network number\n" |
| 3674 | "Network mask\n" |
| 3675 | "Network mask\n" |
| 3676 | "Route-map to modify the attributes\n" |
| 3677 | "Name of the route map\n") |
| 3678 | { |
| 3679 | int ret; |
| 3680 | char prefix_str[BUFSIZ]; |
| 3681 | |
| 3682 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3683 | if (! ret) |
| 3684 | { |
| 3685 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3686 | return CMD_WARNING; |
| 3687 | } |
| 3688 | |
| 3689 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3690 | AFI_IP, bgp_node_safi (vty), argv[2], 0); |
| 3691 | } |
| 3692 | |
| 3693 | DEFUN (bgp_network_mask_backdoor, |
| 3694 | bgp_network_mask_backdoor_cmd, |
| 3695 | "network A.B.C.D mask A.B.C.D backdoor", |
| 3696 | "Specify a network to announce via BGP\n" |
| 3697 | "Network number\n" |
| 3698 | "Network mask\n" |
| 3699 | "Network mask\n" |
| 3700 | "Specify a BGP backdoor route\n") |
| 3701 | { |
| 3702 | int ret; |
| 3703 | char prefix_str[BUFSIZ]; |
| 3704 | |
| 3705 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3706 | if (! ret) |
| 3707 | { |
| 3708 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3709 | return CMD_WARNING; |
| 3710 | } |
| 3711 | |
| 3712 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3713 | } |
| 3714 | |
| 3715 | DEFUN (bgp_network_mask_natural, |
| 3716 | bgp_network_mask_natural_cmd, |
| 3717 | "network A.B.C.D", |
| 3718 | "Specify a network to announce via BGP\n" |
| 3719 | "Network number\n") |
| 3720 | { |
| 3721 | int ret; |
| 3722 | char prefix_str[BUFSIZ]; |
| 3723 | |
| 3724 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3725 | if (! ret) |
| 3726 | { |
| 3727 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3728 | return CMD_WARNING; |
| 3729 | } |
| 3730 | |
| 3731 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3732 | AFI_IP, bgp_node_safi (vty), NULL, 0); |
| 3733 | } |
| 3734 | |
| 3735 | DEFUN (bgp_network_mask_natural_route_map, |
| 3736 | bgp_network_mask_natural_route_map_cmd, |
| 3737 | "network A.B.C.D route-map WORD", |
| 3738 | "Specify a network to announce via BGP\n" |
| 3739 | "Network number\n" |
| 3740 | "Route-map to modify the attributes\n" |
| 3741 | "Name of the route map\n") |
| 3742 | { |
| 3743 | int ret; |
| 3744 | char prefix_str[BUFSIZ]; |
| 3745 | |
| 3746 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3747 | if (! ret) |
| 3748 | { |
| 3749 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3750 | return CMD_WARNING; |
| 3751 | } |
| 3752 | |
| 3753 | return bgp_static_set (vty, vty->index, prefix_str, |
| 3754 | AFI_IP, bgp_node_safi (vty), argv[1], 0); |
| 3755 | } |
| 3756 | |
| 3757 | DEFUN (bgp_network_mask_natural_backdoor, |
| 3758 | bgp_network_mask_natural_backdoor_cmd, |
| 3759 | "network A.B.C.D backdoor", |
| 3760 | "Specify a network to announce via BGP\n" |
| 3761 | "Network number\n" |
| 3762 | "Specify a BGP backdoor route\n") |
| 3763 | { |
| 3764 | int ret; |
| 3765 | char prefix_str[BUFSIZ]; |
| 3766 | |
| 3767 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3768 | if (! ret) |
| 3769 | { |
| 3770 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3771 | return CMD_WARNING; |
| 3772 | } |
| 3773 | |
| 3774 | return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1); |
| 3775 | } |
| 3776 | |
| 3777 | DEFUN (no_bgp_network, |
| 3778 | no_bgp_network_cmd, |
| 3779 | "no network A.B.C.D/M", |
| 3780 | NO_STR |
| 3781 | "Specify a network to announce via BGP\n" |
| 3782 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 3783 | { |
| 3784 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, |
| 3785 | bgp_node_safi (vty)); |
| 3786 | } |
| 3787 | |
| 3788 | ALIAS (no_bgp_network, |
| 3789 | no_bgp_network_route_map_cmd, |
| 3790 | "no network A.B.C.D/M route-map WORD", |
| 3791 | NO_STR |
| 3792 | "Specify a network to announce via BGP\n" |
| 3793 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3794 | "Route-map to modify the attributes\n" |
| 3795 | "Name of the route map\n") |
| 3796 | |
| 3797 | ALIAS (no_bgp_network, |
| 3798 | no_bgp_network_backdoor_cmd, |
| 3799 | "no network A.B.C.D/M backdoor", |
| 3800 | NO_STR |
| 3801 | "Specify a network to announce via BGP\n" |
| 3802 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 3803 | "Specify a BGP backdoor route\n") |
| 3804 | |
| 3805 | DEFUN (no_bgp_network_mask, |
| 3806 | no_bgp_network_mask_cmd, |
| 3807 | "no network A.B.C.D mask A.B.C.D", |
| 3808 | NO_STR |
| 3809 | "Specify a network to announce via BGP\n" |
| 3810 | "Network number\n" |
| 3811 | "Network mask\n" |
| 3812 | "Network mask\n") |
| 3813 | { |
| 3814 | int ret; |
| 3815 | char prefix_str[BUFSIZ]; |
| 3816 | |
| 3817 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 3818 | if (! ret) |
| 3819 | { |
| 3820 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3821 | return CMD_WARNING; |
| 3822 | } |
| 3823 | |
| 3824 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 3825 | bgp_node_safi (vty)); |
| 3826 | } |
| 3827 | |
| 3828 | ALIAS (no_bgp_network_mask, |
| 3829 | no_bgp_network_mask_route_map_cmd, |
| 3830 | "no network A.B.C.D mask A.B.C.D route-map WORD", |
| 3831 | NO_STR |
| 3832 | "Specify a network to announce via BGP\n" |
| 3833 | "Network number\n" |
| 3834 | "Network mask\n" |
| 3835 | "Network mask\n" |
| 3836 | "Route-map to modify the attributes\n" |
| 3837 | "Name of the route map\n") |
| 3838 | |
| 3839 | ALIAS (no_bgp_network_mask, |
| 3840 | no_bgp_network_mask_backdoor_cmd, |
| 3841 | "no network A.B.C.D mask A.B.C.D backdoor", |
| 3842 | NO_STR |
| 3843 | "Specify a network to announce via BGP\n" |
| 3844 | "Network number\n" |
| 3845 | "Network mask\n" |
| 3846 | "Network mask\n" |
| 3847 | "Specify a BGP backdoor route\n") |
| 3848 | |
| 3849 | DEFUN (no_bgp_network_mask_natural, |
| 3850 | no_bgp_network_mask_natural_cmd, |
| 3851 | "no network A.B.C.D", |
| 3852 | NO_STR |
| 3853 | "Specify a network to announce via BGP\n" |
| 3854 | "Network number\n") |
| 3855 | { |
| 3856 | int ret; |
| 3857 | char prefix_str[BUFSIZ]; |
| 3858 | |
| 3859 | ret = netmask_str2prefix_str (argv[0], NULL, prefix_str); |
| 3860 | if (! ret) |
| 3861 | { |
| 3862 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 3863 | return CMD_WARNING; |
| 3864 | } |
| 3865 | |
| 3866 | return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, |
| 3867 | bgp_node_safi (vty)); |
| 3868 | } |
| 3869 | |
| 3870 | ALIAS (no_bgp_network_mask_natural, |
| 3871 | no_bgp_network_mask_natural_route_map_cmd, |
| 3872 | "no network A.B.C.D route-map WORD", |
| 3873 | NO_STR |
| 3874 | "Specify a network to announce via BGP\n" |
| 3875 | "Network number\n" |
| 3876 | "Route-map to modify the attributes\n" |
| 3877 | "Name of the route map\n") |
| 3878 | |
| 3879 | ALIAS (no_bgp_network_mask_natural, |
| 3880 | no_bgp_network_mask_natural_backdoor_cmd, |
| 3881 | "no network A.B.C.D backdoor", |
| 3882 | NO_STR |
| 3883 | "Specify a network to announce via BGP\n" |
| 3884 | "Network number\n" |
| 3885 | "Specify a BGP backdoor route\n") |
| 3886 | |
| 3887 | #ifdef HAVE_IPV6 |
| 3888 | DEFUN (ipv6_bgp_network, |
| 3889 | ipv6_bgp_network_cmd, |
| 3890 | "network X:X::X:X/M", |
| 3891 | "Specify a network to announce via BGP\n" |
| 3892 | "IPv6 prefix <network>/<length>\n") |
| 3893 | { |
| 3894 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 3895 | } |
| 3896 | |
| 3897 | DEFUN (ipv6_bgp_network_route_map, |
| 3898 | ipv6_bgp_network_route_map_cmd, |
| 3899 | "network X:X::X:X/M route-map WORD", |
| 3900 | "Specify a network to announce via BGP\n" |
| 3901 | "IPv6 prefix <network>/<length>\n" |
| 3902 | "Route-map to modify the attributes\n" |
| 3903 | "Name of the route map\n") |
| 3904 | { |
| 3905 | return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, |
| 3906 | bgp_node_safi (vty), argv[1], 0); |
| 3907 | } |
| 3908 | |
| 3909 | DEFUN (no_ipv6_bgp_network, |
| 3910 | no_ipv6_bgp_network_cmd, |
| 3911 | "no network X:X::X:X/M", |
| 3912 | NO_STR |
| 3913 | "Specify a network to announce via BGP\n" |
| 3914 | "IPv6 prefix <network>/<length>\n") |
| 3915 | { |
| 3916 | return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST); |
| 3917 | } |
| 3918 | |
| 3919 | ALIAS (no_ipv6_bgp_network, |
| 3920 | no_ipv6_bgp_network_route_map_cmd, |
| 3921 | "no network X:X::X:X/M route-map WORD", |
| 3922 | NO_STR |
| 3923 | "Specify a network to announce via BGP\n" |
| 3924 | "IPv6 prefix <network>/<length>\n" |
| 3925 | "Route-map to modify the attributes\n" |
| 3926 | "Name of the route map\n") |
| 3927 | |
| 3928 | ALIAS (ipv6_bgp_network, |
| 3929 | old_ipv6_bgp_network_cmd, |
| 3930 | "ipv6 bgp network X:X::X:X/M", |
| 3931 | IPV6_STR |
| 3932 | BGP_STR |
| 3933 | "Specify a network to announce via BGP\n" |
| 3934 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 3935 | |
| 3936 | ALIAS (no_ipv6_bgp_network, |
| 3937 | old_no_ipv6_bgp_network_cmd, |
| 3938 | "no ipv6 bgp network X:X::X:X/M", |
| 3939 | NO_STR |
| 3940 | IPV6_STR |
| 3941 | BGP_STR |
| 3942 | "Specify a network to announce via BGP\n" |
| 3943 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 3944 | #endif /* HAVE_IPV6 */ |
| 3945 | |
| 3946 | /* Aggreagete address: |
| 3947 | |
| 3948 | advertise-map Set condition to advertise attribute |
| 3949 | as-set Generate AS set path information |
| 3950 | attribute-map Set attributes of aggregate |
| 3951 | route-map Set parameters of aggregate |
| 3952 | summary-only Filter more specific routes from updates |
| 3953 | suppress-map Conditionally filter more specific routes from updates |
| 3954 | <cr> |
| 3955 | */ |
| 3956 | struct bgp_aggregate |
| 3957 | { |
| 3958 | /* Summary-only flag. */ |
| 3959 | u_char summary_only; |
| 3960 | |
| 3961 | /* AS set generation. */ |
| 3962 | u_char as_set; |
| 3963 | |
| 3964 | /* Route-map for aggregated route. */ |
| 3965 | struct route_map *map; |
| 3966 | |
| 3967 | /* Suppress-count. */ |
| 3968 | unsigned long count; |
| 3969 | |
| 3970 | /* SAFI configuration. */ |
| 3971 | safi_t safi; |
| 3972 | }; |
| 3973 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3974 | static struct bgp_aggregate * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3975 | bgp_aggregate_new () |
| 3976 | { |
| 3977 | struct bgp_aggregate *new; |
| 3978 | new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); |
| 3979 | memset (new, 0, sizeof (struct bgp_aggregate)); |
| 3980 | return new; |
| 3981 | } |
| 3982 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3983 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3984 | bgp_aggregate_free (struct bgp_aggregate *aggregate) |
| 3985 | { |
| 3986 | XFREE (MTYPE_BGP_AGGREGATE, aggregate); |
| 3987 | } |
| 3988 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3989 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3990 | bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, |
| 3991 | afi_t afi, safi_t safi, struct bgp_info *del, |
| 3992 | struct bgp_aggregate *aggregate) |
| 3993 | { |
| 3994 | struct bgp_table *table; |
| 3995 | struct bgp_node *top; |
| 3996 | struct bgp_node *rn; |
| 3997 | u_char origin; |
| 3998 | struct aspath *aspath = NULL; |
| 3999 | struct aspath *asmerge = NULL; |
| 4000 | struct community *community = NULL; |
| 4001 | struct community *commerge = NULL; |
| 4002 | struct in_addr nexthop; |
| 4003 | u_int32_t med = 0; |
| 4004 | struct bgp_info *ri; |
| 4005 | struct bgp_info *new; |
| 4006 | int first = 1; |
| 4007 | unsigned long match = 0; |
| 4008 | |
| 4009 | /* Record adding route's nexthop and med. */ |
| 4010 | if (rinew) |
| 4011 | { |
| 4012 | nexthop = rinew->attr->nexthop; |
| 4013 | med = rinew->attr->med; |
| 4014 | } |
| 4015 | |
| 4016 | /* ORIGIN attribute: If at least one route among routes that are |
| 4017 | aggregated has ORIGIN with the value INCOMPLETE, then the |
| 4018 | aggregated route must have the ORIGIN attribute with the value |
| 4019 | INCOMPLETE. Otherwise, if at least one route among routes that |
| 4020 | are aggregated has ORIGIN with the value EGP, then the aggregated |
| 4021 | route must have the origin attribute with the value EGP. In all |
| 4022 | other case the value of the ORIGIN attribute of the aggregated |
| 4023 | route is INTERNAL. */ |
| 4024 | origin = BGP_ORIGIN_IGP; |
| 4025 | |
| 4026 | table = bgp->rib[afi][safi]; |
| 4027 | |
| 4028 | top = bgp_node_get (table, p); |
| 4029 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4030 | if (rn->p.prefixlen > p->prefixlen) |
| 4031 | { |
| 4032 | match = 0; |
| 4033 | |
| 4034 | for (ri = rn->info; ri; ri = ri->next) |
| 4035 | { |
| 4036 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4037 | continue; |
| 4038 | |
| 4039 | if (del && ri == del) |
| 4040 | continue; |
| 4041 | |
| 4042 | if (! rinew && first) |
| 4043 | { |
| 4044 | nexthop = ri->attr->nexthop; |
| 4045 | med = ri->attr->med; |
| 4046 | first = 0; |
| 4047 | } |
| 4048 | |
| 4049 | #ifdef AGGREGATE_NEXTHOP_CHECK |
| 4050 | if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) |
| 4051 | || ri->attr->med != med) |
| 4052 | { |
| 4053 | if (aspath) |
| 4054 | aspath_free (aspath); |
| 4055 | if (community) |
| 4056 | community_free (community); |
| 4057 | bgp_unlock_node (rn); |
| 4058 | bgp_unlock_node (top); |
| 4059 | return; |
| 4060 | } |
| 4061 | #endif /* AGGREGATE_NEXTHOP_CHECK */ |
| 4062 | |
| 4063 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4064 | { |
| 4065 | if (aggregate->summary_only) |
| 4066 | { |
| 4067 | ri->suppress++; |
| 4068 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 4069 | match++; |
| 4070 | } |
| 4071 | |
| 4072 | aggregate->count++; |
| 4073 | |
| 4074 | if (aggregate->as_set) |
| 4075 | { |
| 4076 | if (origin < ri->attr->origin) |
| 4077 | origin = ri->attr->origin; |
| 4078 | |
| 4079 | if (aspath) |
| 4080 | { |
| 4081 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4082 | aspath_free (aspath); |
| 4083 | aspath = asmerge; |
| 4084 | } |
| 4085 | else |
| 4086 | aspath = aspath_dup (ri->attr->aspath); |
| 4087 | |
| 4088 | if (ri->attr->community) |
| 4089 | { |
| 4090 | if (community) |
| 4091 | { |
| 4092 | commerge = community_merge (community, |
| 4093 | ri->attr->community); |
| 4094 | community = community_uniq_sort (commerge); |
| 4095 | community_free (commerge); |
| 4096 | } |
| 4097 | else |
| 4098 | community = community_dup (ri->attr->community); |
| 4099 | } |
| 4100 | } |
| 4101 | } |
| 4102 | } |
| 4103 | if (match) |
| 4104 | bgp_process (bgp, rn, afi, safi); |
| 4105 | } |
| 4106 | bgp_unlock_node (top); |
| 4107 | |
| 4108 | if (rinew) |
| 4109 | { |
| 4110 | aggregate->count++; |
| 4111 | |
| 4112 | if (aggregate->summary_only) |
| 4113 | rinew->suppress++; |
| 4114 | |
| 4115 | if (aggregate->as_set) |
| 4116 | { |
| 4117 | if (origin < rinew->attr->origin) |
| 4118 | origin = rinew->attr->origin; |
| 4119 | |
| 4120 | if (aspath) |
| 4121 | { |
| 4122 | asmerge = aspath_aggregate (aspath, rinew->attr->aspath); |
| 4123 | aspath_free (aspath); |
| 4124 | aspath = asmerge; |
| 4125 | } |
| 4126 | else |
| 4127 | aspath = aspath_dup (rinew->attr->aspath); |
| 4128 | |
| 4129 | if (rinew->attr->community) |
| 4130 | { |
| 4131 | if (community) |
| 4132 | { |
| 4133 | commerge = community_merge (community, |
| 4134 | rinew->attr->community); |
| 4135 | community = community_uniq_sort (commerge); |
| 4136 | community_free (commerge); |
| 4137 | } |
| 4138 | else |
| 4139 | community = community_dup (rinew->attr->community); |
| 4140 | } |
| 4141 | } |
| 4142 | } |
| 4143 | |
| 4144 | if (aggregate->count > 0) |
| 4145 | { |
| 4146 | rn = bgp_node_get (table, p); |
| 4147 | new = bgp_info_new (); |
| 4148 | new->type = ZEBRA_ROUTE_BGP; |
| 4149 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4150 | new->peer = bgp->peer_self; |
| 4151 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4152 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 4153 | new->uptime = time (NULL); |
| 4154 | |
| 4155 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4156 | bgp_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4157 | bgp_process (bgp, rn, afi, safi); |
| 4158 | } |
| 4159 | else |
| 4160 | { |
| 4161 | if (aspath) |
| 4162 | aspath_free (aspath); |
| 4163 | if (community) |
| 4164 | community_free (community); |
| 4165 | } |
| 4166 | } |
| 4167 | |
| 4168 | void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t, |
| 4169 | struct bgp_aggregate *); |
| 4170 | |
| 4171 | void |
| 4172 | bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, |
| 4173 | struct bgp_info *ri, afi_t afi, safi_t safi) |
| 4174 | { |
| 4175 | struct bgp_node *child; |
| 4176 | struct bgp_node *rn; |
| 4177 | struct bgp_aggregate *aggregate; |
| 4178 | |
| 4179 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4180 | if (safi == SAFI_MPLS_VPN) |
| 4181 | return; |
| 4182 | |
| 4183 | if (p->prefixlen == 0) |
| 4184 | return; |
| 4185 | |
| 4186 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4187 | return; |
| 4188 | |
| 4189 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 4190 | |
| 4191 | /* Aggregate address configuration check. */ |
| 4192 | for (rn = child; rn; rn = rn->parent) |
| 4193 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4194 | { |
| 4195 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4196 | bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4197 | } |
| 4198 | bgp_unlock_node (child); |
| 4199 | } |
| 4200 | |
| 4201 | void |
| 4202 | bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, |
| 4203 | struct bgp_info *del, afi_t afi, safi_t safi) |
| 4204 | { |
| 4205 | struct bgp_node *child; |
| 4206 | struct bgp_node *rn; |
| 4207 | struct bgp_aggregate *aggregate; |
| 4208 | |
| 4209 | /* MPLS-VPN aggregation is not yet supported. */ |
| 4210 | if (safi == SAFI_MPLS_VPN) |
| 4211 | return; |
| 4212 | |
| 4213 | if (p->prefixlen == 0) |
| 4214 | return; |
| 4215 | |
| 4216 | child = bgp_node_get (bgp->aggregate[afi][safi], p); |
| 4217 | |
| 4218 | /* Aggregate address configuration check. */ |
| 4219 | for (rn = child; rn; rn = rn->parent) |
| 4220 | if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen) |
| 4221 | { |
| 4222 | bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate); |
paul | 286e1e7 | 2003-08-08 00:24:31 +0000 | [diff] [blame] | 4223 | bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4224 | } |
| 4225 | bgp_unlock_node (child); |
| 4226 | } |
| 4227 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4228 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4229 | bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, |
| 4230 | struct bgp_aggregate *aggregate) |
| 4231 | { |
| 4232 | struct bgp_table *table; |
| 4233 | struct bgp_node *top; |
| 4234 | struct bgp_node *rn; |
| 4235 | struct bgp_info *new; |
| 4236 | struct bgp_info *ri; |
| 4237 | unsigned long match; |
| 4238 | u_char origin = BGP_ORIGIN_IGP; |
| 4239 | struct aspath *aspath = NULL; |
| 4240 | struct aspath *asmerge = NULL; |
| 4241 | struct community *community = NULL; |
| 4242 | struct community *commerge = NULL; |
| 4243 | |
| 4244 | table = bgp->rib[afi][safi]; |
| 4245 | |
| 4246 | /* Sanity check. */ |
| 4247 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4248 | return; |
| 4249 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4250 | return; |
| 4251 | |
| 4252 | /* If routes exists below this node, generate aggregate routes. */ |
| 4253 | top = bgp_node_get (table, p); |
| 4254 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4255 | if (rn->p.prefixlen > p->prefixlen) |
| 4256 | { |
| 4257 | match = 0; |
| 4258 | |
| 4259 | for (ri = rn->info; ri; ri = ri->next) |
| 4260 | { |
| 4261 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4262 | continue; |
| 4263 | |
| 4264 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4265 | { |
| 4266 | /* summary-only aggregate route suppress aggregated |
| 4267 | route announcement. */ |
| 4268 | if (aggregate->summary_only) |
| 4269 | { |
| 4270 | ri->suppress++; |
| 4271 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 4272 | match++; |
| 4273 | } |
| 4274 | /* as-set aggregate route generate origin, as path, |
| 4275 | community aggregation. */ |
| 4276 | if (aggregate->as_set) |
| 4277 | { |
| 4278 | if (origin < ri->attr->origin) |
| 4279 | origin = ri->attr->origin; |
| 4280 | |
| 4281 | if (aspath) |
| 4282 | { |
| 4283 | asmerge = aspath_aggregate (aspath, ri->attr->aspath); |
| 4284 | aspath_free (aspath); |
| 4285 | aspath = asmerge; |
| 4286 | } |
| 4287 | else |
| 4288 | aspath = aspath_dup (ri->attr->aspath); |
| 4289 | |
| 4290 | if (ri->attr->community) |
| 4291 | { |
| 4292 | if (community) |
| 4293 | { |
| 4294 | commerge = community_merge (community, |
| 4295 | ri->attr->community); |
| 4296 | community = community_uniq_sort (commerge); |
| 4297 | community_free (commerge); |
| 4298 | } |
| 4299 | else |
| 4300 | community = community_dup (ri->attr->community); |
| 4301 | } |
| 4302 | } |
| 4303 | aggregate->count++; |
| 4304 | } |
| 4305 | } |
| 4306 | |
| 4307 | /* If this node is suppressed, process the change. */ |
| 4308 | if (match) |
| 4309 | bgp_process (bgp, rn, afi, safi); |
| 4310 | } |
| 4311 | bgp_unlock_node (top); |
| 4312 | |
| 4313 | /* Add aggregate route to BGP table. */ |
| 4314 | if (aggregate->count) |
| 4315 | { |
| 4316 | rn = bgp_node_get (table, p); |
| 4317 | |
| 4318 | new = bgp_info_new (); |
| 4319 | new->type = ZEBRA_ROUTE_BGP; |
| 4320 | new->sub_type = BGP_ROUTE_AGGREGATE; |
| 4321 | new->peer = bgp->peer_self; |
| 4322 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4323 | new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set); |
| 4324 | new->uptime = time (NULL); |
| 4325 | |
| 4326 | bgp_info_add (rn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4327 | bgp_unlock_node (rn); |
| 4328 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4329 | /* Process change. */ |
| 4330 | bgp_process (bgp, rn, afi, safi); |
| 4331 | } |
| 4332 | } |
| 4333 | |
| 4334 | void |
| 4335 | bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, |
| 4336 | safi_t safi, struct bgp_aggregate *aggregate) |
| 4337 | { |
| 4338 | struct bgp_table *table; |
| 4339 | struct bgp_node *top; |
| 4340 | struct bgp_node *rn; |
| 4341 | struct bgp_info *ri; |
| 4342 | unsigned long match; |
| 4343 | |
| 4344 | table = bgp->rib[afi][safi]; |
| 4345 | |
| 4346 | if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN) |
| 4347 | return; |
| 4348 | if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) |
| 4349 | return; |
| 4350 | |
| 4351 | /* If routes exists below this node, generate aggregate routes. */ |
| 4352 | top = bgp_node_get (table, p); |
| 4353 | for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) |
| 4354 | if (rn->p.prefixlen > p->prefixlen) |
| 4355 | { |
| 4356 | match = 0; |
| 4357 | |
| 4358 | for (ri = rn->info; ri; ri = ri->next) |
| 4359 | { |
| 4360 | if (BGP_INFO_HOLDDOWN (ri)) |
| 4361 | continue; |
| 4362 | |
| 4363 | if (ri->sub_type != BGP_ROUTE_AGGREGATE) |
| 4364 | { |
| 4365 | if (aggregate->summary_only) |
| 4366 | { |
| 4367 | ri->suppress--; |
| 4368 | |
| 4369 | if (ri->suppress == 0) |
| 4370 | { |
| 4371 | SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED); |
| 4372 | match++; |
| 4373 | } |
| 4374 | } |
| 4375 | aggregate->count--; |
| 4376 | } |
| 4377 | } |
| 4378 | |
| 4379 | /* If this node is suppressed, process the change. */ |
| 4380 | if (match) |
| 4381 | bgp_process (bgp, rn, afi, safi); |
| 4382 | } |
| 4383 | bgp_unlock_node (top); |
| 4384 | |
| 4385 | /* Delete aggregate route from BGP table. */ |
| 4386 | rn = bgp_node_get (table, p); |
| 4387 | |
| 4388 | for (ri = rn->info; ri; ri = ri->next) |
| 4389 | if (ri->peer == bgp->peer_self |
| 4390 | && ri->type == ZEBRA_ROUTE_BGP |
| 4391 | && ri->sub_type == BGP_ROUTE_AGGREGATE) |
| 4392 | break; |
| 4393 | |
| 4394 | /* Withdraw static BGP route from routing table. */ |
| 4395 | if (ri) |
| 4396 | { |
| 4397 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 4398 | bgp_process (bgp, rn, afi, safi); |
| 4399 | bgp_info_delete (rn, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4400 | } |
| 4401 | |
| 4402 | /* Unlock bgp_node_lookup. */ |
| 4403 | bgp_unlock_node (rn); |
| 4404 | } |
| 4405 | |
| 4406 | /* Aggregate route attribute. */ |
| 4407 | #define AGGREGATE_SUMMARY_ONLY 1 |
| 4408 | #define AGGREGATE_AS_SET 1 |
| 4409 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4410 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4411 | bgp_aggregate_set (struct vty *vty, const char *prefix_str, |
| 4412 | afi_t afi, safi_t safi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4413 | u_char summary_only, u_char as_set) |
| 4414 | { |
| 4415 | int ret; |
| 4416 | struct prefix p; |
| 4417 | struct bgp_node *rn; |
| 4418 | struct bgp *bgp; |
| 4419 | struct bgp_aggregate *aggregate; |
| 4420 | |
| 4421 | /* Convert string to prefix structure. */ |
| 4422 | ret = str2prefix (prefix_str, &p); |
| 4423 | if (!ret) |
| 4424 | { |
| 4425 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4426 | return CMD_WARNING; |
| 4427 | } |
| 4428 | apply_mask (&p); |
| 4429 | |
| 4430 | /* Get BGP structure. */ |
| 4431 | bgp = vty->index; |
| 4432 | |
| 4433 | /* Old configuration check. */ |
| 4434 | rn = bgp_node_get (bgp->aggregate[afi][safi], &p); |
| 4435 | |
| 4436 | if (rn->info) |
| 4437 | { |
| 4438 | vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE); |
| 4439 | bgp_unlock_node (rn); |
| 4440 | return CMD_WARNING; |
| 4441 | } |
| 4442 | |
| 4443 | /* Make aggregate address structure. */ |
| 4444 | aggregate = bgp_aggregate_new (); |
| 4445 | aggregate->summary_only = summary_only; |
| 4446 | aggregate->as_set = as_set; |
| 4447 | aggregate->safi = safi; |
| 4448 | rn->info = aggregate; |
| 4449 | |
| 4450 | /* Aggregate address insert into BGP routing table. */ |
| 4451 | if (safi & SAFI_UNICAST) |
| 4452 | bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4453 | if (safi & SAFI_MULTICAST) |
| 4454 | bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4455 | |
| 4456 | return CMD_SUCCESS; |
| 4457 | } |
| 4458 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 4459 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 4460 | bgp_aggregate_unset (struct vty *vty, const char *prefix_str, |
| 4461 | afi_t afi, safi_t safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4462 | { |
| 4463 | int ret; |
| 4464 | struct prefix p; |
| 4465 | struct bgp_node *rn; |
| 4466 | struct bgp *bgp; |
| 4467 | struct bgp_aggregate *aggregate; |
| 4468 | |
| 4469 | /* Convert string to prefix structure. */ |
| 4470 | ret = str2prefix (prefix_str, &p); |
| 4471 | if (!ret) |
| 4472 | { |
| 4473 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 4474 | return CMD_WARNING; |
| 4475 | } |
| 4476 | apply_mask (&p); |
| 4477 | |
| 4478 | /* Get BGP structure. */ |
| 4479 | bgp = vty->index; |
| 4480 | |
| 4481 | /* Old configuration check. */ |
| 4482 | rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p); |
| 4483 | if (! rn) |
| 4484 | { |
| 4485 | vty_out (vty, "%% There is no aggregate-address configuration.%s", |
| 4486 | VTY_NEWLINE); |
| 4487 | return CMD_WARNING; |
| 4488 | } |
| 4489 | |
| 4490 | aggregate = rn->info; |
| 4491 | if (aggregate->safi & SAFI_UNICAST) |
| 4492 | bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate); |
| 4493 | if (aggregate->safi & SAFI_MULTICAST) |
| 4494 | bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate); |
| 4495 | |
| 4496 | /* Unlock aggregate address configuration. */ |
| 4497 | rn->info = NULL; |
| 4498 | bgp_aggregate_free (aggregate); |
| 4499 | bgp_unlock_node (rn); |
| 4500 | bgp_unlock_node (rn); |
| 4501 | |
| 4502 | return CMD_SUCCESS; |
| 4503 | } |
| 4504 | |
| 4505 | DEFUN (aggregate_address, |
| 4506 | aggregate_address_cmd, |
| 4507 | "aggregate-address A.B.C.D/M", |
| 4508 | "Configure BGP aggregate entries\n" |
| 4509 | "Aggregate prefix\n") |
| 4510 | { |
| 4511 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0); |
| 4512 | } |
| 4513 | |
| 4514 | DEFUN (aggregate_address_mask, |
| 4515 | aggregate_address_mask_cmd, |
| 4516 | "aggregate-address A.B.C.D A.B.C.D", |
| 4517 | "Configure BGP aggregate entries\n" |
| 4518 | "Aggregate address\n" |
| 4519 | "Aggregate mask\n") |
| 4520 | { |
| 4521 | int ret; |
| 4522 | char prefix_str[BUFSIZ]; |
| 4523 | |
| 4524 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4525 | |
| 4526 | if (! ret) |
| 4527 | { |
| 4528 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4529 | return CMD_WARNING; |
| 4530 | } |
| 4531 | |
| 4532 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4533 | 0, 0); |
| 4534 | } |
| 4535 | |
| 4536 | DEFUN (aggregate_address_summary_only, |
| 4537 | aggregate_address_summary_only_cmd, |
| 4538 | "aggregate-address A.B.C.D/M summary-only", |
| 4539 | "Configure BGP aggregate entries\n" |
| 4540 | "Aggregate prefix\n" |
| 4541 | "Filter more specific routes from updates\n") |
| 4542 | { |
| 4543 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4544 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4545 | } |
| 4546 | |
| 4547 | DEFUN (aggregate_address_mask_summary_only, |
| 4548 | aggregate_address_mask_summary_only_cmd, |
| 4549 | "aggregate-address A.B.C.D A.B.C.D summary-only", |
| 4550 | "Configure BGP aggregate entries\n" |
| 4551 | "Aggregate address\n" |
| 4552 | "Aggregate mask\n" |
| 4553 | "Filter more specific routes from updates\n") |
| 4554 | { |
| 4555 | int ret; |
| 4556 | char prefix_str[BUFSIZ]; |
| 4557 | |
| 4558 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4559 | |
| 4560 | if (! ret) |
| 4561 | { |
| 4562 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4563 | return CMD_WARNING; |
| 4564 | } |
| 4565 | |
| 4566 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4567 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4568 | } |
| 4569 | |
| 4570 | DEFUN (aggregate_address_as_set, |
| 4571 | aggregate_address_as_set_cmd, |
| 4572 | "aggregate-address A.B.C.D/M as-set", |
| 4573 | "Configure BGP aggregate entries\n" |
| 4574 | "Aggregate prefix\n" |
| 4575 | "Generate AS set path information\n") |
| 4576 | { |
| 4577 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4578 | 0, AGGREGATE_AS_SET); |
| 4579 | } |
| 4580 | |
| 4581 | DEFUN (aggregate_address_mask_as_set, |
| 4582 | aggregate_address_mask_as_set_cmd, |
| 4583 | "aggregate-address A.B.C.D A.B.C.D as-set", |
| 4584 | "Configure BGP aggregate entries\n" |
| 4585 | "Aggregate address\n" |
| 4586 | "Aggregate mask\n" |
| 4587 | "Generate AS set path information\n") |
| 4588 | { |
| 4589 | int ret; |
| 4590 | char prefix_str[BUFSIZ]; |
| 4591 | |
| 4592 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4593 | |
| 4594 | if (! ret) |
| 4595 | { |
| 4596 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4597 | return CMD_WARNING; |
| 4598 | } |
| 4599 | |
| 4600 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4601 | 0, AGGREGATE_AS_SET); |
| 4602 | } |
| 4603 | |
| 4604 | |
| 4605 | DEFUN (aggregate_address_as_set_summary, |
| 4606 | aggregate_address_as_set_summary_cmd, |
| 4607 | "aggregate-address A.B.C.D/M as-set summary-only", |
| 4608 | "Configure BGP aggregate entries\n" |
| 4609 | "Aggregate prefix\n" |
| 4610 | "Generate AS set path information\n" |
| 4611 | "Filter more specific routes from updates\n") |
| 4612 | { |
| 4613 | return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), |
| 4614 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 4615 | } |
| 4616 | |
| 4617 | ALIAS (aggregate_address_as_set_summary, |
| 4618 | aggregate_address_summary_as_set_cmd, |
| 4619 | "aggregate-address A.B.C.D/M summary-only as-set", |
| 4620 | "Configure BGP aggregate entries\n" |
| 4621 | "Aggregate prefix\n" |
| 4622 | "Filter more specific routes from updates\n" |
| 4623 | "Generate AS set path information\n") |
| 4624 | |
| 4625 | DEFUN (aggregate_address_mask_as_set_summary, |
| 4626 | aggregate_address_mask_as_set_summary_cmd, |
| 4627 | "aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 4628 | "Configure BGP aggregate entries\n" |
| 4629 | "Aggregate address\n" |
| 4630 | "Aggregate mask\n" |
| 4631 | "Generate AS set path information\n" |
| 4632 | "Filter more specific routes from updates\n") |
| 4633 | { |
| 4634 | int ret; |
| 4635 | char prefix_str[BUFSIZ]; |
| 4636 | |
| 4637 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4638 | |
| 4639 | if (! ret) |
| 4640 | { |
| 4641 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4642 | return CMD_WARNING; |
| 4643 | } |
| 4644 | |
| 4645 | return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty), |
| 4646 | AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); |
| 4647 | } |
| 4648 | |
| 4649 | ALIAS (aggregate_address_mask_as_set_summary, |
| 4650 | aggregate_address_mask_summary_as_set_cmd, |
| 4651 | "aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 4652 | "Configure BGP aggregate entries\n" |
| 4653 | "Aggregate address\n" |
| 4654 | "Aggregate mask\n" |
| 4655 | "Filter more specific routes from updates\n" |
| 4656 | "Generate AS set path information\n") |
| 4657 | |
| 4658 | DEFUN (no_aggregate_address, |
| 4659 | no_aggregate_address_cmd, |
| 4660 | "no aggregate-address A.B.C.D/M", |
| 4661 | NO_STR |
| 4662 | "Configure BGP aggregate entries\n" |
| 4663 | "Aggregate prefix\n") |
| 4664 | { |
| 4665 | return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty)); |
| 4666 | } |
| 4667 | |
| 4668 | ALIAS (no_aggregate_address, |
| 4669 | no_aggregate_address_summary_only_cmd, |
| 4670 | "no aggregate-address A.B.C.D/M summary-only", |
| 4671 | NO_STR |
| 4672 | "Configure BGP aggregate entries\n" |
| 4673 | "Aggregate prefix\n" |
| 4674 | "Filter more specific routes from updates\n") |
| 4675 | |
| 4676 | ALIAS (no_aggregate_address, |
| 4677 | no_aggregate_address_as_set_cmd, |
| 4678 | "no aggregate-address A.B.C.D/M as-set", |
| 4679 | NO_STR |
| 4680 | "Configure BGP aggregate entries\n" |
| 4681 | "Aggregate prefix\n" |
| 4682 | "Generate AS set path information\n") |
| 4683 | |
| 4684 | ALIAS (no_aggregate_address, |
| 4685 | no_aggregate_address_as_set_summary_cmd, |
| 4686 | "no aggregate-address A.B.C.D/M as-set summary-only", |
| 4687 | NO_STR |
| 4688 | "Configure BGP aggregate entries\n" |
| 4689 | "Aggregate prefix\n" |
| 4690 | "Generate AS set path information\n" |
| 4691 | "Filter more specific routes from updates\n") |
| 4692 | |
| 4693 | ALIAS (no_aggregate_address, |
| 4694 | no_aggregate_address_summary_as_set_cmd, |
| 4695 | "no aggregate-address A.B.C.D/M summary-only as-set", |
| 4696 | NO_STR |
| 4697 | "Configure BGP aggregate entries\n" |
| 4698 | "Aggregate prefix\n" |
| 4699 | "Filter more specific routes from updates\n" |
| 4700 | "Generate AS set path information\n") |
| 4701 | |
| 4702 | DEFUN (no_aggregate_address_mask, |
| 4703 | no_aggregate_address_mask_cmd, |
| 4704 | "no aggregate-address A.B.C.D A.B.C.D", |
| 4705 | NO_STR |
| 4706 | "Configure BGP aggregate entries\n" |
| 4707 | "Aggregate address\n" |
| 4708 | "Aggregate mask\n") |
| 4709 | { |
| 4710 | int ret; |
| 4711 | char prefix_str[BUFSIZ]; |
| 4712 | |
| 4713 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 4714 | |
| 4715 | if (! ret) |
| 4716 | { |
| 4717 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 4718 | return CMD_WARNING; |
| 4719 | } |
| 4720 | |
| 4721 | return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); |
| 4722 | } |
| 4723 | |
| 4724 | ALIAS (no_aggregate_address_mask, |
| 4725 | no_aggregate_address_mask_summary_only_cmd, |
| 4726 | "no aggregate-address A.B.C.D A.B.C.D summary-only", |
| 4727 | NO_STR |
| 4728 | "Configure BGP aggregate entries\n" |
| 4729 | "Aggregate address\n" |
| 4730 | "Aggregate mask\n" |
| 4731 | "Filter more specific routes from updates\n") |
| 4732 | |
| 4733 | ALIAS (no_aggregate_address_mask, |
| 4734 | no_aggregate_address_mask_as_set_cmd, |
| 4735 | "no aggregate-address A.B.C.D A.B.C.D as-set", |
| 4736 | NO_STR |
| 4737 | "Configure BGP aggregate entries\n" |
| 4738 | "Aggregate address\n" |
| 4739 | "Aggregate mask\n" |
| 4740 | "Generate AS set path information\n") |
| 4741 | |
| 4742 | ALIAS (no_aggregate_address_mask, |
| 4743 | no_aggregate_address_mask_as_set_summary_cmd, |
| 4744 | "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", |
| 4745 | NO_STR |
| 4746 | "Configure BGP aggregate entries\n" |
| 4747 | "Aggregate address\n" |
| 4748 | "Aggregate mask\n" |
| 4749 | "Generate AS set path information\n" |
| 4750 | "Filter more specific routes from updates\n") |
| 4751 | |
| 4752 | ALIAS (no_aggregate_address_mask, |
| 4753 | no_aggregate_address_mask_summary_as_set_cmd, |
| 4754 | "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", |
| 4755 | NO_STR |
| 4756 | "Configure BGP aggregate entries\n" |
| 4757 | "Aggregate address\n" |
| 4758 | "Aggregate mask\n" |
| 4759 | "Filter more specific routes from updates\n" |
| 4760 | "Generate AS set path information\n") |
| 4761 | |
| 4762 | #ifdef HAVE_IPV6 |
| 4763 | DEFUN (ipv6_aggregate_address, |
| 4764 | ipv6_aggregate_address_cmd, |
| 4765 | "aggregate-address X:X::X:X/M", |
| 4766 | "Configure BGP aggregate entries\n" |
| 4767 | "Aggregate prefix\n") |
| 4768 | { |
| 4769 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0); |
| 4770 | } |
| 4771 | |
| 4772 | DEFUN (ipv6_aggregate_address_summary_only, |
| 4773 | ipv6_aggregate_address_summary_only_cmd, |
| 4774 | "aggregate-address X:X::X:X/M summary-only", |
| 4775 | "Configure BGP aggregate entries\n" |
| 4776 | "Aggregate prefix\n" |
| 4777 | "Filter more specific routes from updates\n") |
| 4778 | { |
| 4779 | return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 4780 | AGGREGATE_SUMMARY_ONLY, 0); |
| 4781 | } |
| 4782 | |
| 4783 | DEFUN (no_ipv6_aggregate_address, |
| 4784 | no_ipv6_aggregate_address_cmd, |
| 4785 | "no aggregate-address X:X::X:X/M", |
| 4786 | NO_STR |
| 4787 | "Configure BGP aggregate entries\n" |
| 4788 | "Aggregate prefix\n") |
| 4789 | { |
| 4790 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 4791 | } |
| 4792 | |
| 4793 | DEFUN (no_ipv6_aggregate_address_summary_only, |
| 4794 | no_ipv6_aggregate_address_summary_only_cmd, |
| 4795 | "no aggregate-address X:X::X:X/M summary-only", |
| 4796 | NO_STR |
| 4797 | "Configure BGP aggregate entries\n" |
| 4798 | "Aggregate prefix\n" |
| 4799 | "Filter more specific routes from updates\n") |
| 4800 | { |
| 4801 | return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST); |
| 4802 | } |
| 4803 | |
| 4804 | ALIAS (ipv6_aggregate_address, |
| 4805 | old_ipv6_aggregate_address_cmd, |
| 4806 | "ipv6 bgp aggregate-address X:X::X:X/M", |
| 4807 | IPV6_STR |
| 4808 | BGP_STR |
| 4809 | "Configure BGP aggregate entries\n" |
| 4810 | "Aggregate prefix\n") |
| 4811 | |
| 4812 | ALIAS (ipv6_aggregate_address_summary_only, |
| 4813 | old_ipv6_aggregate_address_summary_only_cmd, |
| 4814 | "ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 4815 | IPV6_STR |
| 4816 | BGP_STR |
| 4817 | "Configure BGP aggregate entries\n" |
| 4818 | "Aggregate prefix\n" |
| 4819 | "Filter more specific routes from updates\n") |
| 4820 | |
| 4821 | ALIAS (no_ipv6_aggregate_address, |
| 4822 | old_no_ipv6_aggregate_address_cmd, |
| 4823 | "no ipv6 bgp aggregate-address X:X::X:X/M", |
| 4824 | NO_STR |
| 4825 | IPV6_STR |
| 4826 | BGP_STR |
| 4827 | "Configure BGP aggregate entries\n" |
| 4828 | "Aggregate prefix\n") |
| 4829 | |
| 4830 | ALIAS (no_ipv6_aggregate_address_summary_only, |
| 4831 | old_no_ipv6_aggregate_address_summary_only_cmd, |
| 4832 | "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", |
| 4833 | NO_STR |
| 4834 | IPV6_STR |
| 4835 | BGP_STR |
| 4836 | "Configure BGP aggregate entries\n" |
| 4837 | "Aggregate prefix\n" |
| 4838 | "Filter more specific routes from updates\n") |
| 4839 | #endif /* HAVE_IPV6 */ |
| 4840 | |
| 4841 | /* Redistribute route treatment. */ |
| 4842 | void |
| 4843 | bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, |
| 4844 | u_int32_t metric, u_char type) |
| 4845 | { |
| 4846 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4847 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4848 | struct bgp_info *new; |
| 4849 | struct bgp_info *bi; |
| 4850 | struct bgp_info info; |
| 4851 | struct bgp_node *bn; |
| 4852 | struct attr attr; |
| 4853 | struct attr attr_new; |
| 4854 | struct attr *new_attr; |
| 4855 | afi_t afi; |
| 4856 | int ret; |
| 4857 | |
| 4858 | /* Make default attribute. */ |
| 4859 | bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE); |
| 4860 | if (nexthop) |
| 4861 | attr.nexthop = *nexthop; |
| 4862 | |
| 4863 | attr.med = metric; |
| 4864 | attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 4865 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4866 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4867 | { |
| 4868 | afi = family2afi (p->family); |
| 4869 | |
| 4870 | if (bgp->redist[afi][type]) |
| 4871 | { |
| 4872 | /* Copy attribute for modification. */ |
| 4873 | attr_new = attr; |
| 4874 | |
| 4875 | if (bgp->redist_metric_flag[afi][type]) |
| 4876 | attr_new.med = bgp->redist_metric[afi][type]; |
| 4877 | |
| 4878 | /* Apply route-map. */ |
| 4879 | if (bgp->rmap[afi][type].map) |
| 4880 | { |
| 4881 | info.peer = bgp->peer_self; |
| 4882 | info.attr = &attr_new; |
| 4883 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4884 | SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE); |
| 4885 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4886 | ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP, |
| 4887 | &info); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4888 | |
| 4889 | bgp->peer_self->rmap_type = 0; |
| 4890 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4891 | if (ret == RMAP_DENYMATCH) |
| 4892 | { |
| 4893 | /* Free uninterned attribute. */ |
| 4894 | bgp_attr_flush (&attr_new); |
| 4895 | |
| 4896 | /* Unintern original. */ |
| 4897 | aspath_unintern (attr.aspath); |
| 4898 | bgp_redistribute_delete (p, type); |
| 4899 | return; |
| 4900 | } |
| 4901 | } |
| 4902 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4903 | bn = 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] | 4904 | new_attr = bgp_attr_intern (&attr_new); |
| 4905 | |
| 4906 | for (bi = bn->info; bi; bi = bi->next) |
| 4907 | if (bi->peer == bgp->peer_self |
| 4908 | && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) |
| 4909 | break; |
| 4910 | |
| 4911 | if (bi) |
| 4912 | { |
| 4913 | if (attrhash_cmp (bi->attr, new_attr)) |
| 4914 | { |
| 4915 | bgp_attr_unintern (new_attr); |
| 4916 | aspath_unintern (attr.aspath); |
| 4917 | bgp_unlock_node (bn); |
| 4918 | return; |
| 4919 | } |
| 4920 | else |
| 4921 | { |
| 4922 | /* The attribute is changed. */ |
| 4923 | SET_FLAG (bi->flags, BGP_INFO_ATTR_CHANGED); |
| 4924 | |
| 4925 | /* Rewrite BGP route information. */ |
| 4926 | bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST); |
| 4927 | bgp_attr_unintern (bi->attr); |
| 4928 | bi->attr = new_attr; |
| 4929 | bi->uptime = time (NULL); |
| 4930 | |
| 4931 | /* Process change. */ |
| 4932 | bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); |
| 4933 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 4934 | bgp_unlock_node (bn); |
| 4935 | aspath_unintern (attr.aspath); |
| 4936 | return; |
| 4937 | } |
| 4938 | } |
| 4939 | |
| 4940 | new = bgp_info_new (); |
| 4941 | new->type = type; |
| 4942 | new->sub_type = BGP_ROUTE_REDISTRIBUTE; |
| 4943 | new->peer = bgp->peer_self; |
| 4944 | SET_FLAG (new->flags, BGP_INFO_VALID); |
| 4945 | new->attr = new_attr; |
| 4946 | new->uptime = time (NULL); |
| 4947 | |
| 4948 | bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); |
| 4949 | bgp_info_add (bn, new); |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 4950 | bgp_unlock_node (bn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4951 | bgp_process (bgp, bn, afi, SAFI_UNICAST); |
| 4952 | } |
| 4953 | } |
| 4954 | |
| 4955 | /* Unintern original. */ |
| 4956 | aspath_unintern (attr.aspath); |
| 4957 | } |
| 4958 | |
| 4959 | void |
| 4960 | bgp_redistribute_delete (struct prefix *p, u_char type) |
| 4961 | { |
| 4962 | struct bgp *bgp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4963 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4964 | afi_t afi; |
| 4965 | struct bgp_node *rn; |
| 4966 | struct bgp_info *ri; |
| 4967 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4968 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4969 | { |
| 4970 | afi = family2afi (p->family); |
| 4971 | |
| 4972 | if (bgp->redist[afi][type]) |
| 4973 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 4974 | 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] | 4975 | |
| 4976 | for (ri = rn->info; ri; ri = ri->next) |
| 4977 | if (ri->peer == bgp->peer_self |
| 4978 | && ri->type == type) |
| 4979 | break; |
| 4980 | |
| 4981 | if (ri) |
| 4982 | { |
| 4983 | bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); |
| 4984 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 4985 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
| 4986 | bgp_info_delete (rn, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4987 | } |
| 4988 | bgp_unlock_node (rn); |
| 4989 | } |
| 4990 | } |
| 4991 | } |
| 4992 | |
| 4993 | /* Withdraw specified route type's route. */ |
| 4994 | void |
| 4995 | bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) |
| 4996 | { |
| 4997 | struct bgp_node *rn; |
| 4998 | struct bgp_info *ri; |
| 4999 | struct bgp_table *table; |
| 5000 | |
| 5001 | table = bgp->rib[afi][SAFI_UNICAST]; |
| 5002 | |
| 5003 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5004 | { |
| 5005 | for (ri = rn->info; ri; ri = ri->next) |
| 5006 | if (ri->peer == bgp->peer_self |
| 5007 | && ri->type == type) |
| 5008 | break; |
| 5009 | |
| 5010 | if (ri) |
| 5011 | { |
| 5012 | bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); |
| 5013 | UNSET_FLAG (ri->flags, BGP_INFO_VALID); |
| 5014 | bgp_process (bgp, rn, afi, SAFI_UNICAST); |
| 5015 | bgp_info_delete (rn, ri); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5016 | } |
| 5017 | } |
| 5018 | } |
| 5019 | |
| 5020 | /* Static function to display route. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5021 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5022 | route_vty_out_route (struct prefix *p, struct vty *vty) |
| 5023 | { |
| 5024 | int len; |
| 5025 | u_int32_t destination; |
| 5026 | char buf[BUFSIZ]; |
| 5027 | |
| 5028 | if (p->family == AF_INET) |
| 5029 | { |
| 5030 | len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ)); |
| 5031 | destination = ntohl (p->u.prefix4.s_addr); |
| 5032 | |
| 5033 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 5034 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 5035 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 5036 | || p->u.prefix4.s_addr == 0) |
| 5037 | { |
| 5038 | /* When mask is natural, mask is not displayed. */ |
| 5039 | } |
| 5040 | else |
| 5041 | len += vty_out (vty, "/%d", p->prefixlen); |
| 5042 | } |
| 5043 | else |
| 5044 | len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 5045 | p->prefixlen); |
| 5046 | |
| 5047 | len = 17 - len; |
| 5048 | if (len < 1) |
| 5049 | vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " "); |
| 5050 | else |
| 5051 | vty_out (vty, "%*s", len, " "); |
| 5052 | } |
| 5053 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5054 | enum bgp_display_type |
| 5055 | { |
| 5056 | normal_list, |
| 5057 | }; |
| 5058 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5059 | /* Print the short form route status for a bgp_info */ |
| 5060 | static void |
| 5061 | route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5062 | { |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5063 | /* Route status display. */ |
| 5064 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5065 | vty_out (vty, "R"); |
| 5066 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5067 | vty_out (vty, "S"); |
| 5068 | else if (binfo->suppress) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5069 | vty_out (vty, "s"); |
| 5070 | else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5071 | vty_out (vty, "*"); |
| 5072 | else |
| 5073 | vty_out (vty, " "); |
| 5074 | |
| 5075 | /* Selected */ |
| 5076 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5077 | vty_out (vty, "h"); |
| 5078 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5079 | vty_out (vty, "d"); |
| 5080 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5081 | vty_out (vty, ">"); |
| 5082 | else |
| 5083 | vty_out (vty, " "); |
| 5084 | |
| 5085 | /* Internal route. */ |
| 5086 | if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) |
| 5087 | vty_out (vty, "i"); |
| 5088 | else |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5089 | vty_out (vty, " "); |
| 5090 | } |
| 5091 | |
| 5092 | /* called from terminal list command */ |
| 5093 | void |
| 5094 | route_vty_out (struct vty *vty, struct prefix *p, |
| 5095 | struct bgp_info *binfo, int display, safi_t safi) |
| 5096 | { |
| 5097 | struct attr *attr; |
| 5098 | |
| 5099 | /* short status lead text */ |
| 5100 | route_vty_short_status_out (vty, binfo); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5101 | |
| 5102 | /* print prefix and mask */ |
| 5103 | if (! display) |
| 5104 | route_vty_out_route (p, vty); |
| 5105 | else |
| 5106 | vty_out (vty, "%*s", 17, " "); |
| 5107 | |
| 5108 | /* Print attribute */ |
| 5109 | attr = binfo->attr; |
| 5110 | if (attr) |
| 5111 | { |
| 5112 | if (p->family == AF_INET) |
| 5113 | { |
| 5114 | if (safi == SAFI_MPLS_VPN) |
| 5115 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 5116 | else |
| 5117 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5118 | } |
| 5119 | #ifdef HAVE_IPV6 |
| 5120 | else if (p->family == AF_INET6) |
| 5121 | { |
| 5122 | int len; |
| 5123 | char buf[BUFSIZ]; |
| 5124 | |
| 5125 | len = vty_out (vty, "%s", |
| 5126 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 5127 | len = 16 - len; |
| 5128 | if (len < 1) |
| 5129 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5130 | else |
| 5131 | vty_out (vty, "%*s", len, " "); |
| 5132 | } |
| 5133 | #endif /* HAVE_IPV6 */ |
| 5134 | |
| 5135 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 5136 | vty_out (vty, "%10d", attr->med); |
| 5137 | else |
| 5138 | vty_out (vty, " "); |
| 5139 | |
| 5140 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 5141 | vty_out (vty, "%7d", attr->local_pref); |
| 5142 | else |
| 5143 | vty_out (vty, " "); |
| 5144 | |
| 5145 | vty_out (vty, "%7u ",attr->weight); |
| 5146 | |
| 5147 | /* Print aspath */ |
| 5148 | if (attr->aspath) |
| 5149 | aspath_print_vty (vty, attr->aspath); |
| 5150 | |
| 5151 | /* Print origin */ |
| 5152 | if (strlen (attr->aspath->str) == 0) |
| 5153 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 5154 | else |
| 5155 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 5156 | } |
| 5157 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5158 | } |
| 5159 | |
| 5160 | /* called from terminal list command */ |
| 5161 | void |
| 5162 | route_vty_out_tmp (struct vty *vty, struct prefix *p, |
| 5163 | struct attr *attr, safi_t safi) |
| 5164 | { |
| 5165 | /* Route status display. */ |
| 5166 | vty_out (vty, "*"); |
| 5167 | vty_out (vty, ">"); |
| 5168 | vty_out (vty, " "); |
| 5169 | |
| 5170 | /* print prefix and mask */ |
| 5171 | route_vty_out_route (p, vty); |
| 5172 | |
| 5173 | /* Print attribute */ |
| 5174 | if (attr) |
| 5175 | { |
| 5176 | if (p->family == AF_INET) |
| 5177 | { |
| 5178 | if (safi == SAFI_MPLS_VPN) |
| 5179 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 5180 | else |
| 5181 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5182 | } |
| 5183 | #ifdef HAVE_IPV6 |
| 5184 | else if (p->family == AF_INET6) |
| 5185 | { |
| 5186 | int len; |
| 5187 | char buf[BUFSIZ]; |
| 5188 | |
| 5189 | len = vty_out (vty, "%s", |
| 5190 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 5191 | len = 16 - len; |
| 5192 | if (len < 1) |
| 5193 | vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); |
| 5194 | else |
| 5195 | vty_out (vty, "%*s", len, " "); |
| 5196 | } |
| 5197 | #endif /* HAVE_IPV6 */ |
| 5198 | |
| 5199 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) |
| 5200 | vty_out (vty, "%10d", attr->med); |
| 5201 | else |
| 5202 | vty_out (vty, " "); |
| 5203 | |
| 5204 | if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) |
| 5205 | vty_out (vty, "%7d", attr->local_pref); |
| 5206 | else |
| 5207 | vty_out (vty, " "); |
| 5208 | |
| 5209 | vty_out (vty, "%7d ",attr->weight); |
| 5210 | |
| 5211 | /* Print aspath */ |
| 5212 | if (attr->aspath) |
| 5213 | aspath_print_vty (vty, attr->aspath); |
| 5214 | |
| 5215 | /* Print origin */ |
| 5216 | if (strlen (attr->aspath->str) == 0) |
| 5217 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 5218 | else |
| 5219 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 5220 | } |
| 5221 | |
| 5222 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5223 | } |
| 5224 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5225 | void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5226 | route_vty_out_tag (struct vty *vty, struct prefix *p, |
| 5227 | struct bgp_info *binfo, int display, safi_t safi) |
| 5228 | { |
| 5229 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5230 | u_int32_t label = 0; |
| 5231 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5232 | /* short status lead text */ |
| 5233 | route_vty_short_status_out (vty, binfo); |
| 5234 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5235 | /* print prefix and mask */ |
| 5236 | if (! display) |
| 5237 | route_vty_out_route (p, vty); |
| 5238 | else |
| 5239 | vty_out (vty, "%*s", 17, " "); |
| 5240 | |
| 5241 | /* Print attribute */ |
| 5242 | attr = binfo->attr; |
| 5243 | if (attr) |
| 5244 | { |
| 5245 | if (p->family == AF_INET) |
| 5246 | { |
| 5247 | if (safi == SAFI_MPLS_VPN) |
| 5248 | vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in)); |
| 5249 | else |
| 5250 | vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); |
| 5251 | } |
| 5252 | #ifdef HAVE_IPV6 |
| 5253 | else if (p->family == AF_INET6) |
| 5254 | { |
| 5255 | char buf[BUFSIZ]; |
| 5256 | char buf1[BUFSIZ]; |
| 5257 | if (attr->mp_nexthop_len == 16) |
| 5258 | vty_out (vty, "%s", |
| 5259 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ)); |
| 5260 | else if (attr->mp_nexthop_len == 32) |
| 5261 | vty_out (vty, "%s(%s)", |
| 5262 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ), |
| 5263 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf1, BUFSIZ)); |
| 5264 | |
| 5265 | } |
| 5266 | #endif /* HAVE_IPV6 */ |
| 5267 | } |
| 5268 | |
| 5269 | label = decode_label (binfo->tag); |
| 5270 | |
| 5271 | vty_out (vty, "notag/%d", label); |
| 5272 | |
| 5273 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5274 | } |
| 5275 | |
| 5276 | /* dampening route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5277 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5278 | damp_route_vty_out (struct vty *vty, struct prefix *p, |
| 5279 | struct bgp_info *binfo, int display, safi_t safi) |
| 5280 | { |
| 5281 | struct attr *attr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5282 | int len; |
| 5283 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5284 | /* short status lead text */ |
| 5285 | route_vty_short_status_out (vty, binfo); |
| 5286 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5287 | /* print prefix and mask */ |
| 5288 | if (! display) |
| 5289 | route_vty_out_route (p, vty); |
| 5290 | else |
| 5291 | vty_out (vty, "%*s", 17, " "); |
| 5292 | |
| 5293 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5294 | len = 17 - len; |
| 5295 | if (len < 1) |
| 5296 | vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " "); |
| 5297 | else |
| 5298 | vty_out (vty, "%*s", len, " "); |
| 5299 | |
| 5300 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 5301 | |
| 5302 | /* Print attribute */ |
| 5303 | attr = binfo->attr; |
| 5304 | if (attr) |
| 5305 | { |
| 5306 | /* Print aspath */ |
| 5307 | if (attr->aspath) |
| 5308 | aspath_print_vty (vty, attr->aspath); |
| 5309 | |
| 5310 | /* Print origin */ |
| 5311 | if (strlen (attr->aspath->str) == 0) |
| 5312 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 5313 | else |
| 5314 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 5315 | } |
| 5316 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5317 | } |
| 5318 | |
| 5319 | #define BGP_UPTIME_LEN 25 |
| 5320 | |
| 5321 | /* flap route */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5322 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5323 | flap_route_vty_out (struct vty *vty, struct prefix *p, |
| 5324 | struct bgp_info *binfo, int display, safi_t safi) |
| 5325 | { |
| 5326 | struct attr *attr; |
| 5327 | struct bgp_damp_info *bdi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5328 | char timebuf[BGP_UPTIME_LEN]; |
| 5329 | int len; |
| 5330 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5331 | bdi = binfo->damp_info; |
| 5332 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5333 | /* short status lead text */ |
| 5334 | route_vty_short_status_out (vty, binfo); |
| 5335 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5336 | /* print prefix and mask */ |
| 5337 | if (! display) |
| 5338 | route_vty_out_route (p, vty); |
| 5339 | else |
| 5340 | vty_out (vty, "%*s", 17, " "); |
| 5341 | |
| 5342 | len = vty_out (vty, "%s", binfo->peer->host); |
| 5343 | len = 16 - len; |
| 5344 | if (len < 1) |
| 5345 | vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " "); |
| 5346 | else |
| 5347 | vty_out (vty, "%*s", len, " "); |
| 5348 | |
| 5349 | len = vty_out (vty, "%d", bdi->flap); |
| 5350 | len = 5 - len; |
| 5351 | if (len < 1) |
| 5352 | vty_out (vty, " "); |
| 5353 | else |
| 5354 | vty_out (vty, "%*s ", len, " "); |
| 5355 | |
| 5356 | vty_out (vty, "%s ", peer_uptime (bdi->start_time, |
| 5357 | timebuf, BGP_UPTIME_LEN)); |
| 5358 | |
| 5359 | if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED) |
| 5360 | && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5361 | vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo)); |
| 5362 | else |
| 5363 | vty_out (vty, "%*s ", 8, " "); |
| 5364 | |
| 5365 | /* Print attribute */ |
| 5366 | attr = binfo->attr; |
| 5367 | if (attr) |
| 5368 | { |
| 5369 | /* Print aspath */ |
| 5370 | if (attr->aspath) |
| 5371 | aspath_print_vty (vty, attr->aspath); |
| 5372 | |
| 5373 | /* Print origin */ |
| 5374 | if (strlen (attr->aspath->str) == 0) |
| 5375 | vty_out (vty, "%s", bgp_origin_str[attr->origin]); |
| 5376 | else |
| 5377 | vty_out (vty, " %s", bgp_origin_str[attr->origin]); |
| 5378 | } |
| 5379 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5380 | } |
| 5381 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5382 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5383 | route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, |
| 5384 | struct bgp_info *binfo, afi_t afi, safi_t safi) |
| 5385 | { |
| 5386 | char buf[INET6_ADDRSTRLEN]; |
| 5387 | char buf1[BUFSIZ]; |
| 5388 | struct attr *attr; |
| 5389 | int sockunion_vty_out (struct vty *, union sockunion *); |
| 5390 | |
| 5391 | attr = binfo->attr; |
| 5392 | |
| 5393 | if (attr) |
| 5394 | { |
| 5395 | /* Line1 display AS-path, Aggregator */ |
| 5396 | if (attr->aspath) |
| 5397 | { |
| 5398 | vty_out (vty, " "); |
paul | fe69a50 | 2005-09-10 16:55:02 +0000 | [diff] [blame] | 5399 | if (aspath_count_hops (attr->aspath) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5400 | vty_out (vty, "Local"); |
| 5401 | else |
| 5402 | aspath_print_vty (vty, attr->aspath); |
| 5403 | } |
| 5404 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5405 | if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED)) |
| 5406 | vty_out (vty, ", (removed)"); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5407 | if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) |
| 5408 | vty_out (vty, ", (stale)"); |
| 5409 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
| 5410 | vty_out (vty, ", (aggregated by %d %s)", attr->aggregator_as, |
| 5411 | inet_ntoa (attr->aggregator_addr)); |
| 5412 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) |
| 5413 | vty_out (vty, ", (Received from a RR-client)"); |
| 5414 | if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) |
| 5415 | vty_out (vty, ", (Received from a RS-client)"); |
| 5416 | if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5417 | vty_out (vty, ", (history entry)"); |
| 5418 | else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) |
| 5419 | vty_out (vty, ", (suppressed due to dampening)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5420 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5421 | |
| 5422 | /* Line2 display Next-hop, Neighbor, Router-id */ |
| 5423 | if (p->family == AF_INET) |
| 5424 | { |
| 5425 | vty_out (vty, " %s", safi == SAFI_MPLS_VPN ? |
| 5426 | inet_ntoa (attr->mp_nexthop_global_in) : |
| 5427 | inet_ntoa (attr->nexthop)); |
| 5428 | } |
| 5429 | #ifdef HAVE_IPV6 |
| 5430 | else |
| 5431 | { |
| 5432 | vty_out (vty, " %s", |
| 5433 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, |
| 5434 | buf, INET6_ADDRSTRLEN)); |
| 5435 | } |
| 5436 | #endif /* HAVE_IPV6 */ |
| 5437 | |
| 5438 | if (binfo->peer == bgp->peer_self) |
| 5439 | { |
| 5440 | vty_out (vty, " from %s ", |
| 5441 | p->family == AF_INET ? "0.0.0.0" : "::"); |
| 5442 | vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); |
| 5443 | } |
| 5444 | else |
| 5445 | { |
| 5446 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) |
| 5447 | vty_out (vty, " (inaccessible)"); |
| 5448 | else if (binfo->igpmetric) |
| 5449 | vty_out (vty, " (metric %d)", binfo->igpmetric); |
paul | eb82118 | 2004-05-01 08:44:08 +0000 | [diff] [blame] | 5450 | vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5451 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 5452 | vty_out (vty, " (%s)", inet_ntoa (attr->originator_id)); |
| 5453 | else |
| 5454 | vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ)); |
| 5455 | } |
| 5456 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5457 | |
| 5458 | #ifdef HAVE_IPV6 |
| 5459 | /* display nexthop local */ |
| 5460 | if (attr->mp_nexthop_len == 32) |
| 5461 | { |
| 5462 | vty_out (vty, " (%s)%s", |
| 5463 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, |
| 5464 | buf, INET6_ADDRSTRLEN), |
| 5465 | VTY_NEWLINE); |
| 5466 | } |
| 5467 | #endif /* HAVE_IPV6 */ |
| 5468 | |
| 5469 | /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ |
| 5470 | vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); |
| 5471 | |
| 5472 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) |
| 5473 | vty_out (vty, ", metric %d", attr->med); |
| 5474 | |
| 5475 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) |
| 5476 | vty_out (vty, ", localpref %d", attr->local_pref); |
| 5477 | else |
| 5478 | vty_out (vty, ", localpref %d", bgp->default_local_pref); |
| 5479 | |
| 5480 | if (attr->weight != 0) |
| 5481 | vty_out (vty, ", weight %d", attr->weight); |
| 5482 | |
| 5483 | if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) |
| 5484 | vty_out (vty, ", valid"); |
| 5485 | |
| 5486 | if (binfo->peer != bgp->peer_self) |
| 5487 | { |
| 5488 | if (binfo->peer->as == binfo->peer->local_as) |
| 5489 | vty_out (vty, ", internal"); |
| 5490 | else |
| 5491 | vty_out (vty, ", %s", |
| 5492 | (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); |
| 5493 | } |
| 5494 | else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) |
| 5495 | vty_out (vty, ", aggregated, local"); |
| 5496 | else if (binfo->type != ZEBRA_ROUTE_BGP) |
| 5497 | vty_out (vty, ", sourced"); |
| 5498 | else |
| 5499 | vty_out (vty, ", sourced, local"); |
| 5500 | |
| 5501 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) |
| 5502 | vty_out (vty, ", atomic-aggregate"); |
| 5503 | |
| 5504 | if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) |
| 5505 | vty_out (vty, ", best"); |
| 5506 | |
| 5507 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5508 | |
| 5509 | /* Line 4 display Community */ |
| 5510 | if (attr->community) |
| 5511 | vty_out (vty, " Community: %s%s", attr->community->str, |
| 5512 | VTY_NEWLINE); |
| 5513 | |
| 5514 | /* Line 5 display Extended-community */ |
| 5515 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) |
| 5516 | vty_out (vty, " Extended Community: %s%s", attr->ecommunity->str, |
| 5517 | VTY_NEWLINE); |
| 5518 | |
| 5519 | /* Line 6 display Originator, Cluster-id */ |
| 5520 | if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || |
| 5521 | (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) |
| 5522 | { |
| 5523 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) |
| 5524 | vty_out (vty, " Originator: %s", inet_ntoa (attr->originator_id)); |
| 5525 | |
| 5526 | if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) |
| 5527 | { |
| 5528 | int i; |
| 5529 | vty_out (vty, ", Cluster list: "); |
| 5530 | for (i = 0; i < attr->cluster->length / 4; i++) |
| 5531 | vty_out (vty, "%s ", inet_ntoa (attr->cluster->list[i])); |
| 5532 | } |
| 5533 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5534 | } |
| 5535 | |
| 5536 | if (binfo->damp_info) |
| 5537 | bgp_damp_info_vty (vty, binfo); |
| 5538 | |
| 5539 | /* Line 7 display Uptime */ |
| 5540 | vty_out (vty, " Last update: %s", ctime (&binfo->uptime)); |
| 5541 | } |
| 5542 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5543 | } |
| 5544 | |
paul | b40d939 | 2005-08-22 22:34:41 +0000 | [diff] [blame] | 5545 | #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,%s r RIB-failure, S Stale, R Removed%s" |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5546 | #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] | 5547 | #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" |
| 5548 | #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" |
| 5549 | #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" |
| 5550 | |
| 5551 | enum bgp_show_type |
| 5552 | { |
| 5553 | bgp_show_type_normal, |
| 5554 | bgp_show_type_regexp, |
| 5555 | bgp_show_type_prefix_list, |
| 5556 | bgp_show_type_filter_list, |
| 5557 | bgp_show_type_route_map, |
| 5558 | bgp_show_type_neighbor, |
| 5559 | bgp_show_type_cidr_only, |
| 5560 | bgp_show_type_prefix_longer, |
| 5561 | bgp_show_type_community_all, |
| 5562 | bgp_show_type_community, |
| 5563 | bgp_show_type_community_exact, |
| 5564 | bgp_show_type_community_list, |
| 5565 | bgp_show_type_community_list_exact, |
| 5566 | bgp_show_type_flap_statistics, |
| 5567 | bgp_show_type_flap_address, |
| 5568 | bgp_show_type_flap_prefix, |
| 5569 | bgp_show_type_flap_cidr_only, |
| 5570 | bgp_show_type_flap_regexp, |
| 5571 | bgp_show_type_flap_filter_list, |
| 5572 | bgp_show_type_flap_prefix_list, |
| 5573 | bgp_show_type_flap_prefix_longer, |
| 5574 | bgp_show_type_flap_route_map, |
| 5575 | bgp_show_type_flap_neighbor, |
| 5576 | bgp_show_type_dampend_paths, |
| 5577 | bgp_show_type_damp_neighbor |
| 5578 | }; |
| 5579 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5580 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5581 | 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] | 5582 | enum bgp_show_type type, void *output_arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5583 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5584 | struct bgp_info *ri; |
| 5585 | struct bgp_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5586 | int header = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5587 | int display; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5588 | unsigned long output_count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5589 | |
| 5590 | /* This is first entry point, so reset total line. */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5591 | output_count = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5592 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5593 | /* Start processing of routes. */ |
| 5594 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 5595 | if (rn->info != NULL) |
| 5596 | { |
| 5597 | display = 0; |
| 5598 | |
| 5599 | for (ri = rn->info; ri; ri = ri->next) |
| 5600 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5601 | if (type == bgp_show_type_flap_statistics |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5602 | || type == bgp_show_type_flap_address |
| 5603 | || type == bgp_show_type_flap_prefix |
| 5604 | || type == bgp_show_type_flap_cidr_only |
| 5605 | || type == bgp_show_type_flap_regexp |
| 5606 | || type == bgp_show_type_flap_filter_list |
| 5607 | || type == bgp_show_type_flap_prefix_list |
| 5608 | || type == bgp_show_type_flap_prefix_longer |
| 5609 | || type == bgp_show_type_flap_route_map |
| 5610 | || type == bgp_show_type_flap_neighbor |
| 5611 | || type == bgp_show_type_dampend_paths |
| 5612 | || type == bgp_show_type_damp_neighbor) |
| 5613 | { |
| 5614 | if (! ri->damp_info) |
| 5615 | continue; |
| 5616 | } |
| 5617 | if (type == bgp_show_type_regexp |
| 5618 | || type == bgp_show_type_flap_regexp) |
| 5619 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5620 | regex_t *regex = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5621 | |
| 5622 | if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) |
| 5623 | continue; |
| 5624 | } |
| 5625 | if (type == bgp_show_type_prefix_list |
| 5626 | || type == bgp_show_type_flap_prefix_list) |
| 5627 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5628 | struct prefix_list *plist = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5629 | |
| 5630 | if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) |
| 5631 | continue; |
| 5632 | } |
| 5633 | if (type == bgp_show_type_filter_list |
| 5634 | || type == bgp_show_type_flap_filter_list) |
| 5635 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5636 | struct as_list *as_list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5637 | |
| 5638 | if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) |
| 5639 | continue; |
| 5640 | } |
| 5641 | if (type == bgp_show_type_route_map |
| 5642 | || type == bgp_show_type_flap_route_map) |
| 5643 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5644 | struct route_map *rmap = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5645 | struct bgp_info binfo; |
| 5646 | struct attr dummy_attr; |
| 5647 | int ret; |
| 5648 | |
| 5649 | dummy_attr = *ri->attr; |
| 5650 | binfo.peer = ri->peer; |
| 5651 | binfo.attr = &dummy_attr; |
| 5652 | |
| 5653 | ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); |
| 5654 | |
| 5655 | if (ret == RMAP_DENYMATCH) |
| 5656 | continue; |
| 5657 | } |
| 5658 | if (type == bgp_show_type_neighbor |
| 5659 | || type == bgp_show_type_flap_neighbor |
| 5660 | || type == bgp_show_type_damp_neighbor) |
| 5661 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5662 | union sockunion *su = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5663 | |
| 5664 | if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) |
| 5665 | continue; |
| 5666 | } |
| 5667 | if (type == bgp_show_type_cidr_only |
| 5668 | || type == bgp_show_type_flap_cidr_only) |
| 5669 | { |
| 5670 | u_int32_t destination; |
| 5671 | |
| 5672 | destination = ntohl (rn->p.u.prefix4.s_addr); |
| 5673 | if (IN_CLASSC (destination) && rn->p.prefixlen == 24) |
| 5674 | continue; |
| 5675 | if (IN_CLASSB (destination) && rn->p.prefixlen == 16) |
| 5676 | continue; |
| 5677 | if (IN_CLASSA (destination) && rn->p.prefixlen == 8) |
| 5678 | continue; |
| 5679 | } |
| 5680 | if (type == bgp_show_type_prefix_longer |
| 5681 | || type == bgp_show_type_flap_prefix_longer) |
| 5682 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5683 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5684 | |
| 5685 | if (! prefix_match (p, &rn->p)) |
| 5686 | continue; |
| 5687 | } |
| 5688 | if (type == bgp_show_type_community_all) |
| 5689 | { |
| 5690 | if (! ri->attr->community) |
| 5691 | continue; |
| 5692 | } |
| 5693 | if (type == bgp_show_type_community) |
| 5694 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5695 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5696 | |
| 5697 | if (! ri->attr->community || |
| 5698 | ! community_match (ri->attr->community, com)) |
| 5699 | continue; |
| 5700 | } |
| 5701 | if (type == bgp_show_type_community_exact) |
| 5702 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5703 | struct community *com = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5704 | |
| 5705 | if (! ri->attr->community || |
| 5706 | ! community_cmp (ri->attr->community, com)) |
| 5707 | continue; |
| 5708 | } |
| 5709 | if (type == bgp_show_type_community_list) |
| 5710 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5711 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5712 | |
| 5713 | if (! community_list_match (ri->attr->community, list)) |
| 5714 | continue; |
| 5715 | } |
| 5716 | if (type == bgp_show_type_community_list_exact) |
| 5717 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5718 | struct community_list *list = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5719 | |
| 5720 | if (! community_list_exact_match (ri->attr->community, list)) |
| 5721 | continue; |
| 5722 | } |
| 5723 | if (type == bgp_show_type_flap_address |
| 5724 | || type == bgp_show_type_flap_prefix) |
| 5725 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5726 | struct prefix *p = output_arg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5727 | |
| 5728 | if (! prefix_match (&rn->p, p)) |
| 5729 | continue; |
| 5730 | |
| 5731 | if (type == bgp_show_type_flap_prefix) |
| 5732 | if (p->prefixlen != rn->p.prefixlen) |
| 5733 | continue; |
| 5734 | } |
| 5735 | if (type == bgp_show_type_dampend_paths |
| 5736 | || type == bgp_show_type_damp_neighbor) |
| 5737 | { |
| 5738 | if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED) |
| 5739 | || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) |
| 5740 | continue; |
| 5741 | } |
| 5742 | |
| 5743 | if (header) |
| 5744 | { |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 5745 | vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE); |
| 5746 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 5747 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5748 | if (type == bgp_show_type_dampend_paths |
| 5749 | || type == bgp_show_type_damp_neighbor) |
| 5750 | vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); |
| 5751 | else if (type == bgp_show_type_flap_statistics |
| 5752 | || type == bgp_show_type_flap_address |
| 5753 | || type == bgp_show_type_flap_prefix |
| 5754 | || type == bgp_show_type_flap_cidr_only |
| 5755 | || type == bgp_show_type_flap_regexp |
| 5756 | || type == bgp_show_type_flap_filter_list |
| 5757 | || type == bgp_show_type_flap_prefix_list |
| 5758 | || type == bgp_show_type_flap_prefix_longer |
| 5759 | || type == bgp_show_type_flap_route_map |
| 5760 | || type == bgp_show_type_flap_neighbor) |
| 5761 | vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); |
| 5762 | else |
| 5763 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5764 | header = 0; |
| 5765 | } |
| 5766 | |
| 5767 | if (type == bgp_show_type_dampend_paths |
| 5768 | || type == bgp_show_type_damp_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5769 | damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5770 | else if (type == bgp_show_type_flap_statistics |
| 5771 | || type == bgp_show_type_flap_address |
| 5772 | || type == bgp_show_type_flap_prefix |
| 5773 | || type == bgp_show_type_flap_cidr_only |
| 5774 | || type == bgp_show_type_flap_regexp |
| 5775 | || type == bgp_show_type_flap_filter_list |
| 5776 | || type == bgp_show_type_flap_prefix_list |
| 5777 | || type == bgp_show_type_flap_prefix_longer |
| 5778 | || type == bgp_show_type_flap_route_map |
| 5779 | || type == bgp_show_type_flap_neighbor) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5780 | flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5781 | else |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5782 | route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5783 | display++; |
| 5784 | } |
| 5785 | if (display) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5786 | output_count++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5787 | } |
| 5788 | |
| 5789 | /* No route is displayed */ |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5790 | if (output_count == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5791 | { |
| 5792 | if (type == bgp_show_type_normal) |
| 5793 | vty_out (vty, "No BGP network exists%s", VTY_NEWLINE); |
| 5794 | } |
| 5795 | else |
| 5796 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5797 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5798 | |
| 5799 | return CMD_SUCCESS; |
| 5800 | } |
| 5801 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5802 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5803 | 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] | 5804 | enum bgp_show_type type, void *output_arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5805 | { |
| 5806 | struct bgp_table *table; |
| 5807 | |
| 5808 | if (bgp == NULL) { |
| 5809 | bgp = bgp_get_default (); |
| 5810 | } |
| 5811 | |
| 5812 | if (bgp == NULL) |
| 5813 | { |
| 5814 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 5815 | return CMD_WARNING; |
| 5816 | } |
| 5817 | |
| 5818 | |
| 5819 | table = bgp->rib[afi][safi]; |
| 5820 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 5821 | return bgp_show_table (vty, table, &bgp->router_id, type, output_arg); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5822 | } |
| 5823 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5824 | /* Header of detailed BGP route information */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5825 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5826 | route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, |
| 5827 | struct bgp_node *rn, |
| 5828 | struct prefix_rd *prd, afi_t afi, safi_t safi) |
| 5829 | { |
| 5830 | struct bgp_info *ri; |
| 5831 | struct prefix *p; |
| 5832 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5833 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5834 | char buf1[INET6_ADDRSTRLEN]; |
| 5835 | char buf2[INET6_ADDRSTRLEN]; |
| 5836 | int count = 0; |
| 5837 | int best = 0; |
| 5838 | int suppress = 0; |
| 5839 | int no_export = 0; |
| 5840 | int no_advertise = 0; |
| 5841 | int local_as = 0; |
| 5842 | int first = 0; |
| 5843 | |
| 5844 | p = &rn->p; |
| 5845 | vty_out (vty, "BGP routing table entry for %s%s%s/%d%s", |
| 5846 | (safi == SAFI_MPLS_VPN ? |
| 5847 | prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""), |
| 5848 | safi == SAFI_MPLS_VPN ? ":" : "", |
| 5849 | inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN), |
| 5850 | p->prefixlen, VTY_NEWLINE); |
| 5851 | |
| 5852 | for (ri = rn->info; ri; ri = ri->next) |
| 5853 | { |
| 5854 | count++; |
| 5855 | if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) |
| 5856 | { |
| 5857 | best = count; |
| 5858 | if (ri->suppress) |
| 5859 | suppress = 1; |
| 5860 | if (ri->attr->community != NULL) |
| 5861 | { |
| 5862 | if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE)) |
| 5863 | no_advertise = 1; |
| 5864 | if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT)) |
| 5865 | no_export = 1; |
| 5866 | if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS)) |
| 5867 | local_as = 1; |
| 5868 | } |
| 5869 | } |
| 5870 | } |
| 5871 | |
| 5872 | vty_out (vty, "Paths: (%d available", count); |
| 5873 | if (best) |
| 5874 | { |
| 5875 | vty_out (vty, ", best #%d", best); |
| 5876 | if (safi == SAFI_UNICAST) |
| 5877 | vty_out (vty, ", table Default-IP-Routing-Table"); |
| 5878 | } |
| 5879 | else |
| 5880 | vty_out (vty, ", no best path"); |
| 5881 | if (no_advertise) |
| 5882 | vty_out (vty, ", not advertised to any peer"); |
| 5883 | else if (no_export) |
| 5884 | vty_out (vty, ", not advertised to EBGP peer"); |
| 5885 | else if (local_as) |
| 5886 | vty_out (vty, ", not advertised outside local AS"); |
| 5887 | if (suppress) |
| 5888 | vty_out (vty, ", Advertisements suppressed by an aggregate."); |
| 5889 | vty_out (vty, ")%s", VTY_NEWLINE); |
| 5890 | |
| 5891 | /* advertised peer */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 5892 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5893 | { |
| 5894 | if (bgp_adj_out_lookup (peer, p, afi, safi, rn)) |
| 5895 | { |
| 5896 | if (! first) |
| 5897 | vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE); |
| 5898 | vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN)); |
| 5899 | first = 1; |
| 5900 | } |
| 5901 | } |
| 5902 | if (! first) |
| 5903 | vty_out (vty, " Not advertised to any peer"); |
| 5904 | vty_out (vty, "%s", VTY_NEWLINE); |
| 5905 | } |
| 5906 | |
| 5907 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5908 | static int |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5909 | bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5910 | struct bgp_table *rib, const char *ip_str, |
| 5911 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 5912 | int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5913 | { |
| 5914 | int ret; |
| 5915 | int header; |
| 5916 | int display = 0; |
| 5917 | struct prefix match; |
| 5918 | struct bgp_node *rn; |
| 5919 | struct bgp_node *rm; |
| 5920 | struct bgp_info *ri; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5921 | struct bgp_table *table; |
| 5922 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5923 | /* Check IP address argument. */ |
| 5924 | ret = str2prefix (ip_str, &match); |
| 5925 | if (! ret) |
| 5926 | { |
| 5927 | vty_out (vty, "address is malformed%s", VTY_NEWLINE); |
| 5928 | return CMD_WARNING; |
| 5929 | } |
| 5930 | |
| 5931 | match.family = afi2family (afi); |
| 5932 | |
| 5933 | if (safi == SAFI_MPLS_VPN) |
| 5934 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5935 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5936 | { |
| 5937 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 5938 | continue; |
| 5939 | |
| 5940 | if ((table = rn->info) != NULL) |
| 5941 | { |
| 5942 | header = 1; |
| 5943 | |
| 5944 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 5945 | { |
| 5946 | if (prefix_check && rm->p.prefixlen != match.prefixlen) |
| 5947 | continue; |
| 5948 | |
| 5949 | for (ri = rm->info; ri; ri = ri->next) |
| 5950 | { |
| 5951 | if (header) |
| 5952 | { |
| 5953 | route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p, |
| 5954 | AFI_IP, SAFI_MPLS_VPN); |
| 5955 | |
| 5956 | header = 0; |
| 5957 | } |
| 5958 | display++; |
| 5959 | route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN); |
| 5960 | } |
| 5961 | } |
| 5962 | } |
| 5963 | } |
| 5964 | } |
| 5965 | else |
| 5966 | { |
| 5967 | header = 1; |
| 5968 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5969 | if ((rn = bgp_node_match (rib, &match)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5970 | { |
| 5971 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 5972 | { |
| 5973 | for (ri = rn->info; ri; ri = ri->next) |
| 5974 | { |
| 5975 | if (header) |
| 5976 | { |
| 5977 | route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi); |
| 5978 | header = 0; |
| 5979 | } |
| 5980 | display++; |
| 5981 | route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi); |
| 5982 | } |
| 5983 | } |
| 5984 | } |
| 5985 | } |
| 5986 | |
| 5987 | if (! display) |
| 5988 | { |
| 5989 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 5990 | return CMD_WARNING; |
| 5991 | } |
| 5992 | |
| 5993 | return CMD_SUCCESS; |
| 5994 | } |
| 5995 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 5996 | /* Display specified route of Main RIB */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 5997 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 5998 | 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] | 5999 | afi_t afi, safi_t safi, struct prefix_rd *prd, |
| 6000 | int prefix_check) |
| 6001 | { |
| 6002 | struct bgp *bgp; |
| 6003 | |
| 6004 | /* BGP structure lookup. */ |
| 6005 | if (view_name) |
| 6006 | { |
| 6007 | bgp = bgp_lookup_by_name (view_name); |
| 6008 | if (bgp == NULL) |
| 6009 | { |
| 6010 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 6011 | return CMD_WARNING; |
| 6012 | } |
| 6013 | } |
| 6014 | else |
| 6015 | { |
| 6016 | bgp = bgp_get_default (); |
| 6017 | if (bgp == NULL) |
| 6018 | { |
| 6019 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 6020 | return CMD_WARNING; |
| 6021 | } |
| 6022 | } |
| 6023 | |
| 6024 | return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, |
| 6025 | afi, safi, prd, prefix_check); |
| 6026 | } |
| 6027 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6028 | /* BGP route print out function. */ |
| 6029 | DEFUN (show_ip_bgp, |
| 6030 | show_ip_bgp_cmd, |
| 6031 | "show ip bgp", |
| 6032 | SHOW_STR |
| 6033 | IP_STR |
| 6034 | BGP_STR) |
| 6035 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6036 | 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] | 6037 | } |
| 6038 | |
| 6039 | DEFUN (show_ip_bgp_ipv4, |
| 6040 | show_ip_bgp_ipv4_cmd, |
| 6041 | "show ip bgp ipv4 (unicast|multicast)", |
| 6042 | SHOW_STR |
| 6043 | IP_STR |
| 6044 | BGP_STR |
| 6045 | "Address family\n" |
| 6046 | "Address Family modifier\n" |
| 6047 | "Address Family modifier\n") |
| 6048 | { |
| 6049 | if (strncmp (argv[0], "m", 1) == 0) |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6050 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, |
| 6051 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6052 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6053 | 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] | 6054 | } |
| 6055 | |
| 6056 | DEFUN (show_ip_bgp_route, |
| 6057 | show_ip_bgp_route_cmd, |
| 6058 | "show ip bgp A.B.C.D", |
| 6059 | SHOW_STR |
| 6060 | IP_STR |
| 6061 | BGP_STR |
| 6062 | "Network in the BGP routing table to display\n") |
| 6063 | { |
| 6064 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6065 | } |
| 6066 | |
| 6067 | DEFUN (show_ip_bgp_ipv4_route, |
| 6068 | show_ip_bgp_ipv4_route_cmd, |
| 6069 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D", |
| 6070 | SHOW_STR |
| 6071 | IP_STR |
| 6072 | BGP_STR |
| 6073 | "Address family\n" |
| 6074 | "Address Family modifier\n" |
| 6075 | "Address Family modifier\n" |
| 6076 | "Network in the BGP routing table to display\n") |
| 6077 | { |
| 6078 | if (strncmp (argv[0], "m", 1) == 0) |
| 6079 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0); |
| 6080 | |
| 6081 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6082 | } |
| 6083 | |
| 6084 | DEFUN (show_ip_bgp_vpnv4_all_route, |
| 6085 | show_ip_bgp_vpnv4_all_route_cmd, |
| 6086 | "show ip bgp vpnv4 all A.B.C.D", |
| 6087 | SHOW_STR |
| 6088 | IP_STR |
| 6089 | BGP_STR |
| 6090 | "Display VPNv4 NLRI specific information\n" |
| 6091 | "Display information about all VPNv4 NLRIs\n" |
| 6092 | "Network in the BGP routing table to display\n") |
| 6093 | { |
| 6094 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0); |
| 6095 | } |
| 6096 | |
| 6097 | DEFUN (show_ip_bgp_vpnv4_rd_route, |
| 6098 | show_ip_bgp_vpnv4_rd_route_cmd, |
| 6099 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D", |
| 6100 | SHOW_STR |
| 6101 | IP_STR |
| 6102 | BGP_STR |
| 6103 | "Display VPNv4 NLRI specific information\n" |
| 6104 | "Display information for a route distinguisher\n" |
| 6105 | "VPN Route Distinguisher\n" |
| 6106 | "Network in the BGP routing table to display\n") |
| 6107 | { |
| 6108 | int ret; |
| 6109 | struct prefix_rd prd; |
| 6110 | |
| 6111 | ret = str2prefix_rd (argv[0], &prd); |
| 6112 | if (! ret) |
| 6113 | { |
| 6114 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6115 | return CMD_WARNING; |
| 6116 | } |
| 6117 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0); |
| 6118 | } |
| 6119 | |
| 6120 | DEFUN (show_ip_bgp_prefix, |
| 6121 | show_ip_bgp_prefix_cmd, |
| 6122 | "show ip bgp A.B.C.D/M", |
| 6123 | SHOW_STR |
| 6124 | IP_STR |
| 6125 | BGP_STR |
| 6126 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6127 | { |
| 6128 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6129 | } |
| 6130 | |
| 6131 | DEFUN (show_ip_bgp_ipv4_prefix, |
| 6132 | show_ip_bgp_ipv4_prefix_cmd, |
| 6133 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M", |
| 6134 | SHOW_STR |
| 6135 | IP_STR |
| 6136 | BGP_STR |
| 6137 | "Address family\n" |
| 6138 | "Address Family modifier\n" |
| 6139 | "Address Family modifier\n" |
| 6140 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6141 | { |
| 6142 | if (strncmp (argv[0], "m", 1) == 0) |
| 6143 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1); |
| 6144 | |
| 6145 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6146 | } |
| 6147 | |
| 6148 | DEFUN (show_ip_bgp_vpnv4_all_prefix, |
| 6149 | show_ip_bgp_vpnv4_all_prefix_cmd, |
| 6150 | "show ip bgp vpnv4 all A.B.C.D/M", |
| 6151 | SHOW_STR |
| 6152 | IP_STR |
| 6153 | BGP_STR |
| 6154 | "Display VPNv4 NLRI specific information\n" |
| 6155 | "Display information about all VPNv4 NLRIs\n" |
| 6156 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6157 | { |
| 6158 | return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1); |
| 6159 | } |
| 6160 | |
| 6161 | DEFUN (show_ip_bgp_vpnv4_rd_prefix, |
| 6162 | show_ip_bgp_vpnv4_rd_prefix_cmd, |
| 6163 | "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M", |
| 6164 | SHOW_STR |
| 6165 | IP_STR |
| 6166 | BGP_STR |
| 6167 | "Display VPNv4 NLRI specific information\n" |
| 6168 | "Display information for a route distinguisher\n" |
| 6169 | "VPN Route Distinguisher\n" |
| 6170 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6171 | { |
| 6172 | int ret; |
| 6173 | struct prefix_rd prd; |
| 6174 | |
| 6175 | ret = str2prefix_rd (argv[0], &prd); |
| 6176 | if (! ret) |
| 6177 | { |
| 6178 | vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); |
| 6179 | return CMD_WARNING; |
| 6180 | } |
| 6181 | return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1); |
| 6182 | } |
| 6183 | |
| 6184 | DEFUN (show_ip_bgp_view, |
| 6185 | show_ip_bgp_view_cmd, |
| 6186 | "show ip bgp view WORD", |
| 6187 | SHOW_STR |
| 6188 | IP_STR |
| 6189 | BGP_STR |
| 6190 | "BGP view\n" |
| 6191 | "BGP view name\n") |
| 6192 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6193 | struct bgp *bgp; |
| 6194 | |
| 6195 | /* BGP structure lookup. */ |
| 6196 | bgp = bgp_lookup_by_name (argv[0]); |
| 6197 | if (bgp == NULL) |
| 6198 | { |
| 6199 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6200 | return CMD_WARNING; |
| 6201 | } |
| 6202 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6203 | 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] | 6204 | } |
| 6205 | |
| 6206 | DEFUN (show_ip_bgp_view_route, |
| 6207 | show_ip_bgp_view_route_cmd, |
| 6208 | "show ip bgp view WORD A.B.C.D", |
| 6209 | SHOW_STR |
| 6210 | IP_STR |
| 6211 | BGP_STR |
| 6212 | "BGP view\n" |
| 6213 | "BGP view name\n" |
| 6214 | "Network in the BGP routing table to display\n") |
| 6215 | { |
| 6216 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); |
| 6217 | } |
| 6218 | |
| 6219 | DEFUN (show_ip_bgp_view_prefix, |
| 6220 | show_ip_bgp_view_prefix_cmd, |
| 6221 | "show ip bgp view WORD A.B.C.D/M", |
| 6222 | SHOW_STR |
| 6223 | IP_STR |
| 6224 | BGP_STR |
| 6225 | "BGP view\n" |
| 6226 | "BGP view name\n" |
| 6227 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 6228 | { |
| 6229 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); |
| 6230 | } |
| 6231 | |
| 6232 | #ifdef HAVE_IPV6 |
| 6233 | DEFUN (show_bgp, |
| 6234 | show_bgp_cmd, |
| 6235 | "show bgp", |
| 6236 | SHOW_STR |
| 6237 | BGP_STR) |
| 6238 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6239 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6240 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6241 | } |
| 6242 | |
| 6243 | ALIAS (show_bgp, |
| 6244 | show_bgp_ipv6_cmd, |
| 6245 | "show bgp ipv6", |
| 6246 | SHOW_STR |
| 6247 | BGP_STR |
| 6248 | "Address family\n") |
| 6249 | |
| 6250 | /* old command */ |
| 6251 | DEFUN (show_ipv6_bgp, |
| 6252 | show_ipv6_bgp_cmd, |
| 6253 | "show ipv6 bgp", |
| 6254 | SHOW_STR |
| 6255 | IP_STR |
| 6256 | BGP_STR) |
| 6257 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6258 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, |
| 6259 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6260 | } |
| 6261 | |
| 6262 | DEFUN (show_bgp_route, |
| 6263 | show_bgp_route_cmd, |
| 6264 | "show bgp X:X::X:X", |
| 6265 | SHOW_STR |
| 6266 | BGP_STR |
| 6267 | "Network in the BGP routing table to display\n") |
| 6268 | { |
| 6269 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6270 | } |
| 6271 | |
| 6272 | ALIAS (show_bgp_route, |
| 6273 | show_bgp_ipv6_route_cmd, |
| 6274 | "show bgp ipv6 X:X::X:X", |
| 6275 | SHOW_STR |
| 6276 | BGP_STR |
| 6277 | "Address family\n" |
| 6278 | "Network in the BGP routing table to display\n") |
| 6279 | |
| 6280 | /* old command */ |
| 6281 | DEFUN (show_ipv6_bgp_route, |
| 6282 | show_ipv6_bgp_route_cmd, |
| 6283 | "show ipv6 bgp X:X::X:X", |
| 6284 | SHOW_STR |
| 6285 | IP_STR |
| 6286 | BGP_STR |
| 6287 | "Network in the BGP routing table to display\n") |
| 6288 | { |
| 6289 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6290 | } |
| 6291 | |
| 6292 | DEFUN (show_bgp_prefix, |
| 6293 | show_bgp_prefix_cmd, |
| 6294 | "show bgp X:X::X:X/M", |
| 6295 | SHOW_STR |
| 6296 | BGP_STR |
| 6297 | "IPv6 prefix <network>/<length>\n") |
| 6298 | { |
| 6299 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6300 | } |
| 6301 | |
| 6302 | ALIAS (show_bgp_prefix, |
| 6303 | show_bgp_ipv6_prefix_cmd, |
| 6304 | "show bgp ipv6 X:X::X:X/M", |
| 6305 | SHOW_STR |
| 6306 | BGP_STR |
| 6307 | "Address family\n" |
| 6308 | "IPv6 prefix <network>/<length>\n") |
| 6309 | |
| 6310 | /* old command */ |
| 6311 | DEFUN (show_ipv6_bgp_prefix, |
| 6312 | show_ipv6_bgp_prefix_cmd, |
| 6313 | "show ipv6 bgp X:X::X:X/M", |
| 6314 | SHOW_STR |
| 6315 | IP_STR |
| 6316 | BGP_STR |
| 6317 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6318 | { |
| 6319 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6320 | } |
| 6321 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 6322 | DEFUN (show_bgp_view, |
| 6323 | show_bgp_view_cmd, |
| 6324 | "show bgp view WORD", |
| 6325 | SHOW_STR |
| 6326 | BGP_STR |
| 6327 | "BGP view\n" |
| 6328 | "View name\n") |
| 6329 | { |
| 6330 | struct bgp *bgp; |
| 6331 | |
| 6332 | /* BGP structure lookup. */ |
| 6333 | bgp = bgp_lookup_by_name (argv[0]); |
| 6334 | if (bgp == NULL) |
| 6335 | { |
| 6336 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 6337 | return CMD_WARNING; |
| 6338 | } |
| 6339 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6340 | 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] | 6341 | } |
| 6342 | |
| 6343 | ALIAS (show_bgp_view, |
| 6344 | show_bgp_view_ipv6_cmd, |
| 6345 | "show bgp view WORD ipv6", |
| 6346 | SHOW_STR |
| 6347 | BGP_STR |
| 6348 | "BGP view\n" |
| 6349 | "View name\n" |
| 6350 | "Address family\n") |
| 6351 | |
| 6352 | DEFUN (show_bgp_view_route, |
| 6353 | show_bgp_view_route_cmd, |
| 6354 | "show bgp view WORD X:X::X:X", |
| 6355 | SHOW_STR |
| 6356 | BGP_STR |
| 6357 | "BGP view\n" |
| 6358 | "View name\n" |
| 6359 | "Network in the BGP routing table to display\n") |
| 6360 | { |
| 6361 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 6362 | } |
| 6363 | |
| 6364 | ALIAS (show_bgp_view_route, |
| 6365 | show_bgp_view_ipv6_route_cmd, |
| 6366 | "show bgp view WORD ipv6 X:X::X:X", |
| 6367 | SHOW_STR |
| 6368 | BGP_STR |
| 6369 | "BGP view\n" |
| 6370 | "View name\n" |
| 6371 | "Address family\n" |
| 6372 | "Network in the BGP routing table to display\n") |
| 6373 | |
| 6374 | DEFUN (show_bgp_view_prefix, |
| 6375 | show_bgp_view_prefix_cmd, |
| 6376 | "show bgp view WORD X:X::X:X/M", |
| 6377 | SHOW_STR |
| 6378 | BGP_STR |
| 6379 | "BGP view\n" |
| 6380 | "View name\n" |
| 6381 | "IPv6 prefix <network>/<length>\n") |
| 6382 | { |
| 6383 | return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 6384 | } |
| 6385 | |
| 6386 | ALIAS (show_bgp_view_prefix, |
| 6387 | show_bgp_view_ipv6_prefix_cmd, |
| 6388 | "show bgp view WORD ipv6 X:X::X:X/M", |
| 6389 | SHOW_STR |
| 6390 | BGP_STR |
| 6391 | "BGP view\n" |
| 6392 | "View name\n" |
| 6393 | "Address family\n" |
| 6394 | "IPv6 prefix <network>/<length>\n") |
| 6395 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6396 | /* old command */ |
| 6397 | DEFUN (show_ipv6_mbgp, |
| 6398 | show_ipv6_mbgp_cmd, |
| 6399 | "show ipv6 mbgp", |
| 6400 | SHOW_STR |
| 6401 | IP_STR |
| 6402 | MBGP_STR) |
| 6403 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6404 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, |
| 6405 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6406 | } |
| 6407 | |
| 6408 | /* old command */ |
| 6409 | DEFUN (show_ipv6_mbgp_route, |
| 6410 | show_ipv6_mbgp_route_cmd, |
| 6411 | "show ipv6 mbgp X:X::X:X", |
| 6412 | SHOW_STR |
| 6413 | IP_STR |
| 6414 | MBGP_STR |
| 6415 | "Network in the MBGP routing table to display\n") |
| 6416 | { |
| 6417 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0); |
| 6418 | } |
| 6419 | |
| 6420 | /* old command */ |
| 6421 | DEFUN (show_ipv6_mbgp_prefix, |
| 6422 | show_ipv6_mbgp_prefix_cmd, |
| 6423 | "show ipv6 mbgp X:X::X:X/M", |
| 6424 | SHOW_STR |
| 6425 | IP_STR |
| 6426 | MBGP_STR |
| 6427 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 6428 | { |
| 6429 | return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); |
| 6430 | } |
| 6431 | #endif |
| 6432 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6433 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6434 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6435 | 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] | 6436 | safi_t safi, enum bgp_show_type type) |
| 6437 | { |
| 6438 | int i; |
| 6439 | struct buffer *b; |
| 6440 | char *regstr; |
| 6441 | int first; |
| 6442 | regex_t *regex; |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6443 | int rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6444 | |
| 6445 | first = 0; |
| 6446 | b = buffer_new (1024); |
| 6447 | for (i = 0; i < argc; i++) |
| 6448 | { |
| 6449 | if (first) |
| 6450 | buffer_putc (b, ' '); |
| 6451 | else |
| 6452 | { |
| 6453 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 6454 | continue; |
| 6455 | first = 1; |
| 6456 | } |
| 6457 | |
| 6458 | buffer_putstr (b, argv[i]); |
| 6459 | } |
| 6460 | buffer_putc (b, '\0'); |
| 6461 | |
| 6462 | regstr = buffer_getstr (b); |
| 6463 | buffer_free (b); |
| 6464 | |
| 6465 | regex = bgp_regcomp (regstr); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 6466 | XFREE(MTYPE_TMP, regstr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6467 | if (! regex) |
| 6468 | { |
| 6469 | vty_out (vty, "Can't compile regexp %s%s", argv[0], |
| 6470 | VTY_NEWLINE); |
| 6471 | return CMD_WARNING; |
| 6472 | } |
| 6473 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6474 | rc = bgp_show (vty, NULL, afi, safi, type, regex); |
| 6475 | bgp_regex_free (regex); |
| 6476 | return rc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6477 | } |
| 6478 | |
| 6479 | DEFUN (show_ip_bgp_regexp, |
| 6480 | show_ip_bgp_regexp_cmd, |
| 6481 | "show ip bgp regexp .LINE", |
| 6482 | SHOW_STR |
| 6483 | IP_STR |
| 6484 | BGP_STR |
| 6485 | "Display routes matching the AS path regular expression\n" |
| 6486 | "A regular-expression to match the BGP AS paths\n") |
| 6487 | { |
| 6488 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6489 | bgp_show_type_regexp); |
| 6490 | } |
| 6491 | |
| 6492 | DEFUN (show_ip_bgp_flap_regexp, |
| 6493 | show_ip_bgp_flap_regexp_cmd, |
| 6494 | "show ip bgp flap-statistics regexp .LINE", |
| 6495 | SHOW_STR |
| 6496 | IP_STR |
| 6497 | BGP_STR |
| 6498 | "Display flap statistics of routes\n" |
| 6499 | "Display routes matching the AS path regular expression\n" |
| 6500 | "A regular-expression to match the BGP AS paths\n") |
| 6501 | { |
| 6502 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6503 | bgp_show_type_flap_regexp); |
| 6504 | } |
| 6505 | |
| 6506 | DEFUN (show_ip_bgp_ipv4_regexp, |
| 6507 | show_ip_bgp_ipv4_regexp_cmd, |
| 6508 | "show ip bgp ipv4 (unicast|multicast) regexp .LINE", |
| 6509 | SHOW_STR |
| 6510 | IP_STR |
| 6511 | BGP_STR |
| 6512 | "Address family\n" |
| 6513 | "Address Family modifier\n" |
| 6514 | "Address Family modifier\n" |
| 6515 | "Display routes matching the AS path regular expression\n" |
| 6516 | "A regular-expression to match the BGP AS paths\n") |
| 6517 | { |
| 6518 | if (strncmp (argv[0], "m", 1) == 0) |
| 6519 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, |
| 6520 | bgp_show_type_regexp); |
| 6521 | |
| 6522 | return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, |
| 6523 | bgp_show_type_regexp); |
| 6524 | } |
| 6525 | |
| 6526 | #ifdef HAVE_IPV6 |
| 6527 | DEFUN (show_bgp_regexp, |
| 6528 | show_bgp_regexp_cmd, |
| 6529 | "show bgp regexp .LINE", |
| 6530 | SHOW_STR |
| 6531 | BGP_STR |
| 6532 | "Display routes matching the AS path regular expression\n" |
| 6533 | "A regular-expression to match the BGP AS paths\n") |
| 6534 | { |
| 6535 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 6536 | bgp_show_type_regexp); |
| 6537 | } |
| 6538 | |
| 6539 | ALIAS (show_bgp_regexp, |
| 6540 | show_bgp_ipv6_regexp_cmd, |
| 6541 | "show bgp ipv6 regexp .LINE", |
| 6542 | SHOW_STR |
| 6543 | BGP_STR |
| 6544 | "Address family\n" |
| 6545 | "Display routes matching the AS path regular expression\n" |
| 6546 | "A regular-expression to match the BGP AS paths\n") |
| 6547 | |
| 6548 | /* old command */ |
| 6549 | DEFUN (show_ipv6_bgp_regexp, |
| 6550 | show_ipv6_bgp_regexp_cmd, |
| 6551 | "show ipv6 bgp regexp .LINE", |
| 6552 | SHOW_STR |
| 6553 | IP_STR |
| 6554 | BGP_STR |
| 6555 | "Display routes matching the AS path regular expression\n" |
| 6556 | "A regular-expression to match the BGP AS paths\n") |
| 6557 | { |
| 6558 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, |
| 6559 | bgp_show_type_regexp); |
| 6560 | } |
| 6561 | |
| 6562 | /* old command */ |
| 6563 | DEFUN (show_ipv6_mbgp_regexp, |
| 6564 | show_ipv6_mbgp_regexp_cmd, |
| 6565 | "show ipv6 mbgp regexp .LINE", |
| 6566 | SHOW_STR |
| 6567 | IP_STR |
| 6568 | BGP_STR |
| 6569 | "Display routes matching the AS path regular expression\n" |
| 6570 | "A regular-expression to match the MBGP AS paths\n") |
| 6571 | { |
| 6572 | return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, |
| 6573 | bgp_show_type_regexp); |
| 6574 | } |
| 6575 | #endif /* HAVE_IPV6 */ |
| 6576 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6577 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6578 | 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] | 6579 | safi_t safi, enum bgp_show_type type) |
| 6580 | { |
| 6581 | struct prefix_list *plist; |
| 6582 | |
| 6583 | plist = prefix_list_lookup (afi, prefix_list_str); |
| 6584 | if (plist == NULL) |
| 6585 | { |
| 6586 | vty_out (vty, "%% %s is not a valid prefix-list name%s", |
| 6587 | prefix_list_str, VTY_NEWLINE); |
| 6588 | return CMD_WARNING; |
| 6589 | } |
| 6590 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6591 | return bgp_show (vty, NULL, afi, safi, type, plist); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6592 | } |
| 6593 | |
| 6594 | DEFUN (show_ip_bgp_prefix_list, |
| 6595 | show_ip_bgp_prefix_list_cmd, |
| 6596 | "show ip bgp prefix-list WORD", |
| 6597 | SHOW_STR |
| 6598 | IP_STR |
| 6599 | BGP_STR |
| 6600 | "Display routes conforming to the prefix-list\n" |
| 6601 | "IP prefix-list name\n") |
| 6602 | { |
| 6603 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6604 | bgp_show_type_prefix_list); |
| 6605 | } |
| 6606 | |
| 6607 | DEFUN (show_ip_bgp_flap_prefix_list, |
| 6608 | show_ip_bgp_flap_prefix_list_cmd, |
| 6609 | "show ip bgp flap-statistics prefix-list WORD", |
| 6610 | SHOW_STR |
| 6611 | IP_STR |
| 6612 | BGP_STR |
| 6613 | "Display flap statistics of routes\n" |
| 6614 | "Display routes conforming to the prefix-list\n" |
| 6615 | "IP prefix-list name\n") |
| 6616 | { |
| 6617 | return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6618 | bgp_show_type_flap_prefix_list); |
| 6619 | } |
| 6620 | |
| 6621 | DEFUN (show_ip_bgp_ipv4_prefix_list, |
| 6622 | show_ip_bgp_ipv4_prefix_list_cmd, |
| 6623 | "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", |
| 6624 | SHOW_STR |
| 6625 | IP_STR |
| 6626 | BGP_STR |
| 6627 | "Address family\n" |
| 6628 | "Address Family modifier\n" |
| 6629 | "Address Family modifier\n" |
| 6630 | "Display routes conforming to the prefix-list\n" |
| 6631 | "IP prefix-list name\n") |
| 6632 | { |
| 6633 | if (strncmp (argv[0], "m", 1) == 0) |
| 6634 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6635 | bgp_show_type_prefix_list); |
| 6636 | |
| 6637 | return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6638 | bgp_show_type_prefix_list); |
| 6639 | } |
| 6640 | |
| 6641 | #ifdef HAVE_IPV6 |
| 6642 | DEFUN (show_bgp_prefix_list, |
| 6643 | show_bgp_prefix_list_cmd, |
| 6644 | "show bgp prefix-list WORD", |
| 6645 | SHOW_STR |
| 6646 | BGP_STR |
| 6647 | "Display routes conforming to the prefix-list\n" |
| 6648 | "IPv6 prefix-list name\n") |
| 6649 | { |
| 6650 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6651 | bgp_show_type_prefix_list); |
| 6652 | } |
| 6653 | |
| 6654 | ALIAS (show_bgp_prefix_list, |
| 6655 | show_bgp_ipv6_prefix_list_cmd, |
| 6656 | "show bgp ipv6 prefix-list WORD", |
| 6657 | SHOW_STR |
| 6658 | BGP_STR |
| 6659 | "Address family\n" |
| 6660 | "Display routes conforming to the prefix-list\n" |
| 6661 | "IPv6 prefix-list name\n") |
| 6662 | |
| 6663 | /* old command */ |
| 6664 | DEFUN (show_ipv6_bgp_prefix_list, |
| 6665 | show_ipv6_bgp_prefix_list_cmd, |
| 6666 | "show ipv6 bgp prefix-list WORD", |
| 6667 | SHOW_STR |
| 6668 | IPV6_STR |
| 6669 | BGP_STR |
| 6670 | "Display routes matching the prefix-list\n" |
| 6671 | "IPv6 prefix-list name\n") |
| 6672 | { |
| 6673 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6674 | bgp_show_type_prefix_list); |
| 6675 | } |
| 6676 | |
| 6677 | /* old command */ |
| 6678 | DEFUN (show_ipv6_mbgp_prefix_list, |
| 6679 | show_ipv6_mbgp_prefix_list_cmd, |
| 6680 | "show ipv6 mbgp prefix-list WORD", |
| 6681 | SHOW_STR |
| 6682 | IPV6_STR |
| 6683 | MBGP_STR |
| 6684 | "Display routes matching the prefix-list\n" |
| 6685 | "IPv6 prefix-list name\n") |
| 6686 | { |
| 6687 | return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 6688 | bgp_show_type_prefix_list); |
| 6689 | } |
| 6690 | #endif /* HAVE_IPV6 */ |
| 6691 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6692 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6693 | bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6694 | safi_t safi, enum bgp_show_type type) |
| 6695 | { |
| 6696 | struct as_list *as_list; |
| 6697 | |
| 6698 | as_list = as_list_lookup (filter); |
| 6699 | if (as_list == NULL) |
| 6700 | { |
| 6701 | vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); |
| 6702 | return CMD_WARNING; |
| 6703 | } |
| 6704 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6705 | return bgp_show (vty, NULL, afi, safi, type, as_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6706 | } |
| 6707 | |
| 6708 | DEFUN (show_ip_bgp_filter_list, |
| 6709 | show_ip_bgp_filter_list_cmd, |
| 6710 | "show ip bgp filter-list WORD", |
| 6711 | SHOW_STR |
| 6712 | IP_STR |
| 6713 | BGP_STR |
| 6714 | "Display routes conforming to the filter-list\n" |
| 6715 | "Regular expression access list name\n") |
| 6716 | { |
| 6717 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6718 | bgp_show_type_filter_list); |
| 6719 | } |
| 6720 | |
| 6721 | DEFUN (show_ip_bgp_flap_filter_list, |
| 6722 | show_ip_bgp_flap_filter_list_cmd, |
| 6723 | "show ip bgp flap-statistics filter-list WORD", |
| 6724 | SHOW_STR |
| 6725 | IP_STR |
| 6726 | BGP_STR |
| 6727 | "Display flap statistics of routes\n" |
| 6728 | "Display routes conforming to the filter-list\n" |
| 6729 | "Regular expression access list name\n") |
| 6730 | { |
| 6731 | return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6732 | bgp_show_type_flap_filter_list); |
| 6733 | } |
| 6734 | |
| 6735 | DEFUN (show_ip_bgp_ipv4_filter_list, |
| 6736 | show_ip_bgp_ipv4_filter_list_cmd, |
| 6737 | "show ip bgp ipv4 (unicast|multicast) filter-list WORD", |
| 6738 | SHOW_STR |
| 6739 | IP_STR |
| 6740 | BGP_STR |
| 6741 | "Address family\n" |
| 6742 | "Address Family modifier\n" |
| 6743 | "Address Family modifier\n" |
| 6744 | "Display routes conforming to the filter-list\n" |
| 6745 | "Regular expression access list name\n") |
| 6746 | { |
| 6747 | if (strncmp (argv[0], "m", 1) == 0) |
| 6748 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6749 | bgp_show_type_filter_list); |
| 6750 | |
| 6751 | return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6752 | bgp_show_type_filter_list); |
| 6753 | } |
| 6754 | |
| 6755 | #ifdef HAVE_IPV6 |
| 6756 | DEFUN (show_bgp_filter_list, |
| 6757 | show_bgp_filter_list_cmd, |
| 6758 | "show bgp filter-list WORD", |
| 6759 | SHOW_STR |
| 6760 | BGP_STR |
| 6761 | "Display routes conforming to the filter-list\n" |
| 6762 | "Regular expression access list name\n") |
| 6763 | { |
| 6764 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6765 | bgp_show_type_filter_list); |
| 6766 | } |
| 6767 | |
| 6768 | ALIAS (show_bgp_filter_list, |
| 6769 | show_bgp_ipv6_filter_list_cmd, |
| 6770 | "show bgp ipv6 filter-list WORD", |
| 6771 | SHOW_STR |
| 6772 | BGP_STR |
| 6773 | "Address family\n" |
| 6774 | "Display routes conforming to the filter-list\n" |
| 6775 | "Regular expression access list name\n") |
| 6776 | |
| 6777 | /* old command */ |
| 6778 | DEFUN (show_ipv6_bgp_filter_list, |
| 6779 | show_ipv6_bgp_filter_list_cmd, |
| 6780 | "show ipv6 bgp filter-list WORD", |
| 6781 | SHOW_STR |
| 6782 | IPV6_STR |
| 6783 | BGP_STR |
| 6784 | "Display routes conforming to the filter-list\n" |
| 6785 | "Regular expression access list name\n") |
| 6786 | { |
| 6787 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6788 | bgp_show_type_filter_list); |
| 6789 | } |
| 6790 | |
| 6791 | /* old command */ |
| 6792 | DEFUN (show_ipv6_mbgp_filter_list, |
| 6793 | show_ipv6_mbgp_filter_list_cmd, |
| 6794 | "show ipv6 mbgp filter-list WORD", |
| 6795 | SHOW_STR |
| 6796 | IPV6_STR |
| 6797 | MBGP_STR |
| 6798 | "Display routes conforming to the filter-list\n" |
| 6799 | "Regular expression access list name\n") |
| 6800 | { |
| 6801 | return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 6802 | bgp_show_type_filter_list); |
| 6803 | } |
| 6804 | #endif /* HAVE_IPV6 */ |
| 6805 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 6806 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 6807 | 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] | 6808 | safi_t safi, enum bgp_show_type type) |
| 6809 | { |
| 6810 | struct route_map *rmap; |
| 6811 | |
| 6812 | rmap = route_map_lookup_by_name (rmap_str); |
| 6813 | if (! rmap) |
| 6814 | { |
| 6815 | vty_out (vty, "%% %s is not a valid route-map name%s", |
| 6816 | rmap_str, VTY_NEWLINE); |
| 6817 | return CMD_WARNING; |
| 6818 | } |
| 6819 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6820 | return bgp_show (vty, NULL, afi, safi, type, rmap); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6821 | } |
| 6822 | |
| 6823 | DEFUN (show_ip_bgp_route_map, |
| 6824 | show_ip_bgp_route_map_cmd, |
| 6825 | "show ip bgp route-map WORD", |
| 6826 | SHOW_STR |
| 6827 | IP_STR |
| 6828 | BGP_STR |
| 6829 | "Display routes matching the route-map\n" |
| 6830 | "A route-map to match on\n") |
| 6831 | { |
| 6832 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6833 | bgp_show_type_route_map); |
| 6834 | } |
| 6835 | |
| 6836 | DEFUN (show_ip_bgp_flap_route_map, |
| 6837 | show_ip_bgp_flap_route_map_cmd, |
| 6838 | "show ip bgp flap-statistics route-map WORD", |
| 6839 | SHOW_STR |
| 6840 | IP_STR |
| 6841 | BGP_STR |
| 6842 | "Display flap statistics of routes\n" |
| 6843 | "Display routes matching the route-map\n" |
| 6844 | "A route-map to match on\n") |
| 6845 | { |
| 6846 | return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 6847 | bgp_show_type_flap_route_map); |
| 6848 | } |
| 6849 | |
| 6850 | DEFUN (show_ip_bgp_ipv4_route_map, |
| 6851 | show_ip_bgp_ipv4_route_map_cmd, |
| 6852 | "show ip bgp ipv4 (unicast|multicast) route-map WORD", |
| 6853 | SHOW_STR |
| 6854 | IP_STR |
| 6855 | BGP_STR |
| 6856 | "Address family\n" |
| 6857 | "Address Family modifier\n" |
| 6858 | "Address Family modifier\n" |
| 6859 | "Display routes matching the route-map\n" |
| 6860 | "A route-map to match on\n") |
| 6861 | { |
| 6862 | if (strncmp (argv[0], "m", 1) == 0) |
| 6863 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 6864 | bgp_show_type_route_map); |
| 6865 | |
| 6866 | return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 6867 | bgp_show_type_route_map); |
| 6868 | } |
| 6869 | |
| 6870 | DEFUN (show_bgp_route_map, |
| 6871 | show_bgp_route_map_cmd, |
| 6872 | "show bgp route-map WORD", |
| 6873 | SHOW_STR |
| 6874 | BGP_STR |
| 6875 | "Display routes matching the route-map\n" |
| 6876 | "A route-map to match on\n") |
| 6877 | { |
| 6878 | return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 6879 | bgp_show_type_route_map); |
| 6880 | } |
| 6881 | |
| 6882 | ALIAS (show_bgp_route_map, |
| 6883 | show_bgp_ipv6_route_map_cmd, |
| 6884 | "show bgp ipv6 route-map WORD", |
| 6885 | SHOW_STR |
| 6886 | BGP_STR |
| 6887 | "Address family\n" |
| 6888 | "Display routes matching the route-map\n" |
| 6889 | "A route-map to match on\n") |
| 6890 | |
| 6891 | DEFUN (show_ip_bgp_cidr_only, |
| 6892 | show_ip_bgp_cidr_only_cmd, |
| 6893 | "show ip bgp cidr-only", |
| 6894 | SHOW_STR |
| 6895 | IP_STR |
| 6896 | BGP_STR |
| 6897 | "Display only routes with non-natural netmasks\n") |
| 6898 | { |
| 6899 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6900 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6901 | } |
| 6902 | |
| 6903 | DEFUN (show_ip_bgp_flap_cidr_only, |
| 6904 | show_ip_bgp_flap_cidr_only_cmd, |
| 6905 | "show ip bgp flap-statistics cidr-only", |
| 6906 | SHOW_STR |
| 6907 | IP_STR |
| 6908 | BGP_STR |
| 6909 | "Display flap statistics of routes\n" |
| 6910 | "Display only routes with non-natural netmasks\n") |
| 6911 | { |
| 6912 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6913 | bgp_show_type_flap_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6914 | } |
| 6915 | |
| 6916 | DEFUN (show_ip_bgp_ipv4_cidr_only, |
| 6917 | show_ip_bgp_ipv4_cidr_only_cmd, |
| 6918 | "show ip bgp ipv4 (unicast|multicast) cidr-only", |
| 6919 | SHOW_STR |
| 6920 | IP_STR |
| 6921 | BGP_STR |
| 6922 | "Address family\n" |
| 6923 | "Address Family modifier\n" |
| 6924 | "Address Family modifier\n" |
| 6925 | "Display only routes with non-natural netmasks\n") |
| 6926 | { |
| 6927 | if (strncmp (argv[0], "m", 1) == 0) |
| 6928 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6929 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6930 | |
| 6931 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6932 | bgp_show_type_cidr_only, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6933 | } |
| 6934 | |
| 6935 | DEFUN (show_ip_bgp_community_all, |
| 6936 | show_ip_bgp_community_all_cmd, |
| 6937 | "show ip bgp community", |
| 6938 | SHOW_STR |
| 6939 | IP_STR |
| 6940 | BGP_STR |
| 6941 | "Display routes matching the communities\n") |
| 6942 | { |
| 6943 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6944 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6945 | } |
| 6946 | |
| 6947 | DEFUN (show_ip_bgp_ipv4_community_all, |
| 6948 | show_ip_bgp_ipv4_community_all_cmd, |
| 6949 | "show ip bgp ipv4 (unicast|multicast) community", |
| 6950 | SHOW_STR |
| 6951 | IP_STR |
| 6952 | BGP_STR |
| 6953 | "Address family\n" |
| 6954 | "Address Family modifier\n" |
| 6955 | "Address Family modifier\n" |
| 6956 | "Display routes matching the communities\n") |
| 6957 | { |
| 6958 | if (strncmp (argv[0], "m", 1) == 0) |
| 6959 | return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6960 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6961 | |
| 6962 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6963 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6964 | } |
| 6965 | |
| 6966 | #ifdef HAVE_IPV6 |
| 6967 | DEFUN (show_bgp_community_all, |
| 6968 | show_bgp_community_all_cmd, |
| 6969 | "show bgp community", |
| 6970 | SHOW_STR |
| 6971 | BGP_STR |
| 6972 | "Display routes matching the communities\n") |
| 6973 | { |
| 6974 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6975 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6976 | } |
| 6977 | |
| 6978 | ALIAS (show_bgp_community_all, |
| 6979 | show_bgp_ipv6_community_all_cmd, |
| 6980 | "show bgp ipv6 community", |
| 6981 | SHOW_STR |
| 6982 | BGP_STR |
| 6983 | "Address family\n" |
| 6984 | "Display routes matching the communities\n") |
| 6985 | |
| 6986 | /* old command */ |
| 6987 | DEFUN (show_ipv6_bgp_community_all, |
| 6988 | show_ipv6_bgp_community_all_cmd, |
| 6989 | "show ipv6 bgp community", |
| 6990 | SHOW_STR |
| 6991 | IPV6_STR |
| 6992 | BGP_STR |
| 6993 | "Display routes matching the communities\n") |
| 6994 | { |
| 6995 | return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 6996 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6997 | } |
| 6998 | |
| 6999 | /* old command */ |
| 7000 | DEFUN (show_ipv6_mbgp_community_all, |
| 7001 | show_ipv6_mbgp_community_all_cmd, |
| 7002 | "show ipv6 mbgp community", |
| 7003 | SHOW_STR |
| 7004 | IPV6_STR |
| 7005 | MBGP_STR |
| 7006 | "Display routes matching the communities\n") |
| 7007 | { |
| 7008 | return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7009 | bgp_show_type_community_all, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7010 | } |
| 7011 | #endif /* HAVE_IPV6 */ |
| 7012 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 7013 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 7014 | bgp_show_community (struct vty *vty, int argc, const char **argv, int exact, |
| 7015 | u_int16_t afi, u_char safi) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7016 | { |
| 7017 | struct community *com; |
| 7018 | struct buffer *b; |
| 7019 | int i; |
| 7020 | char *str; |
| 7021 | int first = 0; |
| 7022 | |
| 7023 | b = buffer_new (1024); |
| 7024 | for (i = 0; i < argc; i++) |
| 7025 | { |
| 7026 | if (first) |
| 7027 | buffer_putc (b, ' '); |
| 7028 | else |
| 7029 | { |
| 7030 | if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0)) |
| 7031 | continue; |
| 7032 | first = 1; |
| 7033 | } |
| 7034 | |
| 7035 | buffer_putstr (b, argv[i]); |
| 7036 | } |
| 7037 | buffer_putc (b, '\0'); |
| 7038 | |
| 7039 | str = buffer_getstr (b); |
| 7040 | buffer_free (b); |
| 7041 | |
| 7042 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 7043 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7044 | if (! com) |
| 7045 | { |
| 7046 | vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); |
| 7047 | return CMD_WARNING; |
| 7048 | } |
| 7049 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 7050 | return bgp_show (vty, NULL, afi, safi, |
| 7051 | (exact ? bgp_show_type_community_exact : |
| 7052 | bgp_show_type_community), com); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7053 | } |
| 7054 | |
| 7055 | DEFUN (show_ip_bgp_community, |
| 7056 | show_ip_bgp_community_cmd, |
| 7057 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7058 | SHOW_STR |
| 7059 | IP_STR |
| 7060 | BGP_STR |
| 7061 | "Display routes matching the communities\n" |
| 7062 | "community number\n" |
| 7063 | "Do not send outside local AS (well-known community)\n" |
| 7064 | "Do not advertise to any peer (well-known community)\n" |
| 7065 | "Do not export to next AS (well-known community)\n") |
| 7066 | { |
| 7067 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 7068 | } |
| 7069 | |
| 7070 | ALIAS (show_ip_bgp_community, |
| 7071 | show_ip_bgp_community2_cmd, |
| 7072 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7073 | SHOW_STR |
| 7074 | IP_STR |
| 7075 | BGP_STR |
| 7076 | "Display routes matching the communities\n" |
| 7077 | "community number\n" |
| 7078 | "Do not send outside local AS (well-known community)\n" |
| 7079 | "Do not advertise to any peer (well-known community)\n" |
| 7080 | "Do not export to next AS (well-known community)\n" |
| 7081 | "community number\n" |
| 7082 | "Do not send outside local AS (well-known community)\n" |
| 7083 | "Do not advertise to any peer (well-known community)\n" |
| 7084 | "Do not export to next AS (well-known community)\n") |
| 7085 | |
| 7086 | ALIAS (show_ip_bgp_community, |
| 7087 | show_ip_bgp_community3_cmd, |
| 7088 | "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)", |
| 7089 | SHOW_STR |
| 7090 | IP_STR |
| 7091 | BGP_STR |
| 7092 | "Display routes matching the communities\n" |
| 7093 | "community number\n" |
| 7094 | "Do not send outside local AS (well-known community)\n" |
| 7095 | "Do not advertise to any peer (well-known community)\n" |
| 7096 | "Do not export to next AS (well-known community)\n" |
| 7097 | "community number\n" |
| 7098 | "Do not send outside local AS (well-known community)\n" |
| 7099 | "Do not advertise to any peer (well-known community)\n" |
| 7100 | "Do not export to next AS (well-known community)\n" |
| 7101 | "community number\n" |
| 7102 | "Do not send outside local AS (well-known community)\n" |
| 7103 | "Do not advertise to any peer (well-known community)\n" |
| 7104 | "Do not export to next AS (well-known community)\n") |
| 7105 | |
| 7106 | ALIAS (show_ip_bgp_community, |
| 7107 | show_ip_bgp_community4_cmd, |
| 7108 | "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)", |
| 7109 | SHOW_STR |
| 7110 | IP_STR |
| 7111 | BGP_STR |
| 7112 | "Display routes matching the communities\n" |
| 7113 | "community number\n" |
| 7114 | "Do not send outside local AS (well-known community)\n" |
| 7115 | "Do not advertise to any peer (well-known community)\n" |
| 7116 | "Do not export to next AS (well-known community)\n" |
| 7117 | "community number\n" |
| 7118 | "Do not send outside local AS (well-known community)\n" |
| 7119 | "Do not advertise to any peer (well-known community)\n" |
| 7120 | "Do not export to next AS (well-known community)\n" |
| 7121 | "community number\n" |
| 7122 | "Do not send outside local AS (well-known community)\n" |
| 7123 | "Do not advertise to any peer (well-known community)\n" |
| 7124 | "Do not export to next AS (well-known community)\n" |
| 7125 | "community number\n" |
| 7126 | "Do not send outside local AS (well-known community)\n" |
| 7127 | "Do not advertise to any peer (well-known community)\n" |
| 7128 | "Do not export to next AS (well-known community)\n") |
| 7129 | |
| 7130 | DEFUN (show_ip_bgp_ipv4_community, |
| 7131 | show_ip_bgp_ipv4_community_cmd, |
| 7132 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", |
| 7133 | SHOW_STR |
| 7134 | IP_STR |
| 7135 | BGP_STR |
| 7136 | "Address family\n" |
| 7137 | "Address Family modifier\n" |
| 7138 | "Address Family modifier\n" |
| 7139 | "Display routes matching the communities\n" |
| 7140 | "community number\n" |
| 7141 | "Do not send outside local AS (well-known community)\n" |
| 7142 | "Do not advertise to any peer (well-known community)\n" |
| 7143 | "Do not export to next AS (well-known community)\n") |
| 7144 | { |
| 7145 | if (strncmp (argv[0], "m", 1) == 0) |
| 7146 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST); |
| 7147 | |
| 7148 | return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); |
| 7149 | } |
| 7150 | |
| 7151 | ALIAS (show_ip_bgp_ipv4_community, |
| 7152 | show_ip_bgp_ipv4_community2_cmd, |
| 7153 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7154 | SHOW_STR |
| 7155 | IP_STR |
| 7156 | BGP_STR |
| 7157 | "Address family\n" |
| 7158 | "Address Family modifier\n" |
| 7159 | "Address Family modifier\n" |
| 7160 | "Display routes matching the communities\n" |
| 7161 | "community number\n" |
| 7162 | "Do not send outside local AS (well-known community)\n" |
| 7163 | "Do not advertise to any peer (well-known community)\n" |
| 7164 | "Do not export to next AS (well-known community)\n" |
| 7165 | "community number\n" |
| 7166 | "Do not send outside local AS (well-known community)\n" |
| 7167 | "Do not advertise to any peer (well-known community)\n" |
| 7168 | "Do not export to next AS (well-known community)\n") |
| 7169 | |
| 7170 | ALIAS (show_ip_bgp_ipv4_community, |
| 7171 | show_ip_bgp_ipv4_community3_cmd, |
| 7172 | "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)", |
| 7173 | SHOW_STR |
| 7174 | IP_STR |
| 7175 | BGP_STR |
| 7176 | "Address family\n" |
| 7177 | "Address Family modifier\n" |
| 7178 | "Address Family modifier\n" |
| 7179 | "Display routes matching the communities\n" |
| 7180 | "community number\n" |
| 7181 | "Do not send outside local AS (well-known community)\n" |
| 7182 | "Do not advertise to any peer (well-known community)\n" |
| 7183 | "Do not export to next AS (well-known community)\n" |
| 7184 | "community number\n" |
| 7185 | "Do not send outside local AS (well-known community)\n" |
| 7186 | "Do not advertise to any peer (well-known community)\n" |
| 7187 | "Do not export to next AS (well-known community)\n" |
| 7188 | "community number\n" |
| 7189 | "Do not send outside local AS (well-known community)\n" |
| 7190 | "Do not advertise to any peer (well-known community)\n" |
| 7191 | "Do not export to next AS (well-known community)\n") |
| 7192 | |
| 7193 | ALIAS (show_ip_bgp_ipv4_community, |
| 7194 | show_ip_bgp_ipv4_community4_cmd, |
| 7195 | "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)", |
| 7196 | SHOW_STR |
| 7197 | IP_STR |
| 7198 | BGP_STR |
| 7199 | "Address family\n" |
| 7200 | "Address Family modifier\n" |
| 7201 | "Address Family modifier\n" |
| 7202 | "Display routes matching the communities\n" |
| 7203 | "community number\n" |
| 7204 | "Do not send outside local AS (well-known community)\n" |
| 7205 | "Do not advertise to any peer (well-known community)\n" |
| 7206 | "Do not export to next AS (well-known community)\n" |
| 7207 | "community number\n" |
| 7208 | "Do not send outside local AS (well-known community)\n" |
| 7209 | "Do not advertise to any peer (well-known community)\n" |
| 7210 | "Do not export to next AS (well-known community)\n" |
| 7211 | "community number\n" |
| 7212 | "Do not send outside local AS (well-known community)\n" |
| 7213 | "Do not advertise to any peer (well-known community)\n" |
| 7214 | "Do not export to next AS (well-known community)\n" |
| 7215 | "community number\n" |
| 7216 | "Do not send outside local AS (well-known community)\n" |
| 7217 | "Do not advertise to any peer (well-known community)\n" |
| 7218 | "Do not export to next AS (well-known community)\n") |
| 7219 | |
| 7220 | DEFUN (show_ip_bgp_community_exact, |
| 7221 | show_ip_bgp_community_exact_cmd, |
| 7222 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7223 | SHOW_STR |
| 7224 | IP_STR |
| 7225 | BGP_STR |
| 7226 | "Display routes matching the communities\n" |
| 7227 | "community number\n" |
| 7228 | "Do not send outside local AS (well-known community)\n" |
| 7229 | "Do not advertise to any peer (well-known community)\n" |
| 7230 | "Do not export to next AS (well-known community)\n" |
| 7231 | "Exact match of the communities") |
| 7232 | { |
| 7233 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 7234 | } |
| 7235 | |
| 7236 | ALIAS (show_ip_bgp_community_exact, |
| 7237 | show_ip_bgp_community2_exact_cmd, |
| 7238 | "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7239 | SHOW_STR |
| 7240 | IP_STR |
| 7241 | BGP_STR |
| 7242 | "Display routes matching the communities\n" |
| 7243 | "community number\n" |
| 7244 | "Do not send outside local AS (well-known community)\n" |
| 7245 | "Do not advertise to any peer (well-known community)\n" |
| 7246 | "Do not export to next AS (well-known community)\n" |
| 7247 | "community number\n" |
| 7248 | "Do not send outside local AS (well-known community)\n" |
| 7249 | "Do not advertise to any peer (well-known community)\n" |
| 7250 | "Do not export to next AS (well-known community)\n" |
| 7251 | "Exact match of the communities") |
| 7252 | |
| 7253 | ALIAS (show_ip_bgp_community_exact, |
| 7254 | show_ip_bgp_community3_exact_cmd, |
| 7255 | "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", |
| 7256 | SHOW_STR |
| 7257 | IP_STR |
| 7258 | BGP_STR |
| 7259 | "Display routes matching the communities\n" |
| 7260 | "community number\n" |
| 7261 | "Do not send outside local AS (well-known community)\n" |
| 7262 | "Do not advertise to any peer (well-known community)\n" |
| 7263 | "Do not export to next AS (well-known community)\n" |
| 7264 | "community number\n" |
| 7265 | "Do not send outside local AS (well-known community)\n" |
| 7266 | "Do not advertise to any peer (well-known community)\n" |
| 7267 | "Do not export to next AS (well-known community)\n" |
| 7268 | "community number\n" |
| 7269 | "Do not send outside local AS (well-known community)\n" |
| 7270 | "Do not advertise to any peer (well-known community)\n" |
| 7271 | "Do not export to next AS (well-known community)\n" |
| 7272 | "Exact match of the communities") |
| 7273 | |
| 7274 | ALIAS (show_ip_bgp_community_exact, |
| 7275 | show_ip_bgp_community4_exact_cmd, |
| 7276 | "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", |
| 7277 | SHOW_STR |
| 7278 | IP_STR |
| 7279 | BGP_STR |
| 7280 | "Display routes matching the communities\n" |
| 7281 | "community number\n" |
| 7282 | "Do not send outside local AS (well-known community)\n" |
| 7283 | "Do not advertise to any peer (well-known community)\n" |
| 7284 | "Do not export to next AS (well-known community)\n" |
| 7285 | "community number\n" |
| 7286 | "Do not send outside local AS (well-known community)\n" |
| 7287 | "Do not advertise to any peer (well-known community)\n" |
| 7288 | "Do not export to next AS (well-known community)\n" |
| 7289 | "community number\n" |
| 7290 | "Do not send outside local AS (well-known community)\n" |
| 7291 | "Do not advertise to any peer (well-known community)\n" |
| 7292 | "Do not export to next AS (well-known community)\n" |
| 7293 | "community number\n" |
| 7294 | "Do not send outside local AS (well-known community)\n" |
| 7295 | "Do not advertise to any peer (well-known community)\n" |
| 7296 | "Do not export to next AS (well-known community)\n" |
| 7297 | "Exact match of the communities") |
| 7298 | |
| 7299 | DEFUN (show_ip_bgp_ipv4_community_exact, |
| 7300 | show_ip_bgp_ipv4_community_exact_cmd, |
| 7301 | "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7302 | SHOW_STR |
| 7303 | IP_STR |
| 7304 | BGP_STR |
| 7305 | "Address family\n" |
| 7306 | "Address Family modifier\n" |
| 7307 | "Address Family modifier\n" |
| 7308 | "Display routes matching the communities\n" |
| 7309 | "community number\n" |
| 7310 | "Do not send outside local AS (well-known community)\n" |
| 7311 | "Do not advertise to any peer (well-known community)\n" |
| 7312 | "Do not export to next AS (well-known community)\n" |
| 7313 | "Exact match of the communities") |
| 7314 | { |
| 7315 | if (strncmp (argv[0], "m", 1) == 0) |
| 7316 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST); |
| 7317 | |
| 7318 | return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); |
| 7319 | } |
| 7320 | |
| 7321 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7322 | show_ip_bgp_ipv4_community2_exact_cmd, |
| 7323 | "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", |
| 7324 | SHOW_STR |
| 7325 | IP_STR |
| 7326 | BGP_STR |
| 7327 | "Address family\n" |
| 7328 | "Address Family modifier\n" |
| 7329 | "Address Family modifier\n" |
| 7330 | "Display routes matching the communities\n" |
| 7331 | "community number\n" |
| 7332 | "Do not send outside local AS (well-known community)\n" |
| 7333 | "Do not advertise to any peer (well-known community)\n" |
| 7334 | "Do not export to next AS (well-known community)\n" |
| 7335 | "community number\n" |
| 7336 | "Do not send outside local AS (well-known community)\n" |
| 7337 | "Do not advertise to any peer (well-known community)\n" |
| 7338 | "Do not export to next AS (well-known community)\n" |
| 7339 | "Exact match of the communities") |
| 7340 | |
| 7341 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7342 | show_ip_bgp_ipv4_community3_exact_cmd, |
| 7343 | "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", |
| 7344 | SHOW_STR |
| 7345 | IP_STR |
| 7346 | BGP_STR |
| 7347 | "Address family\n" |
| 7348 | "Address Family modifier\n" |
| 7349 | "Address Family modifier\n" |
| 7350 | "Display routes matching the communities\n" |
| 7351 | "community number\n" |
| 7352 | "Do not send outside local AS (well-known community)\n" |
| 7353 | "Do not advertise to any peer (well-known community)\n" |
| 7354 | "Do not export to next AS (well-known community)\n" |
| 7355 | "community number\n" |
| 7356 | "Do not send outside local AS (well-known community)\n" |
| 7357 | "Do not advertise to any peer (well-known community)\n" |
| 7358 | "Do not export to next AS (well-known community)\n" |
| 7359 | "community number\n" |
| 7360 | "Do not send outside local AS (well-known community)\n" |
| 7361 | "Do not advertise to any peer (well-known community)\n" |
| 7362 | "Do not export to next AS (well-known community)\n" |
| 7363 | "Exact match of the communities") |
| 7364 | |
| 7365 | ALIAS (show_ip_bgp_ipv4_community_exact, |
| 7366 | show_ip_bgp_ipv4_community4_exact_cmd, |
| 7367 | "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", |
| 7368 | SHOW_STR |
| 7369 | IP_STR |
| 7370 | BGP_STR |
| 7371 | "Address family\n" |
| 7372 | "Address Family modifier\n" |
| 7373 | "Address Family modifier\n" |
| 7374 | "Display routes matching the communities\n" |
| 7375 | "community number\n" |
| 7376 | "Do not send outside local AS (well-known community)\n" |
| 7377 | "Do not advertise to any peer (well-known community)\n" |
| 7378 | "Do not export to next AS (well-known community)\n" |
| 7379 | "community number\n" |
| 7380 | "Do not send outside local AS (well-known community)\n" |
| 7381 | "Do not advertise to any peer (well-known community)\n" |
| 7382 | "Do not export to next AS (well-known community)\n" |
| 7383 | "community number\n" |
| 7384 | "Do not send outside local AS (well-known community)\n" |
| 7385 | "Do not advertise to any peer (well-known community)\n" |
| 7386 | "Do not export to next AS (well-known community)\n" |
| 7387 | "community number\n" |
| 7388 | "Do not send outside local AS (well-known community)\n" |
| 7389 | "Do not advertise to any peer (well-known community)\n" |
| 7390 | "Do not export to next AS (well-known community)\n" |
| 7391 | "Exact match of the communities") |
| 7392 | |
| 7393 | #ifdef HAVE_IPV6 |
| 7394 | DEFUN (show_bgp_community, |
| 7395 | show_bgp_community_cmd, |
| 7396 | "show bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7397 | SHOW_STR |
| 7398 | BGP_STR |
| 7399 | "Display routes matching the communities\n" |
| 7400 | "community number\n" |
| 7401 | "Do not send outside local AS (well-known community)\n" |
| 7402 | "Do not advertise to any peer (well-known community)\n" |
| 7403 | "Do not export to next AS (well-known community)\n") |
| 7404 | { |
| 7405 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 7406 | } |
| 7407 | |
| 7408 | ALIAS (show_bgp_community, |
| 7409 | show_bgp_ipv6_community_cmd, |
| 7410 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", |
| 7411 | SHOW_STR |
| 7412 | BGP_STR |
| 7413 | "Address family\n" |
| 7414 | "Display routes matching the communities\n" |
| 7415 | "community number\n" |
| 7416 | "Do not send outside local AS (well-known community)\n" |
| 7417 | "Do not advertise to any peer (well-known community)\n" |
| 7418 | "Do not export to next AS (well-known community)\n") |
| 7419 | |
| 7420 | ALIAS (show_bgp_community, |
| 7421 | show_bgp_community2_cmd, |
| 7422 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7423 | SHOW_STR |
| 7424 | BGP_STR |
| 7425 | "Display routes matching the communities\n" |
| 7426 | "community number\n" |
| 7427 | "Do not send outside local AS (well-known community)\n" |
| 7428 | "Do not advertise to any peer (well-known community)\n" |
| 7429 | "Do not export to next AS (well-known community)\n" |
| 7430 | "community number\n" |
| 7431 | "Do not send outside local AS (well-known community)\n" |
| 7432 | "Do not advertise to any peer (well-known community)\n" |
| 7433 | "Do not export to next AS (well-known community)\n") |
| 7434 | |
| 7435 | ALIAS (show_bgp_community, |
| 7436 | show_bgp_ipv6_community2_cmd, |
| 7437 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7438 | SHOW_STR |
| 7439 | BGP_STR |
| 7440 | "Address family\n" |
| 7441 | "Display routes matching the communities\n" |
| 7442 | "community number\n" |
| 7443 | "Do not send outside local AS (well-known community)\n" |
| 7444 | "Do not advertise to any peer (well-known community)\n" |
| 7445 | "Do not export to next AS (well-known community)\n" |
| 7446 | "community number\n" |
| 7447 | "Do not send outside local AS (well-known community)\n" |
| 7448 | "Do not advertise to any peer (well-known community)\n" |
| 7449 | "Do not export to next AS (well-known community)\n") |
| 7450 | |
| 7451 | ALIAS (show_bgp_community, |
| 7452 | show_bgp_community3_cmd, |
| 7453 | "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)", |
| 7454 | SHOW_STR |
| 7455 | BGP_STR |
| 7456 | "Display routes matching the communities\n" |
| 7457 | "community number\n" |
| 7458 | "Do not send outside local AS (well-known community)\n" |
| 7459 | "Do not advertise to any peer (well-known community)\n" |
| 7460 | "Do not export to next AS (well-known community)\n" |
| 7461 | "community number\n" |
| 7462 | "Do not send outside local AS (well-known community)\n" |
| 7463 | "Do not advertise to any peer (well-known community)\n" |
| 7464 | "Do not export to next AS (well-known community)\n" |
| 7465 | "community number\n" |
| 7466 | "Do not send outside local AS (well-known community)\n" |
| 7467 | "Do not advertise to any peer (well-known community)\n" |
| 7468 | "Do not export to next AS (well-known community)\n") |
| 7469 | |
| 7470 | ALIAS (show_bgp_community, |
| 7471 | show_bgp_ipv6_community3_cmd, |
| 7472 | "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)", |
| 7473 | SHOW_STR |
| 7474 | BGP_STR |
| 7475 | "Address family\n" |
| 7476 | "Display routes matching the communities\n" |
| 7477 | "community number\n" |
| 7478 | "Do not send outside local AS (well-known community)\n" |
| 7479 | "Do not advertise to any peer (well-known community)\n" |
| 7480 | "Do not export to next AS (well-known community)\n" |
| 7481 | "community number\n" |
| 7482 | "Do not send outside local AS (well-known community)\n" |
| 7483 | "Do not advertise to any peer (well-known community)\n" |
| 7484 | "Do not export to next AS (well-known community)\n" |
| 7485 | "community number\n" |
| 7486 | "Do not send outside local AS (well-known community)\n" |
| 7487 | "Do not advertise to any peer (well-known community)\n" |
| 7488 | "Do not export to next AS (well-known community)\n") |
| 7489 | |
| 7490 | ALIAS (show_bgp_community, |
| 7491 | show_bgp_community4_cmd, |
| 7492 | "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)", |
| 7493 | SHOW_STR |
| 7494 | BGP_STR |
| 7495 | "Display routes matching the communities\n" |
| 7496 | "community number\n" |
| 7497 | "Do not send outside local AS (well-known community)\n" |
| 7498 | "Do not advertise to any peer (well-known community)\n" |
| 7499 | "Do not export to next AS (well-known community)\n" |
| 7500 | "community number\n" |
| 7501 | "Do not send outside local AS (well-known community)\n" |
| 7502 | "Do not advertise to any peer (well-known community)\n" |
| 7503 | "Do not export to next AS (well-known community)\n" |
| 7504 | "community number\n" |
| 7505 | "Do not send outside local AS (well-known community)\n" |
| 7506 | "Do not advertise to any peer (well-known community)\n" |
| 7507 | "Do not export to next AS (well-known community)\n" |
| 7508 | "community number\n" |
| 7509 | "Do not send outside local AS (well-known community)\n" |
| 7510 | "Do not advertise to any peer (well-known community)\n" |
| 7511 | "Do not export to next AS (well-known community)\n") |
| 7512 | |
| 7513 | ALIAS (show_bgp_community, |
| 7514 | show_bgp_ipv6_community4_cmd, |
| 7515 | "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)", |
| 7516 | SHOW_STR |
| 7517 | BGP_STR |
| 7518 | "Address family\n" |
| 7519 | "Display routes matching the communities\n" |
| 7520 | "community number\n" |
| 7521 | "Do not send outside local AS (well-known community)\n" |
| 7522 | "Do not advertise to any peer (well-known community)\n" |
| 7523 | "Do not export to next AS (well-known community)\n" |
| 7524 | "community number\n" |
| 7525 | "Do not send outside local AS (well-known community)\n" |
| 7526 | "Do not advertise to any peer (well-known community)\n" |
| 7527 | "Do not export to next AS (well-known community)\n" |
| 7528 | "community number\n" |
| 7529 | "Do not send outside local AS (well-known community)\n" |
| 7530 | "Do not advertise to any peer (well-known community)\n" |
| 7531 | "Do not export to next AS (well-known community)\n" |
| 7532 | "community number\n" |
| 7533 | "Do not send outside local AS (well-known community)\n" |
| 7534 | "Do not advertise to any peer (well-known community)\n" |
| 7535 | "Do not export to next AS (well-known community)\n") |
| 7536 | |
| 7537 | /* old command */ |
| 7538 | DEFUN (show_ipv6_bgp_community, |
| 7539 | show_ipv6_bgp_community_cmd, |
| 7540 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7541 | SHOW_STR |
| 7542 | IPV6_STR |
| 7543 | BGP_STR |
| 7544 | "Display routes matching the communities\n" |
| 7545 | "community number\n" |
| 7546 | "Do not send outside local AS (well-known community)\n" |
| 7547 | "Do not advertise to any peer (well-known community)\n" |
| 7548 | "Do not export to next AS (well-known community)\n") |
| 7549 | { |
| 7550 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST); |
| 7551 | } |
| 7552 | |
| 7553 | /* old command */ |
| 7554 | ALIAS (show_ipv6_bgp_community, |
| 7555 | show_ipv6_bgp_community2_cmd, |
| 7556 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7557 | SHOW_STR |
| 7558 | IPV6_STR |
| 7559 | BGP_STR |
| 7560 | "Display routes matching the communities\n" |
| 7561 | "community number\n" |
| 7562 | "Do not send outside local AS (well-known community)\n" |
| 7563 | "Do not advertise to any peer (well-known community)\n" |
| 7564 | "Do not export to next AS (well-known community)\n" |
| 7565 | "community number\n" |
| 7566 | "Do not send outside local AS (well-known community)\n" |
| 7567 | "Do not advertise to any peer (well-known community)\n" |
| 7568 | "Do not export to next AS (well-known community)\n") |
| 7569 | |
| 7570 | /* old command */ |
| 7571 | ALIAS (show_ipv6_bgp_community, |
| 7572 | show_ipv6_bgp_community3_cmd, |
| 7573 | "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)", |
| 7574 | SHOW_STR |
| 7575 | IPV6_STR |
| 7576 | BGP_STR |
| 7577 | "Display routes matching the communities\n" |
| 7578 | "community number\n" |
| 7579 | "Do not send outside local AS (well-known community)\n" |
| 7580 | "Do not advertise to any peer (well-known community)\n" |
| 7581 | "Do not export to next AS (well-known community)\n" |
| 7582 | "community number\n" |
| 7583 | "Do not send outside local AS (well-known community)\n" |
| 7584 | "Do not advertise to any peer (well-known community)\n" |
| 7585 | "Do not export to next AS (well-known community)\n" |
| 7586 | "community number\n" |
| 7587 | "Do not send outside local AS (well-known community)\n" |
| 7588 | "Do not advertise to any peer (well-known community)\n" |
| 7589 | "Do not export to next AS (well-known community)\n") |
| 7590 | |
| 7591 | /* old command */ |
| 7592 | ALIAS (show_ipv6_bgp_community, |
| 7593 | show_ipv6_bgp_community4_cmd, |
| 7594 | "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)", |
| 7595 | SHOW_STR |
| 7596 | IPV6_STR |
| 7597 | BGP_STR |
| 7598 | "Display routes matching the communities\n" |
| 7599 | "community number\n" |
| 7600 | "Do not send outside local AS (well-known community)\n" |
| 7601 | "Do not advertise to any peer (well-known community)\n" |
| 7602 | "Do not export to next AS (well-known community)\n" |
| 7603 | "community number\n" |
| 7604 | "Do not send outside local AS (well-known community)\n" |
| 7605 | "Do not advertise to any peer (well-known community)\n" |
| 7606 | "Do not export to next AS (well-known community)\n" |
| 7607 | "community number\n" |
| 7608 | "Do not send outside local AS (well-known community)\n" |
| 7609 | "Do not advertise to any peer (well-known community)\n" |
| 7610 | "Do not export to next AS (well-known community)\n" |
| 7611 | "community number\n" |
| 7612 | "Do not send outside local AS (well-known community)\n" |
| 7613 | "Do not advertise to any peer (well-known community)\n" |
| 7614 | "Do not export to next AS (well-known community)\n") |
| 7615 | |
| 7616 | DEFUN (show_bgp_community_exact, |
| 7617 | show_bgp_community_exact_cmd, |
| 7618 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7619 | SHOW_STR |
| 7620 | BGP_STR |
| 7621 | "Display routes matching the communities\n" |
| 7622 | "community number\n" |
| 7623 | "Do not send outside local AS (well-known community)\n" |
| 7624 | "Do not advertise to any peer (well-known community)\n" |
| 7625 | "Do not export to next AS (well-known community)\n" |
| 7626 | "Exact match of the communities") |
| 7627 | { |
| 7628 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 7629 | } |
| 7630 | |
| 7631 | ALIAS (show_bgp_community_exact, |
| 7632 | show_bgp_ipv6_community_exact_cmd, |
| 7633 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7634 | SHOW_STR |
| 7635 | BGP_STR |
| 7636 | "Address family\n" |
| 7637 | "Display routes matching the communities\n" |
| 7638 | "community number\n" |
| 7639 | "Do not send outside local AS (well-known community)\n" |
| 7640 | "Do not advertise to any peer (well-known community)\n" |
| 7641 | "Do not export to next AS (well-known community)\n" |
| 7642 | "Exact match of the communities") |
| 7643 | |
| 7644 | ALIAS (show_bgp_community_exact, |
| 7645 | show_bgp_community2_exact_cmd, |
| 7646 | "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7647 | SHOW_STR |
| 7648 | BGP_STR |
| 7649 | "Display routes matching the communities\n" |
| 7650 | "community number\n" |
| 7651 | "Do not send outside local AS (well-known community)\n" |
| 7652 | "Do not advertise to any peer (well-known community)\n" |
| 7653 | "Do not export to next AS (well-known community)\n" |
| 7654 | "community number\n" |
| 7655 | "Do not send outside local AS (well-known community)\n" |
| 7656 | "Do not advertise to any peer (well-known community)\n" |
| 7657 | "Do not export to next AS (well-known community)\n" |
| 7658 | "Exact match of the communities") |
| 7659 | |
| 7660 | ALIAS (show_bgp_community_exact, |
| 7661 | show_bgp_ipv6_community2_exact_cmd, |
| 7662 | "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7663 | SHOW_STR |
| 7664 | BGP_STR |
| 7665 | "Address family\n" |
| 7666 | "Display routes matching the communities\n" |
| 7667 | "community number\n" |
| 7668 | "Do not send outside local AS (well-known community)\n" |
| 7669 | "Do not advertise to any peer (well-known community)\n" |
| 7670 | "Do not export to next AS (well-known community)\n" |
| 7671 | "community number\n" |
| 7672 | "Do not send outside local AS (well-known community)\n" |
| 7673 | "Do not advertise to any peer (well-known community)\n" |
| 7674 | "Do not export to next AS (well-known community)\n" |
| 7675 | "Exact match of the communities") |
| 7676 | |
| 7677 | ALIAS (show_bgp_community_exact, |
| 7678 | show_bgp_community3_exact_cmd, |
| 7679 | "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", |
| 7680 | SHOW_STR |
| 7681 | BGP_STR |
| 7682 | "Display routes matching the communities\n" |
| 7683 | "community number\n" |
| 7684 | "Do not send outside local AS (well-known community)\n" |
| 7685 | "Do not advertise to any peer (well-known community)\n" |
| 7686 | "Do not export to next AS (well-known community)\n" |
| 7687 | "community number\n" |
| 7688 | "Do not send outside local AS (well-known community)\n" |
| 7689 | "Do not advertise to any peer (well-known community)\n" |
| 7690 | "Do not export to next AS (well-known community)\n" |
| 7691 | "community number\n" |
| 7692 | "Do not send outside local AS (well-known community)\n" |
| 7693 | "Do not advertise to any peer (well-known community)\n" |
| 7694 | "Do not export to next AS (well-known community)\n" |
| 7695 | "Exact match of the communities") |
| 7696 | |
| 7697 | ALIAS (show_bgp_community_exact, |
| 7698 | show_bgp_ipv6_community3_exact_cmd, |
| 7699 | "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", |
| 7700 | SHOW_STR |
| 7701 | BGP_STR |
| 7702 | "Address family\n" |
| 7703 | "Display routes matching the communities\n" |
| 7704 | "community number\n" |
| 7705 | "Do not send outside local AS (well-known community)\n" |
| 7706 | "Do not advertise to any peer (well-known community)\n" |
| 7707 | "Do not export to next AS (well-known community)\n" |
| 7708 | "community number\n" |
| 7709 | "Do not send outside local AS (well-known community)\n" |
| 7710 | "Do not advertise to any peer (well-known community)\n" |
| 7711 | "Do not export to next AS (well-known community)\n" |
| 7712 | "community number\n" |
| 7713 | "Do not send outside local AS (well-known community)\n" |
| 7714 | "Do not advertise to any peer (well-known community)\n" |
| 7715 | "Do not export to next AS (well-known community)\n" |
| 7716 | "Exact match of the communities") |
| 7717 | |
| 7718 | ALIAS (show_bgp_community_exact, |
| 7719 | show_bgp_community4_exact_cmd, |
| 7720 | "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", |
| 7721 | SHOW_STR |
| 7722 | BGP_STR |
| 7723 | "Display routes matching the communities\n" |
| 7724 | "community number\n" |
| 7725 | "Do not send outside local AS (well-known community)\n" |
| 7726 | "Do not advertise to any peer (well-known community)\n" |
| 7727 | "Do not export to next AS (well-known community)\n" |
| 7728 | "community number\n" |
| 7729 | "Do not send outside local AS (well-known community)\n" |
| 7730 | "Do not advertise to any peer (well-known community)\n" |
| 7731 | "Do not export to next AS (well-known community)\n" |
| 7732 | "community number\n" |
| 7733 | "Do not send outside local AS (well-known community)\n" |
| 7734 | "Do not advertise to any peer (well-known community)\n" |
| 7735 | "Do not export to next AS (well-known community)\n" |
| 7736 | "community number\n" |
| 7737 | "Do not send outside local AS (well-known community)\n" |
| 7738 | "Do not advertise to any peer (well-known community)\n" |
| 7739 | "Do not export to next AS (well-known community)\n" |
| 7740 | "Exact match of the communities") |
| 7741 | |
| 7742 | ALIAS (show_bgp_community_exact, |
| 7743 | show_bgp_ipv6_community4_exact_cmd, |
| 7744 | "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", |
| 7745 | SHOW_STR |
| 7746 | BGP_STR |
| 7747 | "Address family\n" |
| 7748 | "Display routes matching the communities\n" |
| 7749 | "community number\n" |
| 7750 | "Do not send outside local AS (well-known community)\n" |
| 7751 | "Do not advertise to any peer (well-known community)\n" |
| 7752 | "Do not export to next AS (well-known community)\n" |
| 7753 | "community number\n" |
| 7754 | "Do not send outside local AS (well-known community)\n" |
| 7755 | "Do not advertise to any peer (well-known community)\n" |
| 7756 | "Do not export to next AS (well-known community)\n" |
| 7757 | "community number\n" |
| 7758 | "Do not send outside local AS (well-known community)\n" |
| 7759 | "Do not advertise to any peer (well-known community)\n" |
| 7760 | "Do not export to next AS (well-known community)\n" |
| 7761 | "community number\n" |
| 7762 | "Do not send outside local AS (well-known community)\n" |
| 7763 | "Do not advertise to any peer (well-known community)\n" |
| 7764 | "Do not export to next AS (well-known community)\n" |
| 7765 | "Exact match of the communities") |
| 7766 | |
| 7767 | /* old command */ |
| 7768 | DEFUN (show_ipv6_bgp_community_exact, |
| 7769 | show_ipv6_bgp_community_exact_cmd, |
| 7770 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7771 | SHOW_STR |
| 7772 | IPV6_STR |
| 7773 | BGP_STR |
| 7774 | "Display routes matching the communities\n" |
| 7775 | "community number\n" |
| 7776 | "Do not send outside local AS (well-known community)\n" |
| 7777 | "Do not advertise to any peer (well-known community)\n" |
| 7778 | "Do not export to next AS (well-known community)\n" |
| 7779 | "Exact match of the communities") |
| 7780 | { |
| 7781 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST); |
| 7782 | } |
| 7783 | |
| 7784 | /* old command */ |
| 7785 | ALIAS (show_ipv6_bgp_community_exact, |
| 7786 | show_ipv6_bgp_community2_exact_cmd, |
| 7787 | "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7788 | SHOW_STR |
| 7789 | IPV6_STR |
| 7790 | BGP_STR |
| 7791 | "Display routes matching the communities\n" |
| 7792 | "community number\n" |
| 7793 | "Do not send outside local AS (well-known community)\n" |
| 7794 | "Do not advertise to any peer (well-known community)\n" |
| 7795 | "Do not export to next AS (well-known community)\n" |
| 7796 | "community number\n" |
| 7797 | "Do not send outside local AS (well-known community)\n" |
| 7798 | "Do not advertise to any peer (well-known community)\n" |
| 7799 | "Do not export to next AS (well-known community)\n" |
| 7800 | "Exact match of the communities") |
| 7801 | |
| 7802 | /* old command */ |
| 7803 | ALIAS (show_ipv6_bgp_community_exact, |
| 7804 | show_ipv6_bgp_community3_exact_cmd, |
| 7805 | "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", |
| 7806 | SHOW_STR |
| 7807 | IPV6_STR |
| 7808 | BGP_STR |
| 7809 | "Display routes matching the communities\n" |
| 7810 | "community number\n" |
| 7811 | "Do not send outside local AS (well-known community)\n" |
| 7812 | "Do not advertise to any peer (well-known community)\n" |
| 7813 | "Do not export to next AS (well-known community)\n" |
| 7814 | "community number\n" |
| 7815 | "Do not send outside local AS (well-known community)\n" |
| 7816 | "Do not advertise to any peer (well-known community)\n" |
| 7817 | "Do not export to next AS (well-known community)\n" |
| 7818 | "community number\n" |
| 7819 | "Do not send outside local AS (well-known community)\n" |
| 7820 | "Do not advertise to any peer (well-known community)\n" |
| 7821 | "Do not export to next AS (well-known community)\n" |
| 7822 | "Exact match of the communities") |
| 7823 | |
| 7824 | /* old command */ |
| 7825 | ALIAS (show_ipv6_bgp_community_exact, |
| 7826 | show_ipv6_bgp_community4_exact_cmd, |
| 7827 | "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", |
| 7828 | SHOW_STR |
| 7829 | IPV6_STR |
| 7830 | BGP_STR |
| 7831 | "Display routes matching the communities\n" |
| 7832 | "community number\n" |
| 7833 | "Do not send outside local AS (well-known community)\n" |
| 7834 | "Do not advertise to any peer (well-known community)\n" |
| 7835 | "Do not export to next AS (well-known community)\n" |
| 7836 | "community number\n" |
| 7837 | "Do not send outside local AS (well-known community)\n" |
| 7838 | "Do not advertise to any peer (well-known community)\n" |
| 7839 | "Do not export to next AS (well-known community)\n" |
| 7840 | "community number\n" |
| 7841 | "Do not send outside local AS (well-known community)\n" |
| 7842 | "Do not advertise to any peer (well-known community)\n" |
| 7843 | "Do not export to next AS (well-known community)\n" |
| 7844 | "community number\n" |
| 7845 | "Do not send outside local AS (well-known community)\n" |
| 7846 | "Do not advertise to any peer (well-known community)\n" |
| 7847 | "Do not export to next AS (well-known community)\n" |
| 7848 | "Exact match of the communities") |
| 7849 | |
| 7850 | /* old command */ |
| 7851 | DEFUN (show_ipv6_mbgp_community, |
| 7852 | show_ipv6_mbgp_community_cmd, |
| 7853 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)", |
| 7854 | SHOW_STR |
| 7855 | IPV6_STR |
| 7856 | MBGP_STR |
| 7857 | "Display routes matching the communities\n" |
| 7858 | "community number\n" |
| 7859 | "Do not send outside local AS (well-known community)\n" |
| 7860 | "Do not advertise to any peer (well-known community)\n" |
| 7861 | "Do not export to next AS (well-known community)\n") |
| 7862 | { |
| 7863 | return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); |
| 7864 | } |
| 7865 | |
| 7866 | /* old command */ |
| 7867 | ALIAS (show_ipv6_mbgp_community, |
| 7868 | show_ipv6_mbgp_community2_cmd, |
| 7869 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", |
| 7870 | SHOW_STR |
| 7871 | IPV6_STR |
| 7872 | MBGP_STR |
| 7873 | "Display routes matching the communities\n" |
| 7874 | "community number\n" |
| 7875 | "Do not send outside local AS (well-known community)\n" |
| 7876 | "Do not advertise to any peer (well-known community)\n" |
| 7877 | "Do not export to next AS (well-known community)\n" |
| 7878 | "community number\n" |
| 7879 | "Do not send outside local AS (well-known community)\n" |
| 7880 | "Do not advertise to any peer (well-known community)\n" |
| 7881 | "Do not export to next AS (well-known community)\n") |
| 7882 | |
| 7883 | /* old command */ |
| 7884 | ALIAS (show_ipv6_mbgp_community, |
| 7885 | show_ipv6_mbgp_community3_cmd, |
| 7886 | "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)", |
| 7887 | SHOW_STR |
| 7888 | IPV6_STR |
| 7889 | MBGP_STR |
| 7890 | "Display routes matching the communities\n" |
| 7891 | "community number\n" |
| 7892 | "Do not send outside local AS (well-known community)\n" |
| 7893 | "Do not advertise to any peer (well-known community)\n" |
| 7894 | "Do not export to next AS (well-known community)\n" |
| 7895 | "community number\n" |
| 7896 | "Do not send outside local AS (well-known community)\n" |
| 7897 | "Do not advertise to any peer (well-known community)\n" |
| 7898 | "Do not export to next AS (well-known community)\n" |
| 7899 | "community number\n" |
| 7900 | "Do not send outside local AS (well-known community)\n" |
| 7901 | "Do not advertise to any peer (well-known community)\n" |
| 7902 | "Do not export to next AS (well-known community)\n") |
| 7903 | |
| 7904 | /* old command */ |
| 7905 | ALIAS (show_ipv6_mbgp_community, |
| 7906 | show_ipv6_mbgp_community4_cmd, |
| 7907 | "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)", |
| 7908 | SHOW_STR |
| 7909 | IPV6_STR |
| 7910 | MBGP_STR |
| 7911 | "Display routes matching the communities\n" |
| 7912 | "community number\n" |
| 7913 | "Do not send outside local AS (well-known community)\n" |
| 7914 | "Do not advertise to any peer (well-known community)\n" |
| 7915 | "Do not export to next AS (well-known community)\n" |
| 7916 | "community number\n" |
| 7917 | "Do not send outside local AS (well-known community)\n" |
| 7918 | "Do not advertise to any peer (well-known community)\n" |
| 7919 | "Do not export to next AS (well-known community)\n" |
| 7920 | "community number\n" |
| 7921 | "Do not send outside local AS (well-known community)\n" |
| 7922 | "Do not advertise to any peer (well-known community)\n" |
| 7923 | "Do not export to next AS (well-known community)\n" |
| 7924 | "community number\n" |
| 7925 | "Do not send outside local AS (well-known community)\n" |
| 7926 | "Do not advertise to any peer (well-known community)\n" |
| 7927 | "Do not export to next AS (well-known community)\n") |
| 7928 | |
| 7929 | /* old command */ |
| 7930 | DEFUN (show_ipv6_mbgp_community_exact, |
| 7931 | show_ipv6_mbgp_community_exact_cmd, |
| 7932 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7933 | SHOW_STR |
| 7934 | IPV6_STR |
| 7935 | MBGP_STR |
| 7936 | "Display routes matching the communities\n" |
| 7937 | "community number\n" |
| 7938 | "Do not send outside local AS (well-known community)\n" |
| 7939 | "Do not advertise to any peer (well-known community)\n" |
| 7940 | "Do not export to next AS (well-known community)\n" |
| 7941 | "Exact match of the communities") |
| 7942 | { |
| 7943 | return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); |
| 7944 | } |
| 7945 | |
| 7946 | /* old command */ |
| 7947 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7948 | show_ipv6_mbgp_community2_exact_cmd, |
| 7949 | "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", |
| 7950 | SHOW_STR |
| 7951 | IPV6_STR |
| 7952 | MBGP_STR |
| 7953 | "Display routes matching the communities\n" |
| 7954 | "community number\n" |
| 7955 | "Do not send outside local AS (well-known community)\n" |
| 7956 | "Do not advertise to any peer (well-known community)\n" |
| 7957 | "Do not export to next AS (well-known community)\n" |
| 7958 | "community number\n" |
| 7959 | "Do not send outside local AS (well-known community)\n" |
| 7960 | "Do not advertise to any peer (well-known community)\n" |
| 7961 | "Do not export to next AS (well-known community)\n" |
| 7962 | "Exact match of the communities") |
| 7963 | |
| 7964 | /* old command */ |
| 7965 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7966 | show_ipv6_mbgp_community3_exact_cmd, |
| 7967 | "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", |
| 7968 | SHOW_STR |
| 7969 | IPV6_STR |
| 7970 | MBGP_STR |
| 7971 | "Display routes matching the communities\n" |
| 7972 | "community number\n" |
| 7973 | "Do not send outside local AS (well-known community)\n" |
| 7974 | "Do not advertise to any peer (well-known community)\n" |
| 7975 | "Do not export to next AS (well-known community)\n" |
| 7976 | "community number\n" |
| 7977 | "Do not send outside local AS (well-known community)\n" |
| 7978 | "Do not advertise to any peer (well-known community)\n" |
| 7979 | "Do not export to next AS (well-known community)\n" |
| 7980 | "community number\n" |
| 7981 | "Do not send outside local AS (well-known community)\n" |
| 7982 | "Do not advertise to any peer (well-known community)\n" |
| 7983 | "Do not export to next AS (well-known community)\n" |
| 7984 | "Exact match of the communities") |
| 7985 | |
| 7986 | /* old command */ |
| 7987 | ALIAS (show_ipv6_mbgp_community_exact, |
| 7988 | show_ipv6_mbgp_community4_exact_cmd, |
| 7989 | "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", |
| 7990 | SHOW_STR |
| 7991 | IPV6_STR |
| 7992 | MBGP_STR |
| 7993 | "Display routes matching the communities\n" |
| 7994 | "community number\n" |
| 7995 | "Do not send outside local AS (well-known community)\n" |
| 7996 | "Do not advertise to any peer (well-known community)\n" |
| 7997 | "Do not export to next AS (well-known community)\n" |
| 7998 | "community number\n" |
| 7999 | "Do not send outside local AS (well-known community)\n" |
| 8000 | "Do not advertise to any peer (well-known community)\n" |
| 8001 | "Do not export to next AS (well-known community)\n" |
| 8002 | "community number\n" |
| 8003 | "Do not send outside local AS (well-known community)\n" |
| 8004 | "Do not advertise to any peer (well-known community)\n" |
| 8005 | "Do not export to next AS (well-known community)\n" |
| 8006 | "community number\n" |
| 8007 | "Do not send outside local AS (well-known community)\n" |
| 8008 | "Do not advertise to any peer (well-known community)\n" |
| 8009 | "Do not export to next AS (well-known community)\n" |
| 8010 | "Exact match of the communities") |
| 8011 | #endif /* HAVE_IPV6 */ |
| 8012 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8013 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8014 | bgp_show_community_list (struct vty *vty, const char *com, int exact, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8015 | u_int16_t afi, u_char safi) |
| 8016 | { |
| 8017 | struct community_list *list; |
| 8018 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8019 | list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8020 | if (list == NULL) |
| 8021 | { |
| 8022 | vty_out (vty, "%% %s is not a valid community-list name%s", com, |
| 8023 | VTY_NEWLINE); |
| 8024 | return CMD_WARNING; |
| 8025 | } |
| 8026 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8027 | return bgp_show (vty, NULL, afi, safi, |
| 8028 | (exact ? bgp_show_type_community_list_exact : |
| 8029 | bgp_show_type_community_list), list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8030 | } |
| 8031 | |
| 8032 | DEFUN (show_ip_bgp_community_list, |
| 8033 | show_ip_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8034 | "show ip bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8035 | SHOW_STR |
| 8036 | IP_STR |
| 8037 | BGP_STR |
| 8038 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8039 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8040 | "community-list name\n") |
| 8041 | { |
| 8042 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST); |
| 8043 | } |
| 8044 | |
| 8045 | DEFUN (show_ip_bgp_ipv4_community_list, |
| 8046 | show_ip_bgp_ipv4_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8047 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8048 | SHOW_STR |
| 8049 | IP_STR |
| 8050 | BGP_STR |
| 8051 | "Address family\n" |
| 8052 | "Address Family modifier\n" |
| 8053 | "Address Family modifier\n" |
| 8054 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8055 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8056 | "community-list name\n") |
| 8057 | { |
| 8058 | if (strncmp (argv[0], "m", 1) == 0) |
| 8059 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); |
| 8060 | |
| 8061 | return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); |
| 8062 | } |
| 8063 | |
| 8064 | DEFUN (show_ip_bgp_community_list_exact, |
| 8065 | show_ip_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8066 | "show ip bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8067 | SHOW_STR |
| 8068 | IP_STR |
| 8069 | BGP_STR |
| 8070 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8071 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8072 | "community-list name\n" |
| 8073 | "Exact match of the communities\n") |
| 8074 | { |
| 8075 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST); |
| 8076 | } |
| 8077 | |
| 8078 | DEFUN (show_ip_bgp_ipv4_community_list_exact, |
| 8079 | show_ip_bgp_ipv4_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8080 | "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8081 | SHOW_STR |
| 8082 | IP_STR |
| 8083 | BGP_STR |
| 8084 | "Address family\n" |
| 8085 | "Address Family modifier\n" |
| 8086 | "Address Family modifier\n" |
| 8087 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8088 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8089 | "community-list name\n" |
| 8090 | "Exact match of the communities\n") |
| 8091 | { |
| 8092 | if (strncmp (argv[0], "m", 1) == 0) |
| 8093 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); |
| 8094 | |
| 8095 | return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); |
| 8096 | } |
| 8097 | |
| 8098 | #ifdef HAVE_IPV6 |
| 8099 | DEFUN (show_bgp_community_list, |
| 8100 | show_bgp_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8101 | "show bgp community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8102 | SHOW_STR |
| 8103 | BGP_STR |
| 8104 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8105 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8106 | "community-list name\n") |
| 8107 | { |
| 8108 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8109 | } |
| 8110 | |
| 8111 | ALIAS (show_bgp_community_list, |
| 8112 | show_bgp_ipv6_community_list_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8113 | "show bgp ipv6 community-list (<1-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8114 | SHOW_STR |
| 8115 | BGP_STR |
| 8116 | "Address family\n" |
| 8117 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8118 | "community-list number\n" |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 8119 | "community-list name\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8120 | |
| 8121 | /* old command */ |
| 8122 | DEFUN (show_ipv6_bgp_community_list, |
| 8123 | show_ipv6_bgp_community_list_cmd, |
| 8124 | "show ipv6 bgp community-list WORD", |
| 8125 | SHOW_STR |
| 8126 | IPV6_STR |
| 8127 | BGP_STR |
| 8128 | "Display routes matching the community-list\n" |
| 8129 | "community-list name\n") |
| 8130 | { |
| 8131 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST); |
| 8132 | } |
| 8133 | |
| 8134 | /* old command */ |
| 8135 | DEFUN (show_ipv6_mbgp_community_list, |
| 8136 | show_ipv6_mbgp_community_list_cmd, |
| 8137 | "show ipv6 mbgp community-list WORD", |
| 8138 | SHOW_STR |
| 8139 | IPV6_STR |
| 8140 | MBGP_STR |
| 8141 | "Display routes matching the community-list\n" |
| 8142 | "community-list name\n") |
| 8143 | { |
| 8144 | return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST); |
| 8145 | } |
| 8146 | |
| 8147 | DEFUN (show_bgp_community_list_exact, |
| 8148 | show_bgp_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8149 | "show bgp community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8150 | SHOW_STR |
| 8151 | BGP_STR |
| 8152 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8153 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8154 | "community-list name\n" |
| 8155 | "Exact match of the communities\n") |
| 8156 | { |
| 8157 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8158 | } |
| 8159 | |
| 8160 | ALIAS (show_bgp_community_list_exact, |
| 8161 | show_bgp_ipv6_community_list_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8162 | "show bgp ipv6 community-list (<1-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8163 | SHOW_STR |
| 8164 | BGP_STR |
| 8165 | "Address family\n" |
| 8166 | "Display routes matching the community-list\n" |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 8167 | "community-list number\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8168 | "community-list name\n" |
| 8169 | "Exact match of the communities\n") |
| 8170 | |
| 8171 | /* old command */ |
| 8172 | DEFUN (show_ipv6_bgp_community_list_exact, |
| 8173 | show_ipv6_bgp_community_list_exact_cmd, |
| 8174 | "show ipv6 bgp community-list WORD exact-match", |
| 8175 | SHOW_STR |
| 8176 | IPV6_STR |
| 8177 | BGP_STR |
| 8178 | "Display routes matching the community-list\n" |
| 8179 | "community-list name\n" |
| 8180 | "Exact match of the communities\n") |
| 8181 | { |
| 8182 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST); |
| 8183 | } |
| 8184 | |
| 8185 | /* old command */ |
| 8186 | DEFUN (show_ipv6_mbgp_community_list_exact, |
| 8187 | show_ipv6_mbgp_community_list_exact_cmd, |
| 8188 | "show ipv6 mbgp community-list WORD exact-match", |
| 8189 | SHOW_STR |
| 8190 | IPV6_STR |
| 8191 | MBGP_STR |
| 8192 | "Display routes matching the community-list\n" |
| 8193 | "community-list name\n" |
| 8194 | "Exact match of the communities\n") |
| 8195 | { |
| 8196 | return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); |
| 8197 | } |
| 8198 | #endif /* HAVE_IPV6 */ |
| 8199 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8200 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8201 | bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8202 | safi_t safi, enum bgp_show_type type) |
| 8203 | { |
| 8204 | int ret; |
| 8205 | struct prefix *p; |
| 8206 | |
| 8207 | p = prefix_new(); |
| 8208 | |
| 8209 | ret = str2prefix (prefix, p); |
| 8210 | if (! ret) |
| 8211 | { |
| 8212 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 8213 | return CMD_WARNING; |
| 8214 | } |
| 8215 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8216 | ret = bgp_show (vty, NULL, afi, safi, type, p); |
| 8217 | prefix_free(p); |
| 8218 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8219 | } |
| 8220 | |
| 8221 | DEFUN (show_ip_bgp_prefix_longer, |
| 8222 | show_ip_bgp_prefix_longer_cmd, |
| 8223 | "show ip bgp A.B.C.D/M longer-prefixes", |
| 8224 | SHOW_STR |
| 8225 | IP_STR |
| 8226 | BGP_STR |
| 8227 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8228 | "Display route and more specific routes\n") |
| 8229 | { |
| 8230 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8231 | bgp_show_type_prefix_longer); |
| 8232 | } |
| 8233 | |
| 8234 | DEFUN (show_ip_bgp_flap_prefix_longer, |
| 8235 | show_ip_bgp_flap_prefix_longer_cmd, |
| 8236 | "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", |
| 8237 | SHOW_STR |
| 8238 | IP_STR |
| 8239 | BGP_STR |
| 8240 | "Display flap statistics of routes\n" |
| 8241 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8242 | "Display route and more specific routes\n") |
| 8243 | { |
| 8244 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8245 | bgp_show_type_flap_prefix_longer); |
| 8246 | } |
| 8247 | |
| 8248 | DEFUN (show_ip_bgp_ipv4_prefix_longer, |
| 8249 | show_ip_bgp_ipv4_prefix_longer_cmd, |
| 8250 | "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", |
| 8251 | SHOW_STR |
| 8252 | IP_STR |
| 8253 | BGP_STR |
| 8254 | "Address family\n" |
| 8255 | "Address Family modifier\n" |
| 8256 | "Address Family modifier\n" |
| 8257 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 8258 | "Display route and more specific routes\n") |
| 8259 | { |
| 8260 | if (strncmp (argv[0], "m", 1) == 0) |
| 8261 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST, |
| 8262 | bgp_show_type_prefix_longer); |
| 8263 | |
| 8264 | return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST, |
| 8265 | bgp_show_type_prefix_longer); |
| 8266 | } |
| 8267 | |
| 8268 | DEFUN (show_ip_bgp_flap_address, |
| 8269 | show_ip_bgp_flap_address_cmd, |
| 8270 | "show ip bgp flap-statistics A.B.C.D", |
| 8271 | SHOW_STR |
| 8272 | IP_STR |
| 8273 | BGP_STR |
| 8274 | "Display flap statistics of routes\n" |
| 8275 | "Network in the BGP routing table to display\n") |
| 8276 | { |
| 8277 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8278 | bgp_show_type_flap_address); |
| 8279 | } |
| 8280 | |
| 8281 | DEFUN (show_ip_bgp_flap_prefix, |
| 8282 | show_ip_bgp_flap_prefix_cmd, |
| 8283 | "show ip bgp flap-statistics A.B.C.D/M", |
| 8284 | SHOW_STR |
| 8285 | IP_STR |
| 8286 | BGP_STR |
| 8287 | "Display flap statistics of routes\n" |
| 8288 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 8289 | { |
| 8290 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST, |
| 8291 | bgp_show_type_flap_prefix); |
| 8292 | } |
| 8293 | #ifdef HAVE_IPV6 |
| 8294 | DEFUN (show_bgp_prefix_longer, |
| 8295 | show_bgp_prefix_longer_cmd, |
| 8296 | "show bgp X:X::X:X/M longer-prefixes", |
| 8297 | SHOW_STR |
| 8298 | BGP_STR |
| 8299 | "IPv6 prefix <network>/<length>\n" |
| 8300 | "Display route and more specific routes\n") |
| 8301 | { |
| 8302 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8303 | bgp_show_type_prefix_longer); |
| 8304 | } |
| 8305 | |
| 8306 | ALIAS (show_bgp_prefix_longer, |
| 8307 | show_bgp_ipv6_prefix_longer_cmd, |
| 8308 | "show bgp ipv6 X:X::X:X/M longer-prefixes", |
| 8309 | SHOW_STR |
| 8310 | BGP_STR |
| 8311 | "Address family\n" |
| 8312 | "IPv6 prefix <network>/<length>\n" |
| 8313 | "Display route and more specific routes\n") |
| 8314 | |
| 8315 | /* old command */ |
| 8316 | DEFUN (show_ipv6_bgp_prefix_longer, |
| 8317 | show_ipv6_bgp_prefix_longer_cmd, |
| 8318 | "show ipv6 bgp X:X::X:X/M longer-prefixes", |
| 8319 | SHOW_STR |
| 8320 | IPV6_STR |
| 8321 | BGP_STR |
| 8322 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 8323 | "Display route and more specific routes\n") |
| 8324 | { |
| 8325 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST, |
| 8326 | bgp_show_type_prefix_longer); |
| 8327 | } |
| 8328 | |
| 8329 | /* old command */ |
| 8330 | DEFUN (show_ipv6_mbgp_prefix_longer, |
| 8331 | show_ipv6_mbgp_prefix_longer_cmd, |
| 8332 | "show ipv6 mbgp X:X::X:X/M longer-prefixes", |
| 8333 | SHOW_STR |
| 8334 | IPV6_STR |
| 8335 | MBGP_STR |
| 8336 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" |
| 8337 | "Display route and more specific routes\n") |
| 8338 | { |
| 8339 | return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST, |
| 8340 | bgp_show_type_prefix_longer); |
| 8341 | } |
| 8342 | #endif /* HAVE_IPV6 */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8343 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8344 | static struct peer * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 8345 | peer_lookup_in_view (struct vty *vty, const char *view_name, |
| 8346 | const char *ip_str) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8347 | { |
| 8348 | int ret; |
| 8349 | struct bgp *bgp; |
| 8350 | struct peer *peer; |
| 8351 | union sockunion su; |
| 8352 | |
| 8353 | /* BGP structure lookup. */ |
| 8354 | if (view_name) |
| 8355 | { |
| 8356 | bgp = bgp_lookup_by_name (view_name); |
| 8357 | if (! bgp) |
| 8358 | { |
| 8359 | vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 8360 | return NULL; |
| 8361 | } |
| 8362 | } |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 8363 | else |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8364 | { |
| 8365 | bgp = bgp_get_default (); |
| 8366 | if (! bgp) |
| 8367 | { |
| 8368 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 8369 | return NULL; |
| 8370 | } |
| 8371 | } |
| 8372 | |
| 8373 | /* Get peer sockunion. */ |
| 8374 | ret = str2sockunion (ip_str, &su); |
| 8375 | if (ret < 0) |
| 8376 | { |
| 8377 | vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE); |
| 8378 | return NULL; |
| 8379 | } |
| 8380 | |
| 8381 | /* Peer structure lookup. */ |
| 8382 | peer = peer_lookup (bgp, &su); |
| 8383 | if (! peer) |
| 8384 | { |
| 8385 | vty_out (vty, "No such neighbor%s", VTY_NEWLINE); |
| 8386 | return NULL; |
| 8387 | } |
| 8388 | |
| 8389 | return peer; |
| 8390 | } |
| 8391 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8392 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8393 | show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, |
| 8394 | int in) |
| 8395 | { |
| 8396 | struct bgp_table *table; |
| 8397 | struct bgp_adj_in *ain; |
| 8398 | struct bgp_adj_out *adj; |
| 8399 | unsigned long output_count; |
| 8400 | struct bgp_node *rn; |
| 8401 | int header1 = 1; |
| 8402 | struct bgp *bgp; |
| 8403 | int header2 = 1; |
| 8404 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8405 | bgp = peer->bgp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8406 | |
| 8407 | if (! bgp) |
| 8408 | return; |
| 8409 | |
| 8410 | table = bgp->rib[afi][safi]; |
| 8411 | |
| 8412 | output_count = 0; |
| 8413 | |
| 8414 | if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], |
| 8415 | PEER_STATUS_DEFAULT_ORIGINATE)) |
| 8416 | { |
| 8417 | 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] | 8418 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 8419 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8420 | |
| 8421 | vty_out (vty, "Originating default network 0.0.0.0%s%s", |
| 8422 | VTY_NEWLINE, VTY_NEWLINE); |
| 8423 | header1 = 0; |
| 8424 | } |
| 8425 | |
| 8426 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 8427 | if (in) |
| 8428 | { |
| 8429 | for (ain = rn->adj_in; ain; ain = ain->next) |
| 8430 | if (ain->peer == peer) |
| 8431 | { |
| 8432 | if (header1) |
| 8433 | { |
| 8434 | 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] | 8435 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 8436 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8437 | header1 = 0; |
| 8438 | } |
| 8439 | if (header2) |
| 8440 | { |
| 8441 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 8442 | header2 = 0; |
| 8443 | } |
| 8444 | if (ain->attr) |
| 8445 | { |
| 8446 | route_vty_out_tmp (vty, &rn->p, ain->attr, safi); |
| 8447 | output_count++; |
| 8448 | } |
| 8449 | } |
| 8450 | } |
| 8451 | else |
| 8452 | { |
| 8453 | for (adj = rn->adj_out; adj; adj = adj->next) |
| 8454 | if (adj->peer == peer) |
| 8455 | { |
| 8456 | if (header1) |
| 8457 | { |
| 8458 | 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] | 8459 | vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
| 8460 | vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8461 | header1 = 0; |
| 8462 | } |
| 8463 | if (header2) |
| 8464 | { |
| 8465 | vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); |
| 8466 | header2 = 0; |
| 8467 | } |
| 8468 | if (adj->attr) |
| 8469 | { |
| 8470 | route_vty_out_tmp (vty, &rn->p, adj->attr, safi); |
| 8471 | output_count++; |
| 8472 | } |
| 8473 | } |
| 8474 | } |
| 8475 | |
| 8476 | if (output_count != 0) |
| 8477 | vty_out (vty, "%sTotal number of prefixes %ld%s", |
| 8478 | VTY_NEWLINE, output_count, VTY_NEWLINE); |
| 8479 | } |
| 8480 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8481 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8482 | peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) |
| 8483 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8484 | if (! peer || ! peer->afc[afi][safi]) |
| 8485 | { |
| 8486 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
| 8487 | return CMD_WARNING; |
| 8488 | } |
| 8489 | |
| 8490 | if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
| 8491 | { |
| 8492 | vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", |
| 8493 | VTY_NEWLINE); |
| 8494 | return CMD_WARNING; |
| 8495 | } |
| 8496 | |
| 8497 | show_adj_route (vty, peer, afi, safi, in); |
| 8498 | |
| 8499 | return CMD_SUCCESS; |
| 8500 | } |
| 8501 | |
| 8502 | DEFUN (show_ip_bgp_neighbor_advertised_route, |
| 8503 | show_ip_bgp_neighbor_advertised_route_cmd, |
| 8504 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8505 | SHOW_STR |
| 8506 | IP_STR |
| 8507 | BGP_STR |
| 8508 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8509 | "Neighbor to display information about\n" |
| 8510 | "Neighbor to display information about\n" |
| 8511 | "Display the routes advertised to a BGP neighbor\n") |
| 8512 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8513 | struct peer *peer; |
| 8514 | |
| 8515 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8516 | if (! peer) |
| 8517 | return CMD_WARNING; |
| 8518 | |
| 8519 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8520 | } |
| 8521 | |
| 8522 | DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, |
| 8523 | show_ip_bgp_ipv4_neighbor_advertised_route_cmd, |
| 8524 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8525 | SHOW_STR |
| 8526 | IP_STR |
| 8527 | BGP_STR |
| 8528 | "Address family\n" |
| 8529 | "Address Family modifier\n" |
| 8530 | "Address Family modifier\n" |
| 8531 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8532 | "Neighbor to display information about\n" |
| 8533 | "Neighbor to display information about\n" |
| 8534 | "Display the routes advertised to a BGP neighbor\n") |
| 8535 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8536 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8537 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8538 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8539 | if (! peer) |
| 8540 | return CMD_WARNING; |
| 8541 | |
| 8542 | if (strncmp (argv[0], "m", 1) == 0) |
| 8543 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0); |
| 8544 | |
| 8545 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8546 | } |
| 8547 | |
| 8548 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8549 | DEFUN (show_bgp_view_neighbor_advertised_route, |
| 8550 | show_bgp_view_neighbor_advertised_route_cmd, |
| 8551 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8552 | SHOW_STR |
| 8553 | BGP_STR |
| 8554 | "BGP view\n" |
| 8555 | "View name\n" |
| 8556 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8557 | "Neighbor to display information about\n" |
| 8558 | "Neighbor to display information about\n" |
| 8559 | "Display the routes advertised to a BGP neighbor\n") |
| 8560 | { |
| 8561 | struct peer *peer; |
| 8562 | |
| 8563 | if (argc == 2) |
| 8564 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8565 | else |
| 8566 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8567 | |
| 8568 | if (! peer) |
| 8569 | return CMD_WARNING; |
| 8570 | |
| 8571 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); |
| 8572 | } |
| 8573 | |
| 8574 | ALIAS (show_bgp_view_neighbor_advertised_route, |
| 8575 | show_bgp_view_ipv6_neighbor_advertised_route_cmd, |
| 8576 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8577 | SHOW_STR |
| 8578 | BGP_STR |
| 8579 | "BGP view\n" |
| 8580 | "View name\n" |
| 8581 | "Address family\n" |
| 8582 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8583 | "Neighbor to display information about\n" |
| 8584 | "Neighbor to display information about\n" |
| 8585 | "Display the routes advertised to a BGP neighbor\n") |
| 8586 | |
| 8587 | DEFUN (show_bgp_view_neighbor_received_routes, |
| 8588 | show_bgp_view_neighbor_received_routes_cmd, |
| 8589 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8590 | SHOW_STR |
| 8591 | BGP_STR |
| 8592 | "BGP view\n" |
| 8593 | "View name\n" |
| 8594 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8595 | "Neighbor to display information about\n" |
| 8596 | "Neighbor to display information about\n" |
| 8597 | "Display the received routes from neighbor\n") |
| 8598 | { |
| 8599 | struct peer *peer; |
| 8600 | |
| 8601 | if (argc == 2) |
| 8602 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 8603 | else |
| 8604 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8605 | |
| 8606 | if (! peer) |
| 8607 | return CMD_WARNING; |
| 8608 | |
| 8609 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1); |
| 8610 | } |
| 8611 | |
| 8612 | ALIAS (show_bgp_view_neighbor_received_routes, |
| 8613 | show_bgp_view_ipv6_neighbor_received_routes_cmd, |
| 8614 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8615 | SHOW_STR |
| 8616 | BGP_STR |
| 8617 | "BGP view\n" |
| 8618 | "View name\n" |
| 8619 | "Address family\n" |
| 8620 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8621 | "Neighbor to display information about\n" |
| 8622 | "Neighbor to display information about\n" |
| 8623 | "Display the received routes from neighbor\n") |
| 8624 | |
| 8625 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8626 | show_bgp_neighbor_advertised_route_cmd, |
| 8627 | "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8628 | SHOW_STR |
| 8629 | BGP_STR |
| 8630 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8631 | "Neighbor to display information about\n" |
| 8632 | "Neighbor to display information about\n" |
| 8633 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8634 | |
| 8635 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8636 | show_bgp_ipv6_neighbor_advertised_route_cmd, |
| 8637 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8638 | SHOW_STR |
| 8639 | BGP_STR |
| 8640 | "Address family\n" |
| 8641 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8642 | "Neighbor to display information about\n" |
| 8643 | "Neighbor to display information about\n" |
| 8644 | "Display the routes advertised to a BGP neighbor\n") |
| 8645 | |
| 8646 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8647 | ALIAS (show_bgp_view_neighbor_advertised_route, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8648 | ipv6_bgp_neighbor_advertised_route_cmd, |
| 8649 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8650 | SHOW_STR |
| 8651 | IPV6_STR |
| 8652 | BGP_STR |
| 8653 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8654 | "Neighbor to display information about\n" |
| 8655 | "Neighbor to display information about\n" |
| 8656 | "Display the routes advertised to a BGP neighbor\n") |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8657 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8658 | /* old command */ |
| 8659 | DEFUN (ipv6_mbgp_neighbor_advertised_route, |
| 8660 | ipv6_mbgp_neighbor_advertised_route_cmd, |
| 8661 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes", |
| 8662 | SHOW_STR |
| 8663 | IPV6_STR |
| 8664 | MBGP_STR |
| 8665 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8666 | "Neighbor to display information about\n" |
| 8667 | "Neighbor to display information about\n" |
| 8668 | "Display the routes advertised to a BGP neighbor\n") |
| 8669 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8670 | struct peer *peer; |
| 8671 | |
| 8672 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8673 | if (! peer) |
| 8674 | return CMD_WARNING; |
| 8675 | |
| 8676 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8677 | } |
| 8678 | #endif /* HAVE_IPV6 */ |
| 8679 | |
| 8680 | DEFUN (show_ip_bgp_neighbor_received_routes, |
| 8681 | show_ip_bgp_neighbor_received_routes_cmd, |
| 8682 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8683 | SHOW_STR |
| 8684 | IP_STR |
| 8685 | BGP_STR |
| 8686 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8687 | "Neighbor to display information about\n" |
| 8688 | "Neighbor to display information about\n" |
| 8689 | "Display the received routes from neighbor\n") |
| 8690 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8691 | struct peer *peer; |
| 8692 | |
| 8693 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8694 | if (! peer) |
| 8695 | return CMD_WARNING; |
| 8696 | |
| 8697 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8698 | } |
| 8699 | |
| 8700 | DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, |
| 8701 | show_ip_bgp_ipv4_neighbor_received_routes_cmd, |
| 8702 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8703 | SHOW_STR |
| 8704 | IP_STR |
| 8705 | BGP_STR |
| 8706 | "Address family\n" |
| 8707 | "Address Family modifier\n" |
| 8708 | "Address Family modifier\n" |
| 8709 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8710 | "Neighbor to display information about\n" |
| 8711 | "Neighbor to display information about\n" |
| 8712 | "Display the received routes from neighbor\n") |
| 8713 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8714 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8715 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8716 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 8717 | if (! peer) |
| 8718 | return CMD_WARNING; |
| 8719 | |
| 8720 | if (strncmp (argv[0], "m", 1) == 0) |
| 8721 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); |
| 8722 | |
| 8723 | return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8724 | } |
| 8725 | |
| 8726 | DEFUN (show_ip_bgp_neighbor_received_prefix_filter, |
| 8727 | show_ip_bgp_neighbor_received_prefix_filter_cmd, |
| 8728 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8729 | SHOW_STR |
| 8730 | IP_STR |
| 8731 | BGP_STR |
| 8732 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8733 | "Neighbor to display information about\n" |
| 8734 | "Neighbor to display information about\n" |
| 8735 | "Display information received from a BGP neighbor\n" |
| 8736 | "Display the prefixlist filter\n") |
| 8737 | { |
| 8738 | char name[BUFSIZ]; |
| 8739 | union sockunion *su; |
| 8740 | struct peer *peer; |
| 8741 | int count; |
| 8742 | |
| 8743 | su = sockunion_str2su (argv[0]); |
| 8744 | if (su == NULL) |
| 8745 | return CMD_WARNING; |
| 8746 | |
| 8747 | peer = peer_lookup (NULL, su); |
| 8748 | if (! peer) |
| 8749 | return CMD_WARNING; |
| 8750 | |
| 8751 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 8752 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8753 | if (count) |
| 8754 | { |
| 8755 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 8756 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8757 | } |
| 8758 | |
| 8759 | return CMD_SUCCESS; |
| 8760 | } |
| 8761 | |
| 8762 | DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, |
| 8763 | show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, |
| 8764 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8765 | SHOW_STR |
| 8766 | IP_STR |
| 8767 | BGP_STR |
| 8768 | "Address family\n" |
| 8769 | "Address Family modifier\n" |
| 8770 | "Address Family modifier\n" |
| 8771 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8772 | "Neighbor to display information about\n" |
| 8773 | "Neighbor to display information about\n" |
| 8774 | "Display information received from a BGP neighbor\n" |
| 8775 | "Display the prefixlist filter\n") |
| 8776 | { |
| 8777 | char name[BUFSIZ]; |
| 8778 | union sockunion *su; |
| 8779 | struct peer *peer; |
| 8780 | int count; |
| 8781 | |
| 8782 | su = sockunion_str2su (argv[1]); |
| 8783 | if (su == NULL) |
| 8784 | return CMD_WARNING; |
| 8785 | |
| 8786 | peer = peer_lookup (NULL, su); |
| 8787 | if (! peer) |
| 8788 | return CMD_WARNING; |
| 8789 | |
| 8790 | if (strncmp (argv[0], "m", 1) == 0) |
| 8791 | { |
| 8792 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); |
| 8793 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8794 | if (count) |
| 8795 | { |
| 8796 | vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); |
| 8797 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8798 | } |
| 8799 | } |
| 8800 | else |
| 8801 | { |
| 8802 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); |
| 8803 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); |
| 8804 | if (count) |
| 8805 | { |
| 8806 | vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); |
| 8807 | prefix_bgp_show_prefix_list (vty, AFI_IP, name); |
| 8808 | } |
| 8809 | } |
| 8810 | |
| 8811 | return CMD_SUCCESS; |
| 8812 | } |
| 8813 | |
| 8814 | |
| 8815 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8816 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8817 | show_bgp_neighbor_received_routes_cmd, |
| 8818 | "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8819 | SHOW_STR |
| 8820 | BGP_STR |
| 8821 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8822 | "Neighbor to display information about\n" |
| 8823 | "Neighbor to display information about\n" |
| 8824 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8825 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8826 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8827 | show_bgp_ipv6_neighbor_received_routes_cmd, |
| 8828 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8829 | SHOW_STR |
| 8830 | BGP_STR |
| 8831 | "Address family\n" |
| 8832 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8833 | "Neighbor to display information about\n" |
| 8834 | "Neighbor to display information about\n" |
| 8835 | "Display the received routes from neighbor\n") |
| 8836 | |
| 8837 | DEFUN (show_bgp_neighbor_received_prefix_filter, |
| 8838 | show_bgp_neighbor_received_prefix_filter_cmd, |
| 8839 | "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8840 | SHOW_STR |
| 8841 | BGP_STR |
| 8842 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8843 | "Neighbor to display information about\n" |
| 8844 | "Neighbor to display information about\n" |
| 8845 | "Display information received from a BGP neighbor\n" |
| 8846 | "Display the prefixlist filter\n") |
| 8847 | { |
| 8848 | char name[BUFSIZ]; |
| 8849 | union sockunion *su; |
| 8850 | struct peer *peer; |
| 8851 | int count; |
| 8852 | |
| 8853 | su = sockunion_str2su (argv[0]); |
| 8854 | if (su == NULL) |
| 8855 | return CMD_WARNING; |
| 8856 | |
| 8857 | peer = peer_lookup (NULL, su); |
| 8858 | if (! peer) |
| 8859 | return CMD_WARNING; |
| 8860 | |
| 8861 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 8862 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 8863 | if (count) |
| 8864 | { |
| 8865 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 8866 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 8867 | } |
| 8868 | |
| 8869 | return CMD_SUCCESS; |
| 8870 | } |
| 8871 | |
| 8872 | ALIAS (show_bgp_neighbor_received_prefix_filter, |
| 8873 | show_bgp_ipv6_neighbor_received_prefix_filter_cmd, |
| 8874 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8875 | SHOW_STR |
| 8876 | BGP_STR |
| 8877 | "Address family\n" |
| 8878 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8879 | "Neighbor to display information about\n" |
| 8880 | "Neighbor to display information about\n" |
| 8881 | "Display information received from a BGP neighbor\n" |
| 8882 | "Display the prefixlist filter\n") |
| 8883 | |
| 8884 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8885 | ALIAS (show_bgp_view_neighbor_received_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8886 | ipv6_bgp_neighbor_received_routes_cmd, |
| 8887 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8888 | SHOW_STR |
| 8889 | IPV6_STR |
| 8890 | BGP_STR |
| 8891 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8892 | "Neighbor to display information about\n" |
| 8893 | "Neighbor to display information about\n" |
| 8894 | "Display the received routes from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8895 | |
| 8896 | /* old command */ |
| 8897 | DEFUN (ipv6_mbgp_neighbor_received_routes, |
| 8898 | ipv6_mbgp_neighbor_received_routes_cmd, |
| 8899 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes", |
| 8900 | SHOW_STR |
| 8901 | IPV6_STR |
| 8902 | MBGP_STR |
| 8903 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8904 | "Neighbor to display information about\n" |
| 8905 | "Neighbor to display information about\n" |
| 8906 | "Display the received routes from neighbor\n") |
| 8907 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8908 | struct peer *peer; |
| 8909 | |
| 8910 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 8911 | if (! peer) |
| 8912 | return CMD_WARNING; |
| 8913 | |
| 8914 | return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8915 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8916 | |
| 8917 | DEFUN (show_bgp_view_neighbor_received_prefix_filter, |
| 8918 | show_bgp_view_neighbor_received_prefix_filter_cmd, |
| 8919 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8920 | SHOW_STR |
| 8921 | BGP_STR |
| 8922 | "BGP view\n" |
| 8923 | "View name\n" |
| 8924 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8925 | "Neighbor to display information about\n" |
| 8926 | "Neighbor to display information about\n" |
| 8927 | "Display information received from a BGP neighbor\n" |
| 8928 | "Display the prefixlist filter\n") |
| 8929 | { |
| 8930 | char name[BUFSIZ]; |
| 8931 | union sockunion *su; |
| 8932 | struct peer *peer; |
| 8933 | struct bgp *bgp; |
| 8934 | int count; |
| 8935 | |
| 8936 | /* BGP structure lookup. */ |
| 8937 | bgp = bgp_lookup_by_name (argv[0]); |
| 8938 | if (bgp == NULL) |
| 8939 | { |
| 8940 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 8941 | return CMD_WARNING; |
| 8942 | } |
| 8943 | |
| 8944 | su = sockunion_str2su (argv[1]); |
| 8945 | if (su == NULL) |
| 8946 | return CMD_WARNING; |
| 8947 | |
| 8948 | peer = peer_lookup (bgp, su); |
| 8949 | if (! peer) |
| 8950 | return CMD_WARNING; |
| 8951 | |
| 8952 | sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST); |
| 8953 | count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name); |
| 8954 | if (count) |
| 8955 | { |
| 8956 | vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE); |
| 8957 | prefix_bgp_show_prefix_list (vty, AFI_IP6, name); |
| 8958 | } |
| 8959 | |
| 8960 | return CMD_SUCCESS; |
| 8961 | } |
| 8962 | |
| 8963 | ALIAS (show_bgp_view_neighbor_received_prefix_filter, |
| 8964 | show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd, |
| 8965 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter", |
| 8966 | SHOW_STR |
| 8967 | BGP_STR |
| 8968 | "BGP view\n" |
| 8969 | "View name\n" |
| 8970 | "Address family\n" |
| 8971 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8972 | "Neighbor to display information about\n" |
| 8973 | "Neighbor to display information about\n" |
| 8974 | "Display information received from a BGP neighbor\n" |
| 8975 | "Display the prefixlist filter\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8976 | #endif /* HAVE_IPV6 */ |
| 8977 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 8978 | static int |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 8979 | bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8980 | safi_t safi, enum bgp_show_type type) |
| 8981 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8982 | if (! peer || ! peer->afc[afi][safi]) |
| 8983 | { |
| 8984 | vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8985 | return CMD_WARNING; |
| 8986 | } |
| 8987 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 8988 | return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8989 | } |
| 8990 | |
| 8991 | DEFUN (show_ip_bgp_neighbor_routes, |
| 8992 | show_ip_bgp_neighbor_routes_cmd, |
| 8993 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 8994 | SHOW_STR |
| 8995 | IP_STR |
| 8996 | BGP_STR |
| 8997 | "Detailed information on TCP and BGP neighbor connections\n" |
| 8998 | "Neighbor to display information about\n" |
| 8999 | "Neighbor to display information about\n" |
| 9000 | "Display routes learned from neighbor\n") |
| 9001 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9002 | struct peer *peer; |
| 9003 | |
| 9004 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9005 | if (! peer) |
| 9006 | return CMD_WARNING; |
| 9007 | |
| 9008 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9009 | bgp_show_type_neighbor); |
| 9010 | } |
| 9011 | |
| 9012 | DEFUN (show_ip_bgp_neighbor_flap, |
| 9013 | show_ip_bgp_neighbor_flap_cmd, |
| 9014 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9015 | SHOW_STR |
| 9016 | IP_STR |
| 9017 | BGP_STR |
| 9018 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9019 | "Neighbor to display information about\n" |
| 9020 | "Neighbor to display information about\n" |
| 9021 | "Display flap statistics of the routes learned from neighbor\n") |
| 9022 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9023 | struct peer *peer; |
| 9024 | |
| 9025 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9026 | if (! peer) |
| 9027 | return CMD_WARNING; |
| 9028 | |
| 9029 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9030 | bgp_show_type_flap_neighbor); |
| 9031 | } |
| 9032 | |
| 9033 | DEFUN (show_ip_bgp_neighbor_damp, |
| 9034 | show_ip_bgp_neighbor_damp_cmd, |
| 9035 | "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9036 | SHOW_STR |
| 9037 | IP_STR |
| 9038 | BGP_STR |
| 9039 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9040 | "Neighbor to display information about\n" |
| 9041 | "Neighbor to display information about\n" |
| 9042 | "Display the dampened routes received from neighbor\n") |
| 9043 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9044 | struct peer *peer; |
| 9045 | |
| 9046 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9047 | if (! peer) |
| 9048 | return CMD_WARNING; |
| 9049 | |
| 9050 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9051 | bgp_show_type_damp_neighbor); |
| 9052 | } |
| 9053 | |
| 9054 | DEFUN (show_ip_bgp_ipv4_neighbor_routes, |
| 9055 | show_ip_bgp_ipv4_neighbor_routes_cmd, |
| 9056 | "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes", |
| 9057 | SHOW_STR |
| 9058 | IP_STR |
| 9059 | BGP_STR |
| 9060 | "Address family\n" |
| 9061 | "Address Family modifier\n" |
| 9062 | "Address Family modifier\n" |
| 9063 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9064 | "Neighbor to display information about\n" |
| 9065 | "Neighbor to display information about\n" |
| 9066 | "Display routes learned from neighbor\n") |
| 9067 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9068 | struct peer *peer; |
| 9069 | |
| 9070 | peer = peer_lookup_in_view (vty, NULL, argv[1]); |
| 9071 | if (! peer) |
| 9072 | return CMD_WARNING; |
| 9073 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9074 | if (strncmp (argv[0], "m", 1) == 0) |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9075 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9076 | bgp_show_type_neighbor); |
| 9077 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9078 | return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9079 | bgp_show_type_neighbor); |
| 9080 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9081 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 9082 | DEFUN (show_ip_bgp_view_rsclient, |
| 9083 | show_ip_bgp_view_rsclient_cmd, |
| 9084 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 9085 | SHOW_STR |
| 9086 | IP_STR |
| 9087 | BGP_STR |
| 9088 | "BGP view\n" |
| 9089 | "BGP view name\n" |
| 9090 | "Information about Route Server Client\n" |
| 9091 | NEIGHBOR_ADDR_STR) |
| 9092 | { |
| 9093 | struct bgp_table *table; |
| 9094 | struct peer *peer; |
| 9095 | |
| 9096 | if (argc == 2) |
| 9097 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9098 | else |
| 9099 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9100 | |
| 9101 | if (! peer) |
| 9102 | return CMD_WARNING; |
| 9103 | |
| 9104 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 9105 | { |
| 9106 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9107 | VTY_NEWLINE); |
| 9108 | return CMD_WARNING; |
| 9109 | } |
| 9110 | |
| 9111 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 9112 | PEER_FLAG_RSERVER_CLIENT)) |
| 9113 | { |
| 9114 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9115 | VTY_NEWLINE); |
| 9116 | return CMD_WARNING; |
| 9117 | } |
| 9118 | |
| 9119 | table = peer->rib[AFI_IP][SAFI_UNICAST]; |
| 9120 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9121 | 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] | 9122 | } |
| 9123 | |
| 9124 | ALIAS (show_ip_bgp_view_rsclient, |
| 9125 | show_ip_bgp_rsclient_cmd, |
| 9126 | "show ip bgp rsclient (A.B.C.D|X:X::X:X)", |
| 9127 | SHOW_STR |
| 9128 | IP_STR |
| 9129 | BGP_STR |
| 9130 | "Information about Route Server Client\n" |
| 9131 | NEIGHBOR_ADDR_STR) |
| 9132 | |
| 9133 | DEFUN (show_ip_bgp_view_rsclient_route, |
| 9134 | show_ip_bgp_view_rsclient_route_cmd, |
| 9135 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 9136 | SHOW_STR |
| 9137 | IP_STR |
| 9138 | BGP_STR |
| 9139 | "BGP view\n" |
| 9140 | "BGP view name\n" |
| 9141 | "Information about Route Server Client\n" |
| 9142 | NEIGHBOR_ADDR_STR |
| 9143 | "Network in the BGP routing table to display\n") |
| 9144 | { |
| 9145 | struct bgp *bgp; |
| 9146 | struct peer *peer; |
| 9147 | |
| 9148 | /* BGP structure lookup. */ |
| 9149 | if (argc == 3) |
| 9150 | { |
| 9151 | bgp = bgp_lookup_by_name (argv[0]); |
| 9152 | if (bgp == NULL) |
| 9153 | { |
| 9154 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9155 | return CMD_WARNING; |
| 9156 | } |
| 9157 | } |
| 9158 | else |
| 9159 | { |
| 9160 | bgp = bgp_get_default (); |
| 9161 | if (bgp == NULL) |
| 9162 | { |
| 9163 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9164 | return CMD_WARNING; |
| 9165 | } |
| 9166 | } |
| 9167 | |
| 9168 | if (argc == 3) |
| 9169 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9170 | else |
| 9171 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9172 | |
| 9173 | if (! peer) |
| 9174 | return CMD_WARNING; |
| 9175 | |
| 9176 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 9177 | { |
| 9178 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9179 | VTY_NEWLINE); |
| 9180 | return CMD_WARNING; |
| 9181 | } |
| 9182 | |
| 9183 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 9184 | PEER_FLAG_RSERVER_CLIENT)) |
| 9185 | { |
| 9186 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9187 | VTY_NEWLINE); |
| 9188 | return CMD_WARNING; |
| 9189 | } |
| 9190 | |
| 9191 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 9192 | (argc == 3) ? argv[2] : argv[1], |
| 9193 | AFI_IP, SAFI_UNICAST, NULL, 0); |
| 9194 | } |
| 9195 | |
| 9196 | ALIAS (show_ip_bgp_view_rsclient_route, |
| 9197 | show_ip_bgp_rsclient_route_cmd, |
| 9198 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D", |
| 9199 | SHOW_STR |
| 9200 | IP_STR |
| 9201 | BGP_STR |
| 9202 | "Information about Route Server Client\n" |
| 9203 | NEIGHBOR_ADDR_STR |
| 9204 | "Network in the BGP routing table to display\n") |
| 9205 | |
| 9206 | DEFUN (show_ip_bgp_view_rsclient_prefix, |
| 9207 | show_ip_bgp_view_rsclient_prefix_cmd, |
| 9208 | "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 9209 | SHOW_STR |
| 9210 | IP_STR |
| 9211 | BGP_STR |
| 9212 | "BGP view\n" |
| 9213 | "BGP view name\n" |
| 9214 | "Information about Route Server Client\n" |
| 9215 | NEIGHBOR_ADDR_STR |
| 9216 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9217 | { |
| 9218 | struct bgp *bgp; |
| 9219 | struct peer *peer; |
| 9220 | |
| 9221 | /* BGP structure lookup. */ |
| 9222 | if (argc == 3) |
| 9223 | { |
| 9224 | bgp = bgp_lookup_by_name (argv[0]); |
| 9225 | if (bgp == NULL) |
| 9226 | { |
| 9227 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9228 | return CMD_WARNING; |
| 9229 | } |
| 9230 | } |
| 9231 | else |
| 9232 | { |
| 9233 | bgp = bgp_get_default (); |
| 9234 | if (bgp == NULL) |
| 9235 | { |
| 9236 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9237 | return CMD_WARNING; |
| 9238 | } |
| 9239 | } |
| 9240 | |
| 9241 | if (argc == 3) |
| 9242 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9243 | else |
| 9244 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9245 | |
| 9246 | if (! peer) |
| 9247 | return CMD_WARNING; |
| 9248 | |
| 9249 | if (! peer->afc[AFI_IP][SAFI_UNICAST]) |
| 9250 | { |
| 9251 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9252 | VTY_NEWLINE); |
| 9253 | return CMD_WARNING; |
| 9254 | } |
| 9255 | |
| 9256 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST], |
| 9257 | PEER_FLAG_RSERVER_CLIENT)) |
| 9258 | { |
| 9259 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9260 | VTY_NEWLINE); |
| 9261 | return CMD_WARNING; |
| 9262 | } |
| 9263 | |
| 9264 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], |
| 9265 | (argc == 3) ? argv[2] : argv[1], |
| 9266 | AFI_IP, SAFI_UNICAST, NULL, 1); |
| 9267 | } |
| 9268 | |
| 9269 | ALIAS (show_ip_bgp_view_rsclient_prefix, |
| 9270 | show_ip_bgp_rsclient_prefix_cmd, |
| 9271 | "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M", |
| 9272 | SHOW_STR |
| 9273 | IP_STR |
| 9274 | BGP_STR |
| 9275 | "Information about Route Server Client\n" |
| 9276 | NEIGHBOR_ADDR_STR |
| 9277 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 9278 | |
| 9279 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9280 | #ifdef HAVE_IPV6 |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9281 | DEFUN (show_bgp_view_neighbor_routes, |
| 9282 | show_bgp_view_neighbor_routes_cmd, |
| 9283 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes", |
| 9284 | SHOW_STR |
| 9285 | BGP_STR |
| 9286 | "BGP view\n" |
| 9287 | "BGP view name\n" |
| 9288 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9289 | "Neighbor to display information about\n" |
| 9290 | "Neighbor to display information about\n" |
| 9291 | "Display routes learned from neighbor\n") |
| 9292 | { |
| 9293 | struct peer *peer; |
| 9294 | |
| 9295 | if (argc == 2) |
| 9296 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9297 | else |
| 9298 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9299 | |
| 9300 | if (! peer) |
| 9301 | return CMD_WARNING; |
| 9302 | |
| 9303 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9304 | bgp_show_type_neighbor); |
| 9305 | } |
| 9306 | |
| 9307 | ALIAS (show_bgp_view_neighbor_routes, |
| 9308 | show_bgp_view_ipv6_neighbor_routes_cmd, |
| 9309 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 9310 | SHOW_STR |
| 9311 | BGP_STR |
| 9312 | "BGP view\n" |
| 9313 | "BGP view name\n" |
| 9314 | "Address family\n" |
| 9315 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9316 | "Neighbor to display information about\n" |
| 9317 | "Neighbor to display information about\n" |
| 9318 | "Display routes learned from neighbor\n") |
| 9319 | |
| 9320 | DEFUN (show_bgp_view_neighbor_damp, |
| 9321 | show_bgp_view_neighbor_damp_cmd, |
| 9322 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9323 | SHOW_STR |
| 9324 | BGP_STR |
| 9325 | "BGP view\n" |
| 9326 | "BGP view name\n" |
| 9327 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9328 | "Neighbor to display information about\n" |
| 9329 | "Neighbor to display information about\n" |
| 9330 | "Display the dampened routes received from neighbor\n") |
| 9331 | { |
| 9332 | struct peer *peer; |
| 9333 | |
| 9334 | if (argc == 2) |
| 9335 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9336 | else |
| 9337 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9338 | |
| 9339 | if (! peer) |
| 9340 | return CMD_WARNING; |
| 9341 | |
| 9342 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9343 | bgp_show_type_damp_neighbor); |
| 9344 | } |
| 9345 | |
| 9346 | ALIAS (show_bgp_view_neighbor_damp, |
| 9347 | show_bgp_view_ipv6_neighbor_damp_cmd, |
| 9348 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9349 | SHOW_STR |
| 9350 | BGP_STR |
| 9351 | "BGP view\n" |
| 9352 | "BGP view name\n" |
| 9353 | "Address family\n" |
| 9354 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9355 | "Neighbor to display information about\n" |
| 9356 | "Neighbor to display information about\n" |
| 9357 | "Display the dampened routes received from neighbor\n") |
| 9358 | |
| 9359 | DEFUN (show_bgp_view_neighbor_flap, |
| 9360 | show_bgp_view_neighbor_flap_cmd, |
| 9361 | "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9362 | SHOW_STR |
| 9363 | BGP_STR |
| 9364 | "BGP view\n" |
| 9365 | "BGP view name\n" |
| 9366 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9367 | "Neighbor to display information about\n" |
| 9368 | "Neighbor to display information about\n" |
| 9369 | "Display flap statistics of the routes learned from neighbor\n") |
| 9370 | { |
| 9371 | struct peer *peer; |
| 9372 | |
| 9373 | if (argc == 2) |
| 9374 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9375 | else |
| 9376 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9377 | |
| 9378 | if (! peer) |
| 9379 | return CMD_WARNING; |
| 9380 | |
| 9381 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, |
| 9382 | bgp_show_type_flap_neighbor); |
| 9383 | } |
| 9384 | |
| 9385 | ALIAS (show_bgp_view_neighbor_flap, |
| 9386 | show_bgp_view_ipv6_neighbor_flap_cmd, |
| 9387 | "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9388 | SHOW_STR |
| 9389 | BGP_STR |
| 9390 | "BGP view\n" |
| 9391 | "BGP view name\n" |
| 9392 | "Address family\n" |
| 9393 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9394 | "Neighbor to display information about\n" |
| 9395 | "Neighbor to display information about\n" |
| 9396 | "Display flap statistics of the routes learned from neighbor\n") |
| 9397 | |
| 9398 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9399 | show_bgp_neighbor_routes_cmd, |
| 9400 | "show bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9401 | SHOW_STR |
| 9402 | BGP_STR |
| 9403 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9404 | "Neighbor to display information about\n" |
| 9405 | "Neighbor to display information about\n" |
| 9406 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9407 | |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9408 | |
| 9409 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9410 | show_bgp_ipv6_neighbor_routes_cmd, |
| 9411 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes", |
| 9412 | SHOW_STR |
| 9413 | BGP_STR |
| 9414 | "Address family\n" |
| 9415 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9416 | "Neighbor to display information about\n" |
| 9417 | "Neighbor to display information about\n" |
| 9418 | "Display routes learned from neighbor\n") |
| 9419 | |
| 9420 | /* old command */ |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9421 | ALIAS (show_bgp_view_neighbor_routes, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9422 | ipv6_bgp_neighbor_routes_cmd, |
| 9423 | "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9424 | SHOW_STR |
| 9425 | IPV6_STR |
| 9426 | BGP_STR |
| 9427 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9428 | "Neighbor to display information about\n" |
| 9429 | "Neighbor to display information about\n" |
| 9430 | "Display routes learned from neighbor\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9431 | |
| 9432 | /* old command */ |
| 9433 | DEFUN (ipv6_mbgp_neighbor_routes, |
| 9434 | ipv6_mbgp_neighbor_routes_cmd, |
| 9435 | "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes", |
| 9436 | SHOW_STR |
| 9437 | IPV6_STR |
| 9438 | MBGP_STR |
| 9439 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9440 | "Neighbor to display information about\n" |
| 9441 | "Neighbor to display information about\n" |
| 9442 | "Display routes learned from neighbor\n") |
| 9443 | { |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9444 | struct peer *peer; |
| 9445 | |
| 9446 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9447 | if (! peer) |
| 9448 | return CMD_WARNING; |
| 9449 | |
| 9450 | return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9451 | bgp_show_type_neighbor); |
| 9452 | } |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 9453 | |
| 9454 | ALIAS (show_bgp_view_neighbor_flap, |
| 9455 | show_bgp_neighbor_flap_cmd, |
| 9456 | "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9457 | SHOW_STR |
| 9458 | BGP_STR |
| 9459 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9460 | "Neighbor to display information about\n" |
| 9461 | "Neighbor to display information about\n" |
| 9462 | "Display flap statistics of the routes learned from neighbor\n") |
| 9463 | |
| 9464 | ALIAS (show_bgp_view_neighbor_flap, |
| 9465 | show_bgp_ipv6_neighbor_flap_cmd, |
| 9466 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics", |
| 9467 | SHOW_STR |
| 9468 | BGP_STR |
| 9469 | "Address family\n" |
| 9470 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9471 | "Neighbor to display information about\n" |
| 9472 | "Neighbor to display information about\n" |
| 9473 | "Display flap statistics of the routes learned from neighbor\n") |
| 9474 | |
| 9475 | ALIAS (show_bgp_view_neighbor_damp, |
| 9476 | show_bgp_neighbor_damp_cmd, |
| 9477 | "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9478 | SHOW_STR |
| 9479 | BGP_STR |
| 9480 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9481 | "Neighbor to display information about\n" |
| 9482 | "Neighbor to display information about\n" |
| 9483 | "Display the dampened routes received from neighbor\n") |
| 9484 | |
| 9485 | ALIAS (show_bgp_view_neighbor_damp, |
| 9486 | show_bgp_ipv6_neighbor_damp_cmd, |
| 9487 | "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes", |
| 9488 | SHOW_STR |
| 9489 | BGP_STR |
| 9490 | "Address family\n" |
| 9491 | "Detailed information on TCP and BGP neighbor connections\n" |
| 9492 | "Neighbor to display information about\n" |
| 9493 | "Neighbor to display information about\n" |
paul | c001ae6 | 2003-11-03 12:37:43 +0000 | [diff] [blame] | 9494 | "Display the dampened routes received from neighbor\n") |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 9495 | |
| 9496 | DEFUN (show_bgp_view_rsclient, |
| 9497 | show_bgp_view_rsclient_cmd, |
| 9498 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)", |
| 9499 | SHOW_STR |
| 9500 | BGP_STR |
| 9501 | "BGP view\n" |
| 9502 | "BGP view name\n" |
| 9503 | "Information about Route Server Client\n" |
| 9504 | NEIGHBOR_ADDR_STR) |
| 9505 | { |
| 9506 | struct bgp_table *table; |
| 9507 | struct peer *peer; |
| 9508 | |
| 9509 | if (argc == 2) |
| 9510 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9511 | else |
| 9512 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9513 | |
| 9514 | if (! peer) |
| 9515 | return CMD_WARNING; |
| 9516 | |
| 9517 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9518 | { |
| 9519 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9520 | VTY_NEWLINE); |
| 9521 | return CMD_WARNING; |
| 9522 | } |
| 9523 | |
| 9524 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9525 | PEER_FLAG_RSERVER_CLIENT)) |
| 9526 | { |
| 9527 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9528 | VTY_NEWLINE); |
| 9529 | return CMD_WARNING; |
| 9530 | } |
| 9531 | |
| 9532 | table = peer->rib[AFI_IP6][SAFI_UNICAST]; |
| 9533 | |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 9534 | 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] | 9535 | } |
| 9536 | |
| 9537 | ALIAS (show_bgp_view_rsclient, |
| 9538 | show_bgp_rsclient_cmd, |
| 9539 | "show bgp rsclient (A.B.C.D|X:X::X:X)", |
| 9540 | SHOW_STR |
| 9541 | BGP_STR |
| 9542 | "Information about Route Server Client\n" |
| 9543 | NEIGHBOR_ADDR_STR) |
| 9544 | |
| 9545 | DEFUN (show_bgp_view_rsclient_route, |
| 9546 | show_bgp_view_rsclient_route_cmd, |
| 9547 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 9548 | SHOW_STR |
| 9549 | BGP_STR |
| 9550 | "BGP view\n" |
| 9551 | "BGP view name\n" |
| 9552 | "Information about Route Server Client\n" |
| 9553 | NEIGHBOR_ADDR_STR |
| 9554 | "Network in the BGP routing table to display\n") |
| 9555 | { |
| 9556 | struct bgp *bgp; |
| 9557 | struct peer *peer; |
| 9558 | |
| 9559 | /* BGP structure lookup. */ |
| 9560 | if (argc == 3) |
| 9561 | { |
| 9562 | bgp = bgp_lookup_by_name (argv[0]); |
| 9563 | if (bgp == NULL) |
| 9564 | { |
| 9565 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9566 | return CMD_WARNING; |
| 9567 | } |
| 9568 | } |
| 9569 | else |
| 9570 | { |
| 9571 | bgp = bgp_get_default (); |
| 9572 | if (bgp == NULL) |
| 9573 | { |
| 9574 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9575 | return CMD_WARNING; |
| 9576 | } |
| 9577 | } |
| 9578 | |
| 9579 | if (argc == 3) |
| 9580 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9581 | else |
| 9582 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9583 | |
| 9584 | if (! peer) |
| 9585 | return CMD_WARNING; |
| 9586 | |
| 9587 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9588 | { |
| 9589 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9590 | VTY_NEWLINE); |
| 9591 | return CMD_WARNING; |
| 9592 | } |
| 9593 | |
| 9594 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9595 | PEER_FLAG_RSERVER_CLIENT)) |
| 9596 | { |
| 9597 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9598 | VTY_NEWLINE); |
| 9599 | return CMD_WARNING; |
| 9600 | } |
| 9601 | |
| 9602 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 9603 | (argc == 3) ? argv[2] : argv[1], |
| 9604 | AFI_IP6, SAFI_UNICAST, NULL, 0); |
| 9605 | } |
| 9606 | |
| 9607 | ALIAS (show_bgp_view_rsclient_route, |
| 9608 | show_bgp_rsclient_route_cmd, |
| 9609 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X", |
| 9610 | SHOW_STR |
| 9611 | BGP_STR |
| 9612 | "Information about Route Server Client\n" |
| 9613 | NEIGHBOR_ADDR_STR |
| 9614 | "Network in the BGP routing table to display\n") |
| 9615 | |
| 9616 | DEFUN (show_bgp_view_rsclient_prefix, |
| 9617 | show_bgp_view_rsclient_prefix_cmd, |
| 9618 | "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 9619 | SHOW_STR |
| 9620 | BGP_STR |
| 9621 | "BGP view\n" |
| 9622 | "BGP view name\n" |
| 9623 | "Information about Route Server Client\n" |
| 9624 | NEIGHBOR_ADDR_STR |
| 9625 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 9626 | { |
| 9627 | struct bgp *bgp; |
| 9628 | struct peer *peer; |
| 9629 | |
| 9630 | /* BGP structure lookup. */ |
| 9631 | if (argc == 3) |
| 9632 | { |
| 9633 | bgp = bgp_lookup_by_name (argv[0]); |
| 9634 | if (bgp == NULL) |
| 9635 | { |
| 9636 | vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); |
| 9637 | return CMD_WARNING; |
| 9638 | } |
| 9639 | } |
| 9640 | else |
| 9641 | { |
| 9642 | bgp = bgp_get_default (); |
| 9643 | if (bgp == NULL) |
| 9644 | { |
| 9645 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); |
| 9646 | return CMD_WARNING; |
| 9647 | } |
| 9648 | } |
| 9649 | |
| 9650 | if (argc == 3) |
| 9651 | peer = peer_lookup_in_view (vty, argv[0], argv[1]); |
| 9652 | else |
| 9653 | peer = peer_lookup_in_view (vty, NULL, argv[0]); |
| 9654 | |
| 9655 | if (! peer) |
| 9656 | return CMD_WARNING; |
| 9657 | |
| 9658 | if (! peer->afc[AFI_IP6][SAFI_UNICAST]) |
| 9659 | { |
| 9660 | vty_out (vty, "%% Activate the neighbor for the address family first%s", |
| 9661 | VTY_NEWLINE); |
| 9662 | return CMD_WARNING; |
| 9663 | } |
| 9664 | |
| 9665 | if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST], |
| 9666 | PEER_FLAG_RSERVER_CLIENT)) |
| 9667 | { |
| 9668 | vty_out (vty, "%% Neighbor is not a Route-Server client%s", |
| 9669 | VTY_NEWLINE); |
| 9670 | return CMD_WARNING; |
| 9671 | } |
| 9672 | |
| 9673 | return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST], |
| 9674 | (argc == 3) ? argv[2] : argv[1], |
| 9675 | AFI_IP6, SAFI_UNICAST, NULL, 1); |
| 9676 | } |
| 9677 | |
| 9678 | ALIAS (show_bgp_view_rsclient_prefix, |
| 9679 | show_bgp_rsclient_prefix_cmd, |
| 9680 | "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M", |
| 9681 | SHOW_STR |
| 9682 | BGP_STR |
| 9683 | "Information about Route Server Client\n" |
| 9684 | NEIGHBOR_ADDR_STR |
| 9685 | "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") |
| 9686 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9687 | #endif /* HAVE_IPV6 */ |
| 9688 | |
| 9689 | struct bgp_table *bgp_distance_table; |
| 9690 | |
| 9691 | struct bgp_distance |
| 9692 | { |
| 9693 | /* Distance value for the IP source prefix. */ |
| 9694 | u_char distance; |
| 9695 | |
| 9696 | /* Name of the access-list to be matched. */ |
| 9697 | char *access_list; |
| 9698 | }; |
| 9699 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9700 | static struct bgp_distance * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9701 | bgp_distance_new () |
| 9702 | { |
| 9703 | struct bgp_distance *new; |
| 9704 | new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); |
| 9705 | memset (new, 0, sizeof (struct bgp_distance)); |
| 9706 | return new; |
| 9707 | } |
| 9708 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9709 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9710 | bgp_distance_free (struct bgp_distance *bdistance) |
| 9711 | { |
| 9712 | XFREE (MTYPE_BGP_DISTANCE, bdistance); |
| 9713 | } |
| 9714 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9715 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9716 | bgp_distance_set (struct vty *vty, const char *distance_str, |
| 9717 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9718 | { |
| 9719 | int ret; |
| 9720 | struct prefix_ipv4 p; |
| 9721 | u_char distance; |
| 9722 | struct bgp_node *rn; |
| 9723 | struct bgp_distance *bdistance; |
| 9724 | |
| 9725 | ret = str2prefix_ipv4 (ip_str, &p); |
| 9726 | if (ret == 0) |
| 9727 | { |
| 9728 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 9729 | return CMD_WARNING; |
| 9730 | } |
| 9731 | |
| 9732 | distance = atoi (distance_str); |
| 9733 | |
| 9734 | /* Get BGP distance node. */ |
| 9735 | rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p); |
| 9736 | if (rn->info) |
| 9737 | { |
| 9738 | bdistance = rn->info; |
| 9739 | bgp_unlock_node (rn); |
| 9740 | } |
| 9741 | else |
| 9742 | { |
| 9743 | bdistance = bgp_distance_new (); |
| 9744 | rn->info = bdistance; |
| 9745 | } |
| 9746 | |
| 9747 | /* Set distance value. */ |
| 9748 | bdistance->distance = distance; |
| 9749 | |
| 9750 | /* Reset access-list configuration. */ |
| 9751 | if (bdistance->access_list) |
| 9752 | { |
| 9753 | free (bdistance->access_list); |
| 9754 | bdistance->access_list = NULL; |
| 9755 | } |
| 9756 | if (access_list_str) |
| 9757 | bdistance->access_list = strdup (access_list_str); |
| 9758 | |
| 9759 | return CMD_SUCCESS; |
| 9760 | } |
| 9761 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9762 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 9763 | bgp_distance_unset (struct vty *vty, const char *distance_str, |
| 9764 | const char *ip_str, const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9765 | { |
| 9766 | int ret; |
| 9767 | struct prefix_ipv4 p; |
| 9768 | u_char distance; |
| 9769 | struct bgp_node *rn; |
| 9770 | struct bgp_distance *bdistance; |
| 9771 | |
| 9772 | ret = str2prefix_ipv4 (ip_str, &p); |
| 9773 | if (ret == 0) |
| 9774 | { |
| 9775 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 9776 | return CMD_WARNING; |
| 9777 | } |
| 9778 | |
| 9779 | distance = atoi (distance_str); |
| 9780 | |
| 9781 | rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p); |
| 9782 | if (! rn) |
| 9783 | { |
| 9784 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 9785 | return CMD_WARNING; |
| 9786 | } |
| 9787 | |
| 9788 | bdistance = rn->info; |
| 9789 | |
| 9790 | if (bdistance->access_list) |
| 9791 | free (bdistance->access_list); |
| 9792 | bgp_distance_free (bdistance); |
| 9793 | |
| 9794 | rn->info = NULL; |
| 9795 | bgp_unlock_node (rn); |
| 9796 | bgp_unlock_node (rn); |
| 9797 | |
| 9798 | return CMD_SUCCESS; |
| 9799 | } |
| 9800 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 9801 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 9802 | bgp_distance_reset () |
| 9803 | { |
| 9804 | struct bgp_node *rn; |
| 9805 | struct bgp_distance *bdistance; |
| 9806 | |
| 9807 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 9808 | if ((bdistance = rn->info) != NULL) |
| 9809 | { |
| 9810 | if (bdistance->access_list) |
| 9811 | free (bdistance->access_list); |
| 9812 | bgp_distance_free (bdistance); |
| 9813 | rn->info = NULL; |
| 9814 | bgp_unlock_node (rn); |
| 9815 | } |
| 9816 | } |
| 9817 | |
| 9818 | /* Apply BGP information to distance method. */ |
| 9819 | u_char |
| 9820 | bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp) |
| 9821 | { |
| 9822 | struct bgp_node *rn; |
| 9823 | struct prefix_ipv4 q; |
| 9824 | struct peer *peer; |
| 9825 | struct bgp_distance *bdistance; |
| 9826 | struct access_list *alist; |
| 9827 | struct bgp_static *bgp_static; |
| 9828 | |
| 9829 | if (! bgp) |
| 9830 | return 0; |
| 9831 | |
| 9832 | if (p->family != AF_INET) |
| 9833 | return 0; |
| 9834 | |
| 9835 | peer = rinfo->peer; |
| 9836 | |
| 9837 | if (peer->su.sa.sa_family != AF_INET) |
| 9838 | return 0; |
| 9839 | |
| 9840 | memset (&q, 0, sizeof (struct prefix_ipv4)); |
| 9841 | q.family = AF_INET; |
| 9842 | q.prefix = peer->su.sin.sin_addr; |
| 9843 | q.prefixlen = IPV4_MAX_BITLEN; |
| 9844 | |
| 9845 | /* Check source address. */ |
| 9846 | rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q); |
| 9847 | if (rn) |
| 9848 | { |
| 9849 | bdistance = rn->info; |
| 9850 | bgp_unlock_node (rn); |
| 9851 | |
| 9852 | if (bdistance->access_list) |
| 9853 | { |
| 9854 | alist = access_list_lookup (AFI_IP, bdistance->access_list); |
| 9855 | if (alist && access_list_apply (alist, p) == FILTER_PERMIT) |
| 9856 | return bdistance->distance; |
| 9857 | } |
| 9858 | else |
| 9859 | return bdistance->distance; |
| 9860 | } |
| 9861 | |
| 9862 | /* Backdoor check. */ |
| 9863 | rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p); |
| 9864 | if (rn) |
| 9865 | { |
| 9866 | bgp_static = rn->info; |
| 9867 | bgp_unlock_node (rn); |
| 9868 | |
| 9869 | if (bgp_static->backdoor) |
| 9870 | { |
| 9871 | if (bgp->distance_local) |
| 9872 | return bgp->distance_local; |
| 9873 | else |
| 9874 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 9875 | } |
| 9876 | } |
| 9877 | |
| 9878 | if (peer_sort (peer) == BGP_PEER_EBGP) |
| 9879 | { |
| 9880 | if (bgp->distance_ebgp) |
| 9881 | return bgp->distance_ebgp; |
| 9882 | return ZEBRA_EBGP_DISTANCE_DEFAULT; |
| 9883 | } |
| 9884 | else |
| 9885 | { |
| 9886 | if (bgp->distance_ibgp) |
| 9887 | return bgp->distance_ibgp; |
| 9888 | return ZEBRA_IBGP_DISTANCE_DEFAULT; |
| 9889 | } |
| 9890 | } |
| 9891 | |
| 9892 | DEFUN (bgp_distance, |
| 9893 | bgp_distance_cmd, |
| 9894 | "distance bgp <1-255> <1-255> <1-255>", |
| 9895 | "Define an administrative distance\n" |
| 9896 | "BGP distance\n" |
| 9897 | "Distance for routes external to the AS\n" |
| 9898 | "Distance for routes internal to the AS\n" |
| 9899 | "Distance for local routes\n") |
| 9900 | { |
| 9901 | struct bgp *bgp; |
| 9902 | |
| 9903 | bgp = vty->index; |
| 9904 | |
| 9905 | bgp->distance_ebgp = atoi (argv[0]); |
| 9906 | bgp->distance_ibgp = atoi (argv[1]); |
| 9907 | bgp->distance_local = atoi (argv[2]); |
| 9908 | return CMD_SUCCESS; |
| 9909 | } |
| 9910 | |
| 9911 | DEFUN (no_bgp_distance, |
| 9912 | no_bgp_distance_cmd, |
| 9913 | "no distance bgp <1-255> <1-255> <1-255>", |
| 9914 | NO_STR |
| 9915 | "Define an administrative distance\n" |
| 9916 | "BGP distance\n" |
| 9917 | "Distance for routes external to the AS\n" |
| 9918 | "Distance for routes internal to the AS\n" |
| 9919 | "Distance for local routes\n") |
| 9920 | { |
| 9921 | struct bgp *bgp; |
| 9922 | |
| 9923 | bgp = vty->index; |
| 9924 | |
| 9925 | bgp->distance_ebgp= 0; |
| 9926 | bgp->distance_ibgp = 0; |
| 9927 | bgp->distance_local = 0; |
| 9928 | return CMD_SUCCESS; |
| 9929 | } |
| 9930 | |
| 9931 | ALIAS (no_bgp_distance, |
| 9932 | no_bgp_distance2_cmd, |
| 9933 | "no distance bgp", |
| 9934 | NO_STR |
| 9935 | "Define an administrative distance\n" |
| 9936 | "BGP distance\n") |
| 9937 | |
| 9938 | DEFUN (bgp_distance_source, |
| 9939 | bgp_distance_source_cmd, |
| 9940 | "distance <1-255> A.B.C.D/M", |
| 9941 | "Define an administrative distance\n" |
| 9942 | "Administrative distance\n" |
| 9943 | "IP source prefix\n") |
| 9944 | { |
| 9945 | bgp_distance_set (vty, argv[0], argv[1], NULL); |
| 9946 | return CMD_SUCCESS; |
| 9947 | } |
| 9948 | |
| 9949 | DEFUN (no_bgp_distance_source, |
| 9950 | no_bgp_distance_source_cmd, |
| 9951 | "no distance <1-255> A.B.C.D/M", |
| 9952 | NO_STR |
| 9953 | "Define an administrative distance\n" |
| 9954 | "Administrative distance\n" |
| 9955 | "IP source prefix\n") |
| 9956 | { |
| 9957 | bgp_distance_unset (vty, argv[0], argv[1], NULL); |
| 9958 | return CMD_SUCCESS; |
| 9959 | } |
| 9960 | |
| 9961 | DEFUN (bgp_distance_source_access_list, |
| 9962 | bgp_distance_source_access_list_cmd, |
| 9963 | "distance <1-255> A.B.C.D/M WORD", |
| 9964 | "Define an administrative distance\n" |
| 9965 | "Administrative distance\n" |
| 9966 | "IP source prefix\n" |
| 9967 | "Access list name\n") |
| 9968 | { |
| 9969 | bgp_distance_set (vty, argv[0], argv[1], argv[2]); |
| 9970 | return CMD_SUCCESS; |
| 9971 | } |
| 9972 | |
| 9973 | DEFUN (no_bgp_distance_source_access_list, |
| 9974 | no_bgp_distance_source_access_list_cmd, |
| 9975 | "no distance <1-255> A.B.C.D/M WORD", |
| 9976 | NO_STR |
| 9977 | "Define an administrative distance\n" |
| 9978 | "Administrative distance\n" |
| 9979 | "IP source prefix\n" |
| 9980 | "Access list name\n") |
| 9981 | { |
| 9982 | bgp_distance_unset (vty, argv[0], argv[1], argv[2]); |
| 9983 | return CMD_SUCCESS; |
| 9984 | } |
| 9985 | |
| 9986 | DEFUN (bgp_damp_set, |
| 9987 | bgp_damp_set_cmd, |
| 9988 | "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 9989 | "BGP Specific commands\n" |
| 9990 | "Enable route-flap dampening\n" |
| 9991 | "Half-life time for the penalty\n" |
| 9992 | "Value to start reusing a route\n" |
| 9993 | "Value to start suppressing a route\n" |
| 9994 | "Maximum duration to suppress a stable route\n") |
| 9995 | { |
| 9996 | struct bgp *bgp; |
| 9997 | int half = DEFAULT_HALF_LIFE * 60; |
| 9998 | int reuse = DEFAULT_REUSE; |
| 9999 | int suppress = DEFAULT_SUPPRESS; |
| 10000 | int max = 4 * half; |
| 10001 | |
| 10002 | if (argc == 4) |
| 10003 | { |
| 10004 | half = atoi (argv[0]) * 60; |
| 10005 | reuse = atoi (argv[1]); |
| 10006 | suppress = atoi (argv[2]); |
| 10007 | max = atoi (argv[3]) * 60; |
| 10008 | } |
| 10009 | else if (argc == 1) |
| 10010 | { |
| 10011 | half = atoi (argv[0]) * 60; |
| 10012 | max = 4 * half; |
| 10013 | } |
| 10014 | |
| 10015 | bgp = vty->index; |
| 10016 | return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty), |
| 10017 | half, reuse, suppress, max); |
| 10018 | } |
| 10019 | |
| 10020 | ALIAS (bgp_damp_set, |
| 10021 | bgp_damp_set2_cmd, |
| 10022 | "bgp dampening <1-45>", |
| 10023 | "BGP Specific commands\n" |
| 10024 | "Enable route-flap dampening\n" |
| 10025 | "Half-life time for the penalty\n") |
| 10026 | |
| 10027 | ALIAS (bgp_damp_set, |
| 10028 | bgp_damp_set3_cmd, |
| 10029 | "bgp dampening", |
| 10030 | "BGP Specific commands\n" |
| 10031 | "Enable route-flap dampening\n") |
| 10032 | |
| 10033 | DEFUN (bgp_damp_unset, |
| 10034 | bgp_damp_unset_cmd, |
| 10035 | "no bgp dampening", |
| 10036 | NO_STR |
| 10037 | "BGP Specific commands\n" |
| 10038 | "Enable route-flap dampening\n") |
| 10039 | { |
| 10040 | struct bgp *bgp; |
| 10041 | |
| 10042 | bgp = vty->index; |
| 10043 | return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); |
| 10044 | } |
| 10045 | |
| 10046 | ALIAS (bgp_damp_unset, |
| 10047 | bgp_damp_unset2_cmd, |
| 10048 | "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", |
| 10049 | NO_STR |
| 10050 | "BGP Specific commands\n" |
| 10051 | "Enable route-flap dampening\n" |
| 10052 | "Half-life time for the penalty\n" |
| 10053 | "Value to start reusing a route\n" |
| 10054 | "Value to start suppressing a route\n" |
| 10055 | "Maximum duration to suppress a stable route\n") |
| 10056 | |
| 10057 | DEFUN (show_ip_bgp_dampened_paths, |
| 10058 | show_ip_bgp_dampened_paths_cmd, |
| 10059 | "show ip bgp dampened-paths", |
| 10060 | SHOW_STR |
| 10061 | IP_STR |
| 10062 | BGP_STR |
| 10063 | "Display paths suppressed due to dampening\n") |
| 10064 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10065 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, |
| 10066 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10067 | } |
| 10068 | |
| 10069 | DEFUN (show_ip_bgp_flap_statistics, |
| 10070 | show_ip_bgp_flap_statistics_cmd, |
| 10071 | "show ip bgp flap-statistics", |
| 10072 | SHOW_STR |
| 10073 | IP_STR |
| 10074 | BGP_STR |
| 10075 | "Display flap statistics of routes\n") |
| 10076 | { |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 10077 | return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, |
| 10078 | bgp_show_type_flap_statistics, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10079 | } |
| 10080 | |
| 10081 | /* Display specified route of BGP table. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10082 | static int |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 10083 | bgp_clear_damp_route (struct vty *vty, const char *view_name, |
| 10084 | const char *ip_str, afi_t afi, safi_t safi, |
| 10085 | struct prefix_rd *prd, int prefix_check) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10086 | { |
| 10087 | int ret; |
| 10088 | struct prefix match; |
| 10089 | struct bgp_node *rn; |
| 10090 | struct bgp_node *rm; |
| 10091 | struct bgp_info *ri; |
| 10092 | struct bgp_info *ri_temp; |
| 10093 | struct bgp *bgp; |
| 10094 | struct bgp_table *table; |
| 10095 | |
| 10096 | /* BGP structure lookup. */ |
| 10097 | if (view_name) |
| 10098 | { |
| 10099 | bgp = bgp_lookup_by_name (view_name); |
| 10100 | if (bgp == NULL) |
| 10101 | { |
| 10102 | vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE); |
| 10103 | return CMD_WARNING; |
| 10104 | } |
| 10105 | } |
| 10106 | else |
| 10107 | { |
| 10108 | bgp = bgp_get_default (); |
| 10109 | if (bgp == NULL) |
| 10110 | { |
| 10111 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); |
| 10112 | return CMD_WARNING; |
| 10113 | } |
| 10114 | } |
| 10115 | |
| 10116 | /* Check IP address argument. */ |
| 10117 | ret = str2prefix (ip_str, &match); |
| 10118 | if (! ret) |
| 10119 | { |
| 10120 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); |
| 10121 | return CMD_WARNING; |
| 10122 | } |
| 10123 | |
| 10124 | match.family = afi2family (afi); |
| 10125 | |
| 10126 | if (safi == SAFI_MPLS_VPN) |
| 10127 | { |
| 10128 | for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) |
| 10129 | { |
| 10130 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) |
| 10131 | continue; |
| 10132 | |
| 10133 | if ((table = rn->info) != NULL) |
| 10134 | if ((rm = bgp_node_match (table, &match)) != NULL) |
| 10135 | if (! prefix_check || rm->p.prefixlen == match.prefixlen) |
| 10136 | { |
| 10137 | ri = rm->info; |
| 10138 | while (ri) |
| 10139 | { |
| 10140 | if (ri->damp_info) |
| 10141 | { |
| 10142 | ri_temp = ri->next; |
| 10143 | bgp_damp_info_free (ri->damp_info, 1); |
| 10144 | ri = ri_temp; |
| 10145 | } |
| 10146 | else |
| 10147 | ri = ri->next; |
| 10148 | } |
| 10149 | } |
| 10150 | } |
| 10151 | } |
| 10152 | else |
| 10153 | { |
| 10154 | if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL) |
| 10155 | if (! prefix_check || rn->p.prefixlen == match.prefixlen) |
| 10156 | { |
| 10157 | ri = rn->info; |
| 10158 | while (ri) |
| 10159 | { |
| 10160 | if (ri->damp_info) |
| 10161 | { |
| 10162 | ri_temp = ri->next; |
| 10163 | bgp_damp_info_free (ri->damp_info, 1); |
| 10164 | ri = ri_temp; |
| 10165 | } |
| 10166 | else |
| 10167 | ri = ri->next; |
| 10168 | } |
| 10169 | } |
| 10170 | } |
| 10171 | |
| 10172 | return CMD_SUCCESS; |
| 10173 | } |
| 10174 | |
| 10175 | DEFUN (clear_ip_bgp_dampening, |
| 10176 | clear_ip_bgp_dampening_cmd, |
| 10177 | "clear ip bgp dampening", |
| 10178 | CLEAR_STR |
| 10179 | IP_STR |
| 10180 | BGP_STR |
| 10181 | "Clear route flap dampening information\n") |
| 10182 | { |
| 10183 | bgp_damp_info_clean (); |
| 10184 | return CMD_SUCCESS; |
| 10185 | } |
| 10186 | |
| 10187 | DEFUN (clear_ip_bgp_dampening_prefix, |
| 10188 | clear_ip_bgp_dampening_prefix_cmd, |
| 10189 | "clear ip bgp dampening A.B.C.D/M", |
| 10190 | CLEAR_STR |
| 10191 | IP_STR |
| 10192 | BGP_STR |
| 10193 | "Clear route flap dampening information\n" |
| 10194 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 10195 | { |
| 10196 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 10197 | SAFI_UNICAST, NULL, 1); |
| 10198 | } |
| 10199 | |
| 10200 | DEFUN (clear_ip_bgp_dampening_address, |
| 10201 | clear_ip_bgp_dampening_address_cmd, |
| 10202 | "clear ip bgp dampening A.B.C.D", |
| 10203 | CLEAR_STR |
| 10204 | IP_STR |
| 10205 | BGP_STR |
| 10206 | "Clear route flap dampening information\n" |
| 10207 | "Network to clear damping information\n") |
| 10208 | { |
| 10209 | return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP, |
| 10210 | SAFI_UNICAST, NULL, 0); |
| 10211 | } |
| 10212 | |
| 10213 | DEFUN (clear_ip_bgp_dampening_address_mask, |
| 10214 | clear_ip_bgp_dampening_address_mask_cmd, |
| 10215 | "clear ip bgp dampening A.B.C.D A.B.C.D", |
| 10216 | CLEAR_STR |
| 10217 | IP_STR |
| 10218 | BGP_STR |
| 10219 | "Clear route flap dampening information\n" |
| 10220 | "Network to clear damping information\n" |
| 10221 | "Network mask\n") |
| 10222 | { |
| 10223 | int ret; |
| 10224 | char prefix_str[BUFSIZ]; |
| 10225 | |
| 10226 | ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); |
| 10227 | if (! ret) |
| 10228 | { |
| 10229 | vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE); |
| 10230 | return CMD_WARNING; |
| 10231 | } |
| 10232 | |
| 10233 | return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, |
| 10234 | SAFI_UNICAST, NULL, 0); |
| 10235 | } |
| 10236 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 10237 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10238 | bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, |
| 10239 | afi_t afi, safi_t safi, int *write) |
| 10240 | { |
| 10241 | struct bgp_node *prn; |
| 10242 | struct bgp_node *rn; |
| 10243 | struct bgp_table *table; |
| 10244 | struct prefix *p; |
| 10245 | struct prefix_rd *prd; |
| 10246 | struct bgp_static *bgp_static; |
| 10247 | u_int32_t label; |
| 10248 | char buf[SU_ADDRSTRLEN]; |
| 10249 | char rdbuf[RD_ADDRSTRLEN]; |
| 10250 | |
| 10251 | /* Network configuration. */ |
| 10252 | for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) |
| 10253 | if ((table = prn->info) != NULL) |
| 10254 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) |
| 10255 | if ((bgp_static = rn->info) != NULL) |
| 10256 | { |
| 10257 | p = &rn->p; |
| 10258 | prd = (struct prefix_rd *) &prn->p; |
| 10259 | |
| 10260 | /* "address-family" display. */ |
| 10261 | bgp_config_write_family_header (vty, afi, safi, write); |
| 10262 | |
| 10263 | /* "network" configuration display. */ |
| 10264 | prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN); |
| 10265 | label = decode_label (bgp_static->tag); |
| 10266 | |
| 10267 | vty_out (vty, " network %s/%d rd %s tag %d", |
| 10268 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10269 | p->prefixlen, |
| 10270 | rdbuf, label); |
| 10271 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10272 | } |
| 10273 | return 0; |
| 10274 | } |
| 10275 | |
| 10276 | /* Configuration of static route announcement and aggregate |
| 10277 | information. */ |
| 10278 | int |
| 10279 | bgp_config_write_network (struct vty *vty, struct bgp *bgp, |
| 10280 | afi_t afi, safi_t safi, int *write) |
| 10281 | { |
| 10282 | struct bgp_node *rn; |
| 10283 | struct prefix *p; |
| 10284 | struct bgp_static *bgp_static; |
| 10285 | struct bgp_aggregate *bgp_aggregate; |
| 10286 | char buf[SU_ADDRSTRLEN]; |
| 10287 | |
| 10288 | if (afi == AFI_IP && safi == SAFI_MPLS_VPN) |
| 10289 | return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); |
| 10290 | |
| 10291 | /* Network configuration. */ |
| 10292 | for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 10293 | if ((bgp_static = rn->info) != NULL) |
| 10294 | { |
| 10295 | p = &rn->p; |
| 10296 | |
| 10297 | /* "address-family" display. */ |
| 10298 | bgp_config_write_family_header (vty, afi, safi, write); |
| 10299 | |
| 10300 | /* "network" configuration display. */ |
| 10301 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 10302 | { |
| 10303 | u_int32_t destination; |
| 10304 | struct in_addr netmask; |
| 10305 | |
| 10306 | destination = ntohl (p->u.prefix4.s_addr); |
| 10307 | masklen2ip (p->prefixlen, &netmask); |
| 10308 | vty_out (vty, " network %s", |
| 10309 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN)); |
| 10310 | |
| 10311 | if ((IN_CLASSC (destination) && p->prefixlen == 24) |
| 10312 | || (IN_CLASSB (destination) && p->prefixlen == 16) |
| 10313 | || (IN_CLASSA (destination) && p->prefixlen == 8) |
| 10314 | || p->u.prefix4.s_addr == 0) |
| 10315 | { |
| 10316 | /* Natural mask is not display. */ |
| 10317 | } |
| 10318 | else |
| 10319 | vty_out (vty, " mask %s", inet_ntoa (netmask)); |
| 10320 | } |
| 10321 | else |
| 10322 | { |
| 10323 | vty_out (vty, " network %s/%d", |
| 10324 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10325 | p->prefixlen); |
| 10326 | } |
| 10327 | |
| 10328 | if (bgp_static->rmap.name) |
| 10329 | vty_out (vty, " route-map %s", bgp_static->rmap.name); |
| 10330 | else if (bgp_static->backdoor) |
| 10331 | vty_out (vty, " backdoor"); |
| 10332 | |
| 10333 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10334 | } |
| 10335 | |
| 10336 | /* Aggregate-address configuration. */ |
| 10337 | for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn)) |
| 10338 | if ((bgp_aggregate = rn->info) != NULL) |
| 10339 | { |
| 10340 | p = &rn->p; |
| 10341 | |
| 10342 | /* "address-family" display. */ |
| 10343 | bgp_config_write_family_header (vty, afi, safi, write); |
| 10344 | |
| 10345 | if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) |
| 10346 | { |
| 10347 | struct in_addr netmask; |
| 10348 | |
| 10349 | masklen2ip (p->prefixlen, &netmask); |
| 10350 | vty_out (vty, " aggregate-address %s %s", |
| 10351 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10352 | inet_ntoa (netmask)); |
| 10353 | } |
| 10354 | else |
| 10355 | { |
| 10356 | vty_out (vty, " aggregate-address %s/%d", |
| 10357 | inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), |
| 10358 | p->prefixlen); |
| 10359 | } |
| 10360 | |
| 10361 | if (bgp_aggregate->as_set) |
| 10362 | vty_out (vty, " as-set"); |
| 10363 | |
| 10364 | if (bgp_aggregate->summary_only) |
| 10365 | vty_out (vty, " summary-only"); |
| 10366 | |
| 10367 | vty_out (vty, "%s", VTY_NEWLINE); |
| 10368 | } |
| 10369 | |
| 10370 | return 0; |
| 10371 | } |
| 10372 | |
| 10373 | int |
| 10374 | bgp_config_write_distance (struct vty *vty, struct bgp *bgp) |
| 10375 | { |
| 10376 | struct bgp_node *rn; |
| 10377 | struct bgp_distance *bdistance; |
| 10378 | |
| 10379 | /* Distance configuration. */ |
| 10380 | if (bgp->distance_ebgp |
| 10381 | && bgp->distance_ibgp |
| 10382 | && bgp->distance_local |
| 10383 | && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT |
| 10384 | || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT |
| 10385 | || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT)) |
| 10386 | vty_out (vty, " distance bgp %d %d %d%s", |
| 10387 | bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, |
| 10388 | VTY_NEWLINE); |
| 10389 | |
| 10390 | for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) |
| 10391 | if ((bdistance = rn->info) != NULL) |
| 10392 | { |
| 10393 | vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance, |
| 10394 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 10395 | bdistance->access_list ? bdistance->access_list : "", |
| 10396 | VTY_NEWLINE); |
| 10397 | } |
| 10398 | |
| 10399 | return 0; |
| 10400 | } |
| 10401 | |
| 10402 | /* Allocate routing table structure and install commands. */ |
| 10403 | void |
| 10404 | bgp_route_init () |
| 10405 | { |
| 10406 | /* Init BGP distance table. */ |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 10407 | bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10408 | |
| 10409 | /* IPv4 BGP commands. */ |
| 10410 | install_element (BGP_NODE, &bgp_network_cmd); |
| 10411 | install_element (BGP_NODE, &bgp_network_mask_cmd); |
| 10412 | install_element (BGP_NODE, &bgp_network_mask_natural_cmd); |
| 10413 | install_element (BGP_NODE, &bgp_network_route_map_cmd); |
| 10414 | install_element (BGP_NODE, &bgp_network_mask_route_map_cmd); |
| 10415 | install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10416 | install_element (BGP_NODE, &bgp_network_backdoor_cmd); |
| 10417 | install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd); |
| 10418 | install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd); |
| 10419 | install_element (BGP_NODE, &no_bgp_network_cmd); |
| 10420 | install_element (BGP_NODE, &no_bgp_network_mask_cmd); |
| 10421 | install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd); |
| 10422 | install_element (BGP_NODE, &no_bgp_network_route_map_cmd); |
| 10423 | install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10424 | install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10425 | install_element (BGP_NODE, &no_bgp_network_backdoor_cmd); |
| 10426 | install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd); |
| 10427 | install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd); |
| 10428 | |
| 10429 | install_element (BGP_NODE, &aggregate_address_cmd); |
| 10430 | install_element (BGP_NODE, &aggregate_address_mask_cmd); |
| 10431 | install_element (BGP_NODE, &aggregate_address_summary_only_cmd); |
| 10432 | install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10433 | install_element (BGP_NODE, &aggregate_address_as_set_cmd); |
| 10434 | install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd); |
| 10435 | install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd); |
| 10436 | install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10437 | install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd); |
| 10438 | install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10439 | install_element (BGP_NODE, &no_aggregate_address_cmd); |
| 10440 | install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd); |
| 10441 | install_element (BGP_NODE, &no_aggregate_address_as_set_cmd); |
| 10442 | install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10443 | install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10444 | install_element (BGP_NODE, &no_aggregate_address_mask_cmd); |
| 10445 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10446 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10447 | install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10448 | install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10449 | |
| 10450 | /* IPv4 unicast configuration. */ |
| 10451 | install_element (BGP_IPV4_NODE, &bgp_network_cmd); |
| 10452 | install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd); |
| 10453 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd); |
| 10454 | install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd); |
| 10455 | install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd); |
| 10456 | install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10457 | install_element (BGP_IPV4_NODE, &no_bgp_network_cmd); |
| 10458 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd); |
| 10459 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd); |
| 10460 | install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd); |
| 10461 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10462 | install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10463 | install_element (BGP_IPV4_NODE, &aggregate_address_cmd); |
| 10464 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd); |
| 10465 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd); |
| 10466 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10467 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd); |
| 10468 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd); |
| 10469 | install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd); |
| 10470 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10471 | install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd); |
| 10472 | install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10473 | install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd); |
| 10474 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd); |
| 10475 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd); |
| 10476 | install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10477 | install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10478 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd); |
| 10479 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10480 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10481 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10482 | install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10483 | |
| 10484 | /* IPv4 multicast configuration. */ |
| 10485 | install_element (BGP_IPV4M_NODE, &bgp_network_cmd); |
| 10486 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd); |
| 10487 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd); |
| 10488 | install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd); |
| 10489 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd); |
| 10490 | install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd); |
| 10491 | install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd); |
| 10492 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd); |
| 10493 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd); |
| 10494 | install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd); |
| 10495 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd); |
| 10496 | install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd); |
| 10497 | install_element (BGP_IPV4M_NODE, &aggregate_address_cmd); |
| 10498 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd); |
| 10499 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd); |
| 10500 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd); |
| 10501 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd); |
| 10502 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd); |
| 10503 | install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd); |
| 10504 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd); |
| 10505 | install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd); |
| 10506 | install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd); |
| 10507 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); |
| 10508 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd); |
| 10509 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd); |
| 10510 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd); |
| 10511 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd); |
| 10512 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); |
| 10513 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd); |
| 10514 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd); |
| 10515 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd); |
| 10516 | install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd); |
| 10517 | |
| 10518 | install_element (VIEW_NODE, &show_ip_bgp_cmd); |
| 10519 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); |
| 10520 | install_element (VIEW_NODE, &show_ip_bgp_route_cmd); |
| 10521 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 10522 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 10523 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 10524 | install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); |
| 10525 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 10526 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 10527 | install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 10528 | install_element (VIEW_NODE, &show_ip_bgp_view_cmd); |
| 10529 | install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd); |
| 10530 | install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd); |
| 10531 | install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); |
| 10532 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 10533 | install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); |
| 10534 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 10535 | install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); |
| 10536 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 10537 | install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); |
| 10538 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 10539 | install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); |
| 10540 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 10541 | install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); |
| 10542 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 10543 | install_element (VIEW_NODE, &show_ip_bgp_community_cmd); |
| 10544 | install_element (VIEW_NODE, &show_ip_bgp_community2_cmd); |
| 10545 | install_element (VIEW_NODE, &show_ip_bgp_community3_cmd); |
| 10546 | install_element (VIEW_NODE, &show_ip_bgp_community4_cmd); |
| 10547 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 10548 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 10549 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 10550 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 10551 | install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); |
| 10552 | install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd); |
| 10553 | install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd); |
| 10554 | install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd); |
| 10555 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 10556 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 10557 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 10558 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 10559 | install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); |
| 10560 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 10561 | install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 10562 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 10563 | install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 10564 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 10565 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 10566 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 10567 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 10568 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 10569 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 10570 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 10571 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 10572 | install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 10573 | install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 10574 | install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 10575 | install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); |
| 10576 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 10577 | install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 10578 | install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 10579 | install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 10580 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 10581 | install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 10582 | install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 10583 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 10584 | install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10585 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd); |
| 10586 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 10587 | install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 10588 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 10589 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 10590 | install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10591 | |
| 10592 | install_element (ENABLE_NODE, &show_ip_bgp_cmd); |
| 10593 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); |
| 10594 | install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); |
| 10595 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); |
| 10596 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); |
| 10597 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); |
| 10598 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); |
| 10599 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); |
| 10600 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); |
| 10601 | install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); |
| 10602 | install_element (ENABLE_NODE, &show_ip_bgp_view_cmd); |
| 10603 | install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd); |
| 10604 | install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd); |
| 10605 | install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); |
| 10606 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); |
| 10607 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); |
| 10608 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); |
| 10609 | install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); |
| 10610 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); |
| 10611 | install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); |
| 10612 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); |
| 10613 | install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); |
| 10614 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); |
| 10615 | install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); |
| 10616 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); |
| 10617 | install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); |
| 10618 | install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd); |
| 10619 | install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd); |
| 10620 | install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd); |
| 10621 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); |
| 10622 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd); |
| 10623 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd); |
| 10624 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd); |
| 10625 | install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); |
| 10626 | install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd); |
| 10627 | install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd); |
| 10628 | install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd); |
| 10629 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); |
| 10630 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd); |
| 10631 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd); |
| 10632 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd); |
| 10633 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); |
| 10634 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); |
| 10635 | install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); |
| 10636 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); |
| 10637 | install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); |
| 10638 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); |
| 10639 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); |
| 10640 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); |
| 10641 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); |
| 10642 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); |
| 10643 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); |
| 10644 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); |
| 10645 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); |
| 10646 | install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); |
| 10647 | install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); |
| 10648 | install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); |
| 10649 | install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); |
| 10650 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); |
| 10651 | install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); |
| 10652 | install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); |
| 10653 | install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); |
| 10654 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); |
| 10655 | install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); |
| 10656 | install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); |
| 10657 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); |
| 10658 | install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10659 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd); |
| 10660 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd); |
| 10661 | install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd); |
| 10662 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd); |
| 10663 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd); |
| 10664 | install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10665 | |
| 10666 | /* BGP dampening clear commands */ |
| 10667 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); |
| 10668 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); |
| 10669 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd); |
| 10670 | install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd); |
| 10671 | |
| 10672 | #ifdef HAVE_IPV6 |
| 10673 | /* New config IPv6 BGP commands. */ |
| 10674 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd); |
| 10675 | install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); |
| 10676 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); |
| 10677 | install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd); |
| 10678 | |
| 10679 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); |
| 10680 | install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd); |
| 10681 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); |
| 10682 | install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd); |
| 10683 | |
| 10684 | /* Old config IPv6 BGP commands. */ |
| 10685 | install_element (BGP_NODE, &old_ipv6_bgp_network_cmd); |
| 10686 | install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd); |
| 10687 | |
| 10688 | install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd); |
| 10689 | install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd); |
| 10690 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd); |
| 10691 | install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd); |
| 10692 | |
| 10693 | install_element (VIEW_NODE, &show_bgp_cmd); |
| 10694 | install_element (VIEW_NODE, &show_bgp_ipv6_cmd); |
| 10695 | install_element (VIEW_NODE, &show_bgp_route_cmd); |
| 10696 | install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); |
| 10697 | install_element (VIEW_NODE, &show_bgp_prefix_cmd); |
| 10698 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); |
| 10699 | install_element (VIEW_NODE, &show_bgp_regexp_cmd); |
| 10700 | install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd); |
| 10701 | install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); |
| 10702 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 10703 | install_element (VIEW_NODE, &show_bgp_filter_list_cmd); |
| 10704 | install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 10705 | install_element (VIEW_NODE, &show_bgp_route_map_cmd); |
| 10706 | install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd); |
| 10707 | install_element (VIEW_NODE, &show_bgp_community_all_cmd); |
| 10708 | install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd); |
| 10709 | install_element (VIEW_NODE, &show_bgp_community_cmd); |
| 10710 | install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd); |
| 10711 | install_element (VIEW_NODE, &show_bgp_community2_cmd); |
| 10712 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd); |
| 10713 | install_element (VIEW_NODE, &show_bgp_community3_cmd); |
| 10714 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd); |
| 10715 | install_element (VIEW_NODE, &show_bgp_community4_cmd); |
| 10716 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd); |
| 10717 | install_element (VIEW_NODE, &show_bgp_community_exact_cmd); |
| 10718 | install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 10719 | install_element (VIEW_NODE, &show_bgp_community2_exact_cmd); |
| 10720 | install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 10721 | install_element (VIEW_NODE, &show_bgp_community3_exact_cmd); |
| 10722 | install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 10723 | install_element (VIEW_NODE, &show_bgp_community4_exact_cmd); |
| 10724 | install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 10725 | install_element (VIEW_NODE, &show_bgp_community_list_cmd); |
| 10726 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd); |
| 10727 | install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); |
| 10728 | install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 10729 | install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); |
| 10730 | install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 10731 | install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 10732 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 10733 | install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 10734 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 10735 | install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); |
| 10736 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 10737 | install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 10738 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10739 | install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd); |
| 10740 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 10741 | install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd); |
| 10742 | install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10743 | install_element (VIEW_NODE, &show_bgp_rsclient_cmd); |
| 10744 | install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd); |
| 10745 | install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10746 | install_element (VIEW_NODE, &show_bgp_view_cmd); |
| 10747 | install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd); |
| 10748 | install_element (VIEW_NODE, &show_bgp_view_route_cmd); |
| 10749 | install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd); |
| 10750 | install_element (VIEW_NODE, &show_bgp_view_prefix_cmd); |
| 10751 | install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 10752 | install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 10753 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 10754 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 10755 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 10756 | install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 10757 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 10758 | install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 10759 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 10760 | install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 10761 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 10762 | install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 10763 | install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10764 | install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); |
| 10765 | install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); |
| 10766 | install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10767 | |
| 10768 | install_element (ENABLE_NODE, &show_bgp_cmd); |
| 10769 | install_element (ENABLE_NODE, &show_bgp_ipv6_cmd); |
| 10770 | install_element (ENABLE_NODE, &show_bgp_route_cmd); |
| 10771 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); |
| 10772 | install_element (ENABLE_NODE, &show_bgp_prefix_cmd); |
| 10773 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); |
| 10774 | install_element (ENABLE_NODE, &show_bgp_regexp_cmd); |
| 10775 | install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd); |
| 10776 | install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); |
| 10777 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd); |
| 10778 | install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); |
| 10779 | install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd); |
| 10780 | install_element (ENABLE_NODE, &show_bgp_route_map_cmd); |
| 10781 | install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd); |
| 10782 | install_element (ENABLE_NODE, &show_bgp_community_all_cmd); |
| 10783 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd); |
| 10784 | install_element (ENABLE_NODE, &show_bgp_community_cmd); |
| 10785 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd); |
| 10786 | install_element (ENABLE_NODE, &show_bgp_community2_cmd); |
| 10787 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd); |
| 10788 | install_element (ENABLE_NODE, &show_bgp_community3_cmd); |
| 10789 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd); |
| 10790 | install_element (ENABLE_NODE, &show_bgp_community4_cmd); |
| 10791 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd); |
| 10792 | install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); |
| 10793 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd); |
| 10794 | install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd); |
| 10795 | install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd); |
| 10796 | install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd); |
| 10797 | install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd); |
| 10798 | install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd); |
| 10799 | install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd); |
| 10800 | install_element (ENABLE_NODE, &show_bgp_community_list_cmd); |
| 10801 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd); |
| 10802 | install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); |
| 10803 | install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd); |
| 10804 | install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); |
| 10805 | install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd); |
| 10806 | install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); |
| 10807 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd); |
| 10808 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); |
| 10809 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd); |
| 10810 | install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); |
| 10811 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd); |
| 10812 | install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); |
| 10813 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10814 | install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd); |
| 10815 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd); |
| 10816 | install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd); |
| 10817 | install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10818 | install_element (ENABLE_NODE, &show_bgp_rsclient_cmd); |
| 10819 | install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd); |
| 10820 | install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10821 | install_element (ENABLE_NODE, &show_bgp_view_cmd); |
| 10822 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd); |
| 10823 | install_element (ENABLE_NODE, &show_bgp_view_route_cmd); |
| 10824 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd); |
| 10825 | install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd); |
| 10826 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd); |
| 10827 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd); |
| 10828 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd); |
| 10829 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd); |
| 10830 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd); |
| 10831 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd); |
| 10832 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd); |
| 10833 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd); |
| 10834 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd); |
| 10835 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd); |
| 10836 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); |
| 10837 | install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd); |
| 10838 | install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 10839 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); |
| 10840 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); |
| 10841 | install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10842 | |
| 10843 | /* old command */ |
| 10844 | install_element (VIEW_NODE, &show_ipv6_bgp_cmd); |
| 10845 | install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); |
| 10846 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); |
| 10847 | install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); |
| 10848 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 10849 | install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 10850 | install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); |
| 10851 | install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); |
| 10852 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd); |
| 10853 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd); |
| 10854 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd); |
| 10855 | install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 10856 | install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 10857 | install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 10858 | install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 10859 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); |
| 10860 | install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 10861 | install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 10862 | install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); |
| 10863 | install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); |
| 10864 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 10865 | install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 10866 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 10867 | install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 10868 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 10869 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); |
| 10870 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd); |
| 10871 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd); |
| 10872 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd); |
| 10873 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 10874 | install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 10875 | install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 10876 | install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 10877 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 10878 | install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 10879 | install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
paul | bb46e94 | 2003-10-24 19:02:03 +0000 | [diff] [blame] | 10880 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 10881 | /* old command */ |
| 10882 | install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); |
| 10883 | install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |
| 10884 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); |
| 10885 | install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); |
| 10886 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); |
| 10887 | install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); |
| 10888 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); |
| 10889 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); |
| 10890 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd); |
| 10891 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd); |
| 10892 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd); |
| 10893 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); |
| 10894 | install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd); |
| 10895 | install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd); |
| 10896 | install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd); |
| 10897 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); |
| 10898 | install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); |
| 10899 | install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); |
| 10900 | install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); |
| 10901 | install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); |
| 10902 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); |
| 10903 | install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); |
| 10904 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); |
| 10905 | install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); |
| 10906 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); |
| 10907 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); |
| 10908 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd); |
| 10909 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd); |
| 10910 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd); |
| 10911 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); |
| 10912 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd); |
| 10913 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd); |
| 10914 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd); |
| 10915 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); |
| 10916 | install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); |
| 10917 | install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); |
| 10918 | |
| 10919 | /* old command */ |
| 10920 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 10921 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd); |
| 10922 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 10923 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); |
| 10924 | |
| 10925 | /* old command */ |
| 10926 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 10927 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd); |
| 10928 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 10929 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); |
| 10930 | |
| 10931 | /* old command */ |
| 10932 | install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 10933 | install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd); |
| 10934 | install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 10935 | install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); |
| 10936 | #endif /* HAVE_IPV6 */ |
| 10937 | |
| 10938 | install_element (BGP_NODE, &bgp_distance_cmd); |
| 10939 | install_element (BGP_NODE, &no_bgp_distance_cmd); |
| 10940 | install_element (BGP_NODE, &no_bgp_distance2_cmd); |
| 10941 | install_element (BGP_NODE, &bgp_distance_source_cmd); |
| 10942 | install_element (BGP_NODE, &no_bgp_distance_source_cmd); |
| 10943 | install_element (BGP_NODE, &bgp_distance_source_access_list_cmd); |
| 10944 | install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd); |
| 10945 | |
| 10946 | install_element (BGP_NODE, &bgp_damp_set_cmd); |
| 10947 | install_element (BGP_NODE, &bgp_damp_set2_cmd); |
| 10948 | install_element (BGP_NODE, &bgp_damp_set3_cmd); |
| 10949 | install_element (BGP_NODE, &bgp_damp_unset_cmd); |
| 10950 | install_element (BGP_NODE, &bgp_damp_unset2_cmd); |
| 10951 | install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd); |
| 10952 | install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd); |
| 10953 | install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd); |
| 10954 | install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd); |
| 10955 | install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd); |
| 10956 | } |