58 Commits

Author SHA1 Message Date
Stefan Junker
72e98b97d6 The macvlan is initially created in a separate network namespaceand the sysctl must be set in that namespace too.Fixes #208.
The macvlan is initially created in a separate network namespace
and the sysctl must be set in that namespace too.

Fixes #208.
2016-05-17 21:11:21 +02:00
Stefan Junker
d91971cbe0 plugins/{ptp,bridge}: teardown first
This will allow the IPAM allocations to be cleared in case the
interfaces and iptables rules are non-existent.
2016-05-11 19:47:55 +02:00
Stefan Junker
ed5f8dfeb2 *: appc/cni -> containernetworking/cni
The project has been moved so internally we simply rename everything.
Consumers are recommended to update their vendored version of cni.
2016-05-06 16:40:27 +02:00
Iago López Galeiras
6aa26f9fd2 plugins/bridge: clean masquerading rules
In the Add command we set up masquerading rules that didn't have a
corresponding clean-up code in Del.

Add the clean-up code.
2016-05-03 12:21:58 +02:00
Dan Williams
99ca41457e macvlan: sysctl must be set in macvlan interface's namespace
The macvlan is initially created in a separate network namespace
and the sysctl must be set in that namespace too.
2016-04-28 11:26:47 -05:00
Stefan Junker
911d941794 Merge pull request #187 from appc/v0.3.0
merge unneeded branch v0.3.0 into master
2016-04-22 19:25:54 +02:00
Gabe Rosenhouse
5d932e4716 Extract testhelpers from loopback test suite 2016-04-17 18:28:10 -07:00
Piotr Skamruk
b2f492e8b5 macvlan: set proxy_arp in time of creating interface
Resolves CNI part of https://github.com/coreos/rkt/issues/1765
Second part would be adding similar lines into kvm flavored macvlan
support (in time of creating macvtap device).
2016-04-07 21:40:58 +02:00
Jonathan Boulle
f6135c7ba3 *: add missing license headers + check 2016-04-01 15:35:21 +02:00
Stefan Junker
6aad63055c *: add comment to iptables rules for ipmasq 2016-03-31 18:01:32 +02:00
Abhishek Chanda
c33daf6706 pkg: add a function to generate chain names
Adds a function to generate chain names for use in iptables and
ports all drivers to use that function. Also adds tests for the
said function.
2016-03-31 18:01:32 +02:00
Stefan Junker
5a39a168f7 pkg/types: add IgnoreUnknown arg and logic
This commit adds a struct type CommonArgs that is to be embedded in
every plugin's argument struct. It contains a field named
"IgnoreUnknown" which will be parsed as a boolean and can be provided to
ignore unknown arguments passed to the plugin.
2016-03-21 20:36:05 +01:00
Stefan Junker
05c5aea77b plugins/host-local: only call LoadArgs() once 2016-03-21 20:17:47 +01:00
Abhishek Chanda
9b2f3380c1 Fix govet warnings 2016-03-16 16:25:41 -07:00
Michael Bridgen
719a1db54b Add invoke.Delegate{Add,Del} for use by meta-plugins
The 'flannel' meta plugin delegates to other plugins to do the actual
OS-level work. It used the ipam.Exec{Add,Del} procedures for this
delegation, since those do precisely what's needed.

However this is a bit misleading, since the flannel plugin _isn't_
doing this for IPAM, and the ipam.Exec* procedures aren't doing
something specific to IPAM plugins.

So: anticipating that there may be more meta plugins that want to
delegate in the same way, this commit moves generic delegation
procedures to `pkg/invoke`, and makes the `pkg/ipam` procedures (still
used, accurately, in the non-meta plugins) shims.
2016-03-04 11:01:22 +00:00
Stefan Junker
4a5426b77a tests: loopback DEL 2016-03-02 17:56:44 +01:00
Stefan Junker
80ab40470c tests: loopback stdout must be JSON 2016-03-02 15:27:05 +01:00
Stefan Junker
52be8aa615 plugins/loopback: take lo down on CmdDel 2016-03-02 15:27:05 +01:00
Stefan Junker
e282f6939d plugins/loopback: return empty result
This is needed to conform to the specification and allow successful
unmarshalling in the invoker.
2016-03-02 15:27:00 +01:00
zachgersh
1e3d680d13 Handle namespaces with care
- After creating new netns, switch back to main netns
- Lock thread during test and test setup
2016-02-29 12:29:06 -05:00
Zachary Gershman
2708bdf2f5 Create a plugin for up'ing a lo device
- Believe we need sudo to create netns
- Use syscall instead of relying on ip netns
- Add sudo to .travis.yml
- Needs more -E
- Revert Godeps GoVersion to 1.4.2
- in travis, test command is run with all necessary env vars
- Loopback plugin only works on 'lo' interface
- Update README, add loopback plugin config
- note script dependency on jq

Signed-off-by: Gabe Rosenhouse <grosenhouse@pivotal.io>
2016-02-29 12:29:06 -05:00
Alban Crequy
f49145d5ff new plugin: tuning
Allow users to tune net network parameters such as somaxconn.

With this patch, users can add a new network configuration:

> {
>   "name": "mytuning",
>   "type": "tuning",
>   "sysctl": {
>           "net.core.somaxconn": "500"
>   }
> }

The value /proc/sys/net/core/somaxconn will be set to 500 in the network
namespace but will remain unchanged on the host.

Only sysctl parameters that belong to the network subsystem can be
modified.

Related to: https://github.com/coreos/rkt/pull/2140
2016-02-18 15:29:12 +01:00
André Martins
33b2de44af fixed ipam host-local IP json tag
Signed-off-by: André Martins <aanm90@gmail.com>
2016-01-31 03:14:53 +00:00
Stefan Junker
137dc8a673 *: reflect SPEC's DNS changes in implementation
* DNS is now a type which will result in a JSON dictionary in
  configurations and results
* Minor refactoring, making use of type embedding
2016-01-29 10:39:28 +01:00
Alban Crequy
2f9ef4adb7 *: add "dns" field to the configuration
appc/cni#76 added a "dns" field in the result JSON. But before this
patch, the plugins had no way of knowing which name server to return.

There could be two ways of knowing which name server to return:
1. add it as an extra argument ("CNI_ARGS")
2. add it in the network configuration as a convenience (received via
   stdin)

I chose the second way because it is easier. In the case of rkt, it
means the user could just add the DNS name servers in
/etc/rkt/net.d/mynetwork.conf.
2016-01-26 18:54:56 +01:00
Stefan Junker
753b10503c host-local: detect missing subnet and error out 2015-11-25 21:18:48 +01:00
Stefan Junker
6f23757868 dhcp: detect if link is down and attempt to set up
With this we still get the "network is down" error, but after the 2nd
retry the interface is up and the dhcp request works.
2015-11-19 11:11:32 +01:00
Eugene Yakubovich
20f1b8694f flannel: doc fix and check for missing subnet.env fields
- Document that flannel outputs FLANNEL_NETWORK b/c we use it
- Check and error out if expecited fields are missing in subnetEnv file

Fixes #72
2015-10-07 15:38:12 -07:00
Eugene Yakubovich
f885288a2d Merge pull request #69 from eyakubovich/err-msgs
Route del would fail due to wrong scope; better errors
2015-09-30 11:56:56 -07:00
Eugene Yakubovich
0becca2e96 Change copyright from CoreOS to CNI authors
CNI is developed by more than just CoreOS, Inc
and the copyright is retained by all CNI
contributors (for their respective contributed code).
2015-09-29 11:51:33 -07:00
Eugene Yakubovich
5efd3ba883 Route del would fail due to wrong scope; better errors
In some cases the route deletion would fail due to wrong
scope. It should be NOWHERE when deleting (per iproute2).
This also adds more verbose error messages.
2015-09-29 11:27:49 -07:00
Stefan Junker
f1c9c632e1 Revert "plugins/ptp: allow host veth to be UP"
This reverts commit 231d2d5a27f3ba54219c3f0b1c8ef2c5dab4faaf.
2015-09-24 18:32:18 +02:00
Stefan Junker
231d2d5a27 plugins/ptp: allow host veth to be UP 2015-09-24 10:57:36 +02:00
Eugene Yakubovich
60be55a7d1 remove host-local-ptp plugin 2015-09-23 11:04:38 +02:00
Eugene Yakubovich
7d8d6b2a7e Use single IP on the host for ptp veths
Instead of allocating a /31 for each container,
use the same IP on the host side for all veths.
This is very similar how real point-to-point
devices work (using donor IPs).
2015-09-23 11:04:38 +02:00
Michael Bridgen
b88f173c43 Factor an API out into a module
This takes some of the machinery from CNI and from the rkt networking
code, and turns it into a library that can be linked into go apps.

Included is an example command-line application that uses the library,
called `cnitool`.

Other headline changes:

 * Plugin exec'ing is factored out

The motivation here is to factor out the protocol for invoking
plugins. To that end, a generalisation of the code from api.go and
pkg/plugin/ipam.go goes into pkg/invoke/exec.go.

 * Move argument-handling and conf-loading into public API

The fact that the arguments get turned into an environment for the
plugin is incidental to the API; so, provide a way of supplying them
as a struct or saying "just use the same arguments as I got" (the
latter is for IPAM plugins).
2015-09-16 10:14:39 +01:00
Stefan Junker
d896b82816 ipvlan/macvlan: remove ipMasq related code
Luckily the docs haven't mentioned support for ipMasq for both plugins so far.
Even if anyone has attempted to enable the feature in their configuration files it didn't have the desired effect for the network.
2015-09-09 14:16:39 +02:00
Stefan Junker
1d398af124 host-local: allow ip request via CNI_ARGS
A specific IP can now be requested via the environment variable CNI_ARGS, e.g.
`CNI_ARGS=ip=1.2.3.4`.
The plugin will try to reserve the specified IP.
If this is not successful the execution will fail.
2015-09-04 01:38:22 +02:00
Eugene Yakubovich
34be862dc3 Merge pull request #41 from eyakubovich/flannel-route
flannel: set up route for the entire flannel network
2015-08-15 16:28:09 -07:00
Eugene Yakubovich
e38572b967 flannel: set up route for the entire flannel network
Without it, packets leave via default route iface
and come back via interface added by flannel plugin.
If rp_filter=1, the packets are dropped.
2015-08-10 14:13:06 -07:00
Stefan Junker
d961f6cd39 host-local: fix routes in README examples 2015-08-03 15:37:14 +02:00
Eugene Yakubovich
64f5cf9e82 Rename veth plugin to ptp and add docs.
ptp (point-to-point) better describes the nature of the plugin
as veth pairs are also used by the bridge plugin.
2015-07-21 17:20:11 -07:00
Eugene Yakubovich
d053cd7184 Merge pull request #35 from eyakubovich/ip_forward
enable net.ipv4.ip_forward in plugins that need it
2015-07-21 17:12:04 -07:00
Eugene Yakubovich
91454b6ebb enable net.ipv4.ip_forward in plugins that need it 2015-07-13 15:41:02 -07:00
Eugene Yakubovich
cc393ddba7 ipvlan: wrong name was used during link creation
Instead of temp (random) name, the final name (e.g. eth0)
was used during link creation. This would collide on hosts
that already had the an interface with such a name.
2015-07-10 14:02:35 -07:00
Eugene Yakubovich
8b6b04773e dhcp: don't swallow err from netns switch 2015-06-15 14:32:16 -07:00
Eugene Yakubovich
50c14e6223 Merge pull request #24 from eyakubovich/dhcp-abs-path
dhcp: make netns path absolute prior to RPC
2015-06-15 12:46:40 -07:00
Eugene Yakubovich
30316e3fa9 dhcp: make netns path absolute prior to RPC
The dhcp daemon may be running with a different cwd
and so the netns paths need to be absolute. This patch
also refactors the code to pull out the common, RPC
parts, out into a separate function.
2015-06-15 12:44:43 -07:00
Eugene Yakubovich
295e02e4e9 dhcp: decrease read timeout and clamp backoff 2015-06-15 12:40:34 -07:00
Eugene Yakubovich
16680be42d No more path rewriting
Path rewriting causes too many problems when vendoring
vendored code. When CNI code is vendored into rkt,
godep has problems code already vendored by CNI.
2015-06-12 16:29:18 -07:00