diff options
author | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-17 17:57:01 +0000 |
---|---|---|
committer | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-17 17:57:01 +0000 |
commit | ef95114d4d73b9f561e09c4f7688b5f7c18330ba (patch) | |
tree | d8d77e0efffa6b3a0a2c392b42e94c7cf36253c9 /net/tools | |
parent | f467442c9e0db18557ee0e1a5060bd25827f9ed9 (diff) | |
download | chromium_src-ef95114d4d73b9f561e09c4f7688b5f7c18330ba.zip chromium_src-ef95114d4d73b9f561e09c4f7688b5f7c18330ba.tar.gz chromium_src-ef95114d4d73b9f561e09c4f7688b5f7c18330ba.tar.bz2 |
Land Recent QUIC Changes
QUIC crypto: move config objects.
Currently the client and server configs are setup and torn-down for each
connection. Since they are supposed to be per-client and per-server objects,
this change makes them parameters that are passed into the connection
Merge internal change: 44269387
QUIC crypto steps 6 and 7: per-server strike register.
This change adds a per-server strike-register that allows the server to
complete 0-RTT connections if the client has enough information cached.
Due to the fact that the per-server and per-client objects
(QuicCryptoServerConfig and QuicCryptoClientConfig) are currently setup and
torn down for each connection, there's no tests in this change for a 0-RTT
handshake because we can't do one yet. The next change will move these objects
into the right place so that 0-RTT handshakes can be tested.
This change also reminded me why I had a server nonce: without it the server
cannot terminate any connections if the strike-register fails. So the server
nonce is firmly back.
Merge internal change: 44228897
R=rch@chromium.org
Review URL: https://codereview.chromium.org/13976007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194634 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools')
-rw-r--r-- | net/tools/quic/quic_client.cc | 12 | ||||
-rw-r--r-- | net/tools/quic/quic_client.h | 7 | ||||
-rw-r--r-- | net/tools/quic/quic_client_session.cc | 6 | ||||
-rw-r--r-- | net/tools/quic/quic_client_session.h | 4 | ||||
-rw-r--r-- | net/tools/quic/quic_client_session_test.cc | 2 | ||||
-rw-r--r-- | net/tools/quic/quic_dispatcher.cc | 10 | ||||
-rw-r--r-- | net/tools/quic/quic_dispatcher.h | 15 | ||||
-rw-r--r-- | net/tools/quic/quic_dispatcher_test.cc | 2 | ||||
-rw-r--r-- | net/tools/quic/quic_reliable_client_stream_test.cc | 5 | ||||
-rw-r--r-- | net/tools/quic/quic_server.cc | 26 | ||||
-rw-r--r-- | net/tools/quic/quic_server.h | 10 | ||||
-rw-r--r-- | net/tools/quic/quic_server_session.cc | 9 | ||||
-rw-r--r-- | net/tools/quic/quic_server_session.h | 7 |
13 files changed, 94 insertions, 21 deletions
diff --git a/net/tools/quic/quic_client.cc b/net/tools/quic/quic_client.cc index 8acb85a..e258c13 100644 --- a/net/tools/quic/quic_client.cc +++ b/net/tools/quic/quic_client.cc @@ -39,6 +39,8 @@ QuicClient::QuicClient(IPEndPoint server_address, packets_dropped_(0), overflow_supported_(false) { epoll_server_.set_timeout_in_us(50 * 1000); + config_.SetDefaults(); + crypto_config_.SetDefaults(); } QuicClient::~QuicClient() { @@ -129,9 +131,13 @@ bool QuicClient::StartConnect() { DCHECK(!connected() && initialized_); QuicGuid guid = QuicRandom::GetInstance()->RandUint64(); - session_.reset(new QuicClientSession(server_hostname_, new QuicConnection( - guid, server_address_, - new QuicEpollConnectionHelper(fd_, &epoll_server_), false))); + session_.reset(new QuicClientSession( + server_hostname_, + config_, + new QuicConnection(guid, server_address_, + new QuicEpollConnectionHelper(fd_, &epoll_server_), + false), + &crypto_config_)); return session_->CryptoConnect(); } diff --git a/net/tools/quic/quic_client.h b/net/tools/quic/quic_client.h index 1328a5e..fa3e014 100644 --- a/net/tools/quic/quic_client.h +++ b/net/tools/quic/quic_client.h @@ -13,6 +13,8 @@ #include "base/hash_tables.h" #include "base/memory/scoped_ptr.h" #include "net/base/ip_endpoint.h" +#include "net/quic/crypto/crypto_handshake.h" +#include "net/quic/quic_config.h" #include "net/quic/quic_framer.h" #include "net/quic/quic_packet_creator.h" #include "net/tools/flip_server/epoll_server.h" @@ -141,6 +143,11 @@ class QuicClient : public EpollCallbackInterface { // because the socket would otherwise overflow. bool overflow_supported_; + // config_ and crypto_config_ contain configuration and cached state about + // servers. + QuicConfig config_; + QuicCryptoClientConfig crypto_config_; + DISALLOW_COPY_AND_ASSIGN(QuicClient); }; diff --git a/net/tools/quic/quic_client_session.cc b/net/tools/quic/quic_client_session.cc index a3e18dc..6fdf11e 100644 --- a/net/tools/quic/quic_client_session.cc +++ b/net/tools/quic/quic_client_session.cc @@ -16,9 +16,11 @@ namespace tools { QuicClientSession::QuicClientSession( const string& server_hostname, - QuicConnection* connection) + const QuicConfig& config, + QuicConnection* connection, + QuicCryptoClientConfig* crypto_config) : QuicSession(connection, false), - crypto_stream_(this, server_hostname) { + crypto_stream_(server_hostname, config, this, crypto_config) { } QuicClientSession::~QuicClientSession() { diff --git a/net/tools/quic/quic_client_session.h b/net/tools/quic/quic_client_session.h index 18bd63b..f51aeea 100644 --- a/net/tools/quic/quic_client_session.h +++ b/net/tools/quic/quic_client_session.h @@ -26,7 +26,9 @@ class QuicReliableClientStream; class QuicClientSession : public QuicSession { public: QuicClientSession(const std::string& server_hostname, - QuicConnection* connection); + const QuicConfig& config, + QuicConnection* connection, + QuicCryptoClientConfig* crypto_config); virtual ~QuicClientSession(); // QuicSession methods: diff --git a/net/tools/quic/quic_client_session_test.cc b/net/tools/quic/quic_client_session_test.cc index c107f5e..39543db 100644 --- a/net/tools/quic/quic_client_session_test.cc +++ b/net/tools/quic/quic_client_session_test.cc @@ -28,7 +28,7 @@ class QuicClientSessionTest : public ::testing::Test { QuicClientSessionTest() : guid_(1), connection_(new PacketSavingConnection(guid_, IPEndPoint(), false)), - session_(kServerHostname, connection_) { + session_(kServerHostname, config_, connection_, &crypto_config_) { config_.SetDefaults(); crypto_config_.SetDefaults(); } diff --git a/net/tools/quic/quic_dispatcher.cc b/net/tools/quic/quic_dispatcher.cc index 9b5ab84..e88a21e 100644 --- a/net/tools/quic/quic_dispatcher.cc +++ b/net/tools/quic/quic_dispatcher.cc @@ -34,8 +34,13 @@ class DeleteSessionsAlarm : public EpollAlarm { QuicDispatcher* dispatcher_; }; -QuicDispatcher::QuicDispatcher(int fd, EpollServer* epoll_server) - : time_wait_list_manager_( +QuicDispatcher::QuicDispatcher(const QuicConfig& config, + const QuicCryptoServerConfig& crypto_config, + int fd, + EpollServer* epoll_server) + : config_(config), + crypto_config_(crypto_config), + time_wait_list_manager_( new QuicTimeWaitListManager(this, epoll_server)), delete_sessions_alarm_(new DeleteSessionsAlarm(this)), epoll_server_(epoll_server), @@ -177,6 +182,7 @@ QuicSession* QuicDispatcher::CreateQuicSession( QuicConnectionHelperInterface* helper = new QuicEpollConnectionHelper(this, epoll_server); return new QuicServerSession( + config_, crypto_config_, new QuicConnection(guid, client_address, helper, true), this); } diff --git a/net/tools/quic/quic_dispatcher.h b/net/tools/quic/quic_dispatcher.h index 6142e8b..b683677 100644 --- a/net/tools/quic/quic_dispatcher.h +++ b/net/tools/quic/quic_dispatcher.h @@ -36,9 +36,12 @@ namespace gfe2 { class EpollServer; } +namespace net { + +class QuicConfig; +class QuicCryptoServerConfig; class QuicSession; -namespace net { namespace tools { namespace test { @@ -46,14 +49,16 @@ class QuicDispatcherPeer; } // namespace test class DeleteSessionsAlarm; - class QuicDispatcher : public QuicPacketWriter, public QuicSessionOwner { public: typedef BlockedList<QuicBlockedWriterInterface*> WriteBlockedList; // Due to the way delete_sessions_closure_ is registered, the Dispatcher // must live until epoll_server Shutdown. - QuicDispatcher(int fd, EpollServer* epoll_server); + QuicDispatcher(const QuicConfig& config, + const QuicCryptoServerConfig& crypto_config, + int fd, + EpollServer* epoll_server); virtual ~QuicDispatcher(); // QuicPacketWriter @@ -98,6 +103,10 @@ class QuicDispatcher : public QuicPacketWriter, public QuicSessionOwner { WriteBlockedList* write_blocked_list() { return &write_blocked_list_; } + protected: + const QuicConfig& config_; + const QuicCryptoServerConfig& crypto_config_; + private: friend class net::tools::test::QuicDispatcherPeer; diff --git a/net/tools/quic/quic_dispatcher_test.cc b/net/tools/quic/quic_dispatcher_test.cc index 52a22dc..e0824bb 100644 --- a/net/tools/quic/quic_dispatcher_test.cc +++ b/net/tools/quic/quic_dispatcher_test.cc @@ -50,7 +50,7 @@ class TestDispatcher : public QuicDispatcher { explicit TestDispatcher(const QuicConfig& config, const QuicCryptoServerConfig& crypto_config, EpollServer* eps) - : QuicDispatcher(1, eps) {} + : QuicDispatcher(config, crypto_config, 1, eps) {} MOCK_METHOD4(CreateQuicSession, QuicSession*( QuicGuid guid, diff --git a/net/tools/quic/quic_reliable_client_stream_test.cc b/net/tools/quic/quic_reliable_client_stream_test.cc index 7b45b97..8020c33 100644 --- a/net/tools/quic/quic_reliable_client_stream_test.cc +++ b/net/tools/quic/quic_reliable_client_stream_test.cc @@ -25,8 +25,9 @@ namespace { class QuicClientStreamTest : public ::testing::Test { public: QuicClientStreamTest() - : session_("localhost", - new MockConnection(1, IPEndPoint(), 0, &eps_, false)), + : session_("localhost", config_, + new MockConnection(1, IPEndPoint(), 0, &eps_, false), + &crypto_config_), body_("hello world") { config_.SetDefaults(); crypto_config_.SetDefaults(); diff --git a/net/tools/quic/quic_server.cc b/net/tools/quic/quic_server.cc index 6f761ae..4e1743a 100644 --- a/net/tools/quic/quic_server.cc +++ b/net/tools/quic/quic_server.cc @@ -12,6 +12,10 @@ #include <sys/socket.h> #include "net/base/ip_endpoint.h" +#include "net/quic/crypto/crypto_handshake.h" +#include "net/quic/crypto/quic_random.h" +#include "net/quic/quic_clock.h" +#include "net/quic/quic_crypto_stream.h" #include "net/quic/quic_data_reader.h" #include "net/quic/quic_protocol.h" #include "net/tools/quic/quic_in_memory_cache.h" @@ -25,6 +29,7 @@ const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; const int kNumPacketsPerReadCall = 5; // Arbitrary +static const char kSourceAddressTokenSecret[] = "secret"; namespace net { namespace tools { @@ -33,10 +38,26 @@ QuicServer::QuicServer() : port_(0), packets_dropped_(0), overflow_supported_(false), - use_recvmmsg_(false) { + use_recvmmsg_(false), + crypto_config_(kSourceAddressTokenSecret) { epoll_server_.set_timeout_in_us(50 * 1000); // Initialize the in memory cache now. QuicInMemoryCache::GetInstance(); + + // Use hardcoded crypto parameters for now. + config_.SetDefaults(); + CryptoHandshakeMessage extra_tags; + config_.ToHandshakeMessage(&extra_tags); + QuicEpollClock clock(&epoll_server_); + + scoped_ptr<CryptoHandshakeMessage> scfg( + crypto_config_.AddDefaultConfig(QuicRandom::GetInstance(), &clock, + extra_tags)); + // If we were using the same config in many servers then we would have to + // parse a QuicConfig from config_tags here. + if (!config_.SetFromHandshakeMessage(*scfg)) { + CHECK(false) << "Crypto config could not be parsed by QuicConfig."; + } } QuicServer::~QuicServer() { @@ -109,7 +130,8 @@ bool QuicServer::Listen(const IPEndPoint& address) { epoll_server_.RegisterFD(fd_, this, kEpollFlags); - dispatcher_.reset(new QuicDispatcher(fd_, &epoll_server_)); + dispatcher_.reset(new QuicDispatcher(config_, crypto_config_, fd_, + &epoll_server_)); return true; } diff --git a/net/tools/quic/quic_server.h b/net/tools/quic/quic_server.h index 813510c..28ea551 100644 --- a/net/tools/quic/quic_server.h +++ b/net/tools/quic/quic_server.h @@ -10,11 +10,15 @@ #include "base/memory/scoped_ptr.h" #include "net/base/ip_endpoint.h" +#include "net/quic/quic_config.h" #include "net/quic/quic_framer.h" #include "net/tools/flip_server/epoll_server.h" #include "net/tools/quic/quic_dispatcher.h" namespace net { + +class QuicCryptoServerConfig; + namespace tools { class QuicDispatcher; @@ -82,6 +86,12 @@ class QuicServer : public EpollCallbackInterface { // If true, use recvmmsg for reading. bool use_recvmmsg_; + // config_ contains non-crypto parameters that are negotiated in the crypto + // handshake. + QuicConfig config_; + // crypto_config_ contains crypto parameters for the handshake. + QuicCryptoServerConfig crypto_config_; + DISALLOW_COPY_AND_ASSIGN(QuicServer); }; diff --git a/net/tools/quic/quic_server_session.cc b/net/tools/quic/quic_server_session.cc index fc84f75..f692332 100644 --- a/net/tools/quic/quic_server_session.cc +++ b/net/tools/quic/quic_server_session.cc @@ -11,10 +11,13 @@ namespace net { namespace tools { -QuicServerSession::QuicServerSession(QuicConnection* connection, - QuicSessionOwner* owner) +QuicServerSession::QuicServerSession( + const QuicConfig& config, + const QuicCryptoServerConfig& crypto_config, + QuicConnection* connection, + QuicSessionOwner* owner) : QuicSession(connection, true), - crypto_stream_(this), + crypto_stream_(config, crypto_config, this), owner_(owner) { } diff --git a/net/tools/quic/quic_server_session.h b/net/tools/quic/quic_server_session.h index 91a0704..be92871a 100644 --- a/net/tools/quic/quic_server_session.h +++ b/net/tools/quic/quic_server_session.h @@ -17,7 +17,9 @@ namespace net { +class QuicConfig; class QuicConnection; +class QuicCryptoServerConfig; class ReliableQuicStream; namespace tools { @@ -34,7 +36,10 @@ class QuicSessionOwner { class QuicServerSession : public QuicSession { public: - QuicServerSession(QuicConnection *connection, QuicSessionOwner* owner); + QuicServerSession(const QuicConfig& config, + const QuicCryptoServerConfig& crypto_config, + QuicConnection* connection, + QuicSessionOwner* owner); // Override the base class to notify the owner of the connection close. virtual void ConnectionClose(QuicErrorCode error, bool from_peer) OVERRIDE; |