diff options
| author | David Lamparter <equinox@diac24.net> | 2017-01-03 16:44:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-03 16:44:44 +0100 |
| commit | 9b532e09f9a612884b2f394fe17d2d3386d3e3a9 (patch) | |
| tree | 416ce8e13e3fd965cee263946e6c86f7e2efa68b | |
| parent | 9f221bd1a826f473b14393b1cf523543738c5050 (diff) | |
| parent | ff9eb96a93cdb5509a45f84bc557eb6dc9122c27 (diff) | |
Merge pull request #37 from LabNConsulting/working/2.0/patch-set-170102a
Working/2.0/patch set 170102a
| -rw-r--r-- | bgpd/bgp_attr.c | 223 | ||||
| -rw-r--r-- | bgpd/bgp_attr.h | 2 | ||||
| -rw-r--r-- | bgpd/bgp_ecommunity.c | 8 | ||||
| -rw-r--r-- | bgpd/bgp_route.c | 301 | ||||
| -rw-r--r-- | bgpd/bgp_vty.c | 154 | ||||
| -rw-r--r-- | bgpd/bgp_vty.h | 10 | ||||
| -rw-r--r-- | bgpd/rfapi/bgp_rfapi_cfg.c | 2 | ||||
| -rw-r--r-- | bgpd/rfapi/bgp_rfapi_cfg.h | 6 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi.c | 28 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi.h | 1 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi_import.c | 49 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi_import.h | 3 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi_rib.c | 2 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi_vty.c | 84 | ||||
| -rw-r--r-- | bgpd/rfapi/vnc_export_bgp.c | 1 | ||||
| -rw-r--r-- | doc/vnc.texi | 4 | ||||
| -rw-r--r-- | lib/command.c | 28 | ||||
| -rw-r--r-- | lib/log.c | 12 | ||||
| -rw-r--r-- | lib/prefix.c | 2 | ||||
| -rwxr-xr-x | lib/route_types.pl | 5 | ||||
| -rw-r--r-- | lib/route_types.txt | 8 | ||||
| -rw-r--r-- | lib/zclient.c | 28 |
22 files changed, 583 insertions, 378 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 827e4610f4..2115fb5efc 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -220,6 +220,11 @@ cluster_finish (void) cluster_hash = NULL; } +static struct hash *encap_hash = NULL; +#if ENABLE_BGP_VNC +static struct hash *vnc_hash = NULL; +#endif + struct bgp_attr_encap_subtlv * encap_tlv_dup(struct bgp_attr_encap_subtlv *orig) { @@ -287,14 +292,10 @@ encap_same(struct bgp_attr_encap_subtlv *h1, struct bgp_attr_encap_subtlv *h2) struct bgp_attr_encap_subtlv *p; struct bgp_attr_encap_subtlv *q; - if (!h1 && !h2) - return 1; - if (h1 && !h2) - return 0; - if (!h1 && h2) - return 0; if (h1 == h2) return 1; + if (h1 == NULL || h2 == NULL) + return 0; for (p = h1; p; p = p->next) { for (q = h2; q; q = q->next) { @@ -325,6 +326,96 @@ encap_same(struct bgp_attr_encap_subtlv *h1, struct bgp_attr_encap_subtlv *h2) return 1; } +static void * +encap_hash_alloc (void *p) +{ + /* Encap structure is already allocated. */ + return p; +} + +typedef enum +{ + ENCAP_SUBTLV_TYPE, +#if ENABLE_BGP_VNC + VNC_SUBTLV_TYPE +#endif +} encap_subtlv_type; + +static struct bgp_attr_encap_subtlv * +encap_intern (struct bgp_attr_encap_subtlv *encap, encap_subtlv_type type) +{ + struct bgp_attr_encap_subtlv *find; + struct hash *hash = encap_hash; +#if ENABLE_BGP_VNC + if (type == VNC_SUBTLV_TYPE) + hash = vnc_hash; +#endif + + find = hash_get (hash, encap, encap_hash_alloc); + if (find != encap) + encap_free (encap); + find->refcnt++; + + return find; +} + +static void +encap_unintern (struct bgp_attr_encap_subtlv **encapp, encap_subtlv_type type) +{ + struct bgp_attr_encap_subtlv *encap = *encapp; + if (encap->refcnt) + encap->refcnt--; + + if (encap->refcnt == 0) + { + struct hash *hash = encap_hash; +#if ENABLE_BGP_VNC + if (type == VNC_SUBTLV_TYPE) + hash = vnc_hash; +#endif + hash_release (hash, encap); + encap_free (encap); + *encapp = NULL; + } +} + +static unsigned int +encap_hash_key_make (void *p) +{ + const struct bgp_attr_encap_subtlv * encap = p; + + return jhash(encap->value, encap->length, 0); +} + +static int +encap_hash_cmp (const void *p1, const void *p2) +{ + return encap_same((struct bgp_attr_encap_subtlv *)p1, + (struct bgp_attr_encap_subtlv *)p2); +} + +static void +encap_init (void) +{ + encap_hash = hash_create (encap_hash_key_make, encap_hash_cmp); +#if ENABLE_BGP_VNC + vnc_hash = hash_create (encap_hash_key_make, encap_hash_cmp); +#endif +} + +static void +encap_finish (void) +{ + hash_clean (encap_hash, (void (*)(void *))encap_free); + hash_free (encap_hash); + encap_hash = NULL; +#if ENABLE_BGP_VNC + hash_clean (vnc_hash, (void (*)(void *))encap_free); + hash_free (vnc_hash); + vnc_hash = NULL; +#endif +} + /* Unknown transit attribute. */ static struct hash *transit_hash; @@ -433,16 +524,6 @@ bgp_attr_extra_free (struct attr *attr) { if (attr->extra) { - if (attr->extra->encap_subtlvs) { - encap_free(attr->extra->encap_subtlvs); - attr->extra->encap_subtlvs = NULL; - } -#if ENABLE_BGP_VNC - if (attr->extra->vnc_subtlvs) { - encap_free(attr->extra->vnc_subtlvs); - attr->extra->vnc_subtlvs = NULL; - } -#endif XFREE (MTYPE_ATTR_EXTRA, attr->extra); attr->extra = NULL; } @@ -480,28 +561,12 @@ bgp_attr_dup (struct attr *new, struct attr *orig) memset(new->extra, 0, sizeof(struct attr_extra)); if (orig->extra) { *new->extra = *orig->extra; - if (orig->extra->encap_subtlvs) { - new->extra->encap_subtlvs = encap_tlv_dup(orig->extra->encap_subtlvs); - } -#if ENABLE_BGP_VNC - if (orig->extra->vnc_subtlvs) { - new->extra->vnc_subtlvs = encap_tlv_dup(orig->extra->vnc_subtlvs); - } -#endif } } else if (orig->extra) { new->extra = bgp_attr_extra_new(); *new->extra = *orig->extra; - if (orig->extra->encap_subtlvs) { - new->extra->encap_subtlvs = encap_tlv_dup(orig->extra->encap_subtlvs); - } -#if ENABLE_BGP_VNC - if (orig->extra->vnc_subtlvs) { - new->extra->vnc_subtlvs = encap_tlv_dup(orig->extra->vnc_subtlvs); - } -#endif } } @@ -522,6 +587,12 @@ bgp_attr_deep_dup (struct attr *new, struct attr *orig) new->extra->cluster = cluster_dup(orig->extra->cluster); if (orig->extra->transit) new->extra->transit = transit_dup(orig->extra->transit); + if (orig->extra->encap_subtlvs) + new->extra->encap_subtlvs = encap_tlv_dup(orig->extra->encap_subtlvs); +#if ENABLE_BGP_VNC + if (orig->extra->vnc_subtlvs) + new->extra->vnc_subtlvs = encap_tlv_dup(orig->extra->vnc_subtlvs); +#endif } } @@ -542,6 +613,12 @@ bgp_attr_deep_free (struct attr *attr) cluster_free(attr->extra->cluster); if (attr->extra->transit) transit_free(attr->extra->transit); + if (attr->extra->encap_subtlvs) + encap_free(attr->extra->encap_subtlvs); +#if ENABLE_BGP_VNC + if (attr->extra->vnc_subtlvs) + encap_free(attr->extra->vnc_subtlvs); +#endif } } @@ -598,7 +675,12 @@ attrhash_key_make (void *p) MIX(cluster_hash_key_make (extra->cluster)); if (extra->transit) MIX(transit_hash_key_make (extra->transit)); - + if (extra->encap_subtlvs) + MIX(encap_hash_key_make (extra->encap_subtlvs)); +#if ENABLE_BGP_VNC + if (extra->vnc_subtlvs) + MIX(encap_hash_key_make (extra->vnc_subtlvs)); +#endif #ifdef HAVE_IPV6 MIX(extra->mp_nexthop_len); key = jhash(extra->mp_nexthop_global.s6_addr, IPV6_MAX_BYTELEN, key); @@ -711,13 +793,12 @@ bgp_attr_hash_alloc (void *p) { attr->extra = bgp_attr_extra_new (); *attr->extra = *val->extra; - - if (attr->extra->encap_subtlvs) { - attr->extra->encap_subtlvs = encap_tlv_dup(attr->extra->encap_subtlvs); + if (val->extra->encap_subtlvs) { + val->extra->encap_subtlvs = NULL; } #if ENABLE_BGP_VNC - if (attr->extra->vnc_subtlvs) { - attr->extra->vnc_subtlvs = encap_tlv_dup(attr->extra->vnc_subtlvs); + if (val->extra->vnc_subtlvs) { + val->extra->vnc_subtlvs = NULL; } #endif } @@ -772,11 +853,27 @@ bgp_attr_intern (struct attr *attr) else attre->transit->refcnt++; } + if (attre->encap_subtlvs) + { + if (! attre->encap_subtlvs->refcnt) + attre->encap_subtlvs = encap_intern (attre->encap_subtlvs, ENCAP_SUBTLV_TYPE); + else + attre->encap_subtlvs->refcnt++; + } +#if ENABLE_BGP_VNC + if (attre->vnc_subtlvs) + { + if (! attre->vnc_subtlvs->refcnt) + attre->vnc_subtlvs = encap_intern (attre->vnc_subtlvs, VNC_SUBTLV_TYPE); + else + attre->vnc_subtlvs->refcnt++; + } +#endif } find = (struct attr *) hash_get (attrhash, attr, bgp_attr_hash_alloc); find->refcnt++; - + return find; } @@ -810,6 +907,14 @@ bgp_attr_refcount (struct attr *attr) if (attre->transit) attre->transit->refcnt++; + + if (attre->encap_subtlvs) + attre->encap_subtlvs->refcnt++; + +#if ENABLE_BGP_VNC + if (attre->vnc_subtlvs) + attre->vnc_subtlvs->refcnt++; +#endif } attr->refcnt++; return attr; @@ -935,6 +1040,14 @@ bgp_attr_unintern_sub (struct attr *attr) if (attr->extra->transit) transit_unintern (attr->extra->transit); + + if (attr->extra->encap_subtlvs) + encap_unintern (&attr->extra->encap_subtlvs, ENCAP_SUBTLV_TYPE); + +#if ENABLE_BGP_VNC + if (attr->extra->vnc_subtlvs) + encap_unintern (&attr->extra->vnc_subtlvs, VNC_SUBTLV_TYPE); +#endif } } @@ -1000,11 +1113,17 @@ bgp_attr_flush (struct attr *attr) transit_free (attre->transit); attre->transit = NULL; } - encap_free(attre->encap_subtlvs); - attre->encap_subtlvs = NULL; + if (attre->encap_subtlvs && ! attre->encap_subtlvs->refcnt) + { + encap_free(attre->encap_subtlvs); + attre->encap_subtlvs = NULL; + } #if ENABLE_BGP_VNC - encap_free(attre->vnc_subtlvs); - attre->vnc_subtlvs = NULL; + if (attre->vnc_subtlvs && ! attre->vnc_subtlvs->refcnt) + { + encap_free(attre->vnc_subtlvs); + attre->vnc_subtlvs = NULL; + } #endif } } @@ -2492,10 +2611,18 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size, if (ret != BGP_ATTR_PARSE_PROCEED) return ret; } - - /* Finally intern unknown attribute. */ - if (attr->extra && attr->extra->transit) - attr->extra->transit = transit_intern (attr->extra->transit); + if (attr->extra) + { + /* Finally intern unknown attribute. */ + if (attr->extra->transit) + attr->extra->transit = transit_intern (attr->extra->transit); + if (attr->extra->encap_subtlvs) + attr->extra->encap_subtlvs = encap_intern (attr->extra->encap_subtlvs, ENCAP_SUBTLV_TYPE); +#if ENABLE_BGP_VNC + if (attr->extra->vnc_subtlvs) + attr->extra->vnc_subtlvs = encap_intern (attr->extra->vnc_subtlvs, VNC_SUBTLV_TYPE); +#endif + } return BGP_ATTR_PARSE_PROCEED; } @@ -3183,6 +3310,7 @@ bgp_attr_init (void) ecommunity_init (); cluster_init (); transit_init (); + encap_init (); } void @@ -3194,6 +3322,7 @@ bgp_attr_finish (void) ecommunity_finish (); cluster_finish (); transit_finish (); + encap_finish (); } /* Make attribute packet. */ diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h index d4f45ba60a..6e639078d6 100644 --- a/bgpd/bgp_attr.h +++ b/bgpd/bgp_attr.h @@ -58,6 +58,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA struct bgp_attr_encap_subtlv { struct bgp_attr_encap_subtlv *next; /* for chaining */ + /* Reference count of this attribute. */ + unsigned long refcnt; uint16_t type; uint16_t length; uint8_t value[1]; /* will be extended */ diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index 6c72aa36d9..65415dcee2 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -54,6 +54,13 @@ ecommunity_free (struct ecommunity **ecom) ecom = NULL; } +static void +ecommunity_hash_free (struct ecommunity *ecom) +{ + ecommunity_free(&ecom); +} + + /* Add a new Extended Communities value to Extended Communities Attribute structure. When the value is already exists in the structure, we don't add the value. Newly added value is sorted by @@ -282,6 +289,7 @@ ecommunity_init (void) void ecommunity_finish (void) { + hash_clean (ecomhash, (void (*)(void *))ecommunity_hash_free); hash_free (ecomhash); ecomhash = NULL; } diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index a61899447a..c717a930b1 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -631,8 +631,9 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, { if (peer_sort (new->peer) == BGP_PEER_IBGP && peer_sort (exist->peer) == BGP_PEER_IBGP - && CHECK_FLAG (mpath_cfg->ibgp_flags, - BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) + && (mpath_cfg == NULL || + CHECK_FLAG (mpath_cfg->ibgp_flags, + BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN))) { newm = BGP_CLUSTER_LIST_LENGTH(new->attr); existm = BGP_CLUSTER_LIST_LENGTH(exist->attr); @@ -868,9 +869,8 @@ bgp_info_cmp_compatible (struct bgp *bgp, struct bgp_info *new, struct bgp_info afi_t afi, safi_t safi) { int paths_eq; - struct bgp_maxpaths_cfg mpath_cfg; int ret; - ret = bgp_info_cmp (bgp, new, exist, &paths_eq, &mpath_cfg, 0, __func__); + ret = bgp_info_cmp (bgp, new, exist, &paths_eq, NULL, 0, __func__); if (paths_eq) ret = 0; @@ -1800,6 +1800,7 @@ subgroup_process_announce_selected (struct update_subgroup *subgrp, PEER_STATUS_ORF_WAIT_REFRESH)) return 0; + memset(&extra, 0, sizeof(struct attr_extra)); /* It's initialized in bgp_announce_check() */ attr.extra = &extra; @@ -4479,7 +4480,6 @@ bgp_config_write_table_map (struct vty *vty, struct bgp *bgp, afi_t afi, return 0; } - DEFUN (bgp_table_map, bgp_table_map_cmd, "table-map WORD", @@ -8167,12 +8167,10 @@ DEFUN (show_ip_bgp_ipv4, "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, - NULL, uj); - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, uj); + return bgp_show (vty, NULL, AFI_IP, + bgp_vty_safi_from_arg(argv[0]), + bgp_show_type_normal, NULL, uj); } ALIAS (show_ip_bgp_ipv4, @@ -8218,12 +8216,10 @@ DEFUN (show_ip_bgp_route_pathtype, DEFUN (show_bgp_ipv4_safi_route_pathtype, show_bgp_ipv4_safi_route_pathtype_cmd, - "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D (bestpath|multipath) {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -8231,16 +8227,14 @@ DEFUN (show_bgp_ipv4_safi_route_pathtype, { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + if (strncmp (argv[2], "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[1], AFI_IP, + bgp_vty_safi_from_arg(argv[0]), + NULL, 0, BGP_PATH_BESTPATH, uj); else - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP, + bgp_vty_safi_from_arg(argv[0]), + NULL, 0, BGP_PATH_MULTIPATH, uj); } DEFUN (show_bgp_ipv4_prefix, @@ -8281,32 +8275,27 @@ DEFUN (show_bgp_ipv6_prefix, DEFUN (show_ip_bgp_ipv4_route, show_ip_bgp_ipv4_route_cmd, - "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}", + "show ip bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D {json}", SHOW_STR IP_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); - - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP, + bgp_vty_safi_from_arg(argv[0]), + NULL, 0, BGP_PATH_ALL, uj); } ALIAS (show_ip_bgp_ipv4_route, show_bgp_ipv4_safi_route_cmd, - "show bgp ipv4 (unicast|multicast) A.B.C.D {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") @@ -8324,78 +8313,123 @@ DEFUN (show_ip_bgp_vpnv4_all_route, return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); } -DEFUN (show_bgp_ipv4_vpn_route, - show_bgp_ipv4_vpn_route_cmd, - "show bgp ipv4 vpn A.B.C.D {json}", +DEFUN (show_bgp_ipv4_safi_rd_route, + show_bgp_ipv4_safi_rd_route_cmd, + "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D {json}", SHOW_STR BGP_STR "Address Family\n" - "Display VPN NLRI specific information\n" - "Network in the BGP routing table to display\n" - JSON_STR) + "Address Family Modifier\n" + "Address Family Modifier\n" + "Display information for a route distinguisher\n" + "ENCAP Route Distinguisher\n" + "Network in the BGP routing table to display\n") { - return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); + int ret; + struct prefix_rd prd; + safi_t safi; + + if (bgp_parse_safi(argv[0], &safi)) { + vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + ret = str2prefix_rd (argv[1], &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; + } + return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); } -DEFUN (show_bgp_ipv6_vpn_route, - show_bgp_ipv6_vpn_route_cmd, - "show bgp ipv6 vpn X:X::X:X {json}", +DEFUN (show_bgp_ipv6_safi_rd_route, + show_bgp_ipv6_safi_rd_route_cmd, + "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X {json}", SHOW_STR BGP_STR "Address Family\n" - "Display VPN NLRI specific information\n" - "Network in the BGP routing table to display\n" - JSON_STR) + "Address Family Modifier\n" + "Address Family Modifier\n" + "Display information for a route distinguisher\n" + "ENCAP Route Distinguisher\n" + "Network in the BGP routing table to display\n") { - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); + int ret; + struct prefix_rd prd; + safi_t safi; + + if (bgp_parse_safi(argv[0], &safi)) { + vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + ret = str2prefix_rd (argv[1], &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; + } + return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); } -DEFUN (show_bgp_ipv4_vpn_rd_route, - show_bgp_ipv4_vpn_rd_route_cmd, - "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D {json}", + +DEFUN (show_bgp_ipv4_safi_rd_prefix, + show_bgp_ipv4_safi_rd_prefix_cmd, + "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}", SHOW_STR BGP_STR - IP_STR - "Display VPN NLRI specific information\n" + "Address Family\n" + "Address Family Modifier\n" + "Address Family Modifier\n" "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Network in the BGP routing table to display\n" - JSON_STR) + "ENCAP Route Distinguisher\n" + "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { int ret; struct prefix_rd prd; + safi_t safi; - ret = str2prefix_rd (argv[0], &prd); + if (bgp_parse_safi(argv[0], &safi)) { + vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + + ret = str2prefix_rd (argv[1], &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); + return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1, BGP_PATH_ALL, use_json (argc, argv)); } -DEFUN (show_bgp_ipv6_vpn_rd_route, - show_bgp_ipv6_vpn_rd_route_cmd, - "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X {json}", +DEFUN (show_bgp_ipv6_safi_rd_prefix, + show_bgp_ipv6_safi_rd_prefix_cmd, + "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M {json}", SHOW_STR BGP_STR "Address Family\n" - "Display VPN NLRI specific information\n" + "Address Family Modifier\n" + "Address Family Modifier\n" "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Network in the BGP routing table to display\n" - JSON_STR) + "ENCAP Route Distinguisher\n" + "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { int ret; struct prefix_rd prd; + safi_t safi; - ret = str2prefix_rd (argv[0], &prd); + if (bgp_parse_safi(argv[0], &safi)) { + vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + + ret = str2prefix_rd (argv[1], &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); + return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1, BGP_PATH_ALL, use_json (argc, argv)); } DEFUN (show_ip_bgp_vpnv4_rd_route, @@ -8455,44 +8489,37 @@ DEFUN (show_ip_bgp_prefix_pathtype, DEFUN (show_ip_bgp_ipv4_prefix, show_ip_bgp_ipv4_prefix_cmd, - "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}", + "show ip bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M {json}", SHOW_STR IP_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); - - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP, + bgp_vty_safi_from_arg(argv[0]), + NULL, 1, BGP_PATH_ALL, uj); } ALIAS (show_ip_bgp_ipv4_prefix, show_bgp_ipv4_safi_prefix_cmd, - "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "JavaScript Object Notation\n") DEFUN (show_ip_bgp_ipv4_prefix_pathtype, show_ip_bgp_ipv4_prefix_pathtype_cmd, - "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}", + "show ip bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M (bestpath|multipath) {json}", SHOW_STR IP_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -8500,26 +8527,22 @@ DEFUN (show_ip_bgp_ipv4_prefix_pathtype, { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + if (strncmp (argv[2], "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[1], AFI_IP, + bgp_vty_safi_from_arg(argv[0]), + NULL, 1, BGP_PATH_BESTPATH, uj); else - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP, + bgp_vty_safi_from_arg(argv[0]), + NULL, 1, BGP_PATH_MULTIPATH, uj); } ALIAS (show_ip_bgp_ipv4_prefix_pathtype, show_bgp_ipv4_safi_prefix_pathtype_cmd, - "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M (bestpath|multipath) {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -8693,14 +8716,14 @@ DEFUN (show_bgp_ipv6_safi, "Address family\n" "Address Family modifier\n" "Address Family modifier\n" + AFI_SAFI_STR "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, - NULL, uj); - return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL, uj); + return bgp_show (vty, NULL, AFI_IP6, + bgp_vty_safi_from_arg(argv[0]), + bgp_show_type_normal, NULL, uj); } static void @@ -8738,20 +8761,18 @@ DEFUN (show_bgp_route, DEFUN (show_bgp_ipv6_safi_route, show_bgp_ipv6_safi_route_cmd, - "show bgp ipv6 (unicast|multicast) X:X::X:X {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP6, + bgp_vty_safi_from_arg(argv[0]), + NULL, 0, BGP_PATH_ALL, uj); } DEFUN (show_bgp_route_pathtype, @@ -8784,28 +8805,24 @@ ALIAS (show_bgp_route_pathtype, DEFUN (show_bgp_ipv6_safi_route_pathtype, show_bgp_ipv6_safi_route_pathtype_cmd, - "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X (bestpath|multipath) {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Network in the BGP routing table to display\n" "Display only the bestpath\n" "Display only multipaths\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + if (strncmp (argv[2], "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[1], AFI_IP6, + bgp_vty_safi_from_arg(argv[0]), + NULL, 0, BGP_PATH_BESTPATH, uj); else - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP6, + bgp_vty_safi_from_arg(argv[0]), + NULL, 0, BGP_PATH_MULTIPATH, uj); } /* old command */ @@ -8835,20 +8852,18 @@ DEFUN (show_bgp_prefix, DEFUN (show_bgp_ipv6_safi_prefix, show_bgp_ipv6_safi_prefix_cmd, - "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X/M {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP6, + bgp_vty_safi_from_arg(argv[0]), + NULL, 1, BGP_PATH_ALL, uj); } DEFUN (show_bgp_prefix_pathtype, @@ -8881,28 +8896,23 @@ ALIAS (show_bgp_prefix_pathtype, DEFUN (show_bgp_ipv6_safi_prefix_pathtype, show_bgp_ipv6_safi_prefix_pathtype_cmd, - "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X/M (bestpath|multipath) {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" "Display only the bestpath\n" "Display only multipaths\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + if (strncmp (argv[2], "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[1], AFI_IP6, + bgp_vty_safi_from_arg(argv[0]), + NULL, 1, BGP_PATH_BESTPATH, uj); else - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP6, + bgp_vty_safi_from_arg(argv[0]), NULL, 1, BGP_PATH_MULTIPATH, uj); } /* old command */ @@ -14983,11 +14993,10 @@ bgp_route_init (void) install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd); - - install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd); + install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd); + install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd); + install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); + install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); /* BGP dampening clear commands */ install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 5b5fd01abe..29649c5b24 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -123,25 +123,29 @@ bgp_parse_afi(const char *str, afi_t *afi) return -1; } +/* supports (unicast|multicast|vpn|encap) */ +safi_t +bgp_vty_safi_from_arg(const char *safi_str) +{ + safi_t safi = SAFI_MAX; /* unknown */ + if (strncmp (safi_str, "m", 1) == 0) + safi = SAFI_MULTICAST; + else if (strncmp (safi_str, "u", 1) == 0) + safi = SAFI_UNICAST; + else if (strncmp (safi_str, "e", 1) == 0) + safi = SAFI_ENCAP; + else if (strncmp (safi_str, "v", 1) == 0) + safi = SAFI_MPLS_VPN; + return safi; +} + int bgp_parse_safi(const char *str, safi_t *safi) { - if (!strcmp(str, "encap")) { - *safi = SAFI_ENCAP; - return 0; - } - if (!strcmp(str, "multicast")) { - *safi = SAFI_MULTICAST; - return 0; - } - if (!strcmp(str, "unicast")) { - *safi = SAFI_UNICAST; - return 0; - } - if (!strcmp(str, "vpn")) { - *safi = SAFI_MPLS_VPN; - return 0; - } + *safi = bgp_vty_safi_from_arg(str); + if (*safi != SAFI_MAX) + return 0; + else return -1; } @@ -6050,14 +6054,24 @@ DEFUN (address_family_ipv4_safi, address_family_ipv4_safi_cmd, "address-family ipv4 (unicast|multicast)", "Enter Address Family command mode\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n") + AFI_SAFI_STR) { - if (strncmp (argv[0], "m", 1) == 0) - vty->node = BGP_IPV4M_NODE; - else - vty->node = BGP_IPV4_NODE; + switch (bgp_vty_safi_from_arg(argv[0])) + { + case SAFI_MULTICAST: + vty->node = BGP_IPV4M_NODE; + break; + case SAFI_ENCAP: + vty->node = BGP_ENCAP_NODE; + break; + case SAFI_MPLS_VPN: + vty->node = BGP_VPNV4_NODE; + break; + case SAFI_UNICAST: + default: + vty->node = BGP_IPV4_NODE; + break; + } return CMD_SUCCESS; } @@ -10755,60 +10769,27 @@ DEFUN (show_ip_bgp_instance_all_summary, DEFUN (show_ip_bgp_ipv4_summary, show_ip_bgp_ipv4_summary_cmd, - "show ip bgp ipv4 (unicast|multicast) summary {json}", + "show ip bgp ipv4 (unicast|multicast|vpn|encap) summary {json}", SHOW_STR IP_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, uj); - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj); + return bgp_show_summary_vty (vty, NULL, AFI_IP, bgp_vty_safi_from_arg(argv[0]), uj); } ALIAS (show_ip_bgp_ipv4_summary, show_bgp_ipv4_safi_summary_cmd, - "show bgp ipv4 (unicast|multicast) summary {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) summary {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Summary of BGP neighbor status\n") -DEFUN (show_bgp_ipv4_vpn_summary, - show_bgp_ipv4_vpn_summary_cmd, - "show bgp ipv4 vpn summary {json}", - SHOW_STR - BGP_STR - "IPv4\n" - "Display VPN NLRI specific information\n" - "Summary of BGP neighbor status\n" - JSON_STR) -{ - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, use_json (argc, argv)); -} - -/* `show ip bgp summary' commands. */ -DEFUN (show_bgp_ipv6_vpn_summary, - show_bgp_ipv6_vpn_summary_cmd, - "show bgp ipv6 vpn summary {json}", - SHOW_STR - BGP_STR - "IPv6\n" - "Display VPN NLRI specific information\n" - "Summary of BGP neighbor status\n" - JSON_STR) -{ - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MPLS_VPN, use_json (argc, argv)); -} - DEFUN (show_ip_bgp_instance_ipv4_summary, show_ip_bgp_instance_ipv4_summary_cmd, "show ip bgp view WORD ipv4 (unicast|multicast) summary {json}", @@ -10837,9 +10818,7 @@ ALIAS (show_ip_bgp_instance_ipv4_summary, BGP_STR "BGP view\n" "View name\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Summary of BGP neighbor status\n") DEFUN (show_ip_bgp_vpnv4_all_summary, @@ -10941,20 +10920,16 @@ ALIAS (show_bgp_instance_summary, DEFUN (show_bgp_ipv6_safi_summary, show_bgp_ipv6_safi_summary_cmd, - "show bgp ipv6 (unicast|multicast) summary {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) summary {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj); - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj); + return bgp_show_summary_vty (vty, NULL, AFI_IP6, bgp_vty_safi_from_arg(argv[0]), uj); } DEFUN (show_bgp_instance_ipv6_safi_summary, @@ -10963,9 +10938,7 @@ DEFUN (show_bgp_instance_ipv6_safi_summary, SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { @@ -13249,7 +13222,7 @@ DEFUN (show_bgp_instance_all_ipv6_updgrps, DEFUN (show_bgp_updgrps, show_bgp_updgrps_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast) update-groups", + "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups", SHOW_STR BGP_STR "Address family\n" @@ -13262,7 +13235,7 @@ DEFUN (show_bgp_updgrps, safi_t safi; afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + safi = bgp_vty_safi_from_arg(argv[1]); return (bgp_show_update_groups(vty, NULL, afi, safi, 0)); } @@ -13327,13 +13300,11 @@ DEFUN (show_bgp_instance_ipv6_updgrps_s, DEFUN (show_bgp_updgrps_s, show_bgp_updgrps_s_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID", + "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups SUBGROUP-ID", SHOW_STR BGP_STR "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Detailed info about v6 dynamic update groups\n" "Specific subgroup to display detailed info for") { @@ -13342,8 +13313,7 @@ DEFUN (show_bgp_updgrps_s, uint64_t subgrp_id; afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - + safi = bgp_vty_safi_from_arg(argv[1]); VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); return(bgp_show_update_groups(vty, NULL, afi, safi, subgrp_id)); } @@ -13441,13 +13411,11 @@ DEFUN (show_ip_bgp_instance_updgrps_adj, DEFUN (show_bgp_updgrps_afi_adj, show_bgp_updgrps_afi_adj_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast) update-groups (advertise-queue|advertised-routes|packet-queue)", + "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups (advertise-queue|advertised-routes|packet-queue)", SHOW_STR BGP_STR "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "BGP update groups\n" "Advertisement queue\n" "Announced routes\n" @@ -13458,7 +13426,7 @@ DEFUN (show_bgp_updgrps_afi_adj, safi_t safi; afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + safi = bgp_vty_safi_from_arg(argv[1]); show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[2], 0); return CMD_SUCCESS; } @@ -13537,13 +13505,11 @@ DEFUN (show_ip_bgp_instance_updgrps_adj_s, DEFUN (show_bgp_updgrps_afi_adj_s, show_bgp_updgrps_afi_adj_s_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)", + "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)", SHOW_STR BGP_STR "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "BGP update groups\n" "Specific subgroup to display info for\n" "Advertisement queue\n" @@ -13556,7 +13522,7 @@ DEFUN (show_bgp_updgrps_afi_adj_s, uint64_t subgrp_id; afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + safi = bgp_vty_safi_from_arg(argv[1]); VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[3], subgrp_id); @@ -16023,10 +15989,6 @@ bgp_vty_init (void) install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd); #endif /* HAVE_IPV6 */ - install_element (VIEW_NODE, &show_bgp_ipv4_vpn_summary_cmd); - - install_element (VIEW_NODE, &show_bgp_ipv6_vpn_summary_cmd); - /* "show ip bgp neighbors" commands. */ install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd); diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h index 573e8c7072..6b4e51bc50 100644 --- a/bgpd/bgp_vty.h +++ b/bgpd/bgp_vty.h @@ -30,6 +30,13 @@ struct bgp; #define BGP_INSTANCE_ALL_CMD "(view|vrf) all" #define BGP_INSTANCE_ALL_HELP_STR "BGP view\nBGP VRF\nAll Views/VRFs\n" +#define AFI_SAFI_STR \ + "Address family\n" \ + "Address Family modifier\n" \ + "Address Family modifier\n" \ + "Address Family modifier\n" \ + "Address Family modifier\n" + extern void bgp_vty_init (void); extern const char *afi_safi_print (afi_t, safi_t); extern int bgp_config_write_update_delay (struct vty *, struct bgp *); @@ -46,4 +53,7 @@ bgp_parse_afi(const char *str, afi_t *afi); extern int bgp_parse_safi(const char *str, safi_t *safi); +extern safi_t +bgp_vty_safi_from_arg(const char *safi_str); + #endif /* _QUAGGA_BGP_VTY_H */ diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index b27febbbeb..202abc61d1 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -3778,7 +3778,7 @@ static struct cmd_node bgp_vnc_l2_group_node = { 1 }; -static struct rfapi_l2_group_cfg * +struct rfapi_l2_group_cfg * bgp_rfapi_get_group_by_lni_label ( struct bgp *bgp, uint32_t logical_net_id, diff --git a/bgpd/rfapi/bgp_rfapi_cfg.h b/bgpd/rfapi/bgp_rfapi_cfg.h index 50ab3e27aa..897b4be764 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.h +++ b/bgpd/rfapi/bgp_rfapi_cfg.h @@ -300,6 +300,12 @@ bgp_rfapi_show_summary (struct bgp *bgp, struct vty *vty); extern struct rfapi_cfg * bgp_rfapi_get_config (struct bgp *bgp); +extern struct rfapi_l2_group_cfg * +bgp_rfapi_get_group_by_lni_label ( + struct bgp *bgp, + uint32_t logical_net_id, + uint32_t label); + extern struct ecommunity * bgp_rfapi_get_ecommunity_by_lni_label ( struct bgp *bgp, diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index 3e97b73538..5945eb09e6 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -2842,13 +2842,39 @@ rfapi_register ( * If mac address is set, add an RT based on the registered LNI */ memset ((char *) &ecom_value, 0, sizeof (ecom_value)); - ecom_value.val[1] = 0x02; + ecom_value.val[1] = ECOMMUNITY_ROUTE_TARGET; ecom_value.val[5] = (l2o->logical_net_id >> 16) & 0xff; ecom_value.val[6] = (l2o->logical_net_id >> 8) & 0xff; ecom_value.val[7] = (l2o->logical_net_id >> 0) & 0xff; rtlist = ecommunity_new(); ecommunity_add_val (rtlist, &ecom_value); } + if (l2o->tag_id) + { + as_t as = bgp->as; + uint16_t val = l2o->tag_id; + memset ((char *) &ecom_value, 0, sizeof (ecom_value)); + ecom_value.val[1] = ECOMMUNITY_ROUTE_TARGET; + if (as > BGP_AS_MAX) + { + ecom_value.val[0] = ECOMMUNITY_ENCODE_AS4; + ecom_value.val[2] = (as >>24) & 0xff; + ecom_value.val[3] = (as >>16) & 0xff; + ecom_value.val[4] = (as >>8) & 0xff; + ecom_value.val[5] = as & 0xff; + } + else + { + ecom_value.val[0] = ECOMMUNITY_ENCODE_AS; + ecom_value.val[2] = (as >>8) & 0xff; + ecom_value.val[3] = as & 0xff; + } + ecom_value.val[6] = (val >> 8) & 0xff; + ecom_value.val[7] = val & 0xff; + if (rtlist == NULL) + rtlist = ecommunity_new(); + ecommunity_add_val (rtlist, &ecom_value); + } } /* diff --git a/bgpd/rfapi/rfapi.h b/bgpd/rfapi/rfapi.h index 7d108432ae..420c6e0d71 100644 --- a/bgpd/rfapi/rfapi.h +++ b/bgpd/rfapi/rfapi.h @@ -89,6 +89,7 @@ struct rfapi_l2address_option uint32_t logical_net_id; /* ~= EVPN Ethernet Segment Id, must not be zero for mac regis. */ uint8_t local_nve_id; + uint16_t tag_id; /* EVPN Ethernet Tag ID, 0 = none */ }; typedef enum diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 0b46702bb0..25c05e65f8 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -1130,6 +1130,49 @@ rfapiEcommunityGetLNI (struct ecommunity *ecom, uint32_t * lni) return ENOENT; } +int +rfapiEcommunityGetEthernetTag (struct ecommunity *ecom, uint16_t * tag_id) +{ + struct bgp *bgp = bgp_get_default (); + *tag_id = 0; /* default to untagged */ + if (ecom) + { + int i; + for (i = 0; i < ecom->size; ++i) + { + as_t as = 0; + int encode = 0; + uint8_t *p = ecom->val + (i * ECOMMUNITY_SIZE); + + /* High-order octet of type. */ + encode = *p++; + + if (*p++ == ECOMMUNITY_ROUTE_TARGET) { + if (encode == ECOMMUNITY_ENCODE_AS4) + { + as = (*p++ << 24); + as |= (*p++ << 16); + as |= (*p++ << 8); + as |= (*p++); + } + else if (encode == ECOMMUNITY_ENCODE_AS) + { + as = (*p++ << 8); + as |= (*p++); + p += 2; /* skip next two, tag/vid always in lowest bytes */ + } + if (as == bgp->as) + { + *tag_id = *p++ << 8; + *tag_id |= (*p++); + return 0; + } + } + } + } + return ENOENT; +} + static int rfapiVpnBiNhEqualsPt (struct bgp_info *bi, struct rfapi_ip_addr *hpt) { @@ -1377,6 +1420,8 @@ rfapiRouteInfo2NextHopEntry ( { (void) rfapiEcommunityGetLNI (bi->attr->extra->ecommunity, &vo->v.l2addr.logical_net_id); + (void) rfapiEcommunityGetEthernetTag (bi->attr->extra->ecommunity, + &vo->v.l2addr.tag_id); } /* local_nve_id comes from lower byte of RD type */ @@ -2106,6 +2151,7 @@ rfapiBgpInfoAttachSorted ( info_new->next = next; if (next) next->prev = info_new; + bgp_attr_intern (info_new->attr); } static void @@ -2114,6 +2160,7 @@ rfapiBgpInfoDetach (struct route_node *rn, struct bgp_info *bi) /* * Remove the route (doubly-linked) */ + // bgp_attr_unintern (&bi->attr); if (bi->next) bi->next->prev = bi->prev; if (bi->prev) @@ -2464,6 +2511,7 @@ rfapiMonitorEncapAdd ( __func__, import_table, vpn_bi, afi, rn, m); RFAPI_CHECK_REFCOUNT (rn, SAFI_ENCAP, 0); + bgp_attr_intern (vpn_bi->attr); } static void @@ -2966,6 +3014,7 @@ rfapiBiStartWithdrawTimer ( wcb->node = rn; wcb->info = bi; wcb->import_table = import_table; + bgp_attr_intern (bi->attr); if (VNC_DEBUG(VERBOSE)) { diff --git a/bgpd/rfapi/rfapi_import.h b/bgpd/rfapi/rfapi_import.h index 3a1ae3573e..3cf55462a1 100644 --- a/bgpd/rfapi/rfapi_import.h +++ b/bgpd/rfapi/rfapi_import.h @@ -203,6 +203,9 @@ extern int rfapiEcommunityGetLNI ( struct ecommunity *ecom, uint32_t *lni); +extern int rfapiEcommunityGetEthernetTag ( + struct ecommunity *ecom, + uint16_t * tag_id); /* enable for debugging; disable for performance */ #if 0 diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index daedbeedef..6aae35e635 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -707,6 +707,8 @@ rfapiRibBi2Ri( { (void) rfapiEcommunityGetLNI (bi->attr->extra->ecommunity, &vo->v.l2addr.logical_net_id); + (void) rfapiEcommunityGetEthernetTag (bi->attr->extra->ecommunity, + &vo->v.l2addr.tag_id); } /* local_nve_id comes from RD */ diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 9b12ad3f7e..fe9b8a3f50 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -2546,7 +2546,7 @@ DEFUN (add_vnc_prefix_cost_life_lnh, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> lifetime <1-4294967295> .LNH_OPTIONS", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2572,7 +2572,7 @@ DEFUN (add_vnc_prefix_life_cost_lnh, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295> cost <0-255> .LNH_OPTIONS", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2598,7 +2598,7 @@ DEFUN (add_vnc_prefix_cost_lnh, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> .LNH_OPTIONS", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2622,7 +2622,7 @@ DEFUN (add_vnc_prefix_life_lnh, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295> .LNH_OPTIONS", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2646,7 +2646,7 @@ DEFUN (add_vnc_prefix_lnh, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) .LNH_OPTIONS", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2671,7 +2671,7 @@ DEFUN (add_vnc_prefix_cost_life, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> lifetime <1-4294967295>", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2697,7 +2697,7 @@ DEFUN (add_vnc_prefix_life_cost, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295> cost <0-255>", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2723,7 +2723,7 @@ DEFUN (add_vnc_prefix_cost, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255>", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2747,7 +2747,7 @@ DEFUN (add_vnc_prefix_life, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295>", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2771,7 +2771,7 @@ DEFUN (add_vnc_prefix, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X)", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2796,7 +2796,7 @@ DEFUN (add_vnc_mac_vni_prefix_cost_life, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M) cost <0-255> lifetime <1-4294967295>", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -2806,7 +2806,7 @@ DEFUN (add_vnc_mac_vni_prefix_cost_life, "UN address of NVE\n" "UN IPv4 interface address\n" "UN IPv6 interface address\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "Administrative cost [default: 255]\n" @@ -2826,7 +2826,7 @@ DEFUN (add_vnc_mac_vni_prefix_life, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M) lifetime <1-4294967295>", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -2836,7 +2836,7 @@ DEFUN (add_vnc_mac_vni_prefix_life, "UN address of NVE\n" "UN IPv4 interface address\n" "UN IPv6 interface address\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "Registration lifetime [default: infinite]\n" @@ -2853,7 +2853,7 @@ DEFUN (add_vnc_mac_vni_prefix_cost, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M) cost <0-255>", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -2863,7 +2863,7 @@ DEFUN (add_vnc_mac_vni_prefix_cost, "UN address of NVE\n" "UN IPv4 interface address\n" "UN IPv6 interface address\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "Administrative cost [default: 255]\n" "Administrative cost\n") @@ -2879,7 +2879,7 @@ DEFUN (add_vnc_mac_vni_prefix, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M)", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -2889,7 +2889,7 @@ DEFUN (add_vnc_mac_vni_prefix, "UN address of NVE\n" "UN IPv4 interface address\n" "UN IPv6 interface address\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n") { /* pfx vn un cost life */ @@ -2903,7 +2903,7 @@ DEFUN (add_vnc_mac_vni_cost_life, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> lifetime <1-4294967295>", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -2930,7 +2930,7 @@ DEFUN (add_vnc_mac_vni_cost, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255>", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -2954,7 +2954,7 @@ DEFUN (add_vnc_mac_vni_life, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295>", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -2979,7 +2979,7 @@ DEFUN (add_vnc_mac_vni, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X)", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -3723,7 +3723,7 @@ DEFUN (clear_vnc_nve_vn_un, "clear vnc nve vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "VN address of NVE\n" "VN IPv4 interface address\n" "VN IPv6 interface address\n" @@ -3753,7 +3753,7 @@ DEFUN (clear_vnc_nve_un_vn, "clear vnc nve un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "UN address of NVE\n" "UN IPv4 interface address\n" "UN IPv6 interface address\n" @@ -3783,7 +3783,7 @@ DEFUN (clear_vnc_nve_vn, "clear vnc nve vn (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "VN address of NVE\n" "VN IPv4 interface address\n" "VN IPv6 interface address\n") { @@ -3808,7 +3808,7 @@ DEFUN (clear_vnc_nve_un, "clear vnc nve un (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "UN address of NVE\n" "UN IPv4 interface address\n" "UN IPv6 interface address\n") { @@ -3841,7 +3841,7 @@ DEFUN (clear_vnc_prefix_vn_un, "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "All prefixes\n" "IPv4 prefix\n" "IPv6 prefix\n" @@ -3871,7 +3871,7 @@ DEFUN (clear_vnc_prefix_un_vn, "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "All prefixes\n" "IPv4 prefix\n" "IPv6 prefix\n" @@ -3901,7 +3901,7 @@ DEFUN (clear_vnc_prefix_un, "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) un (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "All prefixes\n" "IPv4 prefix\n" "IPv6 prefix\n" @@ -3927,7 +3927,7 @@ DEFUN (clear_vnc_prefix_vn, "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) vn (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "All prefixes\n" "IPv4 prefix\n" "IPv6 prefix\n" @@ -3953,7 +3953,7 @@ DEFUN (clear_vnc_prefix_all, "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) *", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "All prefixes\n" "IPv4 prefix\n" "IPv6 prefix\n" @@ -3983,7 +3983,7 @@ DEFUN (clear_vnc_mac_vn_un, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4018,7 +4018,7 @@ DEFUN (clear_vnc_mac_un_vn, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4052,7 +4052,7 @@ DEFUN (clear_vnc_mac_un, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4081,7 +4081,7 @@ DEFUN (clear_vnc_mac_vn, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4110,7 +4110,7 @@ DEFUN (clear_vnc_mac_all, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) *", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4140,7 +4140,7 @@ DEFUN (clear_vnc_mac_vn_un_prefix, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4155,7 +4155,7 @@ DEFUN (clear_vnc_mac_vn_un_prefix, "All UN addresses\n" "UN IPv4 interface address\n" "UN IPv6 interface address\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "All prefixes\n" "IPv4 prefix\n" "IPv6 prefix\n") @@ -4179,7 +4179,7 @@ DEFUN (clear_vnc_mac_un_vn_prefix, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M) prefix (*|A.B.C.D/M|X:X::X:X/M)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4213,7 +4213,7 @@ DEFUN (clear_vnc_mac_un_prefix, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4243,7 +4243,7 @@ DEFUN (clear_vnc_mac_vn_prefix, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4273,7 +4273,7 @@ DEFUN (clear_vnc_mac_all_prefix, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) prefix (*|A.B.C.D/M|X:X::X:X/M)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c index bcfa145c67..f20e9ed674 100644 --- a/bgpd/rfapi/vnc_export_bgp.c +++ b/bgpd/rfapi/vnc_export_bgp.c @@ -76,7 +76,6 @@ encap_attr_export_ce ( memset (new, 0, sizeof (struct attr)); bgp_attr_dup (new, orig); bgp_attr_extra_get (new); - bgp_attr_flush_encap (new); /* * Set nexthop diff --git a/doc/vnc.texi b/doc/vnc.texi index 341cbfcce8..b0d2829cae 100644 --- a/doc/vnc.texi +++ b/doc/vnc.texi @@ -726,7 +726,7 @@ provided to other protocols, either via zebra or directly to BGP. It is important to note that when exporting routes to other protocols, the downstream protocol must also be configured to import the routes. For example, when VNC routes are exported to unicast BGP, the BGP -configuration must include a corresponding @code{redistribute vpn} +configuration must include a corresponding @code{redistribute vnc-direct} statement. @deffn {VNC} {export bgp|zebra mode none|group-nve|registering-nve|ce} @@ -1115,7 +1115,7 @@ The configuration for @code{VNC-GW 1} is shown below. router bgp 64512 bgp router-id 192.168.1.101 bgp cluster-id 1.2.3.4 - redistribute vpn + redistribute vnc-direct neighbor 192.168.1.102 remote-as 64512 no neighbor 192.168.1.102 activate neighbor 192.168.1.103 remote-as 64512 diff --git a/lib/command.c b/lib/command.c index 399252777f..bc816dedea 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1061,6 +1061,7 @@ cmd_ipv6_prefix_match (const char *str) const char *delim = "/\0"; char *dupe, *prefix, *mask, *context, *endptr; int nmask = -1; + enum match_type ret; if (str == NULL) return partly_match; @@ -1074,21 +1075,26 @@ cmd_ipv6_prefix_match (const char *str) prefix = strtok_r(dupe, delim, &context); mask = strtok_r(NULL, delim, &context); + ret = exact_match; if (!mask) - return partly_match; - - /* validate prefix */ - if (inet_pton(AF_INET6, prefix, &sin6_dummy.sin6_addr) != 1) - return no_match; - - /* validate mask */ - nmask = strtol (mask, &endptr, 10); - if (*endptr != '\0' || nmask < 0 || nmask > 128) - return no_match; + ret = partly_match; + else + { + /* validate prefix */ + if (inet_pton(AF_INET6, prefix, &sin6_dummy.sin6_addr) != 1) + ret = no_match; + else + { + /* validate mask */ + nmask = strtol (mask, &endptr, 10); + if (*endptr != '\0' || nmask < 0 || nmask > 128) + ret = no_match; + } + } XFREE(MTYPE_TMP, dupe); - return exact_match; + return ret; } #endif /* HAVE_IPV6 */ @@ -1077,10 +1077,10 @@ proto_redistnum(int afi, const char *s) return ZEBRA_ROUTE_BGP; else if (strncmp (s, "ta", 2) == 0) return ZEBRA_ROUTE_TABLE; - else if (strncmp (s, "v", 1) == 0) - return ZEBRA_ROUTE_VNC; - else if (strncmp (s, "vd", 1) == 0) + else if (strcmp (s, "vnc-direct") == 0) return ZEBRA_ROUTE_VNC_DIRECT; + else if (strcmp (s, "vnc") == 0) + return ZEBRA_ROUTE_VNC; } if (afi == AFI_IP6) { @@ -1100,10 +1100,10 @@ proto_redistnum(int afi, const char *s) return ZEBRA_ROUTE_BGP; else if (strncmp (s, "ta", 2) == 0) return ZEBRA_ROUTE_TABLE; - else if (strncmp (s, "v", 1) == 0) - return ZEBRA_ROUTE_VNC; - else if (strncmp (s, "vd", 1) == 0) + else if (strcmp (s, "vnc-direct") == 0) return ZEBRA_ROUTE_VNC_DIRECT; + else if (strcmp (s, "vnc") == 0) + return ZEBRA_ROUTE_VNC; } return -1; } diff --git a/lib/prefix.c b/lib/prefix.c index bc6afcf9f8..84a04c5300 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -665,7 +665,7 @@ str2prefix_ipv6 (const char *str, struct prefix_ipv6 *p) strncpy (cp, str, pnt - str); *(cp + (pnt - str)) = '\0'; ret = inet_pton (AF_INET6, cp, &p->prefix); - free (cp); + XFREE (MTYPE_TMP, cp); if (ret == 0) return 0; plen = (u_char) atoi (++pnt); diff --git a/lib/route_types.pl b/lib/route_types.pl index ffe9bec04b..62c7417b84 100755 --- a/lib/route_types.pl +++ b/lib/route_types.pl @@ -56,7 +56,7 @@ while (<STDIN>) { # else: 7-field line my @f = split(/,/, $_); - unless (@f == 7) { + unless (@f == 7 || @f == 8) { die "invalid input on route_types line $.\n"; } @@ -73,6 +73,7 @@ while (<STDIN>) { "ipv4" => int($f[4]), "ipv6" => int($f[5]), "shorthelp" => $f[6], + "restrict2" => $f[7], }; push @protos, $proto; $daemons{$f[2]} = { @@ -137,6 +138,8 @@ sub collect { my (@names, @help) = ((), ()); for my $p (@protos) { next if ($protodetail{$p}->{"daemon"} eq $daemon && $daemon ne "zebra"); + next if ($protodetail{$p}->{"restrict2"} ne "" && + $protodetail{$p}->{"restrict2"} ne $daemon); next unless (($ipv4 && $protodetail{$p}->{"ipv4"}) || ($ipv6 && $protodetail{$p}->{"ipv6"})); push @names, $protodetail{$p}->{"cname"}; diff --git a/lib/route_types.txt b/lib/route_types.txt index 54572450b5..154f03f01c 100644 --- a/lib/route_types.txt +++ b/lib/route_types.txt @@ -64,9 +64,9 @@ ZEBRA_ROUTE_LDP, ldp, ldpd, 'L', 0, 0, "LDP" #vnc when sent to zebra ZEBRA_ROUTE_VNC, vnc, NULL, 'v', 1, 1, "VNC" # vnc when sent to bgp -ZEBRA_ROUTE_VNC_DIRECT, vpn, NULL, 'V', 1, 1, "VPN" -# vnc when sent to bgp (remote next hop?) -ZEBRA_ROUTE_VNC_DIRECT_RH, vpn-rh, NULL, 'V', 0, 0, "VPN" +ZEBRA_ROUTE_VNC_DIRECT, vnc-direct,NULL, 'V', 1, 1, "VNC-Direct", bgpd +# vnc when sent to bgp (resolve NVE mode) +ZEBRA_ROUTE_VNC_DIRECT_RH, vnc-rn, NULL, 'V', 0, 0, "VNC-RN" # bgp unicast -> vnc ZEBRA_ROUTE_BGP_DIRECT, bgp-direct, NULL, 'b', 0, 0, "BGP-Direct" # bgp unicast -> vnc @@ -90,4 +90,4 @@ ZEBRA_ROUTE_VNC, "Virtual Network Control (VNC)" ZEBRA_ROUTE_OLSR, "Optimised Link State Routing (OLSR)" ZEBRA_ROUTE_TABLE, "Non-main Kernel Routing Table" ZEBRA_ROUTE_LDP, "Label Distribution Protocol (LDP)" -ZEBRA_ROUTE_VNC_DIRECT, "VPN routes(VPN)" +ZEBRA_ROUTE_VNC_DIRECT, "VNC direct (not via zebra) routes" diff --git a/lib/zclient.c b/lib/zclient.c index 894e0d19ef..440de3635f 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -216,7 +216,9 @@ zclient_socket(void) ret = connect (sock, (struct sockaddr *) &serv, sizeof (serv)); if (ret < 0) { - zlog_warn ("%s connect failure: %d", __PRETTY_FUNCTION__, errno); + if (zclient_debug) + zlog_warn ("%s connect failure: %d(%s)", __PRETTY_FUNCTION__, + errno, safe_strerror (errno)); close (sock); return -1; } @@ -252,7 +254,9 @@ zclient_socket_un (const char *path) ret = connect (sock, (struct sockaddr *) &addr, len); if (ret < 0) { - zlog_warn ("%s connect failure: %d", __PRETTY_FUNCTION__, errno); + if (zclient_debug) + zlog_warn ("%s connect failure: %d(%s)", __PRETTY_FUNCTION__, + errno, safe_strerror (errno)); close (sock); return -1; } @@ -572,23 +576,11 @@ zclient_start (struct zclient *zclient) if (zclient->t_connect) return 0; - /* - * If we fail to connect to the socket on initialization, - * Let's wait a second and see if we can reconnect. - * Cause if we don't connect, we never attempt to - * reconnect. On startup if zebra is slow we - * can get into this situation. - */ - while (zclient_socket_connect(zclient) < 0 && zclient->fail < 5) + if (zclient_socket_connect(zclient) < 0) { if (zclient_debug) zlog_debug ("zclient connection fail"); zclient->fail++; - sleep (1); - } - - if (zclient->sock < 0) - { zclient_event (ZCLIENT_CONNECT, zclient); return -1; } @@ -1727,11 +1719,9 @@ zclient_event (enum event event, struct zclient *zclient) thread_add_event (zclient->master, zclient_connect, zclient, 0); break; case ZCLIENT_CONNECT: - if (zclient->fail >= 10) - return; if (zclient_debug) - zlog_debug ("zclient connect schedule interval is %d", - zclient->fail < 3 ? 10 : 60); + zlog_debug ("zclient connect failures: %d schedule interval is now %d", + zclient->fail, zclient->fail < 3 ? 10 : 60); if (! zclient->t_connect) zclient->t_connect = thread_add_timer (zclient->master, zclient_connect, zclient, |
