From 60f27efbe933ed5c7c6b5d5dc3f8466634a7ef6b Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Mon, 20 Nov 2023 14:52:09 +0400 Subject: [PATCH 1/4] topotato: add environment for freebsd using vagrant Signed-off-by: Bruno Bernard --- Vagrantfile | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 387ff96c7416..f8355eda9350 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -3,7 +3,17 @@ Vagrant.configure("2") do |config| - config.vm.box = "ubuntu/jammy64" + config.vm.define :freebsd do |freebsd| + freebsd.vm.box = "freebsd/FreeBSD-14.0-RELEASE" + freebsd.vm.provision "shell", path: "./vm/freebsd/install.sh" + # freebsd.vm.provision "shell", path: "./vm/freebsd/topotato-install.sh" + end + + config.vm.define :ubuntu do |ubuntu| + ubuntu.vm.box = "ubuntu/jammy64" + ubuntu.vm.provision "shell", path: "./vm/ubuntu/install.sh" + ubuntu.vm.provision "shell", path: "./vm/ubuntu/topotato-install.sh" + end config.vm.hostname = "topotato-dev" @@ -29,7 +39,4 @@ Vagrant.configure("2") do |config| config.vbguest.no_remote = true end - config.vm.provision "shell", path: "./vm/ubuntu/install.sh" - config.vm.provision "shell", path: "./vm/ubuntu/topotato-install.sh" - end From 6b24f1e45caba9bf7e2c74bf90079ec9da40788e Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Mon, 20 Nov 2023 14:52:33 +0400 Subject: [PATCH 2/4] topotato: add scripts for vagrant Signed-off-by: Bruno Bernard --- vm/freebsd/install.sh | 41 ++++++++++++++++++++++++++++++++++ vm/freebsd/topotato-install.sh | 4 ++++ 2 files changed, 45 insertions(+) create mode 100644 vm/freebsd/install.sh create mode 100644 vm/freebsd/topotato-install.sh diff --git a/vm/freebsd/install.sh b/vm/freebsd/install.sh new file mode 100644 index 000000000000..d19aa95b07da --- /dev/null +++ b/vm/freebsd/install.sh @@ -0,0 +1,41 @@ +#!/usr/local/bin/bash + +pkg install git autoconf automake libtool gmake json-c pkgconf \ + bison py39-pytest c-ares py39-sphinx texinfo libunwind libyang2 + +pw groupadd frr -g 101 +pw groupadd frrvty -g 102 +pw adduser frr -g 101 -u 101 -G 102 -c "FRR suite" \ + -d /usr/local/etc/frr -s /usr/sbin/nologin + + +cd /home/vagrant +git clone https://github.com/frrouting/frr.git --single-branch frr +cd frr +./bootstrap.sh +export MAKE=gmake LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include +./configure \ + --sysconfdir=/usr/local/etc/frr \ + --enable-pkgsrcrcdir=/usr/pkg/share/examples/rc.d \ + --localstatedir=/var/run/frr \ + --prefix=/usr/local \ + --enable-multipath=64 \ + --enable-user=frr \ + --enable-group=frr \ + --enable-vty-group=frrvty \ + --enable-configfile-mask=0640 \ + --enable-logfile-mask=0640 \ + --enable-fpm \ + --with-pkg-git-version \ + --with-pkg-extra-version=-MyOwnFRRVersion +gmake +gmake check +gmake install + +mkdir /usr/local/etc/frr +touch /usr/local/etc/frr/frr.conf + +sysctl -w net.inet.ip.forwarding=1 +sysctl -w net.inet6.ip6.forwarding=1 + +service sysctl restart \ No newline at end of file diff --git a/vm/freebsd/topotato-install.sh b/vm/freebsd/topotato-install.sh new file mode 100644 index 000000000000..95889044edb9 --- /dev/null +++ b/vm/freebsd/topotato-install.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd /home/vagrant/dev/topotato +# TODO: Add packages for topotato \ No newline at end of file From d8c48621aa884d7b26bd210de2cb0326357a4a47 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Mon, 20 Nov 2023 17:01:27 +0400 Subject: [PATCH 3/4] topotato: add topotato runner using jail Signed-off-by: Bruno Bernard --- run_jail.sh | 29 +++++++++++++++++++++++++++++ vm/jail.conf | 6 ++++++ 2 files changed, 35 insertions(+) create mode 100755 run_jail.sh create mode 100644 vm/jail.conf diff --git a/run_jail.sh b/run_jail.sh new file mode 100755 index 000000000000..d5a1cc37a074 --- /dev/null +++ b/run_jail.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +cd "`dirname $0`" + +if [ \! -d "/usr/local/etc/frr" ]; then + echo /usr/local/etc/frr does not exist or is not a directory. Please create it. >&2 + exit 1 +fi + +if [ "$1" = "ns_inner" ]; then + + shift + for I in `ls -1 etc`; do + if [ "$I" = "frr" ]; then + continue + fi + mount_nullfs "etc/$I" "/etc/$I" + done + mount -t tmpfs tmpfs /var/tmp + mount -t tmpfs tmpfs /var/run + + # ip link set lo0 up + + exec ${PYTHON:-python} -mpytest "$@" +else + sudo jail -cmr -f ./vm/jail.conf + sudo jexec topotato $PWD/$0 ns_inner $@ + sudo jail -r topotato +fi diff --git a/vm/jail.conf b/vm/jail.conf new file mode 100644 index 000000000000..dcc6d7ebd1c6 --- /dev/null +++ b/vm/jail.conf @@ -0,0 +1,6 @@ +topotato { + allow.mount; + allow.mount.nullfs; + allow.mount.tmpfs; + persist; +} From 71f3aeb8c2eba51d9981f1c773404b4d7048ffa6 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Wed, 29 Nov 2023 16:01:20 +0400 Subject: [PATCH 4/4] topotato: fix script with non-interactive installation for packages Signed-off-by: Bruno Bernard --- vm/freebsd/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/freebsd/install.sh b/vm/freebsd/install.sh index d19aa95b07da..b89722fa18a4 100644 --- a/vm/freebsd/install.sh +++ b/vm/freebsd/install.sh @@ -1,7 +1,7 @@ #!/usr/local/bin/bash -pkg install git autoconf automake libtool gmake json-c pkgconf \ - bison py39-pytest c-ares py39-sphinx texinfo libunwind libyang2 +pkg install -y git autoconf automake libtool gmake json-c pkgconf \ + bison py39-pytest c-ares py39-sphinx texinfo libunwind libyang2 protobuf-c pw groupadd frr -g 101 pw groupadd frrvty -g 102