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

Add List option to RouteSubscribeWithOptions, AddrSubscribeWithOptions, and LinkSubscribeWithOptions. #318

Merged
merged 1 commit into from
Jan 23, 2018

Conversation

eriknordmark
Copy link
Contributor

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.

link_linux.go Outdated
@@ -1514,6 +1515,16 @@ func linkSubscribeAt(newNs, curNs netns.NsHandle, ch chan<- LinkUpdate, done <-c
s.Close()
}()
}
if list {
Copy link
Collaborator

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

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.

@aboch
Copy link
Collaborator

aboch commented Jan 20, 2018

Please fix the gofmt issues, so we can get the UT running.

@aboch
Copy link
Collaborator

aboch commented Jan 20, 2018

Also please add a test function for this.

@aboch
Copy link
Collaborator

aboch commented Jan 23, 2018

Thanks. Please squash the commits in one.

route/addr/link tables as part of RouteSubscribeWithOptions,
AddrSubscribeWithOptions, and LinkSubscribeWithOptions.
@aboch
Copy link
Collaborator

aboch commented Jan 23, 2018

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants