diff --git a/configure.ac b/configure.ac index e071813451..2fedd1a34d 100644 --- a/configure.ac +++ b/configure.ac @@ -383,6 +383,11 @@ AC_CHECK_TYPE([struct ifreq], #include ]]) +AC_CHECK_DECLS([ETH_FLAG_TXVLAN, ETH_FLAG_NTUPLE, ETH_FLAG_RXHASH, ETH_FLAG_LRO, + ETHTOOL_GGSO, ETHTOOL_GGRO, ETHTOOL_GFLAGS], + [], [], [[#include + ]]) + 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 971db437dc..093c99c83c 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -48,6 +48,7 @@ #endif #if defined(SIOCETHTOOL) && defined(HAVE_STRUCT_IFREQ) +# include # include #endif @@ -2800,9 +2801,7 @@ int virNetDevGetFeatures(const char *ifname, virBitmapPtr *out) { - int ret = -1; size_t i = -1; - size_t j = -1; struct ethtool_value cmd = { 0 }; struct elem{ @@ -2815,20 +2814,16 @@ virNetDevGetFeatures(const char *ifname, {ETHTOOL_GTXCSUM, VIR_NET_DEV_FEAT_GTXCSUM}, {ETHTOOL_GSG, VIR_NET_DEV_FEAT_GSG}, {ETHTOOL_GTSO, VIR_NET_DEV_FEAT_GTSO}, +# if HAVE_DECL_ETHTOOL_GGSO {ETHTOOL_GGSO, VIR_NET_DEV_FEAT_GGSO}, +# endif +# if HAVE_DECL_ETHTOOL_GGRO {ETHTOOL_GGRO, VIR_NET_DEV_FEAT_GGRO}, - }; - /* 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}, +# endif }; if (!(*out = virBitmapNew(VIR_NET_DEV_FEAT_LAST))) - goto cleanup; + return -1; for (i = 0; i < ARRAY_CARDINALITY(cmds); i++) { cmd.cmd = cmds[i].cmd; @@ -2836,6 +2831,25 @@ virNetDevGetFeatures(const char *ifname, 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; if (virNetDevFeatureAvailable(ifname, &cmd)) { for (j = 0; j < ARRAY_CARDINALITY(flags); j++) { @@ -2843,12 +2857,9 @@ virNetDevGetFeatures(const char *ifname, ignore_value(virBitmapSetBit(*out, flags[j].feat)); } } +# endif - ret = 0; - cleanup: - - return ret; - + return 0; } #else int