-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delay the initialization of ARP/NDP responders
For secondary-network scenarios, the transport interface can be changed after the agent is started. The ARP/NDP responders should be started after the initialization of secondary-network to bind to the transport interface of the new index. Besides, this change also addresses the following issues: - NDP responder may fail to bind to the new interface due to the Duplicate Address Detection process. - Golang caches the zone index for the interface, which may result in NDP responder binding on the stale interface Fixes: #6623 Signed-off-by: Xu Liu <[email protected]>
- Loading branch information
Showing
11 changed files
with
390 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright 2024 Antrea Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package responder | ||
|
||
import ( | ||
"net/netip" | ||
|
||
"k8s.io/apimachinery/pkg/util/sets" | ||
"k8s.io/klog/v2" | ||
) | ||
|
||
var ( | ||
// map of transportInterfaceName to ARP responder | ||
arpResponders = make(map[string]*arpResponder) | ||
// map of transportInterfaceName to NDP responder | ||
ndpResponders = make(map[string]*ndpResponder) | ||
) | ||
|
||
// NewARPResponder creates a new ARP responder if it does not exist for the given transportInterfaceName. | ||
// This function is not thread-safe. | ||
func NewARPResponder(transportInterfaceName string) *arpResponder { | ||
if responder, ok := arpResponders[transportInterfaceName]; ok { | ||
klog.InfoS("ARP responder already exists", "interface", transportInterfaceName) | ||
return responder | ||
} | ||
a := &arpResponder{ | ||
ifaceName: transportInterfaceName, | ||
assignedIPs: sets.New[string](), | ||
} | ||
klog.InfoS("Created new ARP responder", "interface", transportInterfaceName) | ||
arpResponders[transportInterfaceName] = a | ||
return a | ||
} | ||
|
||
// NewNDPResponder creates a new NDP responder if it does not exist for the given transportInterfaceName. | ||
// This function is not thread-safe. | ||
func NewNDPResponder(transportInterfaceName string) *ndpResponder { | ||
if responder, ok := ndpResponders[transportInterfaceName]; ok { | ||
klog.InfoS("NDP responder already exists", "interface", transportInterfaceName) | ||
return responder | ||
} | ||
n := &ndpResponder{ | ||
ifaceName: transportInterfaceName, | ||
multicastGroups: make(map[netip.Addr]int), | ||
assignedIPs: sets.New[netip.Addr](), | ||
} | ||
klog.InfoS("Created new NDP responder", "interface", transportInterfaceName) | ||
ndpResponders[transportInterfaceName] = n | ||
return n | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.