diff options
author | Satoshi Fujimoto <satoshi.fujimoto7@gmail.com> | 2017-06-20 10:54:35 +0900 |
---|---|---|
committer | Satoshi Fujimoto <satoshi.fujimoto7@gmail.com> | 2017-06-20 11:24:05 +0900 |
commit | 1c7829604d492dde7d9cdd491a77fe3d70797691 (patch) | |
tree | 78e38c269fccf0668faa7a34f0100f679c6be654 /server | |
parent | d75edf18d7febd3f687393e8b0707e57438931eb (diff) |
peer: Check errors in creating Dynamic Peers
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'server')
-rw-r--r-- | server/peer.go | 16 | ||||
-rw-r--r-- | server/server.go | 8 |
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) |