-
Notifications
You must be signed in to change notification settings - Fork 64
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
Prevent dual-stack spamming #275
Conversation
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.
Thanks age left come somments
src/service/ip_vote.rs
Outdated
SocketAddr::V6(socket) => *ip6_count.entry(*socket).or_insert_with(|| 0) += 1, | ||
} | ||
} | ||
self.ipv4_votes.retain(|_, v| v.1 > instant); |
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.
does the order import for majority calculation?
I.e why do we have a test function for test_three_way_vote_draw
.
We can save 2 iterations if we combine majority calculation and stale votes removal did at
ac644c8 but test_three_way_vote_draw
fails
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.
Yeah I think your changes are better. Can't remember about that test. I think we wanted to test that if there is a draw it at least returns Some and not None. It probably should be random from the tie.
Can you make a PR to adjust the logic to what you have here.
Why don't we just mutate the hashmap in the function rather than returning a new hashmap and re-setting it?
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.
yeah makes sense, updated and added the function to your PR!
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.
Going to approve so that if you think it's ready to merge can merge it age!
src/service/ip_vote.rs
Outdated
SocketAddr::V6(socket) => *ip6_count.entry(*socket).or_insert_with(|| 0) += 1, | ||
} | ||
} | ||
self.ipv4_votes.retain(|_, v| v.1 > instant); |
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.
yeah makes sense, updated and added the function to your PR!
Description
I've been testing Ipv6 and dual stack support.
There was a bug, where in dual-stack mode, if a router has not SNAT'd correctly they use random source ports. The
majority()
voting system will never reach a majority and we will continue to ping all peers we see.We waste a lot of traffic as we are never going to reach a majority in this scenario. The correct logic is not to check for a majority on a specific port before asking more more PING's rather, if we have enough PONG responses to reach a majority if our NAT was correctly set up, then no longer send more PINGs.
This PR updates to this new logic.