Skip to content

Commit

Permalink
loxilb-iogh-84 sctp-connect probing method is integrated
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed May 12, 2023
1 parent 0e2208b commit 903be3d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/go-openapi/swag v0.22.3
github.com/go-openapi/validate v0.22.0
github.com/jessevdk/go-flags v1.5.0
github.com/loxilb-io/loxilib v0.8.8-0.20230512160324-dc2b309abeab
github.com/osrg/gobgp/v3 v3.5.0
github.com/prometheus-community/pro-bing v0.1.0
github.com/prometheus/client_model v0.3.0
Expand All @@ -24,8 +25,7 @@ require (
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/loxilb-io/loxilib v0.8.8-0.20230512062703-265e0ce4b789 // indirect
github.com/loxilb-io/sctp v0.0.0-20230512061258-63a8bc8f1b80 // indirect
github.com/loxilb-io/sctp v0.0.0-20230512152123-70e9c76eb88a // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,16 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/loxilb-io/loxilib v0.8.6 h1:Mcwf2me7WmbPdMUDTBf2a6H1ai5dACsKL4/uF+cwLUA=
github.com/loxilb-io/loxilib v0.8.6/go.mod h1:3wwCYuvYUm5BwqfYWjkyx8AXnfU4chZnm+9v50R/ixo=
github.com/loxilb-io/loxilib v0.8.8-0.20230512062703-265e0ce4b789 h1:60m3PZR7rwUl+3GgK73KR1lG59hqlA2Yf2ZqJocXu8s=
github.com/loxilb-io/loxilib v0.8.8-0.20230512062703-265e0ce4b789/go.mod h1:tEXABtZHuPQbkHWnOtmQWt8lhQwhKlSRuHkAyBVrnWM=
github.com/loxilb-io/sctp v0.0.0-20230510141333-0e10149b200d h1:ia8BANfzIzRbi/kzudQJE6OctH1oaxYDCgm0M1BI2DY=
github.com/loxilb-io/sctp v0.0.0-20230510141333-0e10149b200d/go.mod h1:1a6hv8ISVQhnW5IVpW9o+OL6BAFlWiVpC0O4d19g+wQ=
github.com/loxilb-io/loxilib v0.8.8-0.20230512153855-7e0f13cf1a09 h1:t7yKu682dNiJ5NrJTjk4SVcr/p6KtTks2+qYwennaAY=
github.com/loxilb-io/loxilib v0.8.8-0.20230512153855-7e0f13cf1a09/go.mod h1:4dz7zLVR/+XkCY+eevxrlXX4y2DeoVi3dzLwUDSQXqo=
github.com/loxilb-io/loxilib v0.8.8-0.20230512160324-dc2b309abeab h1:ufUyc+dksD0Ms6DqeW9hy3/7tW5CNBUwMTQMY9orsBI=
github.com/loxilb-io/loxilib v0.8.8-0.20230512160324-dc2b309abeab/go.mod h1:4dz7zLVR/+XkCY+eevxrlXX4y2DeoVi3dzLwUDSQXqo=
github.com/loxilb-io/sctp v0.0.0-20230512061258-63a8bc8f1b80 h1:rYO3BYcHt0ILY0sOeygtpUEEFsNS8KZBTbuEIW2foLk=
github.com/loxilb-io/sctp v0.0.0-20230512061258-63a8bc8f1b80/go.mod h1:1a6hv8ISVQhnW5IVpW9o+OL6BAFlWiVpC0O4d19g+wQ=
github.com/loxilb-io/sctp v0.0.0-20230512152123-70e9c76eb88a h1:ASVCk3Mk5n9fNJYJm1+QF9bsFCHysudzE8sj5nhj5P4=
github.com/loxilb-io/sctp v0.0.0-20230512152123-70e9c76eb88a/go.mod h1:1a6hv8ISVQhnW5IVpW9o+OL6BAFlWiVpC0O4d19g+wQ=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
Expand Down
2 changes: 1 addition & 1 deletion loxilb-ebpf
24 changes: 15 additions & 9 deletions loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ import (
"encoding/json"
"errors"
"fmt"
cmn "github.com/loxilb-io/loxilb/common"
tk "github.com/loxilb-io/loxilib"
probing "github.com/prometheus-community/pro-bing"
"io/ioutil"
"net"
"sort"
"strconv"
"sync"
"time"

cmn "github.com/loxilb-io/loxilb/common"
tk "github.com/loxilb-io/loxilib"
probing "github.com/prometheus-community/pro-bing"
)

// error codes
Expand Down Expand Up @@ -1477,24 +1476,27 @@ func (ep *epHost) transitionState(currState bool, inactThr int) {
if ep.inActTries < inactThr {
ep.inActTries++
if ep.inActTries >= inactThr {
if !ep.inactive {
tk.LogIt(tk.LogDebug, "inactive ep - %s:%s:%d(next try after %ds)\n",
ep.epKey, ep.opts.probeType, ep.opts.probePort, ep.opts.currProbeDuration)
}
ep.inactive = true
//tk.LogIt(tk.LogDebug, "inactive ep - %s:%s:%d(next try after %ds)\n",
// ep.epKey, ep.opts.probeType, ep.opts.probePort, ep.opts.currProbeDuration)
}
} else {
ep.inActTries++
// Inactive eps are moved back
if ep.opts.currProbeDuration < 3*DflHostProbeTimeout {
ep.opts.currProbeDuration += 20
}
tk.LogIt(tk.LogDebug, "inactive ep - %s:%s:%d(next try after %ds)\n",
ep.epKey, ep.opts.probeType, ep.opts.probePort, ep.opts.currProbeDuration)
//tk.LogIt(tk.LogDebug, "inactive ep - %s:%s:%d(next try after %ds)\n",
// ep.epKey, ep.opts.probeType, ep.opts.probePort, ep.opts.currProbeDuration)
}
}
}

func (R *RuleH) epCheckNow(ep *epHost) {
var sType string
sHint := ""

sName := fmt.Sprintf("%s:%d", ep.hostName, ep.opts.probePort)
if ep.opts.probeType == HostProbeConnectTcp ||
Expand All @@ -1506,8 +1508,12 @@ func (R *RuleH) epCheckNow(ep *epHost) {
sType = "udp"
} else {
sType = "sctp"
ret, sIP := R.Zone.L3.IfaSelectAny(net.ParseIP(ep.hostName), true)
if ret == 0 {
sHint = sIP.String()
}
}
sOk := tk.L4ServiceProber(sType, sName)
sOk := tk.L4ServiceProber(sType, sName, sHint)
ep.transitionState(sOk, ep.opts.inActTryThr)
} else if ep.opts.probeType == HostProbePing {
pinger, err := probing.NewPinger(ep.hostName)
Expand Down

0 comments on commit 903be3d

Please sign in to comment.