189 Commits

Author SHA1 Message Date
Poh Chiat Koh
c1a7948b19 vrf: fix route filter to use output iface
current route filter uses RT_FILTER_IIF in conjunction with LinkIndex.
This combination is ignored by netlink, rendering the filter
ineffective

Signed-off-by: Poh Chiat Koh <poh@inter.link>
2023-07-21 12:50:21 +02:00
Casey Callendrello
1561794ae9
Merge pull request #924 from SirPhuttel/go-iptables_review
Review code using go-iptables module
2023-07-21 12:23:08 +02:00
Phil Sutter
0a100e5d8f meta: firewall: Fix firewalld test with non-abstract sockets
On a recent Fedora Rawhide, dbus-daemon-1.14.8-1 prints a string
prefixed by 'unix:path' instead of the expected 'unix:abstract', thereby
failing the test. Allowing this alternate prefix fixes the test, so for
communication with the daemon it is not relevant.

Signed-off-by: Phil Sutter <psutter@redhat.com>
2023-07-20 11:34:34 +02:00
Phil Sutter
3eb775c5e6 plugins: meta: portmap: Implement a teardown() fast path
Just attempt to delete the known rules referring to the custom chain,
then flush and delete it. If the latter succeeds, no referencing rules
are left and the job is done.

If the final flush'n'delete fails, fall back to the referencing rule
search which is slow with large rulesets.

Signed-off-by: Phil Sutter <psutter@redhat.com>
2023-07-20 11:34:02 +02:00
Phil Sutter
719f60bb91 utils: iptables: Use go-iptables' ChainExists()
Starting with v0.5.0, go-iptables exports a fast ChainExists() which
does not rely upon listing all chains and searching the results but
probes chain existence by listing its first rule. This should make a
significant difference in rulesets with thousands of chains.

Signed-off-by: Phil Sutter <psutter@redhat.com>
2023-07-20 11:34:02 +02:00
Casey Callendrello
d03b84d8f2
Merge pull request #874 from travelping/vrf-add-routes
Add routes propagation for VRF plugin
2023-06-27 12:20:45 +02:00
Tariq Ibrahim
470eee1385 [tuning]add ability to set tx queue len
Signed-off-by: Tariq Ibrahim <tibrahim@nvidia.com>
2023-06-25 23:28:48 -07:00
Artur Korzeniewski
ca12d49b41 Add routes propagation for VRF plugin
Up until now, if previous plugin assigned routes to interface, movement of
this interface to new VRF cause routes to be deleted.

This patch adds funtionality to VRF plugin to save the routes before
interface is assgined to VRF, and then re-apply all saved routes to new VRF.

Signed-off-by: Artur Korzeniewski <artur.korzeniewski@travelping.com>
2023-06-02 14:21:28 +02:00
Ivan Kolodyazhny
7e918412d5 [sbr]: Ignore LinkNotFoundError during cmdDel
Signed-off-by: Ivan Kolodyazhny <e0ne@e0ne.info>
2023-05-02 14:08:11 +03:00
Dan Williams
10b5639361
Merge pull request #885 from champtar/tuning-CHECK
tuning: fix cmdCheck when using IFNAME
2023-04-24 10:46:37 -05:00
Casey Callendrello
65fe256058
Merge pull request #883 from mmorel-35/linter-2
enable govet and unparam linters
2023-04-24 17:42:55 +02:00
Jingyuan Liang
d8fc886bf0 Bump to golang 1.20 to pick up go1.19.6 / go1.20.1 CVE fixes
Go 1.18 is already EOL and doesn't have fixes available.

Signed-off-by: Jingyuan Liang <jingyuanliang@google.com>
2023-04-21 05:21:43 +00:00
Etienne Champetier
5b7a263e8f tuning: fix cmdCheck when using IFNAME
Fixes: c16cff9805427c5db34b43de3155769b362f596e
Signed-off-by: Etienne Champetier <e.champetier@ateme.com>
2023-04-20 11:19:23 -04:00
Matthieu MOREL
10ddd9e454
enable govet and unparam linters
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-04-11 12:07:04 +02:00
Miguel Duarte Barroso
7bbd4d19e9 linter: fix ginkgolinter errors
Use:
- `BeEmpty` instead of `HaveLen(0)`
- `Expect(x).To(BeZero())` instead of `Expect(x == 0).To(BeTrue())`

Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2023-04-04 16:09:01 +02:00
Casey Callendrello
deec68747e
Merge pull request #853 from mmorel-35/ginkgolinter
enable ginkgolinter linter
2023-04-04 15:24:20 +02:00
Dan Williams
8813bfea7b
Merge pull request #855 from mmorel-35/linters
enable durationcheck,  predeclared, unconvert, unused and wastedassign linters
2023-03-27 10:53:34 -05:00
Marcelo Guerrero Viveros
d71d0f2da1 Fix revive linter errors
Golangci-lint is now running version 1.52.1. This introduced some errors.

Signed-off-by: Marcelo Guerrero Viveros <marguerr@redhat.com>
2023-03-24 21:04:39 +01:00
Matthieu MOREL
2fb0efe8a3
enable durationcheck, predeclared, unconvert, unused and wastedassign linters
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-03-16 07:29:37 +01:00
Matthieu MOREL
09f36a295d enable ginkgolinter linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-03-13 22:27:21 +00:00
Matthieu MOREL
a02bf4b463 enable revive linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-03-13 17:59:41 +01:00
Matthieu MOREL
79f524689c enable gocritic linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-03-13 17:59:33 +01:00
Matthieu MOREL
5a7619c019 enable gosimple linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-03-13 17:59:31 +01:00
Matthieu MOREL
177e0bf2d9
enable staticcheck linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-03-02 11:06:22 +01:00
Matthieu MOREL
d12b81dec5 ci(lint): setup golangci-lint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-03-01 06:55:40 +00:00
liornoy
2d1005ec02
Update tests to utilize ginkgo/v2
This commit updates the import of ginkgo to v2 in
all of the tests.

Signed-off-by: liornoy <lnoy@redhat.com>
Co-authored-by: Sascha Grunert <sgrunert@redhat.com>
2023-02-13 21:15:18 +02:00
Michael Cambria
fb5d195fc5 Only check ipv6 when an IPv6 is configured
Signed-off-by: Michael Cambria <mccv1r0@gmail.com>
2023-01-27 20:22:11 -05:00
Casey Callendrello
0924b71fc8
Merge pull request #790 from austinvazquez/remove-ioutil-references
Remove references to io/ioutil package
2023-01-16 10:45:56 +01:00
Casey Callendrello
f48a5ea512
Merge pull request #798 from mmirecki/pathissue_fix
Fix tuning path validation
2023-01-09 17:48:00 +01:00
Casey Callendrello
a3b678ee03
Merge pull request #772 from BSWANG/master
`portmap` support masquerade all
2023-01-09 17:41:52 +01:00
mmirecki
fd9408bc97 Fix tuning path validation
Signed-off-by: mmirecki <mmirecki@redhat.com>
2022-12-16 11:55:33 +01:00
Emily Shepherd
6b30e290d2
Update portmap test's iptables error check
GitHub Actions recently updated ubuntu-latest to 22.04 [1], which now
defaults to nfttables (rather than iptables-legacy) [2]. The portmap
tests in this project are written with the expectation that expected
error message for one test is in the iptables-legacy format.

This commit updates the check to make it work for both the
iptables-legecy and iptables-nftables variants.

References:
[1]: 4aba37bd3b
[2]: https://ubuntu.com/blog/whats-new-in-security-for-ubuntu-22-04-lts

Signed-off-by: Emily Shepherd <emily@redcoat.dev>
2022-12-06 18:56:59 +00:00
Austin Vazquez
1a6f478913 Remove references to io/ioutil package
Signed-off-by: Austin Vazquez <macedonv@amazon.com>
2022-12-01 22:27:05 +00:00
mmirecki
198ab129a1 Fix path substitution to enable setting sysctls on vlan interfaces
This commit changes the order of substituting sysctl path to first handle
. to / change, before substituting the interface name.
This is needed as vlan interfaces have a . in the name, which should not
be changed.

Signed-off-by: mmirecki <mmirecki@redhat.com>
2022-11-09 11:31:58 +01:00
bingshen.wbs
0463fd19af support masquerade all config
Signed-off-by: bingshen.wbs <bingshen.wbs@alibaba-inc.com>
2022-11-07 13:50:21 +08:00
Dan Williams
9c59728d39
Merge pull request #730 from mmirecki/tuning_duplicate_check
Check for duplicated sysctl keys
2022-05-04 11:21:35 -05:00
mmirecki
7c452c77cd Check for duplicated sysctl keys
Signed-off-by: mmirecki <mmirecki@redhat.com>
2022-04-27 22:13:17 +02:00
Joe Julian
e3d563b0f0
bug: return errors when iptables and ip6tables are unusable
Signed-off-by: Joe Julian <me@joejulian.name>
2022-04-01 11:03:54 -07:00
Casey Callendrello
3512b10ff0
Merge pull request #693 from mmirecki/POC_sysctl_whitelist
Add sysctl allowList
2022-03-02 17:40:46 +01:00
mmirecki
96c3af81e2 Add sysctl allowlist
Signed-off-by: mmirecki <mmirecki@redhat.com>
2022-02-24 15:41:04 +01:00
Dan Winship
08d0f33416 portmap: fix checkPorts result when chain does not exist
checkPorts would return nil rather than an error if the per-container
DNAT chain didn't exist, meaning CHECK would erroneously return
success rather than failure.

chain.check() already (correctly) checks that the chain exists, so
there's no need to do it separately before calling that anyway.

Signed-off-by: Dan Winship <danwinship@redhat.com>
2022-02-21 12:33:14 -05:00
Akihiro Suda
22dd6c553d
firewall: support ingressPolicy=(open|same-bridge) for isolating bridges as in Docker
This commit adds a new parameter `ingressPolicy` (`string`) to the `firewall` plugin.
The supported values are `open` and `same-bridge`.

- `open` is the default and does NOP.

- `same-bridge` creates "CNI-ISOLATION-STAGE-1" and "CNI-ISOLATION-STAGE-2"
that are similar to Docker libnetwork's "DOCKER-ISOLATION-STAGE-1" and
"DOCKER-ISOLATION-STAGE-2" rules.

e.g., when `ns1` and `ns2` are connected to bridge `cni1`, and `ns3` is
connected to bridge `cni2`, the `same-bridge` ingress policy disallows
communications between `ns1` and `ns3`, while allowing communications
between `ns1` and `ns2`.

Please refer to the comment lines in `ingresspolicy.go` for the actual iptables rules.

The `same-bridge` ingress policy is expected to be used in conjunction
with `bridge` plugin. May not work as expected with other "main" plugins.

It should be also noted that the `same-bridge` ingress policy executes
raw `iptables` commands directly, even when the `backend` is set to `firewalld`.
We could potentially use the "direct" API of firewalld [1] to execute
iptables via firewalld, but it doesn't seem to have a clear benefit over just directly
executing raw iptables commands.
(Anyway, we have been already executing raw iptables commands in the `portmap` plugin)

[1] https://firewalld.org/documentation/direct/options.html

This commit replaces the `isolation` plugin proposal (issue 573, PR 574).
The design of `ingressPolicy` was discussed in the comments of the withdrawn PR 574 ,
but `same-network` was renamed to `same-bridge` then.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-02-03 15:49:43 +09:00
Casey Callendrello
186edecd6c
Merge pull request #687 from MikeZappa87/issue/588/removegArp
Replace arping package with arp_notify
2022-01-19 18:14:55 +01:00
Michael Zappa
5d073d690c plugins: replace arping package with arp_notify
this replaces the arping package with the linux arp_notify feature.

Resolves: #588
Signed-off-by: Michael Zappa <Michael.Zappa@stateless.net>
2022-01-06 20:53:54 -07:00
silenceper
67110e02ba
fix #685
Signed-off-by: silenceper <silenceper@gmail.com>
2022-01-06 20:57:52 +08:00
Piotr Skamruk
c16cff9805 Allow setting sysctls on a particular interface
Signed-off-by: Piotr Skamruk <piotr.skamruk@gmail.com>
2021-10-01 18:09:40 +02:00
edef
ceb34eb2e6 Don't redundantly filepath.Clean the output of filepath.Join
filepath.Join is already specified to clean its output,
and the implementation indeed does so.

Signed-off-by: edef <edef@edef.eu>
2021-09-17 14:12:46 +00:00
Casey Callendrello
ba48f8a659 plugins: fix bug where support for CNI version 0.4.0 or 1.0.0 was dropped
Signed-off-by: Casey Callendrello <cdc@redhat.com>
2021-09-07 15:48:16 +02:00
Casey Callendrello
77233dd79d plugins: remove flannel
Now that the flannel CNI plugin has been moved to
https://github.com/flannel-io/cni-plugin, we should remove it from here.

Signed-off-by: Casey Callendrello <cdc@redhat.com>
2021-06-02 17:38:32 +02:00
Dan Williams
6618a0aba8
Merge pull request #623 from anuragensemble/multi-ip-intf
Add multi IP support for SBR
2021-05-19 10:33:40 -05:00