diff options
author | Florin Coras <fcoras@cisco.com> | 2023-02-02 22:56:03 -0800 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2023-02-08 02:20:22 +0000 |
commit | d1eaed02f3d16306e90b4f1ca5a63d3f02057a66 (patch) | |
tree | 6db1e30423b4d76ea3daf15f2acfc5d4c816fb1c /src/vcl | |
parent | 90c9bb871f9b252e15dde0cb0a20e27498ade871 (diff) |
vcl: add ldp implementation for recvmmsg
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I7322abc3d3b0aa81399667bf02b03786fc62c958
(cherry picked from commit f1a232fd863e0e081a8edf8b1859a9417debb7c7)
Diffstat (limited to 'src/vcl')
-rw-r--r-- | src/vcl/ldp.c | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/src/vcl/ldp.c b/src/vcl/ldp.c index 482af3f1f82..ade19a73a94 100644 --- a/src/vcl/ldp.c +++ b/src/vcl/ldp.c @@ -1843,47 +1843,55 @@ int recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, struct timespec *tmo) { - ssize_t size; - const char *func_str; - u32 sh = ldp_fd_to_vlsh (fd); + ldp_worker_ctx_t *ldpw = ldp_worker_get_current (); + u32 sh; ldp_init_check (); + sh = ldp_fd_to_vlsh (fd); + if (sh != VLS_INVALID_HANDLE) { - clib_warning ("LDP<%d>: LDP-TBD", getpid ()); - errno = ENOSYS; - size = -1; - } - else - { - func_str = "libc_recvmmsg"; + struct mmsghdr *mh; + ssize_t rv = 0; + u32 nvecs = 0; + f64 time_out; - if (LDP_DEBUG > 2) - clib_warning ("LDP<%d>: fd %d (0x%x): calling %s(): " - "vmessages %p, vlen %u, flags 0x%x, tmo %p", - getpid (), fd, fd, func_str, vmessages, vlen, - flags, tmo); - - size = libc_recvmmsg (fd, vmessages, vlen, flags, tmo); - } - - if (LDP_DEBUG > 2) - { - if (size < 0) + if (PREDICT_FALSE (ldpw->clib_time.init_cpu_time == 0)) + clib_time_init (&ldpw->clib_time); + if (tmo) { - int errno_val = errno; - perror (func_str); - clib_warning ("LDP<%d>: ERROR: fd %d (0x%x): %s() failed! " - "rv %d, errno = %d", getpid (), fd, fd, - func_str, size, errno_val); - errno = errno_val; + time_out = (f64) tmo->tv_sec + (f64) tmo->tv_nsec / (f64) 1e9; + time_out += clib_time_now (&ldpw->clib_time); } else - clib_warning ("LDP<%d>: fd %d (0x%x): returning %d (0x%x)", - getpid (), fd, fd, size, size); + { + time_out = (f64) ~0; + } + + while (nvecs < vlen) + { + mh = &vmessages[nvecs]; + rv = recvmsg (fd, &mh->msg_hdr, flags); + if (rv > 0) + { + mh->msg_len = rv; + nvecs += 1; + continue; + } + + if (!time_out || clib_time_now (&ldpw->clib_time) >= time_out) + break; + + usleep (1); + } + + return nvecs > 0 ? nvecs : rv; + } + else + { + return libc_recvmmsg (fd, vmessages, vlen, flags, tmo); } - return size; } #endif |