mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 12:14:48 +00:00
virtcontainers: Remove the Network PostAdd method
It's used once by the sandbox code and can be implemented directly there. Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
This commit is contained in:
parent
e0b264430d
commit
c67109a251
@ -211,9 +211,6 @@ type Network interface {
|
|||||||
// RemoveEndpoint removes one single endpoint from the sandbox's network.
|
// RemoveEndpoint removes one single endpoint from the sandbox's network.
|
||||||
RemoveEndpoint(context.Context, *Sandbox, int, bool) error
|
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 runs a callback in a sandbox's network.
|
||||||
Run(context.Context, func() error) error
|
Run(context.Context, func() error) error
|
||||||
|
|
||||||
|
@ -339,32 +339,6 @@ func (n *LinuxNetwork) Add(ctx context.Context, s *Sandbox, hotplug bool) error
|
|||||||
return nil
|
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
|
// Remove network endpoints in the network namespace. It also deletes the network
|
||||||
// namespace in case the namespace has been created by us.
|
// namespace in case the namespace has been created by us.
|
||||||
func (n *LinuxNetwork) Remove(ctx context.Context) error {
|
func (n *LinuxNetwork) Remove(ctx context.Context) error {
|
||||||
|
@ -826,7 +826,27 @@ func (s *Sandbox) createNetwork(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sandbox) postCreatedNetwork(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 {
|
func (s *Sandbox) removeNetwork(ctx context.Context) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user