Skip to content

Commit

Permalink
Add --default-mtu. Change default to 65535 (from 9000).
Browse files Browse the repository at this point in the history
MTU of 9000 was an arbitrary jumbo frame size. Setting the default to
the max possible is probably the least likely to cause surprises
(especially with patch connections).

Add testing of --default-mtu to the test7 example.

Co-authored-by: Aaron Brooks <[email protected]>
  • Loading branch information
kanaka and abrooks committed Apr 4, 2024
1 parent ac5692d commit 714523b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ The following table describes the link properties:
| dev | * | string[15] | eth0 | container intf name |
| ip | * | CIDR | | IP CIDR (index offset) |
| mac | 3 | MAC | | MAC addr (index offset) |
| mtu | * | number 4 | 9000 | intf MTU |
| mtu | * | number 4 | 65535 | intf MTU |
| route | * | string | | ip route add args |
| nat | * | IP | | DNAT/SNAT to IP |
| netem | * | string | | tc qdisc NetEm options |
Expand Down Expand Up @@ -449,8 +449,10 @@ Start the test7 compose configuration:
docker-compose -f examples/test7-compose.yaml up --build --force-recreate
```

Show the links in both node containers to see that the MAC addresses
are `00:0a:0b:0c:0d:0*` and the MTUs are set to `4111`.
Show the links in both node containers to see that on the eth0
interfaces the MAC addresses are `00:0a:0b:0c:0d:0*` and the MTUs are
set to `4111`. The eth1 interfaces should have the command line set
default MTU of `5111`.

```
docker-compose -f examples/test7-compose.yaml exec --index 1 node ip link
Expand Down
5 changes: 4 additions & 1 deletion examples/test7-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker:/var/lib/docker
- ./:/test
command: /app/build/conlink.js --compose-file /test/test7-compose.yaml
command: /app/build/conlink.js --default-mtu 5111 --compose-file /test/test7-compose.yaml

node:
image: alpine
Expand All @@ -29,3 +29,6 @@ services:
mac: 00:0a:0b:0c:0d:01
mtu: 4111
netem: "delay 40ms rate 10mbit"
- bridge: s2
ip: 100.0.1.1/16
dev: eth1
10 changes: 7 additions & 3 deletions src/conlink/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ General Options:
--default-bridge-mode BRIDGE-MODE Default bridge mode (ovs, linux, patch, or auto)
to use for bridge/switch connections
[default: auto] [env: CONLINK_BRIDGE_MODE]
--default-mtu MTU Default link MTU (for non *vlan types)
[default: 65535]
--network-file NETWORK-FILE... Network config file
--compose-file COMPOSE-FILE... Docker compose file with network config
--compose-project NAME Docker compose project name for resolving
Expand Down Expand Up @@ -100,10 +102,11 @@ General Options:
Add default values to a link:
- type: veth
- dev: eth0
- mtu: 9000 (for non *vlan type)
- mtu: --default-mtu (for non *vlan type)
- base: :conlink for veth type, :host for *vlan types, :local otherwise"
[{:as link :keys [type base bridge ip vlanid]} bridges]
(let [type (keyword (or type "veth"))
(let [{:keys [default-mtu]} @ctx
type (keyword (or type "veth"))
base-default (cond (= :veth type) :conlink
(VLAN-TYPES type) :host
:else :local)
Expand All @@ -116,7 +119,7 @@ General Options:
(when bridge
{:bridge (get bridges bridge)})
(when (not (VLAN-TYPES type))
{:mtu (get link :mtu 9000)}))]
{:mtu (get link :mtu default-mtu)}))]
link))

(defn enrich-bridge
Expand Down Expand Up @@ -781,6 +784,7 @@ General Options:
kmod-ovs? (kmod-loaded? "openvswitch")
kmod-mirred? (kmod-loaded? "act_mirred")
_ (swap! ctx merge {:default-bridge-mode (:default-bridge-mode opts)
:default-mtu (:default-mtu opts)
:kmod-ovs? kmod-ovs?
:kmod-mirred? kmod-mirred?})
network-config (P/-> (load-configs compose-file network-file)
Expand Down

0 comments on commit 714523b

Please sign in to comment.