summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/peer.go16
-rw-r--r--server/server.go8
2 files changed, 22 insertions, 2 deletions
diff --git a/server/peer.go b/server/peer.go
index a1ec2404..00785cd2 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -68,8 +68,20 @@ func newDynamicPeer(g *config.Global, neighborAddress string, pg *config.PeerGro
},
},
}
- config.OverwriteNeighborConfigWithPeerGroup(&conf, pg)
- config.SetDefaultNeighborConfigValues(&conf, g.Config.As)
+ if err := config.OverwriteNeighborConfigWithPeerGroup(&conf, pg); err != nil {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": neighborAddress,
+ }).Debugf("Can't overwrite neighbor config: %s", err)
+ return nil
+ }
+ if err := config.SetDefaultNeighborConfigValues(&conf, g.Config.As); err != nil {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": neighborAddress,
+ }).Debugf("Can't set default config: %s", err)
+ return nil
+ }
conf.State.NeighborAddress = neighborAddress
peer := NewPeer(g, &conf, loc, policy)
peer.fsm.state = bgp.BGP_FSM_ACTIVE
diff --git a/server/server.go b/server/server.go
index d1b0b0ff..1ecbedf0 100644
--- a/server/server.go
+++ b/server/server.go
@@ -241,6 +241,14 @@ func (server *BgpServer) Serve() {
"Topic": "Peer",
}).Debugf("Accepted a new dynamic neighbor from:%s", remoteAddr)
peer := newDynamicPeer(&server.bgpConfig.Global, remoteAddr, pg.Conf, server.globalRib, server.policy)
+ if peer == nil {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": remoteAddr,
+ }).Infof("Can't create new Dynamic Peer")
+ conn.Close()
+ return
+ }
server.policy.Reset(nil, map[string]config.ApplyPolicy{peer.ID(): peer.fsm.pConf.ApplyPolicy})
server.neighborMap[remoteAddr] = peer
peer.startFSMHandler(server.fsmincomingCh, server.fsmStateCh)