[PATCH] Replace if_tap check with pf check

Nimish Jain posted 1 patch 2 weeks, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20260627063938.43041-1-unauthorizen@gmail.com
tools/virt-host-validate-bhyve.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[PATCH] Replace if_tap check with pf check
Posted by Nimish Jain 2 weeks, 3 days ago
if_tap is bundled with if_tuntap and usually included in the kernel.
Instead, check whether a firewall is present, otherwise network driver will not work.

Signed-off-by: Nimish Jain <unauthorizen@gmail.com>
---
 tools/virt-host-validate-bhyve.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/virt-host-validate-bhyve.c b/tools/virt-host-validate-bhyve.c
index d7a409db9d..539c6f85f3 100644
--- a/tools/virt-host-validate-bhyve.c
+++ b/tools/virt-host-validate-bhyve.c
@@ -51,7 +51,7 @@ int virHostValidateBhyve(void)
     int fileid = 0;
     g_autofree struct kld_file_stat *stat = g_new0(struct kld_file_stat, 1);
     bool vmm_loaded = false;
-    bool if_tap_loaded = false;
+    bool pf_loaded = false;
     bool if_bridge_loaded = false;
     bool nmdm_loaded = false;
 
@@ -62,8 +62,8 @@ int virHostValidateBhyve(void)
 
         if (STREQ(stat->name, "vmm.ko"))
             vmm_loaded = true;
-        else if (STREQ(stat->name, "if_tap.ko"))
-            if_tap_loaded = true;
+        else if (STREQ(stat->name, "pf.ko"))
+            pf_loaded = true;
         else if (STREQ(stat->name, "if_bridge.ko"))
             if_bridge_loaded = true;
         else if (STREQ(stat->name, "nmdm.ko"))
@@ -71,7 +71,7 @@ int virHostValidateBhyve(void)
     }
 
     MODULE_STATUS_FAIL(vmm, "will not be able to start VMs");
-    MODULE_STATUS_WARN(if_tap, "networking will not work");
+    MODULE_STATUS_WARN(pf, "network driver will not work");
     MODULE_STATUS_WARN(if_bridge, "bridged networking will not work");
     MODULE_STATUS_WARN(nmdm, "nmdm console will not work");
 
-- 
2.39.5 (Apple Git-154)
Re: [PATCH] Replace if_tap check with pf check
Posted by Roman Bogorodskiy 2 weeks, 1 day ago
  Nimish Jain wrote:

> if_tap is bundled with if_tuntap and usually included in the kernel.
> Instead, check whether a firewall is present, otherwise network driver will not work.

Hi,

As mentioned in the github pull request, this commit addresses two not
closely related issues:

 1. incorrect / outdated tap(4) device detection
 2. missing pf(4) detection

I think it makes sense to address them in separate commits.
I think it is also better to fix the tap(4) detection instead of
removing it.

> Signed-off-by: Nimish Jain <unauthorizen@gmail.com>
> ---
>  tools/virt-host-validate-bhyve.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/virt-host-validate-bhyve.c b/tools/virt-host-validate-bhyve.c
> index d7a409db9d..539c6f85f3 100644
> --- a/tools/virt-host-validate-bhyve.c
> +++ b/tools/virt-host-validate-bhyve.c
> @@ -51,7 +51,7 @@ int virHostValidateBhyve(void)
>      int fileid = 0;
>      g_autofree struct kld_file_stat *stat = g_new0(struct kld_file_stat, 1);
>      bool vmm_loaded = false;
> -    bool if_tap_loaded = false;
> +    bool pf_loaded = false;
>      bool if_bridge_loaded = false;
>      bool nmdm_loaded = false;
>  
> @@ -62,8 +62,8 @@ int virHostValidateBhyve(void)
>  
>          if (STREQ(stat->name, "vmm.ko"))
>              vmm_loaded = true;
> -        else if (STREQ(stat->name, "if_tap.ko"))
> -            if_tap_loaded = true;
> +        else if (STREQ(stat->name, "pf.ko"))
> +            pf_loaded = true;
>          else if (STREQ(stat->name, "if_bridge.ko"))
>              if_bridge_loaded = true;
>          else if (STREQ(stat->name, "nmdm.ko"))
> @@ -71,7 +71,7 @@ int virHostValidateBhyve(void)
>      }
>  
>      MODULE_STATUS_FAIL(vmm, "will not be able to start VMs");
> -    MODULE_STATUS_WARN(if_tap, "networking will not work");
> +    MODULE_STATUS_WARN(pf, "network driver will not work");

This message could more specific, e.g. 
"the 'pf' firewall backend will not work".

>      MODULE_STATUS_WARN(if_bridge, "bridged networking will not work");
>      MODULE_STATUS_WARN(nmdm, "nmdm console will not work");
>  
> -- 
> 2.39.5 (Apple Git-154)
>