[libvirt] [PATCH] network: verify proper address family in updates to <host> and <range>

Laine Stump laine at laine.org
Thu Jan 22 15:20:46 UTC 2015


On 01/22/2015 03:47 AM, Ján Tomko wrote:
> On 01/19/2015 11:04 PM, Laine Stump wrote:
>> By specifying parentIndex in a call to virNetworkUpdate(), it was
>> possible to direct libvirt to add a dhcp range or static host of a
>> non-matching address family to the <dhcp> element of an <ip>. For
>> example, given:
>>
>>  <ip address='192.168.122.1' netmask='255.255.255.0'/>
>>  <ip family='ipv6' address='2001:db6:ca3:45::1' prefix='64'/>
>>
>> you could provide a static host entry with an IPv4 address, and
>> specify that it be added to the 2nd <ip> element (index 1):
>>
>>   virsh net-update default add ip-dhcp-host --parent-index 1 \
>>   '<host mac="52:54:00:00:00:01" ip="192.168.122.45"/>'
>>
>> This would be happily added with no error (and no concern of any
>> possible future consequences).
>>
>> This patch checks that any dhcp range or host element being added to a
>> network ip's <dhcp> subelement has addresses of the same family as the
>> ip element they are being added to.
>>
>> This problem was noticed when looking at the reproduction case for
>> https://bugzilla.redhat.com/show_bug.cgi?id=1182486 (but is not a
>> solution to that bug).
>> ---
>>  src/conf/network_conf.c | 18 +++++++++++++++++-
>>  1 file changed, 17 insertions(+), 1 deletion(-)
>>
> ACK
>
> Although it would be nicer if we could also find the correct <dhcp> element
> matching the address when --parent-index is not specified. With the ipv4
> <dhcp> section first I get an error trying to add an ipv6 host:

Good point! We do search for the first <ip> element that has a <dhcp>,
but we don't pay attention to whether or not the address family is the
same. I'll whip up another patch to take care of that.

>
> virsh net-update default add-first ip-dhcp-host ipv6.xml
> error: Failed to update network default
> error: Requested operation is not valid: the address family of a host entry IP
> must match the address family of the dhcp element's parent
>
> Jan
>




More information about the libvir-list mailing list