From f8f516a8b0ccab2f5d9796f90419bf2661c750af Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Thu, 8 Feb 2018 15:10:09 -0800 Subject: session: support local sessions and deprecate redirects Memfd backed shared memory segments can only be negotiated over sockets. For such scenarios, the existing redirect mechanism that establishes cut-through sessions does not work anymore as the two peer application do not share such a socket. This patch adds support for local sessions, as opposed to sessions backed by a transport connection, in a way that is almost transparent to the two applications by reusing the existing binary api messages. Moreover, all segment allocations are now entirely done through the segment manager valloc, so segment overlaps due to independent allocations previously required for redirects are completely avoided. The one notable characteristic of local sessions (cut-through from app perspective) notification messages is that they carry pointers to two event queues, one for each app peer, instead of one. For transport-backed sessions one of the queues can be inferred but for local session they cannot. Change-Id: Ia443fb63e2d9d8e43490275062a708f039038175 Signed-off-by: Florin Coras --- src/svm/ssvm.c | 9 ++++++--- src/svm/svm_fifo_segment.h | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src/svm') diff --git a/src/svm/ssvm.c b/src/svm/ssvm.c index 7077f8be641..04e0efa3d62 100644 --- a/src/svm/ssvm.c +++ b/src/svm/ssvm.c @@ -33,7 +33,7 @@ ssvm_master_init_shm (ssvm_private_t * ssvm) clib_mem_vm_map_t mapa = { 0 }; u8 junk = 0, *ssvm_filename; ssvm_shared_header_t *sh; - uword page_size; + uword page_size, requested_va = 0; void *oldheap; if (ssvm->ssvm_size == 0) @@ -75,9 +75,12 @@ ssvm_master_init_shm (ssvm_private_t * ssvm) page_size = clib_mem_vm_get_page_size (ssvm_fd); if (ssvm->requested_va) - clib_mem_vm_randomize_va (&ssvm->requested_va, min_log2 (page_size)); + { + requested_va = ssvm->requested_va; + clib_mem_vm_randomize_va (&requested_va, min_log2 (page_size)); + } - mapa.requested_va = ssvm->requested_va; + mapa.requested_va = requested_va; mapa.size = ssvm->ssvm_size; mapa.fd = ssvm_fd; if (clib_mem_vm_ext_map (&mapa)) diff --git a/src/svm/svm_fifo_segment.h b/src/svm/svm_fifo_segment.h index bf8d5139e3c..1872da169f9 100644 --- a/src/svm/svm_fifo_segment.h +++ b/src/svm/svm_fifo_segment.h @@ -31,8 +31,8 @@ typedef enum #define FIFO_SEGMENT_MAX_FIFO_SIZE (8<<20) /* 8mb max fifo size */ #define FIFO_SEGMENT_ALLOC_CHUNK_SIZE 32 /* Allocation quantum */ -#define FIFO_SEGMENT_F_IS_PREALLOCATED 1 << 0 /* Segment is preallocated */ -#define FIFO_SEGMENT_F_WILL_DELETE 1 << 1 /* Segment will be removed */ +#define FIFO_SEGMENT_F_IS_PREALLOCATED (1 << 0) +#define FIFO_SEGMENT_F_WILL_DELETE (1 << 1) typedef struct { -- cgit 1.2.3-korg