summaryrefslogtreecommitdiffhomepage
path: root/api/grpc_server.go
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-07-14 14:01:28 +0900
committerSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-07-19 09:44:20 +0900
commitc7ff8580f7cb0834680dc6a48a322c5545a22bfd (patch)
tree8243fcf926e757a5d0ff7afefe1381123dc76420 /api/grpc_server.go
parent2678142d300aea2d803d500ced865c8c89bf186b (diff)
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 <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'api/grpc_server.go')
-rw-r--r--api/grpc_server.go34
1 files changed, 19 insertions, 15 deletions
diff --git a/api/grpc_server.go b/api/grpc_server.go
index 1d8cca6a..54fd01ec 100644
--- a/api/grpc_server.go
+++ b/api/grpc_server.go
@@ -874,21 +874,7 @@ func (s *Server) GetRoa(ctx context.Context, arg *GetRoaRequest) (*GetRoaRespons
if err != nil {
return nil, err
}
- l := make([]*Roa, 0, len(roas))
- for _, r := range roas {
- host, port, _ := net.SplitHostPort(r.Src)
- l = append(l, &Roa{
- As: r.AS,
- Maxlen: uint32(r.MaxLen),
- Prefixlen: uint32(r.Prefix.Length),
- Prefix: r.Prefix.Prefix.String(),
- Conf: &RPKIConf{
- Address: host,
- RemotePort: port,
- },
- })
- }
- return &GetRoaResponse{Roas: l}, nil
+ return &GetRoaResponse{Roas: NewRoaListFromTableStructList(roas)}, nil
}
func (s *Server) EnableZebra(ctx context.Context, arg *EnableZebraRequest) (*EnableZebraResponse, error) {
@@ -2077,6 +2063,24 @@ func NewPolicyFromApiStruct(a *Policy) (*table.Policy, error) {
}, nil
}
+func NewRoaListFromTableStructList(origin []*table.ROA) []*Roa {
+ l := make([]*Roa, 0)
+ for _, r := range origin {
+ host, port, _ := net.SplitHostPort(r.Src)
+ l = append(l, &Roa{
+ As: r.AS,
+ Maxlen: uint32(r.MaxLen),
+ Prefixlen: uint32(r.Prefix.Length),
+ Prefix: r.Prefix.Prefix.String(),
+ Conf: &RPKIConf{
+ Address: host,
+ RemotePort: port,
+ },
+ })
+ }
+ return l
+}
+
func (s *Server) GetPolicy(ctx context.Context, arg *GetPolicyRequest) (*GetPolicyResponse, error) {
l := make([]*Policy, 0)
for _, p := range s.bgpServer.GetPolicy() {