From f78bec886199c76f71d676bb115a94d903717504 Mon Sep 17 00:00:00 2001 From: seantywork Date: Mon, 15 Dec 2025 16:49:18 +0900 Subject: [PATCH] ovs? --- {ovs => br-ovs}/.gitignore | 0 br-ovs/2025-1215.xyz.md | 85 +++++++++++++++++++++++++ ovs/install.sh => br-ovs/ovs-install.sh | 2 + ovs/start.sh => br-ovs/ovs-start.sh | 7 +- br-ovs/test.sh | 54 ++++++++++++++++ ovs/test.sh | 66 +++++++++++-------- 6 files changed, 185 insertions(+), 29 deletions(-) rename {ovs => br-ovs}/.gitignore (100%) create mode 100644 br-ovs/2025-1215.xyz.md rename ovs/install.sh => br-ovs/ovs-install.sh (92%) rename ovs/start.sh => br-ovs/ovs-start.sh (82%) create mode 100755 br-ovs/test.sh mode change 100755 => 100644 ovs/test.sh diff --git a/ovs/.gitignore b/br-ovs/.gitignore similarity index 100% rename from ovs/.gitignore rename to br-ovs/.gitignore diff --git a/br-ovs/2025-1215.xyz.md b/br-ovs/2025-1215.xyz.md new file mode 100644 index 0000000..aedfd0d --- /dev/null +++ b/br-ovs/2025-1215.xyz.md @@ -0,0 +1,85 @@ +# install ovs + +```shell +./ovs-install.sh +``` + +# start ovs + +```shell ++ mkdir -p /usr/local/etc/openvswitch ++ pushd ovs +~/hack/linuxyz/br-ovs/ovs ~/hack/linuxyz/br-ovs ++ sudo ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema ++ popd +~/hack/linuxyz/br-ovs ++ sudo /usr/local/share/openvswitch/scripts/ovs-ctl start + * Starting ovsdb-server + * system ID not configured, please use --system-id + * Configuring Open vSwitch system IDs + * Inserting openvswitch module + * Starting ovs-vswitchd + * Enabling remote OVSDB managers ++ sudo ovs-vsctl --no-wait init + +``` + +# br + +```shell +[ ID] Interval Transfer Bitrate Retr +[ 5] 0.00-60.00 sec 97.0 GBytes 13.9 Gbits/sec 48 sender +[ 5] 0.00-60.00 sec 97.0 GBytes 13.9 Gbits/sec receiver +[ 7] 0.00-60.00 sec 99.2 GBytes 14.2 Gbits/sec 5 sender +[ 7] 0.00-60.00 sec 99.2 GBytes 14.2 Gbits/sec receiver +[ 9] 0.00-60.00 sec 96.9 GBytes 13.9 Gbits/sec 4 sender +[ 9] 0.00-60.00 sec 96.9 GBytes 13.9 Gbits/sec receiver +[ 11] 0.00-60.00 sec 97.7 GBytes 14.0 Gbits/sec 88 sender +[ 11] 0.00-60.00 sec 97.7 GBytes 14.0 Gbits/sec receiver +[SUM] 0.00-60.00 sec 391 GBytes 56.0 Gbits/sec 145 sender +[SUM] 0.00-60.00 sec 391 GBytes 56.0 Gbits/sec receiver +``` + +```shell +[ ID] Interval Transfer Bitrate Retr +[ 5] 0.00-60.00 sec 110 GBytes 15.8 Gbits/sec 5 sender +[ 5] 0.00-60.00 sec 110 GBytes 15.8 Gbits/sec receiver +[ 7] 0.00-60.00 sec 110 GBytes 15.7 Gbits/sec 9 sender +[ 7] 0.00-60.00 sec 110 GBytes 15.7 Gbits/sec receiver +[ 9] 0.00-60.00 sec 113 GBytes 16.1 Gbits/sec 7 sender +[ 9] 0.00-60.00 sec 113 GBytes 16.1 Gbits/sec receiver +[ 11] 0.00-60.00 sec 113 GBytes 16.1 Gbits/sec 5 sender +[ 11] 0.00-60.00 sec 113 GBytes 16.1 Gbits/sec receiver +[SUM] 0.00-60.00 sec 446 GBytes 63.8 Gbits/sec 26 sender +[SUM] 0.00-60.00 sec 446 GBytes 63.8 Gbits/sec receiver +``` + +# ovs + +```shell +[ ID] Interval Transfer Bitrate Retr +[ 5] 0.00-60.00 sec 107 GBytes 15.3 Gbits/sec 243 sender +[ 5] 0.00-60.00 sec 107 GBytes 15.3 Gbits/sec receiver +[ 7] 0.00-60.00 sec 108 GBytes 15.4 Gbits/sec 476 sender +[ 7] 0.00-60.00 sec 108 GBytes 15.4 Gbits/sec receiver +[ 9] 0.00-60.00 sec 105 GBytes 15.0 Gbits/sec 55 sender +[ 9] 0.00-60.00 sec 105 GBytes 15.0 Gbits/sec receiver +[ 11] 0.00-60.00 sec 108 GBytes 15.4 Gbits/sec 5 sender +[ 11] 0.00-60.00 sec 108 GBytes 15.4 Gbits/sec receiver +[SUM] 0.00-60.00 sec 427 GBytes 61.2 Gbits/sec 779 sender +[SUM] 0.00-60.00 sec 427 GBytes 61.1 Gbits/sec receiver +``` + +```shell +[ ID] Interval Transfer Bitrate Retr +[ 5] 0.00-60.00 sec 108 GBytes 15.4 Gbits/sec 4 sender +[ 5] 0.00-60.00 sec 108 GBytes 15.4 Gbits/sec receiver +[ 7] 0.00-60.00 sec 108 GBytes 15.4 Gbits/sec 6 sender +[ 7] 0.00-60.00 sec 108 GBytes 15.4 Gbits/sec receiver +[ 9] 0.00-60.00 sec 107 GBytes 15.4 Gbits/sec 1 sender +[ 9] 0.00-60.00 sec 107 GBytes 15.4 Gbits/sec receiver +[ 11] 0.00-60.00 sec 107 GBytes 15.3 Gbits/sec 6 sender +[ 11] 0.00-60.00 sec 107 GBytes 15.3 Gbits/sec receiver +[SUM] 0.00-60.00 sec 429 GBytes 61.5 Gbits/sec 17 sender +[SUM] 0.00-60.00 sec 429 GBytes 61.5 Gbits/sec receiver +``` \ No newline at end of file diff --git a/ovs/install.sh b/br-ovs/ovs-install.sh similarity index 92% rename from ovs/install.sh rename to br-ovs/ovs-install.sh index 778f4bd..5748a92 100755 --- a/ovs/install.sh +++ b/br-ovs/ovs-install.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -exo pipefail + sudo apt update sudo apt install build-essential make autoconf libtool git clone https://github.com/openvswitch/ovs.git diff --git a/ovs/start.sh b/br-ovs/ovs-start.sh similarity index 82% rename from ovs/start.sh rename to br-ovs/ovs-start.sh index 0a394ab..3483680 100755 --- a/ovs/start.sh +++ b/br-ovs/ovs-start.sh @@ -1,11 +1,16 @@ #!/bin/bash +set -exo pipefail + mkdir -p /usr/local/etc/openvswitch +pushd ovs + sudo ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema +popd + sudo /usr/local/share/openvswitch/scripts/ovs-ctl start sudo ovs-vsctl --no-wait init -# sudo ovs-vswitchd --pidfile --detach --log-file \ No newline at end of file diff --git a/br-ovs/test.sh b/br-ovs/test.sh new file mode 100755 index 0000000..427565a --- /dev/null +++ b/br-ovs/test.sh @@ -0,0 +1,54 @@ +#!/bin/bash + + +setup(){ + sudo ip netns add net1 + sudo ip netns add net2 + sudo ip link add dev veth11 type veth peer name veth12 netns net1 + sudo ip link add dev veth21 type veth peer name veth22 netns net2 + sudo ip netns exec net1 ip addr add 192.168.64.12/24 dev veth12 + sudo ip netns exec net2 ip addr add 192.168.64.22/24 dev veth22 + sudo ip netns exec net1 ip link set veth12 up + sudo ip netns exec net2 ip link set veth22 up + sudo sysctl -w net.ipv4.ip_forward=1 +} + +br_test(){ + sudo ip link add lx-br0 type bridge stp_state 0 + sudo ip link set veth11 master lx-br0 + sudo ip link set veth21 master lx-br0 + sudo ip link set up veth11 + sudo ip link set up veth21 + sudo ip link set up lx-br0 + sudo ip netns exec net2 iperf3 -s 192.168.64.22 > /dev/null 2>&1 & + sudo ip netns exec net1 iperf3 -c 192.168.64.22 -t 60 -i 1 -P 4 + sudo ip netns exec net2 pkill iperf3 + sudo ip link del lx-br0 +} + + +ovs_test(){ + sudo ovs-vsctl add-br ovs-br0 + sudo ovs-vsctl add-port ovs-br0 veth11 + sudo ovs-vsctl add-port ovs-br0 veth21 + sudo ip link set up veth11 + sudo ip link set up veth21 + sudo ip link set ovs-br0 up + sudo ip netns exec net2 iperf3 -s 192.168.64.22 > /dev/null 2>&1 & + sudo ip netns exec net1 iperf3 -c 192.168.64.22 -t 60 -i 1 -P 4 + sudo ip netns exec net2 pkill iperf3 + sudo ovs-vsctl del-br ovs-br0 + +} + +cleanup(){ + sudo ip netns del net1 + sudo ip netns del net2 +} + +setup +br_test +cleanup +setup +ovs_test +cleanup \ No newline at end of file diff --git a/ovs/test.sh b/ovs/test.sh old mode 100755 new mode 100644 index f1b6cdc..97680da --- a/ovs/test.sh +++ b/ovs/test.sh @@ -2,32 +2,42 @@ set -exo pipefail -sudo ovs-vsctl add-br ovs-br0 +ovs_test(){ + sudo ovs-vsctl add-br ovs-br0 + sudo ip netns add net1 + sudo ip netns add net2 + sudo ip link add dev veth11 type veth peer name veth12 netns net1 + sudo ip link add dev veth21 type veth peer name veth22 netns net2 + sudo ovs-vsctl add-port ovs-br0 veth11 + sudo ovs-vsctl add-port ovs-br0 veth21 + sudo ip netns exec net1 ip addr add 192.168.64.12/24 dev veth12 + sudo ip netns exec net2 ip addr add 192.168.64.22/24 dev veth22 + sudo ip netns exec net1 ip link set veth12 up + sudo ip netns exec net2 ip link set veth22 up + sudo ip link set up veth11 + sudo ip link set up veth21 + sudo ip link set ovs-br0 up + sudo sysctl -w net.ipv4.ip_forward=1 +} + +br_test(){ + sudo ovs-vsctl add-br ovs-br0 + sudo ip netns add net1 + sudo ip netns add net2 + sudo ip link add dev veth11 type veth peer name veth12 netns net1 + sudo ip link add dev veth21 type veth peer name veth22 netns net2 + sudo ovs-vsctl add-port ovs-br0 veth11 + sudo ovs-vsctl add-port ovs-br0 veth21 + sudo ip netns exec net1 ip addr add 192.168.64.12/24 dev veth12 + sudo ip netns exec net2 ip addr add 192.168.64.22/24 dev veth22 + sudo ip netns exec net1 ip link set veth12 up + sudo ip netns exec net2 ip link set veth22 up + sudo ip link set up veth11 + sudo ip link set up veth21 + sudo ip link set ovs-br0 up + sudo sysctl -w net.ipv4.ip_forward=1 +} + +ovs_test +br_test -sudo ip netns add net1 - -sudo ip netns add net2 - -sudo ip link add dev veth11 type veth peer name veth12 netns net1 - -sudo ip link add dev veth21 type veth peer name veth22 netns net2 - -sudo ovs-vsctl add-port ovs-br0 veth11 - -sudo ovs-vsctl add-port ovs-br0 veth21 - -sudo ip netns exec net1 ip addr add 192.168.64.12/24 dev veth12 - -sudo ip netns exec net2 ip addr add 192.168.64.22/24 dev veth22 - -sudo ip netns exec net1 ip link set veth12 up - -sudo ip netns exec net2 ip link set veth22 up - -sudo ip link set up veth11 - -sudo ip link set up veth21 - -sudo ip link set ovs-br0 up - -sudo sysctl -w net.ipv4.ip_forward=1 \ No newline at end of file -- 2.43.0