Skip to content

Commit

Permalink
feat: Automaticly match MTU size (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese authored Mar 3, 2025
1 parent e2c5182 commit 79b8aad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN set -eu && \
net-tools \
e2fsprogs \
qemu-utils \
iputils-ping \
genisoimage \
ca-certificates \
netcat-openbsd \
Expand Down
9 changes: 7 additions & 2 deletions src/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -Eeuo pipefail
# Docker environment variables

: "${MAC:=""}"
: "${MTU:=""}"
: "${DHCP:="N"}"
: "${NETWORK:="Y"}"
: "${USER_PORTS:=""}"
Expand Down Expand Up @@ -349,6 +350,10 @@ getInfo() {
error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 27
fi

if [ -z "$MTU" ]; then
MTU=$(cat "/sys/class/net/$VM_NET_DEV/mtu")
fi

if [ -z "$MAC" ]; then
local file="$STORAGE/$PROCESS.mac"
[ -s "$file" ] && MAC=$(<"$file")
Expand Down Expand Up @@ -390,7 +395,7 @@ getInfo
html "Initializing network..."

if [[ "$DEBUG" == [Yy1]* ]]; then
info "Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC"
info "Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC MTU: $MTU"
[ -f /etc/resolv.conf ] && grep '^nameserver*' /etc/resolv.conf
echo
fi
Expand Down Expand Up @@ -444,7 +449,7 @@ else

fi

NET_OPTS+=" -device $ADAPTER,romfile=,netdev=hostnet0,mac=$VM_NET_MAC,id=net0"
NET_OPTS+=" -device $ADAPTER,romfile=,netdev=hostnet0,mac=$VM_NET_MAC,host_mtu=$MTU,id=net0"

html "Initialized network successfully..."
return 0

0 comments on commit 79b8aad

Please sign in to comment.