Commit Graph

104 Commits

Author SHA1 Message Date
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
Avi Kivity
3aec580cbe Add L3 test
Listen for ARP packets and print something out when we see them.
2014-08-31 13:29:54 +03:00
Avi Kivity
4baf051763 net: add support for dispatching packets to L3 protocol handlers 2014-08-31 13:29:14 +03:00
Avi Kivity
607b3af7e6 net: add more helpers for playing with packets
trim_front() - remove a prefix from a packet
get_header() - linearize and return a section of a packet for direct access
2014-08-31 13:26:11 +03:00
Avi Kivity
28d50bbc7a net: define a type for ethernet_address 2014-08-31 13:23:10 +03:00
Avi Kivity
9f5c0dbf59 ip: improve endianness adjustment
Rather than hacking around the inability to bind references to unaligned
scalars, wrap them in a struct (which can then be marked as unaligned),
and use the wrapped values everywhere.  This ensures the code works on
platforms that need special instructions for unaligned access.

Adjust the forwarding functions to require references; passing by value
accidentally can lose the conversion.
2014-08-28 23:16:48 +03:00
Avi Kivity
00b462ef67 ip: fix checksum for odd-sized packets 2014-08-28 20:40:48 +03:00
Avi Kivity
71bef72332 virtio: correctly prepend net_hdr before transmitting packet
Instead of assuming there is room for a header in front of the packet, use
the packet prepending constructor to check for it and allocate it if missing.

This requires splitting the waiting into two parts: first acquiring the
packet, and only then, when we know how many fragments it has, waiting
for virtio dscriptors.  It also requires that we prepare a full buffer_chain
rather than one with exactly one fragment.
2014-08-28 20:07:36 +03:00
Avi Kivity
b89787eeda virtio: fix multi-buffer request
Set 'has_prev' after the first (really last) buffer.
2014-08-28 20:07:36 +03:00
Avi Kivity
859c99971c virtio: introduce net_hdr structure
Used by virtio to control offload.
2014-08-28 20:07:36 +03:00
Avi Kivity
82489025a1 net: don't forget to copy data when prepending a fragment to a packet 2014-08-28 20:07:36 +03:00
Avi Kivity
9e7dd74bfa net: fix build in debug mode due to missing static variable 2014-08-28 20:07:36 +03:00
Avi Kivity
a7930ffcaa net: rework packet class
1. Replace the completion promise<> with a custom deleter class; this
   is lighter weight, and we don't really need the destructor to be
   executed by the scheduler.
2. Add lots of consuctors for composing packets from existing packet,
   by appending or prepending packets
3. Over-allocate in some cases to accomodate for the common practice of
   prepending protocol headers.
2014-08-28 17:29:27 +03:00
Avi Kivity
e697091201 build: link with libtcmalloc
~14% improvement.
2014-08-27 20:25:53 +03:00
Tomasz Grabiec
9813207ed2 build: fix the build on Ubuntu
The build fails for me like this:

/tmp/ccOUUuiH.ltrans0.ltrans.o: In function `reactor::reactor()':
/home/tgrabiec/src/seastar/build/release/../../reactor.cc:41: undefined reference to `io_setup'
/tmp/ccOUUuiH.ltrans1.ltrans.o: In function `reactor::process_io()':
/home/tgrabiec/src/seastar/build/release/../../reactor.cc:133: undefined reference to `io_getevents'
collect2: error: ld returned 1 exit status
../../build.mk:27: recipe for target 'seastar' failed

The workaround was taken from
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1228201

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
[avi: move to separate line with comment to justify the ugliness]
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
2014-08-27 19:56:25 +03:00
Avi Kivity
b957650a03 build: simplify link rules 2014-08-27 19:17:03 +03:00
Avi Kivity
64c8302f39 Move more posix functions to posix.hh
This simplifies checking for errors, especially in constructors.
2014-08-27 18:26:54 +03:00
Avi Kivity
268d24170d Make posix.hh independent of reactor.hh
Move throw_system_error_on() and friends into it.
2014-08-27 17:37:10 +03:00
Tomasz Grabiec
34667e8dfe reactor: fix io_setup() failure
_io_context must be set to 0, otherwise io_setup fails with -EINVAL.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
2014-08-27 17:32:39 +03:00
Avi Kivity
462a285dc1 Add simple virtio test
Able to reply to broadcase ping (ping -b 192.168.122.2)
2014-08-27 17:25:42 +03:00
Avi Kivity
67952a24d4 Add IPv4 definitions and helpers 2014-08-27 17:25:19 +03:00
Avi Kivity
bdd0125116 build: don't unconditionally build with -flto
mode=release will do it itself.
2014-08-27 17:24:29 +03:00
Avi Kivity
888298778a build: pass mode to sub-make 2014-08-27 17:24:17 +03:00
Avi Kivity
5b27163071 Add rudimentary virtio support
Supported:
 - basic virtio ring pump
 - basic virtio-net driver (most features missing)
 - vhost interface (running as a privileged user process, not guest)
2014-08-27 17:22:13 +03:00