Add LinkDriver interface and Driver package#221
Add LinkDriver interface and Driver package#221jsimonetti merged 5 commits intojsimonetti:masterfrom
Conversation
9a147fe to
9eefed8
Compare
|
First off, thank you. This is very nice! I have a few nits which I will comment on while I review. (Please allow me a day or two). One thing i would like to discuss is First off, this function is not threadsafe. So it should have a very clear comment and documentation that it is very unwise to use after you Second, I think we should make a choice for the driver package. Currently it registers the drivers on What do you think? |
|
Thanks for pointing these out. Since Initializing drivers with the second option makes more sense. We'll keep it this way and add Another thing is that I have observed that the iproute2 tool does not send any attribute that is not initialized. I added the name behind a check because it was causing problems. It seems we could do the same for the values below. But I did not want to overcomplicate the PR. Am I missing anything here? I will make all of the changes after your review. |
9eefed8 to
4ea0bf5
Compare
|
I think I might have made your process a bit complicated by rebasing using github by accident. My appologies. |
I believe you are correct. I have not had the need to address this though. I am fine with adding this to the PR |
This commit removes unix.IFLA_UNSPEC and introduces checks for the interface name, the link type and the queue disc fields. Interface name validation is necessary to prevent an 'invalid argument' error when creating a link with an empty name. Other checks were added to be consistent with the ip tools. Signed-off-by: Birol Bilgin <[email protected]>
This commit introduces the NetNS struct and integrates network namespace capabilities into link attributes. This enhancement facilitates the creation of links, such as veth pairs, across different network namespaces without the need to execute directly within those namespaces. Signed-off-by: Birol Bilgin <[email protected]>
This commit introduces a Driver interface and changes Data and SlaveData fields within the LinkInfo struct as LinkDriver to accommodate driver-specific data encoding, addressing the limitation where LinkInfo.Data and SlaveData fields were merely byte slices without support for specific data encoding. Drivers are registered globally with the RegisterDriver function. For un-registered drivers, the default LinkData driver is used. Signed-off-by: Birol Bilgin <[email protected]>
4ea0bf5 to
ea66878
Compare
This commit introduces the 'driver' package, which contains specific implementations of the LinkDriver interface. It also includes the implementation of the Linux bond driver as LinkDriver and the bond slave driver as LinkSlaveDriver. Signed-off-by: Birol Bilgin <[email protected]>
ea66878 to
ede371c
Compare
|
While adding documentation to the drivers, I found a couple of issues and fixed them. |
jsimonetti
left a comment
There was a problem hiding this comment.
Last nit I found. The rest is looking awesome!
This commit adds Netkit and Veth drivers. Signed-off-by: Birol Bilgin <[email protected]>
ede371c to
22f75eb
Compare
@brlbil Thank you once again for this contribution! |
|
@brlbil I am keen to add some more drivers. Could you tell me how you found out what the layout of the linkinfo should be? |
|
@jsimonetti It is good to hear that. I want to work on it but I do not have much spare time these days. I have looked at other Golang Netlink library that implements drivers. It helps but there are some differences because it is designed differently. I have looked at the iproute2 tool but later I learned that it should not be taken as a reference implementation, the net namespace implementation that later changes. Lastly, I have looked at the kernel source https://elixir.bootlin.com/linux/latest/source/drivers/net and kernel patch messages. |
This PR adds a
LinkDriverinterface that replaces theLinkInfo.DataandSlaveDatafields andadds Driver package with link drivers
Bond,Netkit, andVeththat implement theLinkDriverinterface.Only these three drivers are implemented to demonstrate different kinds of link drivers and not complicate the PR.
Please take a look at the commit messages for individual changes.
Fixes: #216