1#!/bin/sh 2# 3# Copyright (C) Internet Systems Consortium, Inc. ("ISC") 4# 5# This Source Code Form is subject to the terms of the Mozilla Public 6# License, v. 2.0. If a copy of the MPL was not distributed with this 7# file, You can obtain one at http://mozilla.org/MPL/2.0/. 8# 9# See the COPYRIGHT file distributed with this work for additional 10# information regarding copyright ownership. 11 12SYSTEMTESTTOP=.. 13. $SYSTEMTESTTOP/conf.sh 14 15DIGOPTS="+norec -p ${PORT}" 16 17status=0 18n=0 19zone=. 20 21n=`expr $n + 1` 22echo_i "check +edns=100 sets version 100 ($n)" 23ret=0 reason= 24$DIG $DIGOPTS @10.53.0.1 +qr +edns=100 soa $zone > dig.out$n 25grep "EDNS: version: 100," dig.out$n > /dev/null || { ret=1; reason="version"; } 26if [ $ret != 0 ]; then echo_i "failed $reason"; fi 27status=`expr $status + $ret` 28 29n=`expr $n + 1` 30ret=0 reason= 31echo_i "check +ednsopt=100 adds option 100 ($n)" 32$DIG $DIGOPTS @10.53.0.1 +qr +ednsopt=100 soa $zone > dig.out$n 33grep "; OPT=100" dig.out$n > /dev/null || { ret=1; reason="option"; } 34if [ $ret != 0 ]; then echo_i "failed $reason"; fi 35status=`expr $status + $ret` 36 37n=`expr $n + 1` 38echo_i "check +ednsflags=0x80 sets flags to 0x0080 ($n)" 39ret=0 reason= 40$DIG $DIGOPTS @10.53.0.1 +qr +ednsflags=0x80 soa $zone > dig.out$n 41grep "MBZ: 0x0080," dig.out$n > /dev/null || { ret=1; reason="flags"; } 42if [ $ret != 0 ]; then echo_i "failed $reason"; fi 43status=`expr $status + $ret` 44 45n=`expr $n + 1` 46echo_i "Unknown EDNS version ($n)" 47ret=0 reason= 48$DIG $DIGOPTS @10.53.0.1 +edns=100 +noednsnegotiation soa $zone > dig.out$n 49grep "status: BADVERS," dig.out$n > /dev/null || { ret=1; reason="status"; } 50grep "EDNS: version: 0," dig.out$n > /dev/null || { ret=1; reason="version"; } 51grep "IN.SOA." dig.out$n > /dev/null && { ret=1; reasons="soa"; } 52if [ $ret != 0 ]; then echo_i "failed $reason"; fi 53status=`expr $status + $ret` 54 55n=`expr $n + 1` 56echo_i "Unknown EDNS option ($n)" 57ret=0 reason= 58$DIG $DIGOPTS @10.53.0.1 +ednsopt=100 soa $zone > dig.out$n 59grep "status: NOERROR," dig.out$n > /dev/null || { ret=1; reason="status"; } 60grep "EDNS: version: 0," dig.out$n > /dev/null || { ret=1; reason="version"; } 61grep "; OPT=100" dig.out$n > /dev/null && { ret=1; reason="option"; } 62grep "IN.SOA." dig.out$n > /dev/null || { ret=1; reason="nosoa"; } 63if [ $ret != 0 ]; then echo_i "failed $reason"; fi 64status=`expr $status + $ret` 65 66n=`expr $n + 1` 67echo_i "Unknown EDNS version + option ($n)" 68ret=0 reason= 69$DIG $DIGOPTS @10.53.0.1 +edns=100 +noednsneg +ednsopt=100 soa $zone > dig.out$n 70grep "status: BADVERS," dig.out$n > /dev/null || { ret=1; reason="status"; } 71grep "EDNS: version: 0," dig.out$n > /dev/null || { ret=1; reason="version"; } 72grep "; OPT=100" dig.out$n > /dev/null && { ret=1; reason="option"; } 73grep "IN.SOA." dig.out$n > /dev/null && { ret=1; reason="soa"; } 74if [ $ret != 0 ]; then echo_i "failed: $reason"; fi 75status=`expr $status + $ret` 76n=`expr $n + 1` 77 78echo_i "Unknown EDNS flag ($n)" 79ret=0 reason= 80$DIG $DIGOPTS @10.53.0.1 +ednsflags=0x80 soa $zone > dig.out$n 81grep "status: NOERROR," dig.out$n > /dev/null || { ret=1; reason="status"; } 82grep "EDNS: version: 0," dig.out$n > /dev/null || { ret=1; reason="version"; } 83grep "EDNS:.*MBZ" dig.out$n > /dev/null > /dev/null && { ret=1; reason="mbz"; } 84grep ".IN.SOA." dig.out$n > /dev/null || { ret=1; reason="nosoa"; } 85if [ $ret != 0 ]; then echo_i "failed $reason"; fi 86status=`expr $status + $ret` 87 88n=`expr $n + 1` 89echo_i "Unknown EDNS version + flag ($n)" 90ret=0 reason= 91$DIG $DIGOPTS @10.53.0.1 +edns=100 +noednsneg +ednsflags=0x80 soa $zone > dig.out$n 92grep "status: BADVERS," dig.out$n > /dev/null || { ret=1; reason="status"; } 93grep "EDNS: version: 0," dig.out$n > /dev/null || { ret=1; reason="version"; } 94grep "EDNS:.*MBZ" dig.out$n > /dev/null > /dev/null && { ret=1; reason="mbz"; } 95grep "IN.SOA." dig.out$n > /dev/null && { ret=1; reason="soa"; } 96if [ $ret != 0 ]; then echo_i "failed $reason"; fi 97status=`expr $status + $ret` 98n=`expr $n + 1` 99 100echo_i "DiG's EDNS negotiation ($n)" 101ret=0 reason= 102$DIG $DIGOPTS @10.53.0.1 +edns=100 soa $zone > dig.out$n 103grep "status: NOERROR," dig.out$n > /dev/null || { ret=1; reason="status"; } 104grep "EDNS: version: 0," dig.out$n > /dev/null || { ret=1; reason="version"; } 105grep "IN.SOA." dig.out$n > /dev/null || { ret=1; reason="soa"; } 106if [ $ret != 0 ]; then echo_i "failed $reason"; fi 107status=`expr $status + $ret` 108n=`expr $n + 1` 109 110echo_i "exit status: $status" 111[ $status -eq 0 ] || exit 1 112