From a703828ff742a335b57a409d7a43d2a5b5ab5af1 Mon Sep 17 00:00:00 2001 From: claudio Date: Tue, 31 May 2022 09:50:26 +0000 Subject: [PATCH] Introduce a integration test for max-communities --- .../usr.sbin/bgpd/integrationtests/Makefile | 13 ++- .../bgpd.maxcomm.rdomain1.conf | 25 ++++++ .../bgpd.maxcomm.rdomain2.conf | 53 ++++++++++++ .../usr.sbin/bgpd/integrationtests/maxcomm.ok | 25 ++++++ .../usr.sbin/bgpd/integrationtests/maxcomm.sh | 80 +++++++++++++++++++ 5 files changed, 193 insertions(+), 3 deletions(-) create mode 100644 regress/usr.sbin/bgpd/integrationtests/bgpd.maxcomm.rdomain1.conf create mode 100644 regress/usr.sbin/bgpd/integrationtests/bgpd.maxcomm.rdomain2.conf create mode 100644 regress/usr.sbin/bgpd/integrationtests/maxcomm.ok create mode 100644 regress/usr.sbin/bgpd/integrationtests/maxcomm.sh diff --git a/regress/usr.sbin/bgpd/integrationtests/Makefile b/regress/usr.sbin/bgpd/integrationtests/Makefile index a0399c9c1f2..1192fea92ff 100644 --- a/regress/usr.sbin/bgpd/integrationtests/Makefile +++ b/regress/usr.sbin/bgpd/integrationtests/Makefile @@ -1,8 +1,8 @@ -# $OpenBSD: Makefile,v 1.14 2021/04/13 07:39:17 claudio Exp $ +# $OpenBSD: Makefile,v 1.15 2022/05/31 09:50:26 claudio Exp $ REGRESS_TARGETS = network_statement md5 ovs mrt \ - maxprefix maxprefixout as0 med \ - eval_all + maxprefix maxprefixout maxcomm \ + as0 med eval_all BGPD ?= /usr/sbin/bgpd @@ -28,6 +28,9 @@ maxprefix: maxprefixout: ${SUDO} ksh ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11 12 pair11 pair12 +maxcomm: + ${SUDO} ksh ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11 12 pair11 pair12 + .if ! exists(/usr/local/bin/exabgp) as0: # install exabgp from ports for additional tests @@ -36,6 +39,10 @@ as0: med: # install exabgp from ports for additional tests @echo SKIPPED + +eval_all: + # install exabgp from ports for additional tests + @echo SKIPPED .else .SUFFIXES: .conf .in diff --git a/regress/usr.sbin/bgpd/integrationtests/bgpd.maxcomm.rdomain1.conf b/regress/usr.sbin/bgpd/integrationtests/bgpd.maxcomm.rdomain1.conf new file mode 100644 index 00000000000..523ba32c3ce --- /dev/null +++ b/regress/usr.sbin/bgpd/integrationtests/bgpd.maxcomm.rdomain1.conf @@ -0,0 +1,25 @@ +AS 4200000001 +router-id 10.12.57.1 +fib-update no + +neighbor 10.12.57.2 { + descr "RDOMAIN2" + remote-as 4200000002 +} + +deny from any +deny to any + +allow from any + +match from any max-communities 0 set metric +1 +match from any max-ext-communities 0 set metric +10 +match from any max-large-communities 0 set metric +100 + +match from any max-communities 2 set metric +2 +match from any max-ext-communities 2 set metric +20 +match from any max-large-communities 2 set metric +200 + +match from any max-communities 1 max-ext-communities 1 max-large-communities 1 \ + set metric +1000 + diff --git a/regress/usr.sbin/bgpd/integrationtests/bgpd.maxcomm.rdomain2.conf b/regress/usr.sbin/bgpd/integrationtests/bgpd.maxcomm.rdomain2.conf new file mode 100644 index 00000000000..e481bba8cd9 --- /dev/null +++ b/regress/usr.sbin/bgpd/integrationtests/bgpd.maxcomm.rdomain2.conf @@ -0,0 +1,53 @@ +AS 4200000002 +router-id 10.12.57.2 +fib-update no + +C1="community 1:1" +C2="community 1:1 community 1:2" +C3="community 1:1 community 1:2 community 1:3" +C4="community 1:1 community 1:2 community 1:3 community 1:4" + +EC1="ext-community rt 1:1" +EC2="ext-community rt 1:1 ext-community rt 1:2" +EC3="ext-community rt 1:1 ext-community rt 1:2 ext-community rt 1:3" +EC4="ext-community rt 1:1 ext-community rt 1:2 ext-community rt 1:3 \ + ext-community rt 1:4" + +LC1="large-community 1:1:1" +LC2="large-community 1:1:1 large-community 1:1:2" +LC3="large-community 1:1:1 large-community 1:1:2 large-community 1:1:3" +LC4="large-community 1:1:1 large-community 1:1:2 large-community 1:1:3 \ + large-community 1:1:4" + +network 10.12.0.0/24 +network 10.12.1.0/24 set { $C1 } +network 10.12.2.0/24 set { $C2 } +network 10.12.3.0/24 set { $C3 } +network 10.12.4.0/24 set { $C4 } + +network 10.13.0.0/24 +network 10.13.1.0/24 set { $EC1 } +network 10.13.2.0/24 set { $EC2 } +network 10.13.3.0/24 set { $EC3 } +network 10.13.4.0/24 set { $EC4 } + +network 10.14.0.0/24 +network 10.14.1.0/24 set { $LC1 } +network 10.14.2.0/24 set { $LC2 } +network 10.14.3.0/24 set { $LC3 } +network 10.14.4.0/24 set { $LC4 } + +network 10.15.0.0/24 +network 10.15.1.0/24 set { $C1 $EC1 $LC1 } +network 10.15.2.0/24 set { $C2 $EC2 $LC2 } +network 10.15.3.0/24 set { $C3 $EC3 $LC3 } + +neighbor 10.12.57.1 { + descr "RDOMAIN1" + remote-as 4200000001 +} + +deny from any +deny to any + +allow to any diff --git a/regress/usr.sbin/bgpd/integrationtests/maxcomm.ok b/regress/usr.sbin/bgpd/integrationtests/maxcomm.ok new file mode 100644 index 00000000000..313ed029739 --- /dev/null +++ b/regress/usr.sbin/bgpd/integrationtests/maxcomm.ok @@ -0,0 +1,25 @@ +flags: * = Valid, > = Selected, I = via IBGP, A = Announced, + S = Stale, E = Error +origin validation state: N = not-found, V = valid, ! = invalid +origin: i = IGP, e = EGP, ? = Incomplete + +flags ovs destination gateway lpref med aspath origin +*> N 10.12.0.0/24 10.12.57.2 100 0 4200000002 i +*> N 10.12.1.0/24 10.12.57.2 100 1 4200000002 i +*> N 10.12.2.0/24 10.12.57.2 100 1 4200000002 i +*> N 10.12.3.0/24 10.12.57.2 100 3 4200000002 i +*> N 10.12.4.0/24 10.12.57.2 100 3 4200000002 i +*> N 10.13.0.0/24 10.12.57.2 100 0 4200000002 i +*> N 10.13.1.0/24 10.12.57.2 100 10 4200000002 i +*> N 10.13.2.0/24 10.12.57.2 100 10 4200000002 i +*> N 10.13.3.0/24 10.12.57.2 100 30 4200000002 i +*> N 10.13.4.0/24 10.12.57.2 100 30 4200000002 i +*> N 10.14.0.0/24 10.12.57.2 100 0 4200000002 i +*> N 10.14.1.0/24 10.12.57.2 100 100 4200000002 i +*> N 10.14.2.0/24 10.12.57.2 100 100 4200000002 i +*> N 10.14.3.0/24 10.12.57.2 100 300 4200000002 i +*> N 10.14.4.0/24 10.12.57.2 100 300 4200000002 i +*> N 10.15.0.0/24 10.12.57.2 100 0 4200000002 i +*> N 10.15.1.0/24 10.12.57.2 100 111 4200000002 i +*> N 10.15.2.0/24 10.12.57.2 100 1111 4200000002 i +*> N 10.15.3.0/24 10.12.57.2 100 1333 4200000002 i diff --git a/regress/usr.sbin/bgpd/integrationtests/maxcomm.sh b/regress/usr.sbin/bgpd/integrationtests/maxcomm.sh new file mode 100644 index 00000000000..1662ebff284 --- /dev/null +++ b/regress/usr.sbin/bgpd/integrationtests/maxcomm.sh @@ -0,0 +1,80 @@ +#!/bin/ksh +# $OpenBSD: maxcomm.sh,v 1.1 2022/05/31 09:50:26 claudio Exp $ + +set -e + +BGPD=$1 +BGPDCONFIGDIR=$2 +RDOMAIN1=$3 +RDOMAIN2=$4 +PAIR1=$5 +PAIR2=$6 + +RDOMAINS="${RDOMAIN1} ${RDOMAIN2}" +PAIRS="${PAIR1} ${PAIR2}" +PAIR1IP=10.12.57.1 +PAIR2IP=10.12.57.2 + +error_notify() { + echo cleanup + pkill -T ${RDOMAIN1} bgpd || true + pkill -T ${RDOMAIN2} bgpd || true + sleep 1 + ifconfig ${PAIR2} destroy || true + ifconfig ${PAIR1} destroy || true + route -qn -T ${RDOMAIN1} flush || true + route -qn -T ${RDOMAIN2} flush || true + ifconfig lo${RDOMAIN1} destroy || true + ifconfig lo${RDOMAIN2} destroy || true + if [ $1 -ne 0 ]; then + echo FAILED + exit 1 + else + echo SUCCESS + fi +} + +if [ "$(id -u)" -ne 0 ]; then + echo need root privileges >&2 + exit 1 +fi + +trap 'error_notify $?' EXIT + +echo check if rdomains are busy +for n in ${RDOMAINS}; do + if /sbin/ifconfig | grep -v "^lo${n}:" | grep " rdomain ${n} "; then + echo routing domain ${n} is already used >&2 + exit 1 + fi +done + +echo check if interfaces are busy +for n in ${PAIRS}; do + /sbin/ifconfig "${n}" >/dev/null 2>&1 && \ + ( echo interface ${n} is already used >&2; exit 1 ) +done + +set -x + +echo setup +ifconfig ${PAIR1} rdomain ${RDOMAIN1} ${PAIR1IP}/30 up +ifconfig ${PAIR2} rdomain ${RDOMAIN2} ${PAIR2IP}/30 up +ifconfig ${PAIR1} patch ${PAIR2} +ifconfig lo${RDOMAIN1} inet 127.0.0.1/8 +ifconfig lo${RDOMAIN2} inet 127.0.0.1/8 + +echo run bgpds +route -T ${RDOMAIN1} exec ${BGPD} \ + -v -f ${BGPDCONFIGDIR}/bgpd.maxcomm.rdomain1.conf +sleep 1 +route -T ${RDOMAIN2} exec ${BGPD} \ + -v -f ${BGPDCONFIGDIR}/bgpd.maxcomm.rdomain2.conf + +sleep 2 +route -T ${RDOMAIN1} exec bgpctl sh rib | tee maxcomm.out +sleep .2 +diff -u ${BGPDCONFIGDIR}/maxcomm.ok maxcomm.out +echo OK + +exit 0 -- 2.20.1