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
Conversation
mcastelino
reviewed
Dec 12, 2016
| assert.Nil(vnic.GetDeviceByName("testiface")) | ||
| assert.NotEqual(vnic.InterfaceName(), "") | ||
| assert.Equal(vnic.InterfaceName(), vnic1.InterfaceName()) | ||
| assert.NotEqual(vnic1.PeerName(), "") |
Contributor
There was a problem hiding this comment.
This may be incorrect... why are you checking peerName for a VM Vnic?
Author
There was a problem hiding this comment.
You're right. But I guess TestVnic_GetDevice() is also incorrect then.
Contributor
There was a problem hiding this comment.
It works because of https://github.com/01org/ciao/blob/master/networking/libsnnet/vnic.go#L66
I forgot about that. So this is ok
Contributor
|
@sboeuf Please look at the travis builds - looks like you introduce a panic triggered by the unit tests. |
Author
|
@rbradford yes I have noticed those issues, I will investigate them today. |
1 similar comment
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>
1 similar comment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.