designate-mdns throws errors when listening on IPv6/dual-stack

Bug #1734101 reported by Simon Leinen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Designate
Fix Released
High
Dr. Jens Harbott

Bug Description

We set up designate-mdns so that it listens on an IPv6 socket, by setting "listen = [::]:5354" in the [service:mdns] section of designate.conf. (The background is that we have IPv6, but no IPv4 connectivity between regions, and we want to set up public-facing nameservers that can get zone data from designate in another region.) BIND 9 is used as the public-facing nameserver.

When a zone is created, it is added to designate-mdns, and then BIND 9 is told to create the zone as a slave and retrieve its contents from designate-mdns via zone transfer from port 5354. This happens even when BIND 9 connects over IPv4 to 127.0.0.1. Here is an extract of syslog on our designate server that shows the problem:

Nov 23 06:55:36 designate-0 named[11565]: received control channel command 'addzone designate-test2.simon.leinen.ch { type slave; masters { 127.0.0.1 port 5354;}; file "slave.designate-test2.simon.leinen.ch.49b88ec2-03ab-4a4f-83c9-ef2136ec16e6"; };'
Nov 23 06:55:36 designate-0 named[11565]: client 127.0.0.1#52994: received notify for zone 'designate-test2.simon.leinen.ch'
Nov 23 06:55:36 designate-0 named[11565]: zone designate-test2.simon.leinen.ch/IN: notify from 127.0.0.1#52994: no serial
Nov 23 06:55:36 designate-0 named[11565]: zone designate-test2.simon.leinen.ch/IN: Transfer started.
Nov 23 06:55:36 designate-0 named[11565]: transfer of 'designate-test2.simon.leinen.ch/IN' from 127.0.0.1#5354: connected using 127.0.0.1#37097
Nov 23 06:55:36 designate-0 designate-mdns[12125]: Traceback (most recent call last):
Nov 23 06:55:36 designate-0 designate-mdns[12125]: File "/usr/lib/python2.7/dist-packages/eventlet/hubs/hub.py", line 457, in fire_timers
Nov 23 06:55:36 designate-0 designate-mdns[12125]: timer()
Nov 23 06:55:36 designate-0 designate-mdns[12125]: File "/usr/lib/python2.7/dist-packages/eventlet/hubs/timer.py", line 58, in __call__
Nov 23 06:55:36 designate-0 designate-mdns[12125]: cb(*args, **kw)
Nov 23 06:55:36 designate-0 designate-mdns[12125]: File "/usr/lib/python2.7/dist-packages/eventlet/greenthread.py", line 214, in main
Nov 23 06:55:36 designate-0 designate-mdns[12125]: result = function(*args, **kwargs)
Nov 23 06:55:36 designate-0 designate-mdns[12125]: File "/usr/lib/python2.7/dist-packages/designate/service.py", line 365, in _dns_handle_tcp_conn
Nov 23 06:55:36 designate-0 designate-mdns[12125]: host, port = addr
Nov 23 06:55:36 designate-0 designate-mdns[12125]: ValueError: too many values to unpack

When we change the listen option to 0.0.0.0:5354, the problem goes away.

[EDITED TO ADD:] We use Ubuntu Cloud Archive packages under Ubuntu 16.04 LTS. For Designate, we use the "pike" version of UCA. The rest of our OpenStack installation still runs Newton.

description: updated
Revision history for this message
Simon Leinen (simon-leinen) wrote :

The line

  host, port = addr

assumes that "addr" (which is returned from socket.accept()) is a pair (2-tuple). But according to https://docs.python.org/2/library/socket.html, an IPv6 address will be represented as a four-tuple (host, port, flowspec, scope). In this case we can safely ignore flowspec and scope, but we must be able to parse this four-tuple variant of addr.

Revision history for this message
Simon Leinen (simon-leinen) wrote :

A quick fix would be to change

  host, port = addr

to

  host, port = addr[0], addr[1]

(I didn't find a more "pythonic" way to ignore extra elements of addr, but then I'm a Python n00b.)

Changed in designate:
assignee: nobody → Dr. Jens Harbott (j-harbott)
status: New → Confirmed
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to designate (master)

Fix proposed to branch: master
Review: https://review.openstack.org/522617

Changed in designate:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to designate (master)

Reviewed: https://review.openstack.org/522617
Committed: https://git.openstack.org/cgit/openstack/designate/commit/?id=5e45b15419e80539e35d08380351445553bf92b0
Submitter: Zuul
Branch: master

commit 5e45b15419e80539e35d08380351445553bf92b0
Author: Jens Harbott <email address hidden>
Date: Thu Nov 23 16:44:02 2017 +0000

    Fix servicing IPv6 based TCP connections

    When a connection is received via IPv6, the address is a 4-tuple
    instead of a 2-tuple for IPv4, so handle this accordingly.

    Also handle the end of the TCP connection gracefully instead of
    emitting an "Invalid packet" warning every time.

    [1] https://docs.python.org/2/library/socket.html

    Change-Id: I935bbea1d58af8a5b41b5d29f12de4dcb7cf6301
    Closes-Bug: 1734101

Changed in designate:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/designate 6.0.0.0b3

This issue was fixed in the openstack/designate 6.0.0.0b3 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to designate (stable/pike)

Fix proposed to branch: stable/pike
Review: https://review.openstack.org/620583

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to designate (stable/pike)

Reviewed: https://review.openstack.org/620583
Committed: https://git.openstack.org/cgit/openstack/designate/commit/?id=16297a3014266f1da2c0a87a19027c7eeec577ea
Submitter: Zuul
Branch: stable/pike

commit 16297a3014266f1da2c0a87a19027c7eeec577ea
Author: Jens Harbott <email address hidden>
Date: Thu Nov 23 16:44:02 2017 +0000

    Fix servicing IPv6 based TCP connections

    When a connection is received via IPv6, the address is a 4-tuple
    instead of a 2-tuple for IPv4, so handle this accordingly.

    Also handle the end of the TCP connection gracefully instead of
    emitting an "Invalid packet" warning every time.

    [1] https://docs.python.org/2/library/socket.html

    Change-Id: I935bbea1d58af8a5b41b5d29f12de4dcb7cf6301
    Closes-Bug: 1734101
    (cherry picked from commit 5e45b15419e80539e35d08380351445553bf92b0)

tags: added: in-stable-pike
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.