summaryrefslogtreecommitdiff
path: root/regress/usr.sbin/bgpd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2019-06-22 08:26:27 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2019-06-22 08:26:27 +0000
commitfeb35fddcc77afde052dcf3ba66d93cd31f4d52d (patch)
treead838a840cdb3b4ac2fef3b7c304e9b598c22e17 /regress/usr.sbin/bgpd
parent2b1befadb9f3caf820a053e76bbb181c549ec397 (diff)
Add a basic test to check that mrt table dumps work.
Hint: they don't right now
Diffstat (limited to 'regress/usr.sbin/bgpd')
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/Makefile9
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/bgpd.mrt.conf64
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/mrt-table-mp.ok32
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/mrt-table-v2.ok32
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/mrt-table.ok32
-rw-r--r--regress/usr.sbin/bgpd/integrationtests/mrt.sh54
6 files changed, 221 insertions, 2 deletions
diff --git a/regress/usr.sbin/bgpd/integrationtests/Makefile b/regress/usr.sbin/bgpd/integrationtests/Makefile
index 22959f7a8d3..ec169e6e1be 100644
--- a/regress/usr.sbin/bgpd/integrationtests/Makefile
+++ b/regress/usr.sbin/bgpd/integrationtests/Makefile
@@ -1,8 +1,10 @@
-# $OpenBSD: Makefile,v 1.4 2019/03/22 20:44:31 denis Exp $
+# $OpenBSD: Makefile,v 1.5 2019/06/22 08:26:26 claudio Exp $
-REGRESS_TARGETS = network_statement md5 ovs
+REGRESS_TARGETS = network_statement md5 ovs mrt
BGPD ?= /usr/sbin/bgpd
+CLEANFILES += *.mrt *.out
+
network_statement:
${SUDO} ksh -x ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11 12 pair11 pair12
@@ -12,4 +14,7 @@ md5:
ovs:
${SUDO} ksh -x ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11 12 pair11 pair12
+mrt:
+ ${SUDO} ksh -x ${.CURDIR}/$@.sh ${BGPD} ${.CURDIR} 11
+
.include <bsd.regress.mk>
diff --git a/regress/usr.sbin/bgpd/integrationtests/bgpd.mrt.conf b/regress/usr.sbin/bgpd/integrationtests/bgpd.mrt.conf
new file mode 100644
index 00000000000..3583139d6cc
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/bgpd.mrt.conf
@@ -0,0 +1,64 @@
+AS 4200000001
+router-id 42.0.0.1
+
+network 192.0.2.0/24 set {
+ localpref 15
+ med 42
+ origin egp
+ prepend-self 5
+ nexthop 1.2.3.4 }
+network 198.51.100.0/24 set {
+ community 42:1 community GRACEFUL_SHUTDOWN
+ ext-community rt 127.0.0.1:15 ext-community ovs invalid
+ large-community 4200000001:42:1 large-community 4200000001:2:4200000001
+}
+network 203.0.113.0/24
+
+network 2001:db8:1::/48 set {
+ localpref 15
+ med 42
+ origin egp
+ prepend-self 5
+ nexthop 2001:db8:42::1 }
+network 2001:db8:2::/48 set {
+ community 42:1 community GRACEFUL_SHUTDOWN
+ ext-community rt 127.0.0.1:15 ext-community ovs invalid
+ large-community 4200000001:42:1 large-community 4200000001:2:4200000001
+}
+network 2001:db8:3::/48
+
+vpn "dummy" on mpe11 {
+ rd 4200000001:1
+ import-target rt 4200000001:42
+ export-target rt 4200000001:42
+
+ network 192.0.2.0/24 set {
+ localpref 15
+ med 42
+ origin egp
+ prepend-self 5
+ nexthop 1.2.3.4 }
+ network 198.51.100.0/24 set {
+ community 42:1 community GRACEFUL_SHUTDOWN
+ ext-community rt 127.0.0.1:15 ext-community ovs invalid
+ large-community 4200000001:42:1 large-community 4200000001:2:42
+ }
+ network 203.0.113.0/24
+
+ network 2001:db8:1::/48 set {
+ localpref 15
+ med 42
+ origin egp
+ prepend-self 5
+ nexthop 2001:db8:42::1 }
+ network 2001:db8:2::/48 set {
+ community 42:1 community GRACEFUL_SHUTDOWN
+ ext-community rt 127.0.0.1:15 ext-community ovs invalid
+ large-community 4200000001:42:1 large-community 4200000001:2:42
+ }
+ network 2001:db8:3::/48
+}
+
+dump table-v2 "./mrt-table-v2.mrt"
+dump table-mp "./mrt-table-mp.mrt"
+dump table "./mrt-table.mrt"
diff --git a/regress/usr.sbin/bgpd/integrationtests/mrt-table-mp.ok b/regress/usr.sbin/bgpd/integrationtests/mrt-table-mp.ok
new file mode 100644
index 00000000000..52ea61960af
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/mrt-table-mp.ok
@@ -0,0 +1,32 @@
+
+BGP routing table entry for 192.0.2.0/24
+ 4200000001 4200000001 4200000001 4200000001 4200000001
+ Nexthop 1.2.3.4 (via 1.2.3.4) Neighbor 0.0.0.0 (0.0.0.0)
+ Origin EGP, metric 42, localpref 15, weight 0, ovs not-found, external
+
+BGP routing table entry for 198.51.100.0/24
+ Nexthop 0.0.0.0 (via 0.0.0.0) Neighbor 0.0.0.0 (0.0.0.0)
+ Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external
+ Communities: 42:1 GRACEFUL_SHUTDOWN
+ Ext. Communities: ovs invalid rt 127.0.0.1:15
+ Large Communities: 4200000001:2:4200000001 4200000001:42:1
+
+BGP routing table entry for 203.0.113.0/24
+ Nexthop 0.0.0.0 (via 0.0.0.0) Neighbor 0.0.0.0 (0.0.0.0)
+ Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external
+
+BGP routing table entry for 2001:db8:1::/48
+ 4200000001 4200000001 4200000001 4200000001 4200000001
+ Nexthop 2001:db8:42::1 (via 2001:db8:42::1) Neighbor :: (0.0.0.0)
+ Origin EGP, metric 42, localpref 15, weight 0, ovs not-found, external
+
+BGP routing table entry for 2001:db8:2::/48
+ Nexthop :: (via ::) Neighbor :: (0.0.0.0)
+ Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external
+ Communities: 42:1 GRACEFUL_SHUTDOWN
+ Ext. Communities: ovs invalid rt 127.0.0.1:15
+ Large Communities: 4200000001:2:4200000001 4200000001:42:1
+
+BGP routing table entry for 2001:db8:3::/48
+ Nexthop :: (via ::) Neighbor :: (0.0.0.0)
+ Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external
diff --git a/regress/usr.sbin/bgpd/integrationtests/mrt-table-v2.ok b/regress/usr.sbin/bgpd/integrationtests/mrt-table-v2.ok
new file mode 100644
index 00000000000..9aa07a67dc2
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/mrt-table-v2.ok
@@ -0,0 +1,32 @@
+
+BGP routing table entry for 192.0.2.0/24
+ 4200000001 4200000001 4200000001 4200000001 4200000001
+ Nexthop 1.2.3.4 (via 1.2.3.4) Neighbor 0.0.0.0 (42.0.0.1)
+ Origin EGP, metric 42, localpref 15, weight 0, ovs not-found, external
+
+BGP routing table entry for 198.51.100.0/24
+ Nexthop 0.0.0.0 (via 0.0.0.0) Neighbor 0.0.0.0 (42.0.0.1)
+ Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external
+ Communities: 42:1 GRACEFUL_SHUTDOWN
+ Ext. Communities: ovs invalid rt 127.0.0.1:15
+ Large Communities: 4200000001:2:4200000001 4200000001:42:1
+
+BGP routing table entry for 203.0.113.0/24
+ Nexthop 0.0.0.0 (via 0.0.0.0) Neighbor 0.0.0.0 (42.0.0.1)
+ Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external
+
+BGP routing table entry for 2001:db8:1::/48
+ 4200000001 4200000001 4200000001 4200000001 4200000001
+ Nexthop 2001:db8:42::1 (via 2001:db8:42::1) Neighbor 0.0.0.0 (42.0.0.1)
+ Origin EGP, metric 42, localpref 15, weight 0, ovs not-found, external
+
+BGP routing table entry for 2001:db8:2::/48
+ Nexthop :: (via ::) Neighbor 0.0.0.0 (42.0.0.1)
+ Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external
+ Communities: 42:1 GRACEFUL_SHUTDOWN
+ Ext. Communities: ovs invalid rt 127.0.0.1:15
+ Large Communities: 4200000001:2:4200000001 4200000001:42:1
+
+BGP routing table entry for 2001:db8:3::/48
+ Nexthop :: (via ::) Neighbor 0.0.0.0 (42.0.0.1)
+ Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external
diff --git a/regress/usr.sbin/bgpd/integrationtests/mrt-table.ok b/regress/usr.sbin/bgpd/integrationtests/mrt-table.ok
new file mode 100644
index 00000000000..52ea61960af
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/mrt-table.ok
@@ -0,0 +1,32 @@
+
+BGP routing table entry for 192.0.2.0/24
+ 4200000001 4200000001 4200000001 4200000001 4200000001
+ Nexthop 1.2.3.4 (via 1.2.3.4) Neighbor 0.0.0.0 (0.0.0.0)
+ Origin EGP, metric 42, localpref 15, weight 0, ovs not-found, external
+
+BGP routing table entry for 198.51.100.0/24
+ Nexthop 0.0.0.0 (via 0.0.0.0) Neighbor 0.0.0.0 (0.0.0.0)
+ Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external
+ Communities: 42:1 GRACEFUL_SHUTDOWN
+ Ext. Communities: ovs invalid rt 127.0.0.1:15
+ Large Communities: 4200000001:2:4200000001 4200000001:42:1
+
+BGP routing table entry for 203.0.113.0/24
+ Nexthop 0.0.0.0 (via 0.0.0.0) Neighbor 0.0.0.0 (0.0.0.0)
+ Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external
+
+BGP routing table entry for 2001:db8:1::/48
+ 4200000001 4200000001 4200000001 4200000001 4200000001
+ Nexthop 2001:db8:42::1 (via 2001:db8:42::1) Neighbor :: (0.0.0.0)
+ Origin EGP, metric 42, localpref 15, weight 0, ovs not-found, external
+
+BGP routing table entry for 2001:db8:2::/48
+ Nexthop :: (via ::) Neighbor :: (0.0.0.0)
+ Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external
+ Communities: 42:1 GRACEFUL_SHUTDOWN
+ Ext. Communities: ovs invalid rt 127.0.0.1:15
+ Large Communities: 4200000001:2:4200000001 4200000001:42:1
+
+BGP routing table entry for 2001:db8:3::/48
+ Nexthop :: (via ::) Neighbor :: (0.0.0.0)
+ Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, external
diff --git a/regress/usr.sbin/bgpd/integrationtests/mrt.sh b/regress/usr.sbin/bgpd/integrationtests/mrt.sh
new file mode 100644
index 00000000000..c54ccc5bf20
--- /dev/null
+++ b/regress/usr.sbin/bgpd/integrationtests/mrt.sh
@@ -0,0 +1,54 @@
+#!/bin/ksh
+# $OpenBSD: mrt.sh,v 1.1 2019/06/22 08:26:26 claudio Exp $
+
+set -e
+
+BGPD=$1
+BGPDCONFIGDIR=$2
+RDOMAIN1=$3
+
+error_notify() {
+ echo cleanup
+ pkill -T ${RDOMAIN1} bgpd || true
+ sleep 1
+ echo cleanup rdomain
+ route -qn -T ${RDOMAIN1} flush || true
+ echo cleanup interfaces
+ ifconfig mpe${RDOMAIN1} destroy || true
+ ifconfig lo${RDOMAIN1} destroy || true
+ if [ $1 -ne 0 ]; then
+ echo FAILED
+ exit 1
+ else
+ echo SUCCESS
+ fi
+}
+
+trap 'error_notify $?' EXIT
+
+echo check if rdomains are busy
+if /sbin/ifconfig lo${RDOMAIN1} > /dev/null 2>&1; then
+ echo routing domain ${RDOMAIN1} is already used >&2; exit 1;
+fi
+
+echo setup
+ifconfig mpe${RDOMAIN1} rdomain ${RDOMAIN1} mplslabel 42
+ifconfig lo${RDOMAIN1} inet 127.0.0.1/8
+
+route -T ${RDOMAIN1} exec ${BGPD} \
+ -v -f ${BGPDCONFIGDIR}/bgpd.mrt.conf
+
+sleep 2
+
+pkill -USR1 -T ${RDOMAIN1} -U 0 bgpd
+
+sleep 2
+
+for i in table-v2 table-mp table; do
+ echo test $i
+ bgpctl show mrt detail file mrt-$i.mrt | \
+ grep -v 'Last update:' > mrt-$i.out
+ diff -u ${BGPDCONFIGDIR}/mrt-$i.ok mrt-$i.out
+done
+
+exit 0