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

Master: bgp show vpn/encap and RFAPI fixes #113

Merged
Show file tree
Hide file tree
Changes from 5 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
26 changes: 1 addition & 25 deletions bgpd/bgp_encap.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,7 @@ bgp_nlri_parse_encap(
if (attr) {
bgp_update (peer, &p, 0, attr, afi, SAFI_ENCAP,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, 0);
#if ENABLE_BGP_VNC
rfapiProcessUpdate(peer, NULL, &p, &prd, attr, afi, SAFI_ENCAP,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL);
#endif
} else {
#if ENABLE_BGP_VNC
rfapiProcessWithdraw(peer, NULL, &p, &prd, attr, afi, SAFI_ENCAP,
ZEBRA_ROUTE_BGP, 0);
#endif
bgp_withdraw (peer, &p, 0, attr, afi, SAFI_ENCAP,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL);
}
Expand Down Expand Up @@ -332,23 +324,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
4 changes: 3 additions & 1 deletion bgpd/bgp_encap.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@

#ifndef _QUAGGA_BGP_ENCAP_H
#define _QUAGGA_BGP_ENCAP_H
#include "bgpd/bgp_route.h"

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

extern int 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 */
103 changes: 36 additions & 67 deletions bgpd/bgp_mplsvpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,6 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr,
safi_t safi;
int addpath_encoded;
u_int32_t addpath_id;
#if ENABLE_BGP_VNC
u_int32_t label = 0;
#endif

/* Check peer status. */
if (peer->status != Established)
Expand Down Expand Up @@ -251,10 +248,6 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr,
return -1;
}

#if ENABLE_BGP_VNC
label = decode_label (pnt);
#endif

/* Copyr label to prefix. */
tagpnt = pnt;

Expand Down Expand Up @@ -294,23 +287,14 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr,

if (attr)
{
bgp_update (peer, &p, addpath_id, attr, packet->afi, SAFI_MPLS_VPN,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt, 0);
#if ENABLE_BGP_VNC
rfapiProcessUpdate(peer, NULL, &p, &prd, attr, packet->afi,
SAFI_MPLS_VPN, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
&label);
#endif
bgp_update (peer, &p, addpath_id, attr, packet->afi, SAFI_MPLS_VPN,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt, 0);
}
else
{
#if ENABLE_BGP_VNC
rfapiProcessWithdraw(peer, NULL, &p, &prd, attr, packet->afi,
SAFI_MPLS_VPN, ZEBRA_ROUTE_BGP, 0);
#endif
bgp_withdraw (peer, &p, addpath_id, attr, packet->afi, SAFI_MPLS_VPN,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt);
}
bgp_withdraw (peer, &p, addpath_id, attr, packet->afi, SAFI_MPLS_VPN,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt);
}
}
/* Packet length consistency check. */
if (pnt != lim)
Expand Down Expand Up @@ -657,7 +641,7 @@ show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u
struct rd_as rd_as;
struct rd_ip rd_ip = {0};
#if ENABLE_BGP_VNC
struct rd_vnc_eth rd_vnc_eth;
struct rd_vnc_eth rd_vnc_eth = {0};
#endif
u_char *pnt;

Expand Down Expand Up @@ -733,23 +717,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 @@ -867,7 +835,7 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd,
struct rd_as rd_as;
struct rd_ip rd_ip = {0};
#if ENABLE_BGP_VNC
struct rd_vnc_eth rd_vnc_eth;
struct rd_vnc_eth rd_vnc_eth = {0};
#endif
u_char *pnt;

Expand Down Expand Up @@ -967,9 +935,9 @@ 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]",
DEFUN (show_bgp_ip_vpn_all_rd,
show_bgp_ip_vpn_all_rd_cmd,
"show bgp "BGP_AFI_CMD_STR" vpn all [rd ASN:nn_or_IP-address:nn] [json]",
Copy link
Member

Choose a reason for hiding this comment

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

show [ip] bgp

SHOW_STR
IP_STR
BGP_STR
Expand All @@ -979,17 +947,17 @@ DEFUN (show_bgp_ip_vpn_rd,
"VPN Route Distinguisher\n"
JSON_STR)
{
int idx_ext_community = 5;
int idx_rd = 5;
Copy link
Member

Choose a reason for hiding this comment

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

idx_rd is not going to be 5.

If I enter:

'show ip bgp ipv4 vpn all rd ASN:nn_or_IP-address:nn"
shouldn't we be at 6?

Copy link
Member

@qlyoung qlyoung Jan 25, 2017

Choose a reason for hiding this comment

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

Additionally, removing the '[ip]' serves only to fragment the command space. I went through and merged the entire show bgp CLI tree so that 'ip' may be optionally prepended some time ago.

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)
if (argc >= 7 && argv[idx_rd]->arg)
{
ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
Expand All @@ -1005,34 +973,17 @@ DEFUN (show_bgp_ip_vpn_rd,
return CMD_SUCCESS;
}

#ifdef KEEP_OLD_VPN_COMMANDS
DEFUN (show_ip_bgp_vpn_all,
show_ip_bgp_vpn_all_cmd,
"show [ip] bgp <vpnv4|vpnv6>",
SHOW_STR
IP_STR
BGP_STR
BGP_VPNVX_HELP_STR)
{
afi_t afi;
int idx = 0;

if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi))
return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_normal, NULL, 0, 0);
return CMD_SUCCESS;
}

DEFUN (show_ip_bgp_vpn_rd,
show_ip_bgp_vpn_rd_cmd,
"show [ip] bgp <vpnv4|vpnv6> rd ASN:nn_or_IP-address:nn",
"show [ip] bgp "BGP_AFI_CMD_STR" vpn rd ASN:nn_or_IP-address:nn",
SHOW_STR
IP_STR
BGP_STR
BGP_VPNVX_HELP_STR
BGP_AFI_HELP_STR
"Display information for a route distinguisher\n"
"VPN Route Distinguisher\n")
{
int idx_ext_community = 5;
int idx_ext_community = argc-1;
int ret;
struct prefix_rd prd;
afi_t afi;
Expand All @@ -1051,6 +1002,23 @@ DEFUN (show_ip_bgp_vpn_rd,
return CMD_SUCCESS;
}

#ifdef KEEP_OLD_VPN_COMMANDS
DEFUN (show_ip_bgp_vpn_all,
show_ip_bgp_vpn_all_cmd,
"show [ip] bgp <vpnv4|vpnv6>",
SHOW_STR
IP_STR
BGP_STR
BGP_VPNVX_HELP_STR)
{
afi_t afi;
int idx = 0;

if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi))
return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_normal, NULL, 0, 0);
return CMD_SUCCESS;
}

DEFUN (show_ip_bgp_vpn_all_tags,
show_ip_bgp_vpn_all_tags_cmd,
"show [ip] bgp <vpnv4|vpnv6> all tags",
Expand Down Expand Up @@ -1386,7 +1354,8 @@ 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);
install_element (VIEW_NODE, &show_bgp_ip_vpn_all_rd_cmd);
install_element (VIEW_NODE, &show_ip_bgp_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
10 changes: 7 additions & 3 deletions bgpd/bgp_mplsvpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#ifndef _QUAGGA_BGP_MPLSVPN_H
#define _QUAGGA_BGP_MPLSVPN_H

#include "bgpd/bgp_route.h"

#define RD_TYPE_AS 0
#define RD_TYPE_IP 1
#define RD_TYPE_AS4 2
Expand Down Expand Up @@ -56,8 +58,8 @@ typedef enum {
(label) == MPLS_LABEL_IMPLICIT_NULL)

#define BGP_VPNVX_HELP_STR \
"Address Family \n" \
"Address Family \n"
"Address Family\n" \
"Address Family\n"

struct rd_as
{
Expand Down Expand Up @@ -100,5 +102,7 @@ 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);

extern 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 */
Loading