28.08.2015 Views

The Design and Implementation of the Anykernel and Rump Kernels

1F3KDce

1F3KDce

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

143<br />

We use shared memory provided by a memory mapped file as <strong>the</strong> network bus.<br />

<strong>The</strong> filename acts as <strong>the</strong> bus h<strong>and</strong>le — all network interfaces configured to be on<br />

<strong>the</strong> same bus use <strong>the</strong> same filename. <strong>The</strong> shmif driver (manual page shmif.4 at<br />

A–47) in <strong>the</strong> rump kernel accesses <strong>the</strong> bus. Each driver instance accesses one bus,<br />

so it is possible to connect a rump kernel to multiple different busses by configuring<br />

multiple drivers. Since all nodes have full access to bus contents, <strong>the</strong> approach does<br />

not protect against malicious nodes. As our main use case is testing, this lack <strong>of</strong><br />

protection is not an issue. Also, <strong>the</strong> creation <strong>of</strong> a file on <strong>the</strong> host is not an issue,<br />

since testing is commonly carried out in a working directory which is removed after<br />

a test case has finished executing.<br />

<strong>The</strong> shmif driver memory maps <strong>the</strong> file <strong>and</strong> uses it as a ring buffer. <strong>The</strong> header<br />

contains pointers to <strong>the</strong> first <strong>and</strong> last packet <strong>and</strong> a generation number, along with<br />

bus locking information. <strong>The</strong> bus lock is a spinlock based on cross-process shared<br />

memory. A downside to this approach is that if a rump kernel crashes while holding<br />

<strong>the</strong> bus lock, <strong>the</strong> whole bus will halt. However, we have never encountered this<br />

situation, so we do not consider it a serious flaw.<br />

Sending a packet requires locking <strong>the</strong> bus <strong>and</strong> copying <strong>the</strong> contents <strong>of</strong> <strong>the</strong> packet to<br />

<strong>the</strong> buffer. Receiving packets is based on <strong>the</strong> ability <strong>of</strong> <strong>the</strong> kqueue interface to be<br />

able to deliver notifications to processes when a file changes. <strong>The</strong> interface driver<br />

gets a kqueue notification, it locks <strong>the</strong> bus <strong>and</strong> analyzes <strong>the</strong> bus header. If <strong>the</strong>re are<br />

new packets for <strong>the</strong> interface on question, <strong>the</strong> driver passes <strong>the</strong>m up to <strong>the</strong> IP layer.<br />

An additional benefit <strong>of</strong> using a file is that <strong>the</strong>re is always one ringbuffer’s worth <strong>of</strong><br />

traffic available in a postmortem situation. <strong>The</strong> shmif_dumpbus tool (manual page<br />

shmif dumpbus.1 at A–10) can be used to convert a busfile into <strong>the</strong> pcap format<br />

which <strong>the</strong> tcpdump tool underst<strong>and</strong>s. This conversion allows running a post-mortem<br />

tcpdump on a rump kernel’s network packet trace.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!