Skip to content

Commit

Permalink
Pass interface index to VPP ping API (#800)
Browse files Browse the repository at this point in the history
* Remove deprecated API for watching VPPAPI events (#798)

* add watcher

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>

* remove deprecated API from wireguard

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>

* fix golangci linter

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>

* go mod tidy

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>

* delete more of deprecated API

Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>

* fix go linter issues

Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>

---------

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>

* fix go linter issues

Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>

---------

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik authored Mar 6, 2024
1 parent a9caca2 commit c7e7e23
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions pkg/tools/heal/liveness_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/pkg/errors"
"go.fd.io/govpp/api"

"github.com/networkservicemesh/sdk-vpp/pkg/tools/ifindex"
)

const (
Expand Down Expand Up @@ -62,16 +64,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 +73,23 @@ func doPing(

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

index, 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: index,
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 c7e7e23

Please sign in to comment.