Skip to content

Commit

Permalink
Showing 3 changed files with 41 additions and 33 deletions.
28 changes: 15 additions & 13 deletions pkg/networkservice/mechanisms/kernel/client.go
Original file line number Diff line number Diff line change
@@ -88,21 +88,23 @@ func (c *kernelClient) Close(ctx context.Context, conn *networkservice.Connectio
logger := log.FromContext(ctx).WithField("kernelClient", "Close")
_, err := next.Client(ctx).Close(ctx, conn, opts...)

var kernelMechErr error
ovsPortInfo, exists := ifnames.Load(ctx, metadata.IsClient(c))
if exists {
if !ovsPortInfo.IsVfRepresentor {
kernelMechErr = resetVeth(ctx, logger, conn, c.bridgeName, metadata.IsClient(c))
} else {
kernelMechErr = resetVF(logger, ovsPortInfo, c.bridgeName)
if mechanism := kernel.ToMechanism(conn.GetMechanism()); mechanism != nil {
var kernelMechErr error
ovsPortInfo, exists := ifnames.Load(ctx, metadata.IsClient(c))
if exists {
if !ovsPortInfo.IsVfRepresentor {
kernelMechErr = resetVeth(ctx, logger, conn, c.bridgeName, metadata.IsClient(c))
} else {
kernelMechErr = resetVF(logger, ovsPortInfo, c.bridgeName)
}
}
}

if err != nil && kernelMechErr != nil {
return nil, errors.Wrap(err, kernelMechErr.Error())
}
if kernelMechErr != nil {
return nil, kernelMechErr
if err != nil && kernelMechErr != nil {
return nil, errors.Wrap(err, kernelMechErr.Error())
}
if kernelMechErr != nil {
return nil, kernelMechErr
}
}

return &empty.Empty{}, err
29 changes: 16 additions & 13 deletions pkg/networkservice/mechanisms/kernel/server.go
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ import (

"github.com/golang/protobuf/ptypes/empty"
"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/kernel"
"github.com/networkservicemesh/sdk-sriov/pkg/networkservice/common/resourcepool"
"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
"github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata"
@@ -70,21 +71,23 @@ func (k *kernelServer) Close(ctx context.Context, conn *networkservice.Connectio
logger := log.FromContext(ctx).WithField("kernelServer", "Close")
_, err := next.Server(ctx).Close(ctx, conn)

var kernelServerErr error
ovsPortInfo, exists := ifnames.LoadAndDelete(ctx, metadata.IsClient(k))
if exists {
if !ovsPortInfo.IsVfRepresentor {
kernelServerErr = resetVeth(ctx, logger, conn, k.bridgeName, metadata.IsClient(k))
} else {
kernelServerErr = resetVF(logger, ovsPortInfo, k.bridgeName)
if mechanism := kernel.ToMechanism(conn.GetMechanism()); mechanism != nil {
var kernelServerErr error
ovsPortInfo, exists := ifnames.LoadAndDelete(ctx, metadata.IsClient(k))
if exists {
if !ovsPortInfo.IsVfRepresentor {
kernelServerErr = resetVeth(ctx, logger, conn, k.bridgeName, metadata.IsClient(k))
} else {
kernelServerErr = resetVF(logger, ovsPortInfo, k.bridgeName)
}
}
}

if err != nil && kernelServerErr != nil {
return nil, errors.Wrap(err, kernelServerErr.Error())
}
if kernelServerErr != nil {
return nil, kernelServerErr
if err != nil && kernelServerErr != nil {
return nil, errors.Wrap(err, kernelServerErr.Error())
}
if kernelServerErr != nil {
return nil, kernelServerErr
}
}

return &empty.Empty{}, err
17 changes: 10 additions & 7 deletions pkg/networkservice/mechanisms/vxlan/server.go
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ import (
"github.com/networkservicemesh/sdk-ovs/pkg/tools/ifnames"

"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/vxlan"

"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/vxlan/vni"
)
@@ -74,14 +75,16 @@ func (v *vxlanServer) Request(ctx context.Context, request *networkservice.Netwo

func (v *vxlanServer) Close(ctx context.Context, conn *networkservice.Connection) (*empty.Empty, error) {
_, err := next.Server(ctx).Close(ctx, conn)
vxlanServerErr := remove(conn, v.bridgeName, v.vxlanInterfacesMutex, v.vxlanInterfacesMap, metadata.IsClient(v))
ifnames.Delete(ctx, metadata.IsClient(v))
if mechanism := vxlan.ToMechanism(conn.GetMechanism()); mechanism != nil {
vxlanServerErr := remove(conn, v.bridgeName, v.vxlanInterfacesMutex, v.vxlanInterfacesMap, metadata.IsClient(v))
ifnames.Delete(ctx, metadata.IsClient(v))

if err != nil && vxlanServerErr != nil {
return nil, errors.Wrap(err, vxlanServerErr.Error())
}
if vxlanServerErr != nil {
return nil, vxlanServerErr
if err != nil && vxlanServerErr != nil {
return nil, errors.Wrap(err, vxlanServerErr.Error())
}
if vxlanServerErr != nil {
return nil, vxlanServerErr
}
}
return &empty.Empty{}, err
}

0 comments on commit 814aea0

Please sign in to comment.