Commit Graph

30 Commits

Author SHA1 Message Date
Saigusa Yasushi adbdd59591 libnetwork/netavark: add isolate option 'strict'
The strict isolate refuses to communicate with non-isolate and isolate.

Signed-off-by: Saigusa Yasushi <56156402+yassi-github@users.noreply.github.com>
2023-06-20 22:03:51 +09:00
Paul Holzinger f28b52d2ee libnetwork: handle id filter better
By default we should do a standard prefix match.
See https://github.com/containers/podman/issues/18471 for context.

Also use the c/storage regex package to only compile the regex when
needed.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-06-12 17:00:40 +02:00
Paul Holzinger e9c74cfce1 netavark: add bclim option for macvlan
see https://github.com/containers/netavark/pull/698

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-25 10:28:38 +02:00
Jan Hendrik Farr 97e2561e60 add static routes
Signed-off-by: Jan Hendrik Farr <github@jfarr.cc>
2023-05-24 10:11:08 +00:00
Paul Holzinger 7052cdf26a libnetwork/netavark: add plugin support
Users can now suplly custom network drivers which will execute the
netavark plugin to create the network. Netavark will execute the pluign
to setup/teardown the netns.
see https://github.com/containers/netavark/pull/509

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-04-04 18:17:50 +02:00
Paul Holzinger 510b51d2f6 libnetwork/netavark: error messages should start lower case
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-04-03 18:45:43 +02:00
Paul Holzinger 5a91ce3d7f libnetwork/netavark: combine ipvlan macvlan code
Remove the code duplication and share some code between the ipvlan and
macvlan config creation.

Also fixes a problem with the macvlan dhcp selection, we have to set the
driver to dhcp if it is unset and no subnets are given.
Ipvlan does not support DHCP because the interfaces share the same mac
address.

Added tests for both the mcvlan dhcp selection and the ipvlan creation.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-03-31 15:27:17 +02:00
Aditya R 6faa28dcf3 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 4e52d1e241 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 a34e72b144 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
Brent Baude cca00f477e 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
Aditya R a1673511b8 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
Ygal Blum f7978269e7 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 f1cb293c6e 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 6a357c2a24 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
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
Paul Holzinger 9b0fcab189 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 358905c1be 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
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
Paul Holzinger 82616479ae libnetwork: ipam driver none disable dns
When we create a network with the ipam driver none we should disabled
dns automatically. Since we mange no ips we cannot provide name
resolution anyway.

This fixes a problem I spotted when adding test to the podman CI.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-31 16:39:23 +02:00
Sascha Grunert a6b63a5c47 Switch to ginkgo/v2
Update ginkgo to the next major version which has been released a while
ago.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-03-30 10:03:17 +02:00
Paul Holzinger cc5a65ab0f libnetwork/netavark: allow network create with no ipam driver
Network create now uses the ipam driver. This allows the user to
configure the ipam driver manually instead of choosing a fixed default.
If the ipam driver is `none` no ips will be assigned to this container.
This means that only the interfaces are created.

This will require a patch in netavark since it rejects the config when
no static ips are provided.

Ref containers/podman#13521

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-29 18:46:29 +02: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
Paul Holzinger a8296384fb netavark: macvlan allow internal networks
When internal is used the default route will not be added,
see https://github.com/containers/netavark/pull/246

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-02-25 14:41:51 +01:00
Paul Holzinger ff12fff79f netavark: add support for dns with internal
netavark + aardvark support this when we add a gateway ip to the config
so that aardvark can use this address to bind on it.
We only add the gateway when not internal or when dns is enabled. If
internal without dns we do not need the gw address.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-02-04 14:27:26 +01:00
Paul Holzinger 6dc28b6260 libnetwork fix subnet validation for macvlan
When we create a macvlan network we should not check if the subnet is
already in use on the host since this is expected for macvlan networks.
Only bridge networks should use this check.

Fixes containers/podman#12971

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-24 16:40:38 +01:00
Paul Holzinger f18244b9a1 libnetwork: netavark allow mtu option for macvlan
We have to support the mtu option for netavark since it is also
supported by CNI.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-10 16:55:19 +01:00
Paul Holzinger 4fcb18dca7 libnetwork: fix lint errors
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-12-17 14:24:21 +01:00
Paul Holzinger 002673d22f add libnetwork package
Copy the libpod/network packages from podman to here so we can use the
same code in buildah as well.

This is mostly a one to one copy only the import paths have been changed
and some errors were added.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-12-16 19:07:38 +01:00