summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-05 17:44:25 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-05 17:44:25 -0800
commitb896584828aaf7f6287842f34dc37f15c0cde1b8 (patch)
tree15ce9ca1c9b75cc0e363cb779bdbebd969551075
parent626da9416938d54ae6a3925037c13a947d365d44 (diff)
cli: improve the state of neighbor
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rwxr-xr-xcli/gobgpcli33
-rw-r--r--server/peer.go28
2 files changed, 38 insertions, 23 deletions
diff --git a/cli/gobgpcli b/cli/gobgpcli
index b1bb46aa..c973baa1 100755
--- a/cli/gobgpcli
+++ b/cli/gobgpcli
@@ -51,6 +51,13 @@ class Show(object):
return 1
def _neighbors(self, neighbor=None):
+ capdict = {1: "MULTIPROTOCOL",
+ 2: "ROUTE_REFRESH",
+ 4: "CARRYING_LABEL_INFO",
+ 64: "GRACEFUL_RESTART",
+ 65: "FOUR_OCTET_AS_NUMBER",
+ 70: "ENHANCED_ROUTE_REFRESH",
+ 128: "ROUTE_REFRESH_CISCO"}
r = requests.get(self.base_url + "/neighbors")
neighbors = r.json()
if self.options.debug:
@@ -60,19 +67,27 @@ class Show(object):
if neighbor is not None and neighbor != n["conf"]["remote_ip"]:
continue
print("BGP neighbor is {:s}, remote AS {:d}".format(n["conf"]["remote_ip"], n["conf"]["remote_as"]))
- print("BGP state = {:s}, up for {:s}".format(n["info"]["bgp_state"], str(timedelta(seconds=n["info"]["uptime"]))))
- print("Message statistics:")
- print(" Sent Rcvd")
- print(" Opens: {:>10d} {:>10d}".format(n["info"]["open_message_out"], n["info"]["open_message_in"]))
- print(" Notifications: {:>10d} {:>10d}".format(n["info"]["notification_out"], n["info"]["notification_in"]))
- print(" Updates: {:>10d} {:>10d}".format(n["info"]["update_message_out"], n["info"]["update_message_in"]))
- print(" Keepalives: {:>10d} {:>10d}".format(n["info"]["keepalive_message_out"], n["info"]["keepalive_message_in"]))
- print(" Route Refesh: {:>10d} {:>10d}".format(n["info"]["refresh_message_out"], n["info"]["refresh_message_in"]))
- print(" Total: {:>10d} {:>10d}".format(n["info"]["total_message_out"], n["info"]["total_message_in"]))
+ print(" BGP version 4, remote router ID {:s}".format(n["conf"]["id"]))
+ print(" BGP state = {:s}, up for {:s}".format(n["info"]["bgp_state"], str(timedelta(seconds=n["info"]["uptime"]))))
+ print(" Neighbor capabilities:")
+ for i in n["conf"]["CapList"]:
+ if i in capdict:
+ i = capdict[i]
+ print(" {:s}".format(i))
+ print(" Message statistics:")
+ print(" Sent Rcvd")
+ print(" Opens: {:>10d} {:>10d}".format(n["info"]["open_message_out"], n["info"]["open_message_in"]))
+ print(" Notifications: {:>10d} {:>10d}".format(n["info"]["notification_out"], n["info"]["notification_in"]))
+ print(" Updates: {:>10d} {:>10d}".format(n["info"]["update_message_out"], n["info"]["update_message_in"]))
+ print(" Keepalives: {:>10d} {:>10d}".format(n["info"]["keepalive_message_out"], n["info"]["keepalive_message_in"]))
+ print(" Route Refesh: {:>10d} {:>10d}".format(n["info"]["refresh_message_out"], n["info"]["refresh_message_in"]))
+ print(" Total: {:>10d} {:>10d}".format(n["info"]["total_message_out"], n["info"]["total_message_in"]))
print("")
return 0
def do_neighbors(self):
+ if len(self.args) != 1:
+ return 1
return self._neighbors()
def do_neighbor(self):
diff --git a/server/peer.go b/server/peer.go
index 516fc24e..96f6dfb3 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -293,23 +293,23 @@ func (peer *Peer) MarshalJSON() ([]byte, error) {
c := f.peerConfig
p := make(map[string]interface{})
+ capList := make([]int, 0)
+ for k, _ := range peer.capMap {
+ capList = append(capList, int(k))
+ }
p["conf"] = struct {
- RemoteIP string `json:"remote_ip"`
- Id string `json:"id"`
- //Description string `json:"description"`
- RemoteAS uint32 `json:"remote_as"`
- //LocalAddress string `json:"local_address"`
- //LocalPort int `json:"local_port"`
- CapRefresh bool `json:"cap_refresh"`
- CapEnhancedRefresh bool `json:"cap_enhanced_refresh"`
+ RemoteIP string `json:"remote_ip"`
+ Id string `json:"id"`
+ RemoteAS uint32 `json:"remote_as"`
+ CapRefresh bool `json:"cap_refresh"`
+ CapEnhancedRefresh bool `json:"cap_enhanced_refresh"`
+ CapList []int
}{
- RemoteIP: c.NeighborAddress.String(),
- Id: peer.peerInfo.ID.To4().String(),
- //Description: "",
- RemoteAS: c.PeerAs,
- //LocalAddress: f.passiveConn.LocalAddr().String(),
- //LocalPort: f.passiveConn.LocalAddr().(*net.TCPAddr).Port,
+ RemoteIP: c.NeighborAddress.String(),
+ Id: peer.peerInfo.ID.To4().String(),
+ RemoteAS: c.PeerAs,
+ CapList: capList,
CapRefresh: false,
CapEnhancedRefresh: false,
}