summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-12-10 11:51:47 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-12-10 11:51:47 +0900
commit71588f6a1aacb996a8a6b4295a7f9a33717c6455 (patch)
tree878485e8210766dde2e6fe096495441baa753dbc /server
parente92a04c9a880e81fdec116f837c5384cd79e0fcd (diff)
rpki: show ROA with server information
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/rpki.go52
1 files changed, 33 insertions, 19 deletions
diff --git a/server/rpki.go b/server/rpki.go
index e7775b2c..e4350f6e 100644
--- a/server/rpki.go
+++ b/server/rpki.go
@@ -145,32 +145,46 @@ func (c *roaClient) handleGRPC(grpcReq *GrpcRequest) {
go sendMultipleResponses(grpcReq, results)
case REQ_ROA:
- if len(c.config.RpkiServerList) == 0 || c.config.RpkiServerList[0].RpkiServerConfig.Address.String() != grpcReq.Name {
+ if len(c.config.RpkiServerList) == 0 {
result := &GrpcResponse{}
- result.ResponseErr = fmt.Errorf("RPKI server that has %v doesn't exist.", grpcReq.Name)
-
+ result.ResponseErr = fmt.Errorf("RPKI server isn't configured.")
grpcReq.ResponseCh <- result
break
}
-
+ conf := c.config.RpkiServerList[0].RpkiServerConfig
results := make([]*GrpcResponse, 0)
- if tree, ok := c.roas[grpcReq.RouteFamily]; ok {
- tree.Walk(func(s string, v interface{}) bool {
- b, _ := v.(*roaBucket)
- for _, r := range b.entries {
- for _, as := range r.AS {
- result := &GrpcResponse{}
- result.Data = &api.ROA{
- As: as,
- Maxlen: uint32(r.MaxLen),
- Prefixlen: uint32(b.PrefixLen),
- Prefix: b.Prefix.String(),
+ var rfList []bgp.RouteFamily
+ switch grpcReq.RouteFamily {
+ case bgp.RF_IPv4_UC:
+ rfList = []bgp.RouteFamily{bgp.RF_IPv4_UC}
+ case bgp.RF_IPv6_UC:
+ rfList = []bgp.RouteFamily{bgp.RF_IPv6_UC}
+ default:
+ rfList = []bgp.RouteFamily{bgp.RF_IPv4_UC, bgp.RF_IPv6_UC}
+ }
+ for _, rf := range rfList {
+ if tree, ok := c.roas[rf]; ok {
+ tree.Walk(func(s string, v interface{}) bool {
+ b, _ := v.(*roaBucket)
+ for _, r := range b.entries {
+ for _, as := range r.AS {
+ result := &GrpcResponse{}
+ result.Data = &api.ROA{
+ As: as,
+ Maxlen: uint32(r.MaxLen),
+ Prefixlen: uint32(b.PrefixLen),
+ Prefix: b.Prefix.String(),
+ Conf: &api.RPKIConf{
+ Address: conf.Address.String(),
+ RemotePort: conf.Port,
+ },
+ }
+ results = append(results, result)
}
- results = append(results, result)
}
- }
- return false
- })
+ return false
+ })
+ }
}
go sendMultipleResponses(grpcReq, results)
}