summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
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 {