Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 16 commits into from Aug 1, 2017

Conversation

morphis
Copy link
Contributor

@morphis 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.

@morphis
Copy link
Contributor Author

morphis commented Jul 26, 2017

Support for kernel modules was now added.

Copy link

@jhodapp jhodapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of things I'm curious about.

}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!!

allow-installation:
slot-snap-type:
- core
deny-auto-connection: true
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

zyga added 6 commits July 28, 2017 17:16
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
@zyga
Copy link
Collaborator

zyga commented Jul 28, 2017

I pushed some API changes and cleanups.

Copy link
Collaborator

@zyga zyga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

c.Assert(s.plug.Sanitize(s.iface), IsNil)
}

func (s *BroadcomAsicControlSuite) TestUsedSecuritySystems(c *C) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jhodapp
Copy link

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

Copy link

@jdstrand jdstrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, please use 'rw' here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/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,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

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?

Copy link

@jhodapp jhodapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy now, looks very good!

@jdstrand
Copy link

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

Copy link

@jdstrand jdstrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The security policy changes look good, thanks.

@codecov-io
Copy link

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
Copy link

jhodapp commented Aug 1, 2017

@zyga can you approve this and merge please?

Copy link
Collaborator

@zyga zyga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
@zyga zyga merged commit 5d4d540 into snapcore:master Aug 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants