[libvirt PATCH 00/21] meson: remove many obsolete checks

We have alot of checks for Linux kernel features that are obsolete since our supported platform matrix lets us assume new enough kernel versions. Removing the checks will speed up the meson phase and reduce the tangle of #ifdefs in the code. I thought I could remove the check for linux/kvm.h but for some reason our code in virhostpcu.c / cpu_x86.c is enabling the codebases even on FreeBSD, which I find kind of odd. Does FreeBSD really ship a linux/kvm.h ? Daniel P. Berrangé (21): meson: remove obsolete check for LOOP_CTL_GET_FREE meson: remove obsolete check for EPOLL_CLOEXEC meson: remove obsolete check for LO_FLAGS_AUTOCLEAR meson: drop check for unshare() netdev: simplify check for ethtool functionality meson: remove obsolete check for ETHTOOL_GGSO meson: remove obsolete check for ETHTOOL_GGRO meson: remove obsolete check for ETHTOOL_GFLAGS meson: remove obsolete check for ETH_FLAG_LRO meson: remove obsolete check for ETH_FLAG_TXVLAN/RXVLAN meson: remove obsolete check for ETH_FLAG_NTUPLE meson: remove obsolete check for ETH_FLAG_RXHASH meson: remove obsolete check for ETHTOOL_GFEATURES meson: remove obsolete check for ETHTOOL_GCOALESCE meson: remove obsolete check for GET_VLAN_VID_CMD meson: simplify check for virnetdevbridge.c headers meson: remove obsolete check for DEVLINK_CMD_ESWITCH_GET meson: remove obsolete check for linux/magic.h meson: remove obsolete check for VHOST_VSOCK_SET_GUEST_CID meson: remove obsolete check for BPF_PROG_QUERY meson: remove obsolete check for BPF_CGROUP_DEVICE meson.build | 82 +++-------------------------------- src/util/virbpf.c | 6 +-- src/util/virbpf.h | 6 +-- src/util/vircgroupv2devices.c | 10 ++--- src/util/virfile.c | 15 ++----- src/util/virnetdev.c | 65 ++++----------------------- src/util/virvsock.c | 4 +- tests/securityselinuxhelper.c | 4 +- tests/virfilemock.c | 2 +- 9 files changed, 32 insertions(+), 162 deletions(-) -- 2.38.1

The LOOP_CTL_GET_FREE constant was introduced to Linux in commit 770fe30a46a12b6fb6b63fbe1737654d28e84844 Author: Kay Sievers <kay.sievers@vrfy.org> Date: Sun Jul 31 22:08:04 2011 +0200 loop: add management interface for on-demand device allocation This is old enough that all our supported platforms can be assumed to have this feature. As a plus point, this meson check is going to start failing with future GCC. It fails to set _GNU_SOURCE, thus 'unshare' is not defined by the header, and its relying on an implicit function decl. For added fun this whole meson check was semantically insane because LOOP_CTL_GET_FREE is not a valid arg to unshare(). Fixes https://fedoraproject.org/wiki/Toolchain/PortingToModernC Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 13 ------------- src/util/virfile.c | 5 ----- 2 files changed, 18 deletions(-) diff --git a/meson.build b/meson.build index f9834a36c2..22679db85d 100644 --- a/meson.build +++ b/meson.build @@ -1541,19 +1541,6 @@ void main(void) { elif get_option('driver_lxc').enabled() error('Required kernel features for LXC were not found') endif - - lxc_get_free_code = ''' -#include <sched.h> -#include <linux/loop.h> -#include <sys/epoll.h> - -void main(void) { - unshare(!(LOOP_CTL_GET_FREE)); -} - ''' - if cc.compiles(lxc_get_free_code) - conf.set('WITH_DECL_LOOP_CTL_GET_FREE', 1) - endif elif get_option('driver_lxc').enabled() error('linux and remote_driver are required for LXC') endif diff --git a/src/util/virfile.c b/src/util/virfile.c index ec40c04b1f..cef9f9979a 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -750,8 +750,6 @@ int virFileUpdatePerm(const char *path, #if defined(__linux__) && WITH_DECL_LO_FLAGS_AUTOCLEAR -# if WITH_DECL_LOOP_CTL_GET_FREE - /* virFileLoopDeviceOpenLoopCtl() returns -1 when a real failure has occurred * while in the process of allocating or opening the loop device. On success * we return 0 and modify the fd to the appropriate file descriptor. @@ -795,7 +793,6 @@ static int virFileLoopDeviceOpenLoopCtl(char **dev_name, int *fd) *dev_name = looppath; return 0; } -# endif /* WITH_DECL_LOOP_CTL_GET_FREE */ static int virFileLoopDeviceOpenSearch(char **dev_name) { @@ -864,7 +861,6 @@ static int virFileLoopDeviceOpen(char **dev_name) { int loop_fd = -1; -# if WITH_DECL_LOOP_CTL_GET_FREE if (virFileLoopDeviceOpenLoopCtl(dev_name, &loop_fd) < 0) return -1; @@ -872,7 +868,6 @@ static int virFileLoopDeviceOpen(char **dev_name) if (loop_fd >= 0) return loop_fd; -# endif /* WITH_DECL_LOOP_CTL_GET_FREE */ /* Without the loop control device we just use the old technique. */ loop_fd = virFileLoopDeviceOpenSearch(dev_name); -- 2.38.1

The EPOLL_CLOEXEC constant was introduced to Linux in commit a0998b50c3f0b8fdd265c63e0032f86ebe377dbf Author: Ulrich Drepper <drepper@redhat.com> Date: Wed Jul 23 21:29:27 2008 -0700 flag parameters: epoll_create This is old enough that all our supported platforms can be assumed to have this feature. For added fun this whole meson check was semantically insane because EPOLL_CLOEXEC is not a valid arg to unshare(). Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 22679db85d..f313767cfe 100644 --- a/meson.build +++ b/meson.build @@ -1532,7 +1532,7 @@ if not get_option('driver_lxc').disabled() and host_machine.system() == 'linux' #include <sys/epoll.h> void main(void) { - unshare(!(LO_FLAGS_AUTOCLEAR + EPOLL_CLOEXEC)); + unshare(!(LO_FLAGS_AUTOCLEAR)); } ''' if cc.compiles(lxc_support_code, name: 'lxc support', args: '-D_GNU_SOURCE') -- 2.38.1

The LO_FLAGS_AUTOCLEAR constant was introduced to Linux in commit 96c5865559cee0f9cbc5173f3c949f6ce3525581 Author: David Woodhouse <dwmw2@infradead.org> Date: Wed Feb 6 01:36:27 2008 -0800 Allow auto-destruction of loop devices This is old enough that all our supported platforms can be assumed to have this feature. For added fun this whole meson check was semantically insane because EPOLL_CLOEXEC is not a valid arg to unshare(). Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 3 +-- src/util/virfile.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index f313767cfe..212c3cfafb 100644 --- a/meson.build +++ b/meson.build @@ -1532,12 +1532,11 @@ if not get_option('driver_lxc').disabled() and host_machine.system() == 'linux' #include <sys/epoll.h> void main(void) { - unshare(!(LO_FLAGS_AUTOCLEAR)); + unshare(1); } ''' if cc.compiles(lxc_support_code, name: 'lxc support', args: '-D_GNU_SOURCE') conf.set('WITH_LXC', 1) - conf.set('WITH_DECL_LO_FLAGS_AUTOCLEAR', 1) elif get_option('driver_lxc').enabled() error('Required kernel features for LXC were not found') endif diff --git a/src/util/virfile.c b/src/util/virfile.c index cef9f9979a..7b37d6888e 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -66,9 +66,7 @@ # include <linux/magic.h> # endif # include <sys/statfs.h> -# if WITH_DECL_LO_FLAGS_AUTOCLEAR -# include <linux/loop.h> -# endif +# include <linux/loop.h> # include <sys/ioctl.h> # include <linux/cdrom.h> /* These come from linux/fs.h, but that header conflicts with @@ -748,7 +746,7 @@ int virFileUpdatePerm(const char *path, } -#if defined(__linux__) && WITH_DECL_LO_FLAGS_AUTOCLEAR +#if defined(__linux__) /* virFileLoopDeviceOpenLoopCtl() returns -1 when a real failure has occurred * while in the process of allocating or opening the loop device. On success -- 2.38.1

The unshare() syscall was introduced to Linux in commit 2da436e00f9a5fdd0fb6b31e4b2b2ba82e8f5ab8 Author: JANAK DESAI <janak@us.ibm.com> Date: Tue Feb 7 12:59:03 2006 -0800 [PATCH] unshare system call -v5: system call registration for i386 This is old enough that all our supported platforms can be assumed to have this feature. Furthermore, the virprocess.c file was already using unshare() with nothing more than a #ifdef __linux__ check. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/meson.build b/meson.build index 212c3cfafb..0a09e510c7 100644 --- a/meson.build +++ b/meson.build @@ -1526,20 +1526,7 @@ elif get_option('driver_libxl').enabled() endif if not get_option('driver_lxc').disabled() and host_machine.system() == 'linux' and conf.has('WITH_LIBVIRTD') - lxc_support_code = ''' -#include <sched.h> -#include <linux/loop.h> -#include <sys/epoll.h> - -void main(void) { - unshare(1); -} - ''' - if cc.compiles(lxc_support_code, name: 'lxc support', args: '-D_GNU_SOURCE') - conf.set('WITH_LXC', 1) - elif get_option('driver_lxc').enabled() - error('Required kernel features for LXC were not found') - endif + conf.set('WITH_LXC', 1) elif get_option('driver_lxc').enabled() error('linux and remote_driver are required for LXC') endif -- 2.38.1

ethtool is a Linux specific feature that has existed since before Linux moved to git. Checking against SIOCETHTOOL + WITH_STRUCT_IFREQ is overkill for our needs. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/util/virnetdev.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 66cfc5d781..c21cf69be1 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -42,6 +42,8 @@ #ifdef __linux__ # include <linux/sockios.h> # include <linux/if_vlan.h> +# include <linux/types.h> +# include <linux/ethtool.h> # define VIR_NETDEV_FAMILY AF_UNIX #elif defined(WITH_STRUCT_IFREQ) && defined(AF_LOCAL) # define VIR_NETDEV_FAMILY AF_LOCAL @@ -49,11 +51,6 @@ # undef WITH_STRUCT_IFREQ #endif -#if defined(SIOCETHTOOL) && defined(WITH_STRUCT_IFREQ) -# include <linux/types.h> -# include <linux/ethtool.h> -#endif - #if WITH_DECL_LINK_ADDR # include <sys/sockio.h> # include <net/if_dl.h> @@ -2958,7 +2955,7 @@ int virNetDevGetRxFilter(const char *ifname, return ret; } -#if defined(SIOCETHTOOL) && defined(WITH_STRUCT_IFREQ) +#if __linux__ /** * virNetDevRDMAFeature -- 2.38.1

The ETHTOOL_GGSO constant was introduced to Linux in commit 37c3185a02d4b85fbe134bf5204535405dd2c957 Author: Herbert Xu <herbert@gondor.apana.org.au> Date: Thu Jun 22 03:07:29 2006 -0700 [NET]: Added GSO toggle This is old enough that all our supported platforms can be assumed to have this feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 1 - src/util/virnetdev.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/meson.build b/meson.build index 0a09e510c7..69d79963f7 100644 --- a/meson.build +++ b/meson.build @@ -654,7 +654,6 @@ symbols = [ [ 'linux/ethtool.h', 'ETH_FLAG_NTUPLE' ], [ 'linux/ethtool.h', 'ETH_FLAG_RXHASH' ], [ 'linux/ethtool.h', 'ETH_FLAG_LRO' ], - [ 'linux/ethtool.h', 'ETHTOOL_GGSO' ], [ 'linux/ethtool.h', 'ETHTOOL_GGRO' ], [ 'linux/ethtool.h', 'ETHTOOL_GFLAGS' ], [ 'linux/ethtool.h', 'ETHTOOL_GFEATURES' ], diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index c21cf69be1..3fdf71e41e 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -3083,9 +3083,7 @@ virNetDevGetEthtoolFeatures(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 WITH_DECL_ETHTOOL_GGSO {ETHTOOL_GGSO, VIR_NET_DEV_FEAT_GGSO}, -# endif # if WITH_DECL_ETHTOOL_GGRO {ETHTOOL_GGRO, VIR_NET_DEV_FEAT_GGRO}, # endif -- 2.38.1

The ETHTOOL_GGRO constant was introduced to Linux in commit b240a0e5644eb817c4a397098a40e1ad42a615bc Author: Herbert Xu <herbert@gondor.apana.org.au> Date: Mon Dec 15 23:44:31 2008 -0800 ethtool: Add GGRO and SGRO ops This is old enough that all our supported platforms can be assumed to have this feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 1 - src/util/virnetdev.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/meson.build b/meson.build index 69d79963f7..be5d356b88 100644 --- a/meson.build +++ b/meson.build @@ -654,7 +654,6 @@ symbols = [ [ 'linux/ethtool.h', 'ETH_FLAG_NTUPLE' ], [ 'linux/ethtool.h', 'ETH_FLAG_RXHASH' ], [ 'linux/ethtool.h', 'ETH_FLAG_LRO' ], - [ 'linux/ethtool.h', 'ETHTOOL_GGRO' ], [ 'linux/ethtool.h', 'ETHTOOL_GFLAGS' ], [ 'linux/ethtool.h', 'ETHTOOL_GFEATURES' ], [ 'linux/ethtool.h', 'ETHTOOL_SCOALESCE' ], diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 3fdf71e41e..bf7393b476 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -3084,9 +3084,7 @@ virNetDevGetEthtoolFeatures(const char *ifname, {ETHTOOL_GSG, VIR_NET_DEV_FEAT_GSG}, {ETHTOOL_GTSO, VIR_NET_DEV_FEAT_GTSO}, {ETHTOOL_GGSO, VIR_NET_DEV_FEAT_GGSO}, -# if WITH_DECL_ETHTOOL_GGRO {ETHTOOL_GGRO, VIR_NET_DEV_FEAT_GGRO}, -# endif }; # if WITH_DECL_ETHTOOL_GFLAGS -- 2.38.1

The ETHTOOL_GFLAGS constant was introduced to Linux in commit 3ae7c0b2e3747b50c3a6c63ebb67469e0a6b3203 Author: Jeff Garzik <jeff@garzik.org> Date: Wed Aug 15 16:00:51 2007 -0700 [ETHTOOL]: Add ETHTOOL_[GS]FLAGS sub-ioctls This is old enough that all our supported platforms can be assumed to have this feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 1 - src/util/virnetdev.c | 20 ++++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/meson.build b/meson.build index be5d356b88..4703b2c670 100644 --- a/meson.build +++ b/meson.build @@ -654,7 +654,6 @@ symbols = [ [ 'linux/ethtool.h', 'ETH_FLAG_NTUPLE' ], [ 'linux/ethtool.h', 'ETH_FLAG_RXHASH' ], [ 'linux/ethtool.h', 'ETH_FLAG_LRO' ], - [ 'linux/ethtool.h', 'ETHTOOL_GFLAGS' ], [ 'linux/ethtool.h', 'ETHTOOL_GFEATURES' ], [ 'linux/ethtool.h', 'ETHTOOL_SCOALESCE' ], [ 'linux/ethtool.h', 'ETHTOOL_GCOALESCE' ], diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index bf7393b476..f6e2b06102 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -3087,24 +3087,22 @@ virNetDevGetEthtoolFeatures(const char *ifname, {ETHTOOL_GGRO, VIR_NET_DEV_FEAT_GGRO}, }; -# if WITH_DECL_ETHTOOL_GFLAGS /* ethtool masks */ struct virNetDevEthtoolFeatureCmd flags[] = { -# if WITH_DECL_ETH_FLAG_LRO +# if WITH_DECL_ETH_FLAG_LRO {ETH_FLAG_LRO, VIR_NET_DEV_FEAT_LRO}, -# endif -# if WITH_DECL_ETH_FLAG_TXVLAN +# endif +# if WITH_DECL_ETH_FLAG_TXVLAN {ETH_FLAG_RXVLAN, VIR_NET_DEV_FEAT_RXVLAN}, {ETH_FLAG_TXVLAN, VIR_NET_DEV_FEAT_TXVLAN}, -# endif -# if WITH_DECL_ETH_FLAG_NTUBLE +# endif +# if WITH_DECL_ETH_FLAG_NTUBLE {ETH_FLAG_NTUPLE, VIR_NET_DEV_FEAT_NTUPLE}, -# endif -# if WITH_DECL_ETH_FLAG_RXHASH +# endif +# if WITH_DECL_ETH_FLAG_RXHASH {ETH_FLAG_RXHASH, VIR_NET_DEV_FEAT_RXHASH}, -# endif - }; # endif + }; for (i = 0; i < G_N_ELEMENTS(ethtool_cmds); i++) { cmd.cmd = ethtool_cmds[i].cmd; @@ -3112,7 +3110,6 @@ virNetDevGetEthtoolFeatures(const char *ifname, ignore_value(virBitmapSetBit(bitmap, ethtool_cmds[i].feat)); } -# if WITH_DECL_ETHTOOL_GFLAGS cmd.cmd = ETHTOOL_GFLAGS; if (virNetDevFeatureAvailable(ifname, fd, ifr, &cmd)) { for (i = 0; i < G_N_ELEMENTS(flags); i++) { @@ -3120,7 +3117,6 @@ virNetDevGetEthtoolFeatures(const char *ifname, ignore_value(virBitmapSetBit(bitmap, flags[i].feat)); } } -# endif } -- 2.38.1

The ETH_FLAG_LRO constant was introduced to Linux in commit 3ae7c0b2e3747b50c3a6c63ebb67469e0a6b3203 Author: Jeff Garzik <jeff@garzik.org> Date: Wed Aug 15 16:00:51 2007 -0700 [ETHTOOL]: Add ETHTOOL_[GS]FLAGS sub-ioctls This is old enough that all our supported platforms can be assumed to have this feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 1 - src/util/virnetdev.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/meson.build b/meson.build index 4703b2c670..3194c2f9af 100644 --- a/meson.build +++ b/meson.build @@ -653,7 +653,6 @@ symbols = [ [ 'linux/ethtool.h', 'ETH_FLAG_TXVLAN' ], [ 'linux/ethtool.h', 'ETH_FLAG_NTUPLE' ], [ 'linux/ethtool.h', 'ETH_FLAG_RXHASH' ], - [ 'linux/ethtool.h', 'ETH_FLAG_LRO' ], [ 'linux/ethtool.h', 'ETHTOOL_GFEATURES' ], [ 'linux/ethtool.h', 'ETHTOOL_SCOALESCE' ], [ 'linux/ethtool.h', 'ETHTOOL_GCOALESCE' ], diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index f6e2b06102..b7de487c36 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -3089,9 +3089,7 @@ virNetDevGetEthtoolFeatures(const char *ifname, /* ethtool masks */ struct virNetDevEthtoolFeatureCmd flags[] = { -# if WITH_DECL_ETH_FLAG_LRO {ETH_FLAG_LRO, VIR_NET_DEV_FEAT_LRO}, -# endif # if WITH_DECL_ETH_FLAG_TXVLAN {ETH_FLAG_RXVLAN, VIR_NET_DEV_FEAT_RXVLAN}, {ETH_FLAG_TXVLAN, VIR_NET_DEV_FEAT_TXVLAN}, -- 2.38.1

The ETH_FLAG_TXVLAN/RXVLAN constants were introduced to Linux in commit d5dbda23804156ae6f35025ade5307a49d1db6d7 Author: Jesse Gross <jesse@nicira.com> Date: Wed Oct 20 13:56:07 2010 +0000 ethtool: Add support for vlan accleration. This is old enough that all our supported platforms can be assumed to have this feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/meson.build b/meson.build index 3194c2f9af..93c8d12264 100644 --- a/meson.build +++ b/meson.build @@ -650,7 +650,6 @@ symbols = [ # Check whether endian provides handy macros. [ 'endian.h', 'htole64' ], - [ 'linux/ethtool.h', 'ETH_FLAG_TXVLAN' ], [ 'linux/ethtool.h', 'ETH_FLAG_NTUPLE' ], [ 'linux/ethtool.h', 'ETH_FLAG_RXHASH' ], [ 'linux/ethtool.h', 'ETHTOOL_GFEATURES' ], -- 2.38.1

The ETH_FLAG_NTUPLE constant was introduced to Linux in commit 15682bc488d4af8c9bb998844a94281025e0a333 Author: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Date: Wed Feb 10 20:03:05 2010 -0800 ethtool: Introduce n-tuple filter programming support This is old enough that all our supported platforms can be assumed to have this feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 1 - src/util/virnetdev.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/meson.build b/meson.build index 93c8d12264..d9af1ac36a 100644 --- a/meson.build +++ b/meson.build @@ -650,7 +650,6 @@ symbols = [ # Check whether endian provides handy macros. [ 'endian.h', 'htole64' ], - [ 'linux/ethtool.h', 'ETH_FLAG_NTUPLE' ], [ 'linux/ethtool.h', 'ETH_FLAG_RXHASH' ], [ 'linux/ethtool.h', 'ETHTOOL_GFEATURES' ], [ 'linux/ethtool.h', 'ETHTOOL_SCOALESCE' ], diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index b7de487c36..5ef4687191 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -3090,13 +3090,9 @@ virNetDevGetEthtoolFeatures(const char *ifname, /* ethtool masks */ struct virNetDevEthtoolFeatureCmd flags[] = { {ETH_FLAG_LRO, VIR_NET_DEV_FEAT_LRO}, -# if WITH_DECL_ETH_FLAG_TXVLAN {ETH_FLAG_RXVLAN, VIR_NET_DEV_FEAT_RXVLAN}, {ETH_FLAG_TXVLAN, VIR_NET_DEV_FEAT_TXVLAN}, -# endif -# if WITH_DECL_ETH_FLAG_NTUBLE {ETH_FLAG_NTUPLE, VIR_NET_DEV_FEAT_NTUPLE}, -# endif # if WITH_DECL_ETH_FLAG_RXHASH {ETH_FLAG_RXHASH, VIR_NET_DEV_FEAT_RXHASH}, # endif -- 2.38.1

On 12/8/22 8:35 AM, Daniel P. Berrangé wrote:
The ETH_FLAG_NTUPLE constant was introduced to Linux in
commit 15682bc488d4af8c9bb998844a94281025e0a333 Author: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Date: Wed Feb 10 20:03:05 2010 -0800
ethtool: Introduce n-tuple filter programming support
This is old enough that all our supported platforms can be assumed to have this feature.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 1 - src/util/virnetdev.c | 4 ---- 2 files changed, 5 deletions(-)
diff --git a/meson.build b/meson.build index 93c8d12264..d9af1ac36a 100644 --- a/meson.build +++ b/meson.build @@ -650,7 +650,6 @@ symbols = [ # Check whether endian provides handy macros. [ 'endian.h', 'htole64' ],
- [ 'linux/ethtool.h', 'ETH_FLAG_NTUPLE' ], [ 'linux/ethtool.h', 'ETH_FLAG_RXHASH' ], [ 'linux/ethtool.h', 'ETHTOOL_GFEATURES' ], [ 'linux/ethtool.h', 'ETHTOOL_SCOALESCE' ], diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index b7de487c36..5ef4687191 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -3090,13 +3090,9 @@ virNetDevGetEthtoolFeatures(const char *ifname, /* ethtool masks */ struct virNetDevEthtoolFeatureCmd flags[] = { {ETH_FLAG_LRO, VIR_NET_DEV_FEAT_LRO}, -# if WITH_DECL_ETH_FLAG_TXVLAN {ETH_FLAG_RXVLAN, VIR_NET_DEV_FEAT_RXVLAN}, {ETH_FLAG_TXVLAN, VIR_NET_DEV_FEAT_TXVLAN}, -# endif -# if WITH_DECL_ETH_FLAG_NTUBLE
Does the fact that this was protected by a symbol named _NTUBLE instead of _NTUPLE mean that this code was never actually executed?
{ETH_FLAG_NTUPLE, VIR_NET_DEV_FEAT_NTUPLE}, -# endif # if WITH_DECL_ETH_FLAG_RXHASH {ETH_FLAG_RXHASH, VIR_NET_DEV_FEAT_RXHASH}, # endif

On Thu, Dec 08, 2022 at 10:15:27AM -0600, Jonathon Jongsma wrote:
On 12/8/22 8:35 AM, Daniel P. Berrangé wrote:
The ETH_FLAG_NTUPLE constant was introduced to Linux in
commit 15682bc488d4af8c9bb998844a94281025e0a333 Author: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Date: Wed Feb 10 20:03:05 2010 -0800
ethtool: Introduce n-tuple filter programming support
This is old enough that all our supported platforms can be assumed to have this feature.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 1 - src/util/virnetdev.c | 4 ---- 2 files changed, 5 deletions(-)
diff --git a/meson.build b/meson.build index 93c8d12264..d9af1ac36a 100644 --- a/meson.build +++ b/meson.build @@ -650,7 +650,6 @@ symbols = [ # Check whether endian provides handy macros. [ 'endian.h', 'htole64' ], - [ 'linux/ethtool.h', 'ETH_FLAG_NTUPLE' ], [ 'linux/ethtool.h', 'ETH_FLAG_RXHASH' ], [ 'linux/ethtool.h', 'ETHTOOL_GFEATURES' ], [ 'linux/ethtool.h', 'ETHTOOL_SCOALESCE' ], diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index b7de487c36..5ef4687191 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -3090,13 +3090,9 @@ virNetDevGetEthtoolFeatures(const char *ifname, /* ethtool masks */ struct virNetDevEthtoolFeatureCmd flags[] = { {ETH_FLAG_LRO, VIR_NET_DEV_FEAT_LRO}, -# if WITH_DECL_ETH_FLAG_TXVLAN {ETH_FLAG_RXVLAN, VIR_NET_DEV_FEAT_RXVLAN}, {ETH_FLAG_TXVLAN, VIR_NET_DEV_FEAT_TXVLAN}, -# endif -# if WITH_DECL_ETH_FLAG_NTUBLE
Does the fact that this was protected by a symbol named _NTUBLE instead of _NTUPLE mean that this code was never actually executed?
Evidentally yes, all the more reason to get rid of pointless obsolete conditionals :-) With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

The ETH_FLAG_RXHASH constant was introduced to Linux in commit b00fabb4020d17bda4bea59507e09fadf573088d Author: stephen hemminger <shemminger@vyatta.com> Date: Mon Mar 29 14:47:27 2010 +0000 netdev: ethtool RXHASH flag This is old enough that all our supported platforms can be assumed to have this feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 1 - src/util/virnetdev.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/meson.build b/meson.build index d9af1ac36a..ff6908d3c4 100644 --- a/meson.build +++ b/meson.build @@ -650,7 +650,6 @@ symbols = [ # Check whether endian provides handy macros. [ 'endian.h', 'htole64' ], - [ 'linux/ethtool.h', 'ETH_FLAG_RXHASH' ], [ 'linux/ethtool.h', 'ETHTOOL_GFEATURES' ], [ 'linux/ethtool.h', 'ETHTOOL_SCOALESCE' ], [ 'linux/ethtool.h', 'ETHTOOL_GCOALESCE' ], diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 5ef4687191..52b8d53ed8 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -3093,9 +3093,7 @@ virNetDevGetEthtoolFeatures(const char *ifname, {ETH_FLAG_RXVLAN, VIR_NET_DEV_FEAT_RXVLAN}, {ETH_FLAG_TXVLAN, VIR_NET_DEV_FEAT_TXVLAN}, {ETH_FLAG_NTUPLE, VIR_NET_DEV_FEAT_NTUPLE}, -# if WITH_DECL_ETH_FLAG_RXHASH {ETH_FLAG_RXHASH, VIR_NET_DEV_FEAT_RXHASH}, -# endif }; for (i = 0; i < G_N_ELEMENTS(ethtool_cmds); i++) { -- 2.38.1

The ETHTOOL_GFEATURES constant was introduced to Linux in commit 5455c6998d34dc983a8693500e4dffefc3682dc5 Author: Michał Mirosław <mirq-linux@rere.qmqm.pl> Date: Tue Feb 15 16:59:17 2011 +0000 net: Introduce new feature setting ops This is old enough that all our supported platforms can be assumed to have this feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 1 - src/util/virnetdev.c | 13 +------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/meson.build b/meson.build index ff6908d3c4..a3a512a565 100644 --- a/meson.build +++ b/meson.build @@ -650,7 +650,6 @@ symbols = [ # Check whether endian provides handy macros. [ 'endian.h', 'htole64' ], - [ 'linux/ethtool.h', 'ETHTOOL_GFEATURES' ], [ 'linux/ethtool.h', 'ETHTOOL_SCOALESCE' ], [ 'linux/ethtool.h', 'ETHTOOL_GCOALESCE' ], diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 52b8d53ed8..c2bccf4e49 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -86,7 +86,7 @@ VIR_LOG_INIT("util.netdev"); #endif #define RESOURCE_FILE_LEN 4096 -#if WITH_DECL_ETHTOOL_GFEATURES +#ifdef __linux__ # define TX_UDP_TNL 25 # define GFEATURES_SIZE 2 # define FEATURE_WORD(blocks, index, field) ((blocks)[(index) / 32U].field) @@ -3264,7 +3264,6 @@ virNetDevSwitchdevFeature(const char *ifname G_GNUC_UNUSED, # endif -# if WITH_DECL_ETHTOOL_GFEATURES /** * virNetDevGFeatureAvailable * This function checks for the availability of a network device gfeature @@ -3305,16 +3304,6 @@ virNetDevGetEthtoolGFeatures(const char *ifname, ignore_value(virBitmapSetBit(bitmap, VIR_NET_DEV_FEAT_TXUDPTNL)); return 0; } -# else -static int -virNetDevGetEthtoolGFeatures(const char *ifname G_GNUC_UNUSED, - virBitmap *bitmap G_GNUC_UNUSED, - int fd G_GNUC_UNUSED, - struct ifreq *ifr G_GNUC_UNUSED) -{ - return 0; -} -# endif # if WITH_DECL_ETHTOOL_SCOALESCE && WITH_DECL_ETHTOOL_GCOALESCE -- 2.38.1

The ETHTOOL_GCOALESCE constant has existed since before Linux moved to git. This is old enough that all our supported platforms can be assumed to have this feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 3 --- src/util/virnetdev.c | 15 --------------- 2 files changed, 18 deletions(-) diff --git a/meson.build b/meson.build index a3a512a565..7fb17bf983 100644 --- a/meson.build +++ b/meson.build @@ -650,9 +650,6 @@ symbols = [ # Check whether endian provides handy macros. [ 'endian.h', 'htole64' ], - [ 'linux/ethtool.h', 'ETHTOOL_SCOALESCE' ], - [ 'linux/ethtool.h', 'ETHTOOL_GCOALESCE' ], - # GET_VLAN_VID_CMD is required for virNetDevGetVLanID [ 'linux/if_vlan.h', 'GET_VLAN_VID_CMD' ], diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index c2bccf4e49..a73d624453 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -3306,7 +3306,6 @@ virNetDevGetEthtoolGFeatures(const char *ifname, } -# if WITH_DECL_ETHTOOL_SCOALESCE && WITH_DECL_ETHTOOL_GCOALESCE /** * virNetDevSetCoalesce: * @ifname: interface name to modify @@ -3402,20 +3401,6 @@ int virNetDevSetCoalesce(const char *ifname, return 0; } -# else -int virNetDevSetCoalesce(const char *ifname, - virNetDevCoalesce *coalesce, - bool update) -{ - if (!coalesce && !update) - return 0; - - virReportSystemError(ENOSYS, - _("Cannot set coalesce info on interface '%s'"), - ifname); - return -1; -} -# endif /** -- 2.38.1

The ETHTOOL_GFEATURES constant has existed since before Linux moved to git. This is old enough that all our supported platforms can be assumed to have this feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 3 --- src/util/virnetdev.c | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 7fb17bf983..f28af30936 100644 --- a/meson.build +++ b/meson.build @@ -650,9 +650,6 @@ symbols = [ # Check whether endian provides handy macros. [ 'endian.h', 'htole64' ], - # GET_VLAN_VID_CMD is required for virNetDevGetVLanID - [ 'linux/if_vlan.h', 'GET_VLAN_VID_CMD' ], - [ 'unistd.h', 'SEEK_HOLE' ], # Check for BSD approach for setting MAC addr diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index a73d624453..9b0f26c1f9 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -959,7 +959,7 @@ virNetDevGetMaster(const char *ifname G_GNUC_UNUSED, #endif /* defined(WITH_LIBNL) */ -#if defined(SIOCGIFVLAN) && defined(WITH_STRUCT_IFREQ) && WITH_DECL_GET_VLAN_VID_CMD +#if __linux__ int virNetDevGetVLanID(const char *ifname, int *vlanid) { struct vlan_ioctl_args vlanargs = { @@ -989,7 +989,7 @@ int virNetDevGetVLanID(const char *ifname, int *vlanid) *vlanid = vlanargs.u.VID; return 0; } -#else /* ! SIOCGIFVLAN */ +#else /* ! __linux__ */ int virNetDevGetVLanID(const char *ifname G_GNUC_UNUSED, int *vlanid G_GNUC_UNUSED) { @@ -997,7 +997,7 @@ int virNetDevGetVLanID(const char *ifname G_GNUC_UNUSED, _("Unable to get VLAN on this platform")); return -1; } -#endif /* ! SIOCGIFVLAN */ +#endif /* ! __linux__ */ /** -- 2.38.1

On 12/8/22 8:35 AM, Daniel P. Berrangé wrote:
The ETHTOOL_GFEATURES constant has existed since before Linux moved to git.
^ This sentence mentions the wrong constant name.
This is old enough that all our supported platforms can be assumed to have this feature.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 3 --- src/util/virnetdev.c | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/meson.build b/meson.build index 7fb17bf983..f28af30936 100644 --- a/meson.build +++ b/meson.build @@ -650,9 +650,6 @@ symbols = [ # Check whether endian provides handy macros. [ 'endian.h', 'htole64' ],
- # GET_VLAN_VID_CMD is required for virNetDevGetVLanID - [ 'linux/if_vlan.h', 'GET_VLAN_VID_CMD' ], - [ 'unistd.h', 'SEEK_HOLE' ],
# Check for BSD approach for setting MAC addr diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index a73d624453..9b0f26c1f9 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -959,7 +959,7 @@ virNetDevGetMaster(const char *ifname G_GNUC_UNUSED, #endif /* defined(WITH_LIBNL) */
-#if defined(SIOCGIFVLAN) && defined(WITH_STRUCT_IFREQ) && WITH_DECL_GET_VLAN_VID_CMD +#if __linux__ int virNetDevGetVLanID(const char *ifname, int *vlanid) { struct vlan_ioctl_args vlanargs = { @@ -989,7 +989,7 @@ int virNetDevGetVLanID(const char *ifname, int *vlanid) *vlanid = vlanargs.u.VID; return 0; } -#else /* ! SIOCGIFVLAN */ +#else /* ! __linux__ */ int virNetDevGetVLanID(const char *ifname G_GNUC_UNUSED, int *vlanid G_GNUC_UNUSED) { @@ -997,7 +997,7 @@ int virNetDevGetVLanID(const char *ifname G_GNUC_UNUSED, _("Unable to get VLAN on this platform")); return -1; } -#endif /* ! SIOCGIFVLAN */ +#endif /* ! __linux__ */
/**

The headers required by virnetdevbridge.c have all exited since before Linux moved to git. It is sufficient to check for just one of them in order to give an error message about needing kernel headers installed. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build index f28af30936..79f9d47520 100644 --- a/meson.build +++ b/meson.build @@ -628,19 +628,11 @@ foreach name : headers endif endforeach -# check for kernel headers required by src/util/virnetdevbridge.c +# check for kernel header required by src/util/virnetdevbridge.c if host_machine.system() == 'linux' - required_headers = [ - 'linux/param.h', - 'linux/sockios.h', - 'linux/if_bridge.h', - 'linux/if_tun.h', - ] - foreach name : required_headers - if not cc.has_header(name) - error('You must install kernel-headers in order to compile libvirt with QEMU or LXC support') - endif - endforeach + if not cc.has_header('linux/sockios.h') + error('You must install kernel-headers in order to compile libvirt with QEMU or LXC support') + endif endif -- 2.38.1

The DEVLINK_CMD_ESWITCH_GET constant was introduced to Linux in commit adf200f31c000d707e4afe238ed1d1199e0cce7c Author: Jiri Pirko <jiri@mellanox.com> Date: Thu Feb 9 15:54:33 2017 +0100 devlink: fix the name of eswitch commands This is old enough that all our supported platforms can be assumed to have this feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 11 ----------- src/util/virnetdev.c | 6 ++---- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/meson.build b/meson.build index 79f9d47520..30dd797ee5 100644 --- a/meson.build +++ b/meson.build @@ -613,11 +613,6 @@ headers = [ 'xlocale.h', ] -if host_machine.system() == 'linux' - # check for DEVLINK_CMD_ESWITCH_GET - headers += 'linux/devlink.h' -endif - if host_machine.system() == 'freebsd' headers += 'libutil.h' endif @@ -652,12 +647,6 @@ symbols = [ if host_machine.system() == 'linux' symbols += [ - # check for DEVLINK_CMD_ESWITCH_GET - # Assume DEVLINK_ESWITCH_MODE_SWITCHDEV is also available, as it was - # introudced in kernel 4.8 along with the original spelling of this - # constant (DEVLINK_CMD_ESWITCH_MODE_GET, not supported by libvirt). - [ 'linux/devlink.h', 'DEVLINK_CMD_ESWITCH_GET' ], - # check for VHOST_VSOCK_SET_GUEST_CID [ 'linux/vhost.h', 'VHOST_VSOCK_SET_GUEST_CID' ], diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 9b0f26c1f9..904ea095cf 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -44,6 +44,7 @@ # include <linux/if_vlan.h> # include <linux/types.h> # include <linux/ethtool.h> +# include <linux/devlink.h> # define VIR_NETDEV_FAMILY AF_UNIX #elif defined(WITH_STRUCT_IFREQ) && defined(AF_LOCAL) # define VIR_NETDEV_FAMILY AF_LOCAL @@ -56,9 +57,6 @@ # include <net/if_dl.h> #endif -#if WITH_LINUX_DEVLINK_H -# include <linux/devlink.h> -#endif #ifndef IFNAMSIZ # define IFNAMSIZ 16 @@ -3112,7 +3110,7 @@ virNetDevGetEthtoolFeatures(const char *ifname, } -# if defined(WITH_LIBNL) && WITH_DECL_DEVLINK_CMD_ESWITCH_GET +# if defined(WITH_LIBNL) /** * virNetDevGetFamilyId: -- 2.38.1

The linux/magic.h header has existed since commit e18fa700c9a31360bc8f193aa543b7ef7b39a06b Author: Jeff Garzik <jeff@garzik.org> Date: Sun Sep 24 11:13:19 2006 -0400 Move several *_SUPER_MAGIC symbols to include/linux/magic.h. This is old enough that all our supported platforms can be assumed to have this header. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 1 - src/util/virfile.c | 4 +--- tests/securityselinuxhelper.c | 4 +--- tests/virfilemock.c | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 30dd797ee5..612257a351 100644 --- a/meson.build +++ b/meson.build @@ -596,7 +596,6 @@ headers = [ 'ifaddrs.h', 'libtasn1.h', 'linux/kvm.h', - 'linux/magic.h', 'mntent.h', 'net/ethernet.h', 'net/if.h', diff --git a/src/util/virfile.c b/src/util/virfile.c index 7b37d6888e..feb0d7f8ba 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -62,9 +62,7 @@ #include <sys/file.h> #ifdef __linux__ -# if WITH_LINUX_MAGIC_H -# include <linux/magic.h> -# endif +# include <linux/magic.h> # include <sys/statfs.h> # include <linux/loop.h> # include <sys/ioctl.h> diff --git a/tests/securityselinuxhelper.c b/tests/securityselinuxhelper.c index 24c9f3841c..c32c90c17e 100644 --- a/tests/securityselinuxhelper.c +++ b/tests/securityselinuxhelper.c @@ -23,9 +23,7 @@ * detected. */ #include "virmock.h" -#if WITH_LINUX_MAGIC_H -# include <linux/magic.h> -#endif +#include <linux/magic.h> #include <selinux/selinux.h> #include <selinux/label.h> #include <sys/vfs.h> diff --git a/tests/virfilemock.c b/tests/virfilemock.c index 093a8d7cf0..4f1b8aecd7 100644 --- a/tests/virfilemock.c +++ b/tests/virfilemock.c @@ -21,7 +21,7 @@ #include <stdio.h> #include <mntent.h> #include <sys/vfs.h> -#if WITH_LINUX_MAGIC_H +#ifdef __linux__ # include <linux/magic.h> #endif -- 2.38.1

The VHOST_VSOCK_SET_GUEST_CID constant was introduced to Linux in commit 433fc58e6bf2c8bd97e57153ed28e64fd78207b8 Author: Asias He <asias@redhat.com> Date: Thu Jul 28 15:36:34 2016 +0100 VSOCK: Introduce vhost_vsock.ko This is old enough that all our supported platforms can be assumed to have this feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 3 --- src/util/virvsock.c | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 612257a351..95bc89ec52 100644 --- a/meson.build +++ b/meson.build @@ -646,9 +646,6 @@ symbols = [ if host_machine.system() == 'linux' symbols += [ - # check for VHOST_VSOCK_SET_GUEST_CID - [ 'linux/vhost.h', 'VHOST_VSOCK_SET_GUEST_CID' ], - # Check if we have new enough kernel to support BPF devices for cgroups v2 [ 'linux/bpf.h', 'BPF_PROG_QUERY' ], [ 'linux/bpf.h', 'BPF_CGROUP_DEVICE' ], diff --git a/src/util/virvsock.c b/src/util/virvsock.c index 4bbbf78167..c6f8b362b8 100644 --- a/src/util/virvsock.c +++ b/src/util/virvsock.c @@ -21,7 +21,7 @@ # include <sys/ioctl.h> #endif -#if WITH_DECL_VHOST_VSOCK_SET_GUEST_CID +#ifdef __linux__ # include <linux/vhost.h> #endif @@ -35,7 +35,7 @@ VIR_LOG_INIT("util.vsock"); -#if WITH_DECL_VHOST_VSOCK_SET_GUEST_CID +#ifdef __linux__ static int virVsockSetGuestCidQuiet(int fd, unsigned int guest_cid) -- 2.38.1

The BPF_PROG_QUERY constant was introduced to Linux in commit defd9c476fa6b01b4eb5450452bfd202138decb7 Author: Alexei Starovoitov <ast@kernel.org> Date: Mon Oct 2 22:50:26 2017 -0700 libbpf: sync bpf.h This is old enough that all our supported platforms can be assumed to have this feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 1 - src/util/virbpf.c | 6 +++--- src/util/virbpf.h | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 95bc89ec52..790d52ec8d 100644 --- a/meson.build +++ b/meson.build @@ -647,7 +647,6 @@ symbols = [ if host_machine.system() == 'linux' symbols += [ # Check if we have new enough kernel to support BPF devices for cgroups v2 - [ 'linux/bpf.h', 'BPF_PROG_QUERY' ], [ 'linux/bpf.h', 'BPF_CGROUP_DEVICE' ], ] endif diff --git a/src/util/virbpf.c b/src/util/virbpf.c index 1169b99d07..34abf6f9b4 100644 --- a/src/util/virbpf.c +++ b/src/util/virbpf.c @@ -24,7 +24,7 @@ VIR_LOG_INIT("util.bpf"); #define VIR_FROM_THIS VIR_FROM_BPF -#if WITH_SYS_SYSCALL_H && WITH_DECL_BPF_PROG_QUERY +#ifdef __linux__ # include <sys/syscall.h> # include <unistd.h> @@ -292,7 +292,7 @@ virBPFDeleteElem(int mapfd, } -#else /* !WITH_SYS_SYSCALL_H || !WITH_DECL_BPF_PROG_QUERY */ +#else /* ! __linux__ */ int @@ -420,4 +420,4 @@ virBPFDeleteElem(int mapfd G_GNUC_UNUSED, errno = ENOSYS; return -1; } -#endif /* !WITH_SYS_SYSCALL_H || !WITH_DECL_BPF_PROG_QUERY */ +#endif /* !__linux__ */ diff --git a/src/util/virbpf.h b/src/util/virbpf.h index 1eafce86c0..cf21ac2d40 100644 --- a/src/util/virbpf.h +++ b/src/util/virbpf.h @@ -18,7 +18,7 @@ #pragma once -#if WITH_DECL_BPF_PROG_QUERY +#ifdef __linux__ # include <linux/bpf.h> @@ -171,7 +171,7 @@ .imm = 0, \ }) -#else /* WITH_DECL_BPF_PROG_QUERY */ +#else /* ! __linux__ */ struct bpf_prog_info; struct bpf_map_info; @@ -191,7 +191,7 @@ struct bpf_insn; # define VIR_BPF_CALL_INSN(func) # define VIR_BPF_EXIT_INSN() -#endif /* WITH_DECL_BPF_PROG_QUERY */ +#endif /* ! __linux__ */ int virBPFCreateMap(unsigned int mapType, -- 2.38.1

The BPF_CGROUP_DEVICE constant was introduced to Linux in commit ebc614f687369f9df99828572b1d85a7c2de3d92 Author: Roman Gushchin <roman.gushchin@linux.dev> Date: Sun Nov 5 08:15:32 2017 -0500 bpf, cgroup: implement eBPF-based device controller for cgroup v2 This is old enough that all our supported platforms can be assumed to have this feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- meson.build | 7 ------- src/util/vircgroupv2devices.c | 10 +++++----- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build index 790d52ec8d..e48e63ef01 100644 --- a/meson.build +++ b/meson.build @@ -644,13 +644,6 @@ symbols = [ [ 'sched.h', 'cpu_set_t' ], ] -if host_machine.system() == 'linux' - symbols += [ - # Check if we have new enough kernel to support BPF devices for cgroups v2 - [ 'linux/bpf.h', 'BPF_CGROUP_DEVICE' ], - ] -endif - foreach symbol : symbols if cc.has_header_symbol(symbol[0], symbol[1], args: '-D_GNU_SOURCE', prefix: symbol.get(2, '')) conf.set('WITH_DECL_@0@'.format(symbol[1].to_upper()), 1) diff --git a/src/util/vircgroupv2devices.c b/src/util/vircgroupv2devices.c index 1769c499c8..05818c4130 100644 --- a/src/util/vircgroupv2devices.c +++ b/src/util/vircgroupv2devices.c @@ -17,13 +17,13 @@ */ #include <config.h> -#if WITH_DECL_BPF_CGROUP_DEVICE +#if __linux__ # include <fcntl.h> # include <linux/bpf.h> # include <sys/stat.h> # include <sys/syscall.h> # include <sys/types.h> -#endif /* !WITH_DECL_BPF_CGROUP_DEVICE */ +#endif /* __linux__ */ #include "internal.h" @@ -41,7 +41,7 @@ VIR_LOG_INIT("util.cgroup"); #define VIR_FROM_THIS VIR_FROM_CGROUP -#if WITH_DECL_BPF_CGROUP_DEVICE +#ifdef __linux__ bool virCgroupV2DevicesAvailable(virCgroup *group) { @@ -583,7 +583,7 @@ virCgroupV2DevicesGetPerms(int perms, return ret; } -#else /* !WITH_DECL_BPF_CGROUP_DEVICE */ +#else /* !__linux__ */ bool virCgroupV2DevicesAvailable(virCgroup *group G_GNUC_UNUSED) { @@ -634,7 +634,7 @@ virCgroupV2DevicesGetPerms(int perms G_GNUC_UNUSED, { return 0; } -#endif /* !WITH_DECL_BPF_CGROUP_DEVICE */ +#endif /* !__linux__ */ uint64_t -- 2.38.1

On a Thursday in 2022, Daniel P. Berrangé wrote:
We have alot of checks for Linux kernel features that are obsolete since our supported platform matrix lets us assume new enough kernel versions. Removing the checks will speed up the meson phase and reduce the tangle of #ifdefs in the code.
I thought I could remove the check for linux/kvm.h but for some reason our code in virhostpcu.c / cpu_x86.c is enabling the codebases even on FreeBSD, which I find kind of odd. Does FreeBSD really ship a linux/kvm.h ?
¯\_ (ツ)_/¯
Daniel P. Berrangé (21): meson: remove obsolete check for LOOP_CTL_GET_FREE meson: remove obsolete check for EPOLL_CLOEXEC meson: remove obsolete check for LO_FLAGS_AUTOCLEAR meson: drop check for unshare() netdev: simplify check for ethtool functionality meson: remove obsolete check for ETHTOOL_GGSO meson: remove obsolete check for ETHTOOL_GGRO meson: remove obsolete check for ETHTOOL_GFLAGS meson: remove obsolete check for ETH_FLAG_LRO meson: remove obsolete check for ETH_FLAG_TXVLAN/RXVLAN meson: remove obsolete check for ETH_FLAG_NTUPLE meson: remove obsolete check for ETH_FLAG_RXHASH meson: remove obsolete check for ETHTOOL_GFEATURES meson: remove obsolete check for ETHTOOL_GCOALESCE meson: remove obsolete check for GET_VLAN_VID_CMD meson: simplify check for virnetdevbridge.c headers meson: remove obsolete check for DEVLINK_CMD_ESWITCH_GET meson: remove obsolete check for linux/magic.h meson: remove obsolete check for VHOST_VSOCK_SET_GUEST_CID meson: remove obsolete check for BPF_PROG_QUERY meson: remove obsolete check for BPF_CGROUP_DEVICE
meson.build | 82 +++-------------------------------- src/util/virbpf.c | 6 +-- src/util/virbpf.h | 6 +-- src/util/vircgroupv2devices.c | 10 ++--- src/util/virfile.c | 15 ++----- src/util/virnetdev.c | 65 ++++----------------------- src/util/virvsock.c | 4 +- tests/securityselinuxhelper.c | 4 +- tests/virfilemock.c | 2 +- 9 files changed, 32 insertions(+), 162 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (3)
-
Daniel P. Berrangé
-
Jonathon Jongsma
-
Ján Tomko