Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some encap/mpls commands #111

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 1 addition & 43 deletions bgpd/bgp_encap.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,23 +332,7 @@ show_adj_route_encap (struct vty *vty, struct peer *peer, struct prefix_rd *prd)
return CMD_SUCCESS;
}

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_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
};

static int
int
bgp_show_encap (
struct vty *vty,
afi_t afi,
Expand Down Expand Up @@ -473,30 +457,6 @@ bgp_show_encap (
return CMD_SUCCESS;
}

DEFUN (show_bgp_ipv4_encap,
show_bgp_ipv4_encap_cmd,
"show [ip] bgp ipv4 encap",
SHOW_STR
IP_STR
BGP_STR
"Address Family\n"
"Display ENCAP NLRI specific information\n")
{
return bgp_show_encap (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0);
}

DEFUN (show_bgp_ipv6_encap,
show_bgp_ipv6_encap_cmd,
"show [ip] bgp ipv6 encap",
SHOW_STR
IP_STR
BGP_STR
"Address Family\n"
"Display ENCAP NLRI specific information\n")
{
return bgp_show_encap (vty, AFI_IP6, NULL, bgp_show_type_normal, NULL, 0);
}

DEFUN (show_bgp_ipv4_encap_rd,
show_bgp_ipv4_encap_rd_cmd,
"show [ip] bgp ipv4 encap rd ASN:nn_or_IP-address:nn",
Expand Down Expand Up @@ -938,7 +898,6 @@ bgp_encap_init (void)
install_element (BGP_ENCAP_NODE, &encap_network_cmd);
install_element (BGP_ENCAP_NODE, &no_encap_network_cmd);

install_element (VIEW_NODE, &show_bgp_ipv4_encap_cmd);
install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_cmd);
install_element (VIEW_NODE, &show_bgp_ipv4_encap_tags_cmd);
install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_tags_cmd);
Expand All @@ -947,7 +906,6 @@ bgp_encap_init (void)
install_element (VIEW_NODE, &show_bgp_ipv4_encap_neighbor_advertised_routes_cmd);
install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_neighbor_advertised_routes_cmd);

install_element (VIEW_NODE, &show_bgp_ipv6_encap_cmd);
install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_cmd);
install_element (VIEW_NODE, &show_bgp_ipv6_encap_tags_cmd);
install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_tags_cmd);
Expand Down
8 changes: 8 additions & 0 deletions bgpd/bgp_encap.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@

extern void bgp_encap_init (void);
extern int bgp_nlri_parse_encap (struct peer *, struct attr *, struct bgp_nlri *);
int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's stay consistent with the code around this new declaration

bgp_show_encap (
struct vty *vty,
afi_t afi,
struct prefix_rd *prd,
enum bgp_show_type type,
void *output_arg,
int tags);

#include "bgp_encap_types.h"
#endif /* _QUAGGA_BGP_ENCAP_H */
1 change: 1 addition & 0 deletions bgpd/bgp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA

#include "bgpd/bgpd.h"
#include "bgpd/bgp_attr.h"
#include "bgpd/bgp_route.h"
#include "bgpd/bgp_mplsvpn.h"
#include "bgpd/bgp_aspath.h"
#include "bgpd/bgp_dump.h"
Expand Down
57 changes: 1 addition & 56 deletions bgpd/bgp_mplsvpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,23 +733,7 @@ show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u
return CMD_SUCCESS;
}

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_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
};

static int
int
bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd,
enum bgp_show_type type, void *output_arg, int tags, u_char use_json)
{
Expand Down Expand Up @@ -967,44 +951,6 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd,
return CMD_SUCCESS;
}

DEFUN (show_bgp_ip_vpn_rd,
show_bgp_ip_vpn_rd_cmd,
"show [ip] bgp "BGP_AFI_CMD_STR" vpn [rd ASN:nn_or_IP-address:nn] [json]",
SHOW_STR
IP_STR
BGP_STR
BGP_VPNVX_HELP_STR
"Display VPN NLRI specific information\n"
"Display information for a route distinguisher\n"
"VPN Route Distinguisher\n"
JSON_STR)
{
int idx_ext_community = 5;
int ret;
struct prefix_rd prd;
afi_t afi;
int idx = 0;

if (argv_find_and_parse_afi (argv, argc, &idx, &afi))
{
if (argv[idx_ext_community]->arg)
{
ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
return CMD_WARNING;
}
return bgp_show_mpls_vpn (vty, afi, &prd, bgp_show_type_normal, NULL, 0, use_json (argc, argv));
}
else
{
return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_normal, NULL, 0, use_json (argc, argv));
}
}
return CMD_SUCCESS;
}

#ifdef KEEP_OLD_VPN_COMMANDS
DEFUN (show_ip_bgp_vpn_all,
show_ip_bgp_vpn_all_cmd,
Expand Down Expand Up @@ -1386,7 +1332,6 @@ bgp_mplsvpn_init (void)
install_element (BGP_VPNV6_NODE, &vpnv6_network_cmd);
install_element (BGP_VPNV6_NODE, &no_vpnv6_network_cmd);

install_element (VIEW_NODE, &show_bgp_ip_vpn_rd_cmd);
#ifdef KEEP_OLD_VPN_COMMANDS
install_element (VIEW_NODE, &show_ip_bgp_vpn_all_cmd);
install_element (VIEW_NODE, &show_ip_bgp_vpn_rd_cmd);
Expand Down
3 changes: 3 additions & 0 deletions bgpd/bgp_mplsvpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,8 @@ extern char *prefix_rd2str (struct prefix_rd *, char *, size_t);

extern int
argv_find_and_parse_vpnvx(struct cmd_token **argv, int argc, int *index, afi_t *afi);
int
bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd,
enum bgp_show_type type, void *output_arg, int tags, u_char use_json);

#endif /* _QUAGGA_BGP_MPLSVPN_H */
40 changes: 9 additions & 31 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -7213,27 +7214,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,
Expand Down Expand Up @@ -7902,15 +7882,9 @@ DEFUN (show_ip_bgp_ipv4,
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, "vpn", &idx))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be changed to use bgp_vty_find_and_parse_afi_safi_vrf (PR #107)
or use the pattern:

if (argv_find_and_parse_afi (argv, argc, &idx, &afi))
argv_find_and_parse_safi (argv, argc, &idx, &safi);

safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN;
}
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);
}

int uj = use_json (argc, argv);
if (uj) argc--;

Expand Down Expand Up @@ -7972,8 +7946,12 @@ DEFUN (show_ip_bgp_ipv4,
else if (argv[idx]->type == IPV4_TKN || argv[idx]->type == IPV6_TKN)
return bgp_show_prefix_longer (vty, vrf, argv[idx + 1]->arg, afi, safi, bgp_show_type_prefix_longer);
}

return bgp_show (vty, bgp, afi, safi, sh_type, NULL, uj);
if (safi == SAFI_MPLS_VPN)
return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_normal, NULL, 0, uj);
else if (safi == SAFI_ENCAP)
return bgp_show_encap (vty, afi, NULL, bgp_show_type_normal, NULL, 0);
else
return bgp_show (vty, bgp, afi, safi, sh_type, NULL, uj);
}

DEFUN (show_ip_bgp_route,
Expand Down
22 changes: 22 additions & 0 deletions bgpd/bgp_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA

struct bgp_nexthop_cache;

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
};


#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\
"h history, * valid, > best, = multipath,%s"\
" i internal, r RIB-failure, S Stale, R Removed%s"
Expand Down
25 changes: 0 additions & 25 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -5588,28 +5588,6 @@ DEFUN (address_family_vpnv6,
}
#endif /* KEEP_OLD_VPN_COMMANDS */

DEFUN (address_family_ipv4_vpn,
address_family_ipv4_vpn_cmd,
"address-family ipv4 vpn",
"Enter Address Family command mode\n"
"Address Family\n"
"Subsequent Address Family modifier\n")
{
vty->node = BGP_VPNV4_NODE;
return CMD_SUCCESS;
}

DEFUN (address_family_ipv6_vpn,
address_family_ipv6_vpn_cmd,
"address-family ipv6 vpn",
"Enter Address Family command mode\n"
"Address Family\n"
"Subsequent Address Family modifier\n")
{
vty->node = BGP_VPNV6_NODE;
return CMD_SUCCESS;
}

DEFUN (address_family_encap,
address_family_encap_cmd,
"address-family <encap|encapv4>",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this now defined?

Expand Down Expand Up @@ -10717,9 +10695,6 @@ bgp_vty_init (void)
install_element (BGP_NODE, &address_family_vpnv4_cmd);
install_element (BGP_NODE, &address_family_vpnv6_cmd);
#endif /* KEEP_OLD_VPN_COMMANDS */
install_element (BGP_NODE, &address_family_ipv4_vpn_cmd);
install_element (BGP_NODE, &address_family_ipv6_vpn_cmd);

install_element (BGP_NODE, &address_family_encap_cmd);
install_element (BGP_NODE, &address_family_encapv6_cmd);

Expand Down
1 change: 1 addition & 0 deletions bgpd/rfapi/rfapi_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "bgpd/bgpd.h"
#include "bgpd/bgp_ecommunity.h"
#include "bgpd/bgp_attr.h"
#include "bgpd/bgp_route.h"
#include "bgpd/bgp_mplsvpn.h"

#include "bgpd/rfapi/bgp_rfapi_cfg.h"
Expand Down
1 change: 1 addition & 0 deletions bgpd/rfapi/vnc_import_bgp.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "bgpd/bgpd.h"
#include "bgpd/bgp_ecommunity.h"
#include "bgpd/bgp_attr.h"
#include "bgpd/bgp_route.h"
#include "bgpd/bgp_mplsvpn.h" /* for RD_TYPE_IP */

#include "bgpd/rfapi/vnc_export_bgp.h"
Expand Down