Skip to content

Commit 776430c

Browse files
committed
feat: enable dual NIC feature support and improve ARP proxy handling in transparent VLAN client
1 parent 2f33a42 commit 776430c

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

cni/network/network_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func platformInit(cniConfig *cni.NetworkConfig) {}
127127

128128
// isDualNicFeatureSupported returns if the dual nic feature is supported. Currently it's only supported for windows hnsv2 path
129129
func (plugin *NetPlugin) isDualNicFeatureSupported(netNs string) bool {
130-
return false
130+
return true
131131
}
132132

133133
func getOverlayGateway(_ *net.IPNet) (net.IP, error) {

network/transparent_vlan_endpointclient_linux.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -418,18 +418,19 @@ func (client *TransparentVlanEndpointClient) AddEndpointRules(epInfo *EndpointIn
418418
}
419419
logger.Info("[transparent-vlan] Adding tunneling rules in vnet namespace")
420420
err := ExecuteInNS(client.nsClient, client.vnetNSName, func() error {
421-
return client.AddVnetRules(epInfo)
422-
})
423-
if err == nil {
424-
logger.Info("calling setArpProxy for", zap.String("vlanIfName", client.vlanIfName))
425-
if err := client.setArpProxy(client.vlanIfName); err != nil {
426-
logger.Error("setArpProxy failed with", zap.Error(err))
421+
if err := client.AddVnetRules(epInfo); err != nil {
427422
return err
428423
}
429-
if err != nil {
430-
logger.Error("setArpProxy failed for VLAN interface", zap.Error(err))
424+
425+
// Set ARP proxy on vnet veth (inside vnet namespace)
426+
logger.Info("calling setArpProxy for", zap.String("vnetVethName", client.vnetVethName))
427+
if err := client.setArpProxy(client.vnetVethName); err != nil {
428+
logger.Error("setArpProxy failed with", zap.Error(err))
429+
return err
431430
}
432-
}
431+
432+
return nil
433+
})
433434

434435
return err
435436
}
@@ -544,7 +545,7 @@ func (client *TransparentVlanEndpointClient) ConfigureContainerInterfacesAndRout
544545

545546
if epInfo.SkipDefaultRoutes {
546547
logger.Info("Skipping adding default routes in container ns as requested")
547-
if err := client.addCustomRoutes(client.containerVethName, epInfo.Subnets[0].Gateway, epInfo.IPAddresses[0]); err != nil {
548+
if err := client.addCustomRoutes(client.containerVethName, epInfo.Subnets[0].Gateway, epInfo.Subnets[0].Prefix, 0); err != nil {
548549
return errors.Wrap(err, "failed container ns add custom routes")
549550
}
550551
return nil
@@ -665,8 +666,8 @@ func (client *TransparentVlanEndpointClient) addCustomRoutes(linkToName string,
665666
}
666667

667668
// Add subnet route (ip route add <subnetCIDR> via <gatewayIP> dev <linkToName>)
668-
_, subnetIPNet, _ := net.ParseCIDR(subnetCIDR.String())
669-
dstIP := net.IPNet{IP: net.ParseIP(defaultGw), Mask: subnetIPNet.Mask}
669+
subnetPrefix, subnetIPNet, _ := net.ParseCIDR(subnetCIDR.String())
670+
dstIP := net.IPNet{IP: subnetPrefix, Mask: subnetIPNet.Mask}
670671
routeInfo = RouteInfo{
671672
Dst: dstIP,
672673
Gw: gWIP,

0 commit comments

Comments
 (0)