summaryrefslogtreecommitdiff
path: root/regress/usr.sbin/bgpd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2019-08-06 15:49:58 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2019-08-06 15:49:58 +0000
commitbc14dab0c7d3f32f51ffb504fa451ad872d9fae4 (patch)
treedf3ea7ba0f62809074fef0ca95f6d276e90790c6 /regress/usr.sbin/bgpd
parent7b67b977cc22cacf9a7699ec5c0a633840d8f7a4 (diff)
Implement RFC7607 testing using exabgp since we need to fiddle with
attributes. Currently not enabled since it will fail.
Diffstat (limited to 'regress/usr.sbin/bgpd')
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/Makefile23
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/api-exabgp.sh11
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/as0.sh105
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/bgpd.as0.conf8
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test1.in27
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2.in28
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2.ok4
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2_2.in24
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2_3.in27
9 files changed, 255 insertions, 2 deletions
diff --git a/regress/usr.sbin/bgpd/integrationtests/Makefile b/regress/usr.sbin/bgpd/integrationtests/Makefile
index 8658b26ade2..33e50536f13 100644
--- a/regress/usr.sbin/bgpd/integrationtests/Makefile
+++ b/regress/usr.sbin/bgpd/integrationtests/Makefile
@@ -1,9 +1,10 @@
-# $OpenBSD: Makefile,v 1.6 2019/08/06 07:31:53 claudio Exp $
+# $OpenBSD: Makefile,v 1.7 2019/08/06 15:49:57 claudio Exp $
REGRESS_TARGETS = network_statement md5 ovs mrt
+
BGPD ?= /usr/sbin/bgpd
-CLEANFILES += *.mrt *.out
+CLEANFILES += *.mrt *.out *.conf *.log
network_statement:
${SUDO} ksh ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11 12 pair11 pair12
@@ -17,4 +18,22 @@ ovs:
mrt:
${SUDO} ksh ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11
+.if ! exists(/usr/local/bin/exabgp)
+# install exabgp from ports for additional tests
+as0:
+ @echo SKIPPED
+.else
+
+.SUFFIXES: .conf .in
+.in.conf:
+ sed 's|##BGPDCONFIGDIR##|${.CURDIR}|' ${.IMPSRC} > ${.TARGET} || \
+ (rm ${.TARGET} && exit 1)
+
+AS0_CONFS = exabgp.as0.test1.conf \
+ exabgp.as0.test2.conf exabgp.as0.test2_2.conf exabgp.as0.test2_3.conf
+
+as0: ${AS0_CONFS}
+ ${SUDO} ksh ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11 12 pair11 pair12
+.endif
+
.include <bsd.regress.mk>
diff --git a/regress/usr.sbin/bgpd/integrationtests/api-exabgp.sh b/regress/usr.sbin/bgpd/integrationtests/api-exabgp.sh
new file mode 100644
index 00000000000..0804058f76a
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/api-exabgp.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# ignore Control C, exabgp will send a TERM
+trap '' SIGINT
+
+(sleep 10 && echo shutdown) &
+
+while read line; do
+ [ -z "$line" ] && continue
+ echo "$line" >&2
+done
diff --git a/regress/usr.sbin/bgpd/integrationtests/as0.sh b/regress/usr.sbin/bgpd/integrationtests/as0.sh
new file mode 100644
index 00000000000..6e87a887d80
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/as0.sh
@@ -0,0 +1,105 @@
+#!/bin/ksh
+# $OpenBSD: as0.sh,v 1.1 2019/08/06 15:49:57 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
+PAIR2IP2=10.12.57.3
+PAIR2IP3=10.12.57.4
+
+error_notify() {
+ echo cleanup
+ pkill -T ${RDOMAIN1} bgpd || true
+ pkill -T ${RDOMAIN2} exabgp || 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
+}
+
+run_exabgp() {
+ local _t=$1
+
+ shift
+ env exabgp.log.destination=stdout \
+ exabgp.log.packets=true \
+ exabgp.log.parser=true \
+ exabgp.log.level=DEBUG \
+ exabgp.api.cli=false \
+ exabgp.daemon.user=build \
+ route -T ${RDOMAIN2} exec exabgp -1 ${1+"$@"} > ./exabgp.$_t.log
+}
+
+if [ ! -x /usr/local/bin/exabgp ]; then
+ echo install exabgp from ports for this test >&2
+ exit 1
+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}/29 up
+ifconfig ${PAIR2} rdomain ${RDOMAIN2} ${PAIR2IP}/29 up
+ifconfig ${PAIR2} alias ${PAIR2IP2}/32
+ifconfig ${PAIR2} alias ${PAIR2IP3}/32
+ifconfig ${PAIR1} patch ${PAIR2}
+ifconfig lo${RDOMAIN1} inet 127.0.0.1/8
+ifconfig lo${RDOMAIN2} inet 127.0.0.1/8
+
+echo run bgpd
+route -T ${RDOMAIN1} exec ${BGPD} \
+ -v -f ${BGPDCONFIGDIR}/bgpd.as0.conf
+
+sleep 1
+
+echo test1
+run_exabgp test1 exabgp.as0.test1.conf > as0.test1.out 2>&1
+grep -q 'error[OPEN message error / Bad Peer AS]' as0.test1.out && echo OK
+
+echo test2
+run_exabgp test2 exabgp.as0.test2*.conf > as0.test2.out 2>&1
+grep 'receive update announced' as0.test2.out | sort | \
+ diff -u ${BGPDCONFIGDIR}/exabgp.as0.test2.ok /dev/stdin
+echo OK
+
+exit 0
diff --git a/regress/usr.sbin/bgpd/integrationtests/bgpd.as0.conf b/regress/usr.sbin/bgpd/integrationtests/bgpd.as0.conf
new file mode 100644
index 00000000000..7678397a2af
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/bgpd.as0.conf
@@ -0,0 +1,8 @@
+AS 64500
+router-id 10.12.57.1
+fib-update no
+
+neighbor 10.12.57.0/29
+
+allow from any
+allow to any
diff --git a/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test1.in b/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test1.in
new file mode 100644
index 00000000000..f81234ecd28
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test1.in
@@ -0,0 +1,27 @@
+process reader {
+ run /bin/sh "##BGPDCONFIGDIR##/api-exabgp.sh";
+ encoder text;
+}
+
+neighbor 10.12.57.1 {
+ router-id 10.12.57.2;
+ local-address 10.12.57.2;
+ local-as 0;
+ peer-as 64500;
+ group-updates;
+ adj-rib-in false;
+ passive false;
+
+ family {
+ ipv4 unicast;
+ }
+
+ static {
+ route 10.12.59.0/24 next-hop self;
+ }
+
+ api {
+ processes [ reader ];
+ neighbor-changes;
+ }
+}
diff --git a/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2.in b/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2.in
new file mode 100644
index 00000000000..826b1020985
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2.in
@@ -0,0 +1,28 @@
+process reader {
+ run /bin/sh "##BGPDCONFIGDIR##/api-exabgp.sh";
+ encoder text;
+}
+
+neighbor 10.12.57.1 {
+ router-id 10.12.57.2;
+ local-address 10.12.57.2;
+ local-as 64501;
+ peer-as 64500;
+ group-updates;
+ adj-rib-in false;
+ passive false;
+
+ family {
+ ipv4 unicast;
+ }
+
+ api {
+ processes [ reader ];
+ neighbor-changes;
+ receive {
+ parsed;
+ update;
+ notification;
+ }
+ }
+}
diff --git a/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2.ok b/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2.ok
new file mode 100644
index 00000000000..d7997c79d1a
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2.ok
@@ -0,0 +1,4 @@
+neighbor 10.12.57.1 receive update announced 10.12.1.0/24 next-hop 10.12.57.3 origin igp as-path [ 64500 64502 ]
+neighbor 10.12.57.1 receive update announced 10.12.3.0/24 next-hop 10.12.57.3 origin igp as-path [ 64500 64502 64505 ]
+neighbor 10.12.57.1 receive update announced 10.13.1.0/24 next-hop 10.12.57.4 origin igp as-path [ 64500 64503 ]
+neighbor 10.12.57.1 receive update announced 10.13.3.0/24 next-hop 10.12.57.4 origin igp as-path [ 64500 64503 64505 ] aggregator ( 23456:127.0.0.1 )
diff --git a/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2_2.in b/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2_2.in
new file mode 100644
index 00000000000..74f4999dcb7
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2_2.in
@@ -0,0 +1,24 @@
+process reader {
+ run /bin/sh "##BGPDCONFIGDIR##/api-exabgp.sh";
+ encoder text;
+}
+
+neighbor 10.12.57.1 {
+ router-id 10.12.57.3;
+ local-address 10.12.57.3;
+ local-as 64502;
+ peer-as 64500;
+ group-updates;
+ adj-rib-in false;
+ passive false;
+
+ family {
+ ipv4 unicast;
+ }
+
+ static {
+ route 10.12.1.0/24 next-hop self ;
+ route 10.12.2.0/24 next-hop self as-path [ 64502 0 64505 ];
+ route 10.12.3.0/24 next-hop self as-path [ 64502 64505 ] aggregator 0:127.0.0.1;
+ }
+}
diff --git a/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2_3.in b/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2_3.in
new file mode 100644
index 00000000000..8fe297af34e
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/exabgp.as0.test2_3.in
@@ -0,0 +1,27 @@
+process reader {
+ run /bin/sh "##BGPDCONFIGDIR##/api-exabgp.sh";
+ encoder text;
+}
+
+neighbor 10.12.57.1 {
+ router-id 10.12.57.4;
+ local-address 10.12.57.4;
+ local-as 64503;
+ peer-as 64500;
+ group-updates;
+ adj-rib-in false;
+ passive false;
+
+ family {
+ ipv4 unicast;
+ }
+ capability {
+ asn4 disable;
+ }
+
+ static {
+ route 10.13.1.0/24 next-hop self ;
+ route 10.13.2.0/24 next-hop self attribute [ 0x02 0x40 0x0103fbf75ba0fbf9 ] attribute [ 0x11 0xc0 0x01030000fbf7000000000000fbf9 ];
+ route 10.13.3.0/24 next-hop self as-path [ 64503 64505 ] aggregator 23456:127.0.0.1 attribute [ 0x12 0xc0 0x000000007f000001 ];
+ }
+}