1. 27 3月, 2017 2 次提交
    • L
      util: remove unused functions from virnetdev.c · bc4168f3
      Laine Stump 提交于
      The global functions virNetDevReplaceMacAddress(),
      virNetDevReplaceNetConfig(), virNetDevRestoreMacAddress(), and
      virNetDevRestoreNetConfig() are no longer used, as their functionality
      has been replaced by virNetDev(Save|Read|Set)NetConfig().
      
      The static functions virNetDevReplaceVfConfig() and
      virNetDevRestoreVfConfig() were only used by the above-named global
      functions that were removed.
      bc4168f3
    • L
      util: new functions virNetDev(Save|Read|Set)NetConfig() · 26694daf
      Laine Stump 提交于
      These three functions are destined to replace
      virNetDev(Replace|Restore)NetConfig() and
      virNetDev(Replace|Restore)MacAddress(), which both do the save and set
      together as a single step. We need to separate the save, read, and set
      steps because there will be situations where we need to do something
      else in between (in particular, we will need to rebind a VF's driver
      after save but before set).
      
      This patch creates the new functions, but doesn't call them - that
      will come in a subsequent patch. Note that the new functions to
      read/write the file that stores the original network config now uses
      JSON rather than plaintext (it still recognizes the old format as well
      though, so it won't get confused during an upgrade).
      26694daf
  2. 24 3月, 2017 1 次提交
    • L
      util: new function virNetDevPFGetVF() · 554253ad
      Laine Stump 提交于
      Given an SRIOV PF netdev name (e.g. "enp2s0f0") and VF#, this new
      function returns the netdev name of the referenced VF device
      (e.g. "enp2s11f6"), or NULL if the device isn't bound to a net driver.
      554253ad
  3. 23 3月, 2017 2 次提交
    • J
      util: Remove NONNULL(1) for virNetDevGetName · 91d28d99
      John Ferlan 提交于
      The 'ifindex' argument is not a pointer, so no need for NONNULL in prototype
      91d28d99
    • L
      util: new function virNetDevGetMaster() · e75f5bfb
      Laine Stump 提交于
      This function provides the bridge/bond device that the given network
      device is attached to. The return value is 0 or -1, and the master
      device is a char** argument to the function - this is needed in order
      to allow for a "success" return from a device that has no master.
      e75f5bfb
  4. 22 3月, 2017 1 次提交
  5. 07 3月, 2017 1 次提交
    • L
      make all struct typedefs comply with proposed coding conventions · 38985269
      Laine Stump 提交于
      Proposed formal coding conventions encourage defining typedefs for
      vir[Blah] and vir[Blah]Ptr separately from the associated struct named
      _vir[Blah]:
      
          typedef struct _virBlah virBlah;
          typedef virBlah *virBlahPtr;
          struct _virBlah {
          ...
          };
      
      At some point in the past, I had submitted several patches using a
      more compact style that I prefer, and they were accepted:
      
          typedef struct _virBlah {
              ...
          } virBlah, *virBlahPtr;
      
      Since these are by far a minority among all struct definitions, this
      patch changes all those definitions to reflect the style prefered by
      the proposal so that there is 100% consistency.
      38985269
  6. 27 6月, 2016 3 次提交
    • A
      Clean up after virNetDevIP creation · 7970436e
      Andrea Bolognani 提交于
      Commit cf0568b0 moved a bunch of functions from virNetDev
      to the more specific virNetDevIP; however, not all of the
      existing uses were moved properly, causing build failures on
      FreeBSD.
      
      Complete the transition to the new names and drop the
      obsolete declarations from the header file while at it.
      7970436e
    • 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
  7. 11 5月, 2016 1 次提交
    • L
      util: set vlan tag for macvtap passthrough mode on SRIOV VFs · 75db9997
      Laine Stump 提交于
      SRIOV VFs used in macvtap passthrough mode can take advantage of the
      SRIOV card's transparent vlan tagging. All the code was there to set
      the vlan tag, and it has been used for SRIOV VFs used for hostdev
      interfaces for several years, but for some reason, the vlan tag for
      macvtap passthrough devices was stubbed out with a -1.
      
      This patch moves a bit of common validation down to a lower level
      (virNetDevReplaceNetConfig()) so it is shared by hostdev and macvtap
      modes, and updates the macvtap caller to actually send the vlan config
      instead of -1.
      75db9997
  8. 13 4月, 2016 1 次提交
  9. 08 4月, 2016 1 次提交
  10. 25 11月, 2015 1 次提交
    • L
      nodedev: report maxCount for virtual_functions capability · f391889f
      Laine Stump 提交于
      A PCI device may have the capability to setup virtual functions (VFs)
      but have them currently all disabled. Prior to this patch, if that was
      the case the the node device XML for the device wouldn't report any
      virtual_functions capability.
      
      With this patch, if a file called "sriov_totalvfs" is found in the
      device's sysfs directory, its contents will be interpreted as a
      decimal number, and that value will be reported as "maxCount" in a
      capability element of the device's XML, e.g.:
      
         <capability type='virtual_functions' maxCount='7'/>
      
      This will be reported regardless of whether or not any VFs are
      currently enabled for the device.
      
      NB: sriov_numvfs (the number of VFs currently active) is also
      available in sysfs, but that value is implied by the number of items
      in the list that is inside the capability element, so there is no
      reason to explicitly provide it as an attribute.
      
      sriov_totalvfs and sriov_numvfs are available in kernels at least as far
      back as the 2.6.32 that is in RHEL6.7, but in the case that they
      simply aren't there, libvirt will behave as it did prior to this patch
      - no maxCount will be displayed, and the virtual_functions capability
      will be absent from the device's XML when 0 VFs are enabled.
      f391889f
  11. 05 11月, 2015 1 次提交
  12. 29 10月, 2015 1 次提交
    • M
      network: wait for DAD to finish for bridge IPv6 addresses · 0f7436ca
      Maxim Perevedentsev 提交于
      commit db488c79 assumed that dnsmasq would complete IPv6 DAD before
      daemonizing, but in reality it doesn't wait, which creates problems
      when libvirt's bridge driver sets the matching "dummy tap device" to
      IFF_DOWN prior to DAD completing.
      
      This patch waits for DAD completion by periodically polling the kernel
      using netlink to check whether there are any IPv6 addresses assigned
      to bridge which have a 'tentative' state (if there are any in this
      state, then DAD hasn't yet finished). After DAD is finished, execution
      continues. To avoid an endless hang in case something was wrong with
      the kernel's DAD, we wait a maximum of 5 seconds.
      0f7436ca
  13. 03 9月, 2015 1 次提交
  14. 21 7月, 2015 1 次提交
    • M
      nodedev: add RDMA and tx-udp_tnl-segmentation NIC capabilities · ac3ed208
      Moshe Levi 提交于
      Adding functionality to libvirt that will allow
      it query the interface for the availability of RDMA and
      tx-udp_tnl-segmentation Offloading NIC capabilities
      
      Here is an example of the feature XML definition:
      
      <device>
      <name>net_eth4_90_e2_ba_5e_a5_45</name>
        <path>/sys/devices/pci0000:00/0000:00:03.0/0000:08:00.1/net/eth4</path>
        <parent>pci_0000_08_00_1</parent>
        <capability type='net'>
          <interface>eth4</interface>
          <address>90:e2:ba:5e:a5:45</address>
          <link speed='10000' state='up'/>
          <feature name='rx'/>
          <feature name='tx'/>
          <feature name='sg'/>
          <feature name='tso'/>
          <feature name='gso'/>
          <feature name='gro'/>
          <feature name='rxvlan'/>
          <feature name='txvlan'/>
          <feature name='rxhash'/>
          <feature name='rdma'/>
          <feature name='txudptnl'/>
          <capability type='80203'/>
        </capability>
      </device>
      ac3ed208
  15. 22 4月, 2015 1 次提交
    • L
      util: set MAC address for VF via netlink message to PF+VF# when possible · cb3fe38c
      Laine Stump 提交于
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1113474
      
      When we set the MAC address of a network device as a part of setting
      up macvtap "passthrough" mode (where the domain has an emulated netdev
      connected to a host macvtap device that has exclusive use of the
      physical device, and sets the device MAC address to match its own,
      i.e. "<interface type='direct'> <source mode='passthrough' .../>"), we
      use ioctl(SIOCSIFHWADDR) giving it the name of that device. This is
      true even if it is an SRIOV Virtual Function (VF).
      
      But, when we are setting the MAC address / vlan ID of a VF in
      preparation for "hostdev network" passthrough (this is where we set
      the MAC address and vlan id of the VF after detaching the host net
      driver and before assigning the device to the domain with PCI
      passthrough, i.e. "<interface type='hostdev'>", we do the setting via
      a netlink RTM_SETLINK message for that VF's Physical Function (PF),
      telling it the VF# we want to change. This sets an "administratively
      changed MAC" flag for that VF in the PF's driver, and from that point
      on (until the PF driver is reloaded, *not* merely the VF driver) that
      VF's MAC address can't be changed using ioctl(SIOCSIFHWADDR) - the
      only way to change it is via the PF with RTM_SETLINK.
      
      This means that if a VF is used for hostdev passthrough, it will have
      the admin flag set, and future attempts to use that VF for macvtap
      passthrough will fail.
      
      The solution to this problem is to check if the device being used for
      macvtap passthrough is actually a VF; if so, we use the netlink
      RTM_SETLINK message to the PF to set the VF's mac address instead of
      ioctl(SIOCSIFHWADDR) directly to the VF; if not, behavior does not
      change from previously.
      
      There are three pieces to making this work:
      
      1) virNetDevMacVLan(Create|Delete)WithVPortProfile() now call
         virNetDev(Replace|Restore)NetConfig() rather than
         virNetDev(Replace|Restore)MacAddress() (simply passing -1 for VF#
         and vlanid).
      
      2) virNetDev(Replace|Restore)NetConfig() check to see if the device is
         a VF. If so, they find the PF's name and VF#, allowing them to call
         virNetDev(Replace|Restore)VfConfig().
      
      3) To prevent mixups when detaching a macvtap passthrough device that
         had been attached while running an older version of libvirt,
         virNetDevRestoreVfConfig() is potentially given the preserved name
         of the VF, and if the proper statefile for a VF can't be found in
         the stateDir (${stateDir}/${pfname}_vf${vfid}),
         virNetDevRestoreMacAddress() is called instead (which will look in
         the file named ${stateDir}/${vfname}).
      
      This problem has existed in every version of libvirt that has both
      macvtap passthrough and interface type='hostdev'. Fortunately people
      seem to use one or the other though, so it hasn't caused any real
      world problem reports.
      cb3fe38c
  16. 15 4月, 2015 2 次提交
  17. 10 4月, 2015 1 次提交
  18. 05 3月, 2015 2 次提交
    • J
      Fix build on mingw · 41c5baea
      Ján Tomko 提交于
      Last commit unconditionally included a linux-specific header.
      
      Do not do that.
      41c5baea
    • J
      SRIOV NIC offload feature discovery · c9027d8f
      James Chapman 提交于
      Adding functionality to libvirt that will allow it
      query the ethtool interface for the availability
      of certain NIC HW offload features
      
      Here is an example of the feature XML definition:
      
      <device>
      <name>net_eth4_90_e2_ba_5e_a5_45</name>
        <path>/sys/devices/pci0000:00/0000:00:03.0/0000:08:00.1/net/eth4</path>
        <parent>pci_0000_08_00_1</parent>
        <capability type='net'>
          <interface>eth4</interface>
          <address>90:e2:ba:5e:a5:45</address>
          <link speed='10000' state='up'/>
          <feature name='rx'/>
          <feature name='tx'/>
          <feature name='sg'/>
          <feature name='tso'/>
          <feature name='gso'/>
          <feature name='gro'/>
          <feature name='rxvlan'/>
          <feature name='txvlan'/>
          <feature name='rxhash'/>
          <capability type='80203'/>
        </capability>
      </device>
      Signed-off-by: NJán Tomko <jtomko@redhat.com>
      c9027d8f
  19. 03 2月, 2015 2 次提交
    • P
      virnetdev: fix some issues found by coverity and mingw builds · 8bda9035
      Pavel Hrdina 提交于
      Commit e562a61a introduced new function to get/set interface state but
      there was misuse of ATTRIBUTE_NONNULL on non-pointer attributes and also
      we need to wrap that functions by #ifdef to not break mingw build.
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      8bda9035
    • L
      util: make virNetDev(Get|Set)IFFlags() static · df2cc650
      Laine Stump 提交于
      e562a61a added these two new helper functions and only used them
      within virnetdev.c, but declared them in the .h file. If some
      currently unsupported interface flags need to be accessed in the
      future, it will make more sense to write the appropriate higher level
      function rather than require us to artificially define IFF_* on some
      mythical platform that doesn't have SIOC[SG]IFFLAGS (and therefore
      doesn't have IFF_*) just so we can call virNetDevSetIFFFlags() to
      return an error.
      
      To help someone in not going down the wrong road, this patch makes the
      two helper functions static, hopefully making it less likely that
      someone will want to use them outside of virnetdev.c.
      df2cc650
  20. 30 1月, 2015 1 次提交
  21. 06 1月, 2015 3 次提交
  22. 29 10月, 2014 1 次提交
  23. 27 10月, 2014 1 次提交
    • L
      util: eliminate "use after free" in callers of virNetDevLinkDump · f9f9699f
      Laine Stump 提交于
      virNetDevLinkDump() gets a message from netlink into "resp", then
      calls nlmsg_parse() to fill the table "tb" with pointers into resp. It
      then returns tb to its caller, but not before freeing the buffer at
      resp. That means that all the callers of virNetDevLinkDump() are
      examining memory that has already been freed. This can be verified by
      filling the buffer at resp with garbage prior to freeing it (or, I
      suppose, just running libvirtd under valgrind) then performing some
      operation that calls virNetDevLinkDump().
      
      The code has been like this ever since virNetDevLinkDump() was written
      - the original author didn't notice it, and neither did later
      additional users of the function. It has only been pure luck (or maybe
      a lack of heavy load, and/or maybe an allocation algorithm in malloc()
      that delays re-use of just-freed memory) that has kept this from
      causing errors, for example when configuring a PCI passthrough or
      macvtap passthrough network interface.
      
      The solution taken in this patch is the simplest - just return resp to
      the caller along with tb, then have the caller free it after they are
      finished using the data (pointers) in tb. I alternately could have
      made a cleaner interface by creating a new struct that put tb and resp
      together along with a vir*Free() function for it, but this function is
      only used in a couple places, and I'm not sure there will be
      additional new uses of virNetDevLinkDump(), so the value of adding a
      new type, extra APIs, etc. is dubious.
      f9f9699f
  24. 07 10月, 2014 1 次提交
  25. 11 6月, 2014 1 次提交
  26. 13 3月, 2014 1 次提交
  27. 08 11月, 2013 1 次提交
  28. 15 10月, 2013 1 次提交
    • E
      maint: avoid 'const fooPtr' in virnet files · 955af4d4
      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 remaining offenders in src/util.
      
      * src/util/virnetdev.h (virNetDevSetMAC)
      (virNetDevReplaceMacAddress, virNetDevValidateConfig)
      (virNetDevReplaceNetConfig): Use intended type.
      * src/util/virnetdevbandwidth.h (virNetDevBandwidthCopy)
      (virNetDevBandwidthPlug): Likewise.
      * src/util/virnetdevmacvlan.h (virNetDevMacVLanCreate)
      (virNetDevMacVLanCreateWithVPortProfile)
      (virNetDevMacVLanDeleteWithVPortProfile)
      (virNetDevMacVLanRestartWithVPortProfile)
      (virNetDevMacVLanVPortProfileRegisterCallback): Likewise.
      * src/util/virnetdevopenvswitch.h (virNetDevOpenvswitchAddPort):
      Likewise.
      * src/util/virnetdevtap.h (virNetDevTapCreateInBridgePort):
      Likewise.
      * src/util/virnetdevvlan.h (virNetDevVlanEqual)
      (virNetDevVlanCopy): Likewise.
      * src/util/virnetdevvportprofile.h
      (virNetDevVPortProfileAssociate)
      (virNetDevVPortProfileDisassociate): Likewise.
      * src/util/virnetlink.h (virNetlinkEventRemoveCallback)
      (virNetlinkEventAddClient, virNetlinkEventRemoveClient):
      Likewise.
      * src/util/virnetdev.c (virNetDevSetMAC)
      (virNetDevReplaceMacAddress, virNetDevValidateConfig)
      (virNetDevReplaceNetConfig): Fix fallout.
      * src/util/virnetdevbandwidth.c (virNetDevBandwidthCopy)
      (virNetDevBandwidthPlug): Likewise.
      * src/util/virnetdevmacvlan.c (virNetDevMacVLanCreate)
      (virNetDevMacVLanCreateWithVPortProfile)
      (virNetDevMacVLanDeleteWithVPortProfile)
      (virNetDevMacVLanRestartWithVPortProfile)
      (virNetDevMacVLanVPortProfileRegisterCallback): Likewise.
      * src/util/virnetdevopenvswitch.c (virNetDevOpenvswitchAddPort):
      Likewise.
      * src/util/virnetdevtap.c (virNetDevTapCreateInBridgePort):
      Likewise.
      * src/util/virnetdevvlan.c (virNetDevVlanEqual)
      (virNetDevVlanCopy): Likewise.
      * src/util/virnetdevvportprofile.c
      (virNetDevVPortProfileAssociate)
      (virNetDevVPortProfileDisassociate)
      (virNetDevVPortProfileOpSetLink, virNetDevVPortProfileOpCommon)
      (virNetDevVPortProfileOp8021Qbg, virNetDevVPortProfileOp8021Qbh):
      Likewise.
      * src/util/virnetlink.c (virNetlinkEventRemoveCallback)
      (virNetlinkEventAddClient, virNetlinkEventRemoveClient):
      Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      955af4d4
  29. 22 6月, 2013 1 次提交
  30. 14 6月, 2013 1 次提交
  31. 15 5月, 2013 1 次提交