summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-01-18 06:48:23 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-01-18 06:48:23 -0800
commite45dbfaa9301230c0bee7622d175dfbda4369069 (patch)
treebd1c14bae6247cd2c52bd20a4df6f1821064315f
parent70fae5c8cc6c8f9e96f2b0f143a71cca551725bc (diff)
gobgp: improve rpki monitor output
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--gobgp/cmd/monitor.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/gobgp/cmd/monitor.go b/gobgp/cmd/monitor.go
index 19b720c2..3f01a089 100644
--- a/gobgp/cmd/monitor.go
+++ b/gobgp/cmd/monitor.go
@@ -23,7 +23,10 @@ import (
"github.com/spf13/cobra"
"golang.org/x/net/context"
"io"
+ "net"
"os"
+ "strconv"
+ "time"
)
func NewMonitorCmd() *cobra.Command {
@@ -131,7 +134,27 @@ func NewMonitorCmd() *cobra.Command {
j, _ := json.Marshal(s)
fmt.Println(string(j))
} else {
- fmt.Println("validation:", s)
+ reason := "Update"
+ if s.Reason == gobgpapi.ROAResult_WITHDRAW {
+ reason = "Withdraw"
+ } else if s.Reason == gobgpapi.ROAResult_PEER_DOWN {
+ reason = "PeerDown"
+ }
+ aspath := &bgp.PathAttributeAsPath{}
+ aspath.DecodeFromBytes(s.AspathAttr)
+ fmt.Printf("[VALIDATION] Reason: %s, Peer: %s, Timestamp: %s, Prefix:%s, OriginAS:%d, ASPath:%s, Old:%s, New:%s", reason, s.Address, time.Unix(s.Timestamp, 0).String(), s.Prefix, s.OriginAs, aspath.String(), s.OldResult, s.NewResult)
+ if len(s.Roas) == 0 {
+ fmt.Printf("\n")
+ } else {
+ fmt.Printf(", ROAs:")
+ for i, roa := range s.Roas {
+ if i != 0 {
+ fmt.Printf(",")
+ }
+ fmt.Printf(" [Source: %s, AS: %v, Prefix: %s, Prefixlen: %v, Maxlen: %v]", net.JoinHostPort(roa.Conf.Address, strconv.Itoa(int(roa.Conf.RemotePort))), roa.As, roa.Prefix, roa.Prefixlen, roa.Maxlen)
+ }
+ fmt.Printf("\n")
+ }
}
}
},