Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
UltraInstinct14 authored Feb 29, 2024
2 parents 38f0135 + 55f0cf2 commit 7064481
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions proto/bfd.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const (
BFDMinSysTXIntervalUs = 100000
BFDDflSysTXIntervalUs = 200000
BFDMinSysRXIntervalUs = 200000
BFDIncrDiscVal = 0x10000000
)

type ConfigArgs struct {
Expand Down Expand Up @@ -82,6 +83,7 @@ type bfdSession struct {
Instance string
Cxn net.Conn
State SessionState
CiState string
MyMulti uint8
RemMulti uint8
MyIP net.IP
Expand Down Expand Up @@ -308,6 +310,12 @@ func (b *bfdSession) RunSessionSM(raw *WireRaw) {
tk.LogIt(tk.LogInfo, "%s: BFD State -> UP\n", b.RemoteName)
}
b.State = BFDUp
if b.CiState == "MASTER" {
// Force reelection
if b.MyDisc <= b.RemDisc {
oldState = BFDDown
}
}
}
newState := b.State
b.Mutex.Unlock()
Expand All @@ -324,8 +332,8 @@ func (b *bfdSession) checkSessTimeout() {
if b.State == BFDUp {
if time.Duration(time.Since(b.LastRxTS).Microseconds()) > time.Duration(b.TimeOut) {
b.State = BFDDown
b.MyDisc = b.RemDisc + 100
tk.LogIt(tk.LogInfo, "%s: BFD State -> Down\n", b.RemoteName)
b.MyDisc = b.RemDisc + BFDIncrDiscVal
tk.LogIt(tk.LogInfo, "%s: BFD State -> Down (%v:%v)\n", b.RemoteName, b.MyDisc, b.RemDisc)
}
}
newState := b.State
Expand All @@ -344,12 +352,17 @@ func (b *bfdSession) sendStateNotification(newState, oldState SessionState, inst
if b.MyDisc > b.RemDisc {
ciState = "MASTER"
}
tk.LogIt(tk.LogInfo, "%s: State change (%v:%v)\n", b.RemoteName, b.MyDisc, b.RemDisc)
b.CiState = ciState
b.Notify.BFDSessionNotify(inst, remote, ciState)
} else if newState == BFDDown && oldState == BFDUp {
ciState := "MASTER"
b.CiState = ciState
b.Notify.BFDSessionNotify(inst, remote, ciState)
} else if b.RemDisc == b.MyDisc {
b.Notify.BFDSessionNotify(inst, remote, "NOT_DEFINED")
ciState := "NOT_DEFINED"
b.CiState = ciState
b.Notify.BFDSessionNotify(inst, remote, ciState)
}
}

Expand Down

0 comments on commit 7064481

Please sign in to comment.