Re: [PATCH] virnetdev: fix build with old kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11.03.2015 09:42, Pavel Hrdina wrote:
> Commit c9027d8f added a detection of NIC HW features, but some of them
> are not available in old kernel.  Very old kernels lack enum
> ethtool_flags and even if this enum is present, not all values are
> available for all kernels.  To be sure that we have everything in kernel
> that we need, we must check for existence of newest value which is
> ETH_FLAG_TXVLAN.  Only then we can be sure that the feature detection
> can be successfully built.
> 
> Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
> ---
>  configure.ac         | 6 ++++++
>  src/util/virnetdev.c | 6 ++++--
>  2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index e071813..3cffb84 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -383,6 +383,12 @@ AC_CHECK_TYPE([struct ifreq],
>          #include <net/if.h>
>    ]])
>  
> +AC_CHECK_DECL([ETH_FLAG_TXVLAN],
> +  [AC_DEFINE([HAVE_ETH_FLAG_TXVLAN],[1],
> +    [Defined if ETH_FLAG_TXVLAN exists in linux/ethtool.h])],
> +  [], [[#include <linux/ethtool.h>
> +  ]])
> +
>  dnl Our only use of libtasn1.h is in the testsuite, and can be skipped
>  dnl if the header is not present.  Assume -ltasn1 is present if the
>  dnl header could be found.
> diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
> index 971db43..7519579 100644
> --- a/src/util/virnetdev.c
> +++ b/src/util/virnetdev.c
> @@ -47,7 +47,8 @@
>  # undef HAVE_STRUCT_IFREQ
>  #endif
>  
> -#if defined(SIOCETHTOOL) && defined(HAVE_STRUCT_IFREQ)
> +#if defined(SIOCETHTOOL) && defined(HAVE_STRUCT_IFREQ) && \
> +    defined(HAVE_ETH_FLAG_TXVLAN)
>  # include <linux/ethtool.h>
>  #endif
>  
> @@ -2733,7 +2734,8 @@ int virNetDevGetRxFilter(const char *ifname,
>      return ret;
>  }
>  
> -#if defined(SIOCETHTOOL) && defined(HAVE_STRUCT_IFREQ)
> +#if defined(SIOCETHTOOL) && defined(HAVE_STRUCT_IFREQ) && \
> +    defined(HAVE_ETH_FLAG_TXVLAN)
>  
>  /**
>   * virNetDevFeatureAvailable
> 

How about selectively enabling only those flags, which we know kernel
knows about? For instance, both ETH_FLAG_RXVLAN and ETH_FLAG_TXVLAN were
added in the same kernel commit d5dbda23. So we can do this instead:

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 971db43..204aae9 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -2821,8 +2821,10 @@ virNetDevGetFeatures(const char *ifname,
     /* ethtool masks */
     struct elem flags[] = {
         {ETH_FLAG_LRO, VIR_NET_DEV_FEAT_LRO},
+# ifdef HAVE_ETH_FLAG_TXVLAN
         {ETH_FLAG_RXVLAN, VIR_NET_DEV_FEAT_RXVLAN},
         {ETH_FLAG_TXVLAN, VIR_NET_DEV_FEAT_TXVLAN},
+# endif
         {ETH_FLAG_NTUPLE, VIR_NET_DEV_FEAT_NTUPLE},
         {ETH_FLAG_RXHASH, VIR_NET_DEV_FEAT_RXHASH},
     };

Looking at other ethtool flags:

3ae7c0b2  2007-08-15 16:00:51 |enum ethtool_flags {
d5dbda23  2010-10-20 13:56:07 |    ETH_FLAG_TXVLAN     = (1 << 7),
d5dbda23  2010-10-20 13:56:07 |    ETH_FLAG_RXVLAN     = (1 << 8),
3ae7c0b2  2007-08-15 16:00:51 |    ETH_FLAG_LRO        = (1 << 15),
15682bc4  2010-02-10 20:03:05 |    ETH_FLAG_NTUPLE     = (1 << 27),
b00fabb4  2010-03-29 14:47:27 |    ETH_FLAG_RXHASH     = (1 << 28),
3ae7c0b2  2007-08-15 16:00:51 |};

Well, I'm not sure if it's worth troubling with NTUPLE nad RXHASH (our
configure script already takes ages to finish). The only left flag LRO
was added among with flags enum, so it should be present everytime the
enum is.

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]