mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-06 03:56:34 +00:00
Merge pull request #7738 from Xuanqing-Shi/7732/handle-non-empty-endpoints-in-RemoveEndpoints
runtime: incorrect handling of non-empty []Endpoint parameter in Remo…
This commit is contained in:
commit
6eedd9b0b9
@ -229,12 +229,17 @@ func (n *LinuxNetwork) addSingleEndpoint(ctx context.Context, s *Sandbox, netInf
|
|||||||
return endpoint, nil
|
return endpoint, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *LinuxNetwork) removeSingleEndpoint(ctx context.Context, s *Sandbox, idx int, hotplug bool) error {
|
func (n *LinuxNetwork) removeSingleEndpoint(ctx context.Context, s *Sandbox, endpoint Endpoint, hotplug bool) error {
|
||||||
if idx > len(n.eps)-1 {
|
var idx int = len(n.eps)
|
||||||
return fmt.Errorf("Endpoint index overflow")
|
for i, val := range n.eps {
|
||||||
|
if val.HardwareAddr() == endpoint.HardwareAddr() {
|
||||||
|
idx = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if idx == len(n.eps) {
|
||||||
|
return fmt.Errorf("Endpoint not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
endpoint := n.eps[idx]
|
|
||||||
|
|
||||||
if endpoint.GetRxRateLimiter() {
|
if endpoint.GetRxRateLimiter() {
|
||||||
networkLogger().WithField("endpoint-type", endpoint.Type()).Info("Deleting rx rate limiter")
|
networkLogger().WithField("endpoint-type", endpoint.Type()).Info("Deleting rx rate limiter")
|
||||||
@ -402,7 +407,7 @@ func (n *LinuxNetwork) RemoveEndpoints(ctx context.Context, s *Sandbox, endpoint
|
|||||||
eps = endpoints
|
eps = endpoints
|
||||||
}
|
}
|
||||||
|
|
||||||
for idx, ep := range eps {
|
for _, ep := range eps {
|
||||||
if endpoints != nil {
|
if endpoints != nil {
|
||||||
new_ep, _ := findEndpoint(ep, n.eps)
|
new_ep, _ := findEndpoint(ep, n.eps)
|
||||||
if new_ep == nil {
|
if new_ep == nil {
|
||||||
@ -410,7 +415,7 @@ func (n *LinuxNetwork) RemoveEndpoints(ctx context.Context, s *Sandbox, endpoint
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := n.removeSingleEndpoint(ctx, s, idx, hotplug); err != nil {
|
if err := n.removeSingleEndpoint(ctx, s, ep, hotplug); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user