interfaces/builtin: implement broadcom-asic-control interface #3623

Merged
merged 16 commits into from Aug 1, 2017

Conversation

Projects
None yet
6 participants
Contributor

morphis commented Jul 26, 2017

This implements a new interface necessary to access certain device nodes exposed by the kernel drivers from Broadcom for their ASIC on switch devices.

This requires specific kernel modules to be available and loaded which will be soon shipped with the official Ubuntu kernel.

knitzsche and others added some commits Jul 21, 2017

interfaces/builtin: get rid of description for broadcom-asic-control
Descriptions will be managed on the forum real soon so there is no need
store it inside the code anymore.
Contributor

morphis commented Jul 26, 2017

Support for kernel modules was now added.

Just a couple of things I'm curious about.

+ allow-installation:
+ slot-snap-type:
+ - core
+ deny-auto-connection: true
@jhodapp

jhodapp Jul 26, 2017

What's the difference between this and line 145 returning true for the AutoConnect method?

@morphis

morphis Jul 26, 2017

Contributor

See the comment in https://github.com/snapcore/snapd/pull/3623/files#diff-7657fbc6427572b16bb91d9568774554R144

AutoConnect is more or less a relict from older times. Base declaration has priority.

@jhodapp

jhodapp Jul 26, 2017

Ah yes, I forgot to comment on that comment. :) It didn't make sense to me. Can you reword that comment on line 144?

@morphis

morphis Jul 28, 2017

Contributor

What doesn't make sense? It's the same comment used on all other interfaces for the AutoConnect method.

@jhodapp

jhodapp Jul 28, 2017

So the comment states this:

// Allow what is allowed in the declarations

Maybe if you point to where the reader of the code could know what exactly is allowed, then it'd make more sense to me. It's just too general of a comment to add much value in my opinion.

+ }
+
+ // Creation of the slot of this type is allowed only by a gadget or os snap
+ if !(slot.Snap.Type == "os") {
@jhodapp

jhodapp Jul 26, 2017

This hasn't been changed to being called "core" instead of "os"?

@morphis

morphis Jul 26, 2017

Contributor

The type of a core snap is still "os". See https://github.com/snapcore/snapd/blob/master/snap/types.go#L31 for details

@jhodapp

jhodapp Jul 26, 2017

Sounds like a bug in snapd that should be fixed before there's hundreds or thousands of interfaces.

@zyga

zyga Jul 28, 2017

Contributor

You will be happy to learn I fixed this a moment ago :)

zyga added some commits Jul 28, 2017

interfaces: rename new files to under_score naming scheme
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: remove redundant interface type checks
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: remove unused SanitizePlug method
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: use helper for slot validation
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: discard the unnecessary String method
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Contributor

zyga commented Jul 28, 2017

I pushed some API changes and cleanups.

I pushed API cleanups and did a small review of the code. I think you need an ack from @jdstrand to land this and a review from @niemeyer on the ImplicitOnClassic flag.

+ return interfaces.StaticInfo{
+ Summary: broadcomAsicControlSummary,
+ ImplicitOnCore: true,
+ ImplicitOnClassic: true,
@zyga

zyga Jul 28, 2017

Contributor

I wonder if this should be implicit on classic where it will show up for nearly everyone. It feels like a thing that we could do via classic gadgets if it is really needed there. WDYT?

@jdstrand

jdstrand Jul 28, 2017

Contributor

I think that this interface is very similar to dcdbas-control, which is implicit classic, and therefore we shouldn't make this PR do something else. If we want to clean this up and make conditional on gadgets, etc, that could be a future improvement.

+`
+
+func (s *BroadcomAsicControlSuite) SetUpTest(c *C) {
+ s.slot = &interfaces.Slot{
@zyga

zyga Jul 28, 2017

Contributor

Can you please just declare more snaps like you did above? I'd much rather see snaptest.MockInfo than hand-made structures.

@morphis

morphis Jul 31, 2017

Contributor

Done

+ c.Assert(s.plug.Sanitize(s.iface), IsNil)
+}
+
+func (s *BroadcomAsicControlSuite) TestUsedSecuritySystems(c *C) {
@zyga

zyga Jul 28, 2017

Contributor

Can you please split this per backend. It will be easier to follow and you can use some shorter variable names (e.g. spec instead of apparmorSpec).

@morphis

morphis Jul 31, 2017

Contributor

Done.

jhodapp commented Jul 28, 2017

@zyga @jdstrand Can we have someone else review the ImplicitOnClassic flag usage since Gustavo is out for the next week? We need to keep this review rolling and merged so it gets into the next possible snapd release.

Thanks for staying on top of this review @zyga

The base declaration, apparmor policy, udev rules and kernel modules all look ok, but please make the requested policy changes.

+/sys/module/linux_user_bde/refcnt r,
+/sys/module/linux_bcm_knet/initstate r,
+/sys/module/linux_bcm_knet/holders/ r,
+/sys/module/linux_bcm_knet/refcnt r,
@jdstrand

jdstrand Jul 28, 2017

Contributor

Since these are all only reads, I think the above can all be collapsed into (which is easier to read and futureproof):

/sys/module/linux_bcm_knet/{,**} r,
/sys/module/linux_kernel_bde/{,**} r,
/sys/module/linux_user_bde/{,**} r,
@morphis

morphis Jul 31, 2017

Contributor

Done

+/sys/module/linux_bcm_knet/refcnt r,
+/dev/linux-user-bde rw,
+/dev/linux-kernel-bde rw,
+/dev/linux-bcm-knet wr,
@jdstrand

jdstrand Jul 28, 2017

Contributor

For consistency, please use 'rw' here.

@morphis

morphis Jul 31, 2017

Contributor

Done

+ return interfaces.StaticInfo{
+ Summary: broadcomAsicControlSummary,
+ ImplicitOnCore: true,
+ ImplicitOnClassic: true,
@zyga

zyga Jul 28, 2017

Contributor

I wonder if this should be implicit on classic where it will show up for nearly everyone. It feels like a thing that we could do via classic gadgets if it is really needed there. WDYT?

@jdstrand

jdstrand Jul 28, 2017

Contributor

I think that this interface is very similar to dcdbas-control, which is implicit classic, and therefore we shouldn't make this PR do something else. If we want to clean this up and make conditional on gadgets, etc, that could be a future improvement.

jhodapp commented Jul 28, 2017

@jdstrand Your last comment about implicit classic I don't quite follow. Are you simply stating that it doesn't need any special review/permission in order to use implicit classic before it gets merged, or something else?

Simon Fels added some commits Jul 31, 2017

I'm happy now, looks very good!

Contributor

jdstrand commented Jul 31, 2017

@jhodapp - I was saying that I don't think the implicit parts of this interface need to change.

The security policy changes look good, thanks.

codecov-io commented Jul 31, 2017

Codecov Report

Merging #3623 into master will increase coverage by 0.02%.
The diff coverage is 91.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3623      +/-   ##
==========================================
+ Coverage   75.19%   75.21%   +0.02%     
==========================================
  Files         386      387       +1     
  Lines       33418    33452      +34     
==========================================
+ Hits        25127    25162      +35     
+ Misses       6480     6478       -2     
- Partials     1811     1812       +1
Impacted Files Coverage Δ
interfaces/builtin/broadcom_asic_control.go 91.17% <91.17%> (ø)
overlord/ifacestate/helpers.go 63% <0%> (+0.66%) ⬆️
interfaces/sorting.go 100% <0%> (+1.28%) ⬆️
cmd/snap/cmd_aliases.go 95% <0%> (+1.66%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1bb7d6d...1005db0. Read the comment docs.

jhodapp commented Aug 1, 2017

@zyga can you approve this and merge please?

zyga approved these changes Aug 1, 2017

LGTM

zyga added some commits Aug 1, 2017

interfaces: bump copyright
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: shorten error handling code
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: improve tests for broadcom-asic-control
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

@zyga zyga merged commit 5d4d540 into snapcore:master Aug 1, 2017

6 of 7 checks passed

yakkety-amd64 autopkgtest finished (failure)
Details
artful-amd64 autopkgtest finished (success)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
xenial-amd64 autopkgtest finished (success)
Details
xenial-i386 autopkgtest finished (success)
Details
xenial-ppc64el autopkgtest finished (success)
Details
zesty-amd64 autopkgtest finished (success)
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment