Commit Graph

159 Commits

Author SHA1 Message Date
Avi Kivity
d71ac705a6 core: reactor::run(): cosmetic rearrangement 2014-09-08 21:39:52 +03:00
Avi Kivity
014657eaff core: switch input_stream to use data_source
With this change, input_stream can be used to either the hosted or the native
stack (when it is plugged in).
2014-09-08 21:31:43 +03:00
Avi Kivity
f9084a2085 core: add a few helpers to temporary_buffer 2014-09-08 21:31:11 +03:00
Avi Kivity
2847a1de65 core: add data_source abstraction
This is a stream of data arriving in chunks.  With a native TCP stack,
it will serve individual buffers as arriving from the network interface and
queued by the TCP stack.  With the hosted stack (bsd_data_source_impl),
we unfortunately have to allocate each chunk individually.
2014-09-08 21:29:08 +03:00
Avi Kivity
e5e59dc7c2 temporary_buffer: support for sharing
A shared buffer will be destroyed when the last clone is destroyed.
2014-09-08 21:27:07 +03:00
Avi Kivity
6f86186e6d eclipse: support for lvalue references 2014-09-08 21:22:51 +03:00
Avi Kivity
c14daba9e6 core: exit program by breaking the loop rather than exit()
This gives more destructors the option to run, making an easier job for
leak detectors.
2014-09-08 21:21:00 +03:00
Avi Kivity
d06508927e core: add a share() helper for deleter class 2014-09-08 21:20:25 +03:00
Avi Kivity
2cc4728325 core: fix shared_ptr memory leak 2014-09-08 21:20:00 +03:00
Avi Kivity
be5e75b6a6 core: disable shared_ptr assignments (until implemented) 2014-09-08 21:19:36 +03:00
Avi Kivity
12aba7e9cb core: fix promise move assignment
Leaked if an object was assigned to itself.
2014-09-08 21:00:09 +03:00
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