Skip to content

Conversation

@lzx404243
Copy link
Collaborator

@lzx404243 lzx404243 commented May 10, 2023

While updating the PROXY protocol tests, I observe the https connections to the origin would hang when PROXY protocol out is enabled in ATS. This PR addresses this.

root cause

After the #9366 changes, the logic of kicking off state machine is in ConnectingEntry and is triggered by callbacks upon one of VC_EVENT_READ_COMPLETE, VC_EVENT_WRITE_READY or VC_EVENT_WRITE_COMPLETE events. The root cause of the hang has to do with none of these events is triggered:

  • Without PROXY protocol enabled, the VC_EVENT_WRITE_READY is triggered and the connection flows. However when PROXY protocol out is enabled, as PROXY protocol data is sent before ssl handshake, the accounting of vio.nbytes and vio.donechanged , leading to VC_EVENT_WRITE_READY not being triggered.
  • VC_EVENT_READ_COMPLETE is not triggered because vio read is not enabled. Prior to Http2 to origin #9366, attach_server_session() enables vio read and is called prior to the handshake. After Http2 to origin #9366, this is called after the handshake so the vio read is disabled during the handshake. As read is disabled, the VC_EVENT_READ_COMPLETE can't be signaled to the handler.

This PR adds a 0-byte read so the vio read is enabled and ConnectingEntry::state_http_server_open() handler can be signaled and called back with the VC_EVENT_READ_COMPLETE event.

@lzx404243 lzx404243 self-assigned this May 10, 2023
@bneradt bneradt added this to the 10.0.0 milestone May 10, 2023
> POST / HTTP/1.1
``
< HTTP/1.1 502 Connection refused
< HTTP/1.1 502 Broken pipe
Copy link
Collaborator Author

@lzx404243 lzx404243 May 11, 2023

Choose a reason for hiding this comment

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

Note to reviewers:

The post_slow_server_max_requests_in was failing with my changes, as it expects a 502 Connection refused, but gets a 502 Broken pipe.

The expectation changed from 502 Broken pipe->502 Connection refused as part of the #9366. Discussed with @bneradt and we believe we should update/revert the expectation to the original. After this PR, certain things seem to be more aligned to how they worked pre H2ToOrigin.

Copy link
Contributor

@bneradt bneradt left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks for fixing and updating the tests.

@bryancall bryancall requested a review from cmcfarlen May 15, 2023 22:27
@ezelkow1
Copy link
Member

[approve ci centos]

@cmcfarlen cmcfarlen requested a review from bneradt May 22, 2023 16:08
@bneradt bneradt merged commit a805575 into apache:master May 22, 2023
cmcfarlen pushed a commit to cmcfarlen/trafficserver that referenced this pull request Jun 3, 2024
* asf/master:
  Fix PROXY protocol out with tls (apache#9698)
  Add automatic detection of ccache for cmake (apache#9720)
  Fix cqpv log field value on H3 connections (apache#9719)
  system_stats: fix buffer overflow caught by asan (apache#9723)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants