summaryrefslogtreecommitdiffhomepage
path: root/server/fsm.go
diff options
context:
space:
mode:
authorYi Tseng <a86487817@gmail.com>2016-04-10 17:34:38 +0800
committerYi Tseng <a86487817@gmail.com>2016-04-11 15:57:39 +0800
commit85d038d209ec5c11e72f4b04d681e76ad8fd661f (patch)
tree9cd8e5a2343c217e92e42d78c813e64d26a208c3 /server/fsm.go
parent6d401bedf5a947444a66daf5312719f6dba8b381 (diff)
Add neighbor-port-number to bgp neighbor config
Allow user to setup neighbor BGP TCP port (Default is 179)
Diffstat (limited to 'server/fsm.go')
-rw-r--r--server/fsm.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/server/fsm.go b/server/fsm.go
index 01587668..487e80c3 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -300,7 +300,11 @@ func (fsm *FSM) connectLoop() error {
connect := func() {
if fsm.state == bgp.BGP_FSM_ACTIVE && !fsm.pConf.GracefulRestart.State.PeerRestarting {
addr := fsm.pConf.Config.NeighborAddress
- host := net.JoinHostPort(addr, strconv.Itoa(bgp.BGP_PORT))
+ port := int(bgp.BGP_PORT)
+ if fsm.pConf.Config.NeighborPortNumber != 0 {
+ port = int(fsm.pConf.Config.NeighborPortNumber)
+ }
+ host := net.JoinHostPort(addr, strconv.Itoa(port))
// check if LocalAddress has been configured
laddr := fsm.pConf.Transport.Config.LocalAddress
var conn net.Conn
@@ -308,7 +312,7 @@ func (fsm *FSM) connectLoop() error {
if laddr != "" {
if fsm.pConf.Config.AuthPassword != "" {
deadline := (MIN_CONNECT_RETRY - 1) * 1000 // msec
- conn, err = DialTCPTimeoutWithMD5Sig(addr, bgp.BGP_PORT, laddr, fsm.pConf.Config.AuthPassword, deadline)
+ conn, err = DialTCPTimeoutWithMD5Sig(addr, port, laddr, fsm.pConf.Config.AuthPassword, deadline)
} else {
lhost := net.JoinHostPort(laddr, "0")
ltcpaddr, e := net.ResolveTCPAddr("tcp", lhost)
@@ -325,7 +329,7 @@ func (fsm *FSM) connectLoop() error {
} else {
if fsm.pConf.Config.AuthPassword != "" {
deadline := (MIN_CONNECT_RETRY - 1) * 1000 // msec
- conn, err = DialTCPTimeoutWithMD5Sig(addr, bgp.BGP_PORT, "0.0.0.0", fsm.pConf.Config.AuthPassword, deadline)
+ conn, err = DialTCPTimeoutWithMD5Sig(addr, port, "0.0.0.0", fsm.pConf.Config.AuthPassword, deadline)
} else {
conn, err = net.DialTimeout("tcp", host, time.Duration(MIN_CONNECT_RETRY-1)*time.Second)
}