2021-02-26 03:59:36 +03:00
#!/usr/bin/env bash
2021-10-17 19:13:06 +03:00
# SPDX-License-Identifier: LGPL-2.1-or-later
2021-02-26 03:59:36 +03:00
set -ex
set -o pipefail
setup( ) {
systemd-analyze log-level debug
2021-09-29 21:30:08 +03:00
for i in { 0..3} ;
2021-02-26 03:59:36 +03:00
do
2021-09-29 21:30:08 +03:00
ip netns del " ns ${ i } " || true
ip link del " veth ${ i } " || true
ip netns add " ns ${ i } "
ip link add " veth ${ i } " type veth peer name " veth ${ i } _ "
ip link set " veth ${ i } _ " netns " ns ${ i } "
ip -n " ns ${ i } " link set dev " veth ${ i } _ " up
ip -n " ns ${ i } " link set dev lo up
ip -n " ns ${ i } " addr add "192.168.113." $(( 4 * i+1)) /30 dev " veth ${ i } _ "
ip link set dev " veth ${ i } " up
2023-12-15 05:22:52 +03:00
ip link property add dev " veth ${ i } " altname " veth ${ i } -altname-with-more-than-15-chars "
2021-09-29 21:30:08 +03:00
ip addr add "192.168.113." $(( 4 * i+2)) /30 dev " veth ${ i } "
2021-02-26 03:59:36 +03:00
done
}
2023-05-16 21:55:45 +03:00
# shellcheck disable=SC2317
2021-02-26 03:59:36 +03:00
teardown( ) {
set +e
2023-05-16 21:55:45 +03:00
for i in { 0..3} ; do
2021-09-29 21:30:08 +03:00
ip netns del " ns ${ i } "
ip link del " veth ${ i } "
2021-02-26 03:59:36 +03:00
done
systemd-analyze log-level info
}
2024-04-25 14:43:18 +03:00
if systemd-analyze compare-versions " $( uname -r) " lt 5.7; then
2021-02-26 03:59:36 +03:00
echo "kernel is not 5.7+" >>/skipped
2024-04-02 21:37:30 +03:00
exit 77
2021-02-26 03:59:36 +03:00
fi
2021-12-11 05:54:01 +03:00
if systemctl --version | grep -q -F -- "-BPF_FRAMEWORK" ; then
2021-12-10 13:51:23 +03:00
echo "bpf-framework is disabled" >>/skipped
2024-04-02 21:37:30 +03:00
exit 77
2021-12-10 13:51:23 +03:00
fi
2021-02-26 03:59:36 +03:00
trap teardown EXIT
setup
2024-05-11 20:17:13 +03:00
systemctl start --wait TEST-62-RESTRICT-IFACES-1.service
systemctl start --wait TEST-62-RESTRICT-IFACES-2.service
systemctl start --wait TEST-62-RESTRICT-IFACES-3.service
systemctl start --wait TEST-62-RESTRICT-IFACES-4.service
systemctl start --wait TEST-62-RESTRICT-IFACES-5.service
2021-02-26 03:59:36 +03:00
2023-07-12 16:49:55 +03:00
touch /testok