mirror of
https://github.com/openvswitch/ovs
synced 2025-09-05 00:35:33 +00:00
socket-util: Introduce emulation and wrapper for recvmmsg().
Not every system will have recvmmsg(), so introduce compatibility code that will allow it to be used blindly from the rest of the tree. This assumes that recvmmsg() and sendmmsg() are either both present or both absent in system libraries and headers. CC: Yi Yang <yangyi01@inspur.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
@@ -104,19 +104,20 @@ int make_unix_socket(int style, bool nonblock,
|
||||
const char *bind_path, const char *connect_path);
|
||||
int get_unix_name_len(const struct sockaddr_un *sun, socklen_t sun_len);
|
||||
|
||||
/* Universal sendmmsg support.
|
||||
/* Universal sendmmsg and recvmmsg support.
|
||||
*
|
||||
* Some platforms, such as new enough Linux and FreeBSD, support sendmmsg, but
|
||||
* other platforms (or older ones) do not. We add the following infrastructure
|
||||
* to allow all code to use sendmmsg, regardless of platform support:
|
||||
* Some platforms, such as new enough Linux and FreeBSD, support sendmmsg and
|
||||
* recvmmsg, but other platforms (or older ones) do not. We add the following
|
||||
* infrastructure to allow all code to use sendmmsg and recvmmsg, regardless of
|
||||
* platform support:
|
||||
*
|
||||
* - For platforms that lack sendmmsg entirely, we emulate it.
|
||||
* - For platforms that lack these functions entirely, we emulate them.
|
||||
*
|
||||
* - Some platforms have sendmmsg() in the C library but not in the kernel.
|
||||
* For example, this is true if a Linux system has a newer glibc with an
|
||||
* old kernel. To compensate, even if sendmmsg() appears to be available,
|
||||
* we still wrap it with a handler that uses our emulation if sendmmsg()
|
||||
* returns ENOSYS.
|
||||
* - Some platforms have sendmmsg() and recvmmsg() in the C library but not in
|
||||
* the kernel. For example, this is true if a Linux system has a newer glibc
|
||||
* with an old kernel. To compensate, even if these functions appear to be
|
||||
* available, we still wrap them with handlers that uses our emulation if the
|
||||
* underlying function returns ENOSYS.
|
||||
*/
|
||||
#ifndef HAVE_STRUCT_MMSGHDR_MSG_LEN
|
||||
struct mmsghdr {
|
||||
@@ -126,9 +127,12 @@ struct mmsghdr {
|
||||
#endif
|
||||
#ifndef HAVE_SENDMMSG
|
||||
int sendmmsg(int, struct mmsghdr *, unsigned int, unsigned int);
|
||||
int recvmmsg(int, struct mmsghdr *, unsigned int, int, struct timespec *);
|
||||
#else
|
||||
#define sendmmsg wrap_sendmmsg
|
||||
int wrap_sendmmsg(int, struct mmsghdr *, unsigned int, unsigned int);
|
||||
#define recvmmsg wrap_recvmmsg
|
||||
int wrap_recvmmsg(int, struct mmsghdr *, unsigned int, int, struct timespec *);
|
||||
#endif
|
||||
|
||||
/* Helpers for calling ioctl() on an AF_INET socket. */
|
||||
|
Reference in New Issue
Block a user