diff --git a/Sanity/basic-bgp/daemons-vnc b/Sanity/basic-bgp/daemons-vnc new file mode 100644 index 0000000..3b386ba --- /dev/null +++ b/Sanity/basic-bgp/daemons-vnc @@ -0,0 +1,121 @@ +# This file tells the frr package which daemons to start. +# +# Sample configurations for these daemons can be found in +# /usr/share/doc/frr/examples/. +# +# ATTENTION: +# +# When activating a daemon for the first time, a config file, even if it is +# empty, has to be present *and* be owned by the user and group "frr", else +# the daemon will not be started by /etc/init.d/frr. The permissions should +# be u=rw,g=r,o=. +# When using "vtysh" such a config file is also needed. It should be owned by +# group "frrvty" and set to ug=rw,o= though. Check /etc/pam.d/frr, too. +# +# The watchfrr, zebra and staticd daemons are always started. +# +bgpd=yes +ospfd=no +ospf6d=no +ripd=no +ripngd=no +isisd=no +pimd=no +pim6d=no +nhrpd=no +eigrpd=no +sharpd=no +pbrd=no +bfdd=no +fabricd=no +vrrpd=no +pathd=no + +# +# If this option is set the /etc/init.d/frr script automatically loads +# the config via "vtysh -b" when the servers are started. +# Check /etc/pam.d/frr if you intend to use "vtysh"! +# +vtysh_enable=yes +zebra_options=" -A 127.0.0.1 -s 90000000" +bgpd_options=" -A 127.0.0.1" +ospfd_options=" -A 127.0.0.1" +ospf6d_options=" -A ::1" +ripd_options=" -A 127.0.0.1" +ripngd_options=" -A ::1" +isisd_options=" -A 127.0.0.1" +pimd_options=" -A 127.0.0.1" +pim6d_options=" -A ::1" +nhrpd_options=" -A 127.0.0.1" +eigrpd_options=" -A 127.0.0.1" +sharpd_options=" -A 127.0.0.1" +pbrd_options=" -A 127.0.0.1" +staticd_options="-A 127.0.0.1" +bfdd_options=" -A 127.0.0.1" +fabricd_options="-A 127.0.0.1" +vrrpd_options=" -A 127.0.0.1" +pathd_options=" -A 127.0.0.1" + + +# If you want to pass a common option to all daemons, you can use the +# "frr_global_options" variable. +# +#frr_global_options="" + + +# The list of daemons to watch is automatically generated by the init script. +# This variable can be used to pass options to watchfrr that will be passed +# prior to the daemon list. +# +# To make watchfrr create/join the specified netns, add the the "--netns" +# option here. It will only have an effect in /etc/frr//daemons, and +# you need to start FRR with "/usr/lib/frr/frrinit.sh start ". +# +watchfrr_options="--netns=vnc" + + +# configuration profile +# +#frr_profile="traditional" +#frr_profile="datacenter" + + +# This is the maximum number of FD's that will be available. Upon startup this +# is read by the control files and ulimit is called. Uncomment and use a +# reasonable value for your setup if you are expecting a large number of peers +# in say BGP. +# +#MAX_FDS=1024 + +# Uncomment this option if you want to run FRR as a non-root user. Note that +# you should know what you are doing since most of the daemons need root +# to work. This could be useful if you want to run FRR in a container +# for instance. +# FRR_NO_ROOT="yes" + +# For any daemon, you can specify a "wrap" command to start instead of starting +# the daemon directly. This will simply be prepended to the daemon invocation. +# These variables have the form daemon_wrap, where 'daemon' is the name of the +# daemon (the same pattern as the daemon_options variables). +# +# Note that when daemons are started, they are told to daemonize with the `-d` +# option. This has several implications. For one, the init script expects that +# when it invokes a daemon, the invocation returns immediately. If you add a +# wrap command here, it must comply with this expectation and daemonize as +# well, or the init script will never return. Furthermore, because daemons are +# themselves daemonized with -d, you must ensure that your wrapper command is +# capable of following child processes after a fork() if you need it to do so. +# +# If your desired wrapper does not support daemonization, you can wrap it with +# a utility program that daemonizes programs, such as 'daemonize'. An example +# of this might look like: +# +# bgpd_wrap="/usr/bin/daemonize /usr/bin/mywrapper" +# +# This is particularly useful for programs which record processes but lack +# daemonization options, such as perf and rr. +# +# If you wish to wrap all daemons in the same way, you may set the "all_wrap" +# variable. +# +#all_wrap="" diff --git a/Sanity/basic-bgp/daemons-vns b/Sanity/basic-bgp/daemons-vns new file mode 100644 index 0000000..7a5ec3f --- /dev/null +++ b/Sanity/basic-bgp/daemons-vns @@ -0,0 +1,121 @@ +# This file tells the frr package which daemons to start. +# +# Sample configurations for these daemons can be found in +# /usr/share/doc/frr/examples/. +# +# ATTENTION: +# +# When activating a daemon for the first time, a config file, even if it is +# empty, has to be present *and* be owned by the user and group "frr", else +# the daemon will not be started by /etc/init.d/frr. The permissions should +# be u=rw,g=r,o=. +# When using "vtysh" such a config file is also needed. It should be owned by +# group "frrvty" and set to ug=rw,o= though. Check /etc/pam.d/frr, too. +# +# The watchfrr, zebra and staticd daemons are always started. +# +bgpd=yes +ospfd=no +ospf6d=no +ripd=no +ripngd=no +isisd=no +pimd=no +pim6d=no +nhrpd=no +eigrpd=no +sharpd=no +pbrd=no +bfdd=no +fabricd=no +vrrpd=no +pathd=no + +# +# If this option is set the /etc/init.d/frr script automatically loads +# the config via "vtysh -b" when the servers are started. +# Check /etc/pam.d/frr if you intend to use "vtysh"! +# +vtysh_enable=yes +zebra_options=" -A 127.0.0.1 -s 90000000" +bgpd_options=" -A 127.0.0.1" +ospfd_options=" -A 127.0.0.1" +ospf6d_options=" -A ::1" +ripd_options=" -A 127.0.0.1" +ripngd_options=" -A ::1" +isisd_options=" -A 127.0.0.1" +pimd_options=" -A 127.0.0.1" +pim6d_options=" -A ::1" +nhrpd_options=" -A 127.0.0.1" +eigrpd_options=" -A 127.0.0.1" +sharpd_options=" -A 127.0.0.1" +pbrd_options=" -A 127.0.0.1" +staticd_options="-A 127.0.0.1" +bfdd_options=" -A 127.0.0.1" +fabricd_options="-A 127.0.0.1" +vrrpd_options=" -A 127.0.0.1" +pathd_options=" -A 127.0.0.1" + + +# If you want to pass a common option to all daemons, you can use the +# "frr_global_options" variable. +# +#frr_global_options="" + + +# The list of daemons to watch is automatically generated by the init script. +# This variable can be used to pass options to watchfrr that will be passed +# prior to the daemon list. +# +# To make watchfrr create/join the specified netns, add the the "--netns" +# option here. It will only have an effect in /etc/frr//daemons, and +# you need to start FRR with "/usr/lib/frr/frrinit.sh start ". +# +watchfrr_options="--netns=vns" + + +# configuration profile +# +#frr_profile="traditional" +#frr_profile="datacenter" + + +# This is the maximum number of FD's that will be available. Upon startup this +# is read by the control files and ulimit is called. Uncomment and use a +# reasonable value for your setup if you are expecting a large number of peers +# in say BGP. +# +#MAX_FDS=1024 + +# Uncomment this option if you want to run FRR as a non-root user. Note that +# you should know what you are doing since most of the daemons need root +# to work. This could be useful if you want to run FRR in a container +# for instance. +# FRR_NO_ROOT="yes" + +# For any daemon, you can specify a "wrap" command to start instead of starting +# the daemon directly. This will simply be prepended to the daemon invocation. +# These variables have the form daemon_wrap, where 'daemon' is the name of the +# daemon (the same pattern as the daemon_options variables). +# +# Note that when daemons are started, they are told to daemonize with the `-d` +# option. This has several implications. For one, the init script expects that +# when it invokes a daemon, the invocation returns immediately. If you add a +# wrap command here, it must comply with this expectation and daemonize as +# well, or the init script will never return. Furthermore, because daemons are +# themselves daemonized with -d, you must ensure that your wrapper command is +# capable of following child processes after a fork() if you need it to do so. +# +# If your desired wrapper does not support daemonization, you can wrap it with +# a utility program that daemonizes programs, such as 'daemonize'. An example +# of this might look like: +# +# bgpd_wrap="/usr/bin/daemonize /usr/bin/mywrapper" +# +# This is particularly useful for programs which record processes but lack +# daemonization options, such as perf and rr. +# +# If you wish to wrap all daemons in the same way, you may set the "all_wrap" +# variable. +# +#all_wrap="" diff --git a/Sanity/basic-bgp/frr-vnc.conf b/Sanity/basic-bgp/frr-vnc.conf new file mode 100644 index 0000000..d974838 --- /dev/null +++ b/Sanity/basic-bgp/frr-vnc.conf @@ -0,0 +1,24 @@ +hostname RouterVNC +! +log file debugging +! +router bgp + bgp router-id + no bgp default ipv4-unicast + neighbor remote-as + neighbor remote-as + ! + address-family ipv4 unicast + network / + network / + network / + neighbor activate + exit-address-family + ! + address-family ipv6 unicast + network / + network / + network / + neighbor activate + exit-address-family +exit \ No newline at end of file diff --git a/Sanity/basic-bgp/frr-vnc.service b/Sanity/basic-bgp/frr-vnc.service new file mode 100644 index 0000000..8ce3c85 --- /dev/null +++ b/Sanity/basic-bgp/frr-vnc.service @@ -0,0 +1,25 @@ +[Unit] +Description=FRRouting +Documentation=https://frrouting.readthedocs.io/en/latest/setup.html +Wants=network.target +After=network-pre.target systemd-sysctl.service +Before=network.target +OnFailure=heartbeat-failed@%n.service + +[Service] +Nice=-5 +Type=forking +NotifyAccess=all +StartLimitInterval=3m +StartLimitBurst=3 +TimeoutSec=2m +WatchdogSec=60s +RestartSec=5 +Restart=on-abnormal +LimitNOFILE=1024 +ExecStart=/sbin/ip netns exec vnc /usr/libexec/frr/frrinit.sh start vnc +ExecStop=/sbin/ip netns exec vnc /usr/libexec/frr/frrinit.sh stop vnc +ExecReload=/sbin/ip netns exec vnc /usr/libexec/frr/frrinit.sh reload vnc + +[Install] +WantedBy=multi-user.target diff --git a/Sanity/basic-bgp/frr-vns.conf b/Sanity/basic-bgp/frr-vns.conf new file mode 100644 index 0000000..1ff9c2d --- /dev/null +++ b/Sanity/basic-bgp/frr-vns.conf @@ -0,0 +1,24 @@ +hostname RouterVNS +! +log file debugging +! +router bgp + bgp router-id + no bgp default ipv4-unicast + neighbor remote-as + neighbor remote-as + ! + address-family ipv4 unicast + network / + network / + network / + neighbor activate + exit-address-family + ! + address-family ipv6 unicast + network / + network / + network / + neighbor activate + exit-address-family +exit \ No newline at end of file diff --git a/Sanity/basic-bgp/frr-vns.service b/Sanity/basic-bgp/frr-vns.service new file mode 100644 index 0000000..d9fa54f --- /dev/null +++ b/Sanity/basic-bgp/frr-vns.service @@ -0,0 +1,25 @@ +[Unit] +Description=FRRouting +Documentation=https://frrouting.readthedocs.io/en/latest/setup.html +Wants=network.target +After=network-pre.target systemd-sysctl.service +Before=network.target +OnFailure=heartbeat-failed@%n.service + +[Service] +Nice=-5 +Type=forking +NotifyAccess=all +StartLimitInterval=3m +StartLimitBurst=3 +TimeoutSec=2m +WatchdogSec=60s +RestartSec=5 +Restart=on-abnormal +LimitNOFILE=1024 +ExecStart=/sbin/ip netns exec vns /usr/libexec/frr/frrinit.sh start vns +ExecStop=/sbin/ip netns exec vns /usr/libexec/frr/frrinit.sh stop vns +ExecReload=/sbin/ip netns exec vns /usr/libexec/frr/frrinit.sh reload vns + +[Install] +WantedBy=multi-user.target diff --git a/Sanity/basic-bgp/main.fmf b/Sanity/basic-bgp/main.fmf new file mode 100644 index 0000000..76651c9 --- /dev/null +++ b/Sanity/basic-bgp/main.fmf @@ -0,0 +1,22 @@ +summary: Basic BGP test +description: Testing BGP functionality without multihosts using virtual networks +contact: Frantisek Hrdina +component: + - frr +test: ./test.sh +framework: beakerlib +recommend: + - frr +require: + - library(virtual-network/virtual-network) +duration: 10m +enabled: true +tag: + - Tier1 +tier: '1' +environment: + AVC_ERROR: +no_avc_check +adjust: + - enabled: false + when: distro < rhel-8 + continue: false \ No newline at end of file diff --git a/Sanity/basic-bgp/test.sh b/Sanity/basic-bgp/test.sh new file mode 100755 index 0000000..94d1995 --- /dev/null +++ b/Sanity/basic-bgp/test.sh @@ -0,0 +1,388 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + + +PACKAGE="frr" + +SERVER_CLIENT_IF_ADDR="192.168.222.0" +SERVER_CLIENT_IF_PREFIX="24" + +SERVER_IF_ADDR="192.168.222.1" +SERVER_IF_PREFIX="24" +SERVER_IF_BCAST="192.168.222.255" + +SERVER_BGP_AS="65000" + +SERVER_STUB_1_IF_ADDR="192.168.101.0" +SERVER_STUB_1_IF_PREFIX="24" +SERVER_STUB_1_IF6_ADDR="2001:aaaa:bbbb:1000::" +SERVER_STUB_1_IF6_PREFIX="64" + +SERVER_STUB_2_IF_ADDR="192.168.102.0" +SERVER_STUB_2_IF_PREFIX="24" +SERVER_STUB_2_IF6_ADDR="2001:aaaa:bbbb:2000::" +SERVER_STUB_2_IF6_PREFIX="64" + +SERVER_FRR_LOG="/var/log/frr/frr-r1.log" +SERVER_CONF_DIR="/etc/frr/vns/" + +CLIENT_IF_ADDR="192.168.222.2" +CLIENT_IF_PREFIX="24" +CLIENT_IF_BCAST="192.168.222.255" + +CLIENT_BGP_AS="75000" + +CLIENT_STUB_1_IF_ADDR="192.168.201.0" +CLIENT_STUB_1_IF_PREFIX="24" +CLIENT_STUB_1_IF6_ADDR="2001:aaaa:bbbb:3000::" +CLIENT_STUB_1_IF6_PREFIX="64" + +CLIENT_STUB_2_IF_ADDR="192.168.202.0" +CLIENT_STUB_2_IF_PREFIX="24" +CLIENT_STUB_2_IF6_ADDR="2001:aaaa:bbbb:4000::" +CLIENT_STUB_2_IF6_PREFIX="64" + +CLIENT_FRR_LOG="/var/log/frr/frr-r2.log" +CLIENT_CONF_DIR="/etc/frr/vnc/" + +SERVER_CLIENT_IF6_ADDR="2001:aaaa:bbbb:5000::" +SERVER_CLIENT_IF6_PREFIX="64" + +SERVER_IF6_ADDR="2001:aaaa:bbbb:5000::1" +SERVER_IF6_PREFIX="64" + +CLIENT_IF6_ADDR="2001:aaaa:bbbb:5000::2" +CLIENT_IF6_PREFIX="64" + + +MAIN_LOG="/tmp/log_routes" + + +rlJournalStart + rlPhaseStartSetup "import virtual-network library" + rlRun "rlImport virtual-network/virtual-network" || rlDie "Import of the library required for the test failed" + rlPhaseEnd + + rlPhaseStartSetup + rlAssertRpm $PACKAGE + + TestDir=$(pwd) + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "pushd $tmp" + + # Need to disable SeLinux, because it does not allow to start service via unit file + # in a network namespace using "ip netns exec". And there are other issues with pid files, log files, etc. + rlRun "setenforce 0" 0 "Disabling SELinux" + rlRun "ORIG_AVC_ERROR=${AVC_ERROR}" + rlRun "AVC_ERROR=+no_avc_check" + + # set up the network, we want a specific IPv4 address for neighbor communication and two IPv6 addresses + # for the set src part of the configuration + vnCreateServerClientNetwork + vnRunServer "ip link set ${vnSERVER_IFACE} up" 0 "Setting the SERVER side of veth UP" + vnRunServer "ip link set lo up" 0 "Setting the SERVER side loopback UP" + vnRunClient "ip link set ${vnCLIENT_IFACE} up" 0 "Setting the CLIENT side of veth UP" + vnRunClient "ip link set lo up" 0 "Setting the CLIENT side loopback UP" + + vnRunServer "ip addr add ${SERVER_IF_ADDR}/${SERVER_IF_PREFIX} broadcast ${SERVER_IF_BCAST} dev ${vnSERVER_IFACE}" 0 "Configuring IPv4 address on SERVER side of veth" + vnRunServer "ip addr add ${SERVER_IF6_ADDR}/${SERVER_IF6_PREFIX} dev ${vnSERVER_IFACE}" 0 "Configuring IPv6 address on SERVER side of veth" + vnRunClient "ip addr add ${CLIENT_IF_ADDR}/${CLIENT_IF_PREFIX} broadcast ${CLIENT_IF_BCAST} dev ${vnCLIENT_IFACE}" 0 "Configuring IPv4 address on CLIENT side of veth" + vnRunClient "ip addr add ${CLIENT_IF6_ADDR}/${CLIENT_IF6_PREFIX} dev ${vnCLIENT_IFACE}" 0 "Configuring IPv6 address on CLIENT side of veth" + + + # Create isolated stub 1 network available only from SERVER network + vnRunServer "ip link add VNS_STUB_1 type veth peer name VNS_STUB_PEER_1" + vnRunServer "ip link set VNS_STUB_1 netns ${vnSERVER_NAMESPACE}" + vnRunServer "ip netns exec ${vnSERVER_NAMESPACE} ip addr add ${SERVER_STUB_1_IF_ADDR}/${SERVER_STUB_1_IF_PREFIX} dev VNS_STUB_1" + vnRunServer "ip netns exec ${vnSERVER_NAMESPACE} ip addr add ${SERVER_STUB_1_IF6_ADDR}/${SERVER_STUB_1_IF6_PREFIX} dev VNS_STUB_1" + vnRunServer "ip netns exec ${vnSERVER_NAMESPACE} ip link set VNS_STUB_1 up" + vnRunServer "ip link set VNS_STUB_PEER_1 up" + + # Create isolated stub 2 network available only from SERVER network + vnRunServer "ip link add VNS_STUB_2 type veth peer name VNS_STUB_PEER_2" + vnRunServer "ip link set VNS_STUB_2 netns ${vnSERVER_NAMESPACE}" + vnRunServer "ip netns exec ${vnSERVER_NAMESPACE} ip addr add ${SERVER_STUB_2_IF_ADDR}/${SERVER_STUB_2_IF_PREFIX} dev VNS_STUB_2" + vnRunServer "ip netns exec ${vnSERVER_NAMESPACE} ip addr add ${SERVER_STUB_2_IF6_ADDR}/${SERVER_STUB_2_IF6_PREFIX} dev VNS_STUB_2" + vnRunServer "ip netns exec ${vnSERVER_NAMESPACE} ip link set VNS_STUB_2 up" + vnRunServer "ip link set VNS_STUB_PEER_2 up" + + # Create isolated stub 1 network available only from CLIENT network + vnRunClient "ip link add VNC_STUB_1 type veth peer name VNC_STUB_PEER_1" + vnRunClient "ip link set VNC_STUB_1 netns ${vnCLIENT_NAMESPACE}" + vnRunClient "ip netns exec ${vnCLIENT_NAMESPACE} ip addr add ${CLIENT_STUB_1_IF_ADDR}/${CLIENT_STUB_1_IF_PREFIX} dev VNC_STUB_1" + vnRunClient "ip netns exec ${vnCLIENT_NAMESPACE} ip addr add ${CLIENT_STUB_1_IF6_ADDR}/${CLIENT_STUB_1_IF6_PREFIX} dev VNC_STUB_1" + vnRunClient "ip netns exec ${vnCLIENT_NAMESPACE} ip link set VNC_STUB_1 up" + vnRunClient "ip link set VNC_STUB_PEER_1 up" + + # Create isolated stub 2 network available only from CLIENT network + vnRunClient "ip link add VNC_STUB_2 type veth peer name VNC_STUB_PEER_2" + vnRunClient "ip link set VNC_STUB_2 netns ${vnCLIENT_NAMESPACE}" + vnRunClient "ip netns exec ${vnCLIENT_NAMESPACE} ip addr add ${CLIENT_STUB_2_IF_ADDR}/${CLIENT_STUB_2_IF_PREFIX} dev VNC_STUB_2" + vnRunClient "ip netns exec ${vnCLIENT_NAMESPACE} ip addr add ${CLIENT_STUB_2_IF6_ADDR}/${CLIENT_STUB_2_IF6_PREFIX} dev VNC_STUB_2" + vnRunClient "ip netns exec ${vnCLIENT_NAMESPACE} ip link set VNC_STUB_2 up" + vnRunClient "ip link set VNC_STUB_PEER_2 up" + + rlRun "ip a &> ip.log" + vnRunServer "ip a &> server-ip.log" + vnRunClient "ip a &> client-ip.log" + + rlRun "rlFileBackup --clean /etc/frr/" + rlRun "rlFileBackup --clean /etc/systemd/system/" + rlRun "rlFileBackup --clean /var/log/frr/" + rlRun "rlFileBackup --clean /var/log/audit/audit.log" + rlRun "rlFileBackup --clean /var/run/frr" + rlRun "rlFileBackup --clean /run/frr" + rlRun "rlFileBackup --clean /root/.history_frr" + rlRun "mkdir /etc/frr/{vns,vnc}" + + rm -rf /etc/frr/frr.conf + #vtysh.conf and frr.conf are in /etc/frr/vns for the server namespace + rlRun "cp -f $TestDir/vtysh-vns.conf ${SERVER_CONF_DIR}vtysh.conf" 0 "Copying vtysh configuration for the SERVER" + rlRun "cp -f $TestDir/frr-vns.conf ${SERVER_CONF_DIR}frr.conf" 0 "Copying frr configuration for the SERVER" + + #vtysh.conf and frr.conf are in /etc/frr/vnc for the client namespace + rlRun "cp -f $TestDir/vtysh-vnc.conf ${CLIENT_CONF_DIR}vtysh.conf" 0 "Copying vtysh configuration for the CLIENT" + rlRun "cp -f $TestDir/frr-vnc.conf ${CLIENT_CONF_DIR}frr.conf" 0 "Copying frr configuration for the CLIENT" + + #I need separate daemons files as well for watchfrr options + rlRun "cp -f $TestDir/daemons-vns ${SERVER_CONF_DIR}daemons" 0 "Copying daemons file for the SERVER" + rlRun "cp -f $TestDir/daemons-vnc ${CLIENT_CONF_DIR}daemons" 0 "Copying daemons file for the CLIENT" + + rlRun "ls -lR /etc/frr/*" + rlRun "cp -f $TestDir/frr-vn{s,c}.service /etc/systemd/system/" 0 "Copying custom unit files to run frr in network namespaces" + + # /etc/frr/vns/frr.conf + rlRun "sed -i 's||${SERVER_FRR_LOG}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_IF_ADDR}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_IF_ADDR}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_IF6_ADDR}|g' ${SERVER_CONF_DIR}frr.conf" + + rlRun "sed -i 's||${SERVER_BGP_AS}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${CLIENT_BGP_AS}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_STUB_1_IF_ADDR}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_STUB_1_IF_PREFIX}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_STUB_2_IF_ADDR}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_STUB_2_IF_PREFIX}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_STUB_1_IF6_ADDR}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_STUB_1_IF6_PREFIX}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_STUB_2_IF6_ADDR}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_STUB_2_IF6_PREFIX}|g' ${SERVER_CONF_DIR}frr.conf" + + rlRun "sed -i 's||${SERVER_CLIENT_IF_ADDR}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_CLIENT_IF_PREFIX}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${CLIENT_IF_ADDR}|g' ${SERVER_CONF_DIR}frr.conf" + + rlRun "sed -i 's||${SERVER_CLIENT_IF6_ADDR}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_CLIENT_IF6_PREFIX}|g' ${SERVER_CONF_DIR}frr.conf" + rlRun "sed -i 's||${CLIENT_IF6_ADDR}|g' ${SERVER_CONF_DIR}frr.conf" + + # /etc/frr/vnc/frr.conf + rlRun "sed -i 's||${CLIENT_FRR_LOG}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${CLIENT_IF_ADDR}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${CLIENT_IF_ADDR}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${CLIENT_IF6_ADDR}|g' ${CLIENT_CONF_DIR}frr.conf" + + rlRun "sed -i 's||${SERVER_BGP_AS}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${CLIENT_BGP_AS}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${CLIENT_STUB_1_IF_ADDR}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${CLIENT_STUB_1_IF_PREFIX}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${CLIENT_STUB_2_IF_ADDR}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${CLIENT_STUB_2_IF_PREFIX}|g' ${CLIENT_CONF_DIR}frr.conf" + + rlRun "sed -i 's||${CLIENT_STUB_1_IF6_ADDR}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${CLIENT_STUB_1_IF6_PREFIX}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${CLIENT_STUB_2_IF6_ADDR}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${CLIENT_STUB_2_IF6_PREFIX}|g' ${CLIENT_CONF_DIR}frr.conf" + + rlRun "sed -i 's||${SERVER_CLIENT_IF_ADDR}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_CLIENT_IF_PREFIX}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_IF_ADDR}|g' ${CLIENT_CONF_DIR}frr.conf" + + rlRun "sed -i 's||${SERVER_CLIENT_IF6_ADDR}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_CLIENT_IF6_PREFIX}|g' ${CLIENT_CONF_DIR}frr.conf" + rlRun "sed -i 's||${SERVER_IF6_ADDR}|g' ${CLIENT_CONF_DIR}frr.conf" + + rlRun "systemctl daemon-reload" + rlPhaseEnd + + rlPhaseStartTest + vnRunServer "ping -c 1 ${SERVER_STUB_1_IF_ADDR}" 0 "Server should be capable to ping its stub 1 ipv4 address" + vnRunServer "ping -c 1 ${SERVER_STUB_2_IF_ADDR}" 0 "Server should be capable to ping its stub 2 ipv4 address" + + vnRunServer "ping -c 1 ${CLIENT_STUB_1_IF_ADDR}" 2 "Server should NOT be capable to ping client's stub 1 ipv4 address before FRR with BGP is run" + vnRunServer "ping -c 1 ${CLIENT_STUB_1_IF_ADDR}" 2 "Server should NOT be capable to ping client's stub 2 ipv4 address before FRR with BGP is run" + + vnRunClient "ping -c 1 ${CLIENT_STUB_1_IF_ADDR}" 0 "Client should be capable to ping its stub 1 ipv4 address" + vnRunClient "ping -c 1 ${CLIENT_STUB_2_IF_ADDR}" 0 "Client should be capable to ping its stub 2 ipv4 address" + + vnRunClient "ping -c 1 ${SERVER_STUB_1_IF_ADDR}" 2 "Client should NOT be capable to ping server's stub 1 ipv4 address before FRR with BGP is run" + vnRunClient "ping -c 1 ${SERVER_STUB_2_IF_ADDR}" 2 "Client should NOT be capable to ping server's stub 2 ipv4 address before FRR with BGP is run" + + vnRunServer "ping6 -c 1 ${SERVER_STUB_1_IF6_ADDR}" 0 "Server should be capable to ping its stub 1 ipv6 address" + vnRunServer "ping6 -c 1 ${SERVER_STUB_2_IF6_ADDR}" 0 "Server should be capable to ping its stub 2 ipv6 address" + + vnRunServer "ping6 -c 1 ${CLIENT_STUB_1_IF6_ADDR}" 2 "Server should NOT be capable to ping client's stub 1 ipv6 address before FRR with BGP is run" + vnRunServer "ping6 -c 1 ${CLIENT_STUB_1_IF6_ADDR}" 2 "Server should NOT be capable to ping client's stub 2 ipv6 address before FRR with BGP is run" + + vnRunClient "ping6 -c 1 ${CLIENT_STUB_1_IF6_ADDR}" 0 "Client should be capable to ping its stub 1 ipv6 address" + vnRunClient "ping6 -c 1 ${CLIENT_STUB_2_IF6_ADDR}" 0 "Client should be capable to ping its stub 2 ipv6 address" + + vnRunClient "ping6 -c 1 ${SERVER_STUB_1_IF6_ADDR}" 2 "Client should NOT be capable to ping server's stub 1 ipv6 address before FRR with BGP is run" + vnRunClient "ping6 -c 1 ${SERVER_STUB_2_IF6_ADDR}" 2 "Client should NOT be capable to ping server's stub 2 ipv6 address before FRR with BGP is run" + + rlRun "systemctl start frr-vns.service" 0 "Starting FRR on SERVER side" + rlRun "systemctl start frr-vnc.service" 0 "Starting FRR on CLIENT side" + + if rlIsRHEL ">8.3" || rlIsFedora || rlIsCentOS '>=8'; then + rlRun "vtysh -N vns -c 'configure terminal' -c 'router bgp $SERVER_BGP_AS' -c 'no bgp ebgp-requires-policy'" + rlRun "vtysh -N vnc -c 'configure terminal' -c 'router bgp $CLIENT_BGP_AS' -c 'no bgp ebgp-requires-policy'" + fi + + #vtysh also needs to run for a specific namespace + rlRun "vtysh -N vns -c 'sh run' &> server-show-running-config.log" + rlRun "vtysh -N vnc -c 'sh run' &> client-show-running-config.log" + + vnRunServer "ping -c 1 ${CLIENT_IF_ADDR}" 0 "Testing that server can ping client ipv4 address" + vnRunClient "ping -c 1 ${SERVER_IF_ADDR}" 0 "Testing that client can ping server ipv4 address" + + vnRunServer "ping6 -c 1 ${CLIENT_IF6_ADDR}" 0 "Testing that server can ping client ipv6 address" + vnRunClient "ping6 -c 1 ${SERVER_IF6_ADDR}" 0 "Testing that client can ping server ipv6 address" + + rlRun "sleep 60" 0 "Waiting for peers to exchange routes and converge" + rlPhaseEnd + + rlPhaseStartTest "ipv4" + # check server + rlRun "vtysh -N vns -c 'show ip bgp ipv4 neighbors' &> server-show-ip-bgp-ipv4-neighbors.log" + rlAssertGrep "BGP state = Established" server-show-ip-bgp-ipv4-neighbors.log + rlAssertGrep "BGP neighbor is $CLIENT_IF_ADDR, remote AS $CLIENT_BGP_AS, local AS $SERVER_BGP_AS" server-show-ip-bgp-ipv4-neighbors.log + + rlRun "vtysh -N vns -c 'sh ip bgp ipv4' &> server-show-ip-bgp-ipv4.log" + rlAssertGrep "\*>\s*${CLIENT_STUB_1_IF_ADDR}/${CLIENT_STUB_1_IF_PREFIX} ${CLIENT_IF_ADDR}\s*0\s*0 ${CLIENT_BGP_AS} i" server-show-ip-bgp-ipv4.log -E + rlAssertGrep "\*>\s*${CLIENT_STUB_2_IF_ADDR}/${CLIENT_STUB_2_IF_PREFIX} ${CLIENT_IF_ADDR}\s*0\s*0 ${CLIENT_BGP_AS} i" server-show-ip-bgp-ipv4.log -E + if rlIsRHELLike '>=10' || rlIsFedora; then + rlAssertGrep "\*\s*${CLIENT_IF_ADDR}\s*0\s*0 ${CLIENT_BGP_AS} i" server-show-ip-bgp-ipv4.log -E + else + rlAssertGrep "\*\s*${SERVER_CLIENT_IF_ADDR}/${SERVER_CLIENT_IF_PREFIX} ${CLIENT_IF_ADDR}\s*0\s*0 ${CLIENT_BGP_AS} i" server-show-ip-bgp-ipv4.log -E + fi + rlRun "vtysh -N vns -c 'show ip route' &> server-show-ip-route.log" + rlAssertGrep "B>\* ${CLIENT_STUB_1_IF_ADDR}" server-show-ip-route.log + rlAssertGrep "B>\* ${CLIENT_STUB_2_IF_ADDR}" server-show-ip-route.log + + + # check client + rlRun "vtysh -N vnc -c 'show ip bgp ipv4 neighbors' &> client-show-ip-bgp-ipv4-neighbors.log" + rlAssertGrep "BGP state = Established" client-show-ip-bgp-ipv4-neighbors.log + rlAssertGrep "BGP neighbor is $SERVER_IF_ADDR, remote AS $SERVER_BGP_AS, local AS $CLIENT_BGP_AS" client-show-ip-bgp-ipv4-neighbors.log + + rlRun "vtysh -N vnc -c 'sh ip bgp ipv4' &> client-show-ip-bgp-ipv4.log" + rlAssertGrep "\*>\s*${SERVER_STUB_1_IF_ADDR}/${SERVER_STUB_1_IF_PREFIX} ${SERVER_IF_ADDR}\s*0\s*0 ${SERVER_BGP_AS} i" client-show-ip-bgp-ipv4.log -E + rlAssertGrep "\*>\s*${SERVER_STUB_2_IF_ADDR}/${SERVER_STUB_2_IF_PREFIX} ${SERVER_IF_ADDR}\s*0\s*0 ${SERVER_BGP_AS} i" client-show-ip-bgp-ipv4.log -E + if rlIsRHELLike '>=10' || rlIsFedora; then + rlAssertGrep "\*\s*${SERVER_IF_ADDR}\s*0\s*0 ${SERVER_BGP_AS} i" client-show-ip-bgp-ipv4.log -E + else + rlAssertGrep "\*\s*${SERVER_CLIENT_IF_ADDR}/${SERVER_CLIENT_IF_PREFIX} ${SERVER_IF_ADDR}\s*0\s*0 ${SERVER_BGP_AS} i" client-show-ip-bgp-ipv4.log -E + fi + + rlRun "vtysh -N vnc -c 'show ip route' &> client-show-ip-route.log" + rlAssertGrep "B>\* ${SERVER_STUB_1_IF_ADDR}" client-show-ip-route.log + rlAssertGrep "B>\* ${SERVER_STUB_2_IF_ADDR}" client-show-ip-route.log + + + vnRunServer "ping -c 1 ${CLIENT_STUB_1_IF_ADDR}" 0 "Server should be capable to ping client's stub 1 ipv4 address since FRR with BGP is run" + vnRunServer "ping -c 1 ${CLIENT_STUB_2_IF_ADDR}" 0 "Server should be capable to ping client's stub 2 ipv4 address since FRR with BGP is run" + vnRunClient "ping -c 1 ${SERVER_STUB_1_IF_ADDR}" 0 "Client should be capable to ping server's stub 1 ipv4 address since FRR with BGP is run" + vnRunClient "ping -c 1 ${SERVER_STUB_2_IF_ADDR}" 0 "Client should be capable to ping server's stub 2 ipv4 address since FRR with BGP is run" + rlPhaseEnd + + rlPhaseStartTest "ipv6" + # check server + rlRun "vtysh -N vns -c 'show ip bgp ipv6 neighbors' &> server-show-ip-bgp-ipv6-neighbors.log" + rlAssertGrep "BGP state = Established" server-show-ip-bgp-ipv6-neighbors.log + rlAssertGrep "BGP neighbor is $CLIENT_IF6_ADDR, remote AS $CLIENT_BGP_AS, local AS $SERVER_BGP_AS" server-show-ip-bgp-ipv6-neighbors.log + + rlRun "vtysh -N vns -c 'sh ip bgp ipv6 wide' &> server-show-ip-bgp-ipv6.log" + rlAssertGrep "\*>\s*${CLIENT_STUB_1_IF6_ADDR}/${CLIENT_STUB_1_IF6_PREFIX}.*\s*0\s*0 ${CLIENT_BGP_AS} i" server-show-ip-bgp-ipv6.log -E + rlAssertGrep "\*>\s*${CLIENT_STUB_2_IF6_ADDR}/${CLIENT_STUB_2_IF6_PREFIX}.*\s*0\s*0 ${CLIENT_BGP_AS} i" server-show-ip-bgp-ipv6.log -E + if rlIsRHELLike '>=10' || rlIsFedora; then + rlAssertGrep "\*\s*.*\s*0\s*0 ${CLIENT_BGP_AS} i" server-show-ip-bgp-ipv6.log -E + else + rlAssertGrep "\*\s*${SERVER_CLIENT_IF6_ADDR}.*\s*0\s*0 ${CLIENT_BGP_AS} i" server-show-ip-bgp-ipv6.log -E + fi + + rlRun "vtysh -N vns -c 'show ipv6 route' &> server-show-ipv6-route.log" + rlAssertGrep "B>\* ${CLIENT_STUB_1_IF6_ADDR}" server-show-ipv6-route.log + rlAssertGrep "B>\* ${CLIENT_STUB_2_IF6_ADDR}" server-show-ipv6-route.log + + + # check client + rlRun "vtysh -N vnc -c 'show ip bgp ipv6 neighbors' &> client-show-ip-bgp-ipv6-neighbors.log" + rlAssertGrep "BGP state = Established" client-show-ip-bgp-ipv6-neighbors.log + rlAssertGrep "BGP neighbor is $SERVER_IF6_ADDR, remote AS $SERVER_BGP_AS, local AS $CLIENT_BGP_AS" client-show-ip-bgp-ipv6-neighbors.log + + rlRun "vtysh -N vnc -c 'sh ip bgp ipv6 wide' &> client-show-ip-bgp-ipv6.log" + rlAssertGrep "\*>\s*${SERVER_STUB_1_IF6_ADDR}/${SERVER_STUB_1_IF6_PREFIX}.*\s*0\s*0 ${SERVER_BGP_AS} i" client-show-ip-bgp-ipv6.log -E + rlAssertGrep "\*>\s*${SERVER_STUB_2_IF6_ADDR}/${SERVER_STUB_2_IF6_PREFIX}.*\s*0\s*0 ${SERVER_BGP_AS} i" client-show-ip-bgp-ipv6.log -E + if rlIsRHELLike '>=10' || rlIsFedora; then + rlAssertGrep "\*\s*.*\s*0\s*0 ${CLIENT_BGP_AS} i" server-show-ip-bgp-ipv6.log -E + else + rlAssertGrep "\*\s*${SERVER_CLIENT_IF6_ADDR}.*\s*0\s*0 ${SERVER_BGP_AS} i" client-show-ip-bgp-ipv6.log -E + fi + + rlRun "vtysh -N vnc -c 'show ipv6 route' &> client-show-ipv6-route.log" + rlAssertGrep "B>\* ${SERVER_STUB_1_IF6_ADDR}" client-show-ipv6-route.log + rlAssertGrep "B>\* ${SERVER_STUB_2_IF6_ADDR}" client-show-ipv6-route.log + + + vnRunServer "ping6 -c 1 ${CLIENT_STUB_1_IF6_ADDR}" 0 "Server should be capable to ping client's stub 1 ipv6 address since FRR with BGP is run" + vnRunServer "ping6 -c 1 ${CLIENT_STUB_2_IF6_ADDR}" 0 "Server should be capable to ping client's stub 2 ipv6 address since FRR with BGP is run" + vnRunClient "ping6 -c 1 ${SERVER_STUB_1_IF6_ADDR}" 0 "Client should be capable to ping server's stub 1 ipv6 address since FRR with BGP is run" + vnRunClient "ping6 -c 1 ${SERVER_STUB_2_IF6_ADDR}" 0 "Client should be capable to ping server's stub 2 ipv6 address since FRR with BGP is run" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "systemctl stop frr-vns.service frr-vnc.service" 0 "Stopping FRR" + + rlFileSubmit "ip.log" + rlFileSubmit "server-ip.log" + rlFileSubmit "client-ip.log" + + rlFileSubmit "${SERVER_CONF_DIR}frr.conf" + rlFileSubmit "server-show-running-config.log" + rlFileSubmit "server-show-ip-bgp-ipv4-neighbors.log" + rlFileSubmit "server-show-ip-bgp-ipv4.log" + rlFileSubmit "server-show-ip-route.log" + rlFileSubmit "server-show-ip-bgp-ipv6-neighbors.log" + rlFileSubmit "server-show-ip-bgp-ipv6.log" + rlFileSubmit "server-show-ipv6-route.log" + rlFileSubmit $SERVER_FRR_LOG + + rlFileSubmit "${CLIENT_CONF_DIR}frr.conf" + rlFileSubmit "client-show-running-config.log" + rlFileSubmit "client-show-ip-bgp-ipv4-neighbors.log" + rlFileSubmit "client-show-ip-bgp-ipv4.log" + rlFileSubmit "client-show-ip-route.log" + rlFileSubmit "client-show-ip-bgp-ipv6-neighbors.log" + rlFileSubmit "client-show-ip-bgp-ipv6.log" + rlFileSubmit "client-show-ipv6-route.log" + rlFileSubmit $CLIENT_FRR_LOG + + vnRemoveServerClientNetwork + + rlFileRestore + rlRun "systemctl daemon-reload" + + # restoring SELinux + rlRun "setenforce 1" 0 "re-Enabling SELinux" + rlRun "AVC_ERROR=${ORIG_AVC_ERROR}" + + # This should prevent propagating AVCs to the tests, that are following + rlRun "fixfiles restore" + rlRun "restorecon -R -v /" + + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/Sanity/basic-bgp/vtysh-vnc.conf b/Sanity/basic-bgp/vtysh-vnc.conf new file mode 100644 index 0000000..e0ab9cb --- /dev/null +++ b/Sanity/basic-bgp/vtysh-vnc.conf @@ -0,0 +1 @@ +service integrated-vtysh-config diff --git a/Sanity/basic-bgp/vtysh-vns.conf b/Sanity/basic-bgp/vtysh-vns.conf new file mode 100644 index 0000000..e0ab9cb --- /dev/null +++ b/Sanity/basic-bgp/vtysh-vns.conf @@ -0,0 +1 @@ +service integrated-vtysh-config