Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add rootful_veth benchmark for comparison #16

Merged
merged 1 commit into from
Aug 28, 2018
Merged
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
6 changes: 4 additions & 2 deletions hack/test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ RUN git clone https://github.com/rd235/vdeplug_slirp.git /vdeplug_slirp && \

FROM ubuntu AS test
# busybox is only for debugging purpose
RUN apt update && apt install -y iperf3 uidmap iproute2 busybox
# sudo is only for rootful veth benchmark (for comparison)
RUN apt update && apt install -y iperf3 uidmap iproute2 busybox sudo
RUN useradd --create-home --home-dir /home/user --uid 1000 user \
&& mkdir -p /run/user/1000
&& mkdir -p /run/user/1000 \
&& echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/user
COPY --from=rootlesskit /rootlesskit /home/user/bin/
COPY --from=slirp4netns /slirp4netns/slirp4netns /home/user/bin/
COPY --from=vpnkit /vpnkit/vpnkit.exe /home/user/bin/vpnkit
Expand Down
21 changes: 21 additions & 0 deletions hack/test/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ function benchmark::iperf3::vdeplug_slirp(){
set +x
}

function benchmark::iperf3::rootful_veth(){
INFO "[benchmark:iperf3] rootful_veth ($@) for reference"
# only --mtu=MTU is supposed as $@
mtu=$(echo $@ | sed -e s/--mtu=//g)
set -x
sudo ip netns add foo
sudo ip link add foo_veth0 type veth peer name foo_veth1
sudo ip link set foo_veth1 netns foo
sudo ip addr add 10.0.42.1/24 dev foo_veth0
sudo ip -netns foo addr add 10.0.42.2/24 dev foo_veth1
sudo ip link set dev foo_veth0 mtu $mtu
sudo ip -netns foo link set dev foo_veth1 mtu $mtu
sudo ip link set foo_veth0 up
sudo ip -netns foo link set foo_veth1 up
sudo ip netns exec foo $IPERF3C 10.0.42.1
sudo ip link del foo_veth0
sudo ip netns del foo
set +x
}

function benchmark::iperf3::main(){
iperf3 -s > /dev/null &
iperf3pid=$!
Expand All @@ -47,6 +67,7 @@ function benchmark::iperf3::main(){
else
benchmark::iperf3::vdeplug_slirp --mtu=$mtu
fi
benchmark::iperf3::rootful_veth --mtu=$mtu
done
kill $iperf3pid
}
Expand Down