Commit Graph

53948 Commits

Author SHA1 Message Date
Avi Kivity
b725fa8ecc core: support signals
Using a signalfd, convert the signal into a future<>, which is completed
when the signal is delivered.

Handle SIGINT by exiting cleanly.
2014-09-08 15:24:49 +03:00
Avi Kivity
a4beb74fa5 posix: add signalfd wrappers 2014-09-08 15:23:59 +03:00
Avi Kivity
a4b1716d69 core: join non-async worker thread on termination
Cleanly join the worker thread during termination, to avoid an EBADF when
the signalfd used for communication is destroyed.  This lets atexit handlers
run, specifically leak detectors.
2014-09-08 15:20:10 +03:00
Avi Kivity
147046adea Fix copyrights 2014-09-04 18:39:25 +03:00
Avi Kivity
effca50ae0 core: fix temporary_buffer<> assigned to itself 2014-09-04 15:33:28 +03:00
Avi Kivity
78154f4606 Switch temporary_buffer<> to use deleter for cleanup
More flexibility for integration with the native stack.
2014-09-04 15:29:05 +03:00
Avi Kivity
6092ac617b build: use linker flags only when linking
Or clang complains.
2014-09-04 15:19:13 +03:00
Avi Kivity
b91389b1d5 core: extract packet::deleter into a core class
Useful everywhere zero-copy can be used.
2014-09-04 13:28:51 +03:00
Avi Kivity
ce7d8c5835 reactor.hh: remove dead code 2014-09-04 12:32:33 +03:00
Avi Kivity
3b0a9d89d9 core: abstract connected sockets
Instead of returning a pollable_fd from server_socket::accept(), return
a new abstract class connected_socket, which is able to provide an
input_stream and an output_stream to the caller.
2014-09-04 12:31:02 +03:00
Avi Kivity
6c1aabd7e1 core: abstrace reactor::listen()
Instead of returning the Unix-tied pollable_fd, return an abstract
server_socket class which is then implement atop pollable_fd, but can
be replaced with a native implementation.
2014-09-04 12:11:17 +03:00
Avi Kivity
065de692db core: rename input_stream_buffer and output_stream_buffer
Since they are going to be the abstract interface to both the bsd socket
layer and the native tcp stack, rename them to more generic names -
input_stream and output_stream.
2014-09-04 11:24:08 +03:00
Avi Kivity
6f22345cf0 Add eclipse.hh to hide Eclipse CDT parsing errors 2014-09-04 10:42:01 +03:00
Avi Kivity
300abc77d8 core: split future/promise into a new header file 2014-09-04 10:37:59 +03:00
Avi Kivity
03c532eb03 net: tcp: only emit packet when needed 2014-09-04 09:21:18 +03:00
Avi Kivity
21d79c6a57 net: tcp: transmit data in outgoing packets 2014-09-04 09:20:44 +03:00
Avi Kivity
6e37ef5a6c net: tcp: advance sequence number after our SYN is acked 2014-09-04 09:16:46 +03:00
Avi Kivity
e16ccd5fc5 net: tcp: keep track of whether our SYN was sent 2014-09-04 09:16:46 +03:00
Avi Kivity
f81450c1de net: add iostream support to tcp_seq 2014-09-04 09:14:02 +03:00
Avi Kivity
8c5ce8c63f net: add iostream support to packed<> 2014-09-04 09:13:42 +03:00
Avi Kivity
6a53e41053 net: packet sharing support
Add a share() method that enables reference counting for the packet and
returns a clone.  The packet's deleter will only be invoked after all clones
are destroyed.

This is useful for tcp, which keeps a packet in the unacknowledged transmit
queue while sending it lower down the stack.
2014-09-04 09:13:00 +03:00
Avi Kivity
e659c7fafc Add specializations to make_shared 2014-09-03 16:22:27 +03:00
Avi Kivity
7739e5a85e net: tcp: handle trivial case of merge_out_of_order() 2014-09-03 11:59:46 +03:00
Avi Kivity
99e0d27b7c net: tcp: do not add empty packet to receive queue 2014-09-03 11:59:26 +03:00
Avi Kivity
1bf1212306 net: tcp: insert newly created tcb into hash table 2014-09-03 11:59:05 +03:00
Avi Kivity
f8132a8180 net: tcp: change receive() interface
Instead of returning a future<packet>, return a future<> (signifying data
is available) and provide a read() method.

This is useful in case the user wants to consume more or less than exactly
one packet.
2014-09-03 11:57:44 +03:00
Avi Kivity
d74b732396 net: tcp: set up initial receive window 2014-09-03 11:56:42 +03:00
Avi Kivity
ee3c7a0c1d net: add packet::append(packet&&)
Allows constructing a mega-packet out of several input packets.
2014-09-03 11:55:07 +03:00
Avi Kivity
144da7d568 core: be more friendly to debuggers 2014-09-03 11:42:49 +03:00
Avi Kivity
c70ab64e1a net: tcp: rename tcb::received() to tcb::input() 2014-09-03 10:30:25 +03:00
Avi Kivity
3d6a7bfdc6 net: tcp: drop non-SYN packets that do not map to an existing tcb 2014-09-03 09:58:32 +03:00
Avi Kivity
47a473b3f2 net: split tcp processing into input and output 2014-09-03 09:57:41 +03:00
Avi Kivity
b65e054604 net: optimize prepending headers to empty packets 2014-09-03 09:56:56 +03:00
Avi Kivity
602eaeded7 net: fix printing ethernet addresses 2014-09-02 23:32:15 +03:00
Avi Kivity
1fbe325f63 net: add a helper to allocate a header in an existing packet
Use in IP and ethernet layers.
2014-09-02 23:29:43 +03:00
Avi Kivity
32a1001ddf tests: add tcp test
Simple echo server on the now famous port 10000.
2014-09-02 20:40:29 +03:00
Avi Kivity
1396459085 net: integrate tcp into ipv4
Define the traits class used to communicate address types and pseudo header
to tcp, and a few glue classes.
2014-09-02 20:39:12 +03:00
Avi Kivity
a5812f2495 net: tcp
Rudimentary TCP support (establishes a connection then falls over, lots of
things missing).

In a departure from tradition, we don't have a state enum with all the
traditional LISTENING states etc.  Instead we have boolean values
indicating whether an event (like a remote SYN received, or our SYN
acknowledged) has happened.  This simplifies things, because in TCP
the sending side and the receiving side are mostly orthogonal, while the
TCP state mixes the two.

TCP is implemented as a template, in order to tune it for the differences
in TCP/IPv4 vs. TCP/IPv6 (mostly address size and pseudo header).
2014-09-02 20:35:49 +03:00
Avi Kivity
673dd21c8b net: fix ip tx
- checksum
- total length
- endianness

were all wrong.
2014-09-02 20:34:19 +03:00
Avi Kivity
c6412f23fc net: fix ip netmask checks 2014-09-02 20:33:49 +03:00
Avi Kivity
9a731c9a56 net: make packed<> friendly to ntoh()/hton() 2014-09-02 20:33:13 +03:00
Avi Kivity
577ac850c8 inet: move ip_checksum into a separate header
Thus it can be used by tcp.
2014-09-02 20:32:03 +03:00
Avi Kivity
48f570f57c core: add shared_ptr<> smart pointer
Just like std::shared_ptr<>, except no atomics.
2014-09-02 19:08:52 +03:00
Avi Kivity
7473b13275 net: fix packet::trim_front() when trimming entire packet
When trimming the tcp header from a tcp packet without any data (such
as a SYN), nothing remains.  trim_front() did not account for this,
and crashed.

Fix by checking for the condition.
2014-09-02 18:24:34 +03:00
Avi Kivity
0a45d4d73b net: implement IPv4 L3->l4 dispatching 2014-09-01 15:19:17 +03:00
Avi Kivity
93f1af6f33 core: add array_map<>
A map implemented using an array, for fast lookups in a small contiguous
search space.
2014-09-01 15:18:13 +03:00
Avi Kivity
b2b24031e9 net: generalize IP checksummer
Allow it to checksum packets and fragments.
2014-09-01 15:17:27 +03:00
Avi Kivity
001616f7e4 arp: fix build error 2014-09-01 15:16:53 +03:00
Avi Kivity
2aa3d0a755 tests: add timer test 2014-09-01 13:01:06 +03:00
Avi Kivity
b397ac699a core: implement timers 2014-09-01 13:01:06 +03:00