vcl: fix fifo sharing
Type: fix
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Iec1fe8315a057214901250d5fb06d1c1e33dda46
diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c
index b680d27..6ab0797 100644
--- a/src/svm/fifo_segment.c
+++ b/src/svm/fifo_segment.c
@@ -903,6 +903,14 @@
return f;
}
+svm_fifo_t *
+fifo_segment_duplicate_fifo (fifo_segment_t *fs, svm_fifo_t *f)
+{
+ svm_fifo_t *nf = fs_fifo_alloc (fs, 0);
+ clib_memcpy (nf, f, sizeof (*f));
+ return nf;
+}
+
/**
* Free fifo allocated in fifo segment
*/
diff --git a/src/svm/fifo_segment.h b/src/svm/fifo_segment.h
index a4290bb..74f73d4 100644
--- a/src/svm/fifo_segment.h
+++ b/src/svm/fifo_segment.h
@@ -132,6 +132,7 @@
fifo_segment_ftype_t ftype);
svm_fifo_t *fifo_segment_alloc_fifo_w_offset (fifo_segment_t *fs,
uword offset);
+svm_fifo_t *fifo_segment_duplicate_fifo (fifo_segment_t *fs, svm_fifo_t *f);
/**
* Free fifo allocated in fifo segment
diff --git a/src/vcl/ldp.c b/src/vcl/ldp.c
index 54a8f66..316d97d 100644
--- a/src/vcl/ldp.c
+++ b/src/vcl/ldp.c
@@ -1945,6 +1945,9 @@
case SO_ERROR:
rv = vls_attr (vlsh, VPPCOM_ATTR_GET_ERROR, optval, optlen);
break;
+ case SO_BINDTODEVICE:
+ rv = 0;
+ break;
default:
LDBG (0, "ERROR: fd %d: getsockopt SOL_SOCKET: vlsh %u "
"optname %d unsupported!", fd, vlsh, optname);
diff --git a/src/vcl/vcl_locked.c b/src/vcl/vcl_locked.c
index ea22bcd..6c606f6 100644
--- a/src/vcl/vcl_locked.c
+++ b/src/vcl/vcl_locked.c
@@ -766,8 +766,7 @@
if (s->rx_fifo)
{
- svm_fifo_add_subscriber (s->rx_fifo, vcl_wrk->vpp_wrk_index);
- svm_fifo_add_subscriber (s->tx_fifo, vcl_wrk->vpp_wrk_index);
+ vcl_session_share_fifos (s, s->rx_fifo, s->tx_fifo);
}
else if (s->session_state == VCL_STATE_LISTEN)
{
diff --git a/src/vcl/vcl_private.c b/src/vcl/vcl_private.c
index 712c070..95a45ff 100644
--- a/src/vcl/vcl_private.c
+++ b/src/vcl/vcl_private.c
@@ -569,6 +569,26 @@
return c;
}
+int
+vcl_session_share_fifos (vcl_session_t *s, svm_fifo_t *rxf, svm_fifo_t *txf)
+{
+ vcl_worker_t *wrk = vcl_worker_get_current ();
+ fifo_segment_t *fs;
+
+ clib_rwlock_reader_lock (&vcm->segment_table_lock);
+
+ fs = fifo_segment_get_segment (&vcm->segment_main, rxf->segment_index);
+ s->rx_fifo = fifo_segment_duplicate_fifo (fs, rxf);
+ s->tx_fifo = fifo_segment_duplicate_fifo (fs, txf);
+
+ clib_rwlock_reader_unlock (&vcm->segment_table_lock);
+
+ svm_fifo_add_subscriber (s->rx_fifo, wrk->vpp_wrk_index);
+ svm_fifo_add_subscriber (s->tx_fifo, wrk->vpp_wrk_index);
+
+ return 0;
+}
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vcl/vcl_private.h b/src/vcl/vcl_private.h
index ab3ecab..151e4e9 100644
--- a/src/vcl/vcl_private.h
+++ b/src/vcl/vcl_private.h
@@ -730,6 +730,8 @@
svm_fifo_chunk_t *vcl_segment_alloc_chunk (uword segment_handle,
u32 slice_index, u32 size,
uword *offset);
+int vcl_session_share_fifos (vcl_session_t *s, svm_fifo_t *rxf,
+ svm_fifo_t *txf);
/*
* VCL Binary API