diff --git a/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipaddress/common.go b/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipaddress/common.go index 2ea63577..c89ea2bd 100644 --- a/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipaddress/common.go +++ b/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipaddress/common.go @@ -90,15 +90,10 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool) return errors.Wrapf(err, "failed to set %s = 0", disableIPv6Filename) } - nsHandle, err := nshandle.FromURL(mechanism.GetNetNSURL()) - defer func() { _ = nsHandle.Close() }() - if err != nil { - return errors.Wrapf(err, "failed to retrieve nsHandle for %+v", mechanism) - } ch := make(chan netlink.AddrUpdate) done := make(chan struct{}) defer close(done) - if err := netlink.AddrSubscribeAt(nsHandle, ch, done); err != nil { + if err := netlink.AddrSubscribeAt(targetNetNS, ch, done); err != nil { return errors.Wrapf(err, "failed to subscribe for interface address updates") } for _, ipNet := range ipNets { diff --git a/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipneighbors/client.go b/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipneighbors/client.go index e55853f9..a553a820 100644 --- a/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipneighbors/client.go +++ b/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipneighbors/client.go @@ -34,6 +34,7 @@ import ( type ipNeighborsClient struct{} +// NewClient creates a new client chain element setting IP neighbors to kernel interface func NewClient() networkservice.NetworkServiceClient { return &ipNeighborsClient{} } @@ -44,7 +45,7 @@ func (i *ipNeighborsClient) Request(ctx context.Context, request *networkservice return nil, err } - if err := create(ctx, conn); err != nil { + if err := create(conn); err != nil { closeCtx, cancelClose := closectx.New(ctx) defer cancelClose() diff --git a/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipneighbors/common.go b/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipneighbors/common.go index ca7ce87d..c52f8671 100644 --- a/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipneighbors/common.go +++ b/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipneighbors/common.go @@ -1,4 +1,4 @@ -// Copyright (c) Nordix Foundation. +// Copyright (c) 2021 Nordix Foundation. // // SPDX-License-Identifier: Apache-2.0 // @@ -19,7 +19,6 @@ package ipneighbors import ( - "context" "net" "os" @@ -31,7 +30,7 @@ import ( link "github.com/networkservicemesh/sdk-kernel/pkg/kernel" ) -func create(ctx context.Context, conn *networkservice.Connection) error { +func create(conn *networkservice.Connection) error { if mechanism := kernel.ToMechanism(conn.GetMechanism()); mechanism != nil { netlinkHandle, err := link.GetNetlinkHandle(mechanism.GetNetNSURL()) if err != nil { @@ -53,7 +52,6 @@ func create(ctx context.Context, conn *networkservice.Connection) error { if err := setIPNeighbors(conn.GetContext().GetIpContext().GetIpNeighbors(), l); err != nil { return errors.WithStack(err) } - } return nil } diff --git a/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipneighbors/server.go b/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipneighbors/server.go index b9a91fe3..99dda044 100644 --- a/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipneighbors/server.go +++ b/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/ipneighbors/server.go @@ -34,6 +34,7 @@ import ( type ipNeighborsServer struct { } +// NewServer creates a new server chain element setting IP neighbors to kernel interface func NewServer() networkservice.NetworkServiceServer { return &ipNeighborsServer{} } @@ -44,7 +45,7 @@ func (i *ipNeighborsServer) Request(ctx context.Context, request *networkservice return nil, err } - if err := create(ctx, conn); err != nil { + if err := create(conn); err != nil { closeCtx, cancelClose := closectx.New(ctx) defer cancelClose()