diff --git a/libpod/define/info.go b/libpod/define/info.go index cc47f7f1b6..3f898c877d 100644 --- a/libpod/define/info.go +++ b/libpod/define/info.go @@ -27,26 +27,27 @@ type SecurityInfo struct { // HostInfo describes the libpod host type HostInfo struct { - Arch string `json:"arch"` - BuildahVersion string `json:"buildahVersion"` - CgroupManager string `json:"cgroupManager"` - CgroupsVersion string `json:"cgroupVersion"` - CgroupControllers []string `json:"cgroupControllers"` - Conmon *ConmonInfo `json:"conmon"` - CPUs int `json:"cpus"` - CPUUtilization *CPUUsage `json:"cpuUtilization"` - DatabaseBackend string `json:"databaseBackend"` - Distribution DistributionInfo `json:"distribution"` - EventLogger string `json:"eventLogger"` - Hostname string `json:"hostname"` - IDMappings IDMappings `json:"idMappings,omitempty"` - Kernel string `json:"kernel"` - LogDriver string `json:"logDriver"` - MemFree int64 `json:"memFree"` - MemTotal int64 `json:"memTotal"` - NetworkBackend string `json:"networkBackend"` - OCIRuntime *OCIRuntimeInfo `json:"ociRuntime"` - OS string `json:"os"` + Arch string `json:"arch"` + BuildahVersion string `json:"buildahVersion"` + CgroupManager string `json:"cgroupManager"` + CgroupsVersion string `json:"cgroupVersion"` + CgroupControllers []string `json:"cgroupControllers"` + Conmon *ConmonInfo `json:"conmon"` + CPUs int `json:"cpus"` + CPUUtilization *CPUUsage `json:"cpuUtilization"` + DatabaseBackend string `json:"databaseBackend"` + Distribution DistributionInfo `json:"distribution"` + EventLogger string `json:"eventLogger"` + Hostname string `json:"hostname"` + IDMappings IDMappings `json:"idMappings,omitempty"` + Kernel string `json:"kernel"` + LogDriver string `json:"logDriver"` + MemFree int64 `json:"memFree"` + MemTotal int64 `json:"memTotal"` + NetworkBackend string `json:"networkBackend"` + NetworkBackendInfo *NetavarkInfo `json:"networkBackendInfo,omitempty"` + OCIRuntime *OCIRuntimeInfo `json:"ociRuntime"` + OS string `json:"os"` // RemoteSocket returns the UNIX domain socket the Podman service is listening on RemoteSocket *RemoteSocket `json:"remoteSocket,omitempty"` RuntimeInfo map[string]interface{} `json:"runtimeInfo,omitempty"` @@ -103,6 +104,16 @@ type ConmonInfo struct { Version string `json:"version"` } +// NetavarkInfo describes the netavark executable being used +type NetavarkInfo struct { + Package string `json:"package"` + Path string `json:"path"` + Version string `json:"version"` + DNSPackage string `json:"dnsPackage,omitempty"` + DNSPath string `json:"dnsPath,omitempty"` + DNSVersion string `json:"dnsVersion,omitempty"` +} + // OCIRuntimeInfo describes the runtime (crun or runc) being // used with podman type OCIRuntimeInfo struct { diff --git a/libpod/info.go b/libpod/info.go index a612a7bf61..394c734f7a 100644 --- a/libpod/info.go +++ b/libpod/info.go @@ -14,6 +14,7 @@ import ( "github.com/containers/buildah" "github.com/containers/buildah/pkg/util" + "github.com/containers/common/libnetwork/types" "github.com/containers/image/v5/pkg/sysregistriesv2" "github.com/containers/podman/v4/libpod/define" "github.com/containers/podman/v4/libpod/linkmode" @@ -118,6 +119,30 @@ func (r *Runtime) hostInfo() (*define.HostInfo, error) { SwapFree: mi.SwapFree, SwapTotal: mi.SwapTotal, } + if info.NetworkBackend == string(types.Netavark) { + path, err := r.config.FindHelperBinary(info.NetworkBackend, true) + if err != nil { + logrus.Errorf("Getting host info on netavark: %v", err) + } else { + version, err := programVersion(path) + if err != nil { + logrus.Errorf("Getting netavark version: %v", err) + } + info.NetworkBackendInfo = &define.NetavarkInfo{ + Path: path, + Package: packageVersion(path), + Version: version, + } + path, err = r.config.FindHelperBinary("aardvark-dns", true) + if err == nil { + version, _ = programVersion(path) + info.NetworkBackendInfo.DNSPath = path + info.NetworkBackendInfo.DNSPackage = packageVersion(path) + info.NetworkBackendInfo.DNSVersion = version + } + } + } + if err := r.setPlatformHostInfo(&info); err != nil { return nil, err } diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats index fb5b722d81..7feffe986b 100644 --- a/test/system/500-networking.bats +++ b/test/system/500-networking.bats @@ -276,6 +276,14 @@ load helpers.network run_podman 1 network rm $mynetname } +@test "podman info netavark" { + if !is_netavark; then + skip "only meaningful for netavark" + fi + run_podman info --format '{{ .Host.NetworkBackendInfo }}' + assert "$output" =~ "netavark" "NetworkBackendInfo should contain inforamation about netavark" +} + @test "podman network reload" { skip_if_remote "podman network reload does not have remote support"