Iām using the User guide from DPDK about mounting the hugepages fs in /mnt/huge and when I run this in devmode or classic, this works, but running in confined (currently testing in jailmode) I get the error running the command.
Iām at a lost as to how to get /mnt loaded in the /var/lib/snapd/hostfs.
As mentioned on IRC I think there are several topics here:
Does dpdk strictly require /mnt/huge as the mount point? If no then we could expose access to /dev/hugepages and ignore the extra mount point. As another possibility we could make a bind mount from /dev/hugepages to /mnt/huge when the interface is connected. Alternatively if the filesystem can be mounted multiple times we could mount a private instance of hugetblfs somewhere inside the mount namespace.
The rule /var/lib/snapd/hostfs/{,*} rw, grants full access to all the files in the root directory and even if corrected to use ** (which grants recursive access) would be a wide-open hole to all of the host. I donāt think we need that.
Ideally, to move forward, we could use a snap that can be used as a test vehicle and we would develop the most natural variant of the possibilities I mentioned.
I will mention for completeness that your are seeing the denial because this rule should be: /var/lib/snapd/hostfs/{,**} rw,. But as @zyga-snapd said, this rule isnāt appropriate for the interface and we would want to come up with something better.
Now that I understand how /var/lib/snaps/hostfs works I agree I need a better option.
Hugepage support is required for the large memory pool allocation used for packet buffers. By using hugepage allocations, performance is increased since fewer pages are needed, and therefore less Translation Lookaside Buffers (TLBs, high speed translation caches), which reduce the time it takes to translate a virtual page address to a physical page address. Without hugepages, high TLB miss rates would occur with the standard 4k page size, slowing performance.
To allow DPDK to use hugepages, after you set the parameter at boot with a kernel parameter (hugepages=1024)
In the deb version of DPDK, we use a script that is executed by systemd at startup that allocates the hugepages and mount point. I havenāt test if it is hardcoded to /mnt/huge, I will test that today, but if I am remember correct, all dpdk is looking for is a mount point with the flags of filesystem hugetlbfs and a nodev flag. I am using /mnt/huge since the DPDK user guide uses it as an example (section 2.3.2.2) and force of habit of using DPDK.
I will try the mount-observe interface and see what happens with that and let you know.
Ok. So I tried the mount-observe interface, but go the same error. I then tried mounting /huge under /media and using removable-media interface, but that resulted in the same error, but it did verify that DPDK is just looking for the hugetlbfs filesystem and the nodev flag since it did move the error to /var/lib/snapd/hostfs/media/huge.
I then modified my hugepages-observe interface that I am working on to just do the read permission for /var/lib/snapd/hostfs/ and that seemed to work, but now I get the following error when DPDK tries to write a lockfile to /var/lib/snapd/hostfs/media/huge:
So I changed my rule for hugepages-observe to read /var/lib/snapd/hostfs and that fixed me to the next step where I then got a deny for wk on /var/lib/snapd/hostfs/mnt/huge, so I created a rule in hugepages-control interface (temporary so I could continue working on confinement while I get guidence on the hostfs). I then was getting a mknod error for /run, but fixed that by adding /run/{,**} c, and I get the following error now:
Jun 12 21:46:37 dpdk-test kernel: [ 107.609886] audit: type=1400 audit(1528839997.736:31): apparmor="DENIED" operation="change_onexec" info="label not found" error=-2 profile="/usr/lib/snapd/snap-confine" name="snap.dpdk-wililupy.testpmd" pid=1541 comm="snap-confine"
Now Iām getting somewhere. I removed my snap, recompiled it with strict and stable confinement and grade, and when I was connecting the interfaces, when I went to connect the hugepages-control interface, I got this error:
Jun 13 17:08:21 dpdk-test kernel: [ 1221.310557] audit: type=1400 audit(1528909701.980:63): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="/snap/core/4650/usr/lib/snapd/snap-confine//mount-namespace-capture-helper" pid=3364 comm="apparmor_parser"
Jun 13 17:08:21 dpdk-test kernel: [ 1221.323305] audit: type=1400 audit(1528909701.992:64): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap-update-ns.core" pid=3366 comm="apparmor_parser"
Jun 13 17:08:22 dpdk-test kernel: [ 1221.331349] audit: type=1400 audit(1528909702.000:65): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.core.hook.configure" pid=3368 comm="apparmor_parser"
Jun 13 17:08:22 dpdk-test kernel: [ 1221.413606] audit: type=1400 audit(1528909702.080:66): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap-update-ns.dpdk-wililupy" pid=3375 comm="apparmor_parser"
And this was from the terminal:
error: cannot perform the following tasks:
- Connect dpdk-wililupy:hugepages-control to core:hugepages-control (cannot setup apparmor for snap "dpdk-wililupy": cannot load apparmor profile "snap.dpdk-wililupy.testpmd": cannot load apparmor profile: exit status 1
apparmor_parser output:
AppArmor parser error for /var/lib/snapd/apparmor/profiles/snap.dpdk-wililupy.testpmd in /var/lib/snapd/apparmor/profiles/snap.dpdk-wililupy.testpmd at line 449: syntax error, unexpected TOK_ID, expecting TOK_MODE
)
- Connect dpdk-wililupy:hugepages-control to core:hugepages-control (cannot load apparmor profile "snap.dpdk-wililupy.testpmd": cannot load apparmor profile: exit status 1
apparmor_parser output:
AppArmor parser error for /var/lib/snapd/apparmor/profiles/snap.dpdk-wililupy.testpmd in /var/lib/snapd/apparmor/profiles/snap.dpdk-wililupy.testpmd at line 449: syntax error, unexpected TOK_ID, expecting TOK_MODE
)
I pushed my snapd changes to my git repo (https://github.com/wililupy/snapd) and so I think I have an issue with my hugepages-control interface. Iāll look there and see what I dig up.
I am working on the /mnt aspect and I will update this thread when that is available. Right now it is not something that can be done with interfaces alone.