Skip to content

Commit

Permalink
Configure MTU of ENI and veths to 9001
Browse files Browse the repository at this point in the history
* Add LinkSetMTU wrapper and  mocks
* Add call to ENI setup and network test
* Change hardcoded veth MTU to 9001
  • Loading branch information
Hiroki Mizuma committed Oct 24, 2018
1 parent 3735b4a commit f905abd
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
12 changes: 12 additions & 0 deletions pkg/netlinkwrapper/mocks/netlinkwrapper_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/netlinkwrapper/netlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type NetLink interface {
NewRule() *netlink.Rule
RuleDel(rule *netlink.Rule) error
RuleAdd(rule *netlink.Rule) error
// LinkSetMTU is equivalent to `ip link set dev $link mtu $mtu`
LinkSetMTU(link netlink.Link, mtu int) error
}

type netLink struct {
Expand Down Expand Up @@ -122,3 +124,7 @@ func (*netLink) RuleDel(rule *netlink.Rule) error {
func (*netLink) RuleAdd(rule *netlink.Rule) error {
return netlink.RuleAdd(rule)
}

func (*netLink) LinkSetMTU(link netlink.Link, mtu int) error {
return netlink.LinkSetMTU(link, mtu)
}
7 changes: 7 additions & 0 deletions pkg/networkutils/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ const (
// - kube-proxy uses 0x0000c000
// - Calico uses 0xffff0000.
defaultConnmark = 0x80

// MTU of ENI - veth MTU defined in plugins/routed-eni/driver/driver.go
ethernetMTU = 9001
)

// NetworkAPIs defines the host level and the eni level network related operations
Expand Down Expand Up @@ -408,6 +411,10 @@ func setupENINetwork(eniIP string, eniMAC string, eniTable int, eniSubnetCIDR st
return errors.Wrapf(err, "eni network setup: failed to find the link which uses mac address %s", eniMAC)
}

if err = netLink.LinkSetMTU(link, ethernetMTU); err != nil {
return errors.Wrapf(err, "eni network setup: failed to set MTU for %s", eniIP)
}

if err = netLink.LinkSetUp(link); err != nil {
return errors.Wrapf(err, "eni network setup: failed to bring up eni %s", eniIP)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/networkutils/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const (
testeniIP = "10.10.10.20"
testeniMAC = "01:23:45:67:89:ab"
testeniSubnet = "10.10.0.0/16"
// Default MTU of ENI and veth
// defined in plugins/routed-eni/driver/driver.go, pkg/networkutils/network.go
testMTU = 9001
)

var (
Expand Down Expand Up @@ -88,6 +91,7 @@ func TestSetupENINetwork(t *testing.T) {
lo.EXPECT().Attrs().Return(mockLinkAttrs1)
eth1.EXPECT().Attrs().Return(mockLinkAttrs2)

mockNetLink.EXPECT().LinkSetMTU(gomock.Any(), testMTU).Return(nil)
mockNetLink.EXPECT().LinkSetUp(gomock.Any()).Return(nil)

// eth1's device
Expand Down
4 changes: 2 additions & 2 deletions plugins/routed-eni/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const (

// TODO need to test all distros use this number
mainRouteTable = 254

ethernetMTU = 1500
// MTU of veth - ENI MTU defined in pkg/networkutils/network.go
ethernetMTU = 9001
)

// NetworkAPIs defines network API calls
Expand Down

1 comment on commit f905abd

@gtaylor
Copy link

@gtaylor gtaylor commented on f905abd Nov 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my own understanding, does this mean that we wouldn't have jumbo frames for cluster networking on amazon-vpc-cni-k8s 1.2.1?

Please sign in to comment.