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