Enhance gntref with some useful operations. Also provide a default object that
represents an invalid grant.
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Some packets, like arp replies, are broadcast to all cpus for handling,
but only packet structure is copied for each cpu, the actual packet data
is the same for all of them. Currently networking stack mangles a
packet data during its travel up the stack while doing ntoh()
translations which cannot obviously work for broadcaster packets. This
patches fixes the code to not modify packet data while doing ntoh(), but
do it in a stack allocated copy of a data instead.
Fixes the following link errors when Xen support is disabled:
build/release/net/native-stack.o: In function `net::add_native_net_options_description(boost::program_options::options_description&)':
/seastar/net/native-stack.cc:101: undefined reference to `get_xenfront_net_options_description()'
build/release/net/native-stack.o: In function `net::create_native_net_device(boost::program_options::variables_map)':
/seastar/net/native-stack.cc:93: undefined reference to `create_xenfront_net_device(boost::program_options::variables_map, bool)'
collect2: error: ld returned 1 exit status
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Checksum offload cannot be disabled in Xen (or at least, I haven't figured
out how). Advertise it as enabled, so that tcp doesn't drop packets as
failing their checksum.
Still need to flesh out the transmit path.
With this, seastar sends SYN/ACK packets in response to connection requests.
The Xen code registers a function that calls semaphore::signal as
an interrupt handler, however that function is not smp safe and may crash,
and in events it generates are likely to be ignored, since they are just
appended to the reactor queue without any real wakeup to the reactor thread.
Switch to using an eventfd. That's still unsafe, but a little better, since
its signalling is smp safe, and will cause the reactor thread to wake up
in case it was asleep.
With this, we are able to receive multiple packets.
We prepared N buffers, but only told the host about one. This meant the host
stopped forwarding received packets almost immediately.
Fix by writing the Xen-visible ring index correctly.
We used gnttab_grant_foreign_access() instead of
gnttab_grant_foreign_access_ref(). While the two functions have similar
enough signatures, they do very different things.
With the change, we are able to receive packets from Xen, though we crash
immediately.
We used gnttab_grant_foreign_access() instead of
gnttab_grant_foreign_access_ref(). While the two functions have similar
enough signatures, they do very different things.
With the change, we are able to transmit packets through Xen.
This is the basic support for xenfront. It can be used in domU, provided there
is a network interface to be hijacked.
The code that follows, is just the mechanics of managing the grants, event
channels, etc.
However, it does not yet work: I can't see netback injecting any data into it.
I am still debugging the protocol, but I wanted to flush the current state.
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
This patch enables xen event channels. It creates the placeholder for the
kernel evtchns when we move to OSv as well.
The main problem with this patch, is that evtchn::pending can return more than
one evtchn, so this that I am doing here is technically wrong. We should probably
call keep_doing() in pending() itself, and have that to store the references to
futures equivalent to the possible event channels, that would then be made ready.
I am, however, having a bit of a hard time coding this, since it's still
unclear how, once the future is consumed, we would generate the next.
Please note: All of this is moot if we disable "split event channels", which
can be done by masking that feature in case it is even available. In that case,
only one event channel will be notified, and when ready, we process both tx and
rx. This is yet another reason why I haven't insisted so much in fixing this properly
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
This patch creates a seastar enabled version of the xen gntalloc device.
TODO: grow the table dynamically, and fix the index selection algorithm. Shouldn't
just always bump 1.
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Simple discovery class + usage of it in the native stack init.
DHCP discovery will be default if no other ip options are set on command
line, and not explicitly turned off.
Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
Also make queue init identical for main and secondary cpus to ensure
notification across threads is possible before "engine start".
Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
Perhaps not the best way to enable "hijacking" the ip stack (for DHCP
querying), but considering the options seems the least intrusive.
Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
Currently there is an implicit unbounded queue between virtio driver
and networking stack where packets may accumulate if they are received
faster that networking stack can handle them. The queuing happen because
virtio buffer availability is signaled immediately after received buffer
promise is fulfilled, but promise fulfilment does not mean that buffer is
processed, only that task that will process it is placed on a task queue.
The patch fixes the problem by making virtio buffer available only after
previous buffer's completion task is executed. It makes the aforementioned
implicit queue between virtio driver and networking stack bound by virtio
ring size.
Instead of providing back pressure towards NIC, which will cause NIC to
slow down and drop packets, network stack should drop packets it cannot
handle by itself. Otherwise one slow receiver may cause drops for all
others. Our native network stack correctly drops packets instead of
providing feedback, so it is safe to just remove feedback from an API.
The Ethernet frame might contain extra bytes after the IP packet for
padding. Trim the extra bytes in order not to confuse TCP.
E.g. When doing TCP connection:
1) <SYN>
2) <SYN,ACK>
3) <ACK>
Packet 3) should be 14 + 20 + 20 = 54 bytes, the sender might send a
packet of size 60 bytes, containing 6 extra bytes for padding.
Fix httpd on ran/sif.
Currently, it is a ping/pong sever. When the client sends a ping, the
server responds a pong. We can add more tests to extend.
This is useful for testing TCP_RR.
This patch enables to interact with xenstore. Since now OSv now fakes the
presence of libxenstore, the code is the same for userspace and kernel.
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Reorder the file in a way, as to allow the usage of command line switches
in the construction of the compiled objects.
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Rewrite http connection termination management to support the
various cases dictated by the HTTP spec: client-side connection
close, server-side connection close, and header specified connection
close.
It's required for instantiating a sstring with the constructor
basic_sstring(initialized_later, size_t size).
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>