Skip to content

Commit

Permalink
Merge pull request #16 from AkihiroSuda/a
Browse files Browse the repository at this point in the history
test: add rootful_veth benchmark for comparison
  • Loading branch information
AkihiroSuda authored Aug 28, 2018
2 parents 5e59e1b + 7df7350 commit ae64a3f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
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

0 comments on commit ae64a3f

Please sign in to comment.