diff options
author | Vincent Bernat <vincent@bernat.im> | 2018-06-10 18:57:51 +0200 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-06-11 11:34:33 +0900 |
commit | ea91729196a0e911988a6ba53cbccb21e9e6d11e (patch) | |
tree | f71e51eba0eb59edb846586f18de16d19139483f | |
parent | c877bb7066911c0638dbd8556463ecb11387bbd1 (diff) |
cmd: don't display uptime for a BGP session if no uptime information
Otherwise, we get something like this:
BGP neighbor is 2001:db8:4::2, remote AS 65000
BGP version 4, remote router ID unknown
BGP state = active, up for 17692d 16:53:12
-rw-r--r-- | gobgp/cmd/neighbor.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gobgp/cmd/neighbor.go b/gobgp/cmd/neighbor.go index 797f75d3..3769ca05 100644 --- a/gobgp/cmd/neighbor.go +++ b/gobgp/cmd/neighbor.go @@ -196,7 +196,12 @@ func showNeighbor(args []string) error { id = p.State.RemoteRouterId } fmt.Printf(" BGP version 4, remote router ID %s\n", id) - fmt.Printf(" BGP state = %s, up for %s\n", p.State.SessionState, formatTimedelta(int64(p.Timers.State.Uptime)-time.Now().Unix())) + fmt.Printf(" BGP state = %s", p.State.SessionState) + if p.Timers.State.Uptime > 0 { + fmt.Printf(", up for %s\n", formatTimedelta(int64(p.Timers.State.Uptime)-time.Now().Unix())) + } else { + fmt.Print("\n") + } fmt.Printf(" BGP OutQ = %d, Flops = %d\n", p.State.Queues.Output, p.State.Flops) fmt.Printf(" Hold time is %d, keepalive interval is %d seconds\n", int(p.Timers.State.NegotiatedHoldTime), int(p.Timers.State.KeepaliveInterval)) fmt.Printf(" Configured hold time is %d, keepalive interval is %d seconds\n", int(p.Timers.Config.HoldTime), int(p.Timers.Config.KeepaliveInterval)) |