201 Commits

Author SHA1 Message Date
Lars Ekman
02bfece2e9 plugins/meta/sbr: Adjusted ipv6 address mask to /128
A /64 mask was used which routed an entire cidr based on source,
not only the bound address.

Fixes #478

Signed-off-by: Lars Ekman <lars.g.ekman@est.tech>
2020-04-28 16:38:35 +02:00
Alban Bedel
5e0fbd8374 portmap: Apply the DNAT hairpin to the whole subnet
The DNAT hairpin rule only allow the container itself to access the
ports it is exposing thru the host IP. Other containers in the same
subnet might also want to access this service via the host IP, so
apply this rule to the whole subnet instead of just for the container.

This is particularly useful with setups using a reverse proxy for
https. With such a setup connections between containers (for ex.
oauth2) have to downgrade to http, or need complex dns setup to make
use of the internal IP of the reverse proxy. On the other hand going
thru the host IP is easy as that is probably what the service name
already resolve to.

Signed-off-by: Alban Bedel <albeu@free.fr>
--
v2: Fixed the tests
v3: Updated iptables rules documentation in README.md
v4: Fixed the network addresses in README.md to match iptables output
2020-04-17 16:27:57 +02:00
ahenan
2a48d68937 Reset the route flag before moving the rule
Signed-off-by: ahenan <ahenan00@gmail.com>
2020-04-06 17:12:45 +02:00
Piotr Skamruk
ca419073e4 modify the error url of windowscontainer
Signed-off-by: root <timyinshi>
2020-03-05 09:38:33 +08:00
Bruce Ma
53854dd948 flannel: remove net conf file after DEL succeed
Signed-off-by: Bruce Ma <brucema19901024@gmail.com>
2020-02-19 21:00:37 +08:00
Antonio Ojea
bf8f171041 iptables: add idempotent functions
Add the following idempotent functions to iptables utils:

DeleteRule: idempotently delete an iptables rule
DeleteChain: idempotently delete an iptables chain
ClearChain: idempotently flush an iptables chain

Signed-off-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
2019-12-12 15:13:15 +01:00
Antonio Ojea
3603738c6a
portmap doesn't fail if chain doesn't exist
It turns out that the portmap plugin is not idempotent if its
executed in parallel.
The errors are caused due to a race of different instantiations
deleting the chains.
This patch does that the portmap plugin doesn't fail if the
errors are because the chain doesn't exist on teardown.

Signed-off-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
2019-12-12 09:03:06 +01:00
Antonio Ojea
d8b1289098
fix portmap port forward flakiness
Use a Describe container for the It code block of the
portmap port forward integration test.

Signed-off-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
2019-12-12 09:03:06 +01:00
Tim Gross
58dd90b996 ensure iptables chain creation is idempotent
Concurrent use of the `portmap` and `firewall` plugins can result in
errors during iptables chain creation:

- The `portmap` plugin has a time-of-check-time-of-use race where it
  checks for existence of the chain but the operation isn't atomic.
- The `firewall` plugin doesn't check for existing chains and just
  returns an error.

This commit makes both operations idempotent by creating the chain and
then discarding the error if it's caused by the chain already
existing. It also factors the chain creation out into `pkg/utils` as a
site for future refactoring work.

Signed-off-by: Tim Gross <tim@0x74696d.com>
2019-11-11 10:00:11 -05:00
Tomofumi Hayashi
2583a0b4ad Sending GratuitousArp in case of MAC address update
This change sends gratuitous ARP when MAC address is changed to
let other devices to know the MAC address update.

Signed-off-by: Tomofumi Hayashi <tohayash@redhat.com>
2019-10-23 15:17:38 +09:00
Bryan Boreham
411d060b81
Merge pull request #389 from CallMeFoxie/bw-units
Use uint64 for Bandwidth plugin
2019-10-09 16:25:06 +01:00
Ashley Reese
cf187287af Update tests for uint64
Signed-off-by: Ashley Reese <ashley@victorianfox.com>
2019-10-03 16:55:41 +02:00
Ashley Reese
0dff883769 Use uint64 for Bandwidth plugin
Signed-off-by: Ashley Reese <ashley@victorianfox.com>
2019-10-03 16:05:27 +02:00
Erik Sipsma
0a1421a08c firewall: remove unused netns check from DEL method
Signed-off-by: Erik Sipsma <sipsma@amazon.com>
2019-09-25 20:38:02 +00:00
Erik Sipsma
fc7059c1ae firewall: don't return error in DEL if prevResult is not found.
The CNI spec states that for DEL implementations, "when CNI_NETNS and/or
prevResult are not provided, the plugin should clean up as many resources as
possible (e.g. releasing IPAM allocations) and return a successful response".
This change results in the firewall plugin conforming to the spec by not
returning an error whenever the del method is not provided a prevResult.

Signed-off-by: Erik Sipsma <sipsma@amazon.com>
2019-09-23 21:11:07 +00:00
Niels van Oosterom
e8365e126d Fixed issue where hostIP address family was not checked against the containerIP address family. closes #378
Signed-off-by: Niels van Oosterom <xcelsion@users.noreply.github.com>
2019-09-06 15:23:00 +02:00
Tomofumi Hayashi
a069a5f1a3 Support "args" in static and tuning
Support "args" field in JSON config to additional configuration
in static and tuning plugins.
2019-08-09 11:52:06 +09:00
Tomofumi Hayashi
8902d2614a Remove link Down/Up in MAC address change to prevent route flush 2019-08-07 13:54:10 +09:00
Gabe Rosenhouse
3fb8dcfd4c pkg/meta/bandwidth: increase IfbDeviceName size
* Increase entroy from 2 bytes to 7 bytes to prevent collisions
* Extract common library function for hash with prefix
* Refactor portmap plugin to use library function

fixes #347

Co-authored-by: Cameron Moreau <cmoreau@pivotal.io>
Co-authored-by: Mikael Manukyan <mmanukyan@pivotal.io>
2019-07-18 11:45:38 -07:00
Tomofumi Hayashi
660685a8af Support ips capability in static and mac capability in tuning
This change introduces new capability flag to change MAC address
and to specify IP addresses by tuning and static.
2019-06-20 17:11:47 +09:00
Bruce Ma
d35c96dda6 bandwidth: add testcases for func getHostInterface
Signed-off-by: Bruce Ma <brucema19901024@gmail.com>
2019-05-21 00:28:04 +08:00
Bruce Ma
344d343431 bandwidth: get bandwidth interface in host ns through container interface
Signed-off-by: Bruce Ma <brucema19901024@gmail.com>
2019-05-18 14:06:45 +08:00
Dan Williams
6bceb68143
Merge pull request #309 from nagiesek/flannel
Flannel: Pass through runtimeConfig to delegate
2019-05-08 10:25:50 -05:00
Nathan Gieseker
071907f867 Flannel: pass runtimeConfig into delegate 2019-05-01 15:58:24 -07:00
Dan Williams
ae0b03787f windows,flannel: cmdGet -> cmdCheck and fix flannel Check return 2019-05-01 10:48:14 -05:00
Michael Cambria
cc4976a43c return nil instead of error for cmdCheck until support is added 2019-04-24 13:47:58 -04:00
Casey Callendrello
72f2a1ffd4 plugins: correctly output build version, cosmetic cleanups
Now that libcni has the ability to print a version message, plumb it
through correctly.

While we're at it,
- fix import paths
- run gofmt
- add some more comments to sample
- add container runtime swappability for release
2019-04-15 16:52:07 +02:00
Michael Cambria
d47387c6fe Add Check support to firewall meta plugin, test cases 2019-04-12 14:37:21 -04:00
Dan Williams
95be5da5e2 firewall: add a couple more testcases 2019-04-12 14:37:21 -04:00
Dan Williams
b46e1a0138 firewall: consolidate firewalld code into firewall plugin 2019-04-12 14:37:21 -04:00
Michal Rostecki
9d6f1e9975 firewall: add firewalld functionality to firewall plugin
Example of usage, which uses flannel for allocating IP
addresses for containers and then registers them in `trusted`
zone in firewalld:

{
  "cniVersion": "0.3.1",
  "name": "flannel-firewalld",
  "plugins": [
    {
      "name": "cbr0",
      "type": "flannel",
      "delegate": {
        "isDefaultGateway": true
      }
    },
    {
      "type": "firewall",
      "backend": "firewalld",
      "zone": "trusted"
    }
  ]
}

Fixes #114

Signed-off-by: Alban Crequy <alban@kinvolk.io>
Signed-off-by: Michal Rostecki <mrostecki@suse.com>
2019-04-12 14:37:21 -04:00
Dan Williams
d096a4df48 firewall: new plugin which allows a host interface to send/receive traffic
Distros often have additional rules in the their iptabvles 'filter' table
that do things like:

-A FORWARD -j REJECT --reject-with icmp-host-prohibited

docker, for example, gets around this by adding explicit rules to the filter
table's FORWARD chain to allow traffic from the docker0 interface.  Do that
for a given host interface too, as a chained plugin.
2019-04-12 14:37:21 -04:00
Michael Cambria
74a2596573 Add check support for: bridge, ipvlan, macvlan, p2p, vlan and host-device main plugins
host-local and static ipam plugins
  tuning, bandwidth and portmap meta plugins

  Utility functions created for common PrevResult checking

  Fix windows build
2019-04-03 13:08:07 -04:00
Casey Callendrello
9fab520c37 Portmap: append, rather than prepend, entry rules
This means that portmapped connections can be more easily controlled /
firewalled.
2019-03-18 14:03:13 -05:00
Nguyen Quang Huy
4bca3e76bf Fix redundant import alias
Because these package names are short and they are unique, it can not conflict. So the import aliases that can be omitted and we should remove them.
2019-02-20 16:58:45 +07:00
Dan Williams
1865a0701e
Merge pull request #212 from plwhite/sbrplugin
Create new Source Based Routing plugin
2019-02-06 10:15:56 -06:00
Peter White
29928cff4d Create new Source Based Routing plugin
This creates a new plugin (sbr) which sets up source based routing, for use
as a chained plugin for multi-network environments.
2019-01-31 09:27:59 +00:00
Michael Cambria
6f3332e9fe Fix for windows too 2018-11-05 16:52:12 -05:00
Michael Cambria
ddbf22f7f9 Vendor github.com/containernetworking/cni libcni and pkg file needed for CHECK
Update plugins/tests to deal with changes made to this vendor'ed code
2018-11-05 16:35:03 -05:00
Dan Williams
9b86f52791
Merge pull request #200 from s1061123/fix/tuning-doc
Add description for mac/mtu/promisc in tuning README.md
2018-09-24 20:53:38 -05:00
Dan Williams
8a579a7fbc
Merge pull request #204 from mrostecki/always-check-err
Add missing error checks
2018-09-24 20:52:38 -05:00
MaiWJ
b56ca2fe45 Windows Support
Patch for https://github.com/containernetworking/plugins/pull/85

+ Windows cni plugins are added
   (*) win-bridge (hostgw)
   (*) win-overlay (vxlan)
+ Windows netconf unit test
+ Fix appveyor config to run the test
+ Build release support for windows plugins

Address comments

From:
    - https://github.com/containernetworking/plugins/pull/85
    - 0049c64e3f
2018-09-21 00:34:07 +08:00
Tomofumi Hayashi
93178bf026 Fix typo. 2018-09-20 22:18:15 +09:00
Michal Rostecki
f5f787057d plugins/meta: Add missing error checks
Signed-off-by: Michal Rostecki <mrostecki@suse.de>
2018-09-20 11:06:50 +02:00
Tomofumi Hayashi
d22e75316f Incorporate comments in PR. 2018-09-13 01:49:47 +09:00
Dan Williams
35b87a34db
Merge pull request #191 from dcbw/portmap-panic-fix
portmap: don't panic if listing a chain returns fewer lines than exected
2018-09-05 10:09:02 -05:00
Tomofumi Hayashi
9048a61dda Add description for mac/mtu/promisc in tuning README.md
This diff adds documents for #177 change (mac/mtu/promisc) in tuning
README.md. Fixes #199.
2018-09-05 16:01:24 +09:00
Dan Williams
7d329215b0 portmap: don't panic if listing a chain returns fewer lines than expected 2018-08-16 09:50:28 -05:00
Dong Jun
220499db6b Correct the bandwidth unit in description
Replace Kbps with bps and Kb with bits in bandwidth description.
2018-08-15 19:26:13 +08:00
Tomofumi Hayashi
9425d24c28 Incorporate @jelloneck/@bboreham/@squeed's comments. 2018-08-09 22:28:12 +09:00