Skip to content

Commit

Permalink
add logs for delete operation into kerneltap server (#321)
Browse files Browse the repository at this point in the history
Signed-off-by: Danil Uzlov <DanilUzlov@yandex.ru>
  • Loading branch information
d-uzlov authored Jul 21, 2021
1 parent 7b2757c commit 2bbda71
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
8 changes: 7 additions & 1 deletion pkg/networkservice/mechanisms/kernel/kerneltap/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ import (

"git.fd.io/govpp.git/api"
"github.com/golang/protobuf/ptypes/empty"

"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/cls"
"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
"github.com/networkservicemesh/sdk/pkg/tools/log"

"google.golang.org/grpc"

"github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata"
Expand Down Expand Up @@ -61,6 +64,9 @@ func (k *kernelTapClient) Request(ctx context.Context, request *networkservice.N
}

func (k *kernelTapClient) Close(ctx context.Context, conn *networkservice.Connection, opts ...grpc.CallOption) (*empty.Empty, error) {
_ = del(ctx, conn, k.vppConn, metadata.IsClient(k))
err := del(ctx, conn, k.vppConn, metadata.IsClient(k))
if err != nil {
log.FromContext(ctx).Error(err)
}
return next.Client(ctx).Close(ctx, conn, opts...)
}
10 changes: 8 additions & 2 deletions pkg/networkservice/mechanisms/kernel/kerneltap/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ import (
interfaces "github.com/edwarnicke/govpp/binapi/interface"
"github.com/edwarnicke/govpp/binapi/interface_types"
"github.com/edwarnicke/govpp/binapi/tapv2"
"github.com/pkg/errors"

"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/kernel"
"github.com/networkservicemesh/api/pkg/api/networkservice/payload"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/pkg/errors"

"github.com/networkservicemesh/sdk-vpp/pkg/tools/ifindex"
"github.com/networkservicemesh/sdk-vpp/pkg/tools/mechutils"
Expand Down Expand Up @@ -139,12 +140,17 @@ func del(ctx context.Context, conn *networkservice.Connection, vppConn api.Conne
if !ok {
return nil
}
now := time.Now()
_, err := tapv2.NewServiceClient(vppConn).TapDeleteV2(ctx, &tapv2.TapDeleteV2{
SwIfIndex: swIfIndex,
})
if err != nil {
return errors.WithStack(err)
return errors.Wrapf(err, "unable to delete connection with SwIfIndex %v", swIfIndex)
}
log.FromContext(ctx).
WithField("SwIfIndex", swIfIndex).
WithField("duration", time.Since(now)).
WithField("vppapi", "TapDeleteV2").Debug("completed")
return nil
}
return nil
Expand Down
7 changes: 6 additions & 1 deletion pkg/networkservice/mechanisms/kernel/kerneltap/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ import (

"git.fd.io/govpp.git/api"
"github.com/golang/protobuf/ptypes/empty"

"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
"github.com/networkservicemesh/sdk/pkg/tools/log"

"github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata"
)
Expand Down Expand Up @@ -53,6 +55,9 @@ func (k *kernelTapServer) Request(ctx context.Context, request *networkservice.N
}

func (k *kernelTapServer) Close(ctx context.Context, conn *networkservice.Connection) (*empty.Empty, error) {
_ = del(ctx, conn, k.vppConn, metadata.IsClient(k))
err := del(ctx, conn, k.vppConn, metadata.IsClient(k))
if err != nil {
log.FromContext(ctx).Error(err)
}
return next.Server(ctx).Close(ctx, conn)
}

0 comments on commit 2bbda71

Please sign in to comment.