1. 19 1月, 2011 2 次提交
  2. 06 1月, 2011 1 次提交
    • K
      bridge: Fix generation of dnsmasq's --dhcp-hostsfile option · a43c7338
      Kay Schubert 提交于
      I added a host definition to a network definition:
      
      <network>
        <name>Lokal</name>
        <uuid>2074f379-b82c-423f-9ada-305d8088daaa</uuid>
        <bridge name='virbr1' stp='on' delay='0' />
        <ip address='192.168.180.1' netmask='255.255.255.0'>
          <dhcp>
            <range start='192.168.180.128' end='192.168.180.254' />
            <host mac='23:74:00:03:42:02' name='somevm' ip='192.168.180.10' />
          </dhcp>
        </ip>
      </network>
      
      But due to the wrong if-statement the argument --dhcp-hostsfile doesn't get
      added to the dnsmasq command. The patch below fixes it for me.
      a43c7338
  3. 24 12月, 2010 9 次提交
    • L
      Run radvd for virtual networks with IPv6 addresses · 8090a568
      Laine Stump 提交于
      Running an instance of the router advertisement daemon (radvd) allows
      guests using the virtual network to automatically acquire an IPv6
      address and default route. Note that acquiring an address only works
      for networks with a prefix length of exactly 64 - radvd is still run
      in other circumstances, and still advertises routes, but autoconf will
      not work because it requires exactly 64 bits of address info from the
      network prefix.
      
      This patch avoids a race condition with the pidfile by manually
      daemonizing radvd rather than allowing it to daemonize itself, then
      creating our own pidfile (in addition to radvd's own file, which is
      unnecessary, but there is no way to tell radvd to not create it). This
      is accomplished by exec'ing it with "--debug 1" in the commandline,
      and using virCommand's features to fork, create a pidfile, and detach
      from the newly forked process.
      8090a568
    • L
      Turn on IPv6 support in the bridge_driver.c virtual network driver · 6ccce752
      Laine Stump 提交于
      At this point everything is already in place to make IPv6 happen, we just
      need to add a few rules, remove some checks for IPv4-only, and document
      the changes to the XML on the website.
      6ccce752
    • L
      Update iptables.c to also support ip6tables. · 537e65e7
      Laine Stump 提交于
      All of the iptables functions eventually call down to a single
      bottom-level function, and fortunately, ip6tables syntax (for all the
      args that we use) is identical to iptables format (except the
      addresses), so all we need to do is:
      
      1) Get an address family down to the lowest level function in each
         case, either implied through an address, or explicitly when no
         address is in the parameter list, and
      
      2) At the lowest level, just decide whether to call "iptables" or
         "ip6tables" based on the family.
      
      The location of the ip6tables binary is determined at build time by
      autoconf. If a particular target system happens to not have ip6tables
      installed, any attempts to run it will generate an error, but that
      won't happen unless someone tries to define an IPv6 address for a
      network. This is identical behavior to IPv4 addresses and iptables.
      537e65e7
    • L
      Support multiple IP addresses on one network in bridge_driver.c · ad48dfa1
      Laine Stump 提交于
      This patch reorganizes the code in bridge_driver.c to account for the
      concept of a single network with multiple IP addresses, without adding
      in the extra variable of IPv6. A small bit of code has been
      temporarily added that checks all given addresses to verify they are
      IPv4 - this will be removed when full IPv6 support is turned on.
      ad48dfa1
    • L
      Change virtual network XML parsing/formatting to support IPv6 · a950dd2a
      Laine Stump 提交于
      This commit adds support for IPv6 parsing and formatting to the
      virtual network XML parser, including moving around data definitions
      to allow for multiple <ip> elements on a single network, but only
      changes the consumers of this API to accommodate for the changes in
      API/structure, not to add any actual IPv6 functionality. That will
      come in a later patch - this patch attempts to maintain the same final
      functionality in both drivers that use the network XML parser - vbox
      and "bridge" (the Linux bridge-based driver used by the qemu
      hypervisor driver).
      
      * src/libvirt_private.syms: Add new private API functions.
      * src/conf/network_conf.[ch]: Change C data structure and
        parsing/formatting.
      * src/network/bridge_driver.c: Update to use new parser/formatter.
      * src/vbox/vbox_tmpl.c: update to use new parser/formatter
      * docs/schemas/network.rng: changes to the schema -
        * there can now be more than one <ip> element.
        * ip address is now an ip-addr (ipv4 or ipv6) rather than ipv4-addr
        * new optional "prefix" attribute that can be used in place of "netmask"
        * new optional "family" attribute - "ipv4" or "ipv6"
          (will default to ipv4)
        * define data types for the above
      * tests/networkxml2xml(in|out)/nat-network.xml: add multiple <ip> elements
        (including IPv6) to a single network definition to verify they are being
        correctly parsed and formatted.
      a950dd2a
    • L
      Replace brSetInetAddress/brSetInetNetmask with brAddInetAddress · 20718b8b
      Laine Stump 提交于
      brSetInetAddress can only set a single IP address on the bridge, and
      uses a method (ioctl(SIOCSETIFADDR)) that only works for IPv4. Replace
      it and brSetInetNetmask with a single function that uses the external
      "ip addr add" command to add an address/prefix to the interface - this
      supports IPv6, and allows adding multiple addresses to the interface.
      
      Although it isn't currently used in the code, we also add a
      brDelInetAddress for completeness' sake.
      
      Also, while we're modifying bridge.c, we change brSetForwardDelay and
      brSetEnableSTP to use the new virCommand API rather than the
      deprecated virRun, and also log an error message in bridge_driver.c if
      either of those fail (previously the failure would be completely
      silent).
      20718b8b
    • L
      Pass prefix rather than netmask into iptables functions · b23d417c
      Laine Stump 提交于
      IPv6 will use prefix exclusively, and IPv4 will also optionally be
      able to use it, and the iptables functions really need a prefix
      anyway, so use the new virNetworkDefPrefix() function to send prefixes
      into iptables functions instead of netmasks.
      
      Also, in a couple places where a netmask is actually needed, use the
      new private API function for it rather than getting it directly. This
      will allow for cases where no netmask or prefix is specified (it
      returns the default for the current class of network.)
      b23d417c
    • L
      Consistently return 0 on success, -1 on failure in bridge_driver.c · 6e3e6db1
      Laine Stump 提交于
      Some functions in this file were returning 1 on success and 0 on
      failure, and others were returning 0 on success and -1 on
      failure. Switch them all to return the libvirt-preferred 0/-1.
      6e3e6db1
    • L
      Fix logging of failed iptables commands · cf731189
      Laine Stump 提交于
      The functions in iptables.c all return -1 on failure, but all their
      callers (which all happen to be in bridge_driver.c) assume that they
      are returning an errno, and the logging is done accordingly. This
      patch fixes all the error checking and logging to assume < 0 is an
      error, and nothing else.
      cf731189
  4. 20 12月, 2010 1 次提交
    • P
      bridge_driver: avoid double call to VIR_FREE · ed039abc
      Paweł Krześniak 提交于
      While not technically a double free (since VIR_FREE NULLs the
      pointer), this is unnecessary extra code.
      
      This crept in when the function was converted from virRun to virCommand.
      
      The AUTHORS file has also been updated.
      ed039abc
  5. 11 12月, 2010 1 次提交
    • L
      Convert dhcpStartDhcpDaemon from virRun to virCommand · 044f2011
      Laine Stump 提交于
      This is pretty straightforward - even though dnsmasq gets daemonized
      and uses a pid file, those things are both handled by the dnsmasq
      binary itself. And libvirt doesn't need any of the output of the
      dnsmasq command either, so we just setup the args and call
      virRun(). Mainly it was just a (mostly) mechanical job of replacing
      the APPEND_ARG() macro (and some other *printfs()) with
      virCommandAddArg*().
      044f2011
  6. 03 12月, 2010 1 次提交
    • J
      Create file in virFileWriteStr() if it doesn't exist · 966a1bfe
      Jean-Baptiste Rouault 提交于
      This patch adds a mode_t parameter to virFileWriteStr().
      If mode is different from 0, virFileWriteStr() will try
      to create the file if it doesn't exist.
      
      * src/util/util.h (virFileWriteStr): Alter signature.
      * src/util/util.c (virFileWriteStr): Allow file creation.
      * src/network/bridge_driver.c (networkEnableIpForwarding)
      (networkDisableIPV6): Adjust clients.
      * src/node_device/node_device_driver.c
      (nodeDeviceVportCreateDelete): Likewise.
      * src/util/cgroup.c (virCgroupSetValueStr): Likewise.
      * src/util/pci.c (pciBindDeviceToStub, pciUnBindDeviceFromStub):
      Likewise.
      966a1bfe
  7. 17 11月, 2010 1 次提交
    • E
      maint: use gnulib configmake rather than open-coding things · 0d5f54bb
      Eric Blake 提交于
      * bootstrap.conf (gnulib_modules): Add configmake.
      * daemon/Makefile.am (libvirtd_CFLAGS): Drop defines provided by
      gnulib.
      * src/Makefile.am (INCLUDES): Likewise.
      * tests/Makefile.am (INCLUDES): Likewise.
      * tools/Makefile.am (virsh_CFLAGS): Likewise.
      * daemon/libvirtd.c (qemudInitPaths, usage, main): Update
      clients.
      * src/cpu/cpu_map.c (CPUMAPFILE): Likewise.
      * src/driver.c (DEFAULT_DRIVER_DIR): Likewise.
      * src/internal.h (_): Likewise.
      * src/libvirt.c (virInitialize): Likewise.
      * src/lxc/lxc_conf.h (LXC_CONFIG_DIR, LXC_STATE_DIR, LXC_LOG_DIR):
      Likewise.
      * src/lxc/lxc_conf.c (lxcCapsInit, lxcLoadDriverConfig):
      Likewise.
      * src/network/bridge_driver.c (NETWORK_PID_DIR)
      (NETWORK_STATE_DIR, DNSMASQ_STATE_DIR, networkStartup): Likewise.
      * src/nwfilter/nwfilter_driver.c (nwfilterDriverStartup):
      Likewise.
      * src/qemu/qemu_conf.c (qemudLoadDriverConfig): Likewise.
      * src/qemu/qemu_driver.c (qemudStartup): Likewise.
      * src/remote/remote_driver.h (LIBVIRTD_PRIV_UNIX_SOCKET)
      (LIBVIRTD_PRIV_UNIX_SOCKET_RO, LIBVIRTD_CONFIGURATION_FILE)
      (LIBVIRT_PKI_DIR): Likewise.
      * src/secret/secret_driver.c (secretDriverStartup): Likewise.
      * src/security/security_apparmor.c (VIRT_AA_HELPER): Likewise.
      * src/security/virt-aa-helper.c (main): Likewise.
      * src/storage/storage_backend_disk.c (PARTHELPER): Likewise.
      * src/storage/storage_driver.c (storageDriverStartup): Likewise.
      * src/uml/uml_driver.c (TEMPDIR, umlStartup): Likewise.
      * src/util/hooks.c (LIBVIRT_HOOK_DIR): Likewise.
      * tools/virsh.c (main): Likewise.
      * docs/hooks.html.in: Likewise.
      0d5f54bb
  8. 28 10月, 2010 1 次提交
    • L
      Only attempt removal of the rule allowing tftp if it was added · 0111cebb
      Laine Stump 提交于
      During virtual network startup, the iptables rule that allows tftp
      traffic is only added if network->def->tftproot is non-empty, but when
      the virtual network is destroyed, we had been unconditionally trying
      to delete the rule. This was harmless, except that it created a bogus
      error message.
      
      This patch conditionalizes the delete command in the same manner that
      the insert command is already conditionalized.
      0111cebb
  9. 26 10月, 2010 2 次提交
    • D
      Avoid squashing errors during network startup cleanup path · d68bb70a
      Daniel P. Berrange 提交于
      When failing to start a virtual network, we have to cleanup,
      tearing down any iptables rules. If the iptables rules were
      not present yet though, this raises an error, which squashes
      the original error we were handling.
      
      * src/network/bridge_driver.c: When failing to start a virtual
        network, don't squash the original error in cleanup
      d68bb70a
    • D
      Fix formatting of network address in iptables helpers · eff1735e
      Daniel P. Berrange 提交于
      The network address was being set to 192.168.122.0 instead
      of 192.168.122.0/24. Fix this by removing the unneccessary
      'network' field from virNetworkDef and just pass the
      network address and netmask into the iptables APIs directly.
      
      * src/conf/network_conf.h, src/conf/network_conf.c: Remove
        the 'network' field from virNEtworkDef.
      * src/network/bridge_driver.c: Update for iptables API changes
      * src/util/iptables.c, src/util/iptables.h: Require the
        network address + netmask pair to be passed in
      eff1735e
  10. 22 10月, 2010 4 次提交
    • D
      Convert virNetwork to use virSocketAddr everywhere · 090404ac
      Daniel P. Berrange 提交于
      Instead of storing the IP address string in virNetwork related
      structs, store the parsed virSocketAddr. This will make it
      easier to add IPv6 support in the future, by letting driver
      code directly check what address family is present
      
      * src/conf/network_conf.c, src/conf/network_conf.h,
        src/network/bridge_driver.c: Convert to use virSocketAddr
        in virNetwork, instead of char *.
      * src/util/bridge.c, src/util/bridge.h,
        src/util/dnsmasq.c, src/util/dnsmasq.h,
        src/util/iptables.c, src/util/iptables.h: Convert to
        take a virSocketAddr instead of char * for any IP
        address parameters
      * src/util/network.h: Add macros to determine if an address
        is set, and what address family is set.
      090404ac
    • D
      Fix error reporting for virSocketParse · 179c4be0
      Daniel P. Berrange 提交于
      The virSocketParse method was not doing any error reporting
      which meant the true cause of the problem was lost. Remove
      all error reporting from callers, and push it into virSocketParse
      
      * src/util/network.c: Add error reporting to virSocketParse
      * src/conf/domain_conf.c, src/conf/network_conf.c,
        src/network/bridge_driver.c: Remove error reporting in
        callers of virSocketParse
      179c4be0
    • D
      Fix passing of address family to virSocketParseAddr · 746c3364
      Daniel P. Berrange 提交于
      The virSocketParseAddr function was accepting any AF_* constant
      and using that to set the ai_flags field in struct addrinfo.
      This is invalid, since address families must go in the ai_family
      field of the struct.
      
      * src/util/network.c: Fix handling of address family
      * src/conf/network_conf.c, src/network/bridge_driver.c: Pass
        AF_UNSPEC instead of relying on it being 0.
      746c3364
    • D
      Include length with virSocketAddr data · af3d4eec
      Daniel P. Berrange 提交于
      Some operations on socket addresses need to know the length of
      the sockaddr struct for the particular address family. This
      info was being discarded when passing around virSocketAddr
      instances. Turn it from a union into a struct containing
      union+socklen_t fields, so length is always kept around.
      
      * src/util/network.h: Add socklen_t field to virSocketAddr
      * src/util/network.c, src/network/bridge_driver.c,
        src/conf/domain_conf.c: Update to take account of new
        struct definition.
      af3d4eec
  11. 10 9月, 2010 1 次提交
    • J
      bridge: Fix static-only DHCP configuration · df990b44
      Jiri Denemark 提交于
      For static-only DHCP, i.e. with no <range> but at least one <host>
      element within <dhcp> element, we have to add "--dhcp-range IP,static"
      option to dnsmasq to actually enable the service. Without this option,
      dnsmasq will not respond to DHCP requests.
      df990b44
  12. 12 8月, 2010 2 次提交
    • J
      bridge: Add --dhcp-no-override option to dnsmasq · e26672f7
      Jiri Denemark 提交于
      --dhcp-no-override description from dnsmasq man page:
      
            Disable  re-use  of  the  DHCP servername and filename fields as
            extra option space. If it can, dnsmasq moves the boot server and
            filename  information  (from  dhcp-boot)  out of their dedicated
            fields into DHCP options. This make extra space available in the
            DHCP  packet  for options but can, rarely, confuse old or broken
            clients. This flag forces "simple and safe" behaviour  to  avoid
            problems in such a case.
      
      It seems some virtual network card ROMs are this old/buggy so let's add
      --dhcp-no-override as a workaround for them. We don't use extra DHCP
      options so this should be safe. The option was added in dnsmasq-2.41,
      which becomes the minimum required version.
      e26672f7
    • J
      bridge: Fix potential segfault when preparing dnsmasq arguments · 6f42d325
      Jiri Denemark 提交于
      We add --dhcp-lease-max=xxx argument when network->def->nranges > 0 but
      we only allocate space for in the opposite case :-) I guess we are lucky
      enough to miscount somewhere else so that we actually allocate more
      space than we need since no-one has hit this bug so far.
      6f42d325
  13. 02 8月, 2010 1 次提交
    • L
      Add iptables rule to fixup DHCP response checksum. · fd5b15ff
      Laine Stump 提交于
      This patch attempts to take advantage of a newly added netfilter
      module to correct for a problem with some guest DHCP client
      implementations when used in conjunction with a DHCP server run on the
      host systems with packet checksum offloading enabled.
      
      The problem is that, when the guest uses a RAW socket to read the DHCP
      response packets, the checksum hasn't yet been fixed by the IP stack,
      so it is incorrect.
      
      The fix implemented here is to add a rule to the POSTROUTING chain of
      the mangle table in iptables that fixes up the checksum for packets on
      the virtual network's bridge that are destined for the bootpc port (ie
      "dhcpc", ie port 68) port on the guest.
      
      Only very new versions of iptables will have this support (it will be
      in the next upstream release), so a failure to add this rule only
      results in a warning message. The iptables patch is here:
      
        http://patchwork.ozlabs.org/patch/58525/
      
      A corresponding kernel module patch is also required (the backend of
      the iptables patch) and that will be in the next release of the
      kernel.
      fd5b15ff
  14. 31 7月, 2010 1 次提交
  15. 28 7月, 2010 1 次提交
    • E
      maint: fix comment typos · 40a0e82c
      Eric Blake 提交于
      * src/network/bridge_driver.c
      (networkAddMasqueradingIptablesRules): Fix spelling and grammar.
      40a0e82c
  16. 19 7月, 2010 1 次提交
    • D
      CVE-2010-2242 Apply a source port mapping to virtual network masquerading · c5678530
      Daniel P. Berrange 提交于
      IPtables will seek to preserve the source port unchanged when
      doing masquerading, if possible. NFS has a pseudo-security
      option where it checks for the source port <= 1023 before
      allowing a mount request. If an admin has used this to make the
      host OS trusted for mounts, the default iptables behaviour will
      potentially allow NAT'd guests access too. This needs to be
      stopped.
      
      With this change, the iptables -t nat -L -n -v rules for the
      default network will be
      
      Chain POSTROUTING (policy ACCEPT 95 packets, 9163 bytes)
       pkts bytes target     prot opt in     out     source               destination
         14   840 MASQUERADE  tcp  --  *      *       192.168.122.0/24    !192.168.122.0/24    masq ports: 1024-65535
         75  5752 MASQUERADE  udp  --  *      *       192.168.122.0/24    !192.168.122.0/24    masq ports: 1024-65535
          0     0 MASQUERADE  all  --  *      *       192.168.122.0/24    !192.168.122.0/24
      
      * src/network/bridge_driver.c: Add masquerade rules for TCP
        and UDP protocols
      * src/util/iptables.c, src/util/iptables.c: Add source port
        mappings for TCP & UDP protocols when masquerading.
      c5678530
  17. 23 6月, 2010 2 次提交
  18. 08 6月, 2010 1 次提交
    • D
      Network duplicate UUID/name checking · 3bb37439
      Daniel P. Berrange 提交于
      The network driver is not doing correct checking for
      duplicate UUID/name values. This introduces a new method
      virNetworkObjIsDuplicate, based on the previously
      written virDomainObjIsDuplicate.
      
      * src/conf/network_conf.c, src/conf/network_conf.c,
        src/libvirt_private.syms: Add virNetworkObjIsDuplicate,
      * src/network/bridge_driver.c: Call virNetworkObjIsDuplicate
        for checking uniqueness of uuid/names
      3bb37439
  19. 28 5月, 2010 1 次提交
    • C
      network: bridge: Don't start network if it collides with host routing · a83fe2c2
      Cole Robinson 提交于
      Fedora bug https://bugzilla.redhat.com/show_bug.cgi?id=235961
      
      If using the default virtual network, an easy way to lose guest network
      connectivity is to install libvirt inside the VM. The autostarted
      default network inside the guest collides with host virtual network
      routing. This is a long standing issue that has caused users quite a
      bit of pain and confusion.
      
      On network startup, parse /proc/net/route and compare the requested
      IP+netmask against host routing destinations: if any matches are found,
      refuse to start the network.
      
      v2: Drop sscanf, fix a comment typo, comment that function could use
          libnl instead of /proc
      
      v3: Consider route netmask. Compare binary data rather than convert to
          string.
      
      v4: Return to using sscanf, drop inet functions in favor of virSocket,
          parsing safety checks. Don't make parse failures fatal, in case
          expected format changes.
      
      v5: Try and continue if we receive unexpected. Delimit parsed lines to
          prevent scanning past newline
      a83fe2c2
  20. 20 5月, 2010 1 次提交
  21. 19 5月, 2010 1 次提交
  22. 07 5月, 2010 1 次提交
    • E
      build: update gnulib · 062a25f0
      Eric Blake 提交于
      81 patches to gnulib, picks up several new syntax checks.
      
      * .gnulib: Update to latest.
      * .x-sc_prohibit_always_true_header_tests: New file.
      * bootstrap.conf (gnulib_modules): Add sched.
      * src/util/processinfo.c (includes): <sched.h> is now guaranteed.
      * src/network/bridge_driver.c (includes): Drop useless
      <strings.h>.
      * src/openvz/openvz_conf.c (includes): Likewise.
      * src/openvz/openvz_driver.c (includes): Likewise.
      * src/phyp/phyp_driver.c (includes): Likewise.
      * src/qemu/qemu_driver.c (includes): Likewise.
      * src/uml/uml_driver.c (includes): Likewise.
      062a25f0
  23. 28 4月, 2010 1 次提交
    • D
      Move dnsmasq host file to a separate directory · 4e041189
      Daniel Veillard 提交于
      use /var/lib/libvirt/dnsmasq since /var/lib/libvirt/network is
      unreadable by the dnsmasq binary
      
      * src/network/bridge_driver.c: update DNSMASQ_STATE_DIR
      * src/Makefile.am: create it on make install
      * libvirt.spec.in: take the new directory into account
      4e041189
  24. 26 4月, 2010 1 次提交
    • S
      Starts dnsmasq from libvirtd with --dhcp-hostsfile option · 8fa9c221
      Satoru SATOH 提交于
      This patch makes libvirtd start the dnsmasq daemon with a
      --dhcp-hostsfile option instead of --dhcp-host options for each
      '//ip/dhcp/host' entries defined in network xml file.
      
      the dnsmasq host file is stored into /var/lib/libvirt/network
      
      * src/network/bridge_driver.c: define the directory for the hostfiles
        and save/delete them to be used by dnsmasq
      8fa9c221
  25. 10 3月, 2010 1 次提交