Skip to content

Commit

Permalink
Send ifindex to ping API in VPP liveness check
Browse files Browse the repository at this point in the history
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik committed Feb 12, 2024
1 parent c72e8a2 commit b34c3aa
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions pkg/tools/heal/liveness_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/govpp/binapi/ip_types"
"github.com/networkservicemesh/govpp/binapi/ping"
"github.com/networkservicemesh/sdk-vpp/pkg/tools/ifindex"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/pkg/errors"
"go.fd.io/govpp/api"
Expand Down Expand Up @@ -62,16 +63,6 @@ func doPing(
responseCh chan bool) {
logger := log.FromContext(deadlineCtx).WithField("srcIP", srcIP.String()).WithField("dstIP", dstIP.String())

if _, err := ping.NewServiceClient(vppConn).WantPingFinishedEvents(deadlineCtx, &ping.WantPingFinishedEvents{
Address: dstIP,
Interval: interval,
Repeat: repeat,
}); err != nil {
logger.Error(errors.Wrap(err, "vppapi WantPingEvents returned error"))
responseCh <- true
return
}

watcher, err := vppConn.WatchEvent(deadlineCtx, &ping.PingFinishedEvent{})
if err != nil {
logger.Error(errors.Wrap(err, "failed to watch ping.PingFinishedEvent").Error())
Expand All @@ -81,6 +72,23 @@ func doPing(

defer func() { watcher.Close() }()

ifindex, ok := ifindex.Load(deadlineCtx, true)
if !ok {
logger.Errorf("failed to load ifindex")
responseCh <- true
return
}
if _, err := ping.NewServiceClient(vppConn).WantPingFinishedEvents(deadlineCtx, &ping.WantPingFinishedEvents{
Address: dstIP,
SwIfIndex: ifindex,
Interval: interval,
Repeat: repeat,
}); err != nil {
logger.Error(errors.Wrap(err, "vppapi WantPingEvents returned error"))
responseCh <- true
return
}

select {
case <-deadlineCtx.Done():
responseCh <- true
Expand Down

0 comments on commit b34c3aa

Please sign in to comment.