Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/build-toybox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -exu
# Toybox route is "pending" but the TODOs are in add/del;
# we're using it for display only so we should be good.
# Toybox sh has more TODOs in multiple areas so don't use it.
toys="base64 mktemp mv route timeout"
toys="base64 mktemp mv timeout"

cd /toybox-*/

Expand Down
15 changes: 9 additions & 6 deletions scripts/install-cni.sh
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,19 @@ else
cni_spec=${cni_spec//@ipv6RouteOptional/}
fi

# Format of `route` output:
# Destination Gateway Genmask Flags Metric Ref Use Iface
# 0.0.0.0 192.168.0.1 0.0.0.0 UG 100 0 0 ens4
# 192.168.0.1 0.0.0.0 255.255.255.255 UH 100 0 0 ens4
# Format of /proc/net/route:
# Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
# ens4 00000000 0100A8C0 0003 0 0 100 00000000 0 0 0
# ens4 0100A8C0 00000000 0005 0 0 100 FFFFFFFF 0 0 0

# Note that Destination and Mask are IP represented in hexadecimal in
# little-endian. Regardless of endianness, 00000000 is always 0.0.0.0.

# The first grep extracts the default line, and the second grep extracts the
# last field, which is the interface name. We stick to using grep to avoid
# first field, which is the interface name. We stick to using grep to avoid
# introducing too many new dependencies.

default_nic=$(route -n | grep -E '^0\.0\.0\.0\s+\S+\s+0\.0\.0\.0' | grep -oE '\S+$')
default_nic=$(grep -E '^\S+\s+00000000\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+00000000\s+' /proc/net/route | grep -oE '^\S+')

# Set mtu
if [ -f "/sys/class/net/$default_nic/mtu" ]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/shell-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ run_test inotify_cmd
inotify / '' /bin/cat /dev/null >/dev/null && pass || fail

run_test default_nic_mtu
[[ -f "/sys/class/net/$(route -n | grep -E '^0\.0\.0\.0\s+\S+\s+0\.0\.0\.0' | grep -oE '\S+$')/mtu" ]] && pass || fail
[[ -f "/sys/class/net/$(grep -E '^\S+\s+00000000\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+00000000\s+' /proc/net/route | grep -oE '^\S+')/mtu" ]] && pass || fail

run_test mktemp_cmd
[[ -f "$(mktemp /tmp.XXXXXX)" ]] && pass || fail
Expand Down