Hi,
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.
Cheers, Stefan
Add include/shmbuf.h which implements the l4shmnet packet protocol, to be used by l4linux and others.
include/shmc.h: - 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 chunks - l4shmc_chunk_overhead(): New function to get size overhead per chunk
include/types.h: - 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
shmc/include/internal.h: - 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
lib/src/shmc.c: - 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()