Skip to content

Commit 00a468a

Browse files
committed
fsm: mostly read peer.fsm.pConf
The logic is to use atomic.Value to store the pointer and use fsm.lock Mutex for a write transaction in the fsm.pConf Most fields are read-only, so they can be accessed an atomic copy via fsm.pConf.Load().Field. Most write fields, state messages statistics and timer state update recvieve are written via atomic.
1 parent f26690d commit 00a468a

File tree

7 files changed

+923
-460
lines changed

7 files changed

+923
-460
lines changed

pkg/config/oc/util.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -528,24 +528,24 @@ func NewPeerFromConfigStruct(pconf *Neighbor) *api.Peer {
528528
AdminState: admin_state,
529529
Messages: &api.Messages{
530530
Received: &api.Message{
531-
Notification: s.Messages.Received.Notification,
532-
Update: s.Messages.Received.Update,
533-
Open: s.Messages.Received.Open,
534-
Keepalive: s.Messages.Received.Keepalive,
535-
Refresh: s.Messages.Received.Refresh,
536-
Discarded: s.Messages.Received.Discarded,
537-
Total: s.Messages.Received.Total,
538-
WithdrawUpdate: uint64(s.Messages.Received.WithdrawUpdate),
539-
WithdrawPrefix: uint64(s.Messages.Received.WithdrawPrefix),
531+
Notification: pconf.State.Messages.Received.Notification,
532+
Update: pconf.State.Messages.Received.Update,
533+
Open: pconf.State.Messages.Received.Open,
534+
Keepalive: pconf.State.Messages.Received.Keepalive,
535+
Refresh: pconf.State.Messages.Received.Refresh,
536+
Discarded: pconf.State.Messages.Received.Discarded,
537+
Total: pconf.State.Messages.Received.Total,
538+
WithdrawUpdate: uint64(pconf.State.Messages.Received.WithdrawUpdate),
539+
WithdrawPrefix: uint64(pconf.State.Messages.Received.WithdrawPrefix),
540540
},
541541
Sent: &api.Message{
542-
Notification: s.Messages.Sent.Notification,
543-
Update: s.Messages.Sent.Update,
544-
Open: s.Messages.Sent.Open,
545-
Keepalive: s.Messages.Sent.Keepalive,
546-
Refresh: s.Messages.Sent.Refresh,
547-
Discarded: s.Messages.Sent.Discarded,
548-
Total: s.Messages.Sent.Total,
542+
Notification: pconf.State.Messages.Sent.Notification,
543+
Update: pconf.State.Messages.Sent.Update,
544+
Open: pconf.State.Messages.Sent.Open,
545+
Keepalive: pconf.State.Messages.Sent.Keepalive,
546+
Refresh: pconf.State.Messages.Sent.Refresh,
547+
Discarded: pconf.State.Messages.Sent.Discarded,
548+
Total: pconf.State.Messages.Sent.Total,
549549
},
550550
},
551551
PeerAsn: s.PeerAs,

0 commit comments

Comments
 (0)