summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-14 10:47:32 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-14 10:47:32 +0900
commitdb0e46824ad9523a7cea43e7e847a29f72df71ec (patch)
tree44c2ae970b03b086006eeda2dfe4196ff5f4510d
parentcc7ff372950afdcc1c9dbf39dcd13a15830410e2 (diff)
server: close the connection after sending notification
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--packet/bgp.go6
-rw-r--r--server/fsm.go15
2 files changed, 16 insertions, 5 deletions
diff --git a/packet/bgp.go b/packet/bgp.go
index 9df7812d..819169c9 100644
--- a/packet/bgp.go
+++ b/packet/bgp.go
@@ -2983,7 +2983,7 @@ type MessageError struct {
TypeCode uint8
SubTypeCode uint8
Data []byte
- message string
+ Message string
}
func NewMessageError(typeCode, subTypeCode uint8, data []byte, msg string) error {
@@ -2991,10 +2991,10 @@ func NewMessageError(typeCode, subTypeCode uint8, data []byte, msg string) error
TypeCode: typeCode,
SubTypeCode: subTypeCode,
Data: data,
- message: msg,
+ Message: msg,
}
}
func (e *MessageError) Error() string {
- return e.message
+ return e.Message
}
diff --git a/server/fsm.go b/server/fsm.go
index 06870f1b..5846410e 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -217,6 +217,11 @@ func (h *FSMHandler) recvMessageWithError() error {
m, err := bgp.ParseBGPBody(hd, bodyBuf)
if err != nil {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": h.fsm.peerConfig.NeighborAddress,
+ "error": err,
+ }).Warn("malformed BGP message")
h.errorCh <- true
return err
}
@@ -249,7 +254,7 @@ func (h *FSMHandler) opensent() bgp.FSMState {
nextState := bgp.BGP_FSM_IDLE
select {
case <-h.t.Dying():
- fsm.passiveConn.Close()
+ h.conn.Close()
return 0
case e := <-h.msgCh:
m := e.MsgData.(*bgp.BGPMessage)
@@ -268,6 +273,7 @@ func (h *FSMHandler) opensent() bgp.FSMState {
// send error
}
case <-h.errorCh:
+ h.conn.Close()
}
return nextState
}
@@ -285,7 +291,7 @@ func (h *FSMHandler) openconfirm() bgp.FSMState {
for {
select {
case <-h.t.Dying():
- fsm.passiveConn.Close()
+ h.conn.Close()
return 0
case <-fsm.keepaliveTicker.C:
m := bgp.NewBGPKeepAliveMessage()
@@ -303,6 +309,7 @@ func (h *FSMHandler) openconfirm() bgp.FSMState {
}
return nextState
case <-h.errorCh:
+ h.conn.Close()
return bgp.BGP_FSM_IDLE
}
}
@@ -330,6 +337,10 @@ func (h *FSMHandler) sendMessageloop() error {
"data": m,
}).Debug("sent")
fsm.bgpMessageStateUpdate(m.Header.Type, false)
+ if m.Header.Type == bgp.BGP_MSG_NOTIFICATION {
+ conn.Close()
+ return nil
+ }
case <-fsm.keepaliveTicker.C:
m := bgp.NewBGPKeepAliveMessage()
b, _ := m.Serialize()