shmc/l4shmnet improvements

Stefan Fritsch Stefan_Fritsch at
Tue Mar 20 10:37:58 CET 2012


the attached shmc.diff fixes many bugs in shmc and adds some new 
functionality. l4shmnet.diff then uses this to implement a protocol that does 
not require one end to wait for the other end during boot, and that allows to 
set the link state up and down. The old protocol is still supported.

The changes may be used under the MIT license (which is included in
the include/shmbuf.h file.

You can find the detailed changelog for shmc.diff below. The diff is on top of 
the diff I have sent in November. 


    Add include/shmbuf.h which implements the l4shmnet packet protocol,
    to be used by l4linux and others.
    - l4shmc_iterate_chunk(): New function to iterate over all chunk names
    - l4shmc_chunk_size(): change return value to allow returning an error
    - l4shmc_area_size_free(): New function to get remaining free space
    - l4shmc_area_overhead(): New function to get overhead not usable by
    - l4shmc_chunk_overhead(): New function to get size overhead per chunk
    - Make l4shmc_chunk_desc_t members volatile to avoid races
    - l4shmc_area_t: add _size member for fast access
    - l4shmc_chunk_t: add _capacity member that stores the size outside of
      the shm area and is therefore safe from tampering by remote end
    - l4shmc_chunk_ready(): need HW memory barrier
    - l4shmc_chunk_size(): Check for overflow
    - l4shmc_chunk_capacity() adapt to new _capacity member
    - l4shmc_chunk_consumed(): don't need a memory barrier
    - l4shmc_create(): protect from integer overflows, initialize lock
    - l4shmc_area_overhead(): new function
    - l4shmc_chunk_overhead(): new function
    - next_chunk(): utility function that gets the next chunk, with
      proper sanity checks to avoid invalid memory access/loops if the
      other side is malicious
    - l4chmc_iterate_chunk(): new function
    - l4shmc_add_chunk(): Add sanity checks, use next_chunk(), initialize
      complete chunk struct properly before inserting into linked list
    - l4shmc_area_size_free(): new function
    - l4shmc_get_chunk_to(): Add sanity checks, use next_chunk()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: l4shmnet.diff
Type: text/x-diff
Size: 20105 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shmc.diff
Type: text/x-diff
Size: 36215 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the l4-hackers mailing list