fix: group observations by zeroing port#949
Merged
Conversation
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).
f1502a3 to
6ef5f5d
Compare
aschmahmann
approved these changes
May 20, 2020
Collaborator
aschmahmann
left a comment
There was a problem hiding this comment.
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 |
Collaborator
There was a problem hiding this comment.
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?
Member
Author
There was a problem hiding this comment.
You're right, we could just skip it. But yeah, I wanted these to be valid multiaddrs.
Contributor
|
@Stebalien In what scenario would a peer have observed addresses with different IP addresses ? |
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). |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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).