• L
    network driver: Start dnsmasq even if no dhcp ranges/hosts are specified. · 7892edc9
    Laine Stump 提交于
    This fixes a regression introduced in commit ad48df, and reported on
    the libvirt-users list:
    
      https://www.redhat.com/archives/libvirt-users/2011-March/msg00018.html
    
    The problem in that commit was that we began searching a list of ip
    address definitions (rather than just having one) to look for a dhcp
    range or static host; when we didn't find any, our pointer (ipdef) was
    left at NULL, and when ipdef was NULL, we returned without starting up
    dnsmasq.
    
    Previously dnsmasq was started even without any dhcp ranges or static
    entries, because it's still useful for DNS services.
    
    Another problem I noticed while investigating was that, if there are
    IPv6 addresses, but no IPv4 addresses of any kind, we would jump out
    at an ever higher level in the call chain.
    
    This patch does the following:
    
    1) networkBuildDnsmasqArgv() = all uses of ipdef are protected from
       NULL dereference. (this patch doesn't change indentation, to make
       review easier. The next patch will change just the
       indentation). ipdef is intended to point to the first IPv4 address
       with DHCP info (or the first IPv4 address if none of them have any
       dhcp info).
    
    2) networkStartDhcpDaemon() = if the loop looking for an ipdef with
       DHCP info comes up empty, we then grab the first IPv4 def from the
       list. Also, instead of returning if there are no IPv4 defs, we just
       return if there are no IP defs at all (either v4 or v6). This way a
       network that is IPv6-only will still get dnsmasq listening for DNS
       queries.
    
    3) in networkStartNetworkDaemon() - we will startup dhcp not just if there
       are any IPv4 addresses, but also if there are any IPv6 addresses.
    7892edc9
bridge_driver.c 77.4 KB