Skip to content
Merged
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
1 change: 1 addition & 0 deletions cmd/traffic_quic/quic_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ QUICClient::start()
NetVCOptions opt;
opt.ip_proto = NetVCOptions::USE_UDP;
opt.ip_family = info->ai_family;
opt.etype = ET_NET;
opt.socket_recv_bufsize = 1048576;
opt.socket_send_bufsize = 1048576;

Expand Down
1 change: 1 addition & 0 deletions cmd/traffic_quic/quic_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#pragma once

#include "P_Net.h"
#include "I_EventSystem.h"
#include "I_NetVConnection.h"
#include "P_QUICNetProcessor.h"
Expand Down
8 changes: 6 additions & 2 deletions cmd/traffic_quic/traffic_quic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,21 @@ main(int argc, const char **argv)
Thread *main_thread = new EThread;
main_thread->set_specific();
net_config_poll_timeout = 10;
ink_net_init(makeModuleVersion(1, 0, PRIVATE_MODULE_HEADER));

SSLInitializeLibrary();
SSLConfig::startup();

netProcessor.init();
quic_NetProcessor.init();

ink_event_system_init(EVENT_SYSTEM_MODULE_VERSION);
eventProcessor.start(THREADS);
udpNet.start(1, stacksize);
quic_NetProcessor.start(-1, stacksize);

QUICClient client(addr, port);
eventProcessor.schedule_in(&client, 1, ET_UDP);
eventProcessor.schedule_in(&client, 1, ET_NET);

this_thread()->execute();
}
Expand Down Expand Up @@ -118,7 +122,7 @@ DNSConnection::trigger()
void
StatPagesManager::register_http(char const *, Action *(*)(Continuation *, HTTPHdr *))
{
ink_assert(false);
// ink_assert(false);
}

#include "ParentSelection.h"
Expand Down
2 changes: 2 additions & 0 deletions iocore/net/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ libinknet_a_SOURCES = \
if ENABLE_QUIC
libinknet_a_SOURCES += \
P_QUICPacketHandler.h \
P_QUICNet.h \
P_QUICNetProcessor.h \
P_QUICNetVConnection.h \
P_QUICNextProtocolAccept.h \
QUICPacketHandler.cc \
QUICNet.cc \
QUICNetProcessor.cc \
QUICNetVConnection.cc \
QUICNextProtocolAccept.cc
Expand Down
1 change: 1 addition & 0 deletions iocore/net/P_Net.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ extern RecRawStatBlock *net_rsb;
#include "P_QUICNetVConnection.h"
#include "P_QUICNetProcessor.h"
#include "P_QUICPacketHandler.h"
#include "P_QUICNet.h"
#endif
// #include "P_QUICCertLookup.h"

Expand Down
84 changes: 84 additions & 0 deletions iocore/net/P_QUICNet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/** @file

A brief file description

@section license License

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef __P_QUICNET_H__
#define __P_QUICNET_H__

#include <bitset>

#include "ts/ink_platform.h"

#include "P_Net.h"

class NetHandler;
typedef int (NetHandler::*NetContHandler)(int, void *);

void initialize_thread_for_quic_net(EThread *thread);

struct QUICPollEvent {
typedef union data_t {
void *ptr;
uint32_t u32;
uint64_t u64;
} data_t;

void free();

data_t data;
UDPPacketInternal *packet;

SLINK(QUICPollEvent, alink);
LINK(QUICPollEvent, link);
};

struct QUICPollCont : public Continuation {
NetHandler *net_handler;
PollDescriptor *pollDescriptor;

QUICPollCont(Ptr<ProxyMutex> &m);
QUICPollCont(Ptr<ProxyMutex> &m, NetHandler *nh);
~QUICPollCont();
int pollEvent(int, Event *);

public:
// Atomic Queue to save incoming packets
ASLL(QUICPollEvent, alink) inQueue;

// Internal Queue to save Long Header Packet
Que(UDPPacketInternal, link) longInQueue;
// Internal Queue to save Short Header Packet
Que(UDPPacketInternal, link) shortInQueue;

private:
void _process_short_header_packet(QUICPollEvent *e, NetHandler *nh);
void _process_long_header_packet(QUICPollEvent *e, NetHandler *nh);
};

static inline QUICPollCont *
get_QUICPollCont(EThread *t)
{
return (QUICPollCont *)ETHREAD_GET_PTR(t, quic_NetProcessor.quicPollCont_offset);
}

extern ClassAllocator<QUICPollEvent> quicPollEventAllocator;
#endif
3 changes: 3 additions & 0 deletions iocore/net/P_QUICNetProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class QUICNetProcessor : public UnixNetProcessor
QUICNetProcessor();
virtual ~QUICNetProcessor();

void init() override;
virtual int start(int, size_t stacksize) override;
void cleanup();
// TODO: refactoring NetProcessor::connect_re and UnixNetProcessor::connect_re_internal
Expand All @@ -67,6 +68,8 @@ class QUICNetProcessor : public UnixNetProcessor

Action *main_accept(Continuation *cont, SOCKET fd, AcceptOptions const &opt) override;

off_t quicPollCont_offset;

private:
QUICNetProcessor(const QUICNetProcessor &);
QUICNetProcessor &operator=(const QUICNetProcessor &);
Expand Down
5 changes: 5 additions & 0 deletions iocore/net/P_QUICNetVConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ class QUICNetVConnection : public UnixNetVConnection, public QUICConnection
QUICNetVConnection() {}
void init(QUICConnectionId original_cid, UDPConnection *, QUICPacketHandler *, QUICConnectionTable *ctable = nullptr);

// accept new conn_id
int acceptEvent(int event, Event *e);

// UnixNetVConnection
void reenable(VIO *vio) override;
VIO *do_io_read(Continuation *c, int64_t nbytes, MIOBuffer *buf) override;
Expand Down Expand Up @@ -302,4 +305,6 @@ class QUICNetVConnection : public UnixNetVConnection, public QUICConnection
QUICStatelessResetToken _reset_token;
};

typedef int (QUICNetVConnection::*QUICNetVConnHandler)(int, void *);

extern ClassAllocator<QUICNetVConnection> quicNetVCAllocator;
2 changes: 2 additions & 0 deletions iocore/net/P_UDPNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ extern UDPNetProcessorInternal udpNetInternal;
#define SLOT_TIME HRTIME_MSECONDS(SLOT_TIME_MSEC)
#define N_SLOTS 2048

constexpr int UDP_PERIOD = 9;

class PacketQueue
{
public:
Expand Down
21 changes: 21 additions & 0 deletions iocore/net/P_UnixNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ struct EventIO {
int events = 0;
#endif
EventLoop event_loop = nullptr;
bool syscall = true;
int type = 0;
union {
Continuation *c;
Expand Down Expand Up @@ -587,6 +588,10 @@ EventIO::start(EventLoop l, UnixUDPConnection *vc, int events)
TS_INLINE int
EventIO::close()
{
if (!this->syscall) {
return 0;
}

stop();
switch (type) {
default:
Expand All @@ -608,6 +613,10 @@ EventIO::close()
TS_INLINE int
EventIO::start(EventLoop l, int afd, Continuation *c, int e)
{
if (!this->syscall) {
return 0;
}

data.c = c;
fd = afd;
event_loop = l;
Expand Down Expand Up @@ -643,6 +652,10 @@ EventIO::start(EventLoop l, int afd, Continuation *c, int e)
TS_INLINE int
EventIO::modify(int e)
{
if (!this->syscall) {
return 0;
}

ink_assert(event_loop);
#if TS_USE_EPOLL && !defined(USE_EDGE_TRIGGER)
struct epoll_event ev;
Expand Down Expand Up @@ -722,6 +735,10 @@ EventIO::modify(int e)
TS_INLINE int
EventIO::refresh(int e)
{
if (!this->syscall) {
return 0;
}

ink_assert(event_loop);
#if TS_USE_KQUEUE && defined(USE_EDGE_TRIGGER)
e = e & events;
Expand Down Expand Up @@ -763,6 +780,10 @@ EventIO::refresh(int e)
TS_INLINE int
EventIO::stop()
{
if (!this->syscall) {
return 0;
}

if (event_loop) {
int retval = 0;
#if TS_USE_EPOLL
Expand Down
Loading