package mirage-net-xen

  1. Overview
  2. Docs

Module AssembleSource

Assemble complete network packets from Xen network messages.

Sourcetype fragment = {
  1. id : int;
    (*

    Ring id of the message this came from.

    *)
  2. offset : int;
    (*

    Where the data starts in the page behind it.

    *)
  3. size : int;
  4. gref : int32;
    (*

    The grant naming that page, or 0l where the page is the reader's own and id finds it.

    *)
}
Sourcetype packet = {
  1. total_size : int;
  2. fragments : fragment list;
  3. extra_ids : int list;
    (*

    Ring ids of slots consumed by extra_info descriptors. Such a slot cost the reader whatever a slot costs, a page on the receive ring, but carries no data and yields no fragment, so a caller that does not release these leaks one per aggregated frame.

    Derived by position, which is only sound where the reader assigned the ids: valid for a frontend reading responses to its own requests, not for a backend reading ids its peer chose.

    *)
}
Sourcetype assembled = (packet, fragment list) result

Error frags reports the fragments of a packet that could not be assembled, so the caller can release their pages and grants rather than leak them. Reading never raises on peer-controlled data.

Sourcemodule type IO = sig ... end
Sourcemodule RX_IO : IO

Receive ring: every response carries the size of its own fragment.

Sourcemodule TX_IO : IO

Transmit ring: the first request announces the whole packet, and its own fragment is what remains once the others are subtracted.