Commit Graph

43077 Commits

Author SHA1 Message Date
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
Avi Kivity
e1f14eded4 posix: timerfd support 2014-09-01 13:01:06 +03:00
Avi Kivity
1b6892abf8 core: switch read_some() to use read(), not recv()
Can be used on non-sockets.
2014-09-01 13:01:06 +03:00
Avi Kivity
32f8a84949 core: add reactor::start() to obtain an initial future<>
The future becomes ready when the system starts running.  This makes it
easier to start from a known state.
2014-09-01 13:01:06 +03:00
Avi Kivity
105015b552 Import timer wheel code from OSv 2014-09-01 13:01:06 +03:00
Avi Kivity
0fbda7c1ec Fix IP checksum for off lengths
Since the data is in network byte order, we must pad the last word to the right.
2014-08-31 23:37:34 +03:00
Avi Kivity
3a75cf1d55 virtio: clear entire virtio net header
Linux looks at the gso hdr_len field even if gso is not used, and refuses
to send the packet if it isn't reasonable.  mode=debug poisons memory,
causing the value to be unreasonable.

Fix by clearing the entire header.
2014-08-31 22:46:27 +03:00
Avi Kivity
c77f77ee3f build: organize files into a directory structure 2014-08-31 21:29:13 +03:00
Avi Kivity
fc5ad77fc8 build: support subdirectories 2014-08-31 21:28:38 +03:00
Avi Kivity
99ed043a41 net: add ipv4 test 2014-08-31 20:38:59 +03:00
Avi Kivity
ad312f9889 net: add IPv4 support
Currently only ARP is integrated.
2014-08-31 20:38:06 +03:00
Avi Kivity
370a46462c net: add arp support
Per-L3 support is provided as a template, with the L3 protocol as a parameter,
so the address type for each protocol is a concrete type without requiring
dynamic allocation or virtual functions for hashing and comparing addresses.
2014-08-31 20:36:06 +03:00
Avi Kivity
7844b18f75 net: don't include ip.hh
Avoid #include dependency hell.
2014-08-31 20:34:46 +03:00
Avi Kivity
50bcea8b5c ethernet: add ethernet class
This serves mostly as a type trait, providing the type name for the address,
and useful functions such as for obtaining the broadcast address.
2014-08-31 20:33:22 +03:00
Avi Kivity
9812b44c62 net: add missing interface:: and l3_protocol:: send() functions 2014-08-31 20:32:08 +03:00
Avi Kivity
ea7d91ac2c net: teach an interface/device about hardware addresses
Since the interface must add its own hardware address when sending packets,
it better know about them.
2014-08-31 20:30:48 +03:00
Avi Kivity
ac4f9a65b5 Add an ipv4_address type
Rather than using the dangerous uint32_t.
2014-08-31 20:26:59 +03:00
Avi Kivity
d7eb75e0ec Add print helper for ethernet_address 2014-08-31 20:23:26 +03:00
Avi Kivity
ae87a8f689 Make ethernet_address its own type
Aliasing to std::array<> can cause confusion.
2014-08-31 20:20:29 +03:00
Avi Kivity
9e16c5ab62 Add print() helper
Forwards everything to boost::format, but with a nicer syntax.
2014-08-31 20:18:09 +03:00
Avi Kivity
ee8558283d Split ethernet support to new file ethernet.hh 2014-08-31 13:37:21 +03:00
Avi Kivity
93804c2b25 Split byte-order support to new file byteorder.hh 2014-08-31 13:34:08 +03:00