diff mbox series

[ovs-dev] pinctrl: give a 'no such name' response when no DNS record is available

Message ID tencent_564FAD3350304EF9CDA469286254F6669E06@qq.com
State Changes Requested
Headers show
Series [ovs-dev] pinctrl: give a 'no such name' response when no DNS record is available | expand

Checks

Context Check Description
ovsrobot/apply-robot fail apply and check: fail
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/github-robot-_ovn-kubernetes fail github build: failed

Commit Message

patchwork-bot+netdevbpf--- via dev Feb. 22, 2022, 9:07 a.m. UTC
From: Yuan-96 <294754599@qq.com>

While the CentOS 8 requests an IPv4 DNS record, the response will be slow without a correct IPv6 DNS record on server. It will send a DNS request(type AAAA) message first but ovn controller will not reply. And the DNS request(type A) message will be sent until DNS request(type AAAA) is timeout.
So the DNS client may expect to receive a reponse with RCODE 3(RFC1035. Name Error) instead of nothing when DNS record is not available. And this patch is for that.

Signed-off-by: Yuan-96 <294754599@qq.com>
---
 controller/pinctrl.c | 72 +++++++++++++++++++++++++++-------------------------
 1 file changed, 37 insertions(+), 35 deletions(-)

Comments

0-day Robot Feb. 22, 2022, 1:59 p.m. UTC | #1
From: robot@bytheb.org

Test-Label: github-robot: Build and Test
Test-Status: fail
http://patchwork.ozlabs.org/api/patches/1595962/

_github build: failed_
Build URL: https://github.com/ovsrobot/ovn/actions/runs/1881582768
Build Logs:
-----------------------Summary of failed steps-----------------------
"osx clang --disable-ssl" failed at step build
"linux gcc --disable-ssl" failed at step build
"linux clang --disable-ssl" failed at step build
"linux gcc test" failed at step build
"linux gcc system-test" failed at step build
"linux clang test asan" failed at step build
"linux gcc test -ljemalloc" failed at step build
"linux clang test -ljemalloc" failed at step build
"linux gcc m32 --disable-ssl" failed at step build
----------------------End summary of failed steps--------------------

-------------------------------BEGIN LOGS----------------------------
####################################################################################
#### [Begin job log] "osx clang --disable-ssl" at step build
####################################################################################
#define HAVE_PRAGMA_MESSAGE 1

configure: exit 0

## ---------------------- ##
## Running config.status. ##
## ---------------------- ##

This file was extended by ovn config.status 21.12.90, which was
generated by GNU Autoconf 2.71.  Invocation command line was

  CONFIG_FILES    = 
  CONFIG_HEADERS  = 
  CONFIG_LINKS    = 
  CONFIG_COMMANDS = 
  $ ./config.status Makefile depfiles

on Mac-1645533059795.local

config.status:1309: creating Makefile
config.status:1538: executing depfiles commands
config.status:1640: cd .       && sed -e '/# am--include-marker/d' Makefile         | make -f - am--depfiles
make[1]: Nothing to be done for `am--depfiles'.
config.status:1645: $? = 0
##[error]Process completed with exit code 1.
####################################################################################
#### [End job log] "osx clang --disable-ssl" at step build
####################################################################################




####################################################################################
#### [Begin job log] "linux gcc --disable-ssl" at step build
####################################################################################

## ---------------------- ##
## Running config.status. ##
## ---------------------- ##

This file was extended by ovn config.status 21.12.90, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  CONFIG_FILES    = 
  CONFIG_HEADERS  = 
  CONFIG_LINKS    = 
  CONFIG_COMMANDS = 
  $ ./config.status Makefile depfiles

on fv-az163-348

config.status:1310: creating Makefile
config.status:1539: executing depfiles commands
config.status:1639: cd .       && sed -e '/# am--include-marker/d' Makefile         | make -f - am--depfiles
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/home/runner/work/ovn/ovn'
make[1]: Nothing to be done for 'am--depfiles'.
make[1]: Leaving directory '/home/runner/work/ovn/ovn'
config.status:1644: $? = 0
##[error]Process completed with exit code 1.
####################################################################################
#### [End job log] "linux gcc --disable-ssl" at step build
####################################################################################




####################################################################################
#### [Begin job log] "linux clang --disable-ssl" at step build
####################################################################################

## ---------------------- ##
## Running config.status. ##
## ---------------------- ##

This file was extended by ovn config.status 21.12.90, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  CONFIG_FILES    = 
  CONFIG_HEADERS  = 
  CONFIG_LINKS    = 
  CONFIG_COMMANDS = 
  $ ./config.status Makefile depfiles

on fv-az163-348

config.status:1311: creating Makefile
config.status:1540: executing depfiles commands
config.status:1640: cd .       && sed -e '/# am--include-marker/d' Makefile         | make -f - am--depfiles
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/home/runner/work/ovn/ovn'
make[1]: Nothing to be done for 'am--depfiles'.
make[1]: Leaving directory '/home/runner/work/ovn/ovn'
config.status:1645: $? = 0
##[error]Process completed with exit code 1.
####################################################################################
#### [End job log] "linux clang --disable-ssl" at step build
####################################################################################




####################################################################################
#### [Begin job log] "linux gcc test" at step build
####################################################################################
writing... ovn-sim.1 { } done
build succeeded.

The manual pages are in Documentation/_build/man.
depbase=`echo controller/pinctrl.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
env REAL_CC="gcc" CHECK="sparse -Wsparse-error -I /home/runner/work/ovn/ovn/ovs/include/sparse -m64 -I /usr/local/include -I /usr/include/x86_64-linux-gnu  " cgcc -target=x86_64 -DHAVE_CONFIG_H -I. -I../..   -I ../../include  -I ../../include -I ../../ovn -I ./include -I ../../lib -I ./lib -I /home/runner/work/ovn/ovn/ovs/include -I /home/runner/work/ovn/ovn/ovs/include -I /home/runner/work/ovn/ovn/ovs/lib -I /home/runner/work/ovn/ovn/ovs/lib -I /home/runner/work/ovn/ovn/ovs -I /home/runner/work/ovn/ovn/ovs    -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wswitch-bool -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare -Wshift-negative-value -Wduplicated-cond -Wshadow -Wmultistatement-macros -Wcast-align=strict -Werror -Werror  -g -O2 -MT contro
 ller/pinctrl.o -MD -MP -MF $depbase.Tpo -c -o controller/pinctrl.o ../../controller/pinctrl.c &&\
mv -f $depbase.Tpo $depbase.Po
depbase=`echo controller/patch.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
env REAL_CC="gcc" CHECK="sparse -Wsparse-error -I /home/runner/work/ovn/ovn/ovs/include/sparse -m64 -I /usr/local/include -I /usr/include/x86_64-linux-gnu  " cgcc -target=x86_64 -DHAVE_CONFIG_H -I. -I../..   -I ../../include  -I ../../include -I ../../ovn -I ./include -I ../../lib -I ./lib -I /home/runner/work/ovn/ovn/ovs/include -I /home/runner/work/ovn/ovn/ovs/include -I /home/runner/work/ovn/ovn/ovs/lib -I /home/runner/work/ovn/ovn/ovs/lib -I /home/runner/work/ovn/ovn/ovs -I /home/runner/work/ovn/ovn/ovs    -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wswitch-bool -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare -Wshift-negative-value -Wduplicated-cond -Wshadow -Wmultistatement-macros -Wcast-align=strict -Werror -Werror  -g -O2 -MT contro
 ller/patch.o -MD -MP -MF $depbase.Tpo -c -o controller/patch.o ../../controller/patch.c &&\
mv -f $depbase.Tpo $depbase.Po
../../controller/pinctrl.c:2992:54: error: undefined identifier 'dns_answer'
../../controller/pinctrl.c:3020:9: error: undefined identifier 'ancount'
../../controller/pinctrl.c:3027:37: error: undefined identifier 'ancount'
../../controller/pinctrl.c:3033:9: error: undefined identifier 'dns_answer'
../../controller/pinctrl.c:3035:33: error: undefined identifier 'dns_answer'
../../controller/pinctrl.c:3037:20: error: undefined identifier 'dns_answer'
make[2]: *** [Makefile:2304: controller/pinctrl.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/home/runner/work/ovn/ovn/ovn-21.12.90/_build/sub'
make[1]: *** [Makefile:1520: all] Error 2
make[1]: Leaving directory '/home/runner/work/ovn/ovn/ovn-21.12.90/_build/sub'
make: *** [Makefile:2794: distcheck] Error 1
+ cat '*/_build/sub/tests/testsuite.log'
cat: '*/_build/sub/tests/testsuite.log': No such file or directory
##[error]Process completed with exit code 1.
####################################################################################
#### [End job log] "linux gcc test" at step build
####################################################################################




####################################################################################
#### [Begin job log] "linux gcc system-test" at step build
####################################################################################

## ---------------------- ##
## Running config.status. ##
## ---------------------- ##

This file was extended by ovn config.status 21.12.90, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  CONFIG_FILES    = 
  CONFIG_HEADERS  = 
  CONFIG_LINKS    = 
  CONFIG_COMMANDS = 
  $ ./config.status Makefile depfiles

on fv-az90-479

config.status:1312: creating Makefile
config.status:1541: executing depfiles commands
config.status:1641: cd .       && sed -e '/# am--include-marker/d' Makefile         | make -f - am--depfiles
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/home/runner/work/ovn/ovn'
make[1]: Nothing to be done for 'am--depfiles'.
make[1]: Leaving directory '/home/runner/work/ovn/ovn'
config.status:1646: $? = 0
##[error]Process completed with exit code 1.
####################################################################################
#### [End job log] "linux gcc system-test" at step build
####################################################################################




####################################################################################
#### [Begin job log] "linux clang test asan" at step build
####################################################################################
../../controller/pinctrl.c:3027:37: error: use of undeclared identifier 'ancount'
    out_dns_header->ancount = htons(ancount);
                                    ^
../../controller/pinctrl.c:3033:9: error: use of undeclared identifier 'dns_answer'
    if (dns_answer.size > 0) {
        ^
../../controller/pinctrl.c:3035:33: error: use of undeclared identifier 'dns_answer'
        dp_packet_put(&pkt_out, dns_answer.data, dns_answer.size);
                                ^
../../controller/pinctrl.c:3035:50: error: use of undeclared identifier 'dns_answer'
        dp_packet_put(&pkt_out, dns_answer.data, dns_answer.size);
                                                 ^
../../controller/pinctrl.c:3037:20: error: use of undeclared identifier 'dns_answer'
    ofpbuf_uninit(&dns_answer);
                   ^
7 errors generated.
make[2]: *** [Makefile:2304: controller/pinctrl.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/home/runner/work/ovn/ovn/ovn-21.12.90/_build/sub'
make[1]: *** [Makefile:1520: all] Error 2
make: *** [Makefile:2794: distcheck] Error 1
make[1]: Leaving directory '/home/runner/work/ovn/ovn/ovn-21.12.90/_build/sub'
+ cat '*/_build/sub/tests/testsuite.log'
cat: '*/_build/sub/tests/testsuite.log': No such file or directory
##[error]Process completed with exit code 1.
####################################################################################
#### [End job log] "linux clang test asan" at step build
####################################################################################




####################################################################################
#### [Begin job log] "linux gcc test -ljemalloc" at step build
####################################################################################
mv -f $depbase.Tpo $depbase.Po
depbase=`echo controller/ofctrl-seqno.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
env REAL_CC="gcc" CHECK="sparse -Wsparse-error -I /home/runner/work/ovn/ovn/ovs/include/sparse -m64 -I /usr/local/include -I /usr/include/x86_64-linux-gnu  " cgcc -target=x86_64 -DHAVE_CONFIG_H -I. -I../..   -I ../../include  -I ../../include -I ../../ovn -I ./include -I ../../lib -I ./lib -I /home/runner/work/ovn/ovn/ovs/include -I /home/runner/work/ovn/ovn/ovs/include -I /home/runner/work/ovn/ovn/ovs/lib -I /home/runner/work/ovn/ovn/ovs/lib -I /home/runner/work/ovn/ovn/ovs -I /home/runner/work/ovn/ovn/ovs    -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wswitch-bool -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare -Wshift-negative-value -Wduplicated-cond -Wshadow -Wmultistatement-macros -Wcast-align=strict -Werror -Werror  -g -O2 -MT contro
 ller/ofctrl-seqno.o -MD -MP -MF $depbase.Tpo -c -o controller/ofctrl-seqno.o ../../controller/ofctrl-seqno.c &&\
mv -f $depbase.Tpo $depbase.Po
depbase=`echo controller/pinctrl.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
env REAL_CC="gcc" CHECK="sparse -Wsparse-error -I /home/runner/work/ovn/ovn/ovs/include/sparse -m64 -I /usr/local/include -I /usr/include/x86_64-linux-gnu  " cgcc -target=x86_64 -DHAVE_CONFIG_H -I. -I../..   -I ../../include  -I ../../include -I ../../ovn -I ./include -I ../../lib -I ./lib -I /home/runner/work/ovn/ovn/ovs/include -I /home/runner/work/ovn/ovn/ovs/include -I /home/runner/work/ovn/ovn/ovs/lib -I /home/runner/work/ovn/ovn/ovs/lib -I /home/runner/work/ovn/ovn/ovs -I /home/runner/work/ovn/ovn/ovs    -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wswitch-bool -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare -Wshift-negative-value -Wduplicated-cond -Wshadow -Wmultistatement-macros -Wcast-align=strict -Werror -Werror  -g -O2 -MT contro
 ller/pinctrl.o -MD -MP -MF $depbase.Tpo -c -o controller/pinctrl.o ../../controller/pinctrl.c &&\
mv -f $depbase.Tpo $depbase.Po
depbase=`echo controller/patch.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
env REAL_CC="gcc" CHECK="sparse -Wsparse-error -I /home/runner/work/ovn/ovn/ovs/include/sparse -m64 -I /usr/local/include -I /usr/include/x86_64-linux-gnu  " cgcc -target=x86_64 -DHAVE_CONFIG_H -I. -I../..   -I ../../include  -I ../../include -I ../../ovn -I ./include -I ../../lib -I ./lib -I /home/runner/work/ovn/ovn/ovs/include -I /home/runner/work/ovn/ovn/ovs/include -I /home/runner/work/ovn/ovn/ovs/lib -I /home/runner/work/ovn/ovn/ovs/lib -I /home/runner/work/ovn/ovn/ovs -I /home/runner/work/ovn/ovn/ovs    -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wswitch-bool -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare -Wshift-negative-value -Wduplicated-cond -Wshadow -Wmultistatement-macros -Wcast-align=strict -Werror -Werror  -g -O2 -MT contro
 ller/patch.o -MD -MP -MF $depbase.Tpo -c -o controller/patch.o ../../controller/patch.c &&\
mv -f $depbase.Tpo $depbase.Po
../../controller/pinctrl.c:2992:54: error: undefined identifier 'dns_answer'
../../controller/pinctrl.c:3020:9: error: undefined identifier 'ancount'
../../controller/pinctrl.c:3027:37: error: undefined identifier 'ancount'
../../controller/pinctrl.c:3033:9: error: undefined identifier 'dns_answer'
../../controller/pinctrl.c:3035:33: error: undefined identifier 'dns_answer'
../../controller/pinctrl.c:3037:20: error: undefined identifier 'dns_answer'
make[2]: *** [Makefile:2304: controller/pinctrl.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/home/runner/work/ovn/ovn/ovn-21.12.90/_build/sub'
make[1]: *** [Makefile:1520: all] Error 2
make[1]: Leaving directory '/home/runner/work/ovn/ovn/ovn-21.12.90/_build/sub'
make: *** [Makefile:2794: distcheck] Error 1
+ cat '*/_build/sub/tests/testsuite.log'
cat: '*/_build/sub/tests/testsuite.log': No such file or directory
##[error]Process completed with exit code 1.
####################################################################################
#### [End job log] "linux gcc test -ljemalloc" at step build
####################################################################################




####################################################################################
#### [Begin job log] "linux clang test -ljemalloc" at step build
####################################################################################
                                                 ^
../../controller/pinctrl.c:3037:20: error: use of undeclared identifier 'dns_answer'
    ofpbuf_uninit(&dns_answer);
                   ^
7 errors generated.
make[2]: *** [Makefile:2304: controller/pinctrl.o] Error 1
make[2]: *** Waiting for unfinished jobs....
Cannot find 'ovs-sphinx-theme' package. Falling back to default theme.
making output directory... done
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [man]: all manpages
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
writing... ovn-sim.1 { } done
build succeeded.

The manual pages are in Documentation/_build/man.
make[2]: Leaving directory '/home/runner/work/ovn/ovn/ovn-21.12.90/_build/sub'
make[1]: *** [Makefile:1520: all] Error 2
make[1]: Leaving directory '/home/runner/work/ovn/ovn/ovn-21.12.90/_build/sub'
make: *** [Makefile:2794: distcheck] Error 1
+ cat '*/_build/sub/tests/testsuite.log'
cat: '*/_build/sub/tests/testsuite.log': No such file or directory
##[error]Process completed with exit code 1.
####################################################################################
#### [End job log] "linux clang test -ljemalloc" at step build
####################################################################################




####################################################################################
#### [Begin job log] "linux gcc m32 --disable-ssl" at step build
####################################################################################

## ---------------------- ##
## Running config.status. ##
## ---------------------- ##

This file was extended by ovn config.status 21.12.90, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  CONFIG_FILES    = 
  CONFIG_HEADERS  = 
  CONFIG_LINKS    = 
  CONFIG_COMMANDS = 
  $ ./config.status Makefile depfiles

on fv-az90-479

config.status:1310: creating Makefile
config.status:1539: executing depfiles commands
config.status:1639: cd .       && sed -e '/# am--include-marker/d' Makefile         | make -f - am--depfiles
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/home/runner/work/ovn/ovn'
make[1]: Nothing to be done for 'am--depfiles'.
make[1]: Leaving directory '/home/runner/work/ovn/ovn'
config.status:1644: $? = 0
##[error]Process completed with exit code 1.
####################################################################################
#### [End job log] "linux gcc m32 --disable-ssl" at step build
####################################################################################
--------------------------------END LOGS-----------------------------
0-day Robot Feb. 22, 2022, 1:59 p.m. UTC | #2
From: robot@bytheb.org

Test-Label: github-robot: ovn-kubernetes
Test-Status: fail
http://patchwork.ozlabs.org/api/patches/1595962/

_github build: failed_
Build URL: https://github.com/ovsrobot/ovn/actions/runs/1881582770
Build Logs:
-----------------------Summary of failed steps-----------------------
"Build" failed at step Build ovn-kubernetes container
----------------------End summary of failed steps--------------------

-------------------------------BEGIN LOGS----------------------------
####################################################################################
#### [Begin job log] "Build" at step Build ovn-kubernetes container
####################################################################################
      |                                                      ^~~~~~~~~~
controller/pinctrl.c:2992:54: note: each undeclared identifier is reported only once for each function it appears in
controller/pinctrl.c:3020:9: error: 'ancount' undeclared (first use in this function)
 3020 |     if (ancount == 0) {
      |         ^~~~~~~
make[2]: *** [Makefile:2308: controller/pinctrl.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/tmp/ovn/rpm/rpmbuild/BUILD/ovn-21.12.90'
make[1]: Leaving directory '/tmp/ovn/rpm/rpmbuild/BUILD/ovn-21.12.90'
make[1]: *** [Makefile:1519: all] Error 2


RPM build errors:
error: Bad exit status from /var/tmp/rpm-tmp.BisZ44 (%build)
    line 33: Possible unexpanded macro in: Obsoletes: openvswitch-ovn-common < 21.12.90-%{release}
    line 34: Possible unexpanded macro in: Provides: openvswitch-ovn-common = 21.12.90-%{release}
    line 84: It's not recommended to have unversioned Obsoletes: Obsoletes: openvswitch-ovn-central
    line 95: It's not recommended to have unversioned Obsoletes: Obsoletes: openvswitch-ovn-host
    line 105: It's not recommended to have unversioned Obsoletes: Obsoletes: openvswitch-ovn-vtep
    line 115: It's not recommended to have unversioned Obsoletes: Obsoletes: openvswitch-ovn-docker
    Bad exit status from /var/tmp/rpm-tmp.BisZ44 (%build)
make: *** [Makefile:3767: rpm-fedora] Error 1
The command '/bin/sh -c make rpm-fedora' returned a non-zero code: 2

##[error]Process completed with exit code 2.
####################################################################################
#### [End job log] "Build" at step Build ovn-kubernetes container
####################################################################################
--------------------------------END LOGS-----------------------------
diff mbox series

Patch

diff --git a/controller/pinctrl.c b/controller/pinctrl.c
index 1b8b475..a2fc1a2 100644
--- a/controller/pinctrl.c
+++ b/controller/pinctrl.c
@@ -2952,47 +2952,41 @@  pinctrl_handle_dns_lookup(
     }
 
     ds_destroy(&query_name);
-    if (!answer_data) {
-        goto exit;
-    }
 
 
-    uint16_t ancount = 0;
-    uint64_t dns_ans_stub[128 / 8];
-    struct ofpbuf dns_answer = OFPBUF_STUB_INITIALIZER(dns_ans_stub);
+    if (answer_data) {
+        uint16_t ancount = 0;
+        uint64_t dns_ans_stub[128 / 8];
+        struct ofpbuf dns_answer = OFPBUF_STUB_INITIALIZER(dns_ans_stub);
 
-    if (query_type == DNS_QUERY_TYPE_PTR) {
-        dns_build_ptr_answer(&dns_answer, in_queryname, idx, answer_data);
-        ancount++;
-    } else {
-        struct lport_addresses ip_addrs;
-        if (!extract_ip_addresses(answer_data, &ip_addrs)) {
-            goto exit;
-        }
+        if (query_type == DNS_QUERY_TYPE_PTR) {
+            dns_build_ptr_answer(&dns_answer, in_queryname, idx, answer_data);
+            ancount++;
+        } else {
+            struct lport_addresses ip_addrs;
+            if (!extract_ip_addresses(answer_data, &ip_addrs)) {
+                goto exit;
+            }
 
-        if (query_type == DNS_QUERY_TYPE_A ||
-            query_type == DNS_QUERY_TYPE_ANY) {
-            for (size_t i = 0; i < ip_addrs.n_ipv4_addrs; i++) {
-                dns_build_a_answer(&dns_answer, in_queryname, idx,
-                                   ip_addrs.ipv4_addrs[i].addr);
-                ancount++;
+            if (query_type == DNS_QUERY_TYPE_A ||
+                query_type == DNS_QUERY_TYPE_ANY) {
+                for (size_t i = 0; i < ip_addrs.n_ipv4_addrs; i++) {
+                    dns_build_a_answer(&dns_answer, in_queryname, idx,
+                                       ip_addrs.ipv4_addrs[i].addr);
+                    ancount++;
+                }
             }
-        }
 
-        if (query_type == DNS_QUERY_TYPE_AAAA ||
-            query_type == DNS_QUERY_TYPE_ANY) {
-            for (size_t i = 0; i < ip_addrs.n_ipv6_addrs; i++) {
-                dns_build_aaaa_answer(&dns_answer, in_queryname, idx,
-                                      &ip_addrs.ipv6_addrs[i].addr);
-                ancount++;
+            if (query_type == DNS_QUERY_TYPE_AAAA ||
+                query_type == DNS_QUERY_TYPE_ANY) {
+                for (size_t i = 0; i < ip_addrs.n_ipv6_addrs; i++) {
+                    dns_build_aaaa_answer(&dns_answer, in_queryname, idx,
+                                          &ip_addrs.ipv6_addrs[i].addr);
+                    ancount++;
+                }
             }
+            destroy_lport_addresses(&ip_addrs);
         }
-        destroy_lport_addresses(&ip_addrs);
-    }
-
-    if (!ancount) {
-        ofpbuf_uninit(&dns_answer);
-        goto exit;
     }
 
     uint16_t new_l4_size = ntohs(in_udp->udp_len) +  dns_answer.size;
@@ -3023,6 +3017,12 @@  pinctrl_handle_dns_lookup(
     /* Set the response bit to 1 in the flags. */
     out_dns_header->lo_flag |= 0x80;
 
+    if (ancount == 0) {
+        /*Set the reply code bits to 0011 in the flags
+         *when here is no dns record. */
+        out_dns_header->hi_flag |= 0x03;
+    }
+
     /* Set the answer RRs. */
     out_dns_header->ancount = htons(ancount);
     out_dns_header->arcount = 0;
@@ -3030,8 +3030,10 @@  pinctrl_handle_dns_lookup(
     /* Copy the Query section. */
     dp_packet_put(&pkt_out, dp_packet_data(pkt_in), dp_packet_size(pkt_in));
 
-    /* Copy the answer sections. */
-    dp_packet_put(&pkt_out, dns_answer.data, dns_answer.size);
+    if (dns_answer.size > 0) {
+        /* Copy the answer sections. */
+        dp_packet_put(&pkt_out, dns_answer.data, dns_answer.size);
+    }
     ofpbuf_uninit(&dns_answer);
 
     out_udp->udp_len = htons(new_l4_size);