Bug 1033739 - Dnsmasq need prefix in dhcp-range for dhcpv6
Summary: Dnsmasq need prefix in dhcp-range for dhcpv6
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-22 18:25 UTC by Bertrand Belguise
Modified: 2016-06-03 21:38 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-04-21 19:20:14 UTC
Embargoed:


Attachments (Terms of Use)

Description Bertrand Belguise 2013-11-22 18:25:06 UTC
Description of problem:


Version-Release number of selected component (if applicable):
libvirt 1.1.4

How reproducible:
always


Steps to Reproduce:
1. configue ipv6 network with
<ip family='ipv6' address='2a00:c70:1:xxxx:xxxx:xxx:8xxx:ffff' prefix='97'>
  <dhcp>
    <range start='2a00:c70:1:xxx:xxxx:xxxx:8xxx:901' end='2a00:c70:1:xxxx:xxxx:xxx:8xxx:f01' />
2.
 start the network
3.
 got in /var/lib/libvirt/dnsmasq.conf file
dhcp-range=2a00:c70:1:xxxx:xxxx:xxxx:8xxx:901,2a00:c70:1:xxxx:xxxx:xxxx:8xxx:f01

Actual results:
in log dnsmasq-dhcp[2380]: no address range available for DHCPv6 request via virbr0
and dhclient can't get ipv6 address


Expected results:
in /var/lib/libvirt/dnsmasq.conf file
dhcp-range=2a00:c70:1:xxxx:xxxx:xxxx:8xxx:901,2a00:c70:1:xxxx:xxxx:xxxx:8xxx:f01,97
in log
Nov 22 18:53:22 root dnsmasq-dhcp[3102]: DHCPREPLY(virbr0) 2a00:c70:1:xxxx:xxxx:xxx etc

Nov 22 18:53:27 root dnsmasq-dhcp[3102]: RTR-ADVERT(virbr0) 2a00:c70:1:xxxx:xxxx:xxxx:8000:0


Additional info:
dnsmasq look if a dhcp-range with same network tahn interface exist, if dhcp-range as no prefix then default to /64 and can only match with a /64 interface address

Comment 1 Cole Robinson 2016-04-19 20:12:56 UTC
Laine, this looks like a fairly simple simple patch to wire up but I don't have a setup to test. Do you have valid ipv6 networks that could be tweaked to test this?

Comment 2 Laine Stump 2016-04-21 18:15:37 UTC
It took awhile to get a working DHCPv6 *client* (dhclient's DHCPv6 in both Fedora 21 and Fedora 22 seems to be broken, but F24-alpha works). I tested with and without a patch that adds ",$prefix" to each dhcp-range option for IPv6 addresses - dnsmasq on the host gave the message reported above without the patch (and didn't supply an address), but with the patch it properly provided an IPv6 address to the guest.

I just sent the patch upstream for review:

  https://www.redhat.com/archives/libvir-list/2016-April/msg01525.html

Comment 3 Laine Stump 2016-04-21 19:20:14 UTC
The above patch is now pushed upstream, will be in the next release:

commit bf3d9f305ebad9d8abd68e4600d2db996b860e68
Author: Laine Stump <laine>
Date:   Thu Apr 21 14:03:18 2016 -0400

    network: fix DHCPv6 on networks with prefix != 64

Comment 4 yalzhang@redhat.com 2016-05-09 10:08:00 UTC
Hi Laine,

Please help to confirm, prefix of DHCPv6 is not supported to configure and it is fixed to 64, right? I have configure the prefix to "97", and it is right in the network conf file, but no effect on the guest. It is always '64' whatever I set in the network definition.Thanks in advance.

Please refer to the details below:

Test with 1.3.4-1.el7.x86_64  and upstream libvirt-1.3.5-1.fc25.x86_64
# virsh net-dumpxml default
<network connections='1'>
  <name>default</name>
  <uuid>ac3350be-5fa1-405c-b19f-cf0ef7c81263</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:15:e9:3a'/>
  <ip address='192.168.122.1' netmask='255.255.252.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254'/>
    </dhcp>
  </ip>
  ** <ip family='ipv6' address='2001:db8:ca2:2::1' prefix='97'> **
    <dhcp>
      <range start='2001:db8:ca2:2::100' end='2001:db8:ca2:2::1ff'/>
    </dhcp>
  </ip>
</network>

# cat /var/lib/libvirt/dnsmasq/default.conf
##WARNING:  THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
##OVERWRITTEN AND LOST.  Changes to this configuration should be made using:
##    virsh net-edit default
## or other application using the libvirt API.
##
## dnsmasq conf file created by libvirt
strict-order
pid-file=/var/run/libvirt/network/default.pid
except-interface=lo
bind-dynamic
interface=virbr0
dhcp-range=192.168.122.2,192.168.122.254
dhcp-no-override
dhcp-range=2001:db8:ca2:2::100,2001:db8:ca2:2::1ff,** 97 **
dhcp-lease-max=509
dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts
enable-ra

but in the guest, the prefixlen is always 64 no matter what we set in the network definition. Is it expected?

# ifconfig
ens9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.234  netmask 255.255.252.0  broadcast 192.168.123.255
        inet6 2001:db8:ca2:2::1d1  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::5054:ff:fea4:23a4  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:a4:23:a4  txqueuelen 1000  (Ethernet)
        RX packets 110  bytes 12267 (11.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 95  bytes 12477 (12.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Comment 5 Laine Stump 2016-05-20 16:02:17 UTC
Sigh.Yes, that does appear to be (kind of) the case. According to this thread:

  http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2013q1/006817.html

and in particular this message:

  http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2013q1/006911.html

dhclient hardcodes the prefix to 64 (and NetworkManager to 128) for any address they acquire, and it's because there isn't a standard method of sending the interface prefix in the dhcpv6 offer (which seem *very* strange).

So I believe there is nothing that libvirt can do about this, because there is nothing that dnsmasq can do about it.

Simon, is this correct? Or has something changed in the 3 years since the above email thread happened?

Comment 6 Simon Kelley 2016-06-03 21:38:08 UTC
Nothing has changed. AFAIK, DHCPv6 is still not a complete
configuration system for IPv6, you need router advertisements to tell
the client what the prefix length and default router are.

Dnsmasq can make the relevant router advertisements, of course, but
integrating the the information in the client is tricky. This seems
relevant


https://kb.isc.org/article/AA-01141/31/How-to-workaround-IPv6-prefix-len
gth-issues-with-ISC-DHCP-clients.html


Note You need to log in before you can comment on or make changes to this bug.