1. 27 6月, 2016 10 次提交
    • L
      util: new function virNetDevIPInfoAddToDev · f1e0d0da
      Laine Stump 提交于
      This patch takes the code out of
      lxcContainerRenameAndEnableInterfaces() that adds all IP addresses and
      IP routes to the interface, and puts it into a utility function
      virNetDevIPInfoAddToDev() in virnetdevip.c so that it can be used by
      anyone.
      
      One small change in functionality -
      lxcContainerRenameAndEnableInterfaces() previously would add all IP
      addresses to the interface while it was still offline, then set the
      interface online, and then add the routes. Because I don't want the
      utility function to set the interface online, I've moved this up so
      the interface is first set online, then IP addresses and routes are
      added. This is the same order that the network service from
      initscripts (in ifup-ether) does it, so it shouldn't pose any problem
      (and hasn't, in the tests that I've run).
      f1e0d0da
    • L
      lxc: move debug/error log when adding IP addresses to virNetDevIPAddrAdd · 4ff9ec7d
      Laine Stump 提交于
      It makes more sense to have the logging at the lower level so other
      callers can share the goodness.
      
      While removing so much stuff from / touching so many lines in
      lxcContainerRenameAndEnableInterfaces() (which used to have this
      debug/error logging), label names were changed and it was updated to
      use the now-more-common method of initializing ret to -1 (failure),
      then setting to 0 right before the cleanup label.
      4ff9ec7d
    • L
      conf: single object containing list of IP addresses, list of routes · 9911562a
      Laine Stump 提交于
      There are currently two places in the domain where this combination is
      used, and there is about to be another. This patch puts them together
      for brevity and uniformity.
      
      As with the newly-renamed virNetDevIPAddr and virNetDevIPRoute
      objects, the new virNetDevIPInfo object will need to be accessed by a
      utility function that calls low level Netlink functions (so we don't
      want it to be in the conf directory) and will be called from multiple
      hypervisor drivers (so it can't be in any hypervisor directory); the
      most appropriate place is thus once again the util directory.
      
      The parse and format functions are in conf/domain_conf.c because only
      the domain XML (i.e. *not* the network XML) has this exact combination
      of IP addresses plus routes. Note that virDomainNetIPInfoFormat() will
      end up being the only caller to virDomainNetRoutesFormat() and
      virDomainNetIPsFormat(), so it will just subsume those functions in a
      later patch, but we can't do that until they are no longer called.
      
      (It would have been nice to include the interface name within the
      virNetDevIPInfo object (with a slight name change), but that can't
      be done cleanly, because in each case the interface name is provided
      in a different place in the XML relative to the routes and IP
      addresses, so putting it in this object would actually make the code
      more confused rather than simpler).
      9911562a
    • L
      util: move IP route & address object-related functions to virnetdevip.c · fa18e814
      Laine Stump 提交于
      These functions all need to be called from a utility function that
      must be located in the util directory, so we move them all into
      util/virnetdevip.[ch] now that it exists.
      
      Function and struct names were appropriately changed for the new
      location, but all code is unchanged aside from motion and renaming.
      fa18e814
    • L
      util: new files virnetdevip.[ch] for IP-related netdev functions · cf0568b0
      Laine Stump 提交于
      This patch splits virnetdev.[ch] into multiple files, with the new
      virnetdevip.[ch] containing all the functions related to setting and
      retrieving IP-related info for a device (both addresses and routes).
      cf0568b0
    • L
      lxc: use correct prefix when setting veth IP address · 70a2c7e0
      Laine Stump 提交于
      Commit c9a641 (first appearred in 1.2.12) added support for setting
      the guest-side IP address of veth devices in lxc domains.
      Unfortunately, it hardcoded the assumption that the proper prefix for
      any IP address with no explicit prefix in the config should be "24";
      that is only correct for class C IPv4 addresses, but not for any other
      IPv4 address, nor for any IPv6 address.
      
      The good news is that there is already a function in libvirt that will
      determine the proper default prefix for any IP address. This patch
      replaces the use of the ill-fated VIR_SOCKET_ADDR_DEFAULT_PREFIX with
      calls to virSocketAddrGetIPPrefix().
      70a2c7e0
    • L
      util: allow calling virSocketAddrGetIPPrefix with NULL netmask or address · 9359167e
      Laine Stump 提交于
      There are times when we don't have a netmask pointer to give to
      virSocketAddrGetIPPrefix() (e.g. the IP addresses in domain interfaces
      only have a prefix, no netmask), but it would have caused a segv if we
      called it with NULL instead of a pointer to a netmask. This patch
      qualifies the code that would use the netmask or address pointers to
      check for NULL first.
      9359167e
    • L
      global: consistently use IP rather than Ip in identifiers · 22a6873a
      Laine Stump 提交于
      I'm tired of mistyping this all the time, so let's do it the same all
      the time (similar to how we changed all "Pci" to "PCI" awhile back).
      
      (NB: I've left alone some things in the esx and vbox drivers because
      I'm unable to compile them and they weren't obviously *not* a part of
      some API. I also didn't change a couple of variables named,
      e.g. "somethingIptables", because they were derived from the name of
      the "iptables" command)
      22a6873a
    • L
      util: move virInterface(State|Link)/virNetDevFeature from conf to util · 638c6e5b
      Laine Stump 提交于
      These had been declared in conf/device_conf.h, but then used in
      util/virnetdev.c, meaning that we had to #include conf/device_conf.h
      in virnetdev.c (which we have for a long time said shouldn't be done.
      
      This caused a bigger problem when I tried to #include util/virnetdev.h
      in a file in src/conf (which is allowed) - for some reason the
      "device_conf.h: File not found" error.
      
      The solution is to move the data types and functions used in util
      sources from conf to util. Some names were adjusted during the move
      ("virInterface" --> "virNetDevIf", and "VIR_INTERFACE" -->
      "VIR_NETDEV_IF")
      638c6e5b
    • L
      util: move virNetDevLinkDump to virnetlink.c · 943a400c
      Laine Stump 提交于
      virNetDevLinkDump should have been in virnetlink.c, but that file
      didn't exist yet when the function was created. It didn't really
      matter until now - I found that having virnetlink.h included by
      virnetdev.h caused build problems when trying to #include virnetdev.h
      in a .c file in src/conf (due to missing directory in -I). Rather than
      fix that to further institutionalize the incorrect placement of this
      one function, this patch moves the function.
      943a400c
  2. 25 6月, 2016 5 次提交
  3. 24 6月, 2016 16 次提交
  4. 22 6月, 2016 1 次提交
  5. 20 6月, 2016 7 次提交
  6. 17 6月, 2016 1 次提交
    • L
      util: fix missing broadcast address in bridge and tap device IP addresses · bf913385
      Laine Stump 提交于
      Commit b3d06987 added peer address setting to the low level
      virNetDevSetIPAddress() function, but ended up causing a segfault in
      cases where the caller passed NULL for peer address.
      
      Commit a3510e33 fixed the segfault, but managed to cause us to
      skip setting the broadcast address when setting an interface's IP
      address. The result is that the broadcast address is 0.0.0.0 for all
      libvirt-created bridges (and interfaces in lxc containers with IP
      addresses set by libvirt).
      
      This was reported on the mailing list:
      
        https://www.redhat.com/archives/libvir-list/2016-June/msg00027.html
      
      but I was too busy to investigate at the time. I found it by accident
      today while refactoring virNetDevSetIPAddress(). Since this regression
      is present in the 1.3.5 release, I'm sending the bugfix as a separate
      patch from my larger refactoring patchset.
      bf913385