BastilleBSD / bastille

Bastille is an open-source system for automating deployment and management of containerized applications on FreeBSD.
https://bastillebsd.org
BSD 3-Clause "New" or "Revised" License
817 stars 129 forks source link

[BUG] /usr/local/bin/jib does not set correct MTU on epair(4) devices if bridge/ext_if uses jumbo frames #523

Open tdm4 opened 2 years ago

tdm4 commented 2 years ago

[MANDATORY] Describe the bug [MANDATORY] The script /usr/local/bin/jib does not create epair(4) devices with the correct MTU. If the external interface and bridge are using mtu 9001 (for jumbo frames), the epair(4) devices attempt to get created with a default MTU of 1500 which results in an error:

kernel: ena0bridge: invalid MTU: 1500(epair0a) != 9001

[MANDATORY] Bastille and FreeBSD version (paste bastille -v && freebsd-version -kru output) 0.9.20220216 13.1-RELEASE 13.1-RELEASE 13.1-RELEASE

[MANDATORY] How did you install bastille? (port/pkg/git) pkg

[optional] Steps to reproduce? Set MTU of external network interface to 9001 and attempt to create a VNET jail. It will fail and leave epair* devices lying around.

[optional] Expected behavior The epair(4) devices MTU must match that of the bridge, and the VNET jail will be created correctly.

[optional] Screenshots No screenshots available

[optional] Additional context The original /usr/share/examples/jails/jib (on 13.1-RELEASE) line 309:

new=$( ifconfig epair create ) || return

I was able to workaround it by changing the line to:

new=$( ifconfig epair create mtu 9001 ) || return

However, this was just a quick fix for my use case. It would be better for the script to query the mtu of the bridge and set the mtu accordingly. Something like:

bridge_mtu=$(ifconfig $iface$bridge | awk '/mtu/ {print $6}')
new=$( ifconfig epair create mtu ${bridge_mtu} ) || return
woodsb02 commented 2 years ago

It’s worth noting that the behaviour of bridge has changed in FreeBSD 14 that resolves this, but it’s not going to be backported to FreeBSD 13, so may still be worth fixing in jib/bastille.

Refer to the follow FreeBSD source changes in CURRENT.

if_bridge: allow MTU changes https://cgit.freebsd.org/src/commit/sys/net/if_bridge.c?id=33306493825b291a308c0d37396e82de458f6cfe

if_bridge: change MTU for new members https://cgit.freebsd.org/src/commit/sys/net/if_bridge.c?id=1865ebfb12ddaf3d0ff1458e6152b3cb1f1bdee8