summaryrefslogtreecommitdiffhomepage
path: root/server/fsm.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-08-03 04:27:33 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-04-04 22:07:46 +0900
commitbba54bdaa14c1a4c13245548757b38a89531fd9b (patch)
treeee8b87c207dc489d64f0a6e55c2bca0ede3f20bf /server/fsm.go
parent00f8406cb6a207341ea4f68a8fa294f31eb7bc7b (diff)
skip asn negotiation for BGP unnumbered peers
since BGP unnumbered peers are typically trusted, skip asn negotiation for easy configuration. from configuration file: ```toml [[neighbors]] [[neighbors.config]] neighbor-interface = "eth0" ``` from cli: ``` $ gobgp neighbor add interface eth0 ``` Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/fsm.go')
-rw-r--r--server/fsm.go24
1 files changed, 21 insertions, 3 deletions
diff --git a/server/fsm.go b/server/fsm.go
index e680f8ec..f623f399 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -474,9 +474,9 @@ func (h *FSMHandler) active() (bgp.FSMState, FsmStateReason) {
break
}
fsm.conn = conn
- if fsm.pConf.Config.PeerType == config.PEER_TYPE_EXTERNAL {
+ if fsm.pConf.Config.PeerAs != 0 && fsm.pConf.Config.PeerType == config.PEER_TYPE_EXTERNAL {
ttl := 1
- if fsm.pConf.EbgpMultihop.Config.Enabled == true {
+ if fsm.pConf.EbgpMultihop.Config.Enabled {
ttl = int(fsm.pConf.EbgpMultihop.Config.MultihopTtl)
}
if ttl != 0 {
@@ -844,11 +844,29 @@ func (h *FSMHandler) opensent() (bgp.FSMState, FsmStateReason) {
if m.Header.Type == bgp.BGP_MSG_OPEN {
fsm.recvOpen = m
body := m.Body.(*bgp.BGPOpen)
- err := bgp.ValidateOpenMsg(body, fsm.pConf.Config.PeerAs)
+ peerAs, err := bgp.ValidateOpenMsg(body, fsm.pConf.Config.PeerAs)
if err != nil {
fsm.sendNotificationFromErrorMsg(err.(*bgp.MessageError))
return bgp.BGP_FSM_IDLE, FSM_INVALID_MSG
}
+
+ // ASN negotiation was skipped
+ if fsm.pConf.Config.PeerAs == 0 {
+ typ := config.PEER_TYPE_EXTERNAL
+ if fsm.peerInfo.LocalAS == peerAs {
+ typ = config.PEER_TYPE_INTERNAL
+ }
+ fsm.pConf.State.PeerType = typ
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": fsm.pConf.Config.NeighborAddress,
+ "State": fsm.state.String(),
+ }).Infof("skiped asn negotiation: peer-as: %d, peer-type: %s", peerAs, typ)
+ } else {
+ fsm.pConf.State.PeerType = fsm.pConf.Config.PeerType
+ }
+ fsm.pConf.State.PeerAs = peerAs
+ fsm.peerInfo.AS = peerAs
fsm.peerInfo.ID = body.ID
fsm.capMap, fsm.rfMap = open2Cap(body, fsm.pConf)