diff options
| -rw-r--r-- | bgpd/bgp_encap.c | 8 | ||||
| -rw-r--r-- | bgpd/bgp_encap.h | 4 | ||||
| -rw-r--r-- | bgpd/bgp_mplsvpn.c | 95 | ||||
| -rw-r--r-- | bgpd/bgp_mplsvpn.h | 6 | ||||
| -rw-r--r-- | bgpd/bgp_route.c | 140 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi.c | 5 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi_import.c | 6 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi_private.h | 1 |
8 files changed, 181 insertions, 84 deletions
diff --git a/bgpd/bgp_encap.c b/bgpd/bgp_encap.c index 11282a505d..4ec45108b4 100644 --- a/bgpd/bgp_encap.c +++ b/bgpd/bgp_encap.c @@ -189,15 +189,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); } diff --git a/bgpd/bgp_encap.h b/bgpd/bgp_encap.h index 0de737c49b..4d57fca79d 100644 --- a/bgpd/bgp_encap.h +++ b/bgpd/bgp_encap.h @@ -21,11 +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, +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 */ diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 6e722bbb55..d13de9b9e6 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -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) @@ -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; @@ -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) @@ -658,7 +642,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; @@ -853,7 +837,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; @@ -967,20 +951,60 @@ DEFUN (show_ip_bgp_vpn_all, 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; +} +#endif + +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]", + 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_rd = 5; + int ret; + struct prefix_rd prd; + afi_t afi; + int idx = 0; + + if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) + { + if (argc >= 7 && argv[idx_rd]->arg) + { + ret = str2prefix_rd (argv[idx_rd]->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; } 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; @@ -999,6 +1023,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", @@ -1334,6 +1375,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_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); diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h index ea6cbcd272..148e5946f1 100644 --- a/bgpd/bgp_mplsvpn.h +++ b/bgpd/bgp_mplsvpn.h @@ -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 @@ -62,8 +64,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 { diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index fb33b234f4..9fffde13ad 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2683,6 +2683,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 @@ -2777,6 +2792,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 @@ -2816,6 +2846,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. */ @@ -5833,7 +5870,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, " "); @@ -7347,7 +7385,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) @@ -7514,6 +7553,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]; @@ -7976,7 +8027,7 @@ static int bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t /* BGP route print out function. */ DEFUN (show_ip_bgp, show_ip_bgp_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>\ @@ -7993,12 +8044,8 @@ DEFUN (show_ip_bgp, 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" @@ -8111,18 +8158,14 @@ DEFUN (show_ip_bgp, 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" @@ -8194,17 +8237,13 @@ DEFUN (show_ip_bgp_route, DEFUN (show_ip_bgp_regexp, show_ip_bgp_regexp_cmd, - "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|encap>]] regexp REGEX...", + "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] regexp REGEX...", 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 "Display routes matching the AS path regular expression\n" "A regular-expression to match the BGP AS paths\n") { @@ -8229,17 +8268,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|ipv6> [<unicast|multicast|vpn|encap>]] [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\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 JSON_STR) { vrf_id_t vrf = VRF_DEFAULT; @@ -9269,18 +9304,12 @@ 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|ipv6> [<unicast|multicast|vpn|encap>]] " + "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\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -9454,18 +9483,14 @@ 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|ipv6> [<unicast|multicast|vpn|encap>]] " + "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\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 "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -9545,6 +9570,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) { @@ -10361,6 +10412,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); diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index cc6b555c9d..3a6c313888 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -423,9 +423,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 && diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 1cd12ca0d2..8e68eec53a 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -3724,6 +3724,12 @@ rfapiBgpInfoFilteredImportVPN ( if (rn->info) original_had_routes = 1; + if (VNC_DEBUG(VERBOSE)) + { + vnc_zlog_debug_verbose ("%s: showing IT node on entry", __func__); + rfapiShowItNode (NULL, rn); /* debug */ + } + /* * Look for same route (will have same RD and peer) */ diff --git a/bgpd/rfapi/rfapi_private.h b/bgpd/rfapi/rfapi_private.h index ed83ef1e1f..8ac2966bfe 100644 --- a/bgpd/rfapi/rfapi_private.h +++ b/bgpd/rfapi/rfapi_private.h @@ -31,6 +31,7 @@ #include "lib/workqueue.h" #include "bgpd/bgp_attr.h" +#include "bgpd/bgp_route.h" #include "rfapi.h" |
