summaryrefslogtreecommitdiff
path: root/regress/usr.sbin/bgpd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2020-01-26 00:54:48 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2020-01-26 00:54:48 +0000
commit29e254b7f151abb7caac5dcc488bc541a4605909 (patch)
tree7502801a95bb74af47820dc05dca1db524630f3b /regress/usr.sbin/bgpd
parent539f80d2dc71ca492f3c90298526e2482443dbed (diff)
Also test maxprefix out. Based on maxprefix test added a few days ago.
Diffstat (limited to 'regress/usr.sbin/bgpd')
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/Makefile8
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefixout.rdomain1.conf16
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefixout.rdomain2.conf15
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/maxprefixout.sh87
4 files changed, 124 insertions, 2 deletions
diff --git a/regress/usr.sbin/bgpd/integrationtests/Makefile b/regress/usr.sbin/bgpd/integrationtests/Makefile
index 71924c0fd3b..168bf8226fc 100644
--- a/regress/usr.sbin/bgpd/integrationtests/Makefile
+++ b/regress/usr.sbin/bgpd/integrationtests/Makefile
@@ -1,6 +1,7 @@
-# $OpenBSD: Makefile,v 1.10 2020/01/22 02:01:11 claudio Exp $
+# $OpenBSD: Makefile,v 1.11 2020/01/26 00:54:47 claudio Exp $
-REGRESS_TARGETS = network_statement md5 ovs mrt maxprefix as0
+REGRESS_TARGETS = network_statement md5 ovs mrt \
+ maxprefix maxprefixout as0
BGPD ?= /usr/sbin/bgpd
@@ -21,6 +22,9 @@ mrt:
maxprefix:
${SUDO} ksh ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11 12 pair11 pair12
+maxprefixout:
+ ${SUDO} ksh ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11 12 pair11 pair12
+
.if ! exists(/usr/local/bin/exabgp)
as0:
# install exabgp from ports for additional tests
diff --git a/regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefixout.rdomain1.conf b/regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefixout.rdomain1.conf
new file mode 100644
index 00000000000..a009d9ca0f3
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefixout.rdomain1.conf
@@ -0,0 +1,16 @@
+AS 4200000001
+router-id 10.12.57.1
+fib-update no
+
+log updates
+
+neighbor 10.12.57.2 {
+ descr "RDOMAIN2"
+ remote-as 4200000002
+ max-prefix 2 out
+}
+
+deny from any
+deny to any
+
+allow to any
diff --git a/regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefixout.rdomain2.conf b/regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefixout.rdomain2.conf
new file mode 100644
index 00000000000..0e428e42fc0
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefixout.rdomain2.conf
@@ -0,0 +1,15 @@
+AS 4200000002
+router-id 10.12.57.2
+fib-update no
+
+log updates
+
+neighbor 10.12.57.1 {
+ descr "RDOMAIN1"
+ remote-as 4200000001
+}
+
+deny from any
+deny to any
+
+allow from any
diff --git a/regress/usr.sbin/bgpd/integrationtests/maxprefixout.sh b/regress/usr.sbin/bgpd/integrationtests/maxprefixout.sh
new file mode 100644
index 00000000000..647469224db
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/maxprefixout.sh
@@ -0,0 +1,87 @@
+#!/bin/ksh
+# $OpenBSD: maxprefixout.sh,v 1.1 2020/01/26 00:54:47 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.maxprefixout.rdomain1.conf
+route -T ${RDOMAIN2} exec ${BGPD} \
+ -v -f ${BGPDCONFIGDIR}/bgpd.maxprefixout.rdomain2.conf
+
+sleep 3
+
+echo test1: add two networks
+route -T ${RDOMAIN1} exec bgpctl network add 10.12.58.0/24
+route -T ${RDOMAIN1} exec bgpctl network add 10.12.59.0/24
+sleep 1
+route -T ${RDOMAIN1} exec bgpctl show nei | \
+ awk '/^ Prefixes/ { if ($2 == "2") { print "ok"; ok=1; exit 0; } }
+ END { if (ok != 1) { print "bad bgpctl output"; exit 2; } }'
+
+echo test1: add another network
+route -T ${RDOMAIN1} exec bgpctl network add 10.12.60.0/24
+sleep 1
+route -T ${RDOMAIN1} exec bgpctl show nei | \
+ grep '^ Last error sent: Cease, sent max-prefix exceeded'