[PATCH 4/5] virnetdevbridge: Include virnetlink.h always

Michal Privoznik via Devel posted 5 patches 3 months, 4 weeks ago
There is a newer version of this series
[PATCH 4/5] virnetdevbridge: Include virnetlink.h always
Posted by Michal Privoznik via Devel 3 months, 4 weeks ago
From: Michal Privoznik <mprivozn@redhat.com>

The whole point of virnetlink.h is that it hides away the build
time dependency on netlink. It wraps netlink functions in our
functions which then have a stub implementation in case netlink
support was disabled.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/util/virnetdevbridge.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index 3b54e2cb1e..70e78a9be6 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -23,6 +23,7 @@
 #include "virerror.h"
 #include "virfile.h"
 #include "virlog.h"
+#include "virnetlink.h"
 #include "virstring.h"
 
 #ifdef WITH_NET_IF_H
@@ -30,9 +31,6 @@
 #endif
 
 #ifdef __linux__
-# if defined(WITH_LIBNL)
-#  include "virnetlink.h"
-# endif
 # include <linux/sockios.h>
 # include <linux/param.h>     /* HZ                 */
 # include <linux/in6.h>
-- 
2.49.0
Re: [PATCH 4/5] virnetdevbridge: Include virnetlink.h always
Posted by Peter Krempa via Devel 3 months, 4 weeks ago
On Mon, May 12, 2025 at 15:37:15 +0200, Michal Privoznik via Devel wrote:
> From: Michal Privoznik <mprivozn@redhat.com>
> 
> The whole point of virnetlink.h is that it hides away the build
> time dependency on netlink. It wraps netlink functions in our
> functions which then have a stub implementation in case netlink
> support was disabled.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/util/virnetdevbridge.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
> index 3b54e2cb1e..70e78a9be6 100644
> --- a/src/util/virnetdevbridge.c
> +++ b/src/util/virnetdevbridge.c
> @@ -23,6 +23,7 @@
>  #include "virerror.h"
>  #include "virfile.h"
>  #include "virlog.h"
> +#include "virnetlink.h"
>  #include "virstring.h"
>  
>  #ifdef WITH_NET_IF_H
> @@ -30,9 +31,6 @@
>  #endif
>  
>  #ifdef __linux__
> -# if defined(WITH_LIBNL)
> -#  include "virnetlink.h"
> -# endif

While I could see point in dropping the '#if defined(WITH_LIBNL)' part,
in this file where there is already an '#ifdef __linux__' I think that
keeping it there makes a bit more sense. E.g. it'll break the build if
some of the netlink functions (even stubbed out) will be used in
non-linux code which is conidtionally compiled in this file already.

>  # include <linux/sockios.h>
>  # include <linux/param.h>     /* HZ                 */
>  # include <linux/in6.h>
> -- 
> 2.49.0
>