Commit Graph

28 Commits

Author SHA1 Message Date
Dan Čermák 95730e30c3 Gate CNI support behind the `cni` build tag
- add cni build tag to libnetwork/cni
- split libnetwork/network into multiple files so that cni support can be made
  optionally available
- add -cni build targets to Makefile and build for amd64 with and without cni
- add a simple upgrade mechanism if the user never set the network backend explicitly
- add cni build tag to .golangci.yml to prevent false positives

See also https://issues.redhat.com/browse/RUN-1943

Signed-off-by: Dan Čermák <dcermak@suse.com>
2024-01-30 09:18:31 +01:00
Oleksandr Redko ba4c7c98bb chore: remove outdated build constraints
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-03 22:56:00 +02:00
Paul Holzinger 9ebf5859ff libnetwork/{netavark,cni}: accept containers.conf
Just pass down the full containers.conf as this is needed by
rootlessnetns code, also remove the now duplicated fields and read the
options directly from the config struct.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-12-05 15:28:20 +01:00
Chetan Giradkar 41f0492c7f Add configurability to Netavark firewall driver
closes #1338

Signed-off-by: Chetan Giradkar <cgiradka@redhat.com>
2023-11-28 12:51:21 +00:00
Valentin Rothberg 5fb9ed7f84 pkg/config: turn NetavarkPluginDirs into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg 67a73c7cc6 pkg/config: turn CNIPluginDirs into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg de32d5a9f7 linters: enable dupword
Mostly monkey work to fix comments but there was also an error message.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-09-01 11:51:25 +02:00
Paul Holzinger 7966ad46e4 pkg/config: add netavark_plugin_dirs fields
Add config field to specify the location for the netavark plugins.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-04-04 18:20:12 +02:00
Valentin Rothberg e17483b871 bump to golangci-lint v1.50.0
Used `go fmt` rules to migrate away from deprecated functions, for
instance `gofmt -w -s -r 'ioutil.TempDir(a, b) -> os.MkdirTemp(a, b)'`

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-10-17 15:03:07 +02:00
Daniel J Walsh f8f4db6239 Ignore additionalstore images when deciding to use netavark or CNI
We are using CNI for systems that have run podman system reset, if
storage is setup with additional stores.  This change will ignore
additional store images and will use netarvark on clean systems.

[NO NEW TESTS NEEDED]

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2124887

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-09-08 13:29:42 -04:00
Matthew Heon 8bfe4fc505 Use an alternative CNI lock for read-only config dirs
When the configuration directory is on a read-only filesystem,
there's no risk of concurrency issues as there's no possibility
of changing anything. As such, while it prevents the use of our
default lock location, it also removes any need for a lock at
all.

Making the lock entirely optional is a lot of code, so instead of
doing that let's just put it in our temporary files directory,
where it can't hurt anything.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2022-08-17 14:59:25 -04:00
Dominique Martinet 2e8943d3f7 add network dns_bind_port setting and set NETAVARK_DNS_PORT from it
This commit allows using aardvark with an alternate port as per
implementation in containers/netavark#323

Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
2022-07-08 09:45:15 +09:00
Dominique Martinet 06b9bdd684 libnetwork/network/interface.go: fix typo in private function name
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
2022-07-08 08:07:37 +09:00
Doug Rabson 71784ae373 Build libnetwork/network on FreeBSD
Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-05-12 18:13:24 +01:00
Paul Holzinger cc110440e4 enable unparam, exportloopref and revive linters
unparam and exportloopref already work without changes.
For revive I had to silence many naming issues. I decided to silence them
instead of changing the name because I didn't want to break any code.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-05-06 13:32:35 +02:00
Jason T. Greene 77d8f70039 Deprecate MachineEnabled and replace with API
machine.IsPodmanMachine replaces MachineEnabled
machine.MachineHostType informs the type unknown, qemu, wsl, etc
machine.IsGvProxyBased used to make specific determinations re gvproxy

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-04-23 12:32:54 -05:00
Kir Kolyshkin 82bf88ed0c libnetwork: rm nolint:golint hints
Those were added by commit 4fcb18dca, but are apparently no longer
needed.

Reported-by: Paul Holzinger <pholzing@redhat.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-04-11 15:03:50 -07:00
Kir Kolyshkin b951b72412 Gofumpt the code
gofumpt is a stricter version of gofmt, basically making the code more
readable, and fixing the gocritic's octalLiterar warnings like this one:

	pkg/util/util_supported.go:26:17: octalLiteral: use new octal literal style, 0o722 (gocritic)
		return (perm & 0722) == 0700
			       ^

Generated by gofumpt -w .

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-04-09 16:50:11 -07:00
Valentin Rothberg 095aded91c go fmt: use go 1.18 conditional-build syntax
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-18 11:04:40 +01:00
Aditya R 8968d3fa1c netavark: warn only if network has DNSEnabled and aardvark binary is not found
Move generic warning to netavark/run and warns user if one or more
network has `DNSEnabled` and `aardvark-dns` binary is not set

Signed-off-by: Aditya R <arajan@redhat.com>
2022-03-04 11:03:24 +05:30
Aditya R d4c4a151e1 libnetwork: Fix warning when aarvark-dns is not found
Use appropriate variable when producing warning for missing
aardvark-dns. Current output variable will always be empty when
aarvark-dns is missing.

Closes: https://github.com/containers/podman/issues/13412

Signed-off-by: Aditya R <arajan@redhat.com>
2022-03-03 21:29:35 +05:30
Paul Holzinger f146736795 set DefaultSubnetPools for network backend
In commit 60766b5e5e I forgot to add the field here, without this the
config field from containers.conf is not used in backend.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-02-16 18:15:34 +01:00
Paul Holzinger 16febcdabe netavark: use aardvark-dns path from containers.conf
We need to use the configured path from containers.conf for the
aardvark-dns binary location.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-25 16:06:56 +01:00
Paul Holzinger 995cdaae8f netavark: use globally shared network config dir
Since the network namespace is shared for all rootful libpod instances
we also need to make sure to use the same network config dir and run dir
to ensure that we do not use the same subnet or ip for more than one
container.

Also update the documentation about the network_config_dir field.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-17 15:36:03 +01:00
Paul Holzinger 55acbe7f30 libnetwork: use atomic write for the backend file
It is possible that two processes write at the same time and this could
lead to an invalid value in the file.

I think this fixes a race condition which was observed in the buildah
integration tests.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-07 17:43:19 +01:00
Paul Holzinger 588325c4ae libnetwork: netavark use runrooot for ipam db
We should not use XDG_RUNTIME_DIR for the ipam db. This directory is
shared but we need the ipam db per storage. We can use the runroot for
this. It should be a tmpfs to reset the ipam assignments after a reboot.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-04 15:46:23 +01:00
Paul Holzinger 8893b57c6e libnetwork: remove unneeded Lockfile argument
If the caller can decide the lockfile path it is just more likely that
there is a lock missmatch due different lock names. We should always
just use the config dir and use a lock with a static name.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-04 15:46:23 +01:00
Paul Holzinger 25af87fbcc libnetwork: add function to get the default network backend
When the network backend is unset in the config we have to to figure out
if we need CNI or netavark. New installs should use netavark while
existing installs should continue to use CNI to prevent breaking
systems.

We use the following conditions to determine what backend to use:
1. read ${graphroot}/defaultNetworkBackend
2. find netavark binary (if not installed use CNI)
3. check containers, images and CNI networks and if there are some
   we have an existing install and should continue to use CNI

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-04 15:46:12 +01:00