Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
interfaces: support network namespaces via 'ip netns' in network-control (LP: #1624675) #2450
Conversation
jdstrand
added some commits
Dec 8, 2016
|
@javacruft - I tried to test neutron with this using 'snap-deploy' but it wouldn't install neutron. Note, you need to connect the firewall-control interface for nova, but something else is wrong (tried on 16.04). |
zyga
reviewed
Dec 10, 2016
This looks good apart from the spread test as outlined above. The first thing I'd like to do next week is to land the packaging branch so that snapd spread tests can run against the locally built snap-confine. After this is done and after the spread test is adjusted we can land this knowing the feature is fully supported and works OK
| @@ -0,0 +1,34 @@ | ||
| +summary: The /run/netns directory propagates events outwards |
zyga
Dec 10, 2016
Contributor
This looks good but those spread tests don't run (yet). Could you please add this test under tests/main instead?
jdstrand
Dec 12, 2016
Contributor
@zyga Since you just said that the spread tests aren't yet running against the locally built snap-confine, moving the test will result in a spread test failure since the spread-tested snap-confine won't have the changes required. That's why I put the spread test where I did.
zyga
Dec 12, 2016
Contributor
This makes sense (obviously, sorry for not realizing this earlier).
We can now run spread tests as snap-confine is merged at the packaging level in master so we can revisit this.
jdstrand
added some commits
Dec 12, 2016
|
@zyga: thanks. I moved the spread test to tests/main/interfaces-network-namespace-control |
|
FYI, the trusty failure is unrelated: |
|
I'm puzzled what happened with the travis failure-- afaics it just didn't finish, so I 'restarted the build'. |
|
linode:ubuntu-core-16-64:tests/main/interfaces-network-control fails with: hsearch_r failed: No such process hsearch_r sets errno to ESRCH ("No such process") if it can't find the value. This is caused by this seccomp rule: setns - CLONE_NEWNET The linode:ubuntu-core-16-64:tests/main/interfaces-network-namespace-control failed with errors that I would expect with an older snap-confine. It's almost as if the linode machine didn't get the new snap-confine code. If I run spread with -debug, I see:
but I don't know how to map that to a snap-confine or snapd commit. Note that these spread tests pass on autopkgtest for xenial, yakkety and zesty (trusty is a different issue, see my previous comment) so it seems like there is something awry on the linode system. |
|
@mvo5 and I discussed this a bit on IRC. What is happening is that in Travis, the test harness is not pulling in the changes to snap-confine in this PR. This is demonstrated by:
As such, Travis pulled upstream/master, not this PR, which explains why both interfaces-network-control and interfaces-network-namespace-control failed (Travis got the new spread test, but not the code to work with it). Because the autopkgtests did get the updated code and the tests passed there, I believe that the Travis spread failures should not impact this PR's acceptance, since once this PR is committed, upstream/master will have all the bits needed for the spread test to pass. |
|
@mvo5 asked me to update this PR with upstream/master so keep in mind that will remove the specific evidence for the Travis failure. |
|
Fwiw, snap-confine |
|
FYI, with the new push these are the only failures: I don't know what the first is. @mvo5 - could the last two be because it is an all snaps image and not getting the updated snap-confine? |
|
install-remove-multi failure is unrelated:
|
mvo5
added this to the 2.20 milestone
Dec 13, 2016
mvo5
referenced this pull request
Dec 13, 2016
Merged
tests: update custom core snap with the freshly build snap-confine #2472
jdstrand
added some commits
Dec 13, 2016
jdstrand
changed the title from
interfaces: add network-namespace-control (LP: #1624675)
to
interfaces: support network namespaces via 'ip netns' in network-control (LP: #1624675)
Dec 13, 2016
|
With the new commits into network-control, only linode:ubuntu-core-16-64:tests/main/interfaces-network-control-ip-netns fails for the same reasons as before. On zesty, these unrelated failures:
Note, these same to be failing in other PRs. Eg #1613 (comment) |
|
@mvo5 - I incorporated the feedback from Gustavo and retested locally and see that it is passing in non-all-snaps systems. This got a +1 from Zygmunt. I believe this is ready to merge pending how you want to handle the test infrastructure. |
|
Thanks, I merged master and now spread is happy. |
mvo5
merged commit 1bb919f
into
snapcore:master
Dec 14, 2016
4 of 6 checks passed
|
Thanks! |
jdstrand
deleted the
jdstrand:network-namespace-control
branch
Jan 9, 2017
croepha
commented
Jan 12, 2017
•
|
I feel like I'm late to party here, and also I might be missing something, as I'm not very familiar with the internals of snappy as you all are, but as I understand it the goal of these changes is to allow snaps to set their network namespace. While I think that Is a fine and acceptable goal, wouldn't a more powerful feature be a way for snappy-confine to set the appropriate net namespace for the snap? With the approach that is enabled by this PR you are trusting the snap to set its namespace properly, but if you did it with confine then you wouldn't have to trust the snap... The snap would just run in that net namespace and if there were appropriate ipsec rules then that snap wouldn't be allowed to do anything on/from the root ip and not able to access the systems root loopback interface... |
|
@croepha - Hi! We intentionally have snaps run in the global network namespace so they are fully integrated into the system. Snappy is a bit different from container technologies like docker and lxd in that while we leverage various container technologies to implement the sandbox, snaps are meant to integrate into the system and feel like installed applications that can interact with each other and the system in controlled ways. A mental model one can use is: snaps are for applications that integrate into the system, docker can be used for 'process containers' where the application process is in its own namespace for everything and lxd can be thought of as full machine as a container (eg, think 'migrating a VM to a container' where everything in that container shares the same container-specific namespace for everything). With that in mind, this interface allows snaps that 'plugs: [ network-control ]' (a very privileged interface that allows configuring all kings of networking on the device) to also be able to use 'ip netns' to setup network namespaces for the system or other snaps to then use and enter. This is useful in and of itself for management snaps. I agree it would be useful to limit what snaps can do with networking (eg, loopback, talking to other snaps on the system via network IPC) and this work is planned. To preserve the properties of integrating into the system, this will be implemented using AppArmor fine-grained network mediation which will (rather easily once fine-grained network mediation is finished) allow things like interface connections for daemon network listeners just like we do with unix sockets. |
jdstrand commentedDec 10, 2016
•
Edited 1 time
-
jdstrand
Dec 10, 2016
This interface allows snaps to use the 'ip netns' command to create and use persistent network namespaces that can by entered via
setns(),nsenter --net=/run/netns/...andip netns execby other snaps or unsnapped processes.This PR:
With the recent move of snap-confine into snapd, snap-confine's spread.yaml was removed and its spread tests cannot be run. I did install an updated snapd and snap-confine in a VM and ran the spread test's commands successfully.
I'm on the fence regarding having
network-namespace-controlin its own interface as opposed to just being added tonetwork-control. On the one hand, not all snaps that usenetwork-controlwill need or want to setup persistent network interfaces via 'ip netns', but probably every snap that plugsnetwork-namespace-controlwill then neednetwork-controlto do anything interesting with the network namespace. In addition, having only a subset of the ip command supported in each ofnetwork-controlandnetwork-namespace-controlfeels a little odd.Interestingly, developing this PR resulted in discovering two apparmor bugs and highlighting a seccomp missing feature in snappy kernels:
plugs: [ network-namespace-control ]and avoid the hack)ip netns identify <pid>andip netns pids <namespace>require ptracing other processes. Up until the 4.8 kernels allowing ptrace would allow for a seccomp sandbox escape. As a result, I added explicit deny rules with audit to block and document the attack but serve as a reminder to get it fixed. Once this patch is backported, made available as part of our snappy kernel porting guide and in our supported kernels, we can allowptrace (trace) peer=snap.@{SNAP_NAME}.*,in the default template then addptrace (trace),to theprocess-controlinterface or perhaps a separateptraceinterface.UPDATE: @niemeyer and I decided this would be better in network-control so I've updated the PR accordingly. Note that references to 'network-namespace-control' in the comments refer to the original PR that implemented this as a separate interface.