2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

socket-util: Support sendmmsg() regardless of platform.

This will have its first user in an upcoming commit.

Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Ben Pfaff
2017-07-12 17:38:33 -07:00
parent 5b4db7b54f
commit 8a8c1b93b1
4 changed files with 72 additions and 1 deletions

View File

@@ -87,6 +87,33 @@ 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.
*
* 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:
*
* - For platforms that lack sendmmsg entirely, we emulate it.
*
* - 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.
*/
#ifndef HAVE_STRUCT_MMSGHDR_MSG_LEN
struct mmsghdr {
struct msghdr msg_hdr;
unsigned int msg_len;
};
#endif
#ifndef HAVE_SENDMMSG
int sendmmsg(int, struct mmsghdr *, unsigned int, unsigned int);
#else
#define sendmmsg wrap_sendmmsg
int wrap_sendmmsg(int, struct mmsghdr *, unsigned int, unsigned int);
#endif
/* Helpers for calling ioctl() on an AF_INET socket. */
struct ifreq;
int af_inet_ioctl(unsigned long int command, const void *arg);