Skip to content

Commit

Permalink
do not invoke next.Close when connection not established
Browse files Browse the repository at this point in the history
Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@est.tech>
  • Loading branch information
pperiyasamy committed Sep 20, 2021
1 parent 19a0785 commit 01075a0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions pkg/networkservice/mechanisms/kernel/smartvf_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ func (k *kernelSmartVFServer) Request(ctx context.Context, request *networkservi
if err != nil && !isEstablished {
closeCtx, cancelClose := postponeCtxFunc()
defer cancelClose()

if _, closeErr := k.Close(closeCtx, conn); closeErr != nil {
err = errors.Wrapf(err, "connection closed with error: %s", closeErr.Error())
if ovsPortInfo, exists := ifnames.LoadAndDelete(closeCtx, metadata.IsClient(k)); exists {
if kernelServerErr := resetVF(logger, ovsPortInfo, k.bridgeName); kernelServerErr != nil {
err = errors.Wrapf(err, "connection closed with error: %s", kernelServerErr.Error())
}
}
return nil, err
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/networkservice/mechanisms/kernel/veth_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ func (k *kernelVethServer) Request(ctx context.Context, request *networkservice.
if err != nil && !isEstablished {
closeCtx, cancelClose := postponeCtxFunc()
defer cancelClose()

if _, closeErr := k.Close(closeCtx, conn); closeErr != nil {
err = errors.Wrapf(err, "connection closed with error: %s", closeErr.Error())
if _, exists := ifnames.LoadAndDelete(closeCtx, metadata.IsClient(k)); exists {
if kernelServerErr := resetVeth(closeCtx, logger, conn, k.bridgeName, metadata.IsClient(k)); kernelServerErr != nil {
err = errors.Wrapf(err, "connection closed with error: %s", kernelServerErr.Error())
}
}
return nil, err
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/networkservice/mechanisms/vxlan/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ func (v *vxlanServer) Request(ctx context.Context, request *networkservice.Netwo
if err != nil && !isEstablished {
closeCtx, cancelClose := postponeCtxFunc()
defer cancelClose()

if _, closeErr := v.Close(closeCtx, conn); closeErr != nil {
err = errors.Wrapf(err, "connection closed with error: %s", closeErr.Error())
if _, exists := ifnames.LoadAndDelete(closeCtx, metadata.IsClient(v)); exists {
if vxlanServerErr := remove(conn, v.bridgeName, v.vxlanInterfacesMutex, v.vxlanInterfacesMap, metadata.IsClient(v)); vxlanServerErr != nil {
err = errors.Wrapf(err, "connection closed with error: %s", vxlanServerErr.Error())
}
}
return nil, err
}
Expand Down

0 comments on commit 01075a0

Please sign in to comment.