From c7ff8580f7cb0834680dc6a48a322c5545a22bfd Mon Sep 17 00:00:00 2001 From: Satoshi Fujimoto Date: Fri, 14 Jul 2017 14:01:28 +0900 Subject: cli: get detailed RPKI information This patch adds the feature in the neighbor subcommand to get detailed information about RPKI validation. The command receives a prefix in Adj-RIB-In, and gives the detailed RPKI information for the route. The informaton includes the validation status, the reason if it is invalid, and matched/unmatched VRPs. Example: $ gobgp neighbor 172.17.0.3 adj-in 2.1.0.0/16 validation Target Prefix: 2.1.0.0/16, AS: 65001 This route is invalid reason: as No VRP ASN matches the route origin ASN. Matched VRPs: No Entry Unmatched AS VRPs: Network AS MaxLen 2.0.0.0/12 3215 16 2.1.0.0/16 3215 16 Unmatched Length VRPs: No Entry Signed-off-by: Satoshi Fujimoto --- client/client.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'client') diff --git a/client/client.go b/client/client.go index b9faf6ba..e8108c64 100644 --- a/client/client.go +++ b/client/client.go @@ -22,12 +22,13 @@ import ( "strconv" "time" + "golang.org/x/net/context" + "google.golang.org/grpc" + api "github.com/osrg/gobgp/api" "github.com/osrg/gobgp/config" "github.com/osrg/gobgp/packet/bgp" "github.com/osrg/gobgp/table" - "golang.org/x/net/context" - "google.golang.org/grpc" ) type Client struct { @@ -841,17 +842,7 @@ func (cli *Client) GetROA(family bgp.RouteFamily) ([]*table.ROA, error) { if err != nil { return nil, err } - roas := make([]*table.ROA, 0, len(rsp.Roas)) - for _, r := range rsp.Roas { - ip := net.ParseIP(r.Prefix) - if ip.To4() != nil { - ip = ip.To4() - } - afi, _ := bgp.RouteFamilyToAfiSafi(family) - roa := table.NewROA(int(afi), []byte(ip), uint8(r.Prefixlen), uint8(r.Maxlen), r.As, net.JoinHostPort(r.Conf.Address, r.Conf.RemotePort)) - roas = append(roas, roa) - } - return roas, nil + return api.NewROAListFromApiStructList(rsp.Roas), nil } func (cli *Client) AddRPKIServer(address string, port, lifetime int) error { -- cgit v1.2.3