Skip to content
This repository was archived by the owner on Jul 16, 2020. It is now read-only.

networking: libsnnet: Make API more explicit and get existing VNIC device by name#966

Merged
mcastelino merged 2 commits into
ciao-project:masterfrom
sboeuf:master
Dec 13, 2016
Merged

networking: libsnnet: Make API more explicit and get existing VNIC device by name#966
mcastelino merged 2 commits into
ciao-project:masterfrom
sboeuf:master

Conversation

@sboeuf

@sboeuf sboeuf commented Dec 12, 2016

Copy link
Copy Markdown

libsnnet API lets us get an existing VNIC device only from its alias. Because this
API is used externally by other project such as virtcontainers, there are cases where
no alias is set for an existing interface, and we want to be able to retrieve a VNIC
object from this existing interface.

This PR duplicates the existing GetDevice() to provide a new GetDeviceByName, relying
on netlink LinkByName function. It builds a VNIC object according to the information found
for the related link name.

The API SetHardwareAddr() was implicitely creating a Vnic peer related
to the current Vnic, and it was setting the hardware address for this peer.
It was a very specific case for Ciao but we want more explicit things now
that libsnnet is used externally from other projects.

This PR simplifies SetHardwareAddr() function and adds the complexity
in the Ciao's calling code instead.

Also, it returns a default peer name in case the link name does not fit the
expected prefixes. It is needed because in case you set manually the link
name, you will get a creation error. Indeed, the peer name will be "", and
it will be impossible to create a link with that name.

assert.Nil(vnic.GetDeviceByName("testiface"))
assert.NotEqual(vnic.InterfaceName(), "")
assert.Equal(vnic.InterfaceName(), vnic1.InterfaceName())
assert.NotEqual(vnic1.PeerName(), "")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This may be incorrect... why are you checking peerName for a VM Vnic?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

You're right. But I guess TestVnic_GetDevice() is also incorrect then.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sboeuf sboeuf changed the title networking: libsnnet: Get existing VNIC device by name networking: libsnnet: Make API more explicit and get existing VNIC device by name Dec 12, 2016
@rbradford

Copy link
Copy Markdown
Contributor

@sboeuf Please look at the travis builds - looks like you introduce a panic triggered by the unit tests.

@sboeuf

sboeuf commented Dec 13, 2016

Copy link
Copy Markdown
Author

@rbradford yes I have noticed those issues, I will investigate them today.

@coveralls

coveralls commented Dec 13, 2016

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.01%) to 66.626% when pulling ff86766 on sboeuf:master into a4835f0 on 01org:master.

1 similar comment
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.01%) to 66.626% when pulling ff86766 on sboeuf:master into a4835f0 on 01org:master.

Sebastien Boeuf added 2 commits December 13, 2016 15:05
libsnnet API lets us get an existing VNIC device only from its alias. Because this
API is used externally by other project such as virtcontainers, there are cases where
no alias is set for an existing interface, and we want to be able to retrieve a VNIC
object from this existing interface.

This patch duplicates the existing GetDevice() to provide a new GetDeviceByName, relying
on netlink LinkByName function. It builds a VNIC object according to the information found
for the related link name.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
The API SetHardwareAddr() was implicitely creating a Vnic peer related
to the current Vnic, and it was setting the hardware address for this peer.
It was a very specific case for Ciao but we want more explicit things now
that libsnnet is used externally from other projects.

This patch simplifies SetHardwareAddr() function and adds the complexity
in the Ciao's calling code instead.

Also, it returns a default peer name in case the link name does not fit the
expected prefixes. It is needed because in case you set manually the link
name, you will get a creation error. Indeed, the peer name will be "", and
it will be impossible to create a link with that name.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 66.646% when pulling fce606b on sboeuf:master into a4835f0 on 01org:master.

1 similar comment
@coveralls

coveralls commented Dec 13, 2016

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 66.646% when pulling fce606b on sboeuf:master into a4835f0 on 01org:master.

@mcastelino mcastelino merged commit d0bb7a1 into ciao-project:master Dec 13, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants