diff --git a/bin/tests/system/conf.sh.in b/bin/tests/system/conf.sh.in index 43716c034c..4ab0f91aab 100644 --- a/bin/tests/system/conf.sh.in +++ b/bin/tests/system/conf.sh.in @@ -101,6 +101,13 @@ else TESTSOCK6=false fi +if grep "^#define WANT_IPV6 1" $TOP/config.h > /dev/null 2>&1 ; then + TESTSOCK6="$TESTSOCK6" +else + TESTSOCK6=false +fi + + PYTHON=@PYTHON@ # diff --git a/bin/tests/system/digdelv/tests.sh b/bin/tests/system/digdelv/tests.sh index e33b04c658..7974df0b17 100644 --- a/bin/tests/system/digdelv/tests.sh +++ b/bin/tests/system/digdelv/tests.sh @@ -179,6 +179,65 @@ if [ -x ${DIG} ] ; then grep "^weeks.example. 1814400" < dig.out.test$n > /dev/null || ret=1 if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` + + n=`expr $n + 1` + echo "I:checking dig -6 -4 ($n)" + ret=0 + $DIG $DIGOPTS +tcp @10.53.0.2 -4 -6 A a.example > dig.out.test$n 2>&1 && ret=1 + grep "only one of -4 and -6 allowed" < dig.out.test$n > /dev/null || ret=1 + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` + + n=`expr $n + 1` + echo "I:checking dig @IPv6addr -4 A a.example ($n)" + if $TESTSOCK6 fd92:7065:b8e:ffff::2 + then + ret=0 + $DIG $DIGOPTS +tcp @fd92:7065:b8e:ffff::2 -4 A a.example > dig.out.test$n 2>&1 && ret=1 + grep "address family not supported" < dig.out.test$n > /dev/null || ret=1 + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` + else + echo "I:IPv6 unavailable; skipping" + fi + + n=`expr $n + 1` + echo "I:checking dig @IPv4addr -6 A a.example ($n)" + if $TESTSOCK6 fd92:7065:b8e:ffff::2 + then + ret=0 + ret=0 + $DIG $DIGOPTS +tcp @10.53.0.2 -6 A a.example > dig.out.test$n 2>&1 || ret=1 + grep "SERVER: ::ffff:10.53.0.2#5300" < dig.out.test$n > /dev/null || ret=1 + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` + else + echo "I:IPv6 unavailable; skipping" + fi + + n=`expr $n + 1` + echo "I:checking dig +subnet ($n)" + ret=0 + $DIG $DIGOPTS +tcp @10.53.0.2 +subnet=127.0.0.1 A a.example > dig.out.test$n 2>&1 || ret=1 + grep "CLIENT-SUBNET: 127.0.0.1/32/0" < dig.out.test$n > /dev/null || ret=1 + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` + + n=`expr $n + 1` + echo "I:checking dig +sp works as an abbriviated form of split ($n)" + ret=0 + $DIG $DIGOPTS @10.53.0.3 +sp=4 -t sshfp foo.example > dig.out.test$n || ret=1 + grep " 9ABC DEF6 7890 " < dig.out.test$n > /dev/null || ret=1 + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` + + n=`expr $n + 1` + echo "I:checking dig -c works ($n)" + ret=0 + $DIG $DIGOPTS @10.53.0.3 -c CHAOS -t txt version.bind > dig.out.test$n || ret=1 + grep "version.bind. 0 CH TXT" < dig.out.test$n > /dev/null || ret=1 + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` else echo "$DIG is needed, so skipping these dig tests" @@ -302,6 +361,38 @@ if [ -x ${DELV} ] ; then test "${f:-0}" -eq 4 || ret=1 if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` + + n=`expr $n + 1` + echo "I:checking delv +sp works as an abbriviated form of split ($n)" + ret=0 + $DELV $DELVOPTS @10.53.0.3 +sp=4 -t sshfp foo.example > delv.out.test$n || ret=1 + grep " 9ABC DEF6 7890 " < delv.out.test$n > /dev/null || ret=1 + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` + + n=`expr $n + 1` + echo "I:checking delv +sh works as an abbriviated form of short ($n)" + ret=0 + $DELV $DELVOPTS @10.53.0.3 +sh a a.example > delv.out.test$n || ret=1 + if test `wc -l < delv.out.test$n` != 1 ; then ret=1 ; fi + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` + + n=`expr $n + 1` + echo "I:checking delv -c IN works ($n)" + ret=0 + $DELV $DELVOPTS @10.53.0.3 -c IN -t a a.example > delv.out.test$n || ret=1 + grep "a.example." < delv.out.test$n > /dev/null || ret=1 + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` + + n=`expr $n + 1` + echo "I:checking delv -c CH is ignored, and treated like IN ($n)" + ret=0 + $DELV $DELVOPTS @10.53.0.3 -c CH -t a a.example > delv.out.test$n || ret=1 + grep "a.example." < delv.out.test$n > /dev/null || ret=1 + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` exit $status else diff --git a/bin/tests/system/reclimit/tests.sh b/bin/tests/system/reclimit/tests.sh index eee69febca..50f9b16ff0 100644 --- a/bin/tests/system/reclimit/tests.sh +++ b/bin/tests/system/reclimit/tests.sh @@ -31,7 +31,12 @@ $DIG $DIGOPTS @10.53.0.3 indirect1.example.org > dig.out.1.test$n || ret=1 grep "status: SERVFAIL" dig.out.1.test$n > /dev/null || ret=1 $DIG $DIGOPTS +short @10.53.0.2 count txt > dig.out.2.test$n || ret=1 eval count=`cat dig.out.2.test$n` -[ $count -eq 26 ] || ret=1 +if $TESTSOCK6 != false +then + [ $count -eq 26 ] || { ret=1; echo "I: count ($count) != 26"; } +else + [ $count -eq 14 ] || { ret=1; echo "I: count ($count) != 14"; } +fi if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` @@ -45,7 +50,12 @@ $DIG $DIGOPTS @10.53.0.3 indirect2.example.org > dig.out.1.test$n || ret=1 grep "status: NOERROR" dig.out.1.test$n > /dev/null || ret=1 $DIG $DIGOPTS +short @10.53.0.2 count txt > dig.out.2.test$n || ret=1 eval count=`cat dig.out.2.test$n` -[ $count -eq 49 ] || ret=1 +if $TESTSOCK6 != false +then + [ $count -eq 49 ] || { ret=1; echo "I: count ($count) != 49"; } +else + [ $count -eq 26 ] || { ret=1; echo "I: count ($count) != 26"; } +fi if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` @@ -64,7 +74,12 @@ $DIG $DIGOPTS @10.53.0.3 indirect3.example.org > dig.out.1.test$n || ret=1 grep "status: SERVFAIL" dig.out.1.test$n > /dev/null || ret=1 $DIG $DIGOPTS +short @10.53.0.2 count txt > dig.out.2.test$n || ret=1 eval count=`cat dig.out.2.test$n` -[ $count -eq 12 ] || ret=1 +if $TESTSOCK6 != false +then + [ $count -eq 12 ] || { ret=1; echo "I: count ($count) != 12"; } +else + [ $count -eq 7 ] || { ret=1; echo "I: count ($count) != 7"; } +fi if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` @@ -78,7 +93,12 @@ $DIG $DIGOPTS @10.53.0.3 indirect4.example.org > dig.out.1.test$n || ret=1 grep "status: NOERROR" dig.out.1.test$n > /dev/null || ret=1 $DIG $DIGOPTS +short @10.53.0.2 count txt > dig.out.2.test$n || ret=1 eval count=`cat dig.out.2.test$n` -[ $count -eq 21 ] || ret=1 +if $TESTSOCK6 != false +then + [ $count -eq 21 ] || { ret=1; echo "I: count ($count) != 21"; } +else + [ $count -eq 12 ] || { ret=1; echo "I: count ($count) != 12"; } +fi if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` @@ -94,10 +114,13 @@ echo "13" > ans2/ans.limit $RNDC -c ../common/rndc.conf -s 10.53.0.3 -p 9953 flush 2>&1 | sed 's/^/I:ns1 /' $DIG $DIGOPTS @10.53.0.2 reset > /dev/null || ret=1 $DIG $DIGOPTS @10.53.0.3 indirect5.example.org > dig.out.1.test$n || ret=1 -grep "status: SERVFAIL" dig.out.1.test$n > /dev/null || ret=1 +if $TESTSOCK6 != false +then + grep "status: SERVFAIL" dig.out.1.test$n > /dev/null || ret=1 +fi $DIG $DIGOPTS +short @10.53.0.2 count txt > dig.out.2.test$n || ret=1 eval count=`cat dig.out.2.test$n` -[ $count -le 50 ] || ret=1 +[ $count -le 50 ] || { ret=1; echo "I: count ($count) !<= 50"; } if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` @@ -111,7 +134,7 @@ $DIG $DIGOPTS @10.53.0.3 indirect6.example.org > dig.out.1.test$n || ret=1 grep "status: NOERROR" dig.out.1.test$n > /dev/null || ret=1 $DIG $DIGOPTS +short @10.53.0.2 count txt > dig.out.2.test$n || ret=1 eval count=`cat dig.out.2.test$n` -[ $count -le 50 ] || ret=1 +[ $count -le 50 ] || { ret=1; echo "I: count ($count) !<= 50"; } if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` @@ -127,10 +150,13 @@ echo "10" > ans2/ans.limit $RNDC -c ../common/rndc.conf -s 10.53.0.3 -p 9953 flush 2>&1 | sed 's/^/I:ns1 /' $DIG $DIGOPTS @10.53.0.2 reset > /dev/null || ret=1 $DIG $DIGOPTS @10.53.0.3 indirect7.example.org > dig.out.1.test$n || ret=1 -grep "status: SERVFAIL" dig.out.1.test$n > /dev/null || ret=1 +if $TESTSOCK6 != false +then + grep "status: SERVFAIL" dig.out.1.test$n > /dev/null || ret=1 +fi $DIG $DIGOPTS +short @10.53.0.2 count txt > dig.out.2.test$n || ret=1 eval count=`cat dig.out.2.test$n` -[ $count -le 40 ] || ret=1 +[ $count -le 40 ] || { ret=1; echo "I: count ($count) !<= 40"; } if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` @@ -144,7 +170,7 @@ $DIG $DIGOPTS @10.53.0.3 indirect8.example.org > dig.out.1.test$n || ret=1 grep "status: NOERROR" dig.out.1.test$n > /dev/null || ret=1 $DIG $DIGOPTS +short @10.53.0.2 count txt > dig.out.2.test$n || ret=1 eval count=`cat dig.out.2.test$n` -[ $count -le 40 ] || ret=1 +[ $count -le 40 ] || { ret=1; echo "I: count ($count) !<= 40"; } if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` @@ -159,7 +185,7 @@ eval count=`cat dig.out.2.test$n` [ $count -lt 50 ] || ret=1 $DIG $DIGOPTS +short @10.53.0.7 count txt > dig.out.3.test$n || ret=1 eval count=`cat dig.out.3.test$n` -[ $count -lt 50 ] || ret=1 +[ $count -lt 50 ] || { ret=1; echo "I: count ($count) !<= 50"; } if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` diff --git a/bin/tests/system/staticstub/tests.sh b/bin/tests/system/staticstub/tests.sh index 0abc308d7b..edb2aa5f48 100755 --- a/bin/tests/system/staticstub/tests.sh +++ b/bin/tests/system/staticstub/tests.sh @@ -162,7 +162,7 @@ n=`expr $n + 1` # Note: for a short term workaround we use ::1, assuming it's configured and # usable for our tests. We should eventually use the test ULA and available # checks introduced in change 2916. -if $PERL ../testsock6.pl ::1 2> /dev/null +if $TESTSOCK6 ../testsock6.pl ::1 2> /dev/null then echo "I:checking IPv6 static-stub address ($n)" ret=0 diff --git a/lib/isc/tests/socket_test.c b/lib/isc/tests/socket_test.c index 8e84364732..49453ea7ed 100644 --- a/lib/isc/tests/socket_test.c +++ b/lib/isc/tests/socket_test.c @@ -14,8 +14,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id$ */ - /*! \file */ #include @@ -25,6 +23,7 @@ #include #include +#include #include #include @@ -431,6 +430,7 @@ ATF_TC_HEAD(udp_dscp_v6, tc) { atf_tc_set_md_var(tc, "descr", "udp dscp ipv6"); } ATF_TC_BODY(udp_dscp_v6, tc) { +#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6) isc_result_t result; isc_sockaddr_t addr1, addr2; struct in6_addr in6; @@ -526,6 +526,10 @@ ATF_TC_BODY(udp_dscp_v6, tc) { isc_socket_detach(&s2); isc_test_end(); +#else + UNUSED(tc); + atf_tc_skip("IPv6 not available"); +#endif } /* Test TCP sendto/recv (IPv4) */ @@ -632,6 +636,7 @@ ATF_TC_HEAD(tcp_dscp_v6, tc) { atf_tc_set_md_var(tc, "descr", "tcp dscp ipv6"); } ATF_TC_BODY(tcp_dscp_v6, tc) { +#ifdef ISC_PLATFORM_HAVEIPV6 isc_result_t result; isc_sockaddr_t addr1; struct in6_addr in6; @@ -730,6 +735,10 @@ ATF_TC_BODY(tcp_dscp_v6, tc) { isc_socket_detach(&s3); isc_test_end(); +#else + UNUSED(tc); + atf_tc_skip("IPv6 not available"); +#endif } ATF_TC(net_probedscp); diff --git a/lib/isc/unix/net.c b/lib/isc/unix/net.c index 9bcd189225..4329395f1d 100644 --- a/lib/isc/unix/net.c +++ b/lib/isc/unix/net.c @@ -110,13 +110,21 @@ const struct in6_addr isc_net_in6addrloop = IN6ADDR_LOOPBACK_INIT; # if defined(WANT_IPV6) static isc_once_t once_ipv6only = ISC_ONCE_INIT; -# endif -# if defined(ISC_PLATFORM_HAVEIN6PKTINFO) +# if defined(ISC_PLATFORM_HAVEIN6PKTINFO) static isc_once_t once_ipv6pktinfo = ISC_ONCE_INIT; -# endif +# endif +# endif /* WANT_IPV6 */ #endif /* ISC_PLATFORM_HAVEIPV6 */ +#ifndef ISC_CMSG_IP_TOS +#ifdef __APPLE__ +#define ISC_CMSG_IP_TOS 0 /* As of 10.8.2. */ +#else /* ! __APPLE__ */ +#define ISC_CMSG_IP_TOS 1 +#endif /* ! __APPLE__ */ +#endif /* ! ISC_CMSG_IP_TOS */ + static isc_once_t once = ISC_ONCE_INIT; static isc_once_t once_dscp = ISC_ONCE_INIT; @@ -408,6 +416,9 @@ isc_net_probe_ipv6pktinfo(void) { return (ipv6pktinfo_result); } +#if ISC_CMSG_IP_TOS || \ + defined(ISC_NET_BSD44MSGHDR) && defined(IPV6_TCLASS) && defined(WANT_IPV6) + static inline ISC_SOCKADDR_LEN_T cmsg_len(ISC_SOCKADDR_LEN_T len) { #ifdef CMSG_LEN @@ -613,6 +624,7 @@ cmsgsend(int s, int level, int type, struct addrinfo *res) { return (ISC_TRUE); } #endif +#endif static void try_dscp_v4(void) { @@ -664,14 +676,6 @@ try_dscp_v4(void) { #ifdef ISC_NET_BSD44MSGHDR -#ifndef ISC_CMSG_IP_TOS -#ifdef __APPLE__ -#define ISC_CMSG_IP_TOS 0 /* As of 10.8.2. */ -#else /* ! __APPLE__ */ -#define ISC_CMSG_IP_TOS 1 -#endif /* ! __APPLE__ */ -#endif /* ! ISC_CMSG_IP_TOS */ - #if ISC_CMSG_IP_TOS if (cmsgsend(s, IPPROTO_IP, IP_TOS, res0)) dscp_result |= ISC_NET_DSCPPKTV4;