Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci/rat-exclude.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ blib/**
**/*.default.in
**/*.config
**/*.gold
**/go.mod
**/go.sum
**/*.hrw4u
**/.gitignore
**/.gitmodules
Expand Down
22 changes: 20 additions & 2 deletions include/iocore/net/quic/Mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "iocore/net/quic/QUICStreamAdapter.h"
#include "iocore/net/quic/QUICStream.h"

#include <algorithm>

class MockQUICContext;

using namespace std::literals;
Expand Down Expand Up @@ -191,6 +193,11 @@ class MockQUICConnectionInfoProvider : public QUICConnectionInfoProvider
{
return negotiated_application_name_sv;
}

void
on_stream_updated() override
{
}
};

class MockQUICStreamManager : public QUICStreamManager
Expand Down Expand Up @@ -431,6 +438,11 @@ class MockQUICConnection : public QUICConnection
return negotiated_application_name_sv;
}

void
on_stream_updated() override
{
}

int _transmit_count = 0;
int _retransmit_count = 0;
Ptr<ProxyMutex> _mutex;
Expand Down Expand Up @@ -519,13 +531,19 @@ class MockQUICStreamAdapter : public QUICStreamAdapter
Ptr<IOBufferBlock>
_read(size_t len) override
{
this->_sending_data_len -= len;
Ptr<IOBufferBlock> block = make_ptr<IOBufferBlock>(new_IOBufferBlock());
len = std::min(len, this->_sending_data_len);
Ptr<IOBufferBlock> block = make_ptr<IOBufferBlock>(new_IOBufferBlock());
block->alloc(iobuffer_size_to_index(len, BUFFER_SIZE_INDEX_32K));
block->fill(len);
return block;
}

void
_consume(size_t len) override
{
this->_sending_data_len -= std::min(len, this->_sending_data_len);
}

private:
size_t _sending_data_len = 0;
size_t _total_sending_data_len = 0;
Expand Down
1 change: 1 addition & 0 deletions include/iocore/net/quic/QUICConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class QUICConnectionInfoProvider
virtual bool is_handshake_completed() const = 0;
virtual QUICVersion negotiated_version() const = 0;
virtual std::string_view negotiated_application_name() const = 0;
virtual void on_stream_updated() = 0;
};

class QUICConnection : public QUICConnectionInfoProvider
Expand Down
6 changes: 6 additions & 0 deletions include/iocore/net/quic/QUICStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "tscore/List.h"

#include "iocore/eventsystem/Event.h"
#include "iocore/eventsystem/IOBuffer.h"

#include "iocore/net/quic/QUICConnection.h"
#include "iocore/net/quic/QUICDebugNames.h"
Expand Down Expand Up @@ -53,6 +54,7 @@ class QUICStream
QUICStreamDirection direction() const;
bool is_bidirectional() const;
bool has_no_more_data() const;
bool has_data_to_send();

QUICOffset final_offset() const;

Expand All @@ -66,6 +68,7 @@ class QUICStream
* QUICApplication need to call one of these functions when it process VC_EVENT_*
*/
void on_read();
void on_write();
void on_eos();

/**
Expand All @@ -85,6 +88,9 @@ class QUICStream
uint64_t _received_bytes = 0;
uint64_t _sent_bytes = 0;
bool _has_no_more_data = false;
Ptr<IOBufferBlock> _pending_send_block;
bool _pending_send_fin = false;
bool _sent_fin = false;
};

class QUICStreamStateListener
Expand Down
4 changes: 3 additions & 1 deletion include/iocore/net/quic/QUICStreamAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class QUICStreamAdapter

virtual int64_t write(QUICOffset offset, const uint8_t *data, uint64_t data_length, bool fin) = 0;
Ptr<IOBufferBlock> read(size_t len);
void consume(size_t len);
virtual bool is_eos() = 0;
virtual uint64_t unread_len() = 0;
virtual uint64_t read_len() = 0;
Expand All @@ -60,6 +61,7 @@ class QUICStreamAdapter
virtual void notify_eos() = 0;

protected:
virtual Ptr<IOBufferBlock> _read(size_t len) = 0;
virtual Ptr<IOBufferBlock> _read(size_t len) = 0;
virtual void _consume(size_t len) = 0;
QUICStream &_stream;
};
1 change: 1 addition & 0 deletions include/iocore/net/quic/QUICStreamVCAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class QUICStreamVCAdapter : public VConnection, public QUICStreamAdapter

protected:
Ptr<IOBufferBlock> _read(size_t len) override;
void _consume(size_t len) override;

VIO _read_vio;
VIO _write_vio;
Expand Down
6 changes: 3 additions & 3 deletions include/iocore/net/quic/QUICTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,9 @@ class QUICFiveTuple
int protocol() const;

private:
IpEndpoint _source;
IpEndpoint _destination;
int _protocol;
IpEndpoint _source{};
IpEndpoint _destination{};
int _protocol = 0;
uint64_t _hash_code = 0;
};

Expand Down
21 changes: 18 additions & 3 deletions include/proxy/http2/Http2Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class Http2Stream : public ProxyTransaction
void increment_data_length(uint64_t length);
bool payload_length_is_valid() const;
bool is_write_vio_done() const;
int64_t write_vio_ntodo() const;
void update_sent_count(unsigned num_bytes);
Http2StreamId get_id() const;
Http2StreamState get_state() const;
Expand All @@ -174,6 +175,7 @@ class Http2Stream : public ProxyTransaction
void set_receive_headers(HTTPHdr &h2_headers);
void reset_receive_headers();
void reset_send_headers();
void set_sent_request_method(int method);
MIOBuffer *read_vio_writer() const;
int64_t read_vio_read_avail();
bool is_read_enabled() const;
Expand Down Expand Up @@ -214,6 +216,7 @@ class Http2Stream : public ProxyTransaction
Http2StreamId _id = -1;
Http2StreamState _state = Http2StreamState::HTTP2_STREAM_STATE_IDLE;
int64_t _http_sm_id = -1;
int _sent_request_method{-1};

HTTPHdr _receive_header;
#if TS_USE_MALLOC_ALLOCATOR
Expand Down Expand Up @@ -314,6 +317,12 @@ Http2Stream::is_write_vio_done() const
return this->write_vio.ntodo() == 0;
}

inline int64_t
Http2Stream::write_vio_ntodo() const
{
return this->write_vio.ntodo();
}

inline void
Http2Stream::update_sent_count(unsigned num_bytes)
{
Expand Down Expand Up @@ -389,6 +398,12 @@ Http2Stream::reset_send_headers()
this->_send_header.create(HTTPType::RESPONSE);
}

inline void
Http2Stream::set_sent_request_method(int method)
{
_sent_request_method = method;
}

// Check entire DATA payload length if content-length: header exists
inline void
Http2Stream::increment_data_length(uint64_t length)
Expand All @@ -405,9 +420,9 @@ Http2Stream::payload_length_is_valid() const

// Skip Content-Length check on [RFC 7230] 3.3.2 conditions
bool is_payload_precluded =
this->is_outbound_connection() && (_send_header.method_get_wksidx() == HTTP_WKSIDX_HEAD ||
(_send_header.method_get_wksidx() == HTTP_WKSIDX_GET && _send_header.presence(mask) &&
_receive_header.status_get() == HTTPStatus::NOT_MODIFIED));
this->is_outbound_connection() &&
(_sent_request_method == HTTP_WKSIDX_HEAD || (_sent_request_method == HTTP_WKSIDX_GET && _send_header.presence(mask) &&
_receive_header.status_get() == HTTPStatus::NOT_MODIFIED));

if (content_length != 0 && !is_payload_precluded && content_length != data_length) {
Warning("Bad payload length content_length=%d data_legnth=%d session_id=%" PRId64, content_length,
Expand Down
1 change: 1 addition & 0 deletions include/proxy/http3/Http3App.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class Http3App : public QUICApplication
void _handle_bidi_stream_on_write_complete(int event, VIO *vio);
void _handle_bidi_stream_on_eos(int event, VIO *vio);

void _handle_error(const Http3Error &error);
void _set_qpack_stream(Http3StreamType type, QUICStreamVCAdapter *adapter);

QUICStreamVCAdapter::IOInfo &_get_stream_info(QUICStreamId stream_id);
Expand Down
1 change: 1 addition & 0 deletions include/proxy/http3/Http3ProtocolEnforcer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ class Http3ProtocolEnforcer : public Http3FrameHandler

private:
bool _is_first_frame_received_on_control = false;
bool _is_headers_frame_received = false;
};
3 changes: 3 additions & 0 deletions include/proxy/http3/Http3Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class HQSession : public ProxySession
void remove_transaction(HQTransaction *trans);
HQTransaction *get_transaction(QUICStreamId);

protected:
void _close_transactions();

private:
// this should be unordered map?
Queue<HQTransaction> _transaction_list;
Expand Down
8 changes: 5 additions & 3 deletions include/proxy/http3/Http3StreamDataVIOAdaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class Http3StreamDataVIOAdaptor : public Http3FrameHandler
bool has_data();

private:
VIO *_sink_vio = nullptr;
int64_t _total_data_length = 0;
MIOBuffer *_buffer;
VIO *_sink_vio = nullptr;
int64_t _total_data_length = 0;
MIOBuffer *_buffer = nullptr;
IOBufferReader *_reader = nullptr;
bool _finalized = false;
};
26 changes: 21 additions & 5 deletions include/proxy/http3/Http3Transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@
#include "proxy/http3/Http3FrameDispatcher.h"
#include "proxy/http3/Http3FrameCollector.h"

#include <functional>

class QUICStreamIO;
class HQSession;
class Http09Session;
class Http3Session;
class Http3HeaderFramer;
class Http3DataFramer;
class Http3HeaderVIOAdaptor;
class Http3ProtocolEnforcer;
class Http3StreamDataVIOAdaptor;

class HQTransaction : public ProxyTransaction
Expand All @@ -53,6 +56,8 @@ class HQTransaction : public ProxyTransaction
void transaction_done() override;
void release() override;
int get_transaction_id() const override;
void stream_closed();
void set_stream_cleanup(std::function<void()> cleanup);
void increment_transactions_stat() override;
void decrement_transactions_stat() override;

Expand Down Expand Up @@ -81,6 +86,7 @@ class HQTransaction : public ProxyTransaction
void _schedule_read_complete_event();
void _unschedule_read_complete_event();
void _close_read_complete_event(Event *e);
void _schedule_read_event();
void _schedule_write_ready_event();
void _unschedule_write_ready_event();
void _close_write_ready_event(Event *e);
Expand All @@ -90,12 +96,14 @@ class HQTransaction : public ProxyTransaction
void _signal_event(int event, Event *e);
void _signal_read_event();
void _signal_write_event();
bool _is_write_buffer_flushed();
void _delete_if_possible();

EThread *_thread = nullptr;

MIOBuffer _read_vio_buf{BUFFER_SIZE_INDEX_4K};
QUICStreamVCAdapter::IOInfo &_info;
QUICStreamId _stream_id = 0;

size_t _sent_bytes = 0;

Expand All @@ -106,7 +114,12 @@ class HQTransaction : public ProxyTransaction
Event *_write_ready_event = nullptr;
Event *_write_complete_event = nullptr;

bool _transaction_done = false;
bool _transaction_done = false;
bool _event_handler_active = false;
bool _closed = false;
bool _stream_closed = false;

std::function<void()> _stream_cleanup;
};

class Http3Transaction : public HQTransaction
Expand All @@ -121,6 +134,7 @@ class Http3Transaction : public HQTransaction
int state_stream_closed(int event, Event *data) override;

void do_io_close(int lerrno = -1) override;
void on_header_decode_complete();

bool is_response_header_sent() const;
bool is_response_body_sent() const;
Expand All @@ -131,14 +145,16 @@ class Http3Transaction : public HQTransaction
private:
int64_t _process_read_vio() override;
int64_t _process_write_vio() override;
void _handle_error(const Http3Error &error);

// These are for HTTP/3
Http3FrameDispatcher _frame_dispatcher;
Http3FrameCollector _frame_collector;
Http3FrameGenerator *_header_framer = nullptr;
Http3FrameGenerator *_data_framer = nullptr;
Http3HeaderVIOAdaptor *_header_handler = nullptr;
Http3StreamDataVIOAdaptor *_data_handler = nullptr;
Http3ProtocolEnforcer *_protocol_enforcer = nullptr;
Http3FrameGenerator *_header_framer = nullptr;
Http3FrameGenerator *_data_framer = nullptr;
Http3HeaderVIOAdaptor *_header_handler = nullptr;
Http3StreamDataVIOAdaptor *_data_handler = nullptr;
};

/**
Expand Down
1 change: 1 addition & 0 deletions include/proxy/http3/Http3Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ enum class Http3FrameType : uint64_t {
X_RESERVED_4 = 0x09,
MAX_PUSH_ID = 0x0D,
X_MAX_DEFINED = 0x0D,
RESERVED = 0x21,
UNKNOWN = 0x0E,
};

Expand Down
2 changes: 2 additions & 0 deletions include/proxy/logging/TransactionLogData.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "proxy/hdrs/HTTP.h"
#include "tscore/ink_inet.h"

#include <cstddef>
#include <cstdint>
#include <optional>
#include <string_view>

Expand Down
1 change: 1 addition & 0 deletions src/iocore/net/P_QUICNetVConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class QUICNetVConnection : public UnixNetVConnection,
bool is_at_anti_amplification_limit() const override;
bool is_address_validation_completed() const override;
bool is_handshake_completed() const override;
void on_stream_updated() override;

// QUICSupport
QUICConnection *get_quic_connection() override;
Expand Down
2 changes: 1 addition & 1 deletion src/iocore/net/P_UDPNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class UDPNetProcessorInternal : public UDPNetProcessor

private:
void read_single_message_from_net(UDPNetHandler *nh, UDPConnection *uc);
void read_multiple_messages_from_net(UDPNetHandler *nh, UDPConnection *xuc);
bool read_multiple_messages_from_net(UDPNetHandler *nh, UDPConnection *xuc);
};

extern UDPNetProcessorInternal udpNetInternal;
Expand Down
Loading