summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-06-28 10:44:07 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-06-28 10:44:07 +0900
commit6f644ee1ca1be81e6ec96c8504e34c26b3d1f8a8 (patch)
tree099d576dfdff67fc1d6c6f64fb6a4ccdfd6ae8ed
parent35bb5694a9be788c651119f5913c6fef2d08c5c2 (diff)
fsm: do two-bytes AS translation if didn't sent 4byte cap
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--server/fsm.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/server/fsm.go b/server/fsm.go
index e80c6512..401570cd 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -122,6 +122,7 @@ type FSM struct {
peerInfo *table.PeerInfo
policy *table.RoutingPolicy
gracefulRestartTimer *time.Timer
+ twoByteAsTrans bool
version uint
}
@@ -216,6 +217,22 @@ func (fsm *FSM) StateChange(nextState bgp.FSMState) {
case bgp.BGP_FSM_ESTABLISHED:
fsm.pConf.Timers.State.Uptime = time.Now().Unix()
fsm.pConf.State.EstablishedCount++
+ if _, y := fsm.capMap[bgp.BGP_CAP_FOUR_OCTET_AS_NUMBER]; !y {
+ fsm.twoByteAsTrans = true
+ break
+ }
+ y := func() bool {
+ for _, c := range capabilitiesFromConfig(fsm.pConf) {
+ switch c.(type) {
+ case *bgp.CapFourOctetASNumber:
+ return true
+ }
+ }
+ return false
+ }()
+ if !y {
+ fsm.twoByteAsTrans = true
+ }
case bgp.BGP_FSM_ACTIVE:
if !fsm.pConf.Transport.Config.PassiveMode {
fsm.getActiveCh <- struct{}{}
@@ -1006,7 +1023,7 @@ func (h *FSMHandler) sendMessageloop() error {
fsm := h.fsm
ticker := keepaliveTicker(fsm)
send := func(m *bgp.BGPMessage) error {
- if _, y := fsm.capMap[bgp.BGP_CAP_FOUR_OCTET_AS_NUMBER]; !y && m.Header.Type == bgp.BGP_MSG_UPDATE {
+ if fsm.twoByteAsTrans && m.Header.Type == bgp.BGP_MSG_UPDATE {
log.WithFields(log.Fields{
"Topic": "Peer",
"Key": fsm.pConf.Config.NeighborAddress,