Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: can not unmarshal DNS over UDP message which is more than 512 octets long and indicates TC=0 #13696

Closed
netroby opened this issue Dec 21, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@netroby
Copy link

commented Dec 21, 2015

cannot unmarshal DNS message
dial tcp: lookup g-ec4.images-amazon.com on 127.0.0.1:53: cannot unmarshal DNS message

$drill g-ec4.images-amazon.com     
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 4883
;; flags: qr rd ra ; QUERY: 1, ANSWER: 12, AUTHORITY: 0, ADDITIONAL: 0 
;; QUESTION SECTION:
;; g-ec4.images-amazon.com. IN  A

;; ANSWER SECTION:
g-ec4.images-amazon.com.    399 IN  CNAME   ec4.images-amazon.chinacache.net.
ec4.images-amazon.chinacache.net.   126 IN  CNAME   joyo-amazon.cncssr.chinacache.net.
joyo-amazon.cncssr.chinacache.net.  1627    IN  CNAME   hpcc-page.cncssr.chinacache.net.
hpcc-page.cncssr.chinacache.net.    60  IN  A   119.188.138.29
hpcc-page.cncssr.chinacache.net.    60  IN  A   119.188.138.24
hpcc-page.cncssr.chinacache.net.    60  IN  A   123.130.123.6
hpcc-page.cncssr.chinacache.net.    60  IN  A   218.58.209.106
hpcc-page.cncssr.chinacache.net.    60  IN  A   218.60.108.135
hpcc-page.cncssr.chinacache.net.    60  IN  A   218.24.17.40
hpcc-page.cncssr.chinacache.net.    60  IN  A   222.163.198.56
hpcc-page.cncssr.chinacache.net.    60  IN  A   221.204.171.42
hpcc-page.cncssr.chinacache.net.    60  IN  A   221.204.23.16

;; AUTHORITY SECTION:

;; ADDITIONAL SECTION:

;; Query time: 0 msec
;; SERVER: 127.0.0.1
;; WHEN: Mon Dec 21 08:59:15 2015
;; MSG SIZE  rcvd: 690

@netroby

This comment has been minimized.

Copy link
Author

commented Dec 21, 2015

the source code to dial a tcp connection

c, err = net.Dial(network, addr)

@mikioh mikioh changed the title Golang 1.5.2 can not unmarshal dns message net: can not unmarshal DNS over UDP message which is more than 512 octets long and indicates TC=0 Dec 21, 2015

@mikioh

This comment has been minimized.

Copy link
Contributor

commented Dec 21, 2015

I think you already have the answer. Please take a look at the output of drill.

;; SERVER: 127.0.0.1
;; WHEN: Mon Dec 21 08:59:15 2015
;; MSG SIZE rcvd: 690

I suppose that the DNS server your are running should behave like the following:

WHILE
        READ QueryMessage from UDP endpoint
        IF QueryMessage exists THEN
                PARSE QueryMessage to extract Header, Questions, OptRR
                IF Header and Questions look fine THEN
                        COMPOSE ResponseMessage with Answers
                        IF ResponseMessageLength <= 512 THEN
                                WRITE ResponseMessage to UDP endpoint
                        ELSE
                                IF OptRR exists THEN
                                        RECOMPOSE ResponseMessage using OptRR
                                        WRITE ResponseMessage to UDP endpoint
                                ELSE
                                        RECOMPOSE ResponseMessage to be <= 512
                                        SET TC in ResponseMessage to 1
                                        WRITE ResponseMessage to UDP endpoint
                                ENDIF
                        ENDIF
                ELSE
                        COMPOSE ResponseMessage with ErrorCode
                        WRITE ResponseMessage to UDP endpoint
                ENDIF
        ENDIF
        READ QueryMessage from TCP endpoint
        IF QueryMessage exists THEN
                PARSE QueryMessage to extract Header, Questions, OptRR
                IF Header and Questions look fine THEN
                        COMPOSE ResponseMessage with Answers
                        WRITE ResponseMessage to TCP endpoint
                ELSE
                        COMPOSE ResponseMessage with ErrorCode
                        WRITE ResponseMessage to TCP endpoint
                ENDIF
        ENDIF
ENDWHILE

Closing as "working as intended." FWIW, we already have #13356.

@mikioh mikioh closed this Dec 21, 2015

@mikioh

This comment has been minimized.

Copy link
Contributor

commented Dec 21, 2015

@netroby,

I think you may follow https://golang.org/wiki/Questions.

@golang golang locked and limited conversation to collaborators Dec 29, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.