mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
virnetdev: fix build with old kernel
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 most of that flags, because
only few of them were defined at first.
Also to successfully build libvirt with older kernel we need to include
<linux/types.h> before <linux/ethtool.h> to have __u32 and friends
defined.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
eaf1539d2a
commit
48461b169e
@ -383,6 +383,11 @@ AC_CHECK_TYPE([struct ifreq],
|
|||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
AC_CHECK_DECLS([ETH_FLAG_TXVLAN, ETH_FLAG_NTUPLE, ETH_FLAG_RXHASH, ETH_FLAG_LRO,
|
||||||
|
ETHTOOL_GGSO, ETHTOOL_GGRO, ETHTOOL_GFLAGS],
|
||||||
|
[], [], [[#include <linux/ethtool.h>
|
||||||
|
]])
|
||||||
|
|
||||||
dnl Our only use of libtasn1.h is in the testsuite, and can be skipped
|
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 if the header is not present. Assume -ltasn1 is present if the
|
||||||
dnl header could be found.
|
dnl header could be found.
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SIOCETHTOOL) && defined(HAVE_STRUCT_IFREQ)
|
#if defined(SIOCETHTOOL) && defined(HAVE_STRUCT_IFREQ)
|
||||||
|
# include <linux/types.h>
|
||||||
# include <linux/ethtool.h>
|
# include <linux/ethtool.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2800,9 +2801,7 @@ int
|
|||||||
virNetDevGetFeatures(const char *ifname,
|
virNetDevGetFeatures(const char *ifname,
|
||||||
virBitmapPtr *out)
|
virBitmapPtr *out)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
size_t i = -1;
|
size_t i = -1;
|
||||||
size_t j = -1;
|
|
||||||
struct ethtool_value cmd = { 0 };
|
struct ethtool_value cmd = { 0 };
|
||||||
|
|
||||||
struct elem{
|
struct elem{
|
||||||
@ -2815,20 +2814,16 @@ virNetDevGetFeatures(const char *ifname,
|
|||||||
{ETHTOOL_GTXCSUM, VIR_NET_DEV_FEAT_GTXCSUM},
|
{ETHTOOL_GTXCSUM, VIR_NET_DEV_FEAT_GTXCSUM},
|
||||||
{ETHTOOL_GSG, VIR_NET_DEV_FEAT_GSG},
|
{ETHTOOL_GSG, VIR_NET_DEV_FEAT_GSG},
|
||||||
{ETHTOOL_GTSO, VIR_NET_DEV_FEAT_GTSO},
|
{ETHTOOL_GTSO, VIR_NET_DEV_FEAT_GTSO},
|
||||||
|
# if HAVE_DECL_ETHTOOL_GGSO
|
||||||
{ETHTOOL_GGSO, VIR_NET_DEV_FEAT_GGSO},
|
{ETHTOOL_GGSO, VIR_NET_DEV_FEAT_GGSO},
|
||||||
|
# endif
|
||||||
|
# if HAVE_DECL_ETHTOOL_GGRO
|
||||||
{ETHTOOL_GGRO, VIR_NET_DEV_FEAT_GGRO},
|
{ETHTOOL_GGRO, VIR_NET_DEV_FEAT_GGRO},
|
||||||
};
|
# endif
|
||||||
/* ethtool masks */
|
|
||||||
struct elem flags[] = {
|
|
||||||
{ETH_FLAG_LRO, VIR_NET_DEV_FEAT_LRO},
|
|
||||||
{ETH_FLAG_RXVLAN, VIR_NET_DEV_FEAT_RXVLAN},
|
|
||||||
{ETH_FLAG_TXVLAN, VIR_NET_DEV_FEAT_TXVLAN},
|
|
||||||
{ETH_FLAG_NTUPLE, VIR_NET_DEV_FEAT_NTUPLE},
|
|
||||||
{ETH_FLAG_RXHASH, VIR_NET_DEV_FEAT_RXHASH},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!(*out = virBitmapNew(VIR_NET_DEV_FEAT_LAST)))
|
if (!(*out = virBitmapNew(VIR_NET_DEV_FEAT_LAST)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_CARDINALITY(cmds); i++) {
|
for (i = 0; i < ARRAY_CARDINALITY(cmds); i++) {
|
||||||
cmd.cmd = cmds[i].cmd;
|
cmd.cmd = cmds[i].cmd;
|
||||||
@ -2836,6 +2831,25 @@ virNetDevGetFeatures(const char *ifname,
|
|||||||
ignore_value(virBitmapSetBit(*out, cmds[i].feat));
|
ignore_value(virBitmapSetBit(*out, cmds[i].feat));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# if HAVE_DECL_ETHTOOL_GFLAGS
|
||||||
|
size_t j = -1;
|
||||||
|
/* ethtool masks */
|
||||||
|
struct elem flags[] = {
|
||||||
|
# if HAVE_DECL_ETH_FLAG_LRO
|
||||||
|
{ETH_FLAG_LRO, VIR_NET_DEV_FEAT_LRO},
|
||||||
|
# endif
|
||||||
|
# if HAVE_DECL_ETH_FLAG_TXVLAN
|
||||||
|
{ETH_FLAG_RXVLAN, VIR_NET_DEV_FEAT_RXVLAN},
|
||||||
|
{ETH_FLAG_TXVLAN, VIR_NET_DEV_FEAT_TXVLAN},
|
||||||
|
# endif
|
||||||
|
# if HAVE_DECL_ETH_FLAG_NTUBLE
|
||||||
|
{ETH_FLAG_NTUPLE, VIR_NET_DEV_FEAT_NTUPLE},
|
||||||
|
# endif
|
||||||
|
# if HAVE_DECL_ETH_FLAG_RXHASH
|
||||||
|
{ETH_FLAG_RXHASH, VIR_NET_DEV_FEAT_RXHASH},
|
||||||
|
# endif
|
||||||
|
};
|
||||||
|
|
||||||
cmd.cmd = ETHTOOL_GFLAGS;
|
cmd.cmd = ETHTOOL_GFLAGS;
|
||||||
if (virNetDevFeatureAvailable(ifname, &cmd)) {
|
if (virNetDevFeatureAvailable(ifname, &cmd)) {
|
||||||
for (j = 0; j < ARRAY_CARDINALITY(flags); j++) {
|
for (j = 0; j < ARRAY_CARDINALITY(flags); j++) {
|
||||||
@ -2843,12 +2857,9 @@ virNetDevGetFeatures(const char *ifname,
|
|||||||
ignore_value(virBitmapSetBit(*out, flags[j].feat));
|
ignore_value(virBitmapSetBit(*out, flags[j].feat));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int
|
int
|
||||||
|
Loading…
Reference in New Issue
Block a user