1. 02 5月, 2016 1 次提交
    • C
      nwfilter: Fix potential locking problems on ObjLoad failure · ab05abdb
      Cole Robinson 提交于
      In virNWFilterObjLoad we can still fail after virNWFilterObjAssignDef,
      but we don't unlock and free the created virNWFilterObjPtr in the
      cleanup path.
      
      The bit we are trying to do after AssignDef is just STRDUP in the
      configFile path. However caching the configFile in the NWFilterObj
      is largely redundant and doesn't follow the same pattern we use
      for domain and network objects.
      
      So just remove all the configFile caching which fixes the latent
      bug as a side effect.
      ab05abdb
  2. 21 10月, 2015 1 次提交
  3. 15 10月, 2015 1 次提交
  4. 08 1月, 2015 1 次提交
    • S
      nwfilter: Add support for icmpv6 filtering · 3a3b3691
      Stefan Berger 提交于
      Make use of the ebtables functionality to be able to filter certain
      parameters of icmpv6 packets. Extend the XML parser for icmpv6 types,
      type ranges, codes, and code ranges. Extend the nwfilter documentation,
      schema, and test cases.
      
      Being able to filter icmpv6 types and codes helps extending the DHCP
      snooper for IPv6 and filtering at least some parameters of IPv6's NDP
      (Neighbor Discovery Protocol) packets. However, the filtering will not
      be as good as the filtering of ARP packets since we cannot
      check on IP addresses in the payload of the NDP packets.
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      3a3b3691
  5. 02 12月, 2014 1 次提交
  6. 15 11月, 2014 1 次提交
  7. 29 10月, 2014 1 次提交
    • E
      maint: avoid static zero init in helpers · ff99c791
      Eric Blake 提交于
      C guarantees that static variables are zero-initialized.  Some older
      compilers (and also gcc -fno-zero-initialized-in-bss) create larger
      binaries if you explicitly zero-initialize a static variable.
      
      * src/conf/nwfilter_conf.c: Fix initialization.
      * src/cpu/cpu_x86.c: Likewise.
      * src/interface/interface_backend_netcf.c: Likewise.
      * src/locking/lock_daemon.c: Likewise.
      * src/locking/lock_driver_lockd.c: Likewise.
      * src/locking/lock_driver_sanlock.c: Likewise.
      * src/network/bridge_driver.c: Likewise.
      * src/node_device/node_device_udev.c: Likewise.
      * src/nwfilter/nwfilter_learnipaddr.c: Likewise.
      * src/rpc/virnetserver.c: Likewise.
      * src/security/security_selinux.c
      (virSecuritySELinuxGenSecurityLabel): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ff99c791
  8. 04 9月, 2014 1 次提交
    • E
      maint: use consistent if-else braces in conf and friends · ff78ff7c
      Eric Blake 提交于
      I'm about to add a syntax check that enforces our documented
      HACKING style of always using matching {} on if-else statements.
      
      This patch focuses on code shared between multiple drivers.
      
      * src/conf/domain_conf.c (virDomainFSDefParseXML)
      (virSysinfoParseXML, virDomainNetDefParseXML)
      (virDomainWatchdogDefParseXML)
      (virDomainRedirFilterUSBDevDefParseXML): Correct use of {}.
      * src/conf/interface_conf.c (virInterfaceDefParseDhcp)
      (virInterfaceDefParseIp, virInterfaceVlanDefFormat)
      (virInterfaceDefParseStartMode, virInterfaceDefParseBondMode)
      (virInterfaceDefParseBondMiiCarrier)
      (virInterfaceDefParseBondArpValid): Likewise.
      * src/conf/node_device_conf.c (virNodeDevCapStorageParseXML):
      Likewise.
      * src/conf/nwfilter_conf.c (virNWFilterRuleDetailsParse)
      (virNWFilterRuleParse, virNWFilterDefParseXML): Likewise.
      * src/conf/secret_conf.c (secretXMLParseNode): Likewise.
      * src/cpu/cpu_x86.c (x86Baseline, x86FeatureLoad, x86ModelLoad):
      Likewise.
      * src/network/bridge_driver.c (networkKillDaemon)
      (networkDnsmasqConfContents): Likewise.
      * src/node_device/node_device_hal.c (dev_refresh): Likewise.
      * src/nwfilter/nwfilter_gentech_driver.c (virNWFilterInstantiate):
      Likewise.
      * src/nwfilter/nwfilter_ebiptables_driver.c
      (_iptablesCreateRuleInstance): Likewise.
      * src/storage/storage_backend_disk.c
      (virStorageBackendDiskBuildPool): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ff78ff7c
  9. 07 7月, 2014 1 次提交
  10. 03 7月, 2014 1 次提交
    • J
      Use virBufferCheckError everywhere we report OOM error · 92a8e72f
      Ján Tomko 提交于
      Replace:
      if (virBufferError(&buf)) {
          virBufferFreeAndReset(&buf);
          virReportOOMError();
          ...
      }
      
      with:
      if (virBufferCheckError(&buf) < 0)
          ...
      
      This should not be a functional change (unless some callers
      misused the virBuffer APIs - a different error would be reported
      then)
      92a8e72f
  11. 14 5月, 2014 1 次提交
  12. 02 5月, 2014 1 次提交
    • J
      fix build with older gcc · 1055852a
      Ján Tomko 提交于
      Older gcc (4.1.2-55.el5, 4.2.1 on FreeBSD) reports bogus warnings:
      ../../src/conf/nwfilter_conf.c:2111: warning: 'protocol' may be used
      uninitialized in this function
      ../../src/conf/nwfilter_conf.c:2110: warning: 'dataProtocolID' may be
      used uninitialized in this function
      
      Initialize them to NULL to make the compiler happy.
      1055852a
  13. 30 4月, 2014 1 次提交
    • S
      nwfilter: Validate rule after parsing · a457fc65
      Stefan Berger 提交于
      An IP or IPv6 rule with port specification but without protocol
      specification cannot be instantiated by ebtables. The documentation
      points to 'protocol' being required but implementation does not
      enforce it to be given.
      
      Implement a rule validation function that checks whether the rule is
      valid when it is defined. This for example prevents the definition
      of rules like:
      
      <ip dstportstart='53'>
      
      where a protocol attribute would be required for it to be valid and for
      ebtables to be able to instantiate it. A valid rule then is:
      
      <ip protocol='udp' dstportstart='53'>
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      a457fc65
  14. 29 4月, 2014 1 次提交
    • E
      conf: use virDirRead API · 6b9f40e8
      Eric Blake 提交于
      When reading configuration files, we were silently ignoring
      directory read failures.  While unlikely, we might as well
      report them.
      
      * src/conf/domain_conf.c (virDomainObjListLoadAllConfigs): Report
      readdir errors.
      * src/conf/network_conf.c (virNetworkLoadAllState)
      (virNetworkLoadAllConfigs): Likewise.
      * src/conf/nwfilter_conf.c (virNWFilterLoadAllConfigs): Likewise.
      * src/conf/storage_conf.c (virStoragePoolLoadAllConfigs):
      Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      6b9f40e8
  15. 25 4月, 2014 2 次提交
  16. 25 3月, 2014 1 次提交
  17. 21 3月, 2014 1 次提交
  18. 14 3月, 2014 2 次提交
    • L
      conf: eliminate hardcoded indentation in nwfilter xml · d3679928
      Laine Stump 提交于
      This file was using multiple virBuffers, inserting the contents of
      buf3 into buf2, then inserting the contents of buf2 into buf1, rather
      than the more conventional method of just passing around a single
      virBufferPtr and streaming everything into that single buffer. This
      was unnecessary, and also made it more difficult to make indentation
      relative, because when you insert a string into a buffer, the
      indentation of the buffer is only applied once at the beginning of the
      string, *not* each time a newline is encountered in the string.
      d3679928
    • S
      nwfilter: Add ARP src/dst IP mask for ebtables ARP · a81756f1
      Stefan Berger 提交于
      Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=862887
      
      Add a netmask for the source and destination IP address for the
      ebtables --arp-ip-src and --arp-ip-dst options. Extend the XML
      parser with support for XML attributes for these netmasks similar
      to already supported netmasks. Extend the documentation.
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      a81756f1
  19. 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
  20. 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
  21. 20 1月, 2014 1 次提交
  22. 16 1月, 2014 1 次提交
  23. 02 12月, 2013 1 次提交
    • N
      Fix memory leak in virNWFilterDefParseXML() · 6c874c01
      Nehal J Wani 提交于
      While running nwfilterxml2xmltest, it was found that valgrind pointed out the
      following error...
      
      ==7466== 16 bytes in 1 blocks are definitely lost in loss record 26 of 90
      ==7466==    at 0x4A06B6F: calloc (vg_replace_malloc.c:593)
          ==7466==    by 0x4C651AD: virAlloc (viralloc.c:142)
          ==7466==    by 0x4D0450D: virNWFilterDefParseNode (nwfilter_conf.c:2575)
          ==7466==    by 0x4D05D84: virNWFilterDefParse (nwfilter_conf.c:2647)
          ==7466==    by 0x401FDE: testCompareXMLToXMLHelper (nwfilterxml2xmltest.c:39)
          ==7466==    by 0x402DE1: virtTestRun (testutils.c:138)
          ==7466==    by 0x4018E9: mymain (nwfilterxml2xmltest.c:111)
          ==7466==    by 0x403482: virtTestMain (testutils.c:593)
          ==7466==    by 0x341F421A04: (below main) (libc-start.c:225)
      
      ...21 times, which are related to 21 tests in nwfilterxml2xmltest.c which sent
      EXPECT_WARN = false. There were two scenarios in virNWFilterDefParseXML(),
      when the variable 'entry' was malloc'ed, but not freed.
      6c874c01
  24. 21 11月, 2013 1 次提交
    • E
      maint: fix comma style issues: nwfilter · f5690336
      Eric Blake 提交于
      Most of our code base uses space after comma but not before;
      fix the remaining uses before adding a syntax check.
      
      * src/nwfilter/nwfilter_ebiptables_driver.c: Consistently use
      commas.
      * src/nwfilter/nwfilter_gentech_driver.c: Likewise.
      * src/nwfilter/nwfilter_learnipaddr.c: Likewise.
      * src/conf/nwfilter_conf.c: Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      f5690336
  25. 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
  26. 07 10月, 2013 3 次提交
  27. 26 9月, 2013 1 次提交
  28. 05 9月, 2013 1 次提交
  29. 11 7月, 2013 1 次提交
  30. 10 7月, 2013 1 次提交
  31. 06 6月, 2013 1 次提交
  32. 23 5月, 2013 1 次提交
  33. 21 5月, 2013 1 次提交
  34. 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
  35. 08 4月, 2013 1 次提交
    • D
      Disable cast-align warnings in various places · e57aaa6f
      Daniel P. Berrange 提交于
      There are a number of places which generate cast alignment
      warnings, which are difficult or impossible to address. Use
      pragmas to disable the warnings in these few places
      
      conf/nwfilter_conf.c: In function 'virNWFilterRuleDetailsParse':
      conf/nwfilter_conf.c:1806:16: warning: cast increases required alignment of target type [-Wcast-align]
               item = (nwItemDesc *)((char *)nwf + att[idx].dataIdx);
      conf/nwfilter_conf.c: In function 'virNWFilterRuleDefDetailsFormat':
      conf/nwfilter_conf.c:3238:16: warning: cast increases required alignment of target type [-Wcast-align]
               item = (nwItemDesc *)((char *)def + att[i].dataIdx);
      
      storage/storage_backend_mpath.c: In function 'virStorageBackendCreateVols':
      storage/storage_backend_mpath.c:247:17: warning: cast increases required alignment of target type [-Wcast-align]
               names = (struct dm_names *)(((char *)names) + next);
      
      nwfilter/nwfilter_dhcpsnoop.c: In function 'virNWFilterSnoopDHCPDecode':
      nwfilter/nwfilter_dhcpsnoop.c:994:15: warning: cast increases required alignment of target type [-Wcast-align]
               pip = (struct iphdr *) pep->eh_data;
      nwfilter/nwfilter_dhcpsnoop.c:1004:11: warning: cast increases required alignment of target type [-Wcast-align]
           pup = (struct udphdr *) ((char *) pip + (pip->ihl << 2));
      
      nwfilter/nwfilter_learnipaddr.c: In function 'procDHCPOpts':
      nwfilter/nwfilter_learnipaddr.c:327:33: warning: cast increases required alignment of target type [-Wcast-align]
                       uint32_t *tmp = (uint32_t *)&dhcpopt->value;
      nwfilter/nwfilter_learnipaddr.c: In function 'learnIPAddressThread':
      nwfilter/nwfilter_learnipaddr.c:501:43: warning: cast increases required alignment of target type [-Wcast-align]
                           struct iphdr *iphdr = (struct iphdr*)(packet +
      nwfilter/nwfilter_learnipaddr.c:538:43: warning: cast increases required alignment of target type [-Wcast-align]
                           struct iphdr *iphdr = (struct iphdr*)(packet +
      nwfilter/nwfilter_learnipaddr.c:544:48: warning: cast increases required alignment of target type [-Wcast-align]
                               struct udphdr *udphdr= (struct udphdr *)
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      e57aaa6f
  36. 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