Overlay MTU is 20 bytes too large on an IPv6 Swarm data path
Description
The overlay driver sets a container's overlay interface MTU to the network's base MTU (1500 unless com.docker.network.driver.mtu is set) minus a fixed 50-byte VXLAN allowance. The allowance assumes an IPv4 outer header. On an IPv6 Swarm data path the overhead is 70 bytes:
| Header | Allowance | IPv6 data path |
|---|---|---|
| Inner Ethernet | 14 | 14 |
| Outer IP | 20 | 40 |
| UDP | 8 | 8 |
| VXLAN | 8 | 8 |
| Total | 50 | 70 |
The container's MTU is therefore 20 bytes larger than the path can carry.
On a 1500-byte underlay the container's interface MTU is 1450, but with the don't-fragment bit set only packets up to 1430 bytes cross between nodes. Anything sized to the interface MTU, TCP's MSS included, is 20 bytes too large for the path.
In my test the 1450-byte DF send failed with EMSGSIZE because the sending container's kernel had already learned the lower path MTU. Full-size packets depend on path MTU discovery to get through.
Reproduce
- Two Linux hosts with IPv6 connectivity to each other, on a network with a 1500-byte MTU.
- On host 1:
docker swarm init --advertise-addr <host1-ipv6> - On host 2:
docker swarm join --advertise-addr <host2-ipv6> --token <token> [<host1-ipv6>]:2377 - On host 1:
docker network create -d overlay --attachable ov docker run -d --name target --network ov alpine sleep infinity - On host 2:
docker run --rm --network ov alpine sh -c ' cat /sys/class/net/eth0/mtu apk add -q iputils ping -c1 -W2 -M do -s 1402 target # 1430-byte IP packet ping -c1 -W2 -M do -s 1422 target # 1450-byte IP packet '
The interface MTU is 1450. The first ping gets a reply. The second fails.
An IPv4 control plane with an IPv6 --data-path-addr gives the same result.
Expected behavior
The overlay interface MTU is the largest packet that crosses the data path: 1430 on a 1500-byte IPv6 underlay.
docker version
The bug is in every release since v25.0.0, which added IPv6 data-path support (#46790), and on master.
docker info
The bug does not depend on the environment beyond an IPv6 data-path address.
Additional Info
- The allowance is
vxlanEncap = 50indaemon/libnetwork/drivers/overlay/overlay.go. It is subtracted in(*network).maxMTU, which sets both the VXLAN link's MTU and the container's interface MTU. The kernel's allowance for VXLAN over IPv6 is 70 bytes (VXLAN6_HEADROOM). - Encrypted overlays subtract the same allowance before the ESP overhead. On an IPv6 data path they should get an MTU of 1424 where the path fits 1404 (1500 − 70 − 26). I have not measured this.
- Workaround: create the network with
com.docker.network.driver.mtuset 20 bytes below the underlay MTU, e.g.--opt com.docker.network.driver.mtu=1480on a 1500-byte underlay. The allowance is subtracted from that value, giving 1430, or 1404 on an encrypted network. setupSubnetSandboxcallsisIPv6Transport()to configure the VXLAN link for IPv6 peers.maxMTUcould choose its allowance the same way.
Source: moby/moby