diff --git a/src/runtime/virtcontainers/network.go b/src/runtime/virtcontainers/network.go index cce583ff5a..81f5985e30 100644 --- a/src/runtime/virtcontainers/network.go +++ b/src/runtime/virtcontainers/network.go @@ -211,9 +211,6 @@ type Network interface { // RemoveEndpoint removes one single endpoint from the sandbox's network. RemoveEndpoint(context.Context, *Sandbox, int, bool) error - // PostAdd is a post networking endpoint addition hook. - PostAdd(context.Context, bool) error - // Run runs a callback in a sandbox's network. Run(context.Context, func() error) error diff --git a/src/runtime/virtcontainers/network_linux.go b/src/runtime/virtcontainers/network_linux.go index 4b6c7cb264..8a9e72cddd 100644 --- a/src/runtime/virtcontainers/network_linux.go +++ b/src/runtime/virtcontainers/network_linux.go @@ -339,32 +339,6 @@ func (n *LinuxNetwork) Add(ctx context.Context, s *Sandbox, hotplug bool) error return nil } -func (n *LinuxNetwork) PostAdd(ctx context.Context, hotplug bool) error { - if hotplug { - return nil - } - - if n.eps == nil { - return nil - } - - endpoints := n.eps - - for _, endpoint := range endpoints { - netPair := endpoint.NetworkPair() - if netPair == nil { - continue - } - if netPair.VhostFds != nil { - for _, VhostFd := range netPair.VhostFds { - VhostFd.Close() - } - } - } - - return nil -} - // Remove network endpoints in the network namespace. It also deletes the network // namespace in case the namespace has been created by us. func (n *LinuxNetwork) Remove(ctx context.Context) error { diff --git a/src/runtime/virtcontainers/sandbox.go b/src/runtime/virtcontainers/sandbox.go index f9341e70e0..5bccf1b07a 100644 --- a/src/runtime/virtcontainers/sandbox.go +++ b/src/runtime/virtcontainers/sandbox.go @@ -826,7 +826,27 @@ func (s *Sandbox) createNetwork(ctx context.Context) error { } func (s *Sandbox) postCreatedNetwork(ctx context.Context) error { - return s.network.PostAdd(ctx, s.factory != nil) + if s.factory != nil { + return nil + } + + if s.network.Endpoints() == nil { + return nil + } + + for _, endpoint := range s.network.Endpoints() { + netPair := endpoint.NetworkPair() + if netPair == nil { + continue + } + if netPair.VhostFds != nil { + for _, VhostFd := range netPair.VhostFds { + VhostFd.Close() + } + } + } + + return nil } func (s *Sandbox) removeNetwork(ctx context.Context) error {