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 4 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
8 changes: 0 additions & 8 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
38 changes: 11 additions & 27 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 @@ -867,7 +851,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 @@ -969,7 +953,7 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd,

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 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 +963,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 Down
39 changes: 38 additions & 1 deletion bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -2680,6 +2680,21 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
bgp_process (bgp, rn, afi, safi);
bgp_unlock_node (rn);

#if ENABLE_BGP_VNC
if (SAFI_MPLS_VPN == safi)
{
uint32_t label = decode_label(tag);

rfapiProcessUpdate(peer, NULL, p, prd, attr, afi, safi, type, sub_type,
&label);
}
if (SAFI_ENCAP == safi)
{
rfapiProcessUpdate(peer, NULL, p, prd, attr, afi, safi, type, sub_type,
NULL);
}
#endif

return 0;
} // End of implicit withdraw

Expand Down Expand Up @@ -2774,6 +2789,21 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
/* Process change. */
bgp_process (bgp, rn, afi, safi);

#if ENABLE_BGP_VNC
if (SAFI_MPLS_VPN == safi)
{
uint32_t label = decode_label(tag);

rfapiProcessUpdate(peer, NULL, p, prd, attr, afi, safi, type, sub_type,
&label);
}
if (SAFI_ENCAP == safi)
{
rfapiProcessUpdate(peer, NULL, p, prd, attr, afi, safi, type, sub_type,
NULL);
}
#endif

return 0;

/* This BGP update is filtered. Log the reason then update BGP
Expand Down Expand Up @@ -2813,6 +2843,13 @@ bgp_withdraw (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
struct bgp_node *rn;
struct bgp_info *ri;

#if ENABLE_BGP_VNC
if ((SAFI_MPLS_VPN == safi) || (SAFI_ENCAP == safi))
{
rfapiProcessWithdraw(peer, NULL, p, prd, NULL, afi, safi, type, 0);
}
#endif

bgp = peer->bgp;

/* Lookup node. */
Expand Down Expand Up @@ -9441,7 +9478,7 @@ 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] [<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]",
Copy link
Member

Choose a reason for hiding this comment

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

It was my understanding that we are converting to a 'afi safi' format. Shouldn't we loose encap and vpnv4 as afi's then?

SHOW_STR
IP_STR
BGP_STR
Expand Down
4 changes: 2 additions & 2 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -5586,7 +5586,6 @@ DEFUN (address_family_vpnv6,
vty->node = BGP_VPNV6_NODE;
return CMD_SUCCESS;
}
#endif /* KEEP_OLD_VPN_COMMANDS */

DEFUN (address_family_ipv4_vpn,
address_family_ipv4_vpn_cmd,
Expand All @@ -5609,6 +5608,7 @@ DEFUN (address_family_ipv6_vpn,
vty->node = BGP_VPNV6_NODE;
return CMD_SUCCESS;
}
#endif /* KEEP_OLD_VPN_COMMANDS */

DEFUN (address_family_encap,
address_family_encap_cmd,
Expand Down Expand Up @@ -10716,9 +10716,9 @@ bgp_vty_init (void)
#ifdef KEEP_OLD_VPN_COMMANDS
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);
#endif /* KEEP_OLD_VPN_COMMANDS */

install_element (BGP_NODE, &address_family_encap_cmd);
install_element (BGP_NODE, &address_family_encapv6_cmd);
Expand Down
7 changes: 4 additions & 3 deletions bgpd/rfapi/rfapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,10 @@ del_vnc_route (
{

vnc_zlog_debug_verbose
("%s: trying bi=%p, bi->peer=%p, bi->type=%d, bi->sub_type=%d, bi->extra->vnc.export.rfapi_handle=%p",
("%s: trying bi=%p, bi->peer=%p, bi->type=%d, bi->sub_type=%d, bi->extra->vnc.export.rfapi_handle=%p, local_pref=%u",
__func__, bi, bi->peer, bi->type, bi->sub_type,
(bi->extra ? bi->extra->vnc.export.rfapi_handle : NULL));
(bi->extra ? bi->extra->vnc.export.rfapi_handle : NULL),
((bi->attr && CHECK_FLAG(bi->attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))? bi->attr->local_pref: 0));

if (bi->peer == peer &&
bi->type == type &&
Expand Down Expand Up @@ -2777,7 +2778,7 @@ rfapi_register (
NULL,
action == RFAPI_REGISTER_KILL);

if (0 == rfapiApDelete (bgp, rfd, &p, pfx_mac, &adv_tunnel))
if (0 == rfapiApDelete (bgp, rfd, &p, pfx_mac, &prd, &adv_tunnel))
{
if (adv_tunnel)
rfapiTunnelRouteAnnounce (bgp, rfd, &rfd->max_prefix_lifetime);
Expand Down
Loading