1. 08 11月, 2019 1 次提交
    • L
      util: set bridge device MAC address explicitly during virNetDevBridgeCreate · 13ec8270
      Laine Stump 提交于
      When libvirt first implemented a stable and configurable MAC address
      for the bridges created for libvirt virtual networks (commit
      5754dbd5, in libvirt v0.8.8) most distro stable releases didn't
      support explicitly setting the MAC address of a bridge; the bridge
      just always assumed the lowest numbered MAC of all attached
      interfaces. Because of this, we stabilized the bridge MAC address by
      creating a "dummy" tap interface with a MAC address guaranteed to be
      lower than any of the guest tap devices' MACs (which all started with
      0xFE, so it's not difficult to do) and attached it to the bridge -
      this was the inception of the "virbr0-nic" device that has confused so
      many people over the years.
      
      Even though the linux kernel had recently gained support for
      explicitly setting a bridge MAC, we deemed it unnecessary to set the
      MAC that way, because the other (indirect) method worked everywhere.
      
      But recently there have been reports that the bridge MAC address was
      not following the setting in the network config, and mismatched the
      MAC of the dummy tap device (which was still correct). It turns out
      that this is due to a change in systemd-242 that persists whatever MAC
      address is set for a bridge when it's initially started. According to
      the systemd NEWS file entry for version 242
      (https://github.com/systemd/systemd/blob/master/NEWS):
      
        "if a bridge interface is created without any slaves, and gains
         a slave later, then now the bridge does not inherit slave's MAC."
      
      This change was the result of:
      
        https://github.com/systemd/systemd/issues/3374
      
      (apparently if there is no MAC saved for a bridge by the name of a
      bridge being created, the random MAC generated during creation is
      saved, and then that same MAC is used to explicitly set the MAC each
      time it is created). Once a bridge has an explicitly set MAC, the "use
      the lowest numbered MAC of attached devices" rule is ignored, so our
      dummy tap device is like the goggles - it does nothing! (well, almost).
      
      We could whine about changes in default behavior, etc. etc., but
      because the change was in response to actual user problems, that seems
      likely a fruitless task. Fortunately, time has marched on, and even
      distro releases that are old enough that they are no longer supported
      by upstream libvirt (e.g. RHEL6) have support for explicitly setting a
      bridge device MAC address, either during creation or with a separate
      ioctl after creation, so we can now do that.
      
      To enable explicitly setting the mac during bridge creation, we add a
      mac arg to virNetDevBridgeCreate().  In the case of platforms where
      the bridge is created with a netlink RTM_NEWLINK message, we just add
      that mac to the message. For platforms that still use an ioctl (either
      SIOCBRADDBR or SIOCIFCREATE2), we make a separate call to
      virNetDevSetMAC() after creating the bridge.
      
      (NB: I was unable to test the calling of virNetDevSetMAC() from the
      SIOCIFCREATE2 (BSD) version of virNetDevBridgeCreate(); even though I
      managed to get a FreeBSD system setup and libvirt built there, when I
      tried to start the default network the SIOCIFCREATE2 ioctl itself
      failed, so it never even got to the virNetDevSetMAC(). That leaves the
      FreeBSD implementation untested.)
      
      This makes the dummy tap pointless for purposes of setting the MAC
      address, but it is still useful for IPv6 DAD initialization (which
      apparently requires at least one interface to be attached to the
      bridge and online), as well as for setting an initial MTU for the
      bridge, so it hasn't been removed.
      
      (NB: we can safely *always* call virNetDevBridgeCreate() with
      &def->mac from the network driver because, in spite of the existence
      of a "mac_specified" bool in the config suggesting that it may not
      always be present, in reality a mac address will always be added to
      any network that doesn't have one - this is guaranteed in all cases by
      commit a47ae7c0)
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1760851Signed-off-by: NLaine Stump <laine@redhat.com>
      Reviewed-by: NJiri Denemark <jdenemar@redhat.com>
      13ec8270
  2. 16 10月, 2019 2 次提交
  3. 15 10月, 2019 1 次提交
  4. 30 4月, 2019 1 次提交
  5. 09 4月, 2019 1 次提交
  6. 14 12月, 2018 1 次提交
    • D
      Remove all Author(s): lines from source file headers · 60046283
      Daniel P. Berrangé 提交于
      In many files there are header comments that contain an Author:
      statement, supposedly reflecting who originally wrote the code.
      In a large collaborative project like libvirt, any non-trivial
      file will have been modified by a large number of different
      contributors. IOW, the Author: comments are quickly out of date,
      omitting people who have made significant contribitions.
      
      In some places Author: lines have been added despite the person
      merely being responsible for creating the file by moving existing
      code out of another file. IOW, the Author: lines give an incorrect
      record of authorship.
      
      With this all in mind, the comments are useless as a means to identify
      who to talk to about code in a particular file. Contributors will always
      be better off using 'git log' and 'git blame' if they need to  find the
      author of a particular bit of code.
      
      This commit thus deletes all Author: comments from the source and adds
      a rule to prevent them reappearing.
      
      The Copyright headers are similarly misleading and inaccurate, however,
      we cannot delete these as they have legal meaning, despite being largely
      inaccurate. In addition only the copyright holder is permitted to change
      their respective copyright statement.
      Reviewed-by: NErik Skultety <eskultet@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      60046283
  7. 26 11月, 2018 1 次提交
  8. 24 9月, 2018 1 次提交
  9. 12 9月, 2018 2 次提交
  10. 14 8月, 2018 2 次提交
  11. 23 7月, 2018 1 次提交
    • A
      src: Make virStr*cpy*() functions return an int · 6c0d0210
      Andrea Bolognani 提交于
      Currently, the functions return a pointer to the
      destination buffer on success or NULL on failure.
      
      Not only does this kind of error handling look quite
      alien in the context of libvirt, where most functions
      return zero on success and a negative int on failure,
      but it's also somewhat pointless because unless there's
      been a failure the returned pointer will be the same
      one passed in by the user, thus offering no additional
      value.
      
      Change the functions so that they return an int
      instead.
      Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
      6c0d0210
  12. 28 6月, 2017 1 次提交
  13. 13 6月, 2017 1 次提交
  14. 02 6月, 2016 1 次提交
  15. 29 8月, 2015 2 次提交
    • L
      util: fallback to ioctl(SIOCBRDELBR) if netlink RTM_DELLINK fails · 97d26e47
      Laine Stump 提交于
      commit 09778e09 switched from using ioctl(SIOCBRDELBR) for bridge
      device deletion to using a netlink RTM_DELLINK message, which is the
      more modern way to delete a bridge (and also doesn't require the
      bridge to be ~IFF_UP to succeed). However, although older kernels
      (e.g. 2.6.32, in RHEL6/CentOS6) support deleting *some* link types
      with RTM_NEWLINK, they don't support deleting bridges, and there is no
      compile-time way to figure this out.
      
      This patch moves the body of the SIOCBRDELBR version of
      virNetDevBridgeDelete() into a static function, calls the new function
      from the original, and also calls the new function from the
      RTM_DELLINK version if the RTM_DELLINK message generates an EOPNOTSUPP
      error. Since RTM_DELLINK is done from the subordinate function
      virNetlinkDelLink, which is also called for other purposes (deleting a
      macvtap interface), a function pointer called "fallback" has been
      added to the arglist of virNetlinkDelLink() - if that arg != NULL, the
      provided function will be called when (and only when) RTM_DELLINK
      fails with EOPNOTSUPP.
      
      Resolves:  https://bugzilla.redhat.com/show_bug.cgi?id=1252780 (part 2)
      97d26e47
    • L
      util: fallback to ioctl(SIOCBRADDBR) if netlink RTM_NEWLINK fails · 66dcb409
      Laine Stump 提交于
      commit fc7b23db switched from using ioctl(SIOCBRADDBR) for bridge
      creation to using a netlink RTM_NEWLINK message with IFLA_INFO_KIND =
      "bridge", which is the more modern way to create a bridge. However,
      although older kernels (e.g. 2.6.32, in RHEL6/CentOS6) support
      creating *some* link types with RTM_NEWLINK, they don't support
      creating bridges, and there is no compile-time way to figure this out
      (since the "type" isn't an enum, but rather a character string).
      
      This patch moves the body of the SIOCBRADDBR version of
      virNetDevBridgeCreate() into a static function, calls the new function
      from the original, and also calls the new function from the
      RTM_NEWLINK version if the RTM_NEWLINK message generates an EOPNOTSUPP
      error.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1252780
      66dcb409
  16. 15 4月, 2015 1 次提交
    • M
      Cleanup "/sys/class/net" usage · 96a21e97
      Michal Privoznik 提交于
      Throughout the code, we have several places need to construct a path
      somewhere in /sys/class/net/... They are not consistent and nearly
      each code piece invents its own way how to do it. So unify this by:
      
      1) use virNetDevSysfsFile() wherever possible
      
      2) At least use common macro SYSFS_NET_DIR declared in virnetdev.h at
         the rest of places which can't go with 1)
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      96a21e97
  17. 27 3月, 2015 2 次提交
    • L
      util: use netlink to create bridge devices · fc7b23db
      Laine Stump 提交于
      Just as it is possible to delete a bridge device with the netlink
      RTM_DELLINK message, one can be created with the RTM_NEWLINK
      message. Because of differences in the format of the message, it's not
      as straightforward as with virNetlinkDelLink() to create a single
      utility function that can be used to create any type of interface, so
      the new netlink version of virNetDevBridgeCreate() does its own
      construction of the netlink message and calls virNetlinkCommand()
      itself.
      
      This doesn't provide any extra functionality, just provides symmetry
      with the previous commit.
      
      NB: We *could* alter the API of virNetDevBridgeCreate() to take a MAC
      address, and directly program that mac address into the bridge (by
      adding an IFLA_ADDRESS attribute, as is done in
      virNetDevMacVLanCreate()) rather than separately creating the "dummy
      tap" (e.g. virbr0-nic) to maintain a fixed mac address on the bridge,
      but the commit history of virnetdevbridge.c shows that the presence of
      this dummy tap is essential in some older versions of the kernel
      (between 2.6.39 and 3.1 or 3.2, possibly?) to proper operation of IPv6
      DAD, and I don't want to take the chance of breaking something that I
      don't have the time/setup to test (my RHEL6 box is at kernel
      2.6.32-544, and the next lowest kernel I have is 3.17)
      fc7b23db
    • L
      util: use netlink to delete bridge devices · 09778e09
      Laine Stump 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1125755
      
      reported that a stray bridge device was left on the system when a
      libvirt network failed to start due to an illegal iptables rule caused
      by bad config. Apparently the reason this was happening was that
      NetworkManager was noticing immediately when the bridge device was
      created and automatically setting it IFF_UP. libvirt would then try to
      setup the iptables rules, get an error back, and since libvirt had
      never IFF_UPed the bridge, it didn't expect that it needed to set it
      ~IFF_UP before deleting it during the cleanup process. But the
      ioctl(SIOCBRDELBR) ioctl will fail to delete a bridge if it is IFF_UP.
      
      Since that bug was reported, NetworkManager has gotten a bit more
      polite in this respect, but just in case something similar happens in
      the future, this patch switches to using the netlink RTM_DELLINK
      message to delete the bridge - unlike SIOCBRDELBR, it will delete the
      requested bridge no matter what the setting of IFF_UP.
      09778e09
  18. 10 12月, 2014 1 次提交
  19. 09 12月, 2014 3 次提交
    • E
      build: fix unused variable in mingw · b4861ce9
      Eric Blake 提交于
      Bug introduced in commit 100b7a72:
      
      util/virnetdevbridge.c: In function 'virNetDevBridgePortSetLearning':
      util/virnetdevbridge.c:359:38: error: unused parameter 'enable' [-Werror=unused-parameter]
                                      bool enable)
                                            ^
      
      * src/util/virnetdevbridge.c (virNetDevBridgePortSetLearning): Mark
      unused variable.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      b4861ce9
    • L
      util: functions to manage bridge fdb (forwarding database) · 19a5474d
      Laine Stump 提交于
      These two functions use netlink RTM_NEWNEIGH and RTM_DELNEIGH messages
      to add and delete entries from a bridge's fdb. The bridge itself is
      not referenced in the arguments to the functions, only the name of the
      device that is attached to the bridge (since a device can only be
      attached to one bridge at a time, and must be attached for this
      function to make sense, the kernel easily infers which bridge's fdb is
      being modified by looking at the device name/index).
      19a5474d
    • L
      util: new functions for setting bridge and bridge port attributes · 100b7a72
      Laine Stump 提交于
      These functions all set/get items in the sysfs for a bridge device.
      100b7a72
  20. 15 11月, 2014 1 次提交
  21. 25 3月, 2014 1 次提交
  22. 16 9月, 2013 1 次提交
    • E
      build: fix build with latest rawhide kernel headers · e62e0094
      Eric Blake 提交于
      Bother those kernel developers.  In the latest rawhide, kernel
      and glibc have now been unified so that <netinet/in.h> and
      <linux/in6.h> no longer clash; but <linux/if_bridge.h> is still
      not self-contained.  Because of the latest header change, the
      build is failing with:
      
      checking for linux/param.h... no
      configure: error: You must install kernel-headers in order to compile libvirt with QEMU or LXC support
      
      with details:
      
      In file included from conftest.c:561:0:
      /usr/include/linux/in6.h:71:18: error: field 'flr_dst' has incomplete type
        struct in6_addr flr_dst;
      
      We need a workaround to avoid our workaround :)
      
      * configure.ac (NETINET_LINUX_WORKAROUND): New test.
      * src/util/virnetdevbridge.c (includes): Use it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      e62e0094
  23. 09 8月, 2013 1 次提交
    • E
      build: more workarounds for if_bridge.h · 70024dc9
      Eric Blake 提交于
      This is a second attempt at fixing the problem first attempted
      in commit 2df8d991; basically undoing the fact that it was
      reverted in commit 43cee32f, plus fixing two more issues: the
      code in configure.ac has to EXACTLY match virnetdevbridge.c
      with regards to declaring in6 types before using if_bridge.h,
      and the fact that RHEL 5 has even more conflicts:
      
      In file included from util/virnetdevbridge.c:49:
      /usr/include/linux/in6.h:47: error: conflicting types for 'in6addr_any'
      /usr/include/netinet/in.h:206: error: previous declaration of 'in6addr_any' was here
      /usr/include/linux/in6.h:49: error: conflicting types for 'in6addr_loopback'
      /usr/include/netinet/in.h:207: error: previous declaration of 'in6addr_loopback' was here
      
      The rest of this commit message borrows from the original try
      of 2df8d991:
      
      A fresh checkout on a RHEL 6 machine with these packages:
      kernel-headers-2.6.32-405.el6.x86_64
      glibc-2.12-1.128.el6.x86_64
      failed to configure with this message:
      checking for linux/if_bridge.h... no
      configure: error: You must install kernel-headers in order to compile libvirt with QEMU or LXC support
      
      Digging in config.log, we see that the problem is identical to
      what we fixed earlier in commit d12c2811:
      
      configure:98831: checking for linux/if_bridge.h
      configure:98853: gcc -std=gnu99 -c -g -O2  conftest.c >&5
      In file included from /usr/include/linux/if_bridge.h:17,
                       from conftest.c:559:
      /usr/include/linux/in6.h:31: error: redefinition of 'struct in6_addr'
      /usr/include/linux/in6.h:48: error: redefinition of 'struct sockaddr_in6'
      /usr/include/linux/in6.h:56: error: redefinition of 'struct ipv6_mreq'
      configure:98860: $? = 1
      
      I had not hit it earlier because I was using incremental builds,
      where config.cache had shielded me from the kernel-headers breakage.
      
      * configure.ac (if_bridge.h): Avoid conflicting type definitions.
      * src/util/virnetdevbridge.c (includes): Also sanitize for RHEL 5.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      70024dc9
  24. 24 7月, 2013 1 次提交
    • E
      build: work around broken kernel headers · d12c2811
      Eric Blake 提交于
      Thanks to a lack of coordination between kernel and glibc folks,
      it has been impossible to mix code using <linux/in.h> and
      <net/in.h> for some time now (see for example commit c308a9ae).
      On at least RHEL 6, <linux/if_bridge.h> tries to use the kernel
      side, and fails due to our desire to use the glibc side elsewhere:
      
      In file included from /usr/include/linux/if_bridge.h:17,
                       from util/virnetdevbridge.c:42:
      /usr/include/linux/in6.h:31: error: redefinition of ‘struct in6_addr’
      /usr/include/linux/in6.h:48: error: redefinition of ‘struct sockaddr_in6’
      /usr/include/linux/in6.h:56: error: redefinition of ‘struct ipv6_mreq’
      
      Thankfully, the kernel layout of these structs is ABI-compatible,
      they only differ in the type system presented to the C compiler.
      While there are other versions of kernel headers that avoid the
      problem, it is easier to just work around the issue than to expect
      all developers to upgrade to working kernel headers.
      
      * src/util/virnetdevbridge.c (includes): Coerce the kernel version
      of in.h to not collide with the normal version.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      d12c2811
  25. 11 7月, 2013 1 次提交
  26. 10 7月, 2013 1 次提交
  27. 25 6月, 2013 1 次提交
  28. 21 6月, 2013 2 次提交
  29. 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
  30. 08 3月, 2013 1 次提交
  31. 15 1月, 2013 1 次提交
    • E
      build: further fixes for broken if_bridge.h · 1bf661ca
      Eric Blake 提交于
      Commit c308a9ae was incomplete; it resolved the configure failure,
      but not a later build failure.
      
      * src/util/virnetdevbridge.c: Include pre-req header.
      * configure.ac (AC_CHECK_HEADERS): Prefer standard in.h over
      non-standard ip6.h.
      1bf661ca
  32. 21 12月, 2012 1 次提交