Commit Graph

94 Commits

Author SHA1 Message Date
Chris Evich e50941aaa1
Cirrus: Update CI VM images to F37
Thanks to @Luap99 for the test fix.

Signed-off-by: Chris Evich <cevich@redhat.com>
2023-03-15 14:11:03 -04:00
Aditya R 602f4b0792
netavark,NetworkUpdate: NetworkUpdateOptions must be IP addresses
We enforced NetworkDNSServers to be IP addresses and we follow this
enfore rule while a user is creating network, see comment
https://github.com/containers/common/pull/1237#pullrequestreview-1188001727
and PR https://github.com/containers/common/pull/1237

Following check was missed in `NetworkUpdateOptions` hence add this
check now.

Signed-off-by: Aditya R <arajan@redhat.com>
2023-03-10 19:41:18 +05:30
Paul Holzinger 5dff71c396
fix netavark IgnoreIfExists config test flake
We cannot compare network with Expect().To(Equal()), the internal
time.Time is not equal after parsing from file. There is some internal
field offset that can be different but the date is still the same. Other
tests have the same problem and to circumvent this we use EqualNetwork()
there. Do the same here.

Fixes #1335

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-02-20 15:13:09 +01:00
T K Chandra Hasan 790e87b8e7 Closes #15830 Support docker-specific network create options via CLI
Signed-off-by: T K Chandra Hasan <t.k.chandra.hasan@ibm.com>
2023-02-10 21:51:48 +05:30
Daniel J Walsh 87412307e5
Don't use lockfile.Locker, it is deprecated
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-02-06 15:00:30 -05:00
OpenShift Merge Robot ac78fcccf8
Merge pull request #1292 from baude/adddhcpmacvlanback
Enable DHCP macvlan
2023-01-26 14:41:50 -05:00
Brent Baude 509ce862ec Enable DHCP macvlan
With progress on netavark-dhcp-proxy, we can begin to macvlan with dhcp
back into the fold for netavark.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-01-17 08:15:31 -06:00
Paul Holzinger afca07b384
libnetwork/cni: mkdir network config dir
Commit 4bf13f4b29 caused a regression, previously the lockfile
package create the config directory. Now this is no longer the case
so we have to create it explicitly.

Note that netavark already did this so no change is needed there.

This was reported by the RHEL QE team.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-01-17 14:56:47 +01:00
Daniel J Walsh 8f4d13b90d
Compile regex on demand not in init
Should speed up app startup time a little since the compile
happens for all users of the library. Compile only on use.

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-01-12 16:03:02 -05:00
Paul Holzinger 4bf13f4b29
libnetwork: change lock path to tmpfs for root
The default /etc/containers/networks location might not be writeable,
while this breaks podman network create it does not need to break all
podman commands since the lock is created on libpod initialization.

ref https://github.com/containers/common/pull/1270

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-01-05 16:46:42 +01:00
Paul Holzinger 0bada26de2
pkg/netns: UnmountNS() accept netns path as string
I want to switch podman over to only using strings for the netns path.
So we no longer pass this interface around. Buildah doesn't use this so
we only need to fix it in Podman. I have a WIP PR[1] for that.

[1] https://github.com/containers/podman/pull/16756

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-12-07 14:53:47 +01:00
Aditya R 403bec6fd3
libnetwork: extend API to support NetworkUpdate
New features in netavark/aardvark allows users to update network dns
servers and all the containers attached to those networks uses updated
resolvers.

Following PR adds support in `libnetwork` to support

* Add support for higher level `NetworkUpdate` API
* Add support for `Update` exec call which can invoke netavark with a
  new update option added here: https://github.com/containers/netavark/pull/503

Signed-off-by: Aditya R <arajan@redhat.com>
2022-12-07 07:53:02 +05:30
OpenShift Merge Robot eb48ebbf8c
Merge pull request #1250 from ygalblum/network_ignore
Libnetwork: Add IgnoreIfExists flag to network create method
2022-12-06 06:07:49 -05:00
OpenShift Merge Robot de8e6a821a
Merge pull request #1256 from Luap99/cni-ipam-none
libnetwork/cni: fix panic with ipam driver none
2022-12-06 03:38:42 -05:00
Paul Holzinger 3803bc2a02
libnetwork/cni: fix panic with ipam driver none
When creating macvlan or ipvlan network configs with the none ipam
driver we would always cause a segfault because of a nil pointer
dereference.

Add a test for both to prevent a regression.

Fixes containers/podman#16620

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-12-05 17:55:03 +01:00
Daniel J Walsh 4f8757f688
Vendor in latest containers/(storage, image)
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-12-05 10:04:10 -05:00
Ygal Blum fcab41d586 Libnetwork: Add NetworkCreateOptions to the NetworkCreate method
For now, only add IgnoreIfExists flag.
Having this flag is very useful when using scripts or systemd unit files

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2022-12-05 15:57:15 +02:00
Aditya R 0d903e38ed
libnetwork, Network: add field NetworkDNSServers for network scoped dns
libnetwork must allow to pass network_dns_servers so aardvark and
netavark can consume it and enabled network scoped dns.

Feature implemented at netavark and aardvark end
* Netavark: https://github.com/containers/netavark/pull/497

Signed-off-by: Aditya R <arajan@redhat.com>
2022-11-21 21:29:14 +05:30
Matthew Heon 49c183885b Add support for route metric in network configs
All the gruntwork is done by Netavark, so all that's needed it to
know the key exists and verify that it parses as a uint.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2022-11-10 16:09:15 -05:00
Paul Holzinger 63b7d867cb
libnetwork/netavark: disable dns for macvlan
This is not supported in netavark so we should set to false by default
to make sure podman inspect will show the correct info.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-10-25 16:14:19 +02:00
OpenShift Merge Robot 98295c0109
Merge pull request #1193 from vrothberg/bump-golangci
bump to golangci-lint v1.50.0
2022-10-17 10:23:28 -04:00
Valentin Rothberg 4a4d9056a3 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
Aditya R def117654f
libnetwork: add DNSServers to NetworkOptions
Netavark now accets `dns_servers` for each container which allows
containers to use custom DNS servers as resolvers instead of falling
back to host's resolver.

Following field allows callers to libnetwork to pass newly added field
to `netavark` and `aarvark-dns`

Actual feature implemented
* https://github.com/containers/aardvark-dns/pull/240
* https://github.com/containers/netavark/pull/452

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]

Signed-off-by: Aditya R <arajan@redhat.com>
2022-10-17 15:42:35 +05:30
Paul Holzinger d8d9c467ad
libnetwork/types: add correct swagger types
Both MAC and IP addresses are strings when serialized to JSON or
deserialized from JSON. By default swagger will show a byte array which
is wrong so we have to manually overwrite these fields.

Required for https://github.com/containers/podman/issues/13342
However we still have to update our swagger version to at least 0.30 in
podman to make it work.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-14 12:47:59 +02:00
Daniel J Walsh b1d5206441
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 50c2c97c3b 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
openshift-ci[bot] fc74878c20
Merge pull request #1088 from cdoern/prune
move prune filter parsing to common
2022-07-16 07:56:36 +00:00
Charlie Doern ee08c8772e move prune filter parsing to common
there was some eerily similar code in c/common and in podman for
creating filter functions for various types. Move some of it here
and add support for the label!= filter in libnetwork only. Libimage already supports it.

after this merges, will file a PR with the fix for containers within podman as well

see containers/podman#14182

Signed-off-by: Charlie Doern <cdoern@redhat.com>
2022-07-15 09:56:02 -04:00
openshift-ci[bot] 7979683170
Merge pull request #1077 from saschagrunert/errors
Switch to golang native error wrapping
2022-07-12 11:21:37 +00:00
Sascha Grunert e6f0784b23
Switch to golang native error wrapping
`github.com/pkg/errors` is deprecated since quite some time so we now
use the native error wrapping for more idiomatic golang.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-12 10:54:07 +02:00
Dominique Martinet f0158d87cf 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 81a4dfd78c 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
Paul Holzinger f4312dcd84
libnetwork: add constants for network options
Duplicating strings is evil and can result in typos, lets expose the
options as constants.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-07-07 16:56:16 +02:00
cdoern a30f995291
libnetwork/netavark: add isolate option
depends on containers/netavark#275

Signed-off-by: cdoern <cdoern@redhat.com>
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-07-07 16:40:30 +02:00
Paul Holzinger 949781323c
libnetwork/cni: add isolate option
Add the isolate option to cni. This uses the ingress policy from the firewall
plugin.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-07-07 16:26:11 +02:00
Paul Holzinger 3fd22689ed
resolvconf: add option to keep orig resolv content
Even when a custom nameserver is set by the caller they may wish to
still keep the original nameserver too. This is needed by podman/buildah
when they only want to add the slirp4netns dns ip at the beginning for
example.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-05-23 16:09:10 +02:00
Paul Holzinger 89b875a02b
libnetwork: add new resolvconf package
both buildah and podman currently use a slightly different resolvconf lib,
to prevent duplication and having to fix bugs twice they should both use
this new package instead.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-05-23 16:09:03 +02:00
Doug Rabson 0bffaa207f Build libnetwork/netavark on FreeBSD
This only gets the libnetwork part to build - I have not tried to
get the rest of netavark to build on FreeBSD.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-05-14 10:55:36 +01:00
Doug Rabson 777e9acbd2 Build libnetwork/cni on FreeBSD
This is enough to get basic CNI networking working on FreeBSD

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-05-14 10:55:32 +01:00
Doug Rabson 58b1927a56 Build libnetwork/network on FreeBSD
Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-05-12 18:13:24 +01:00
Paul Holzinger bba4bb8129
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
Daniel J Walsh 7dc7657bb9
Change rootfull->rootful
[NO NEW TESTS NEEDED] Just a docs change.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-04-25 13:50:12 -04:00
Jason T. Greene 0db57c8ff1 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
Paul Holzinger 7cb3f0d8ce
libnetwork/etchosts: add GetBaseHostFile()
Add helper function to convert the base_hosts_file config value to a
actual path. It is important to use securejoin to make sure that
containers cannot point to a file on the hosts via a symlink.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-21 11:48:55 +02:00
Paul Holzinger 88163a6db7
libnetwork/etchosts: add GetNetworkHostEntries()
Add function to get all host entries from a given network status.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-21 11:48:55 +02:00
Paul Holzinger 56484929a5
add host_containers_internal_ip to containers.conf
Set the ip for the host.containers.internal entry in the containers /etc/hosts
file. This can be set to "none" to disable adding this entry. By default it
will automatically choose the host ip.

Also add a function to get the correct host.containers.internal ip. This
should be used by podman and buildah and then passed to the New()
function.

Ref https://github.com/containers/podman/issues/13224

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-21 11:48:36 +02:00
Paul Holzinger b5c27e2817
add base_hosts_file field to containers.conf
base_hosts_file can be used to overwrite the default base host file
/etc/hosts which is used to copy hosts entries from this file into the
containers /etc/hosts file. As special value "image" can be used to copy
the entries from the image hosts file or "none" to not use a base file
at all. IF the value is empty we should use /etc/hosts as default.

Ref https://github.com/containers/podman/issues/13277
Ref https://github.com/containers/podman/issues/13748

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-21 11:39:56 +02:00
Paul Holzinger 3b99bea9c2
add new etchosts package
Add a new libnetwork/etchosts package to manage reading/writing hosts files.
This package exports four functions New(), Add(), AddIfExists() and Remove().
See the godoc comments on the functions.

Both podman and buildah should use this functions to make sure files are
generated identical.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-21 11:39:55 +02:00
Kir Kolyshkin b408d782e6 libnetwork: rm nolint:golint hints
Those were added by commit 39a8401bf, 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 98ddeca2e2 libnetwork/netavark:: suppress errcheck warn
This one:

	libnetwork/netavark/ipam_test.go:45:22: Error return value is not checked (errcheck)
			networkInterface = libpodNet.(*netavarkNetwork)
					   ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-04-09 17:57:03 -07:00