From: claudio Date: Wed, 28 Aug 2024 13:14:39 +0000 (+0000) Subject: Extend maxprefix and maxprefixout tests to also check that the limits X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=988ce863cc09490c3d442845d78d27731b198a22;p=openbsd Extend maxprefix and maxprefixout tests to also check that the limits are checked during reload. --- diff --git a/regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefix.rdomain2.conf b/regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefix.rdomain2.conf index 63a6e111766..714a7944970 100644 --- a/regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefix.rdomain2.conf +++ b/regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefix.rdomain2.conf @@ -7,7 +7,7 @@ log updates neighbor 10.12.57.1 { descr "RDOMAIN1" remote-as 4200000001 - max-prefix 2 + #MAX-PREFIX# } deny from any diff --git a/regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefixout.rdomain1.conf b/regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefixout.rdomain1.conf index a009d9ca0f3..74a24f8c9ce 100644 --- a/regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefixout.rdomain1.conf +++ b/regress/usr.sbin/bgpd/integrationtests/bgpd.maxprefixout.rdomain1.conf @@ -7,7 +7,7 @@ log updates neighbor 10.12.57.2 { descr "RDOMAIN2" remote-as 4200000002 - max-prefix 2 out + #MAX-PREFIX# } deny from any diff --git a/regress/usr.sbin/bgpd/integrationtests/maxprefix.sh b/regress/usr.sbin/bgpd/integrationtests/maxprefix.sh index fa4baf568e1..0fcefe2a0b6 100644 --- a/regress/usr.sbin/bgpd/integrationtests/maxprefix.sh +++ b/regress/usr.sbin/bgpd/integrationtests/maxprefix.sh @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: maxprefix.sh,v 1.3 2023/02/15 14:19:08 claudio Exp $ +# $OpenBSD: maxprefix.sh,v 1.4 2024/08/28 13:14:39 claudio Exp $ set -e @@ -64,12 +64,14 @@ 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 +echo test1: run bgpds +sed -e 's/#MAX-PREFIX#/max-prefix 2/' \ + ${BGPDCONFIGDIR}/bgpd.maxprefix.rdomain2.conf > \ + ./bgpd.maxprefix.rdomain2.conf route -T ${RDOMAIN1} exec ${BGPD} \ -v -f ${BGPDCONFIGDIR}/bgpd.maxprefix.rdomain1.conf route -T ${RDOMAIN2} exec ${BGPD} \ - -v -f ${BGPDCONFIGDIR}/bgpd.maxprefix.rdomain2.conf - + -v -f ./bgpd.maxprefix.rdomain2.conf sleep 1 route -T ${RDOMAIN1} exec bgpctl nei RDOMAIN2 up sleep 1 @@ -87,3 +89,38 @@ route -T ${RDOMAIN1} exec bgpctl network add 10.12.60.0/24 sleep 1 route -T ${RDOMAIN1} exec bgpctl show nei | \ grep '^ Last error received: Cease, received max-prefix exceeded' + +echo test1: cleanup +pkill -T ${RDOMAIN1} bgpd || true +pkill -T ${RDOMAIN2} bgpd || true +sleep 1 + +echo test2: run bgpds +sed -e 's/#MAX-PREFIX#/max-prefix 10/' \ + ${BGPDCONFIGDIR}/bgpd.maxprefix.rdomain2.conf > \ + ./bgpd.maxprefix.rdomain2.conf +route -T ${RDOMAIN1} exec ${BGPD} \ + -v -f ${BGPDCONFIGDIR}/bgpd.maxprefix.rdomain1.conf +route -T ${RDOMAIN2} exec ${BGPD} \ + -v -f ./bgpd.maxprefix.rdomain2.conf +sleep 1 +route -T ${RDOMAIN1} exec bgpctl nei RDOMAIN2 up +sleep 1 + +echo test2: add three 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 +route -T ${RDOMAIN1} exec bgpctl network add 10.12.60.0/24 +sleep 1 +route -T ${RDOMAIN1} exec bgpctl show nei | \ + awk '/^ Prefixes/ { if ($2 == "3") { print "ok"; ok=1; exit 0; } } + END { if (ok != 1) { print "bad bgpctl output"; exit 2; } }' + +echo test2: reload config +sed -e 's/#MAX-PREFIX#/max-prefix 2/' \ + ${BGPDCONFIGDIR}/bgpd.maxprefix.rdomain2.conf > \ + ./bgpd.maxprefix.rdomain2.conf +route -T ${RDOMAIN2} exec bgpctl reload +sleep 1 +route -T ${RDOMAIN1} exec bgpctl show nei | \ + grep '^ Last error received: Cease, received max-prefix exceeded' diff --git a/regress/usr.sbin/bgpd/integrationtests/maxprefixout.sh b/regress/usr.sbin/bgpd/integrationtests/maxprefixout.sh index 77c1fcb6904..644be5d2207 100644 --- a/regress/usr.sbin/bgpd/integrationtests/maxprefixout.sh +++ b/regress/usr.sbin/bgpd/integrationtests/maxprefixout.sh @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: maxprefixout.sh,v 1.2 2023/02/15 14:19:08 claudio Exp $ +# $OpenBSD: maxprefixout.sh,v 1.3 2024/08/28 13:14:39 claudio Exp $ set -e @@ -64,9 +64,12 @@ 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 +echo test1: run bgpds +sed -e 's/#MAX-PREFIX#/max-prefix 2 out/' \ + ${BGPDCONFIGDIR}/bgpd.maxprefixout.rdomain1.conf > \ + ./bgpd.maxprefixout.rdomain1.conf route -T ${RDOMAIN1} exec ${BGPD} \ - -v -f ${BGPDCONFIGDIR}/bgpd.maxprefixout.rdomain1.conf + -v -f ./bgpd.maxprefixout.rdomain1.conf route -T ${RDOMAIN2} exec ${BGPD} \ -v -f ${BGPDCONFIGDIR}/bgpd.maxprefixout.rdomain2.conf @@ -87,3 +90,39 @@ 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' + +echo test1: cleanup +pkill -T ${RDOMAIN1} bgpd || true +pkill -T ${RDOMAIN2} bgpd || true +sleep 1 + +echo test2: run bgpds +sed -e 's/#MAX-PREFIX#/max-prefix 20 out/' \ + ${BGPDCONFIGDIR}/bgpd.maxprefixout.rdomain1.conf > \ + ./bgpd.maxprefixout.rdomain1.conf +route -T ${RDOMAIN1} exec ${BGPD} \ + -v -f ./bgpd.maxprefixout.rdomain1.conf +route -T ${RDOMAIN2} exec ${BGPD} \ + -v -f ${BGPDCONFIGDIR}/bgpd.maxprefixout.rdomain2.conf + +sleep 1 +route -T ${RDOMAIN1} exec bgpctl nei RDOMAIN2 up +sleep 1 + +echo test2: add three 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 +route -T ${RDOMAIN1} exec bgpctl network add 10.12.60.0/24 +sleep 1 +route -T ${RDOMAIN1} exec bgpctl show nei | \ + awk '/^ Prefixes/ { if ($2 == "3") { print "ok"; ok=1; exit 0; } } + END { if (ok != 1) { print "bad bgpctl output"; exit 2; } }' + +echo test2: reload config +sed -e 's/#MAX-PREFIX#/max-prefix 2 out/' \ + ${BGPDCONFIGDIR}/bgpd.maxprefixout.rdomain1.conf > \ + ./bgpd.maxprefixout.rdomain1.conf +route -T ${RDOMAIN1} exec bgpctl reload +sleep 1 +route -T ${RDOMAIN1} exec bgpctl show nei | \ + grep '^ Last error sent: Cease, sent max-prefix exceeded'