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

Prevent dual-stack spamming #275

Merged
merged 8 commits into from
Jan 22, 2025
Merged

Prevent dual-stack spamming #275

merged 8 commits into from
Jan 22, 2025

Conversation

AgeManning
Copy link
Member

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.

@AgeManning AgeManning requested a review from jxs January 15, 2025 05:40
src/service/ip_vote.rs Outdated Show resolved Hide resolved
Copy link
Member

@jxs jxs left a 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 Show resolved Hide resolved
src/service/ip_vote.rs Outdated Show resolved Hide resolved
SocketAddr::V6(socket) => *ip6_count.entry(*socket).or_insert_with(|| 0) += 1,
}
}
self.ipv4_votes.retain(|_, v| v.1 > instant);
Copy link
Member

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

Copy link
Member Author

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?

Copy link
Member

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!

Copy link
Member

@jxs jxs left a 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!

SocketAddr::V6(socket) => *ip6_count.entry(*socket).or_insert_with(|| 0) += 1,
}
}
self.ipv4_votes.retain(|_, v| v.1 > instant);
Copy link
Member

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!

@AgeManning AgeManning merged commit 1445a56 into master Jan 22, 2025
6 checks passed
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