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

fix: group observations by zeroing port #949

Merged
merged 1 commit into from
May 20, 2020
Merged

Conversation

Stebalien
Copy link
Member

In #917, we started dropping additional address observations if we had multiple for the same transport set. However, on further consideration, this isn't quite correct. We want to keep additional observations for multiple IP addresses. The real issue is many observations for different ports.

So this patch simply changes the key with which we group observations from "address protocols" to "address without the port" (well, with the port set to 0).

In #917, we started dropping additional address observations if we had multiple
for the same transport set. However, on further consideration, this isn't quite
correct. We _want_ to keep additional observations for multiple IP addresses.
The real issue is many observations for different ports.

So this patch simply changes the key with which we group observations from
"address protocols" to "address without the port" (well, with the port set to
0).
Copy link
Collaborator

@aschmahmann aschmahmann left a comment

Choose a reason for hiding this comment

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

LGTM. Added a brief question.

switch proto := c.Protocol(); proto.Code {
case ma.P_TCP, ma.P_UDP:
key = append(key, proto.VCode...)
key = append(key, 0, 0) // zero in two bytes
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Why are we adding in the zero bytes here instead of just skipping them? Is this just a defensive measure to keep them as valid multiaddrs?

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, we could just skip it. But yeah, I wanted these to be valid multiaddrs.

@Stebalien Stebalien merged commit f6d0327 into master May 20, 2020
@aarshkshah1992
Copy link
Contributor

@Stebalien In what scenario would a peer have observed addresses with different IP addresses ?

@Stebalien
Copy link
Member Author

If they have multiple interfaces and/or multiple IP addresses. For example, they might be behind multiple NATs at the same time (I think this is the case for AWS).

@Stebalien Stebalien mentioned this pull request May 26, 2020
77 tasks
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.

3 participants