summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/bmp.go2
-rw-r--r--server/fsm.go100
-rw-r--r--server/mrt.go4
-rw-r--r--server/peer.go12
-rw-r--r--server/server.go31
5 files changed, 81 insertions, 68 deletions
diff --git a/server/bmp.go b/server/bmp.go
index 4d76822b..1e12e372 100644
--- a/server/bmp.go
+++ b/server/bmp.go
@@ -289,7 +289,7 @@ func bmpPeerRoute(t uint8, policy bool, pd uint64, peeri *table.PeerInfo, timest
func bmpPeerStats(peerType uint8, peerDist uint64, timestamp int64, neighConf *config.Neighbor) *bmp.BMPMessage {
var peerFlags uint8 = 0
- ph := bmp.NewBMPPeerHeader(peerType, peerFlags, peerDist, neighConf.Config.NeighborAddress, neighConf.State.PeerAs, neighConf.State.RemoteRouterId, float64(timestamp))
+ ph := bmp.NewBMPPeerHeader(peerType, peerFlags, peerDist, neighConf.State.NeighborAddress, neighConf.State.PeerAs, neighConf.State.RemoteRouterId, float64(timestamp))
return bmp.NewBMPStatisticsReport(
*ph,
[]bmp.BMPStatsTLVInterface{
diff --git a/server/fsm.go b/server/fsm.go
index 3817bd23..2c01c14d 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -227,7 +227,7 @@ func NewFSM(gConf *config.Global, pConf *config.Neighbor, policy *table.RoutingP
func (fsm *FSM) StateChange(nextState bgp.FSMState) {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"old": fsm.state.String(),
"new": nextState.String(),
"reason": fsm.reason,
@@ -298,12 +298,12 @@ func (fsm *FSM) sendNotificationFromErrorMsg(e *bgp.MessageError) error {
fsm.h.conn.Close()
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"Data": e,
}).Warn("sent notification")
return nil
}
- return fmt.Errorf("can't send notification to %s since TCP connection is not established", fsm.pConf.Config.NeighborAddress)
+ return fmt.Errorf("can't send notification to %s since TCP connection is not established", fsm.pConf.State.NeighborAddress)
}
func (fsm *FSM) sendNotification(code, subType uint8, data []byte, msg string) error {
@@ -323,7 +323,7 @@ func (fsm *FSM) connectLoop() error {
timer.Stop()
connect := func() {
- addr := fsm.pConf.Config.NeighborAddress
+ addr := fsm.pConf.State.NeighborAddress
port := int(bgp.BGP_PORT)
if fsm.pConf.Transport.Config.RemotePort != 0 {
port = int(fsm.pConf.Transport.Config.RemotePort)
@@ -342,7 +342,7 @@ func (fsm *FSM) connectLoop() error {
if e != nil {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
}).Warnf("failed to resolve ltcpaddr: %s", e)
return
}
@@ -358,13 +358,13 @@ func (fsm *FSM) connectLoop() error {
conn.Close()
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
}).Warn("active conn is closed to avoid being blocked")
}
} else {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
}).Debugf("failed to connect: %s", err)
}
@@ -378,7 +378,7 @@ func (fsm *FSM) connectLoop() error {
case <-fsm.t.Dying():
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
}).Debug("stop connect loop")
return nil
case <-timer.C:
@@ -429,7 +429,7 @@ func (h *FSMHandler) idle() (bgp.FSMState, FsmStateReason) {
if fsm.pConf.GracefulRestart.State.PeerRestarting {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Warn("graceful restart timer expired")
return bgp.BGP_FSM_IDLE, FSM_RESTART_TIMER_EXPIRED
@@ -441,7 +441,7 @@ func (h *FSMHandler) idle() (bgp.FSMState, FsmStateReason) {
conn.Close()
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Warn("Closed an accepted connection")
case <-idleHoldTimer.C:
@@ -449,7 +449,7 @@ func (h *FSMHandler) idle() (bgp.FSMState, FsmStateReason) {
if fsm.adminState == ADMIN_STATE_UP {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"Duration": fsm.idleHoldTime,
}).Debug("IdleHoldTimer expired")
fsm.idleHoldTime = HOLDTIME_IDLE
@@ -503,7 +503,7 @@ func (h *FSMHandler) active() (bgp.FSMState, FsmStateReason) {
if fsm.pConf.GracefulRestart.State.PeerRestarting {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Warn("graceful restart timer expired")
return bgp.BGP_FSM_IDLE, FSM_RESTART_TIMER_EXPIRED
@@ -519,7 +519,7 @@ func (h *FSMHandler) active() (bgp.FSMState, FsmStateReason) {
case ADMIN_STATE_UP:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
"AdminState": stateOp.State.String(),
}).Panic("code logic bug")
@@ -658,13 +658,13 @@ func (h *FSMHandler) recvMessageWithError() (*FsmMsg, error) {
h.fsm.bgpMessageStateUpdate(0, true)
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": h.fsm.pConf.Config.NeighborAddress,
+ "Key": h.fsm.pConf.State.NeighborAddress,
"State": h.fsm.state.String(),
"error": err,
}).Warn("malformed BGP Header")
fmsg := &FsmMsg{
MsgType: FSM_MSG_BGP_MESSAGE,
- MsgSrc: h.fsm.pConf.Config.NeighborAddress,
+ MsgSrc: h.fsm.pConf.State.NeighborAddress,
MsgData: err,
Version: h.fsm.version,
}
@@ -687,14 +687,14 @@ func (h *FSMHandler) recvMessageWithError() (*FsmMsg, error) {
}
fmsg := &FsmMsg{
MsgType: FSM_MSG_BGP_MESSAGE,
- MsgSrc: h.fsm.pConf.Config.NeighborAddress,
+ MsgSrc: h.fsm.pConf.State.NeighborAddress,
timestamp: now,
Version: h.fsm.version,
}
if err != nil {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": h.fsm.pConf.Config.NeighborAddress,
+ "Key": h.fsm.pConf.State.NeighborAddress,
"State": h.fsm.state.String(),
"error": err,
}).Warn("malformed BGP message")
@@ -717,7 +717,7 @@ func (h *FSMHandler) recvMessageWithError() (*FsmMsg, error) {
if err != nil {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": h.fsm.pConf.Config.NeighborAddress,
+ "Key": h.fsm.pConf.State.NeighborAddress,
"State": h.fsm.state.String(),
"error": err,
}).Warn("malformed BGP update message")
@@ -752,7 +752,7 @@ func (h *FSMHandler) recvMessageWithError() (*FsmMsg, error) {
}
fmsg.PathList = table.ProcessMessage(m, h.fsm.peerInfo, fmsg.timestamp)
- id := h.fsm.pConf.Config.NeighborAddress
+ id := h.fsm.pConf.State.NeighborAddress
for _, path := range fmsg.PathList {
if path.IsEOR() {
continue
@@ -779,7 +779,7 @@ func (h *FSMHandler) recvMessageWithError() (*FsmMsg, error) {
communication, rest := decodeAdministrativeCommunication(body.Data)
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": h.fsm.pConf.Config.NeighborAddress,
+ "Key": h.fsm.pConf.State.NeighborAddress,
"Code": body.ErrorCode,
"Subcode": body.ErrorSubcode,
"Communicated-Reason": communication,
@@ -788,7 +788,7 @@ func (h *FSMHandler) recvMessageWithError() (*FsmMsg, error) {
} else {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": h.fsm.pConf.Config.NeighborAddress,
+ "Key": h.fsm.pConf.State.NeighborAddress,
"Code": body.ErrorCode,
"Subcode": body.ErrorSubcode,
"Data": body.Data,
@@ -880,14 +880,14 @@ func (h *FSMHandler) opensent() (bgp.FSMState, FsmStateReason) {
conn.Close()
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Warn("Closed an accepted connection")
case <-fsm.gracefulRestartTimer.C:
if fsm.pConf.GracefulRestart.State.PeerRestarting {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Warn("graceful restart timer expired")
h.conn.Close()
@@ -919,7 +919,7 @@ func (h *FSMHandler) opensent() (bgp.FSMState, FsmStateReason) {
fsm.pConf.State.PeerType = typ
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Infof("skiped asn negotiation: peer-as: %d, peer-type: %s", peerAs, typ)
} else {
@@ -974,7 +974,7 @@ func (h *FSMHandler) opensent() (bgp.FSMState, FsmStateReason) {
if fsm.pConf.GracefulRestart.State.PeerRestarting && cap.Flags&0x08 == 0 {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Warn("restart flag is not set")
// send notification?
@@ -1018,7 +1018,7 @@ func (h *FSMHandler) opensent() (bgp.FSMState, FsmStateReason) {
default:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
"Data": e.MsgData,
}).Panic("unknown msg type")
@@ -1040,7 +1040,7 @@ func (h *FSMHandler) opensent() (bgp.FSMState, FsmStateReason) {
case ADMIN_STATE_UP:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
"AdminState": stateOp.State.String(),
}).Panic("code logic bug")
@@ -1091,14 +1091,14 @@ func (h *FSMHandler) openconfirm() (bgp.FSMState, FsmStateReason) {
conn.Close()
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Warn("Closed an accepted connection")
case <-fsm.gracefulRestartTimer.C:
if fsm.pConf.GracefulRestart.State.PeerRestarting {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Warn("graceful restart timer expired")
h.conn.Close()
@@ -1130,7 +1130,7 @@ func (h *FSMHandler) openconfirm() (bgp.FSMState, FsmStateReason) {
default:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
"Data": e.MsgData,
}).Panic("unknown msg type")
@@ -1152,7 +1152,7 @@ func (h *FSMHandler) openconfirm() (bgp.FSMState, FsmStateReason) {
case ADMIN_STATE_UP:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
"AdminState": stateOp.State.String(),
}).Panic("code logic bug")
@@ -1170,7 +1170,7 @@ func (h *FSMHandler) sendMessageloop() error {
if fsm.twoByteAsTrans && m.Header.Type == bgp.BGP_MSG_UPDATE {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
"Data": m,
}).Debug("update for 2byte AS peer")
@@ -1181,7 +1181,7 @@ func (h *FSMHandler) sendMessageloop() error {
if err != nil {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
"Data": err,
}).Warn("failed to serialize")
@@ -1197,7 +1197,7 @@ func (h *FSMHandler) sendMessageloop() error {
if err != nil {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
"Data": err,
}).Warn("failed to send")
@@ -1214,7 +1214,7 @@ func (h *FSMHandler) sendMessageloop() error {
communication, rest := decodeAdministrativeCommunication(body.Data)
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
"Code": body.ErrorCode,
"Subcode": body.ErrorSubcode,
@@ -1224,7 +1224,7 @@ func (h *FSMHandler) sendMessageloop() error {
} else {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
"Code": body.ErrorCode,
"Subcode": body.ErrorSubcode,
@@ -1238,7 +1238,7 @@ func (h *FSMHandler) sendMessageloop() error {
update := m.Body.(*bgp.BGPUpdate)
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
"nlri": update.NLRI,
"withdrawals": update.WithdrawnRoutes,
@@ -1247,7 +1247,7 @@ func (h *FSMHandler) sendMessageloop() error {
default:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
"data": m,
}).Debug("sent")
@@ -1323,7 +1323,7 @@ func (h *FSMHandler) established() (bgp.FSMState, FsmStateReason) {
conn.Close()
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Warn("Closed an accepted connection")
case err := <-h.errorCh:
@@ -1333,7 +1333,7 @@ func (h *FSMHandler) established() (bgp.FSMState, FsmStateReason) {
err = FSM_GRACEFUL_RESTART
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Info("peer graceful restart")
fsm.gracefulRestartTimer.Reset(time.Duration(fsm.pConf.GracefulRestart.State.PeerRestartTime) * time.Second)
@@ -1342,7 +1342,7 @@ func (h *FSMHandler) established() (bgp.FSMState, FsmStateReason) {
case <-holdTimer.C:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Warn("hold timer expired")
m := bgp.NewBGPNotificationMessage(bgp.BGP_ERROR_HOLD_TIMER_EXPIRED, 0, nil)
@@ -1399,7 +1399,7 @@ func (h *FSMHandler) loop() error {
if nextState == bgp.BGP_FSM_ESTABLISHED && oldState == bgp.BGP_FSM_OPENCONFIRM {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Info("Peer Up")
}
@@ -1413,14 +1413,14 @@ func (h *FSMHandler) loop() error {
}
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
"Reason": reason,
}).Info("Peer Down")
}
e := time.AfterFunc(time.Second*120, func() {
- log.WithFields(log.Fields{"Topic": "Peer"}).Fatalf("failed to free the fsm.h.t for %s %s %s", fsm.pConf.Config.NeighborAddress, oldState, nextState)
+ log.WithFields(log.Fields{"Topic": "Peer"}).Fatalf("failed to free the fsm.h.t for %s %s %s", fsm.pConf.State.NeighborAddress, oldState, nextState)
})
h.t.Wait()
e.Stop()
@@ -1429,7 +1429,7 @@ func (h *FSMHandler) loop() error {
if nextState >= bgp.BGP_FSM_IDLE {
e := &FsmMsg{
MsgType: FSM_MSG_STATE_CHANGE,
- MsgSrc: fsm.pConf.Config.NeighborAddress,
+ MsgSrc: fsm.pConf.State.NeighborAddress,
MsgData: nextState,
Version: h.fsm.version,
}
@@ -1443,7 +1443,7 @@ func (h *FSMHandler) changeAdminState(s AdminState) error {
if fsm.adminState != s {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
"AdminState": s.String(),
}).Debug("admin state changed")
@@ -1455,19 +1455,19 @@ func (h *FSMHandler) changeAdminState(s AdminState) error {
case ADMIN_STATE_UP:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Info("Administrative start")
case ADMIN_STATE_DOWN:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Info("Administrative shutdown")
case ADMIN_STATE_PFX_CT:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Info("Administrative shutdown(Prefix limit reached)")
}
@@ -1475,7 +1475,7 @@ func (h *FSMHandler) changeAdminState(s AdminState) error {
} else {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
+ "Key": fsm.pConf.State.NeighborAddress,
"State": fsm.state.String(),
}).Warn("cannot change to the same state")
diff --git a/server/mrt.go b/server/mrt.go
index f4a22658..e2cfa6fc 100644
--- a/server/mrt.go
+++ b/server/mrt.go
@@ -109,7 +109,7 @@ func (m *mrtWriter) loop() error {
t := uint32(time.Now().Unix())
peers := make([]*mrt.Peer, 0, len(m.Neighbor))
for _, pconf := range m.Neighbor {
- peers = append(peers, mrt.NewPeer(pconf.State.RemoteRouterId, pconf.Config.NeighborAddress, pconf.Config.PeerAs, true))
+ peers = append(peers, mrt.NewPeer(pconf.State.RemoteRouterId, pconf.State.NeighborAddress, pconf.Config.PeerAs, true))
}
if bm, err := mrt.NewMRTMessage(t, mrt.TABLE_DUMPv2, mrt.PEER_INDEX_TABLE, mrt.NewPeerIndexTable(m.RouterId, "", peers)); err != nil {
break
@@ -119,7 +119,7 @@ func (m *mrtWriter) loop() error {
idx := func(p *table.Path) uint16 {
for i, pconf := range m.Neighbor {
- if p.GetSource().Address.String() == pconf.Config.NeighborAddress {
+ if p.GetSource().Address.String() == pconf.State.NeighborAddress {
return uint16(i)
}
}
diff --git a/server/peer.go b/server/peer.go
index 8adc6a22..4e5b7435 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -44,11 +44,11 @@ func NewPeerGroup(c *config.PeerGroup) *PeerGroup {
}
func (pg *PeerGroup) AddMember(c config.Neighbor) {
- pg.members[c.Config.NeighborAddress] = c
+ pg.members[c.State.NeighborAddress] = c
}
func (pg *PeerGroup) DeleteMember(c config.Neighbor) {
- delete(pg.members, c.Config.NeighborAddress)
+ delete(pg.members, c.State.NeighborAddress)
}
type Peer struct {
@@ -71,7 +71,7 @@ func NewPeer(g *config.Global, conf *config.Neighbor, loc *table.TableManager, p
prefixLimitWarned: make(map[bgp.RouteFamily]bool),
}
if peer.isRouteServerClient() {
- peer.tableId = conf.Config.NeighborAddress
+ peer.tableId = conf.State.NeighborAddress
} else {
peer.tableId = table.GLOBAL_RIB_NAME
}
@@ -81,7 +81,7 @@ func NewPeer(g *config.Global, conf *config.Neighbor, loc *table.TableManager, p
}
func (peer *Peer) ID() string {
- return peer.fsm.pConf.Config.NeighborAddress
+ return peer.fsm.pConf.State.NeighborAddress
}
func (peer *Peer) TableID() string {
@@ -360,7 +360,7 @@ func (peer *Peer) processOutgoingPaths(paths, olds []*table.Path) []*table.Path
if peer.fsm.pConf.GracefulRestart.State.LocalRestarting {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.fsm.pConf.Config.NeighborAddress,
+ "Key": peer.fsm.pConf.State.NeighborAddress,
}).Debug("now syncing, suppress sending updates")
return nil
}
@@ -478,7 +478,7 @@ func (peer *Peer) handleUpdate(e *FsmMsg) ([]*table.Path, []bgp.RouteFamily, *bg
update := m.Body.(*bgp.BGPUpdate)
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.fsm.pConf.Config.NeighborAddress,
+ "Key": peer.fsm.pConf.State.NeighborAddress,
"nlri": update.NLRI,
"withdrawals": update.WithdrawnRoutes,
"attributes": update.PathAttributes,
diff --git a/server/server.go b/server/server.go
index ac2f20ef..7428d47e 100644
--- a/server/server.go
+++ b/server/server.go
@@ -801,7 +801,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) {
deferralExpiredFunc := func(family bgp.RouteFamily) func() {
return func() {
server.mgmtOperation(func() error {
- server.softResetOut(peer.fsm.pConf.Config.NeighborAddress, family, true)
+ server.softResetOut(peer.fsm.pConf.State.NeighborAddress, family, true)
return nil
}, false)
}
@@ -864,6 +864,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) {
// clear counter
if peer.fsm.adminState == ADMIN_STATE_DOWN {
peer.fsm.pConf.State = config.NeighborState{}
+ peer.fsm.pConf.State.NeighborAddress = peer.fsm.pConf.Config.NeighborAddress
peer.fsm.pConf.Timers.State = config.TimersState{}
}
peer.startFSMHandler(server.fsmincomingCh, server.fsmStateCh)
@@ -970,7 +971,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) {
pathList := peer.adjRibIn.DropStale(peer.configuredRFlist())
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.fsm.pConf.Config.NeighborAddress,
+ "Key": peer.fsm.pConf.State.NeighborAddress,
}).Debugf("withdraw %d stale routes", len(pathList))
server.propagateUpdate(peer, pathList)
}
@@ -1000,7 +1001,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) {
default:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.fsm.pConf.Config.NeighborAddress,
+ "Key": peer.fsm.pConf.State.NeighborAddress,
"Data": e.MsgData,
}).Panic("unknown msg type")
}
@@ -1061,7 +1062,7 @@ func (s *BgpServer) UpdatePolicy(policy config.RoutingPolicy) error {
for _, peer := range s.neighborMap {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.fsm.pConf.Config.NeighborAddress,
+ "Key": peer.fsm.pConf.State.NeighborAddress,
}).Info("call set policy")
ap[peer.ID()] = peer.fsm.pConf.ApplyPolicy
}
@@ -1622,7 +1623,11 @@ func (server *BgpServer) addPeerGroup(c *config.PeerGroup) error {
}
func (server *BgpServer) addNeighbor(c *config.Neighbor) error {
- addr := c.Config.NeighborAddress
+ addr, err := config.ExtractNeighborAddress(c)
+ if err != nil {
+ return err
+ }
+
if _, y := server.neighborMap[addr]; y {
return fmt.Errorf("Can't overwrite the existing peer: %s", addr)
}
@@ -1735,7 +1740,11 @@ func (server *BgpServer) deleteNeighbor(c *config.Neighbor, code, subcode uint8)
}
}
- addr := c.Config.NeighborAddress
+ addr, err := config.ExtractNeighborAddress(c)
+ if err != nil {
+ return err
+ }
+
if intf := c.Config.NeighborInterface; intf != "" {
var err error
addr, err = config.GetIPv6LinkLocalNeighborAddress(intf)
@@ -1850,7 +1859,11 @@ func (s *BgpServer) updateNeighbor(c *config.Neighbor) (needsSoftResetIn bool, e
}
}
- addr := c.Config.NeighborAddress
+ addr, err := config.ExtractNeighborAddress(c)
+ if err != nil {
+ return err
+ }
+
peer, ok := s.neighborMap[addr]
if !ok {
return needsSoftResetIn, fmt.Errorf("Neighbor that has %v doesn't exist.", addr)
@@ -1998,10 +2011,10 @@ func (s *BgpServer) setAdminState(addr, communication string, enable bool) error
case peer.fsm.adminStateCh <- *stateOp:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.fsm.pConf.Config.NeighborAddress,
+ "Key": peer.fsm.pConf.State.NeighborAddress,
}).Debug(message)
default:
- log.Warning("previous request is still remaining. : ", peer.fsm.pConf.Config.NeighborAddress)
+ log.Warning("previous request is still remaining. : ", peer.fsm.pConf.State.NeighborAddress)
}
}
if enable {