Skip to content

Comments

autonatv2: fix server dial data request policy#3247

Merged
sukunrt merged 1 commit intomasterfrom
push-quwlmmlszssr
Mar 24, 2025
Merged

autonatv2: fix server dial data request policy#3247
sukunrt merged 1 commit intomasterfrom
push-quwlmmlszssr

Conversation

@sukunrt
Copy link
Member

@sukunrt sukunrt commented Mar 21, 2025

The policy was comparing the connection local addr to the observed addr. This should be comparing the connection remote addr to the requested dial addr.

The impact here is:
if we refresh reachability for addresses every hour, we will be spending 100kB per address per hour. That's equivalent to 30 B/s. For 10 addrs this will be 300 B/s or 3kb/s

@sukunrt sukunrt requested a review from MarcoPolo March 21, 2025 18:48
@sukunrt sukunrt force-pushed the push-quwlmmlszssr branch 3 times, most recently from f796e0f to dd21c0d Compare March 21, 2025 18:55
Copy link
Collaborator

@MarcoPolo MarcoPolo left a comment

Choose a reason for hiding this comment

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

one thing around the test, but otherwise good


// amplificationAttackPrevention is a dialDataRequestPolicy which requests data when the peer's observed
// IP address is different from the dial back IP address
func amplificationAttackPrevention(s network.Stream, dialAddr ma.Multiaddr) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

dialAddr was previously unused? That seems like it should have been caught by a lint check.

Copy link
Member Author

@sukunrt sukunrt Mar 24, 2025

Choose a reason for hiding this comment

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

agreed. Made #3248 to track this.

I've configured my editor, but we should enable lint checks in ci too.

require.Error(t, err)

// ipv6 address should work fine with dial data
res, err = c.GetReachability(context.Background(), []Request{{Addr: quicv6Addr, SendDialData: true}})
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this check actually asserts that dial data was requested, right?

Is there a way to assert that we were requested dial data?

Copy link
Member Author

Choose a reason for hiding this comment

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

added this to the checks:
require.ErrorContains(t, err, "invalid dial data request: low priority addr")

The policy was comparing the connection local addr to the observed
addr. This should be comparing the connection remote addr to the
requested dial addr.

The impact here is:
if we refresh reachability for addresses every hour, we will be spending
100kB per address per hour. That's equivalent to 30 B/s. For 10 addrs 
this will be 300 B/s or 3kb/s
@sukunrt sukunrt force-pushed the push-quwlmmlszssr branch from dd21c0d to 77eba57 Compare March 24, 2025 15:25
@sukunrt sukunrt requested a review from MarcoPolo March 24, 2025 15:25
@sukunrt sukunrt merged commit 0682ad7 into master Mar 24, 2025
9 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.

2 participants