1. 25 4月, 2014 2 次提交
  2. 14 3月, 2014 1 次提交
  3. 10 3月, 2014 1 次提交
    • M
      conf: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT · 2133441a
      Michal Privoznik 提交于
      This fixes a possible double free. In virNetworkAssignDef() if
      virBitmapNew() fails, then virNetworkObjFree(network) is called.
      However, with network->def pointing to actual @def. So if caller
      frees @def again, ...
      
      Moreover, this fixes one possible memory leak too. In
      virInterfaceAssignDef() if appending to the list of interfaces
      fails, we ought to call virInterfaceObjFree() instead of bare
      VIR_FREE().
      
      Although, in order to do that some array size variables needs
      to be turned into size_t rather than int.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      2133441a
  4. 31 1月, 2014 1 次提交
    • D
      Push nwfilter update locking up to top level · 6e5c79a1
      Daniel P. Berrange 提交于
      The NWFilter code has as a deadlock race condition between
      the virNWFilter{Define,Undefine} APIs and starting of guest
      VMs due to mis-matched lock ordering.
      
      In the virNWFilter{Define,Undefine} codepaths the lock ordering
      is
      
        1. nwfilter driver lock
        2. virt driver lock
        3. nwfilter update lock
        4. domain object lock
      
      In the VM guest startup paths the lock ordering is
      
        1. virt driver lock
        2. domain object lock
        3. nwfilter update lock
      
      As can be seen the domain object and nwfilter update locks are
      not acquired in a consistent order.
      
      The fix used is to push the nwfilter update lock upto the top
      level resulting in a lock ordering for virNWFilter{Define,Undefine}
      of
      
        1. nwfilter driver lock
        2. nwfilter update lock
        3. virt driver lock
        4. domain object lock
      
      and VM start using
      
        1. nwfilter update lock
        2. virt driver lock
        3. domain object lock
      
      This has the effect of serializing VM startup once again, even if
      no nwfilters are applied to the guest. There is also the possibility
      of deadlock due to a call graph loop via virNWFilterInstantiate
      and virNWFilterInstantiateFilterLate.
      
      These two problems mean the lock must be turned into a read/write
      lock instead of a plain mutex at the same time. The lock is used to
      serialize changes to the "driver->nwfilters" hash, so the write lock
      only needs to be held by the define/undefine methods. All other
      methods can rely on a read lock which allows good concurrency.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      6e5c79a1
  5. 15 10月, 2013 1 次提交
    • E
      maint: avoid 'const fooPtr' in nwfilter files · 1b7ec657
      Eric Blake 提交于
      'const fooPtr' is the same as 'foo * const' (the pointer won't
      change, but it's contents can).  But in general, if an interface
      is trying to be const-correct, it should be using 'const foo *'
      (the pointer is to data that can't be changed).
      
      Fix up offenders in nwfilter code.
      
      This patch does nothing about the stupidity evident in having
      __virNWFilterInstantiateFilter, _virNWFilterInstantiateFilter,
      and virNWFilterInstantiateFilter, which differ only by leading
      underscores, and which infringes on the namespace reserved to
      the implementation - that would need to be a separate cleanup.
      
      * src/nwfilter/nwfilter_dhcpsnoop.h (virNWFilterDHCPSnoopReq): Use
      intended type.
      * src/nwfilter/nwfilter_gentech_driver.h
      (virNWFilterInstantiateFilter)
      (virNWFilterUpdateInstantiateFilter)
      (virNWFilterInstantiataeFilterLate, virNWFilterTeardownFilter)
      (virNWFilterCreateVarHashmap): Likewise.
      * src/nwfilter/nwfilter_learnipaddr.h (virNWFilterLearnIPAddress):
      Likewise.
      * src/conf/nwfilter_conf.h (virNWFilterApplyBasicRules)
      (virNWFilterApplyDHCPOnlyRules): Likewise.
      (virNWFilterDefFormat): Make const-correct.
      * src/conf/nwfilter_params.h (virNWFilterVarValueCopy)
      (virNWFilterVarValueGetSimple, virNWFilterVarValueGetCardinality)
      (virNWFilterVarValueEqual, virNWFilterVarAccessEqual)
      (virNWFilterVarAccessGetVarName, virNWFilterVarAccessGetType)
      (virNWFilterVarAccessGetIterId, virNWFilterVarAccessGetIndex)
      (virNWFilterVarAccessIsAvailable)
      (virNWFilterVarCombIterGetVarValue): Use intended type.
      (virNWFilterVarValueGetNthValue): Make const-correct.
      * src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopReqLeaseDel)
      (virNWFilterSnoopIFKeyFMT, virNWFilterDHCPSnoopReq)
      (virNWFilterSnoopPruneIter, virNWFilterSnoopRemAllReqIter)
      (virNWFilterDHCPSnoopReq): Fix fallout.
      * src/nwfilter/nwfilter_gentech_driver.c
      (virNWFilterVarHashmapAddStdValues, virNWFilterCreateVarHashmap)
      (virNWFilterInstantiate, __virNWFilterInstantiateFilter)
      (_virNWFilterInstantiateFilter, virNWFilterInstantiateFilterLate)
      (virNWFilterInstantiateFilter)
      (virNWFilterUpdateInstantiateFilter)
      (virNWFilterRollbackUpdateFilter, virNWFilterTeardownFilter):
      Likewise.
      * src/nwfilter/nwfilter_learnipaddr.c (virNWFilterLearnIPAddress):
      Likewise.
      * src/conf/nwfilter_params.c (virNWFilterVarValueCopy)
      (virNWFilterVarValueGetSimple)
      (virNWFilterVarValueGetCardinality, virNWFilterVarValueEqual)
      (virNWFilterVarCombIterAddVariable)
      (virNWFilterVarCombIterGetVarValue, virNWFilterVarValueCompare)
      (virNWFilterFormatParamAttributes, virNWFilterVarAccessEqual)
      (virNWFilterVarAccessGetVarName, virNWFilterVarAccessGetType)
      (virNWFilterVarAccessGetIterId, virNWFilterVarAccessGetIndex)
      (virNWFilterVarAccessGetIntIterId)
      (virNWFilterVarAccessIsAvailable)
      (virNWFilterVarValueGetNthValue): Likewise.
      * src/nwfilter/nwfilter_ebiptables_driver.c (ebtablesApplyBasicRules)
      (ebtablesApplyDHCPOnlyRules, ebiptablesRuleOrderSort)
      (ebiptablesRuleOrderSortPtr): Likewise.
      * src/conf/nwfilter_conf.c (virNWFilterDefEqual)
      (virNWFilterDefFormat): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1b7ec657
  6. 07 10月, 2013 3 次提交
  7. 02 5月, 2013 1 次提交
    • M
      virutil: Move string related functions to virstring.c · 7c9a2d88
      Michal Privoznik 提交于
      The source code base needs to be adapted as well. Some files
      include virutil.h just for the string related functions (here,
      the include is substituted to match the new file), some include
      virutil.h without any need (here, the include is removed), and
      some require both.
      7c9a2d88
  8. 05 2月, 2013 1 次提交
    • D
      Turn virDomainObjList into an opaque virObject · 37abd471
      Daniel P. Berrange 提交于
      As a step towards making virDomainObjList thread-safe turn it
      into an opaque virObject, preventing any direct access to its
      internals.
      
      As part of this a new method virDomainObjListForEach is
      introduced to replace all existing usage of virHashForEach
      37abd471
  9. 23 1月, 2013 1 次提交
    • D
      Fix nwfilter driver reload/shutdown handling when unprivileged · abbec81b
      Daniel P. Berrange 提交于
      Although the nwfilter driver skips startup when running in a
      session libvirtd, it did not skip reload or shutdown. This
      caused errors to be reported when sending SIGHUP to libvirtd,
      and caused an abort() in libdbus on shutdown due to trying
      to remove a dbus filter that was never added
      abbec81b
  10. 21 12月, 2012 3 次提交
  11. 21 9月, 2012 1 次提交
  12. 22 8月, 2012 1 次提交
  13. 10 8月, 2012 2 次提交
    • L
      nwfilter: fix crash during filter define when lxc driver failed startup · b8a56f12
      Laine Stump 提交于
      The meat of this patch is just moving the calls to
      virNWFilterRegisterCallbackDriver from each hypervisor's "register"
      function into its "initialize" function. The rest is just code
      movement to allow that, and a new virNWFilterUnRegisterCallbackDriver
      function to undo what the register function does.
      
      The long explanation:
      
      There is an array in nwfilter called callbackDrvArray that has
      pointers to a table of functions for each hypervisor driver that are
      called by nwfilter. One of those function pointers is to a function
      that will lock the hypervisor driver. Entries are added to the table
      by calling each driver's "register" function, which happens quite
      early in libvirtd's startup.
      
      Sometime later, each driver's "initialize" function is called. This
      function allocates a driver object and stores a pointer to it in a
      static variable that was previously initialized to NULL. (and here's
      the important part...) If the "initialize" function fails, the driver
      object is freed, and that pointer set back to NULL (but the entry in
      nwfilter's callbackDrvArray is still there).
      
      When the "lock the driver" function mentioned above is called, it
      assumes that the driver was successfully loaded, so it blindly tries
      to call virMutexLock on "driver->lock".
      
      BUT, if the initialize never happened, or if it failed, "driver" is
      NULL. And it just happens that "lock" is always the first field in
      driver so it is also NULL.
      
      Boom.
      
      To fix this, the call to virNWFilterRegisterCallbackDriver for each
      driver shouldn't be called until the end of its (*already guaranteed
      successful*) "initialize" function, not during its "register" function
      (which is currently the case). This implies that there should also be
      a virNWFilterUnregisterCallbackDriver() function that is called in a
      driver's "shutdown" function (although in practice, that function is
      currently never called).
      b8a56f12
    • E
      build: fix PROBE() usage of intptr_t · 51ee43aa
      Eric Blake 提交于
      Otherwise, in locations like virobject.c where PROBE is used,
      for certain configure options, the compiler warns:
      
      util/virobject.c:110:1: error: 'intptr_t' undeclared (first use in this function)
      
      As long as we are making this header always available, we can
      clean up several other files.
      
      * src/internal.h (includes): Pull in <stdint.h>.
      * src/conf/nwfilter_conf.h: Rely on internal.h.
      * src/storage/storage_backend.c: Likewise.
      * src/storage/storage_backend.h: Likewise.
      * src/util/cgroup.c: Likewise.
      * src/util/sexpr.h: Likewise.
      * src/util/virhashcode.h: Likewise.
      * src/util/virnetdevvportprofile.h: Likewise.
      * src/util/virnetlink.h: Likewise.
      * src/util/virrandom.h: Likewise.
      * src/vbox/vbox_driver.c: Likewise.
      * src/xenapi/xenapi_driver.c: Likewise.
      * src/xenapi/xenapi_utils.c: Likewise.
      * src/xenapi/xenapi_utils.h: Likewise.
      * src/xenxs/xenxs_private.h: Likewise.
      * tests/storagebackendsheepdogtest.c: Likewise.
      51ee43aa
  14. 23 7月, 2012 1 次提交
    • O
      Desert the FSF address in copyright · f9ce7dad
      Osier Yang 提交于
      Per the FSF address could be changed from time to time, and GNU
      recommends the following now: (http://www.gnu.org/licenses/gpl-howto.html)
      
        You should have received a copy of the GNU General Public License
        along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
      
      This patch removes the explicit FSF address, and uses above instead
      (of course, with inserting 'Lesser' before 'General').
      
      Except a bunch of files for security driver, all others are changed
      automatically, the copyright for securify files are not complete,
      that's why to do it manually:
      
        src/security/security_selinux.h
        src/security/security_driver.h
        src/security/security_selinux.c
        src/security/security_apparmor.h
        src/security/security_apparmor.c
        src/security/security_driver.c
      f9ce7dad
  15. 19 7月, 2012 1 次提交
  16. 17 7月, 2012 1 次提交
    • S
      Convert 'raw MAC address' usages to use virMacAddr · 387117ad
      Stefan Berger 提交于
      Introduce new members in the virMacAddr 'class'
      - virMacAddrSet: set virMacAddr from a virMacAddr
      - virMacAddrSetRaw: setting virMacAddr from raw 6 byte MAC address buffer
      - virMacAddrGetRaw: writing virMacAddr into raw 6 byte MAC address buffer
      - virMacAddrCmp: comparing two virMacAddr
      - virMacAddrCmpRaw: comparing a virMacAddr with a raw 6 byte MAC address buffer
      
      then replace raw MAC addresses by replacing
      
      - 'unsigned char *' with virMacAddrPtr
      - 'unsigned char ... [VIR_MAC_BUFLEN]' with virMacAddr
      
      and introduce usage of above functions where necessary.
      387117ad
  17. 21 5月, 2012 1 次提交
    • S
      nwfilter: Add support for ipset · a3f3ab4c
      Stefan Berger 提交于
      This patch adds support for the recent ipset iptables extension
      to libvirt's nwfilter subsystem. Ipset allows to maintain 'sets'
      of IP addresses, ports and other packet parameters and allows for
      faster lookup (in the order of O(1) vs. O(n)) and rule evaluation
      to achieve higher throughput than what can be achieved with
      individual iptables rules.
      
      On the command line iptables supports ipset using
      
      iptables ... -m set --match-set <ipset name> <flags> -j ...
      
      where 'ipset name' is the name of a previously created ipset and
      flags is a comma-separated list of up to 6 flags. Flags use 'src' and 'dst'
      for selecting IP addresses, ports etc. from the source or
      destination part of a packet. So a concrete example may look like this:
      
      iptables -A INPUT -m set --match-set test src,src -j ACCEPT
      
      Since ipset management is quite complex, the idea was to leave ipset 
      management outside of libvirt but still allow users to reference an ipset.
      The user would have to make sure the ipset is available once the VM is
      started so that the iptables rule(s) referencing the ipset can be created.
      
      Using XML to describe an ipset in an nwfilter rule would then look as
      follows:
      
        <rule action='accept' direction='in'>
          <all ipset='test' ipsetflags='src,src'/>
        </rule>
      
      The two parameters on the command line are also the two distinct XML attributes
      'ipset' and 'ipsetflags'.
      
      FYI: Here is the man page for ipset:
      
      https://ipset.netfilter.org/ipset.man.html
      
      Regards,
          Stefan
      a3f3ab4c
  18. 19 4月, 2012 1 次提交
    • S
      nwfilter: Fix support for trusted DHCP servers · 7c26343b
      Stefan Berger 提交于
      Fix the support for trusted DHCP server in the ebtables code's
      hard-coded function applying DHCP only filtering rules:
      Rather than using a char * use the more flexible
      virNWFilterVarValuePtr that contains the trusted DHCP server(s)
      IP address. Process all entries.
      
      Since all callers so far provided NULL as parameter, no changes
      are necessary in any other code.
      7c26343b
  19. 27 1月, 2012 1 次提交
    • S
      nwfilter: Force instantiation of filters upon driver reload · 8fa78dd4
      Stefan Berger 提交于
      Introduce a function that rebuilds all running VMs' filters. Call
      this function when reloading the nwfilter driver.
      
      This addresses a problem introduced by the 2nd patch that typically
      causes no filters to be reinstantiate anymore upon driver reload
      since their XML has not changed. Yet the current behavior is that
      upon a SIGHUP all filters get reinstantiated.
      8fa78dd4
  20. 26 1月, 2012 1 次提交
  21. 11 1月, 2012 1 次提交
    • S
      Introduce possibility to have an iterator per variable · 80e9a5cd
      Stefan Berger 提交于
      This patch introduces the capability to use a different iterator per
      variable.
      
      The currently supported notation of variables in a filtering rule like
      
        <rule action='accept' direction='out'>
           <tcp  srcipaddr='$A' srcportstart='$B'/>
        </rule>
      
      processes the two lists 'A' and 'B' in parallel. This means that A and B
      must have the same number of 'N' elements and that 'N' rules will be 
      instantiated (assuming all tuples from A and B are unique).
      
      In this patch we now introduce the assignment of variables to different
      iterators. Therefore a rule like
      
        <rule action='accept' direction='out'>
           <tcp  srcipaddr='$A[@1]' srcportstart='$B[@2]'/>
        </rule>
      
      will now create every combination of elements in A with elements in B since
      A has been assigned to an iterator with Id '1' and B has been assigned to an
      iterator with Id '2', thus processing their value independently.
      
      The first rule has an equivalent notation of
      
        <rule action='accept' direction='out'>
           <tcp  srcipaddr='$A[@0]' srcportstart='$B[@0]'/>
        </rule>
      80e9a5cd
  22. 24 11月, 2011 1 次提交
  23. 23 11月, 2011 3 次提交
  24. 19 11月, 2011 5 次提交
    • S
      Add support for VLAN filtering · 8047c4bf
      Stefan Berger 提交于
      This patch adds support for filtering of VLAN (802.1Q) traffic to the
      parser and makes us of the ebtables support for VLAN filtering. This code
      now enables the filtering of traffic in chains with prefix 'vlan'.
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      8047c4bf
    • S
      Extend rule priorities into negative numbers · f6e80a71
      Stefan Berger 提交于
      So far rules' priorities have only been valid in the range [0,1000].
      Now I am extending their priority into the range [-1000, 1000] for subsequently
      being able to sort rules and the access of (jumps into) chains following
      priorities.
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      f6e80a71
    • S
      Enable chains with names having a known prefix · ea7c73a7
      Stefan Berger 提交于
      This patch enables chains that have a known prefix in their name.
      Known prefixes are: 'ipv4', 'ipv6', 'arp', 'rarp'. All prefixes
      are also protocols that can be evaluated on the ebtables level.
      
      Following the prefix they will be automatically connected to an interface's
      'root' chain and jumped into following the protocol they evaluate, i.e.,
      a table 'arp-xyz' will be accessed from the root table using
      
      ebtables -t nat -A <iface root table> -p arp -j I-<ifname>-arp-xyz
      
      thus generating a 'root' chain like this one here:
      
      Bridge chain: libvirt-O-vnet0, entries: 5, policy: ACCEPT
      -p IPv4 -j O-vnet0-ipv4
      -p ARP -j O-vnet0-arp
      -p 0x8035 -j O-vnet0-rarp
      -p ARP -j O-vnet0-arp-xyz
      -j DROP 
      
      where the chain 'arp-xyz' is accessed for filtering of ARP packets.
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      ea7c73a7
    • S
      Use the actual names of chains in data structure · 19028ad6
      Stefan Berger 提交于
      Use the name of the chain rather than its type index (enum).
      This pushes the later enablement of chains with user-given names
      into the XML parser. For now we still only allow those names that
      are well known ('root', 'arp', 'rarp', 'ipv4' and 'ipv6').
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      19028ad6
    • S
      Introduce an internal priority for chains · 4df34ec3
      Stefan Berger 提交于
      For better handling of the sorting of chains introduce an internally used
      priority. Use a lookup table to store the priorities. For now their actual
      values do not matter just that the values cause the chains to be properly
      sorted through changes in the following patches. However, the values are
      chosen as negative so that once they are sorted along with filtering rules
      (whose priority may only be positive for now) they will always be instantiated
      before them (lower values cause instantiation before higher values). This
      is done to maintain backwards compatibility.
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      4df34ec3
  25. 15 11月, 2011 1 次提交
    • D
      Split src/util/network.{c,h} into 5 pieces · d3406045
      Daniel P. Berrange 提交于
      The src/util/network.c file is a dumping ground for many different
      APIs. Split it up into 5 pieces, along functional lines
      
       - src/util/virnetdevbandwidth.c: virNetDevBandwidth type & helper APIs
       - src/util/virnetdevvportprofile.c: virNetDevVPortProfile type & helper APIs
       - src/util/virsocketaddr.c: virSocketAddr and APIs
       - src/conf/netdev_bandwidth_conf.c: XML parsing / formatting
         for virNetDevBandwidth
       - src/conf/netdev_vport_profile_conf.c: XML parsing / formatting
         for virNetDevVPortProfile
      
      * src/util/network.c, src/util/network.h: Split into 5 pieces
      * src/conf/netdev_bandwidth_conf.c, src/conf/netdev_bandwidth_conf.h,
        src/conf/netdev_vport_profile_conf.c, src/conf/netdev_vport_profile_conf.h,
        src/util/virnetdevbandwidth.c, src/util/virnetdevbandwidth.h,
        src/util/virnetdevvportprofile.c, src/util/virnetdevvportprofile.h,
        src/util/virsocketaddr.c, src/util/virsocketaddr.h: New pieces
      * daemon/libvirtd.h, daemon/remote.c, src/conf/domain_conf.c,
        src/conf/domain_conf.h, src/conf/network_conf.c,
        src/conf/network_conf.h, src/conf/nwfilter_conf.h,
        src/esx/esx_util.h, src/network/bridge_driver.c,
        src/qemu/qemu_conf.c, src/rpc/virnetsocket.c,
        src/rpc/virnetsocket.h, src/util/dnsmasq.h, src/util/interface.h,
        src/util/iptables.h, src/util/macvtap.c, src/util/macvtap.h,
        src/util/virnetdev.h, src/util/virnetdevtap.c,
        tools/virsh.c: Update include files
      d3406045
  26. 21 10月, 2011 1 次提交
  27. 24 5月, 2011 1 次提交
  28. 17 4月, 2011 1 次提交