Skip to content

quic: Fix QuicFilterManagerConnectionImpl::ConnectionInfoProviderSharedPtr - #19008

Merged
RyanTheOptimist merged 9 commits into
envoyproxy:mainfrom
RyanTheOptimist:ConnectionInfoProviderSharedPtr
Nov 18, 2021
Merged

RyanTheOptimist merged 9 commits into
envoyproxy:mainfrom
RyanTheOptimist:ConnectionInfoProviderSharedPtr

Conversation

@RyanTheOptimist

Copy link
Copy Markdown
Contributor

quic: Fix QuicFilterManagerConnectionImpl::ConnectionInfoProviderSharedPtr

If QuicFilterManagerConnectionImpl::ConnectionInfoProviderSharedPtr is
called after the connection is closed, return nullptr.

Risk Level: Low
Testing: New unit tests
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

/assign @danzh2010

…edPtr

If QuicFilterManagerConnectionImpl::ConnectionInfoProviderSharedPtr is
called after the connection is closed, return nullptr.

Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
@RyanTheOptimist
RyanTheOptimist force-pushed the ConnectionInfoProviderSharedPtr branch from 62b824b to 60919fc Compare November 15, 2021 19:25
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
@@ -64,6 +64,9 @@ class QuicFilterManagerConnectionImpl : public Network::ConnectionImplBase,
return network_connection_->connectionSocket()->connectionInfoProvider();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this one need the same fix as well?

Copy link
Copy Markdown
Contributor Author

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 one is fixable, at least not without a larger refactor of this class (which maybe we should do?). This method returns a reference to a ConnectionInfoSetter. But if the network_connection_ or the network_connection_->connectionSocket() are null then this method will return a null reference (which is illegal). So presumably this method must only be called when they are non-null? If that is not a valid assumption then perhaps we need to refactor this class to make this information always available?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good point! Can you add ENVOY_BUG before returning?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

return network_connection_->connectionSocket()->connectionInfoProvider();
}
Network::ConnectionInfoProviderSharedPtr connectionInfoProviderSharedPtr() const override {
if (!network_connection_ || !network_connection_->connectionSocket()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this break existing tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I hope not :) If either of those are null when this method is called, we would see a crash in the old code. With the new code, we don't crash, we just return null. CI is green, so I think we're ok.

Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
danzh2010
danzh2010 previously approved these changes Nov 16, 2021

@danzh2010 danzh2010 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing this!

@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

/assign @alyssawilk

@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only

Copy link
Copy Markdown

Retrying Azure Pipelines:
Check envoy-presubmit didn't fail.

🐱

Caused by: a #19008 (comment) was created by @RyanTheOptimist.

see: more, trace.

alyssawilk
alyssawilk previously approved these changes Nov 17, 2021
}
};

TEST(QuicFilterManagerConnectionImplTest, ConnectionInfoProviderSharedPtr) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional, do you think we should make this all a test fixture, for ease of future tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Heh, I did consider it initially and wasn't sure if it'd be worth doing. But if it also occurred to you then I'm sure it is. Done!

Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
@RyanTheOptimist
RyanTheOptimist dismissed stale reviews from alyssawilk and danzh2010 via a08314b November 17, 2021 21:46

@RyanTheOptimist RyanTheOptimist left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks

}
};

TEST(QuicFilterManagerConnectionImplTest, ConnectionInfoProviderSharedPtr) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Heh, I did consider it initially and wasn't sure if it'd be worth doing. But if it also occurred to you then I'm sure it is. Done!

@RyanTheOptimist
RyanTheOptimist merged commit aac4631 into envoyproxy:main Nov 18, 2021
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