-
Notifications
You must be signed in to change notification settings - Fork 757
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
Add List option to RouteSubscribeWithOptions, AddrSubscribeWithOptions, and LinkSubscribeWithOptions. #318
Conversation
link_linux.go
Outdated
@@ -1514,6 +1515,16 @@ func linkSubscribeAt(newNs, curNs netns.NsHandle, ch chan<- LinkUpdate, done <-c | |||
s.Close() | |||
}() | |||
} | |||
if list { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, shouldn't the dump request be performed after spawning the receive go routine ?
link_linux.go
Outdated
} | ||
|
||
// LinkSubscribeOptions contains a set of options to use with | ||
// LinkSubscribeWithOptions. | ||
type LinkSubscribeOptions struct { | ||
Namespace *netns.NsHandle | ||
ErrorCallback func(error) | ||
List bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call this ListExisting
? I think it would be more self-explanatory.
Please fix the gofmt issues, so we can get the UT running. |
Also please add a test function for this. |
Thanks. Please squash the commits in one. |
route/addr/link tables as part of RouteSubscribeWithOptions, AddrSubscribeWithOptions, and LinkSubscribeWithOptions.
LGTM |
If an application wants to track the set of kernel routes (or addresses or links) it needs to both determine the initial content and subscribe to changes. However, there are inherent race conditions in using RouteList + RouteSubscribe. If RouteList is invoked before RouteSubscribe then obviously some changes can be lost in between. But more subtly, in the other other the application can see some adds and deletes from the subscribe before the RouteList results, which makes it hard to track the actual content of the kernel.
This patch adds a List boolean option which makes RouteSubscribeWithOptions (and same for addr and links) request the list and the subscription and feed the initial table as "adds" to the application, which makes it a lot easier to track the kernel table.