Skip to content

Comments

improve netns integration#25

Open
ensc wants to merge 16 commits intolinux-vserver:masterfrom
ensc:master
Open

improve netns integration#25
ensc wants to merge 16 commits intolinux-vserver:masterfrom
ensc:master

Conversation

@ensc
Copy link
Contributor

@ensc ensc commented Apr 23, 2016

Patchset allows to do create a netns enabled vserver without extra scripts.

  • It improves actual 'netns/' configuration by adding support for 'macvlan' link types
  • it applies iptables setup between link creation and bringing the link up
  • it reuses existing 'interfaces/' infrastructure
  • it adds two 'exec-netns' and 'reload-iptables' command line options for 'vserver'

Example:

/etc/vservers/.../
|- noncontext           # flag
|- netns/
|  |- ip4tables.rules
|  |- ip6tables.rules
|  `- interfaces/
|     `- 0/
|        |- host        # content: 'eth1'
|        `- type        # content: 'macvlan'
`- interfaces/
   |- dev               # content: 'geth0'
   |- 0/
      |- ip             # content: '192.168.12.77'
      |- gw             # content: '192.168.12.65'
      `- prefix         # content: '28'
# vserver mail-msa exec-netns ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
7: geth0@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/ether b6:16:fc:30:df:17 brd ff:ff:ff:ff:ff:ff

ensc and others added 16 commits April 19, 2016 13:42
Execute the is-file check only for bind mounts; they might trigger
e.g. for loop mounts too which is unwanted. As src is located in host
filesystem, we can allow symlinks there.

To prevent symlink attacks (which were possible with the previous
dst-check too) we have to verify the mount destination.  Although the
patch allows races when executed for running guests, it is safe in the
'vserver start' case.


Signed-off-by: Enrico Scholz <enrico.scholz@ensc.de>
Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Run the programs in the guest's netns (when enabled).

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Setting a default route is a very common task when working with netns.
This patch adds a new 'gw' parameter, so that no extra pre-scripts are
needed for vservers with simple networking.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Some interface setup options must be run in netns context.  This patch
runs them through a new CMD_IP_NETNS command.  Later patches will modify
this variable.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
record the network namespace for later patches

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
required for later patches; noop atm

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
'ip netns' related commands require special mounts; skip them in
_namespaceCleanup.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Due to later patches, 'del' must remove macvlan interfaces in guest
context so we need knowledge about device names.

Unified add/del operations.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
'shift' seems to be more reliable then 'unset'. Use it.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
It is sometimes (e.g. for updating iptables setup) useful to have markers
in the kernel log.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Because entering the netns of a running vserver is not trivial,
'exec-netns' and 'reload-iptables' options were added.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant