summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-09-05 22:16:43 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-09-05 22:19:42 +0900
commit50d96889e8668387b95bde12e7dacf017550f438 (patch)
tree0f9903ce346dd43bb5dcdd727c58d27715d1efc4 /server
parentc1229339972cc11d444acb9acadfe23e43ae00d7 (diff)
server: support ransport.TransportConfig.LocalAddress for passive connect
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/server.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/server/server.go b/server/server.go
index eb9bcee9..298505f5 100644
--- a/server/server.go
+++ b/server/server.go
@@ -239,6 +239,32 @@ func (server *BgpServer) Serve() {
remoteAddr, _, _ := net.SplitHostPort(conn.RemoteAddr().String())
peer, found := server.neighborMap[remoteAddr]
if found {
+ localAddrValid := func(laddr net.IP) bool {
+ if laddr == nil {
+ return true
+ }
+ l := conn.LocalAddr()
+ if l == nil {
+ // already closed
+ return false
+ }
+
+ host, _, _ := net.SplitHostPort(l.String())
+ if host != laddr.String() {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": remoteAddr,
+ "Configured addr": laddr.String(),
+ "Addr": host,
+ }).Info("Mismatched local address")
+ return false
+ }
+ return true
+ }(peer.conf.Transport.TransportConfig.LocalAddress)
+ if localAddrValid == false {
+ conn.Close()
+ continue
+ }
log.Debug("accepted a new passive connection from ", remoteAddr)
peer.PassConn(conn)
} else {