From d11fe519f204d655a86212ed3aa59377e79c1ac3 Mon Sep 17 00:00:00 2001 From: Rahul Jain Date: Fri, 3 Jul 2020 08:44:18 +0530 Subject: [PATCH] Auto discovery mtu Discover mtu of primary interface if defaultMTU param is not set in the antrea.yaml --- build/yamls/antrea-eks.yml | 12 +++--- build/yamls/antrea-gke.yml | 12 +++--- build/yamls/antrea-ipsec.yml | 12 +++--- build/yamls/antrea-windows.yml | 10 ++--- build/yamls/antrea.yml | 12 +++--- build/yamls/base/conf/antrea-agent.conf | 6 +-- .../yamls/windows/base/conf/antrea-agent.conf | 6 +-- cmd/antrea-agent/agent.go | 1 - cmd/antrea-agent/options.go | 28 ------------- docs/configuration.md | 6 +-- docs/eks-installation.md | 5 +-- docs/gke-installation.md | 4 +- pkg/agent/agent.go | 41 ++++++++++++++++--- pkg/agent/cniserver/server.go | 5 +-- pkg/agent/config/node_config.go | 13 ++++++ pkg/agent/util/net.go | 23 +++++++++++ pkg/agent/util/net_linux.go | 23 ----------- pkg/agent/util/net_windows.go | 23 ----------- test/integration/agent/cniserver_test.go | 6 +-- test/integration/agent/route_test.go | 3 +- 20 files changed, 120 insertions(+), 131 deletions(-) diff --git a/build/yamls/antrea-eks.yml b/build/yamls/antrea-eks.yml index 45f2fd02e75..3068a0f5767 100644 --- a/build/yamls/antrea-eks.yml +++ b/build/yamls/antrea-eks.yml @@ -550,9 +550,9 @@ data: # - stt #tunnelType: geneve - # Default MTU to use for the host gateway interface and the network interface of each Pod. If - # omitted, antrea-agent will default this value to 1450 to accommodate for tunnel encapsulate - # overhead. + # Default MTU to use for the host gateway interface and the network interface of each Pod. + # If omitted, antrea-agent will discover the MTU of the Node's primary interface and + # also adjust MTU to accommodate for tunnel encapsulation overhead (if applicable). #defaultMTU: 1450 # Whether or not to enable IPsec encryption of tunnel traffic. IPsec encryption is only supported @@ -627,7 +627,7 @@ metadata: annotations: {} labels: app: antrea - name: antrea-config-9cf7tk2d9b + name: antrea-config-hhthk4g2f4 namespace: kube-system --- apiVersion: v1 @@ -733,7 +733,7 @@ spec: key: node-role.kubernetes.io/master volumes: - configMap: - name: antrea-config-9cf7tk2d9b + name: antrea-config-hhthk4g2f4 name: antrea-config - name: antrea-controller-tls secret: @@ -950,7 +950,7 @@ spec: operator: Exists volumes: - configMap: - name: antrea-config-9cf7tk2d9b + name: antrea-config-hhthk4g2f4 name: antrea-config - hostPath: path: /etc/cni/net.d diff --git a/build/yamls/antrea-gke.yml b/build/yamls/antrea-gke.yml index 4e25e25c95e..1c22307861c 100644 --- a/build/yamls/antrea-gke.yml +++ b/build/yamls/antrea-gke.yml @@ -550,9 +550,9 @@ data: # - stt #tunnelType: geneve - # Default MTU to use for the host gateway interface and the network interface of each Pod. If - # omitted, antrea-agent will default this value to 1450 to accommodate for tunnel encapsulate - # overhead. + # Default MTU to use for the host gateway interface and the network interface of each Pod. + # If omitted, antrea-agent will discover the MTU of the Node's primary interface and + # also adjust MTU to accommodate for tunnel encapsulation overhead (if applicable). #defaultMTU: 1450 # Whether or not to enable IPsec encryption of tunnel traffic. IPsec encryption is only supported @@ -627,7 +627,7 @@ metadata: annotations: {} labels: app: antrea - name: antrea-config-mggd25d555 + name: antrea-config-mbkmc9bb22 namespace: kube-system --- apiVersion: v1 @@ -733,7 +733,7 @@ spec: key: node-role.kubernetes.io/master volumes: - configMap: - name: antrea-config-mggd25d555 + name: antrea-config-mbkmc9bb22 name: antrea-config - name: antrea-controller-tls secret: @@ -948,7 +948,7 @@ spec: operator: Exists volumes: - configMap: - name: antrea-config-mggd25d555 + name: antrea-config-mbkmc9bb22 name: antrea-config - hostPath: path: /etc/cni/net.d diff --git a/build/yamls/antrea-ipsec.yml b/build/yamls/antrea-ipsec.yml index 1c5405c896e..be5d81446d2 100644 --- a/build/yamls/antrea-ipsec.yml +++ b/build/yamls/antrea-ipsec.yml @@ -550,9 +550,9 @@ data: # - stt tunnelType: gre - # Default MTU to use for the host gateway interface and the network interface of each Pod. If - # omitted, antrea-agent will default this value to 1450 to accommodate for tunnel encapsulate - # overhead. + # Default MTU to use for the host gateway interface and the network interface of each Pod. + # If omitted, antrea-agent will discover the MTU of the Node's primary interface and + # also adjust MTU to accommodate for tunnel encapsulation overhead (if applicable). #defaultMTU: 1450 # Whether or not to enable IPsec encryption of tunnel traffic. IPsec encryption is only supported @@ -627,7 +627,7 @@ metadata: annotations: {} labels: app: antrea - name: antrea-config-ch9mhb526k + name: antrea-config-5tkdbb96c6 namespace: kube-system --- apiVersion: v1 @@ -742,7 +742,7 @@ spec: key: node-role.kubernetes.io/master volumes: - configMap: - name: antrea-config-ch9mhb526k + name: antrea-config-5tkdbb96c6 name: antrea-config - name: antrea-controller-tls secret: @@ -992,7 +992,7 @@ spec: operator: Exists volumes: - configMap: - name: antrea-config-ch9mhb526k + name: antrea-config-5tkdbb96c6 name: antrea-config - hostPath: path: /etc/cni/net.d diff --git a/build/yamls/antrea-windows.yml b/build/yamls/antrea-windows.yml index 59ffb0435da..39e1117f419 100644 --- a/build/yamls/antrea-windows.yml +++ b/build/yamls/antrea-windows.yml @@ -37,9 +37,9 @@ data: # - stt #tunnelType: geneve - # Default MTU to use for the host gateway interface and the network interface of each Pod. If - # omitted, antrea-agent will default this value to 1450 to accommodate for tunnel encapsulate - # overhead. + # Default MTU to use for the host gateway interface and the network interface of each Pod. + # If omitted, antrea-agent will discover the MTU of the Node's primary interface and + # also adjust MTU to accommodate for tunnel encapsulation overhead. #defaultMTU: 1450 # CIDR Range for services in cluster. It's required to support egress network policy, should @@ -69,7 +69,7 @@ kind: ConfigMap metadata: labels: app: antrea - name: antrea-windows-config-2b4h888dt2 + name: antrea-windows-config-k24chf74ct namespace: kube-system --- apiVersion: apps/v1 @@ -157,7 +157,7 @@ spec: operator: Exists volumes: - configMap: - name: antrea-windows-config-2b4h888dt2 + name: antrea-windows-config-k24chf74ct name: antrea-windows-config - configMap: defaultMode: 420 diff --git a/build/yamls/antrea.yml b/build/yamls/antrea.yml index 7a989be3b15..3ee5624ba0b 100644 --- a/build/yamls/antrea.yml +++ b/build/yamls/antrea.yml @@ -550,9 +550,9 @@ data: # - stt #tunnelType: geneve - # Default MTU to use for the host gateway interface and the network interface of each Pod. If - # omitted, antrea-agent will default this value to 1450 to accommodate for tunnel encapsulate - # overhead. + # Default MTU to use for the host gateway interface and the network interface of each Pod. + # If omitted, antrea-agent will discover the MTU of the Node's primary interface and + # also adjust MTU to accommodate for tunnel encapsulation overhead (if applicable). #defaultMTU: 1450 # Whether or not to enable IPsec encryption of tunnel traffic. IPsec encryption is only supported @@ -627,7 +627,7 @@ metadata: annotations: {} labels: app: antrea - name: antrea-config-btd998c7bt + name: antrea-config-hc2t9429cd namespace: kube-system --- apiVersion: v1 @@ -733,7 +733,7 @@ spec: key: node-role.kubernetes.io/master volumes: - configMap: - name: antrea-config-btd998c7bt + name: antrea-config-hc2t9429cd name: antrea-config - name: antrea-controller-tls secret: @@ -948,7 +948,7 @@ spec: operator: Exists volumes: - configMap: - name: antrea-config-btd998c7bt + name: antrea-config-hc2t9429cd name: antrea-config - hostPath: path: /etc/cni/net.d diff --git a/build/yamls/base/conf/antrea-agent.conf b/build/yamls/base/conf/antrea-agent.conf index e373043dd58..50412a91ea5 100644 --- a/build/yamls/base/conf/antrea-agent.conf +++ b/build/yamls/base/conf/antrea-agent.conf @@ -31,9 +31,9 @@ featureGates: # - stt #tunnelType: geneve -# Default MTU to use for the host gateway interface and the network interface of each Pod. If -# omitted, antrea-agent will default this value to 1450 to accommodate for tunnel encapsulate -# overhead. +# Default MTU to use for the host gateway interface and the network interface of each Pod. +# If omitted, antrea-agent will discover the MTU of the Node's primary interface and +# also adjust MTU to accommodate for tunnel encapsulation overhead (if applicable). #defaultMTU: 1450 # Whether or not to enable IPsec encryption of tunnel traffic. IPsec encryption is only supported diff --git a/build/yamls/windows/base/conf/antrea-agent.conf b/build/yamls/windows/base/conf/antrea-agent.conf index cc39712c66c..17dce0acfec 100644 --- a/build/yamls/windows/base/conf/antrea-agent.conf +++ b/build/yamls/windows/base/conf/antrea-agent.conf @@ -19,9 +19,9 @@ featureGates: # - stt #tunnelType: geneve -# Default MTU to use for the host gateway interface and the network interface of each Pod. If -# omitted, antrea-agent will default this value to 1450 to accommodate for tunnel encapsulate -# overhead. +# Default MTU to use for the host gateway interface and the network interface of each Pod. +# If omitted, antrea-agent will discover the MTU of the Node's primary interface and +# also adjust MTU to accommodate for tunnel encapsulation overhead. #defaultMTU: 1450 # CIDR Range for services in cluster. It's required to support egress network policy, should diff --git a/cmd/antrea-agent/agent.go b/cmd/antrea-agent/agent.go index 09a895eda6e..2dd9386f02e 100644 --- a/cmd/antrea-agent/agent.go +++ b/cmd/antrea-agent/agent.go @@ -163,7 +163,6 @@ func run(o *Options) error { cniServer := cniserver.New( o.config.CNISocket, o.config.HostProcPathPrefix, - o.config.DefaultMTU, nodeConfig, k8sClient, podUpdates, diff --git a/cmd/antrea-agent/options.go b/cmd/antrea-agent/options.go index 97431cb86a5..b8203ac43fa 100644 --- a/cmd/antrea-agent/options.go +++ b/cmd/antrea-agent/options.go @@ -35,14 +35,6 @@ const ( defaultHostProcPathPrefix = "/host" defaultServiceCIDR = "10.96.0.0/12" defaultTunnelType = ovsconfig.GeneveTunnel - defaultMTUGeneve = 1450 - defaultMTUVXLAN = 1450 - defaultMTUGRE = 1462 - defaultMTUSTT = 1500 - defaultMTU = 1500 - // IPsec ESP can add a maximum of 38 bytes to the packet including the ESP - // header and trailer. - ipsecESPOverhead = 38 ) type Options struct { @@ -151,26 +143,6 @@ func (o *Options) setDefaults() { if o.config.TrafficEncapMode == "" { o.config.TrafficEncapMode = config.TrafficEncapModeEncap.String() } - - if o.config.DefaultMTU == 0 { - ok, encapMode := config.GetTrafficEncapModeFromStr(o.config.TrafficEncapMode) - if ok && !encapMode.SupportsEncap() { - o.config.DefaultMTU = defaultMTU - } else if o.config.TunnelType == ovsconfig.VXLANTunnel { - o.config.DefaultMTU = defaultMTUVXLAN - } else if o.config.TunnelType == ovsconfig.GeneveTunnel { - o.config.DefaultMTU = defaultMTUGeneve - } else if o.config.TunnelType == ovsconfig.GRETunnel { - o.config.DefaultMTU = defaultMTUGRE - } else if o.config.TunnelType == ovsconfig.STTTunnel { - o.config.DefaultMTU = defaultMTUSTT - } - - if o.config.EnableIPSecTunnel { - o.config.DefaultMTU -= ipsecESPOverhead - } - } - if o.config.APIPort == 0 { o.config.APIPort = apis.AntreaAgentAPIPort } diff --git a/docs/configuration.md b/docs/configuration.md index 591a3500dc9..21bda1d2ba3 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -51,9 +51,9 @@ Use `antrea-agent -h` to see complete options. # for the GRE tunnel type. #enableIPSecTunnel: false -# Default MTU to use for the host gateway interface and the network interface of -# each Pod. If omitted, antrea-agent will default this value to 1450 to accommodate -# for tunnel encapsulate overhead. +# Default MTU to use for the host gateway interface and the network interface of each Pod. +# If omitted, antrea-agent will discover the MTU of the Node's primary interface and +# also adjust MTU to accommodate for tunnel encapsulation overhead (if applicable). #defaultMTU: 1450 # CIDR Range for services in cluster. It's required to support egress network policy, should diff --git a/docs/eks-installation.md b/docs/eks-installation.md index 88ec7ceaa07..92df7e7c739 100644 --- a/docs/eks-installation.md +++ b/docs/eks-installation.md @@ -20,9 +20,8 @@ deployment yaml at: https://raw.githubusercontent.com/vmware-tanzu/antrea/master/build/yamls/antrea-eks.yml ``` -Based on EKS worker Node MTU size and Kubernetes service cluster IP range, adjust -``defaultMTU`` and ``serviceCIDR`` values of antrea-agent.conf in antrea-eks.yml - accordingly, and apply antrea-eks.yml to the EKS cluster. +Based on Kubernetes service cluster IP range, adjust ``serviceCIDR`` values of antrea-agent.conf +in antrea-eks.yml accordingly, and apply antrea-eks.yml to the EKS cluster. ```bash kubectl apply -f antrea-eks.yaml diff --git a/docs/gke-installation.md b/docs/gke-installation.md index 569cf2d1cb0..9419cc3f26e 100644 --- a/docs/gke-installation.md +++ b/docs/gke-installation.md @@ -94,8 +94,8 @@ For any given release `` (e.g. `v0.5.0`), get the Antrea GKE deployment yam https://raw.githubusercontent.com/vmware-tanzu/antrea/master/build/yamls/antrea-gke.yml ```` - Update ``defaultMTU`` (default is 1500) and ``serviceCIDR`` value of antrea-agent.conf in antrea-gke.yml with -GKE_SERVICE_CIDR selected at the time of deploying GKE cluster. + Update ``serviceCIDR`` value of antrea-agent.conf in antrea-gke.yml with GKE_SERVICE_CIDR selected at the time of + deploying GKE cluster. 3. Deploy Antrea diff --git a/pkg/agent/agent.go b/pkg/agent/agent.go index 9d0ee46c8e1..0f4f28471e3 100644 --- a/pkg/agent/agent.go +++ b/pkg/agent/agent.go @@ -61,8 +61,8 @@ type Initializer struct { routeClient route.Interface ifaceStore interfacestore.InterfaceStore ovsBridge string - hostGateway string // name of gateway port on the OVS bridge - mtu int // Pod network interface MTU + hostGateway string // name of gateway port on the OVS bridge + mtu int serviceCIDR *net.IPNet // K8s Service ClusterIP CIDR networkConfig *config.NetworkConfig nodeConfig *config.NodeConfig @@ -412,9 +412,9 @@ func (i *Initializer) setupGatewayInterface() error { // Idempotent operation to set the gateway's MTU: we perform this operation regardless of // whether or not the gateway interface already exists, as the desired MTU may change across // restarts. - klog.V(4).Infof("Setting gateway interface %s MTU to %d", i.hostGateway, i.mtu) + klog.V(4).Infof("Setting gateway interface %s MTU to %d", i.hostGateway, i.nodeConfig.NodeMTU) - i.ovsBridgeClient.SetInterfaceMTU(i.hostGateway, i.mtu) + i.ovsBridgeClient.SetInterfaceMTU(i.hostGateway, i.nodeConfig.NodeMTU) if err := i.configureGatewayInterface(gatewayIface); err != nil { return err } @@ -543,16 +543,23 @@ func (i *Initializer) initNodeLocalConfig() error { if err != nil { return fmt.Errorf("failed to obtain local IP address from k8s: %w", err) } - localAddr, _, err := util.GetIPNetDeviceFromIP(ipAddr) + localAddr, localIntf, err := util.GetIPNetDeviceFromIP(ipAddr) if err != nil { return fmt.Errorf("failed to get local IPNet: %v", err) } + mtu, err := i.getNodeMTU(localIntf) + if err != nil { + return err + } + klog.Infof("Setting Node MTU=%d", mtu) + i.nodeConfig = &config.NodeConfig{ Name: nodeName, OVSBridge: i.ovsBridge, DefaultTunName: defaultTunInterfaceName, NodeIPAddr: localAddr, + NodeMTU: mtu, UplinkNetConfig: new(config.AdapterNetConfig)} if i.networkConfig.TrafficEncapMode.IsNetworkPolicyOnly() { @@ -641,3 +648,27 @@ func getRoundInfo(bridgeClient ovsconfig.OVSBridgeClient) types.RoundInfo { return roundInfo } + +func (i *Initializer) getNodeMTU(localIntf *net.Interface) (int, error) { + if i.mtu != 0 { + return i.mtu, nil + } + mtu := localIntf.MTU + // Make sure mtu is set on the interface. + if mtu <= 0 { + return 0, fmt.Errorf("Failed to fetch Node MTU : %v", mtu) + } + if i.networkConfig.TrafficEncapMode.SupportsEncap() { + if i.networkConfig.TunnelType == ovsconfig.VXLANTunnel { + mtu -= config.VXLANOverhead + } else if i.networkConfig.TunnelType == ovsconfig.GeneveTunnel { + mtu -= config.GeneveOverhead + } else if i.networkConfig.TunnelType == ovsconfig.GRETunnel { + mtu -= config.GREOverhead + } + } + if i.networkConfig.EnableIPSecTunnel { + mtu -= config.IpsecESPOverhead + } + return mtu, nil +} diff --git a/pkg/agent/cniserver/server.go b/pkg/agent/cniserver/server.go index ed165719f07..96c63a43f25 100644 --- a/pkg/agent/cniserver/server.go +++ b/pkg/agent/cniserver/server.go @@ -93,7 +93,6 @@ type CNIServer struct { serverVersion string nodeConfig *config.NodeConfig hostProcPathPrefix string - defaultMTU int kubeClient clientset.Interface containerAccess *containerAccessArbitrator podConfigurator *podConfigurator @@ -182,7 +181,7 @@ func (s *CNIServer) loadNetworkConfig(request *cnipb.CniCmdRequest) (*CNIConfig, s.updateLocalIPAMSubnet(cniConfig) } if cniConfig.MTU == 0 { - cniConfig.MTU = s.defaultMTU + cniConfig.MTU = s.nodeConfig.NodeMTU } klog.Infof("Load network configurations: %v", cniConfig) return cniConfig, nil @@ -496,7 +495,6 @@ func (s *CNIServer) CmdCheck(_ context.Context, request *cnipb.CniCmdRequest) ( func New( cniSocket, hostProcPathPrefix string, - defaultMTU int, nodeConfig *config.NodeConfig, kubeClient clientset.Interface, podUpdates chan<- v1beta1.PodReference, @@ -509,7 +507,6 @@ func New( serverVersion: cni.AntreaCNIVersion, nodeConfig: nodeConfig, hostProcPathPrefix: hostProcPathPrefix, - defaultMTU: defaultMTU, kubeClient: kubeClient, containerAccess: newContainerAccessArbitrator(), podUpdates: podUpdates, diff --git a/pkg/agent/config/node_config.go b/pkg/agent/config/node_config.go index def42a4935d..ecf7c82c2a4 100644 --- a/pkg/agent/config/node_config.go +++ b/pkg/agent/config/node_config.go @@ -33,6 +33,15 @@ const ( BridgeOFPort = 0xfffffffe ) +const ( + VXLANOverhead = 50 + GeneveOverhead = 50 + GREOverhead = 38 + // IPsec ESP can add a maximum of 38 bytes to the packet including the ESP + // header and trailer. + IpsecESPOverhead = 38 +) + type GatewayConfig struct { // Name is the name of host gateway, e.g. antrea-gw0. Name string @@ -69,6 +78,10 @@ type NodeConfig struct { PodCIDR *net.IPNet // The Node's IP used in Kubernetes. It has the network mask information. NodeIPAddr *net.IPNet + // Set either via defaultMTU config in antrea.yaml or auto discovered. + // Auto discovery will use MTU value of the Node's primary interface. + // For Encap and Hybrid mode, Node MTU will be adjusted to account for encap header. + NodeMTU int // The config of the gateway interface on the OVS bridge. GatewayConfig *GatewayConfig // The config of the OVS bridge uplink interface. Only for Windows Node. diff --git a/pkg/agent/util/net.go b/pkg/agent/util/net.go index a06cfe4d0a5..195ced6294c 100644 --- a/pkg/agent/util/net.go +++ b/pkg/agent/util/net.go @@ -95,3 +95,26 @@ func listenUnix(address string) (net.Listener, error) { func dialUnix(address string) (net.Conn, error) { return net.Dial("unix", address) } + +// GetIPNetDeviceFromIP returns a local IP/mask and associated device from IP. +func GetIPNetDeviceFromIP(localIP net.IP) (*net.IPNet, *net.Interface, error) { + linkList, err := net.Interfaces() + if err != nil { + return nil, nil, err + } + + for _, link := range linkList { + addrList, err := link.Addrs() + if err != nil { + continue + } + for _, addr := range addrList { + if ipNet, ok := addr.(*net.IPNet); ok { + if ipNet.IP.Equal(localIP) { + return ipNet, &link, nil + } + } + } + } + return nil, nil, fmt.Errorf("unable to find local IP and device") +} diff --git a/pkg/agent/util/net_linux.go b/pkg/agent/util/net_linux.go index 43d865b0037..66aacbe88e6 100644 --- a/pkg/agent/util/net_linux.go +++ b/pkg/agent/util/net_linux.go @@ -25,32 +25,9 @@ import ( "github.com/containernetworking/plugins/pkg/ip" "github.com/containernetworking/plugins/pkg/ns" "github.com/vishvananda/netlink" - "golang.org/x/sys/unix" "k8s.io/klog" ) -// GetIPNetDeviceFromIP returns a local IP/mask and associated device from IP. -func GetIPNetDeviceFromIP(localIP net.IP) (*net.IPNet, netlink.Link, error) { - linkList, err := netlink.LinkList() - if err != nil { - return nil, nil, err - } - - for _, link := range linkList { - addrList, err := netlink.AddrList(link, unix.AF_INET) - if err != nil { - klog.Errorf("Failed to get addr list for device %s", link) - continue - } - for _, addr := range addrList { - if addr.IP.Equal(localIP) { - return addr.IPNet, link, nil - } - } - } - return nil, nil, fmt.Errorf("unable to find local IP and device") -} - // GetNetLink returns dev link from name. func GetNetLink(dev string) netlink.Link { link, err := netlink.LinkByName(dev) diff --git a/pkg/agent/util/net_windows.go b/pkg/agent/util/net_windows.go index 4e51f9323c6..046f974f2ee 100644 --- a/pkg/agent/util/net_windows.go +++ b/pkg/agent/util/net_windows.go @@ -202,29 +202,6 @@ func EnableHNSNetworkExtension(hnsNetID string, vSwitchExtension string) error { return nil } -// GetIPNetDeviceFromIP returns a local IP/mask and associated device from IP. -func GetIPNetDeviceFromIP(localIP net.IP) (*net.IPNet, *net.Interface, error) { - linkList, err := net.Interfaces() - if err != nil { - return nil, nil, err - } - - for _, link := range linkList { - addrList, err := link.Addrs() - if err != nil { - continue - } - for _, addr := range addrList { - if ipNet, ok := addr.(*net.IPNet); ok { - if ipNet.IP.Equal(localIP) { - return ipNet, &link, nil - } - } - } - } - return nil, nil, fmt.Errorf("unable to find local IP and device") -} - func SetLinkUp(name string) (net.HardwareAddr, int, error) { // Set host gateway interface up. if err := EnableHostInterface(name); err != nil { diff --git a/test/integration/agent/cniserver_test.go b/test/integration/agent/cniserver_test.go index d3b9ed36424..0cfdb78bcb7 100644 --- a/test/integration/agent/cniserver_test.go +++ b/test/integration/agent/cniserver_test.go @@ -537,9 +537,9 @@ func (tester *cmdAddDelTester) cmdDelTest(tc testCase, dataDir string) { func newTester() *cmdAddDelTester { tester := &cmdAddDelTester{} ifaceStore := interfacestore.NewInterfaceStore() + testNodeConfig.NodeMTU = 1450 tester.server = cniserver.New(testSock, "", - 1450, testNodeConfig, k8sFake.NewSimpleClientset(), make(chan v1beta1.PodReference, 100), @@ -679,7 +679,6 @@ func setupChainTest( routeMock = routetest.NewMockInterface(controller) server = cniserver.New(testSock, "", - 1500, testNodeConfig, k8sFake.NewSimpleClientset(), make(chan v1beta1.PodReference, 100), @@ -803,6 +802,7 @@ func init() { gwMAC, _ = net.ParseMAC("11:11:11:11:11:11") nodeGateway := &config.GatewayConfig{IP: gwIP, MAC: gwMAC, Name: ""} _, nodePodCIDR, _ := net.ParseCIDR("192.168.1.0/24") + nodeMTU := 1500 - testNodeConfig = &config.NodeConfig{Name: nodeName, PodCIDR: nodePodCIDR, GatewayConfig: nodeGateway} + testNodeConfig = &config.NodeConfig{Name: nodeName, PodCIDR: nodePodCIDR, NodeMTU: nodeMTU, GatewayConfig: nodeGateway} } diff --git a/test/integration/agent/route_test.go b/test/integration/agent/route_test.go index e2613c7a577..b6c2c8b4f5f 100644 --- a/test/integration/agent/route_test.go +++ b/test/integration/agent/route_test.go @@ -46,11 +46,12 @@ func ExecOutputTrim(cmd string) (string, error) { var ( _, podCIDR, _ = net.ParseCIDR("10.10.10.0/24") - nodeIP, nodeLink, _ = util.GetIPNetDeviceFromIP(func() net.IP { + nodeIP, nodeIntf, _ = util.GetIPNetDeviceFromIP(func() net.IP { conn, _ := net.Dial("udp", "8.8.8.8:80") defer conn.Close() return conn.LocalAddr().(*net.UDPAddr).IP }()) + nodeLink, _ = netlink.LinkByName(nodeIntf.Name) localPeerIP = ip.NextIP(nodeIP.IP) remotePeerIP = net.ParseIP("50.50.50.1") _, serviceCIDR, _ = net.ParseCIDR("200.200.0.0/16")