summaryrefslogtreecommitdiff
path: root/bgpd/bgp_route.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_route.c')
-rw-r--r--bgpd/bgp_route.c257
1 files changed, 89 insertions, 168 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index f045d17000..8be76595f7 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -51,6 +51,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "bgpd/bgp_filter.h"
#include "bgpd/bgp_fsm.h"
#include "bgpd/bgp_mplsvpn.h"
+#include "bgpd/bgp_encap.h"
#include "bgpd/bgp_nexthop.h"
#include "bgpd/bgp_damp.h"
#include "bgpd/bgp_advertise.h"
@@ -5867,7 +5868,8 @@ route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo,
vty_out (vty, " ");
/* Internal route. */
- if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
+ if (binfo->peer &&
+ (binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
vty_out (vty, "i");
else
vty_out (vty, " ");
@@ -7250,27 +7252,6 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
-enum bgp_show_type
-{
- bgp_show_type_normal,
- bgp_show_type_regexp,
- bgp_show_type_prefix_list,
- bgp_show_type_filter_list,
- bgp_show_type_route_map,
- bgp_show_type_neighbor,
- bgp_show_type_cidr_only,
- bgp_show_type_prefix_longer,
- bgp_show_type_community_all,
- bgp_show_type_community,
- bgp_show_type_community_exact,
- bgp_show_type_community_list,
- bgp_show_type_community_list_exact,
- bgp_show_type_flap_statistics,
- bgp_show_type_flap_neighbor,
- bgp_show_type_dampend_paths,
- bgp_show_type_damp_neighbor
-};
-
static int
bgp_show_prefix_list (struct vty *vty, const char *name,
const char *prefix_list_str, afi_t afi,
@@ -7397,7 +7378,8 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table,
{
union sockunion *su = output_arg;
- if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
+ if (ri->peer == NULL ||
+ ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
continue;
}
if (type == bgp_show_type_cidr_only)
@@ -7543,6 +7525,18 @@ bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
return CMD_WARNING;
}
+ /* use MPLS and ENCAP specific shows until they are merged */
+ if (safi == SAFI_MPLS_VPN)
+ {
+ return bgp_show_mpls_vpn(vty, afi, NULL, type, output_arg,
+ 0, use_json);
+ }
+ if (safi == SAFI_ENCAP)
+ {
+ return bgp_show_encap(vty, afi, NULL, type, output_arg,
+ 0);
+ }
+
table = bgp->rib[afi][safi];
@@ -7873,7 +7867,7 @@ bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
/* BGP route print out function. */
DEFUN (show_ip_bgp_ipv4,
show_ip_bgp_ipv4_cmd,
- "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|encap>]]\
+ "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]]\
[<\
cidr-only\
|dampening <flap-statistics|dampened-paths|parameters>\
@@ -7889,12 +7883,8 @@ DEFUN (show_ip_bgp_ipv4,
IP_STR
BGP_STR
BGP_INSTANCE_HELP_STR
- "Address Family\n"
- "Address Family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
+ BGP_AFI_HELP_STR
+ BGP_SAFI_HELP_STR
"Display only routes with non-natural netmasks\n"
"Display detailed information about dampening\n"
"Display flap statistics of routes\n"
@@ -7934,19 +7924,10 @@ DEFUN (show_ip_bgp_ipv4,
afi = AFI_IP;
if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx))
vrf = argv[++idx]->arg;
- if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx))
- {
- afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP;
- if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx))
- safi = bgp_vty_safi_from_arg (argv[idx]->text);
- }
- else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx))
- {
- afi = AFI_IP;
- safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN;
- // advance idx if necessary
- argv_find (argv, argc, "unicast", &idx);
- }
+ if (argv_find_and_parse_afi (argv, argc, &idx, &afi))
+ {
+ argv_find_and_parse_safi (argv, argc, &idx, &safi);
+ }
int uj = use_json (argc, argv);
if (uj) argc--;
@@ -8015,18 +7996,14 @@ DEFUN (show_ip_bgp_ipv4,
DEFUN (show_ip_bgp_route,
show_ip_bgp_route_cmd,
- "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|encap>]]"
+ "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]]"
"<A.B.C.D|A.B.C.D/M|X:X::X:X|X:X::X:X/M> [<bestpath|multipath>] [json]",
SHOW_STR
IP_STR
BGP_STR
BGP_INSTANCE_HELP_STR
- "Address Family\n"
- "Address Family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
+ BGP_AFI_HELP_STR
+ BGP_SAFI_HELP_STR
"Network in the BGP routing table to display\n"
"IPv4 prefix\n"
"Network in the BGP routing table to display\n"
@@ -8053,20 +8030,10 @@ DEFUN (show_ip_bgp_route,
/* [<view|vrf> WORD] */
if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx))
vrf = argv[++idx]->arg;
- /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */
- if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx))
- {
- afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP;
- if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx))
- safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST;
- }
- else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx))
- {
- afi = AFI_IP;
- safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN;
- // advance idx if necessary
- argv_find (argv, argc, "unicast", &idx);
- }
+ if (argv_find_and_parse_afi (argv, argc, &idx, &afi))
+ {
+ argv_find_and_parse_safi (argv, argc, &idx, &safi);
+ }
/* <A.B.C.D|A.B.C.D/M|X:X::X:X|X:X::X:X/M> */
if (argv_find (argv, argc, "A.B.C.D", &idx) || argv_find (argv, argc, "X:X::X:X", &idx))
@@ -8100,24 +8067,12 @@ DEFUN (show_ip_bgp_route,
DEFUN (show_ip_bgp_regexp,
show_ip_bgp_regexp_cmd,
- "show [ip] bgp [<ipv4 [<unicast|multicast|vpn|encap>]|ipv6 [<unicast|multicast|vpn|encap>]|encap [unicast]|vpnv4 [unicast]>] regexp REGEX...",
+ "show [ip] bgp ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] regexp REGEX...",
SHOW_STR
IP_STR
BGP_STR
- "Address Family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family\n"
- "Address Family modifier\n"
- "Address Family\n"
- "Address Family modifier\n"
+ BGP_AFI_HELP_STR
+ BGP_SAFI_HELP_STR
"Display routes matching the AS path regular expression\n"
"A regular-expression to match the BGP AS paths\n")
{
@@ -8126,20 +8081,10 @@ DEFUN (show_ip_bgp_regexp,
int idx = 0;
- /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */
- if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx))
- {
- afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP;
- if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx))
- safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST;
- }
- else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx))
- {
- afi = AFI_IP;
- safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN;
- // advance idx if necessary
- argv_find (argv, argc, "unicast", &idx);
- }
+ if (argv_find_and_parse_afi (argv, argc, &idx, &afi))
+ {
+ argv_find_and_parse_safi (argv, argc, &idx, &safi);
+ }
// get index of regex
argv_find (argv, argc, "regexp", &idx);
@@ -8153,21 +8098,13 @@ DEFUN (show_ip_bgp_regexp,
DEFUN (show_ip_bgp_instance_all,
show_ip_bgp_instance_all_cmd,
- "show [ip] bgp <view|vrf> all [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] [json]",
+ "show [ip] bgp <view|vrf> all ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] [json]",
SHOW_STR
IP_STR
BGP_STR
BGP_INSTANCE_ALL_HELP_STR
- "Address Family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family\n"
- "Address Family modifier\n"
- "Address Family\n"
- "Address Family modifier\n"
+ BGP_AFI_HELP_STR
+ BGP_SAFI_HELP_STR
JSON_STR)
{
afi_t afi = AFI_IP;
@@ -8178,20 +8115,11 @@ DEFUN (show_ip_bgp_instance_all,
/* show [ip] bgp */
if (argv_find (argv, argc, "ip", &idx))
afi = AFI_IP;
- /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */
- if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx))
- {
- afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP;
- if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx))
- safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST;
- }
- else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx))
- {
- afi = AFI_IP;
- safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN;
- // advance idx if necessary
- argv_find (argv, argc, "unicast", &idx);
- }
+ /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
+ if (argv_find_and_parse_afi (argv, argc, &idx, &afi))
+ {
+ argv_find_and_parse_safi (argv, argc, &idx, &safi);
+ }
u_char uj = use_json(argc, argv);
@@ -9478,21 +9406,13 @@ peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
DEFUN (show_ip_bgp_instance_neighbor_advertised_route,
show_ip_bgp_instance_neighbor_advertised_route_cmd,
- "show [ip] bgp [<view|vrf> WORD] [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] neighbors <A.B.C.D|X:X::X:X|WORD> <received-routes|advertised-routes> [route-map WORD] [json]",
+ "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] neighbors <A.B.C.D|X:X::X:X|WORD> <received-routes|advertised-routes> [route-map WORD] [json]",
SHOW_STR
IP_STR
BGP_STR
BGP_INSTANCE_HELP_STR
- "Address Family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family\n"
- "Address Family modifier\n"
- "Address Family\n"
- "Address Family modifier\n"
+ BGP_AFI_HELP_STR
+ BGP_SAFI_HELP_STR
"Detailed information on TCP and BGP neighbor connections\n"
"Neighbor to display information about\n"
"Neighbor to display information about\n"
@@ -9520,20 +9440,11 @@ DEFUN (show_ip_bgp_instance_neighbor_advertised_route,
/* [<view|vrf> WORD] */
if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx))
vrf = argv[++idx]->arg;
- /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */
- if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx))
- {
- afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP;
- if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx))
- safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST;
- }
- else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx))
- {
- afi = AFI_IP;
- safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN;
- // advance idx if necessary
- argv_find (argv, argc, "unicast", &idx);
- }
+ /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
+ if (argv_find_and_parse_afi (argv, argc, &idx, &afi))
+ {
+ argv_find_and_parse_safi (argv, argc, &idx, &safi);
+ }
/* neighbors <A.B.C.D|X:X::X:X|WORD> */
argv_find (argv, argc, "neighbors", &idx);
@@ -9670,21 +9581,13 @@ bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
DEFUN (show_ip_bgp_neighbor_routes,
show_ip_bgp_neighbor_routes_cmd,
- "show [ip] bgp [<view|vrf> WORD] [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] neighbors <A.B.C.D|X:X::X:X|WORD> <flap-statistics|dampened-routes|routes> [json]",
+ "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] neighbors <A.B.C.D|X:X::X:X|WORD> <flap-statistics|dampened-routes|routes> [json]",
SHOW_STR
IP_STR
BGP_STR
BGP_INSTANCE_HELP_STR
- "Address Family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family\n"
- "Address Family modifier\n"
- "Address Family\n"
- "Address Family modifier\n"
+ BGP_AFI_HELP_STR
+ BGP_SAFI_HELP_STR
"Detailed information on TCP and BGP neighbor connections\n"
"Neighbor to display information about\n"
"Neighbor to display information about\n"
@@ -9710,20 +9613,11 @@ DEFUN (show_ip_bgp_neighbor_routes,
/* [<view|vrf> WORD] */
if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx))
vrf = argv[++idx]->arg;
- /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */
- if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx))
- {
- afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP;
- if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx))
- safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST;
- }
- else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx))
- {
- afi = AFI_IP;
- safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN;
- // advance idx if necessary
- argv_find (argv, argc, "unicast", &idx);
- }
+ /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
+ if (argv_find_and_parse_afi (argv, argc, &idx, &afi))
+ {
+ argv_find_and_parse_safi (argv, argc, &idx, &safi);
+ }
/* neighbors <A.B.C.D|X:X::X:X|WORD> */
argv_find (argv, argc, "neighbors", &idx);
peerstr = argv[++idx]->arg;
@@ -9758,6 +9652,32 @@ struct bgp_distance
char *access_list;
};
+DEFUN (show_bgp_afi_vpn_rd_route,
+ show_bgp_afi_vpn_rd_route_cmd,
+ "show bgp "BGP_AFI_CMD_STR" vpn rd ASN:nn_or_IP-address:nn <A.B.C.D/M|X:X::X:X/M> [json]",
+ SHOW_STR
+ BGP_STR
+ BGP_AFI_HELP_STR
+ "Address Family modifier\n"
+ "Display information for a route distinguisher\n"
+ "Route Distinguisher\n"
+ "Network in the BGP routing table to display\n")
+{
+ int ret;
+ struct prefix_rd prd;
+ afi_t afi = AFI_MAX;
+ int idx = 0;
+
+ argv_find_and_parse_afi (argv, argc, &idx, &afi);
+ ret = str2prefix_rd (argv[5]->arg, &prd);
+ if (! ret)
+ {
+ vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ return bgp_show_route (vty, NULL, argv[6]->arg, afi, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv));
+}
+
static struct bgp_distance *
bgp_distance_new (void)
{
@@ -10575,6 +10495,7 @@ bgp_route_init (void)
#ifdef KEEP_OLD_VPN_COMMANDS
install_element (VIEW_NODE, &show_ip_bgp_vpn_all_route_prefix_cmd);
#endif /* KEEP_OLD_VPN_COMMANDS */
+ install_element (VIEW_NODE, &show_bgp_afi_vpn_rd_route_cmd);
/* BGP dampening clear commands */
install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);