]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_route.c
bgpd: Add 'rd all' keyword to EVPN/L3VPN show cmds
[mirror_frr.git] / bgpd / bgp_route.c
index d7a4a4363340e29546c237f55848ddf92c53c9f8..b3c6fbff8f58a6380196de16eea2a1ecd957e53a 100644 (file)
@@ -97,6 +97,11 @@ DEFINE_HOOK(bgp_snmp_update_stats,
            (struct bgp_node *rn, struct bgp_path_info *pi, bool added),
            (rn, pi, added))
 
+DEFINE_HOOK(bgp_rpki_prefix_status,
+           (struct peer *peer, struct attr *attr,
+            const struct prefix *prefix),
+           (peer, attr, prefix))
+
 /* Extern from bgp_dump.c */
 extern const char *bgp_origin_str[];
 extern const char *bgp_origin_long_str[];
@@ -990,7 +995,7 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
        if (newm < existm) {
                if (debug)
                        zlog_debug(
-                               "%s: %s wins over %s due to IGP metric %d < %d",
+                               "%s: %s wins over %s due to IGP metric %u < %u",
                                pfx_buf, new_buf, exist_buf, newm, existm);
                ret = 1;
        }
@@ -998,7 +1003,7 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
        if (newm > existm) {
                if (debug)
                        zlog_debug(
-                               "%s: %s loses to %s due to IGP metric %d > %d",
+                               "%s: %s loses to %s due to IGP metric %u > %u",
                                pfx_buf, new_buf, exist_buf, newm, existm);
                ret = 0;
        }
@@ -1020,7 +1025,7 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
                        if (newm < existm) {
                                if (debug)
                                        zlog_debug(
-                                               "%s: %s wins over %s due to CLUSTER_LIST length %d < %d",
+                                               "%s: %s wins over %s due to CLUSTER_LIST length %u < %u",
                                                pfx_buf, new_buf, exist_buf,
                                                newm, existm);
                                ret = 1;
@@ -1029,7 +1034,7 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
                        if (newm > existm) {
                                if (debug)
                                        zlog_debug(
-                                               "%s: %s loses to %s due to CLUSTER_LIST length %d > %d",
+                                               "%s: %s loses to %s due to CLUSTER_LIST length %u > %u",
                                                pfx_buf, new_buf, exist_buf,
                                                newm, existm);
                                ret = 0;
@@ -5250,26 +5255,18 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
                /* Check address. */
                if (afi == AFI_IP6 && safi == SAFI_UNICAST) {
                        if (IN6_IS_ADDR_LINKLOCAL(&p.u.prefix6)) {
-                               char buf[BUFSIZ];
-
                                flog_err(
                                        EC_BGP_UPDATE_RCV,
-                                       "%s: IPv6 unicast NLRI is link-local address %s, ignoring",
-                                       peer->host,
-                                       inet_ntop(AF_INET6, &p.u.prefix6, buf,
-                                                 BUFSIZ));
+                                       "%s: IPv6 unicast NLRI is link-local address %pI6, ignoring",
+                                       peer->host, &p.u.prefix6);
 
                                continue;
                        }
                        if (IN6_IS_ADDR_MULTICAST(&p.u.prefix6)) {
-                               char buf[BUFSIZ];
-
                                flog_err(
                                        EC_BGP_UPDATE_RCV,
-                                       "%s: IPv6 unicast NLRI is multicast address %s, ignoring",
-                                       peer->host,
-                                       inet_ntop(AF_INET6, &p.u.prefix6, buf,
-                                                 BUFSIZ));
+                                       "%s: IPv6 unicast NLRI is multicast address %pI6, ignoring",
+                                       peer->host, &p.u.prefix6);
 
                                continue;
                        }
@@ -7554,6 +7551,21 @@ static const char *bgp_origin2str(uint8_t origin)
        return "n/a";
 }
 
+static const char *bgp_rpki_validation2str(int v_state)
+{
+       switch (v_state) {
+       case 1:
+               return "valid";
+       case 2:
+               return "not found";
+       case 3:
+               return "invalid";
+       default:
+               break;
+       }
+       return "ERROR";
+}
+
 int bgp_aggregate_unset(struct bgp *bgp, struct prefix *prefix, afi_t afi,
                        safi_t safi, char *errmsg, size_t errmsg_len)
 {
@@ -9568,6 +9580,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
        int i;
        char *nexthop_hostname =
                bgp_nexthop_hostname(path->peer, path->nexthop);
+       int rpki_validation_state = 0;
 
        if (json_paths) {
                json_path = json_object_new_object();
@@ -10166,6 +10179,20 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
                }
        }
 
+       const struct prefix *p = bgp_dest_get_prefix(bn);
+       if (p->family == AF_INET || p->family == AF_INET6)
+               rpki_validation_state = hook_call(bgp_rpki_prefix_status,
+                                                 path->peer, path->attr, p);
+       if (rpki_validation_state) {
+               if (json_paths)
+                       json_object_string_add(
+                               json_path, "rpkiValidationState",
+                               bgp_rpki_validation2str(rpki_validation_state));
+               else
+                       vty_out(vty, ", validation-state: %s",
+                               bgp_rpki_validation2str(rpki_validation_state));
+       }
+
        if (json_bestpath)
                json_object_object_add(json_path, "bestpath", json_bestpath);
 
@@ -12385,6 +12412,9 @@ static int bgp_table_stats_walker(struct thread *t)
        case AFI_IP6:
                space = IPV6_MAX_BITLEN;
                break;
+       case AFI_L2VPN:
+               space = EVPN_ROUTE_PREFIXLEN;
+               break;
        default:
                return 0;
        }
@@ -13794,13 +13824,14 @@ struct bgp_distance {
 
 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 bgp "BGP_AFI_CMD_STR" vpn rd <ASN:NN_OR_IP-ADDRESS:NN|all> <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"
+       "All Route Distinguishers\n"
        "Network in the BGP routing table to display\n"
        "Network in the BGP routing table to display\n"
        JSON_STR)
@@ -13815,6 +13846,11 @@ DEFUN (show_bgp_afi_vpn_rd_route,
                return CMD_WARNING;
        }
 
+       if (!strcmp(argv[5]->arg, "all"))
+               return bgp_show_route(vty, NULL, argv[6]->arg, afi,
+                                     SAFI_MPLS_VPN, NULL, 0, BGP_PATH_SHOW_ALL,
+                                     use_json(argc, argv));
+
        ret = str2prefix_rd(argv[5]->arg, &prd);
        if (!ret) {
                vty_out(vty, "%% Malformed Route Distinguisher\n");