summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gobgp/neighbor.go11
-rw-r--r--server/peer.go15
2 files changed, 20 insertions, 6 deletions
diff --git a/gobgp/neighbor.go b/gobgp/neighbor.go
index ad82e312..ad700311 100644
--- a/gobgp/neighbor.go
+++ b/gobgp/neighbor.go
@@ -186,6 +186,8 @@ func showNeighbor(args []string) error {
sort.Sort(caps)
+ firstMp := true
+
for _, c := range caps {
support := ""
if m := lookup(c, p.Conf.LocalCap); m != nil {
@@ -199,9 +201,14 @@ func showNeighbor(args []string) error {
}
if c.Code != api.BGP_CAPABILITY_MULTIPROTOCOL {
- fmt.Printf(" %s: %s\n", c.Code, support)
+ fmt.Printf(" %s:\t%s\n", c.Code, support)
} else {
- fmt.Printf(" %s(%s): %s\n", c.Code, c.MultiProtocol, support)
+ if firstMp {
+ fmt.Printf(" %s:\n", c.Code)
+ firstMp = false
+ }
+ fmt.Printf(" %s:\t%s\n", bgp.RouteFamily(c.MultiProtocol), support)
+
}
}
fmt.Print(" Message statistics:\n")
diff --git a/server/peer.go b/server/peer.go
index 0d7e2369..43a9d32a 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -37,7 +37,7 @@ type Peer struct {
conf config.Neighbor
fsm *FSM
rfMap map[bgp.RouteFamily]bool
- capMap map[bgp.BGPCapabilityCode]bgp.ParameterCapabilityInterface
+ capMap map[bgp.BGPCapabilityCode][]bgp.ParameterCapabilityInterface
adjRib *table.AdjRib
peerInfo *table.PeerInfo
outgoing chan *bgp.BGPMessage
@@ -52,7 +52,7 @@ func NewPeer(g config.Global, conf config.Neighbor) *Peer {
gConf: g,
conf: conf,
rfMap: make(map[bgp.RouteFamily]bool),
- capMap: make(map[bgp.BGPCapabilityCode]bgp.ParameterCapabilityInterface),
+ capMap: make(map[bgp.BGPCapabilityCode][]bgp.ParameterCapabilityInterface),
}
conf.NeighborState.SessionState = uint32(bgp.BGP_FSM_IDLE)
@@ -113,7 +113,12 @@ func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) ([]*table.Path, bool, []*b
for _, p := range body.OptParams {
if paramCap, y := p.(*bgp.OptionParameterCapability); y {
for _, c := range paramCap.Capability {
- peer.capMap[c.Code()] = c
+ m, ok := peer.capMap[c.Code()]
+ if !ok {
+ m = make([]bgp.ParameterCapabilityInterface, 0, 1)
+ }
+ peer.capMap[c.Code()] = append(m, c)
+
if c.Code() == bgp.BGP_CAP_MULTIPROTOCOL {
m := c.(*bgp.CapMultiProtocol)
r[bgp.AfiSafiToRouteFamily(m.CapValue.AFI, m.CapValue.SAFI)] = true
@@ -234,7 +239,9 @@ func (peer *Peer) ToApiStruct() *api.Peer {
remoteCap := make([]*api.Capability, 0, len(peer.capMap))
for _, c := range peer.capMap {
- remoteCap = append(remoteCap, c.ToApiStruct())
+ for _, m := range c {
+ remoteCap = append(remoteCap, m.ToApiStruct())
+ }
}
caps := capabilitiesFromConfig(&peer.gConf, &peer.conf)