-
Notifications
You must be signed in to change notification settings - Fork 369
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 <xu.liu@broadcom.com>
- 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,48 @@ | ||
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.