Skip to content

Commit

Permalink
support disable arp check ip conflict in vlan provider network (#2760)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobz965 committed May 8, 2023
1 parent c55cbd6 commit e2bf60f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 63 deletions.
2 changes: 2 additions & 0 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ CNI_CONFIG_PRIORITY=${CNI_CONFIG_PRIORITY:-01}
ENABLE_LB_SVC=${ENABLE_LB_SVC:-false}
ENABLE_NAT_GW=${ENABLE_NAT_GW:-false}
ENABLE_KEEP_VM_IP=${ENABLE_KEEP_VM_IP:-true}
ENABLE_ARP_DETECT_IP_CONFLICT=${ENABLE_ARP_DETECT_IP_CONFLICT:-true}
NODE_LOCAL_DNS_IP=${NODE_LOCAL_DNS_IP:-}
# exchange link names of OVS bridge and the provider nic
# in the default provider-network
Expand Down Expand Up @@ -3726,6 +3727,7 @@ spec:
- /kube-ovn/start-cniserver.sh
args:
- --enable-mirror=$ENABLE_MIRROR
- --enable-arp-detect-ip-conflict=$ENABLE_ARP_DETECT_IP_CONFLICT
- --encap-checksum=true
- --service-cluster-ip-range=$SVC_CIDR
- --iface=${IFACE}
Expand Down
125 changes: 64 additions & 61 deletions pkg/daemon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,35 @@ import (
// Configuration is the daemon conf
type Configuration struct {
// interface being used for tunnel
tunnelIface string
Iface string
DPDKTunnelIface string
MTU int
MSS int
EnableMirror bool
MirrorNic string
BindSocket string
OvsSocket string
KubeConfigFile string
KubeClient kubernetes.Interface
KubeOvnClient clientset.Interface
NodeName string
ServiceClusterIPRange string
NodeSwitch string
EncapChecksum bool
EnablePprof bool
MacLearningFallback bool
PprofPort int
NetworkType string
CniConfDir string
CniConfFile string
CniConfName string
DefaultProviderName string
DefaultInterfaceName string
ExternalGatewayConfigNS string
ExternalGatewaySwitch string // provider network underlay vlan subnet
EnableMetrics bool
tunnelIface string
Iface string
DPDKTunnelIface string
MTU int
MSS int
EnableMirror bool
MirrorNic string
BindSocket string
OvsSocket string
KubeConfigFile string
KubeClient kubernetes.Interface
KubeOvnClient clientset.Interface
NodeName string
ServiceClusterIPRange string
NodeSwitch string
EncapChecksum bool
EnablePprof bool
MacLearningFallback bool
PprofPort int
NetworkType string
CniConfDir string
CniConfFile string
CniConfName string
DefaultProviderName string
DefaultInterfaceName string
ExternalGatewayConfigNS string
ExternalGatewaySwitch string // provider network underlay vlan subnet
EnableMetrics bool
EnableArpDetectIPConflict bool
}

// ParseFlags will parse cmd args then init kubeClient and configuration
Expand All @@ -79,15 +80,16 @@ func ParseFlags() *Configuration {
argPprofPort = pflag.Int("pprof-port", 10665, "The port to get profiling data")
argMacLearningFallback = pflag.Bool("mac-learning-fallback", false, "Fallback to the legacy MAC learning mode")

argsNetworkType = pflag.String("network-type", util.NetworkTypeGeneve, "Tunnel encapsulation protocol in overlay networks")
argCniConfDir = pflag.String("cni-conf-dir", "/etc/cni/net.d", "Path of the CNI config directory.")
argCniConfFile = pflag.String("cni-conf-file", "/kube-ovn/01-kube-ovn.conflist", "Path of the CNI config file.")
argsCniConfName = pflag.String("cni-conf-name", "01-kube-ovn.conflist", "Specify the name of kube ovn conflist name in dir /etc/cni/net.d/, default: 01-kube-ovn.conflist")
argsDefaultProviderName = pflag.String("default-provider-name", "provider", "The vlan or vxlan type default provider interface name")
argsDefaultInterfaceName = pflag.String("default-interface-name", "", "The default host interface name in the vlan/vxlan type")
argExternalGatewayConfigNS = pflag.String("external-gateway-config-ns", "kube-system", "The namespace of configmap external-gateway-config, default: kube-system")
argExternalGatewaySwitch = pflag.String("external-gateway-switch", "external", "The name of the external gateway switch which is a ovs bridge to provide external network, default: external")
argEnableMetrics = pflag.Bool("enable-metrics", true, "Whether to support metrics query")
argsNetworkType = pflag.String("network-type", util.NetworkTypeGeneve, "Tunnel encapsulation protocol in overlay networks")
argCniConfDir = pflag.String("cni-conf-dir", "/etc/cni/net.d", "Path of the CNI config directory.")
argCniConfFile = pflag.String("cni-conf-file", "/kube-ovn/01-kube-ovn.conflist", "Path of the CNI config file.")
argsCniConfName = pflag.String("cni-conf-name", "01-kube-ovn.conflist", "Specify the name of kube ovn conflist name in dir /etc/cni/net.d/, default: 01-kube-ovn.conflist")
argsDefaultProviderName = pflag.String("default-provider-name", "provider", "The vlan or vxlan type default provider interface name")
argsDefaultInterfaceName = pflag.String("default-interface-name", "", "The default host interface name in the vlan/vxlan type")
argExternalGatewayConfigNS = pflag.String("external-gateway-config-ns", "kube-system", "The namespace of configmap external-gateway-config, default: kube-system")
argExternalGatewaySwitch = pflag.String("external-gateway-switch", "external", "The name of the external gateway switch which is a ovs bridge to provide external network, default: external")
argEnableMetrics = pflag.Bool("enable-metrics", true, "Whether to support metrics query")
argEnableArpDetectIPConflict = pflag.Bool("enable-arp-detect-ip-conflict", true, "Whether to support arp detect ip conflict in vlan network")
)

// mute info log for ipset lib
Expand All @@ -112,30 +114,31 @@ func ParseFlags() *Configuration {
pflag.Parse()

config := &Configuration{
Iface: *argIface,
DPDKTunnelIface: *argDPDKTunnelIface,
MTU: *argMTU,
EnableMirror: *argEnableMirror,
MirrorNic: *argMirrorNic,
BindSocket: *argBindSocket,
OvsSocket: *argOvsSocket,
KubeConfigFile: *argKubeConfigFile,
EnablePprof: *argEnablePprof,
PprofPort: *argPprofPort,
MacLearningFallback: *argMacLearningFallback,
NodeName: strings.ToLower(*argNodeName),
ServiceClusterIPRange: *argServiceClusterIPRange,
NodeSwitch: *argNodeSwitch,
EncapChecksum: *argEncapChecksum,
NetworkType: *argsNetworkType,
CniConfDir: *argCniConfDir,
CniConfFile: *argCniConfFile,
CniConfName: *argsCniConfName,
DefaultProviderName: *argsDefaultProviderName,
DefaultInterfaceName: *argsDefaultInterfaceName,
ExternalGatewayConfigNS: *argExternalGatewayConfigNS,
ExternalGatewaySwitch: *argExternalGatewaySwitch,
EnableMetrics: *argEnableMetrics,
Iface: *argIface,
DPDKTunnelIface: *argDPDKTunnelIface,
MTU: *argMTU,
EnableMirror: *argEnableMirror,
MirrorNic: *argMirrorNic,
BindSocket: *argBindSocket,
OvsSocket: *argOvsSocket,
KubeConfigFile: *argKubeConfigFile,
EnablePprof: *argEnablePprof,
PprofPort: *argPprofPort,
MacLearningFallback: *argMacLearningFallback,
NodeName: strings.ToLower(*argNodeName),
ServiceClusterIPRange: *argServiceClusterIPRange,
NodeSwitch: *argNodeSwitch,
EncapChecksum: *argEncapChecksum,
NetworkType: *argsNetworkType,
CniConfDir: *argCniConfDir,
CniConfFile: *argCniConfFile,
CniConfName: *argsCniConfName,
DefaultProviderName: *argsDefaultProviderName,
DefaultInterfaceName: *argsDefaultInterfaceName,
ExternalGatewayConfigNS: *argExternalGatewayConfigNS,
ExternalGatewaySwitch: *argExternalGatewaySwitch,
EnableMetrics: *argEnableMetrics,
EnableArpDetectIPConflict: *argEnableArpDetectIPConflict,
}
return config
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/daemon/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,11 @@ func (csh cniServerHandler) handleAdd(req *restful.Request, resp *restful.Respon
u2oInterconnectionIP = podSubnet.Status.U2OInterconnectionIP
}

detectIPConflict := podSubnet.Spec.Vlan != ""
subnetHasVlan := podSubnet.Spec.Vlan != ""
detectIPConflict := csh.Config.EnableArpDetectIPConflict && subnetHasVlan
// skip ping check gateway for pods during live migration
if pod.Annotations[fmt.Sprintf(util.LiveMigrationAnnotationTemplate, podRequest.Provider)] != "true" {
if podSubnet.Spec.Vlan != "" && !podSubnet.Spec.LogicalGateway {
if subnetHasVlan && !podSubnet.Spec.LogicalGateway {
if podSubnet.Spec.DisableGatewayCheck {
gatewayCheckMode = gatewayCheckModeArpingNotConcerned
} else {
Expand Down

0 comments on commit e2bf60f

Please sign in to comment.