* [PATCH 2/3] network: recvmsg and sendmsg standard compliance (BZ#16919)
2016-03-23 14:31 [PATCH v2 0/3] Fix {recv,send}{m}msg standard compliance (BZ#16919) Adhemerval Zanella
@ 2016-03-23 14:31 ` Adhemerval Zanella
2016-03-23 15:00 ` Andreas Schwab
2016-03-23 21:51 ` Joseph Myers
2016-03-23 14:31 ` [PATCH 3/3] network: recvmmsg and sendmmsg " Adhemerval Zanella
2016-03-23 14:31 ` [PATCH 1/3] Adjust kernel-features.h defaults for recvmsg and sendmsg Adhemerval Zanella
2 siblings, 2 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2016-03-23 14:31 UTC (permalink / raw)
To: libc-alpha
POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen
to be of size int and socklen_t respectively. However Linux defines it as
both size_t and for 64-bit it requires some adjustments to make the
functions standard compliance.
This patch fixes it by creating a temporary header and zeroing the pad
fields for 64-bits architecture where size of size_t exceeds the size of
the int. Also for such architectures the old recvmsg and sendmsg is
exported as a compatibility version.
Tested on x86_64, i686, aarch64, armhf, and powerpc64le.
* conform/data/sys/socket.h-data (msghdr.msg_iovlen): Remove xfail-
and change to correct expected type.
(msghdr.msg_controllen): Likewise.
(cmsghdr.cmsg_len): Likewise.
* sysdeps/unix/sysv/linux/bits/socket.h (msghdr.msg_iovlen): Fix
expected POSIX assumption about the size.
(msghdr.msg_controllen): Likewise.
(msghdr.__glibc_reserved1): Likewise.
(msghdr.__glibc_reserved2): Likewise.
* nptl/Makefile (libpthread-routines): Add ptw-oldrecvmsg and
ptw-oldsendmsg.
* sysdeps/unix/sysv/linux/aarch64/Version [libc] (GLIBC_2.24):
Add recvmsg and sendmsg.
[libpthread] (GLIBC_2.24): Likewise.
* sysdeps/unix/sysv/linux/alpha/Versions [libc] (GLIBC_2.24):
Likewise.
[libpthread] (GLIBC_2.24): Likewise.
* sysdeps/unix/sysv/linux/ia64/Versions [libc] (GLIBC_2.24):
Likewise.
[libpthread] (GLIBC_2.24): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/Versions [libc] (GLIBC_2.24):
Likewise.
[libpthread] (GLIBC_2.24): Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions [libc]
(GLIBC_2.24): Likewise.
[libpthread] (GLIBC_2.24): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/Versions [libc] (GLIBC_2.24):
Likewise.
[libpthread] (GLIBC_2.24): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/Versions [libc] (GLIBC_2.24):
Likewise.
[libpthread] (GLIBC_2.24): Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/Versions [libc]
(GLIBC_2.24): Likewise.
[libpthread] (GLIBC_2.24): Likewise.
* sysdeps/unix/sysv/linux/x84_64/Versions [libc] (GLIBC_2.24):
Likewise.
[libpthread] (GLIBC_2.24): Likewise.
* sysdeps/unix/sysv/linux/Makefile
[$(subdir) = socket)] (sysdep_headers): Add oldrecvmsg and oldsendmsg.
* sysdeps/unix/sysv/linux/check_native.c (__check_native): Fix msghdr
initialization.
* sysdeps/unix/sysv/linux/check_pf.c (make_request): Likewise.
* sysdeps/unix/sysv/linux/ifaddrs.c (__netlink_request): Likewise.
* sysdeps/unix/sysv/linux/oldrecvmsg.c: New file.
* sysdeps/unix/sysv/linux/oldsendmsg.c: Likewise.
* sysdeps/unix/sysv/linux/recvmsg.c (__libc_recvmsg): Adjust msghdr
iovlen and controllen fields to adjust to POSIX specification.
* sysdeps/unix/sysv/linux/sendmsg.c (__libc_sendmsg): Likewise.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist: New version and
added recvmsg and sendmsg.
* sysdeps/unix/sysv/linux/aarch64/libpthread.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libpthread.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libpthread.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/libpthread.abilis: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise.
* sysdepe/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist:
Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist: Likewise.
---
ChangeLog | 77 +++++++
conform/data/sys/socket.h-data | 8 +-
nptl/Makefile | 1 +
sysdeps/unix/sysv/linux/Makefile | 2 +-
sysdeps/unix/sysv/linux/aarch64/Versions | 9 +
sysdeps/unix/sysv/linux/aarch64/libc.abilist | 3 +
sysdeps/unix/sysv/linux/aarch64/libpthread.abilist | 3 +
sysdeps/unix/sysv/linux/alpha/Versions | 6 +
sysdeps/unix/sysv/linux/alpha/libc.abilist | 3 +
sysdeps/unix/sysv/linux/alpha/libpthread.abilist | 3 +
sysdeps/unix/sysv/linux/bits/socket.h | 45 +++-
sysdeps/unix/sysv/linux/check_native.c | 11 +-
sysdeps/unix/sysv/linux/check_pf.c | 11 +-
sysdeps/unix/sysv/linux/ia64/Versions | 6 +
sysdeps/unix/sysv/linux/ia64/libc.abilist | 3 +
sysdeps/unix/sysv/linux/ia64/libpthread.abilist | 3 +
sysdeps/unix/sysv/linux/ifaddrs.c | 11 +-
.../unix/sysv/linux/mips/mips64/libpthread.abilist | 3 +
.../sysv/linux/mips/mips64/n32/libpthread.abilist | 256 +++++++++++++++++++++
sysdeps/unix/sysv/linux/mips/mips64/n64/Versions | 10 +
.../unix/sysv/linux/mips/mips64/n64/libc.abilist | 3 +
sysdeps/unix/sysv/linux/oldrecvmsg.c | 42 ++++
sysdeps/unix/sysv/linux/oldsendmsg.c | 42 ++++
sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions | 6 +
.../sysv/linux/powerpc/powerpc64/libc-le.abilist | 3 +
.../unix/sysv/linux/powerpc/powerpc64/libc.abilist | 3 +
.../linux/powerpc/powerpc64/libpthread-le.abilist | 3 +
.../linux/powerpc/powerpc64/libpthread.abilist | 3 +
sysdeps/unix/sysv/linux/recvmsg.c | 40 +++-
sysdeps/unix/sysv/linux/s390/s390-64/Versions | 9 +
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 3 +
.../sysv/linux/s390/s390-64/libpthread.abilist | 3 +
sysdeps/unix/sysv/linux/sendmsg.c | 27 ++-
sysdeps/unix/sysv/linux/sparc/sparc64/Versions | 9 +
sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 3 +
.../sysv/linux/sparc/sparc64/libpthread.abilist | 3 +
.../unix/sysv/linux/tile/tilegx/tilegx64/Versions | 11 +
.../sysv/linux/tile/tilegx/tilegx64/libc.abilist | 3 +
.../linux/tile/tilegx/tilegx64/libpthread.abilist | 3 +
sysdeps/unix/sysv/linux/x86_64/64/Versions | 10 +
sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 3 +
.../unix/sysv/linux/x86_64/64/libpthread.abilist | 3 +
42 files changed, 667 insertions(+), 42 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/libpthread.abilist
create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/Versions
create mode 100644 sysdeps/unix/sysv/linux/oldrecvmsg.c
create mode 100644 sysdeps/unix/sysv/linux/oldsendmsg.c
create mode 100644 sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/Versions
create mode 100644 sysdeps/unix/sysv/linux/x86_64/64/Versions
diff --git a/conform/data/sys/socket.h-data b/conform/data/sys/socket.h-data
index 442d4d2..3a6cf7c 100644
--- a/conform/data/sys/socket.h-data
+++ b/conform/data/sys/socket.h-data
@@ -22,10 +22,9 @@ type {struct msghdr}
element {struct msghdr} {void*} msg_name
element {struct msghdr} socklen_t msg_namelen
element {struct msghdr} {struct iovec*} msg_iov
-// Bug 16919: wrong type for msg_iovlen and msg_controllen members.
-xfail-element {struct msghdr} int msg_iovlen
+element {struct msghdr} int msg_iovlen
element {struct msghdr} {void*} msg_control
-xfail-element {struct msghdr} socklen_t msg_controllen
+element {struct msghdr} socklen_t msg_controllen
element {struct msghdr} int msg_flags
type {struct iovec}
@@ -35,8 +34,7 @@ element {struct iovec} size_t iov_len
type {struct cmsghdr}
-// Bug 16919: wrong type for cmsg_len member.
-xfail-element {struct cmsghdr} socklen_t cmsg_len
+element {struct cmsghdr} socklen_t cmsg_len
element {struct cmsghdr} int cmsg_level
element {struct cmsghdr} int cmsg_type
diff --git a/nptl/Makefile b/nptl/Makefile
index dc3ccab..28604f6 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -115,6 +115,7 @@ libpthread-routines = nptl-init vars events version pt-interp \
ptw-pread ptw-pread64 ptw-pwrite ptw-pwrite64 \
ptw-tcdrain ptw-wait ptw-waitpid ptw-msgrcv ptw-msgsnd \
ptw-sigwait ptw-sigsuspend \
+ ptw-oldrecvmsg ptw-oldsendmsg \
pt-raise pt-system \
flockfile ftrylockfile funlockfile \
sigaction \
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 9999600..493ac13 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -124,7 +124,7 @@ ifeq ($(subdir),socket)
sysdep_headers += net/if_ppp.h net/ppp-comp.h \
net/ppp_defs.h net/if_arp.h net/route.h net/ethernet.h \
net/if_slip.h net/if_packet.h net/if_shaper.h
-sysdep_routines += cmsg_nxthdr
+sysdep_routines += cmsg_nxthdr oldrecvmsg oldsendmsg
endif
ifeq ($(subdir),sunrpc)
diff --git a/sysdeps/unix/sysv/linux/aarch64/Versions b/sysdeps/unix/sysv/linux/aarch64/Versions
index 9bd87fe..73ca6fc 100644
--- a/sysdeps/unix/sysv/linux/aarch64/Versions
+++ b/sysdeps/unix/sysv/linux/aarch64/Versions
@@ -5,8 +5,17 @@ ld {
}
}
libc {
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
+
GLIBC_PRIVATE {
__vdso_clock_gettime;
__vdso_clock_getres;
}
}
+libpthread {
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
+}
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 5799239..c3f2346 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2087,3 +2087,6 @@ GLIBC_2.23 fts64_close F
GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist b/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
index 0cf30ee..e33401a 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
@@ -224,3 +224,6 @@ GLIBC_2.17 write F
GLIBC_2.18 GLIBC_2.18 A
GLIBC_2.18 pthread_getattr_default_np F
GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/alpha/Versions b/sysdeps/unix/sysv/linux/alpha/Versions
index 29b82f9..72fac79 100644
--- a/sysdeps/unix/sysv/linux/alpha/Versions
+++ b/sysdeps/unix/sysv/linux/alpha/Versions
@@ -85,6 +85,9 @@ libc {
#errlist-compat 140
_sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
}
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
GLIBC_PRIVATE {
__libc_alpha_cache_shape;
}
@@ -99,6 +102,9 @@ libpthread {
# Changed PTHREAD_STACK_MIN.
pthread_attr_setstack; pthread_attr_setstacksize;
}
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
}
librt {
GLIBC_2.3 {
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 0fa4ee9..7822242 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -1998,6 +1998,9 @@ GLIBC_2.23 fts64_close F
GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/alpha/libpthread.abilist b/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
index 7e121d4..65cb648 100644
--- a/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
@@ -216,6 +216,9 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
GLIBC_2.2.3 pthread_getattr_np F
GLIBC_2.2.6 GLIBC_2.2.6 A
GLIBC_2.2.6 __nanosleep F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
GLIBC_2.3.2 GLIBC_2.3.2 A
GLIBC_2.3.2 pthread_cond_broadcast F
GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h
index 0581c79..9c284a4 100644
--- a/sysdeps/unix/sysv/linux/bits/socket.h
+++ b/sysdeps/unix/sysv/linux/bits/socket.h
@@ -27,6 +27,8 @@
#include <stddef.h>
#include <sys/types.h>
+#include <endian.h>
+#include <bits/wordsize.h>
/* Type for length arguments in socket calls. */
#ifndef __socklen_t_defined
@@ -231,13 +233,32 @@ struct msghdr
socklen_t msg_namelen; /* Length of address data. */
struct iovec *msg_iov; /* Vector of data to send/receive into. */
- size_t msg_iovlen; /* Number of elements in the vector. */
+#if __WORDSIZE == 64
+# if __BYTE_ORDER == __BIG_ENDIAN
+ int __glibc_reserved1; /* Pad to adjust Linux size to POSIX defined
+ size for msg_iovlen. */
+ int msg_iovlen; /* Number of elements in the vector. */
+# else
+ int msg_iovlen;
+ int __glibc_reserved1;
+# endif
+#else
+ int msg_iovlen;
+#endif
void *msg_control; /* Ancillary data (eg BSD filedesc passing). */
- size_t msg_controllen; /* Ancillary data buffer length.
- !! The type should be socklen_t but the
- definition of the kernel is incompatible
- with this. */
+#if __WORDSIZE == 64
+# if __BYTE_ORDER == __BIG_ENDIAN
+ int __glibc_reserved2; /* Pad to adjust Linux size to POSIX defined
+ size for msg_controllen. */
+ socklen_t msg_controllen; /* Ancillary data buffer length. */
+# else
+ socklen_t msg_controllen;
+ int __glibc_reserved2;
+# endif
+#else
+ socklen_t msg_controllen;
+#endif
int msg_flags; /* Flags on received message. */
};
@@ -245,11 +266,15 @@ struct msghdr
/* Structure used for storage of ancillary data object information. */
struct cmsghdr
{
- size_t cmsg_len; /* Length of data in cmsg_data plus length
- of cmsghdr structure.
- !! The type should be socklen_t but the
- definition of the kernel is incompatible
- with this. */
+#if __BYTE_ORDER == __BIG_ENDIAN
+ int __glibc_reserved1; /* Pad toadjust Linux size to POSIX defined
+ size for cmsg_len. */
+ socklen_t cmsg_len; /* Length of data in cmsg_data plus length
+ of cmsghdr structure. */
+#else
+ socklen_t cmsg_len;
+ int __glibc_reserved1;
+#endif
int cmsg_level; /* Originating protocol. */
int cmsg_type; /* Protocol specific type. */
#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
diff --git a/sysdeps/unix/sysv/linux/check_native.c b/sysdeps/unix/sysv/linux/check_native.c
index b3cbbe3..a8e447e 100644
--- a/sysdeps/unix/sysv/linux/check_native.c
+++ b/sysdeps/unix/sysv/linux/check_native.c
@@ -111,10 +111,13 @@ __check_native (uint32_t a1_index, int *a1_native,
{
struct msghdr msg =
{
- (void *) &nladdr, sizeof (nladdr),
- &iov, 1,
- NULL, 0,
- 0
+ .msg_name = (void *) &nladdr,
+ .msg_namelen = sizeof (nladdr),
+ .msg_iov = &iov,
+ .msg_iovlen = 1,
+ .msg_control = NULL,
+ .msg_controllen = 0,
+ .msg_flags = 0
};
ssize_t read_len = TEMP_FAILURE_RETRY (__recvmsg (fd, &msg, 0));
diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c
index d55953a..89e9031 100644
--- a/sysdeps/unix/sysv/linux/check_pf.c
+++ b/sysdeps/unix/sysv/linux/check_pf.c
@@ -158,10 +158,13 @@ make_request (int fd, pid_t pid)
{
struct msghdr msg =
{
- (void *) &nladdr, sizeof (nladdr),
- &iov, 1,
- NULL, 0,
- 0
+ .msg_name = (void *) &nladdr,
+ .msg_namelen = sizeof (nladdr),
+ .msg_iov = &iov,
+ .msg_iovlen = 1,
+ .msg_control = NULL,
+ .msg_controllen = 0,
+ .msg_flags = 0
};
ssize_t read_len = TEMP_FAILURE_RETRY (__recvmsg (fd, &msg, 0));
diff --git a/sysdeps/unix/sysv/linux/ia64/Versions b/sysdeps/unix/sysv/linux/ia64/Versions
index b38d6ef..cac811c 100644
--- a/sysdeps/unix/sysv/linux/ia64/Versions
+++ b/sysdeps/unix/sysv/linux/ia64/Versions
@@ -22,12 +22,18 @@ libc {
GLIBC_2.2.6 {
getunwind;
}
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
}
libpthread {
GLIBC_2.3.3 {
# Changed PTHREAD_STACK_MIN.
pthread_attr_setstack; pthread_attr_setstacksize;
}
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
}
librt {
GLIBC_2.3.3 {
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index 921ec55..f5739b4 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -1874,6 +1874,9 @@ GLIBC_2.23 fts64_close F
GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/ia64/libpthread.abilist b/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
index d4c8ded..0f3c4c2 100644
--- a/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
@@ -204,6 +204,9 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
GLIBC_2.2.3 pthread_getattr_np F
GLIBC_2.2.6 GLIBC_2.2.6 A
GLIBC_2.2.6 __nanosleep F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
GLIBC_2.3.2 GLIBC_2.3.2 A
GLIBC_2.3.2 pthread_cond_broadcast F
GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c
index ca38d1a..54f1124 100644
--- a/sysdeps/unix/sysv/linux/ifaddrs.c
+++ b/sysdeps/unix/sysv/linux/ifaddrs.c
@@ -161,10 +161,13 @@ __netlink_request (struct netlink_handle *h, int type)
{
struct msghdr msg =
{
- (void *) &nladdr, sizeof (nladdr),
- &iov, 1,
- NULL, 0,
- 0
+ .msg_name = (void *) &nladdr,
+ .msg_namelen = sizeof (nladdr),
+ .msg_iov = &iov,
+ .msg_iovlen = 1,
+ .msg_control = NULL,
+ .msg_controllen = 0,
+ .msg_flags = 0
};
read_len = TEMP_FAILURE_RETRY (__recvmsg (h->fd, &msg, 0));
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist b/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
index ad55bdd..6098136 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
@@ -213,6 +213,9 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
GLIBC_2.2.3 pthread_getattr_np F
GLIBC_2.2.6 GLIBC_2.2.6 A
GLIBC_2.2.6 __nanosleep F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
GLIBC_2.3.2 GLIBC_2.3.2 A
GLIBC_2.3.2 pthread_cond_broadcast F
GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libpthread.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libpthread.abilist
new file mode 100644
index 0000000..ad55bdd
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libpthread.abilist
@@ -0,0 +1,256 @@
+GLIBC_2.0 GLIBC_2.0 A
+GLIBC_2.0 _IO_flockfile F
+GLIBC_2.0 _IO_ftrylockfile F
+GLIBC_2.0 _IO_funlockfile F
+GLIBC_2.0 __close F
+GLIBC_2.0 __connect F
+GLIBC_2.0 __errno_location F
+GLIBC_2.0 __fcntl F
+GLIBC_2.0 __fork F
+GLIBC_2.0 __h_errno_location F
+GLIBC_2.0 __lseek F
+GLIBC_2.0 __open F
+GLIBC_2.0 __pthread_getspecific F
+GLIBC_2.0 __pthread_key_create F
+GLIBC_2.0 __pthread_mutex_destroy F
+GLIBC_2.0 __pthread_mutex_init F
+GLIBC_2.0 __pthread_mutex_lock F
+GLIBC_2.0 __pthread_mutex_trylock F
+GLIBC_2.0 __pthread_mutex_unlock F
+GLIBC_2.0 __pthread_mutexattr_destroy F
+GLIBC_2.0 __pthread_mutexattr_init F
+GLIBC_2.0 __pthread_mutexattr_settype F
+GLIBC_2.0 __pthread_once F
+GLIBC_2.0 __pthread_setspecific F
+GLIBC_2.0 __read F
+GLIBC_2.0 __send F
+GLIBC_2.0 __sigaction F
+GLIBC_2.0 __wait F
+GLIBC_2.0 __write F
+GLIBC_2.0 _pthread_cleanup_pop F
+GLIBC_2.0 _pthread_cleanup_pop_restore F
+GLIBC_2.0 _pthread_cleanup_push F
+GLIBC_2.0 _pthread_cleanup_push_defer F
+GLIBC_2.0 accept F
+GLIBC_2.0 close F
+GLIBC_2.0 connect F
+GLIBC_2.0 fcntl F
+GLIBC_2.0 flockfile F
+GLIBC_2.0 fork F
+GLIBC_2.0 fsync F
+GLIBC_2.0 ftrylockfile F
+GLIBC_2.0 funlockfile F
+GLIBC_2.0 longjmp F
+GLIBC_2.0 lseek F
+GLIBC_2.0 msync F
+GLIBC_2.0 nanosleep F
+GLIBC_2.0 open F
+GLIBC_2.0 pause F
+GLIBC_2.0 pthread_atfork F
+GLIBC_2.0 pthread_attr_destroy F
+GLIBC_2.0 pthread_attr_getdetachstate F
+GLIBC_2.0 pthread_attr_getinheritsched F
+GLIBC_2.0 pthread_attr_getschedparam F
+GLIBC_2.0 pthread_attr_getschedpolicy F
+GLIBC_2.0 pthread_attr_getscope F
+GLIBC_2.0 pthread_attr_init F
+GLIBC_2.0 pthread_attr_setdetachstate F
+GLIBC_2.0 pthread_attr_setinheritsched F
+GLIBC_2.0 pthread_attr_setschedparam F
+GLIBC_2.0 pthread_attr_setschedpolicy F
+GLIBC_2.0 pthread_attr_setscope F
+GLIBC_2.0 pthread_cancel F
+GLIBC_2.0 pthread_cond_broadcast F
+GLIBC_2.0 pthread_cond_destroy F
+GLIBC_2.0 pthread_cond_init F
+GLIBC_2.0 pthread_cond_signal F
+GLIBC_2.0 pthread_cond_timedwait F
+GLIBC_2.0 pthread_cond_wait F
+GLIBC_2.0 pthread_condattr_destroy F
+GLIBC_2.0 pthread_condattr_init F
+GLIBC_2.0 pthread_create F
+GLIBC_2.0 pthread_detach F
+GLIBC_2.0 pthread_equal F
+GLIBC_2.0 pthread_exit F
+GLIBC_2.0 pthread_getschedparam F
+GLIBC_2.0 pthread_getspecific F
+GLIBC_2.0 pthread_join F
+GLIBC_2.0 pthread_key_create F
+GLIBC_2.0 pthread_key_delete F
+GLIBC_2.0 pthread_kill F
+GLIBC_2.0 pthread_kill_other_threads_np F
+GLIBC_2.0 pthread_mutex_destroy F
+GLIBC_2.0 pthread_mutex_init F
+GLIBC_2.0 pthread_mutex_lock F
+GLIBC_2.0 pthread_mutex_trylock F
+GLIBC_2.0 pthread_mutex_unlock F
+GLIBC_2.0 pthread_mutexattr_destroy F
+GLIBC_2.0 pthread_mutexattr_getkind_np F
+GLIBC_2.0 pthread_mutexattr_init F
+GLIBC_2.0 pthread_mutexattr_setkind_np F
+GLIBC_2.0 pthread_once F
+GLIBC_2.0 pthread_self F
+GLIBC_2.0 pthread_setcancelstate F
+GLIBC_2.0 pthread_setcanceltype F
+GLIBC_2.0 pthread_setschedparam F
+GLIBC_2.0 pthread_setspecific F
+GLIBC_2.0 pthread_sigmask F
+GLIBC_2.0 pthread_testcancel F
+GLIBC_2.0 raise F
+GLIBC_2.0 read F
+GLIBC_2.0 recv F
+GLIBC_2.0 recvfrom F
+GLIBC_2.0 recvmsg F
+GLIBC_2.0 sem_destroy F
+GLIBC_2.0 sem_getvalue F
+GLIBC_2.0 sem_init F
+GLIBC_2.0 sem_post F
+GLIBC_2.0 sem_trywait F
+GLIBC_2.0 sem_wait F
+GLIBC_2.0 send F
+GLIBC_2.0 sendmsg F
+GLIBC_2.0 sendto F
+GLIBC_2.0 sigaction F
+GLIBC_2.0 siglongjmp F
+GLIBC_2.0 sigwait F
+GLIBC_2.0 system F
+GLIBC_2.0 tcdrain F
+GLIBC_2.0 vfork F
+GLIBC_2.0 wait F
+GLIBC_2.0 waitpid F
+GLIBC_2.0 write F
+GLIBC_2.11 GLIBC_2.11 A
+GLIBC_2.11 pthread_sigqueue F
+GLIBC_2.12 GLIBC_2.12 A
+GLIBC_2.12 pthread_getname_np F
+GLIBC_2.12 pthread_mutex_consistent F
+GLIBC_2.12 pthread_mutexattr_getrobust F
+GLIBC_2.12 pthread_mutexattr_setrobust F
+GLIBC_2.12 pthread_setname_np F
+GLIBC_2.18 GLIBC_2.18 A
+GLIBC_2.18 pthread_getattr_default_np F
+GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.2 GLIBC_2.2 A
+GLIBC_2.2 __libc_allocate_rtsig F
+GLIBC_2.2 __libc_current_sigrtmax F
+GLIBC_2.2 __libc_current_sigrtmin F
+GLIBC_2.2 __open64 F
+GLIBC_2.2 __pread64 F
+GLIBC_2.2 __pthread_rwlock_destroy F
+GLIBC_2.2 __pthread_rwlock_init F
+GLIBC_2.2 __pthread_rwlock_rdlock F
+GLIBC_2.2 __pthread_rwlock_tryrdlock F
+GLIBC_2.2 __pthread_rwlock_trywrlock F
+GLIBC_2.2 __pthread_rwlock_unlock F
+GLIBC_2.2 __pthread_rwlock_wrlock F
+GLIBC_2.2 __pwrite64 F
+GLIBC_2.2 __res_state F
+GLIBC_2.2 __vfork F
+GLIBC_2.2 lseek64 F
+GLIBC_2.2 open64 F
+GLIBC_2.2 pread F
+GLIBC_2.2 pread64 F
+GLIBC_2.2 pthread_attr_getguardsize F
+GLIBC_2.2 pthread_attr_getstack F
+GLIBC_2.2 pthread_attr_getstackaddr F
+GLIBC_2.2 pthread_attr_getstacksize F
+GLIBC_2.2 pthread_attr_init F
+GLIBC_2.2 pthread_attr_setguardsize F
+GLIBC_2.2 pthread_attr_setstack F
+GLIBC_2.2 pthread_attr_setstackaddr F
+GLIBC_2.2 pthread_attr_setstacksize F
+GLIBC_2.2 pthread_barrier_destroy F
+GLIBC_2.2 pthread_barrier_init F
+GLIBC_2.2 pthread_barrier_wait F
+GLIBC_2.2 pthread_barrierattr_destroy F
+GLIBC_2.2 pthread_barrierattr_init F
+GLIBC_2.2 pthread_barrierattr_setpshared F
+GLIBC_2.2 pthread_condattr_getpshared F
+GLIBC_2.2 pthread_condattr_setpshared F
+GLIBC_2.2 pthread_create F
+GLIBC_2.2 pthread_getconcurrency F
+GLIBC_2.2 pthread_getcpuclockid F
+GLIBC_2.2 pthread_mutex_timedlock F
+GLIBC_2.2 pthread_mutexattr_getpshared F
+GLIBC_2.2 pthread_mutexattr_gettype F
+GLIBC_2.2 pthread_mutexattr_setpshared F
+GLIBC_2.2 pthread_mutexattr_settype F
+GLIBC_2.2 pthread_rwlock_destroy F
+GLIBC_2.2 pthread_rwlock_init F
+GLIBC_2.2 pthread_rwlock_rdlock F
+GLIBC_2.2 pthread_rwlock_timedrdlock F
+GLIBC_2.2 pthread_rwlock_timedwrlock F
+GLIBC_2.2 pthread_rwlock_tryrdlock F
+GLIBC_2.2 pthread_rwlock_trywrlock F
+GLIBC_2.2 pthread_rwlock_unlock F
+GLIBC_2.2 pthread_rwlock_wrlock F
+GLIBC_2.2 pthread_rwlockattr_destroy F
+GLIBC_2.2 pthread_rwlockattr_getkind_np F
+GLIBC_2.2 pthread_rwlockattr_getpshared F
+GLIBC_2.2 pthread_rwlockattr_init F
+GLIBC_2.2 pthread_rwlockattr_setkind_np F
+GLIBC_2.2 pthread_rwlockattr_setpshared F
+GLIBC_2.2 pthread_setconcurrency F
+GLIBC_2.2 pthread_spin_destroy F
+GLIBC_2.2 pthread_spin_init F
+GLIBC_2.2 pthread_spin_lock F
+GLIBC_2.2 pthread_spin_trylock F
+GLIBC_2.2 pthread_spin_unlock F
+GLIBC_2.2 pthread_yield F
+GLIBC_2.2 pwrite F
+GLIBC_2.2 pwrite64 F
+GLIBC_2.2 sem_close F
+GLIBC_2.2 sem_destroy F
+GLIBC_2.2 sem_getvalue F
+GLIBC_2.2 sem_init F
+GLIBC_2.2 sem_open F
+GLIBC_2.2 sem_post F
+GLIBC_2.2 sem_timedwait F
+GLIBC_2.2 sem_trywait F
+GLIBC_2.2 sem_unlink F
+GLIBC_2.2 sem_wait F
+GLIBC_2.2.3 GLIBC_2.2.3 A
+GLIBC_2.2.3 pthread_getattr_np F
+GLIBC_2.2.6 GLIBC_2.2.6 A
+GLIBC_2.2.6 __nanosleep F
+GLIBC_2.3.2 GLIBC_2.3.2 A
+GLIBC_2.3.2 pthread_cond_broadcast F
+GLIBC_2.3.2 pthread_cond_destroy F
+GLIBC_2.3.2 pthread_cond_init F
+GLIBC_2.3.2 pthread_cond_signal F
+GLIBC_2.3.2 pthread_cond_timedwait F
+GLIBC_2.3.2 pthread_cond_wait F
+GLIBC_2.3.3 GLIBC_2.3.3 A
+GLIBC_2.3.3 __pthread_cleanup_routine F
+GLIBC_2.3.3 __pthread_register_cancel F
+GLIBC_2.3.3 __pthread_register_cancel_defer F
+GLIBC_2.3.3 __pthread_unregister_cancel F
+GLIBC_2.3.3 __pthread_unregister_cancel_restore F
+GLIBC_2.3.3 __pthread_unwind_next F
+GLIBC_2.3.3 pthread_attr_getaffinity_np F
+GLIBC_2.3.3 pthread_attr_setaffinity_np F
+GLIBC_2.3.3 pthread_attr_setstack F
+GLIBC_2.3.3 pthread_attr_setstacksize F
+GLIBC_2.3.3 pthread_barrierattr_getpshared F
+GLIBC_2.3.3 pthread_condattr_getclock F
+GLIBC_2.3.3 pthread_condattr_setclock F
+GLIBC_2.3.3 pthread_getaffinity_np F
+GLIBC_2.3.3 pthread_setaffinity_np F
+GLIBC_2.3.3 pthread_timedjoin_np F
+GLIBC_2.3.3 pthread_tryjoin_np F
+GLIBC_2.3.4 GLIBC_2.3.4 A
+GLIBC_2.3.4 pthread_attr_getaffinity_np F
+GLIBC_2.3.4 pthread_attr_setaffinity_np F
+GLIBC_2.3.4 pthread_getaffinity_np F
+GLIBC_2.3.4 pthread_setaffinity_np F
+GLIBC_2.3.4 pthread_setschedprio F
+GLIBC_2.4 GLIBC_2.4 A
+GLIBC_2.4 pthread_mutex_consistent_np F
+GLIBC_2.4 pthread_mutex_getprioceiling F
+GLIBC_2.4 pthread_mutex_setprioceiling F
+GLIBC_2.4 pthread_mutexattr_getprioceiling F
+GLIBC_2.4 pthread_mutexattr_getprotocol F
+GLIBC_2.4 pthread_mutexattr_getrobust_np F
+GLIBC_2.4 pthread_mutexattr_setprioceiling F
+GLIBC_2.4 pthread_mutexattr_setprotocol F
+GLIBC_2.4 pthread_mutexattr_setrobust_np F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/Versions b/sysdeps/unix/sysv/linux/mips/mips64/n64/Versions
new file mode 100644
index 0000000..f6ac045
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/Versions
@@ -0,0 +1,10 @@
+libc {
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
+}
+libpthread {
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
+}
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index 53e0c9a..6722f90 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -1932,6 +1932,9 @@ GLIBC_2.23 fts64_close F
GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/oldrecvmsg.c b/sysdeps/unix/sysv/linux/oldrecvmsg.c
new file mode 100644
index 0000000..fef55dd
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/oldrecvmsg.c
@@ -0,0 +1,42 @@
+/* Compatibility version of recvmsg.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/socket.h>
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+#include <shlib-compat.h>
+
+#if LONG_MAX > INT_MAX
+/* Both libc.so and libpthread.so provides sendmsg, so we need to
+ provide the compat symbol for both libraries. */
+# if SHLIB_COMPAT (MODULE_NAME, GLIBC_2_0, GLIBC_2_24)
+
+/* We can use the same struct layout for old symbol version since
+ size is the same. */
+ssize_t
+__old_recvmsg (int fd, struct msghdr *msg, int flags)
+{
+# ifdef __ASSUME_RECVMSG_SYSCALL
+ return SYSCALL_CANCEL (recvmsg, fd, msg, flags);
+# else
+ return SOCKETCALL_CANCEL (recvmsg, fd, msg, flags);
+# endif
+}
+compat_symbol (MODULE_NAME, __old_recvmsg, recvmsg, GLIBC_2_0);
+# endif
+#endif /* LONG_MAX > INT_MAX */
diff --git a/sysdeps/unix/sysv/linux/oldsendmsg.c b/sysdeps/unix/sysv/linux/oldsendmsg.c
new file mode 100644
index 0000000..7d533c1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/oldsendmsg.c
@@ -0,0 +1,42 @@
+/* Compatibility implementation of sendmsg.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/socket.h>
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+#include <shlib-compat.h>
+
+#if LONG_MAX > INT_MAX
+/* Both libc.so and libpthread.so provides sendmsg, so we need to
+ provide the compat symbol for both libraries. */
+# if SHLIB_COMPAT (MODULE_NAME, GLIBC_2_0, GLIBC_2_24)
+
+/* We can use the same struct layout for old symbol version since
+ size is the same. */
+ssize_t
+__old_sendmsg (int fd, const struct msghdr *msg, int flags)
+{
+# ifdef __ASSUME_SENDMSG_SYSCALL
+ return SYSCALL_CANCEL (sendmsg, fd, msg, flags);
+# else
+ return SOCKETCALL_CANCEL (sendmsg, fd, msg, flags);
+# endif
+}
+compat_symbol (MODULE_NAME, __old_sendmsg, sendmsg, GLIBC_2_0);
+# endif
+#endif /* LONG_MAX > INT_MAX */
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions b/sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions
index a8e88b8..4dc8d57 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions
@@ -22,6 +22,9 @@ libc {
GLIBC_2.17 {
__ppc_get_timebase_freq;
}
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
}
librt {
@@ -40,4 +43,7 @@ libpthread {
# Changed PTHREAD_STACK_MIN.
pthread_attr_setstack; pthread_attr_setstacksize;
}
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
}
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
index a97bd43..7839b5a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
@@ -2175,3 +2175,6 @@ GLIBC_2.23 fts64_close F
GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
index 00772cb..20d5a19 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
@@ -89,6 +89,9 @@ GLIBC_2.23 fts64_close F
GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 _Exit F
GLIBC_2.3 _IO_2_1_stderr_ D 0xe0
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist
index 0cf30ee..e33401a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist
@@ -224,3 +224,6 @@ GLIBC_2.17 write F
GLIBC_2.18 GLIBC_2.18 A
GLIBC_2.18 pthread_getattr_default_np F
GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist
index 464b91a..4a845a0 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist
@@ -9,6 +9,9 @@ GLIBC_2.12 pthread_setname_np F
GLIBC_2.18 GLIBC_2.18 A
GLIBC_2.18 pthread_getattr_default_np F
GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 _IO_flockfile F
GLIBC_2.3 _IO_ftrylockfile F
diff --git a/sysdeps/unix/sysv/linux/recvmsg.c b/sysdeps/unix/sysv/linux/recvmsg.c
index 4caf22e..fa3a46e 100644
--- a/sysdeps/unix/sysv/linux/recvmsg.c
+++ b/sysdeps/unix/sysv/linux/recvmsg.c
@@ -15,23 +15,47 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <errno.h>
-#include <signal.h>
#include <sys/socket.h>
-
#include <sysdep-cancel.h>
#include <socketcall.h>
-#include <kernel-features.h>
-#include <sys/syscall.h>
+#include <shlib-compat.h>
ssize_t
__libc_recvmsg (int fd, struct msghdr *msg, int flags)
{
+ ssize_t ret;
+
+ /* POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen
+ to be int and socklen_t respectively. However Linux defines it as
+ both size_t. So for 64-bit it requires some adjustments by copying to
+ temporary header and zeroing the pad fields. */
+#if LONG_MAX > INT_MAX
+ struct msghdr hdr, *orig = msg;
+ if (msg != NULL)
+ {
+ hdr = *msg;
+ hdr.__glibc_reserved1 = 0;
+ hdr.__glibc_reserved2 = 0;
+ msg = &hdr;
+ }
+#endif
+
#ifdef __ASSUME_RECVMSG_SYSCALL
- return SYSCALL_CANCEL (recvmsg, fd, msg, flags);
+ ret = SYSCALL_CANCEL (recvmsg, fd, msg, flags);
#else
- return SOCKETCALL_CANCEL (recvmsg, fd, msg, flags);
+ ret = SOCKETCALL_CANCEL (recvmsg, fd, msg, flags);
+#endif
+
+#if LONG_MAX > INT_MAX
+ if (orig != NULL)
+ *orig = hdr;
#endif
+
+ return ret;
}
-weak_alias (__libc_recvmsg, recvmsg)
weak_alias (__libc_recvmsg, __recvmsg)
+#if LONG_MAX > INT_MAX
+versioned_symbol (libc, __libc_recvmsg, recvmsg, GLIBC_2_24);
+#else
+weak_alias (__libc_recvmsg, recvmsg)
+#endif
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/Versions b/sysdeps/unix/sysv/linux/s390/s390-64/Versions
index 3f4d960..708028f 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/Versions
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/Versions
@@ -4,6 +4,9 @@ libc {
__register_frame; __register_frame_table; __deregister_frame;
__frame_state_for; __register_frame_info_table;
}
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
}
librt {
@@ -13,3 +16,9 @@ librt {
timer_settime;
}
}
+
+libpthread {
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
+}
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index 1af185f..5892fcd 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -1871,6 +1871,9 @@ GLIBC_2.23 fts64_close F
GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
index 83a1fcd..152bfb5 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
@@ -207,6 +207,9 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
GLIBC_2.2.3 pthread_getattr_np F
GLIBC_2.2.6 GLIBC_2.2.6 A
GLIBC_2.2.6 __nanosleep F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
GLIBC_2.3.2 GLIBC_2.3.2 A
GLIBC_2.3.2 pthread_cond_broadcast F
GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/sendmsg.c b/sysdeps/unix/sysv/linux/sendmsg.c
index 5b2741a..10cded4 100644
--- a/sysdeps/unix/sysv/linux/sendmsg.c
+++ b/sysdeps/unix/sysv/linux/sendmsg.c
@@ -15,23 +15,38 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <errno.h>
-#include <signal.h>
#include <sys/socket.h>
-
#include <sysdep-cancel.h>
#include <socketcall.h>
-#include <kernel-features.h>
-#include <sys/syscall.h>
+#include <shlib-compat.h>
ssize_t
__libc_sendmsg (int fd, const struct msghdr *msg, int flags)
{
+ /* POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen
+ to be int and socklen_t respectively. However Linux defines it as
+ both size_t. So for 64-bit it requires some adjustments by copying to
+ temporary header and zeroing the pad fields. */
+#if LONG_MAX > INT_MAX
+ struct msghdr hdr;
+ if (msg != NULL)
+ {
+ hdr = *msg;
+ hdr.__glibc_reserved1 = 0;
+ hdr.__glibc_reserved2 = 0;
+ msg = &hdr;
+ }
+#endif
+
#ifdef __ASSUME_SENDMSG_SYSCALL
return SYSCALL_CANCEL (sendmsg, fd, msg, flags);
#else
return SOCKETCALL_CANCEL (sendmsg, fd, msg, flags);
#endif
}
-weak_alias (__libc_sendmsg, sendmsg)
weak_alias (__libc_sendmsg, __sendmsg)
+#if LONG_MAX > INT_MAX
+versioned_symbol (libc, __libc_sendmsg, sendmsg, GLIBC_2_24);
+#else
+weak_alias (__libc_sendmsg, sendmsg)
+#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/Versions b/sysdeps/unix/sysv/linux/sparc/sparc64/Versions
index fbea1bb..be45683 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/Versions
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/Versions
@@ -8,6 +8,9 @@ libc {
# w*
wordexp;
}
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
}
librt {
@@ -17,3 +20,9 @@ librt {
timer_settime;
}
}
+
+libpthread {
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
+}
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index 91b97ef..015a2f1 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -1900,6 +1900,9 @@ GLIBC_2.23 fts64_close F
GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
index d4c8ded..0f3c4c2 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
@@ -204,6 +204,9 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
GLIBC_2.2.3 pthread_getattr_np F
GLIBC_2.2.6 GLIBC_2.2.6 A
GLIBC_2.2.6 __nanosleep F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
GLIBC_2.3.2 GLIBC_2.3.2 A
GLIBC_2.3.2 pthread_cond_broadcast F
GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/Versions b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/Versions
new file mode 100644
index 0000000..6ee9839
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/Versions
@@ -0,0 +1,11 @@
+libc {
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
+}
+
+libpthread {
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
+}
diff --git a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
index a66e8ec..1e160bd 100644
--- a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
@@ -2094,3 +2094,6 @@ GLIBC_2.23 fts64_close F
GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist
index d16158f..3e3dcf7 100644
--- a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist
@@ -224,3 +224,6 @@ GLIBC_2.12 write F
GLIBC_2.18 GLIBC_2.18 A
GLIBC_2.18 pthread_getattr_default_np F
GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/Versions b/sysdeps/unix/sysv/linux/x86_64/64/Versions
new file mode 100644
index 0000000..f6ac045
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/64/Versions
@@ -0,0 +1,10 @@
+libc {
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
+}
+libpthread {
+ GLIBC_2.24 {
+ recvmsg; sendmsg;
+ }
+}
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index c6e3cd4..175339e 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -1851,6 +1851,9 @@ GLIBC_2.23 fts64_close F
GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
index 85365c0..b599e47 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
@@ -203,6 +203,9 @@ GLIBC_2.2.5 waitpid F
GLIBC_2.2.5 write F
GLIBC_2.2.6 GLIBC_2.2.6 A
GLIBC_2.2.6 __nanosleep F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmsg F
GLIBC_2.3.2 GLIBC_2.3.2 A
GLIBC_2.3.2 pthread_cond_broadcast F
GLIBC_2.3.2 pthread_cond_destroy F
--
1.9.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] network: recvmsg and sendmsg standard compliance (BZ#16919)
2016-03-23 14:31 ` [PATCH 2/3] network: recvmsg and sendmsg " Adhemerval Zanella
@ 2016-03-23 15:00 ` Andreas Schwab
2016-03-23 18:20 ` Adhemerval Zanella
2016-03-23 21:51 ` Joseph Myers
1 sibling, 1 reply; 12+ messages in thread
From: Andreas Schwab @ 2016-03-23 15:00 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
> diff --git a/sysdeps/unix/sysv/linux/oldrecvmsg.c b/sysdeps/unix/sysv/linux/oldrecvmsg.c
> new file mode 100644
> index 0000000..fef55dd
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/oldrecvmsg.c
> @@ -0,0 +1,42 @@
> +/* Compatibility version of recvmsg.
> + Copyright (C) 2016 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <http://www.gnu.org/licenses/>. */
> +
> +#include <sys/socket.h>
> +#include <sysdep-cancel.h>
> +#include <socketcall.h>
> +#include <shlib-compat.h>
> +
> +#if LONG_MAX > INT_MAX
Should this use __WORDSIZE, too?
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] network: recvmsg and sendmsg standard compliance (BZ#16919)
2016-03-23 15:00 ` Andreas Schwab
@ 2016-03-23 18:20 ` Adhemerval Zanella
0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2016-03-23 18:20 UTC (permalink / raw)
To: Andreas Schwab; +Cc: libc-alpha
On 23-03-2016 12:00, Andreas Schwab wrote:
> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
>
>> diff --git a/sysdeps/unix/sysv/linux/oldrecvmsg.c b/sysdeps/unix/sysv/linux/oldrecvmsg.c
>> new file mode 100644
>> index 0000000..fef55dd
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/oldrecvmsg.c
>> @@ -0,0 +1,42 @@
>> +/* Compatibility version of recvmsg.
>> + Copyright (C) 2016 Free Software Foundation, Inc.
>> + This file is part of the GNU C Library.
>> +
>> + The GNU C Library is free software; you can redistribute it and/or
>> + modify it under the terms of the GNU Lesser General Public
>> + License as published by the Free Software Foundation; either
>> + version 2.1 of the License, or (at your option) any later version.
>> +
>> + The GNU C Library is distributed in the hope that it will be useful,
>> + but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> + Lesser General Public License for more details.
>> +
>> + You should have received a copy of the GNU Lesser General Public
>> + License along with the GNU C Library; if not, see
>> + <http://www.gnu.org/licenses/>. */
>> +
>> +#include <sys/socket.h>
>> +#include <sysdep-cancel.h>
>> +#include <socketcall.h>
>> +#include <shlib-compat.h>
>> +
>> +#if LONG_MAX > INT_MAX
>
> Should this use __WORDSIZE, too?
I was not sure, but for consistency with socket.h definition I think it
should. I will change it.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] network: recvmsg and sendmsg standard compliance (BZ#16919)
2016-03-23 14:31 ` [PATCH 2/3] network: recvmsg and sendmsg " Adhemerval Zanella
2016-03-23 15:00 ` Andreas Schwab
@ 2016-03-23 21:51 ` Joseph Myers
2016-03-24 12:58 ` Adhemerval Zanella
1 sibling, 1 reply; 12+ messages in thread
From: Joseph Myers @ 2016-03-23 21:51 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
Is there any current need to have these functions in libpthread as well as
libc? Or could we make the libpthread versions into compat symbols
(including on 32-bit architectures) *without* adding new versions in
libpthread - with new versions going in libc only?
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] network: recvmsg and sendmsg standard compliance (BZ#16919)
2016-03-23 21:51 ` Joseph Myers
@ 2016-03-24 12:58 ` Adhemerval Zanella
0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2016-03-24 12:58 UTC (permalink / raw)
To: Joseph Myers; +Cc: libc-alpha
On 23-03-2016 18:51, Joseph Myers wrote:
> Is there any current need to have these functions in libpthread as well as
> libc? Or could we make the libpthread versions into compat symbols
> (including on 32-bit architectures) *without* adding new versions in
> libpthread - with new versions going in libc only?
>
I think it is possible to just add the compat symbol for all architectures
in libpthread and move all the new implementation on libc only. I will
change it.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] network: recvmmsg and sendmmsg standard compliance (BZ#16919)
2016-03-23 14:31 [PATCH v2 0/3] Fix {recv,send}{m}msg standard compliance (BZ#16919) Adhemerval Zanella
2016-03-23 14:31 ` [PATCH 2/3] network: recvmsg and sendmsg " Adhemerval Zanella
@ 2016-03-23 14:31 ` Adhemerval Zanella
2016-03-23 14:31 ` [PATCH 1/3] Adjust kernel-features.h defaults for recvmsg and sendmsg Adhemerval Zanella
2 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2016-03-23 14:31 UTC (permalink / raw)
To: libc-alpha
POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen
to be of size int and socklen_t respectively, however Linux implements
it as a size_t. So for 64-bits architecture where sizeof of size_t is
larger than socklen_t, both sendmmsg and recvmmsg need to adjust the
mmsghdr::msg_hdr internal fields before issuing the syscall itself.
This patch fixes it by operating on the padding if it the case.
For recvmmsg, the most straightfoward case, only zero padding the fields
is suffice. However, for sendmmsg, where adjusting the buffer is out
of the contract (since it may point to a read-only data), the function
is rewritten to use sendmsg instead (which from previous patch
allocates a temporary msghdr to operate on).
Also for 64-bit ports that requires it, a new recvmmsg and sendmmsg
compat version is created (which uses size_t for both cmsghdr::cmsg_len
and internal
Tested on x86_64, i686, aarch64, armhf, and powerpc64le.
* sysdeps/unix/sysv/linux/Makefile
[$(subdir) = socket] (sysdep_routines): Add oldrecvmmsg and
oldsendmmsg.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Add recvmmsg and
sendmmsg.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/kernel-features.h
(__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Remove define.
[__LINUX_KERNEL_VERSION > 0x030000]
(__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Add define.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
(__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
(__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
(__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
(__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Remove define.
* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
(__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
* sysdeps/unix/sysv/linux/s390/kernel-features.h
(__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Add define.
(__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
* sysdeps/unix/sysv/linux/sh/kernel-features.h
(__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Remove define.
* sysdeps/unix/sysv/linux/sparc/kernel-features.h
(__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
(__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/recvmmsg.c: Remove file.
* sysdeps/unix/sysv/linux/mips/mips32/sendmmsg.c: Likewise.
* sysdeps/unix/sysv/linux/oldrecvmmsg.c: New file.
* sysdeps/unix/sysv/linux/oldsendmmsg.c: Likewise.
* sysdeps/unix/sysv/linux/recvmmsg.c (__recvmmsg): Adjust msghdr
iovlen and controllen fields to adjust to POSIX specification.
* sysdeps/unix/sysv/linux/sendmmsg.c (__sendmmsg): Likewise.
---
ChangeLog | 43 ++++++++++
sysdeps/unix/sysv/linux/Makefile | 3 +-
sysdeps/unix/sysv/linux/aarch64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/alpha/libc.abilist | 2 +
sysdeps/unix/sysv/linux/ia64/libc.abilist | 2 +
.../unix/sysv/linux/microblaze/kernel-features.h | 2 +
.../unix/sysv/linux/mips/mips64/n64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/oldrecvmmsg.c | 91 ++++++++++++++++++++++
sysdeps/unix/sysv/linux/oldsendmmsg.c | 90 +++++++++++++++++++++
.../sysv/linux/powerpc/powerpc64/libc-le.abilist | 2 +
.../unix/sysv/linux/powerpc/powerpc64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/recvmmsg.c | 61 +++++++++------
sysdeps/unix/sysv/linux/s390/kernel-features.h | 3 +
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/sendmmsg.c | 72 ++++++++++++-----
sysdeps/unix/sysv/linux/sh/kernel-features.h | 3 -
sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 2 +
.../sysv/linux/tile/tilegx/tilegx64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 2 +
19 files changed, 341 insertions(+), 47 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/oldrecvmmsg.c
create mode 100644 sysdeps/unix/sysv/linux/oldsendmmsg.c
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 493ac13..08937e0 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -124,7 +124,8 @@ ifeq ($(subdir),socket)
sysdep_headers += net/if_ppp.h net/ppp-comp.h \
net/ppp_defs.h net/if_arp.h net/route.h net/ethernet.h \
net/if_slip.h net/if_packet.h net/if_shaper.h
-sysdep_routines += cmsg_nxthdr oldrecvmsg oldsendmsg
+sysdep_routines += cmsg_nxthdr oldrecvmsg oldsendmsg \
+ oldrecvmmsg oldsendmmsg
endif
ifeq ($(subdir),sunrpc)
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index c3f2346..7981817 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2088,5 +2088,7 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 7822242..0c1e1ac 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -1999,7 +1999,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index f5739b4..b1388d1 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -1875,7 +1875,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h
index db471ef..88a847b 100644
--- a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h
@@ -19,6 +19,8 @@
/* MicroBlaze uses socketcall. */
#define __ASSUME_SOCKETCALL 1
+#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1
+
/* All supported kernel versions for MicroBlaze have these syscalls. */
#define __ASSUME_SOCKET_SYSCALL 1
#define __ASSUME_BIND_SYSCALL 1
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index 6722f90..0e2ff75 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -1933,7 +1933,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/oldrecvmmsg.c b/sysdeps/unix/sysv/linux/oldrecvmmsg.c
new file mode 100644
index 0000000..d01fff7
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/oldrecvmmsg.c
@@ -0,0 +1,91 @@
+/* Compatibility version of recvmsg.
+ Copyright (C) 2010-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/socket.h>
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+#include <shlib-compat.h>
+
+#if LONG_MAX > INT_MAX
+# if SHLIB_COMPAT (libc, GLIBC_2_12, GLIBC_2_24)
+
+# ifdef __ASSUME_RECVMMSG_SYSCALL
+int
+__old_recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen,
+ int flags, struct timespec *tmo)
+{
+ return SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
+}
+# elif defined __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL
+int
+__old_recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen,
+ int flags, struct timespec *tmo)
+{
+ return SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
+}
+# elif defined __ASSUME_SOCKETCALL
+static int have_recvmmsg;
+
+int
+__old_recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen,
+ int flags, struct timespec *tmo)
+{
+ if (__glibc_likely (have_recvmmsg >= 0))
+ {
+ int ret = SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags,
+ tmo);
+ /* The kernel returns -EINVAL for unknown socket operations.
+ We need to convert that error to an ENOSYS error. */
+ if (__builtin_expect (ret < 0, 0)
+ && have_recvmmsg == 0
+ && errno == EINVAL)
+ {
+ /* Try another call, this time with an invalid file
+ descriptor and all other parameters cleared. This call
+ will not cause any harm and it will return
+ immediately. */
+ ret = SOCKETCALL_CANCEL (invalid, -1);
+ if (errno == EINVAL)
+ {
+ have_recvmmsg = -1;
+ __set_errno (ENOSYS);
+ }
+ else
+ {
+ have_recvmmsg = 1;
+ __set_errno (EINVAL);
+ }
+ return -1;
+ }
+ return ret;
+ }
+ __set_errno (ENOSYS);
+ return -1;
+}
+# else
+int
+__old_recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen,
+ int flags, struct timespec *tmo)
+{
+ __set_errno (ENOSYS);
+ return -1;
+}
+# endif
+compat_symbol (libc, __old_recvmmsg, recvmmsg, GLIBC_2_12);
+# endif /* SHLIB_COMPAT (libc, GLIBC_2_12, GLIBC_2_24) */
+#endif /* LONG_MAX > INT_MAX */
diff --git a/sysdeps/unix/sysv/linux/oldsendmmsg.c b/sysdeps/unix/sysv/linux/oldsendmmsg.c
new file mode 100644
index 0000000..7970b73
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/oldsendmmsg.c
@@ -0,0 +1,90 @@
+/* Compatibility implementation of sendmmsg.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/socket.h>
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+#include <shlib-compat.h>
+
+#if LONG_MAX > INT_MAX
+# if SHLIB_COMPAT (libc, GLIBC_2_14, GLIBC_2_24)
+
+# ifdef __ASSUME_SENDMMSG_SYSCALL
+int
+__old_sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen,
+ int flags)
+{
+ return SYSCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+}
+# elif defined __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL
+int
+__old_sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen,
+ int flags)
+{
+ return SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+}
+# elif defined __ASSUME_SOCKETCALL
+static int have_sendmmsg;
+
+int
+__old_sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen,
+ int flags)
+{
+ if (__glibc_likely (have_sendmmsg >= 0))
+ {
+ int ret = SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+ /* The kernel returns -EINVAL for unknown socket operations.
+ We need to convert that error to an ENOSYS error. */
+ if (__builtin_expect (ret < 0, 0)
+ && have_sendmmsg == 0
+ && errno == EINVAL)
+ {
+ /* Try another call, this time with an invalid file
+ descriptor and all other parameters cleared. This call
+ will not cause any harm and it will return
+ immediately. */
+ ret = SOCKETCALL_CANCEL (invalid, -1);
+ if (errno == EINVAL)
+ {
+ have_sendmmsg = -1;
+ __set_errno (ENOSYS);
+ }
+ else
+ {
+ have_sendmmsg = 1;
+ __set_errno (EINVAL);
+ }
+ return -1;
+ }
+ return ret;
+ }
+ __set_errno (ENOSYS);
+ return -1;
+}
+# else
+# define __sendmmsg __old_sendmmsg
+# undef libc_hidden_def
+# define libc_hidden_def(name)
+# undef weak_alias
+# define weak_alias(name, alias)
+# include <socket/sendmmsg.c>
+# endif
+
+compat_symbol (libc, __old_sendmmsg, sendmmsg, GLIBC_2_14);
+# endif /* SHLIB_COMPAT (libc, GLIBC_2_14, GLIBC_2_24) */
+#endif /* LONG_MAX > INT_MAX */
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
index 7839b5a..85286c4 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
@@ -2176,5 +2176,7 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
index 20d5a19..0abd098 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
@@ -90,7 +90,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 _Exit F
diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c
index bf18260..8aa1ff1 100644
--- a/sysdeps/unix/sysv/linux/recvmmsg.c
+++ b/sysdeps/unix/sysv/linux/recvmmsg.c
@@ -16,12 +16,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <errno.h>
#include <sys/socket.h>
-
+#include <socketcall.h>
#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-#include <kernel-features.h>
+#include <shlib-compat.h>
/* Do not use the recvmmsg syscall on socketcall architectures unless
it was added at the same time as the socketcall support or can be
@@ -32,31 +30,39 @@
# undef __NR_recvmmsg
#endif
-#ifdef __NR_recvmmsg
+static inline void
+adjust_mmsghdr (struct mmsghdr *vmessages, unsigned int vlen)
+{
+#if LONG_MAX > INT_MAX
+ /* POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen
+ to be int and socklen_t respectively. However Linux defines it as
+ both size_t. So for 64-bit it requires some adjustments by zeroing
+ the pad fields. */
+ struct mmsghdr *vmhdr = vmessages;
+ for (unsigned int i = 0; i != 0; i--, vmhdr++)
+ {
+ vmhdr->msg_hdr.__glibc_reserved1 = 0;
+ vmhdr->msg_hdr.__glibc_reserved2 = 0;
+ }
+#endif
+}
+
int
-recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
- struct timespec *tmo)
+__recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen,
+ int flags, struct timespec *tmo)
{
+#ifdef __NR_recvmmsg
+ adjust_mmsghdr (vmessages, vlen);
return SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
-}
#elif defined __NR_socketcall
-# include <socketcall.h>
# ifdef __ASSUME_RECVMMSG_SOCKETCALL
-int
-recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
- struct timespec *tmo)
-{
+ adjust_mmsghdr (vmessages, vlen);
return SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
-}
# else
-static int have_recvmmsg;
-
-int
-recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
- struct timespec *tmo)
-{
+ static int have_recvmmsg;
if (__glibc_likely (have_recvmmsg >= 0))
{
+ adjust_mmsghdr (vmessages, vlen);
int ret = SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags,
tmo);
/* The kernel returns -EINVAL for unknown socket operations.
@@ -86,8 +92,19 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
}
__set_errno (ENOSYS);
return -1;
-}
# endif /* __ASSUME_RECVMMSG_SOCKETCALL */
#else
-# include <socket/recvmmsg.c>
+# define STUB 1
+ __set_errno (ENOSYS);
+ return -1;
+#endif
+}
+#ifdef STUB
+stub_warning (recvmmsg)
+#endif
+
+#if LONG_MAX > INT_MAX
+versioned_symbol (libc, __recvmmsg, recvmmsg, GLIBC_2_24);
+#else
+weak_alias (__recvmmsg, recvmmsg)
#endif
diff --git a/sysdeps/unix/sysv/linux/s390/kernel-features.h b/sysdeps/unix/sysv/linux/s390/kernel-features.h
index b3edee4..ee18203 100644
--- a/sysdeps/unix/sysv/linux/s390/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/s390/kernel-features.h
@@ -20,6 +20,9 @@
/* S/390 uses socketcall. */
#define __ASSUME_SOCKETCALL 1
+#define __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL 1
+#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1
+
/* Direct socketcalls available with kernel 4.3. */
#if __LINUX_KERNEL_VERSION >= 0x040300
# define __ASSUME_SOCKET_SYSCALL 1
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index 5892fcd..03a9b97 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -1872,7 +1872,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/sendmmsg.c b/sysdeps/unix/sysv/linux/sendmmsg.c
index 6e0d46b..688043e 100644
--- a/sysdeps/unix/sysv/linux/sendmmsg.c
+++ b/sysdeps/unix/sysv/linux/sendmmsg.c
@@ -16,12 +16,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <errno.h>
#include <sys/socket.h>
-
+#include <socketcall.h>
#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-#include <kernel-features.h>
+#include <shlib-compat.h>
/* Do not use the sendmmsg syscall on socketcall architectures unless
it was added at the same time as the socketcall support or can be
@@ -32,31 +30,53 @@
# undef __NR_sendmmsg
#endif
-#ifdef __NR_sendmmsg
+#if LONG_MAX > INT_MAX
+static inline int
+send_mmsghdr (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
+{
+ /* Emulate kernel interface for vlen size. */
+ if (vlen > IOV_MAX)
+ vlen = IOV_MAX;
+ if (vlen == 0)
+ return 0;
+ /* POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen
+ to be int and socklen_t respectively, however Linux defines it as both
+ size_t. So for 64-bit it requires some adjustments by copying to
+ temporary header and zeroing the pad fields.
+ The problem is sendmmsg's msghdr may points to an already-filled control
+ buffer and modifying it is not part of sendmmsg contract (the data may
+ be in ro map). So interact over the msghdr calling the sendmsg that
+ adjust the header using a temporary buffer. */
+ for (unsigned int i = 0; i < vlen; i++)
+ {
+ ssize_t ret = __sendmsg (fd, &vmessages[i].msg_hdr, flags);
+ if (ret < 0)
+ return -1;
+ vmessages[i].msg_len = ret;
+ }
+ return 1;
+}
+#endif
+
int
__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
{
+# if LONG_MAX > INT_MAX
+ return send_mmsghdr (fd, vmessages, vlen, flags);
+#elif defined __NR_sendmmsg
return SYSCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
-}
-libc_hidden_def (__sendmmsg)
-weak_alias (__sendmmsg, sendmmsg)
#elif defined __NR_socketcall
-# include <socketcall.h>
# ifdef __ASSUME_SENDMMSG_SOCKETCALL
-int
-__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
-{
return SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
-}
# else
-static int have_sendmmsg;
-
-int
-__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
-{
+ static int have_sendmmsg;
if (__glibc_likely (have_sendmmsg >= 0))
{
+# if LONG_MAX > INT_MAX
+ int ret = send_mmsghdr (fd, vmessages, vlen, flags);
+# else
int ret = SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+# endif
/* The kernel returns -EINVAL for unknown socket operations.
We need to convert that error to an ENOSYS error. */
if (__builtin_expect (ret < 0, 0)
@@ -84,10 +104,20 @@ __sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
}
__set_errno (ENOSYS);
return -1;
-}
# endif /* __ASSUME_SENDMMSG_SOCKETCALL */
+#else /* defined __NR_socketcall */
+# define STUB 1
+ __set_errno (ENOSYS);
+ return -1;
+#endif
+}
+#ifdef STUB
+stub_warning (sendmmsg)
+#endif
+
libc_hidden_def (__sendmmsg)
-weak_alias (__sendmmsg, sendmmsg)
+#if LONG_MAX > INT_MAX
+versioned_symbol (libc, __sendmmsg, sendmmsg, GLIBC_2_24);
#else
-# include <socket/sendmmsg.c>
+weak_alias (__sendmmsg, sendmmsg)
#endif
diff --git a/sysdeps/unix/sysv/linux/sh/kernel-features.h b/sysdeps/unix/sysv/linux/sh/kernel-features.h
index ad05fc3..be50320 100644
--- a/sysdeps/unix/sysv/linux/sh/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/sh/kernel-features.h
@@ -37,9 +37,6 @@
#define __ASSUME_GETSOCKOPT_SYSCALL 1
#define __ASSUME_SETSOCKOPT_SYSCALL 1
-/* The sendmmsg syscall was added for SH in 3.0. */
-#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1
-
#include_next <kernel-features.h>
/* SH does not have a 64-bit inode field. */
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index 015a2f1..38b976f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -1901,7 +1901,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
index 1e160bd..07b1332 100644
--- a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
@@ -2095,5 +2095,7 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index 175339e..baea1f5 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -1852,7 +1852,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
--
1.9.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/3] Adjust kernel-features.h defaults for recvmsg and sendmsg
2016-03-23 14:31 [PATCH v2 0/3] Fix {recv,send}{m}msg standard compliance (BZ#16919) Adhemerval Zanella
2016-03-23 14:31 ` [PATCH 2/3] network: recvmsg and sendmsg " Adhemerval Zanella
2016-03-23 14:31 ` [PATCH 3/3] network: recvmmsg and sendmmsg " Adhemerval Zanella
@ 2016-03-23 14:31 ` Adhemerval Zanella
2 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2016-03-23 14:31 UTC (permalink / raw)
To: libc-alpha
This patch removes the auto-generation for recvmsg and sendmsg syscall
and adjust the kernel-features.h for all architectures supported on
Linux. This patch follows the idea of 'Adjust kernel-features.h defaults
for socket syscalls.' (35ade9f11b9007ee9683529f2d33698ff35255c8) by define
__ASSUME_SENDMSG_SYSCALL and __ASSUME_RECVMSG_SYSCALL as supported by
default and undefine it for the architecture that do not support it
directly.
The main rationale is to make is easier add code wrapper over the syscall
to fix BZ#16919 (recvmsg standard compliance).
Tested on x86_64, i686, aarch64, armhf, and powerpc64le.
* sysdeps/unix/sysv/linux/alpha/syscalls.list (recvmsg): Remove
from auto-generation.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/arm/syscalls.list (recvmsg): Likewise.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (recvmsg): Likewise.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (recvmsg): Likewise.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (recvmsg): Likewise.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/mips/syscalls.list (recvmsg): Likewise.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list (recvmsg):
Likewise.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (recvmsg): Likewise.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/i386/kernel-features.h
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL):
Remove.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_SENDMSG_SYSCALL):
Undefine.
[__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_RECVMSG_SYSCALL):
Likewise.
* sysdeps/unix/sysv/linux/kernel-features.h
(__ASSUME_SENDMSG_SYSCALL): Define.
(__ASSUME_RECVMSG_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL):
Remove.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_SENDMSG_SYSCALL):
Undefine.
[__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_RECVMSG_SYSCALL):
Likewise.
* sysdeps/unix/sysv/linux/s390/kernel-features.h
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL):
Remove.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_SENDMSG_SYSCALL):
Undefine.
[__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_RECVMSG_SYSCALL):
Likewise.
* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
(__ASSUME_SENDMSG_SYSCALL): Undefine.
(__ASSUME_RECVMSG_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
(__ASSUME_SENDMSG_SYSCALL): Likewise.
(__ASSUME_RECVMSG_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/sh/kernel-features.h
(__ASSUME_SENDMSG_SYSCALL): Likewise.
(__ASSUME_RECVMSG_SYSCALL): Likewise.
---
ChangeLog | 60 ++++++++++++++++++++++
sysdeps/unix/sysv/linux/alpha/syscalls.list | 2 -
sysdeps/unix/sysv/linux/arm/syscalls.list | 2 -
sysdeps/unix/sysv/linux/generic/syscalls.list | 2 -
sysdeps/unix/sysv/linux/hppa/syscalls.list | 2 -
sysdeps/unix/sysv/linux/i386/kernel-features.h | 4 +-
sysdeps/unix/sysv/linux/ia64/syscalls.list | 2 -
sysdeps/unix/sysv/linux/kernel-features.h | 8 +++
sysdeps/unix/sysv/linux/m68k/kernel-features.h | 4 +-
.../unix/sysv/linux/microblaze/kernel-features.h | 2 -
sysdeps/unix/sysv/linux/mips/syscalls.list | 2 -
sysdeps/unix/sysv/linux/powerpc/kernel-features.h | 2 -
sysdeps/unix/sysv/linux/s390/kernel-features.h | 4 +-
sysdeps/unix/sysv/linux/sh/kernel-features.h | 2 -
.../unix/sysv/linux/sparc/sparc64/syscalls.list | 2 -
sysdeps/unix/sysv/linux/x86_64/syscalls.list | 2 -
16 files changed, 74 insertions(+), 28 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index cad1fc3..0c9efcb 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -27,9 +27,7 @@ getsockopt - getsockopt i:iiiBN __getsockopt getsockopt
listen - listen i:ii __listen listen
recv - recv Ci:ibni __libc_recv __recv recv
recvfrom - recvfrom Ci:ibniBN __libc_recvfrom __recvfrom recvfrom
-recvmsg - recvmsg Ci:ipi __libc_recvmsg __recvmsg recvmsg
send - send Ci:ibni __libc_send __send send
-sendmsg - sendmsg Ci:ipi __libc_sendmsg __sendmsg sendmsg
sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto
setsockopt - setsockopt i:iiibn __setsockopt setsockopt
shutdown - shutdown i:ii __shutdown shutdown
diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list
index c06954f..82402b1 100644
--- a/sysdeps/unix/sysv/linux/arm/syscalls.list
+++ b/sysdeps/unix/sysv/linux/arm/syscalls.list
@@ -43,9 +43,7 @@ getsockopt - getsockopt i:iiiBN __getsockopt getsockopt
listen - listen i:ii __listen listen
recv - recv Ci:ibni __libc_recv __recv recv
recvfrom - recvfrom Ci:ibniBN __libc_recvfrom __recvfrom recvfrom
-recvmsg - recvmsg Ci:ipi __libc_recvmsg __recvmsg recvmsg
send - send Ci:ibni __libc_send __send send
-sendmsg - sendmsg Ci:ipi __libc_sendmsg __sendmsg sendmsg
sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto
setsockopt - setsockopt i:iiibn __setsockopt setsockopt
shutdown - shutdown i:ii __shutdown shutdown
diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
index 4b2e747..5993ab4 100644
--- a/sysdeps/unix/sysv/linux/generic/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -28,5 +28,3 @@ recvfrom - recvfrom Ci:ibniBN __libc_recvfrom __recvfrom recvfrom
setsockopt - setsockopt i:iiibn __setsockopt setsockopt
getsockopt - getsockopt i:iiiBN __getsockopt getsockopt
shutdown - shutdown i:ii __shutdown shutdown
-sendmsg - sendmsg Ci:ipi __libc_sendmsg __sendmsg sendmsg
-recvmsg - recvmsg Ci:ipi __libc_recvmsg __recvmsg recvmsg
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index d29c358..1f3dfb0 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -24,9 +24,7 @@ getsockopt - getsockopt i:iiiBN __getsockopt getsockopt
listen - listen i:ii __listen listen
recv - recv Ci:ibni __libc_recv __recv recv
recvfrom - recvfrom Ci:ibniBN __libc_recvfrom __recvfrom recvfrom
-recvmsg - recvmsg Ci:ipi __libc_recvmsg __recvmsg recvmsg
send - send Ci:ibni __libc_send __send send
-sendmsg - sendmsg Ci:ipi __libc_sendmsg __sendmsg sendmsg
sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto
setsockopt - setsockopt i:iiibn __setsockopt setsockopt
shutdown - shutdown i:ii __shutdown shutdown
diff --git a/sysdeps/unix/sysv/linux/i386/kernel-features.h b/sysdeps/unix/sysv/linux/i386/kernel-features.h
index 45054f8..148963c 100644
--- a/sysdeps/unix/sysv/linux/i386/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/i386/kernel-features.h
@@ -40,10 +40,8 @@
# define __ASSUME_GETPEERNAME_SYSCALL 1
# define __ASSUME_SENDTO_SYSCALL 1
# define __ASSUME_SENDTO_FOR_SEND_SYSCALL 1
-# define __ASSUME_SENDMSG_SYSCALL 1
# define __ASSUME_RECVFROM_SYSCALL 1
# define __ASSUME_RECVFROM_FOR_RECV_SYSCALL 1
-# define __ASSUME_RECVMSG_SYSCALL 1
# define __ASSUME_SHUTDOWN_SYSCALL 1
#endif
@@ -51,4 +49,6 @@
#if __LINUX_KERNEL_VERSION < 0x040300
# undef __ASSUME_ACCEPT4_SYSCALL
+# undef __ASSUME_SENDMSG_SYSCALL
+# undef __ASSUME_RECVMSG_SYSCALL
#endif
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index 8642bac..68b6c9a 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -28,9 +28,7 @@ getsockopt - getsockopt i:iiiBN __getsockopt getsockopt
listen - listen i:ii __listen listen
recv - recv Ci:ibni __libc_recv __recv recv
recvfrom - recvfrom Ci:ibniBN __libc_recvfrom __recvfrom recvfrom
-recvmsg - recvmsg Ci:ipi __libc_recvmsg __recvmsg recvmsg
send - send Ci:ibni __libc_send __send send
-sendmsg - sendmsg Ci:ipi __libc_sendmsg __sendmsg sendmsg
sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto
setsockopt - setsockopt i:iiibn __setsockopt setsockopt
shutdown - shutdown i:ii __shutdown shutdown
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index 5a1b204..3fba4151 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -145,3 +145,11 @@
# define __ASSUME_SENDMMSG_SYSCALL 1
# define __ASSUME_SENDMMSG 1
#endif
+
+/* Support for recvmsg and sendmsg was added in 2.6.12 in most architectures,
+ with some added later (for instance 2.6.37 for powerpc) and for some only
+ through syscall (with wire-up syscall added in later versionsi). Define
+ __ASSUME_RECVMSG_SYSCALL and __ASUME_SENDMSG_SYSCALL if glibc uses direct
+ syscall, otherwise glibc will use socketcall. */
+#define __ASSUME_SENDMSG_SYSCALL 1
+#define __ASSUME_RECVMSG_SYSCALL 1
diff --git a/sysdeps/unix/sysv/linux/m68k/kernel-features.h b/sysdeps/unix/sysv/linux/m68k/kernel-features.h
index 646bc4b..dec04f0 100644
--- a/sysdeps/unix/sysv/linux/m68k/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/m68k/kernel-features.h
@@ -34,10 +34,8 @@
# define __ASSUME_GETPEERNAME_SYSCALL 1
# define __ASSUME_SENDTO_SYSCALL 1
# define __ASSUME_SENDTO_FOR_SEND_SYSCALL 1
-# define __ASSUME_SENDMSG_SYSCALL 1
# define __ASSUME_RECVFROM_SYSCALL 1
# define __ASSUME_RECVFROM_FOR_RECV_SYSCALL 1
-# define __ASSUME_RECVMSG_SYSCALL 1
# define __ASSUME_SHUTDOWN_SYSCALL 1
#endif
@@ -47,6 +45,8 @@
# undef __ASSUME_ACCEPT4_SYSCALL
# undef __ASSUME_RECVMMSG_SYSCALL
# undef __ASSUME_SENDMMSG_SYSCALL
+# undef __ASSUME_SENDMSG_SYSCALL
+# undef __ASSUME_RECVMSG_SYSCALL
#endif
/* No support for PI futexes or robust mutexes before 3.10 for m68k. */
diff --git a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h
index 3938989..db471ef 100644
--- a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h
@@ -35,8 +35,6 @@
#define __ASSUME_SHUTDOWN_SYSCALL 1
#define __ASSUME_GETSOCKOPT_SYSCALL 1
#define __ASSUME_SETSOCKOPT_SYSCALL 1
-#define __ASSUME_SENDMSG_SYSCALL 1
-#define __ASSUME_RECVMSG_SYSCALL 1
/* Support for the accept4 and recvmmsg syscalls was added in 2.6.33. */
#define __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL 1
diff --git a/sysdeps/unix/sysv/linux/mips/syscalls.list b/sysdeps/unix/sysv/linux/mips/syscalls.list
index db731b1..cd946a0 100644
--- a/sysdeps/unix/sysv/linux/mips/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/syscalls.list
@@ -21,9 +21,7 @@ getsockopt - getsockopt i:iiiBN __getsockopt getsockopt
listen - listen i:ii __listen listen
recv - recv Ci:ibni __libc_recv __recv recv
recvfrom - recvfrom Ci:ibniBN __libc_recvfrom __recvfrom recvfrom
-recvmsg - recvmsg Ci:ipi __libc_recvmsg __recvmsg recvmsg
send - send Ci:ibni __libc_send __send send
-sendmsg - sendmsg Ci:ipi __libc_sendmsg __sendmsg sendmsg
sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto
setsockopt - setsockopt i:iiibn __setsockopt setsockopt
shutdown - shutdown i:ii __shutdown shutdown
diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
index 171c030..5449f18 100644
--- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
@@ -36,8 +36,6 @@
#define __ASSUME_SHUTDOWN_SYSCALL 1
#define __ASSUME_GETSOCKOPT_SYSCALL 1
#define __ASSUME_SETSOCKOPT_SYSCALL 1
-#define __ASSUME_SENDMSG_SYSCALL 1
-#define __ASSUME_RECVMSG_SYSCALL 1
/* The sendmmsg syscall was added for PowerPC in 3.0. */
#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1
diff --git a/sysdeps/unix/sysv/linux/s390/kernel-features.h b/sysdeps/unix/sysv/linux/s390/kernel-features.h
index a6f131b..b3edee4 100644
--- a/sysdeps/unix/sysv/linux/s390/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/s390/kernel-features.h
@@ -34,10 +34,8 @@
# define __ASSUME_GETPEERNAME_SYSCALL 1
# define __ASSUME_SENDTO_SYSCALL 1
# define __ASSUME_SENDTO_FOR_SEND_SYSCALL 1
-# define __ASSUME_SENDMSG_SYSCALL 1
# define __ASSUME_RECVFROM_SYSCALL 1
# define __ASSUME_RECVFROM_FOR_RECV_SYSCALL 1
-# define __ASSUME_RECVMSG_SYSCALL 1
# define __ASSUME_SHUTDOWN_SYSCALL 1
#endif
@@ -47,4 +45,6 @@
# undef __ASSUME_ACCEPT4_SYSCALL
# undef __ASSUME_RECVMMSG_SYSCALL
# undef __ASSUME_SENDMMSG_SYSCALL
+# undef __ASSUME_SENDMSG_SYSCALL
+# undef __ASSUME_RECVMSG_SYSCALL
#endif
diff --git a/sysdeps/unix/sysv/linux/sh/kernel-features.h b/sysdeps/unix/sysv/linux/sh/kernel-features.h
index 9b4d1c2..ad05fc3 100644
--- a/sysdeps/unix/sysv/linux/sh/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/sh/kernel-features.h
@@ -36,8 +36,6 @@
#define __ASSUME_SHUTDOWN_SYSCALL 1
#define __ASSUME_GETSOCKOPT_SYSCALL 1
#define __ASSUME_SETSOCKOPT_SYSCALL 1
-#define __ASSUME_SENDMSG_SYSCALL 1
-#define __ASSUME_RECVMSG_SYSCALL 1
/* The sendmmsg syscall was added for SH in 3.0. */
#define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list
index 3d1c1da..eecd837 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list
@@ -11,9 +11,7 @@ getsockopt - getsockopt 5 __getsockopt getsockopt
listen - listen 2 __listen listen
recv - recv C:4 __libc_recv __recv recv
recvfrom - recvfrom C:6 __libc_recvfrom __recvfrom recvfrom
-recvmsg - recvmsg C:3 __libc_recvmsg __recvmsg recvmsg
send - send C:4 __libc_send __send send
-sendmsg - sendmsg C:3 __libc_sendmsg __sendmsg sendmsg
sendto - sendto C:6 __libc_sendto __sendto sendto
setsockopt - setsockopt 5 __setsockopt setsockopt
shutdown - shutdown 2 __shutdown shutdown
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index 2e4135f..d09d101 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -26,8 +26,6 @@ getsockname - getsockname i:ipp __getsockname getsockname
getsockopt - getsockopt i:iiiBN __getsockopt getsockopt
listen - listen i:ii __listen listen
recvfrom - recvfrom Ci:ibniBN __libc_recvfrom __recvfrom recvfrom
-recvmsg - recvmsg Ci:ipi __libc_recvmsg __recvmsg recvmsg
-sendmsg - sendmsg Ci:ipi __libc_sendmsg __sendmsg sendmsg
sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto
setsockopt - setsockopt i:iiibn __setsockopt setsockopt
shutdown - shutdown i:ii __shutdown shutdown
--
1.9.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] network: recvmmsg and sendmmsg standard compliance (BZ#16919)
2016-03-25 13:57 [PATCH v3 0/3] Fix {recv,send}{m}msg standard compliance (BZ#16919) Adhemerval Zanella
@ 2016-03-25 13:57 ` Adhemerval Zanella
2016-03-25 20:00 ` Joseph Myers
0 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2016-03-25 13:57 UTC (permalink / raw)
To: libc-alpha
POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen
to be of size int and socklen_t respectively, however Linux implements
it as a size_t. So for 64-bits architecture where sizeof of size_t is
larger than socklen_t, both sendmmsg and recvmmsg need to adjust the
mmsghdr::msg_hdr internal fields before issuing the syscall itself.
This patch fixes it by operating on the padding if it the case.
For recvmmsg, the most straightfoward case, only zero padding the fields
is suffice. However, for sendmmsg, where adjusting the buffer is out
of the contract (since it may point to a read-only data), the function
is rewritten to use sendmsg instead (which from previous patch
allocates a temporary msghdr to operate on).
Also for 64-bit ports that requires it, a new recvmmsg and sendmmsg
compat version is created (which uses size_t for both cmsghdr::cmsg_len
and internal
Tested on x86_64, i686, aarch64, armhf, and powerpc64le.
* sysdeps/unix/sysv/linux/Makefile
[$(subdir) = socket] (sysdep_routines): Add oldrecvmmsg and
oldsendmmsg.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Add recvmmsg and
sendmmsg.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/oldrecvmmsg.c: New file.
* sysdeps/unix/sysv/linux/oldsendmmsg.c: Likewise.
* sysdeps/unix/sysv/linux/recvmmsg.c (__recvmmsg): Adjust msghdr
iovlen and controllen fields to adjust to POSIX specification.
* sysdeps/unix/sysv/linux/sendmmsg.c (__sendmmsg): Likewise.
---
ChangeLog | 21 ++++++
sysdeps/unix/sysv/linux/Makefile | 3 +-
sysdeps/unix/sysv/linux/aarch64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/alpha/libc.abilist | 2 +
sysdeps/unix/sysv/linux/ia64/libc.abilist | 2 +
.../unix/sysv/linux/mips/mips64/n64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/oldrecvmmsg.c | 75 ++++++++++++++++++++++
sysdeps/unix/sysv/linux/oldsendmmsg.c | 75 ++++++++++++++++++++++
.../sysv/linux/powerpc/powerpc64/libc-le.abilist | 2 +
.../unix/sysv/linux/powerpc/powerpc64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/recvmmsg.c | 61 +++++++++++-------
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/sendmmsg.c | 72 +++++++++++++++------
sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 2 +
.../sysv/linux/tile/tilegx/tilegx64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 2 +
16 files changed, 283 insertions(+), 44 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/oldrecvmmsg.c
create mode 100644 sysdeps/unix/sysv/linux/oldsendmmsg.c
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index af8e13a..6d556dc 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -124,7 +124,8 @@ ifeq ($(subdir),socket)
sysdep_headers += net/if_ppp.h net/ppp-comp.h \
net/ppp_defs.h net/if_arp.h net/route.h net/ethernet.h \
net/if_slip.h net/if_packet.h net/if_shaper.h
-sysdep_routines += cmsg_nxthdr oldrecvmsg oldsendmsg
+sysdep_routines += cmsg_nxthdr oldrecvmsg oldsendmsg \
+ oldrecvmmsg oldsendmmsg
CFLAGS-recvmsg.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-sendmsg.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-oldrecvmsg.c = -fexceptions -fasynchronous-unwind-tables
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index c3f2346..7981817 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2088,5 +2088,7 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 7822242..0c1e1ac 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -1999,7 +1999,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index f5739b4..b1388d1 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -1875,7 +1875,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index 6722f90..0e2ff75 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -1933,7 +1933,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/oldrecvmmsg.c b/sysdeps/unix/sysv/linux/oldrecvmmsg.c
new file mode 100644
index 0000000..31fbb2d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/oldrecvmmsg.c
@@ -0,0 +1,75 @@
+/* Compatibility version of recvmsg.
+ Copyright (C) 2010-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/socket.h>
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+#include <shlib-compat.h>
+
+#if __WORDSIZE == 64
+# if SHLIB_COMPAT (libc, GLIBC_2_12, GLIBC_2_24)
+
+int
+__old_recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen,
+ int flags, struct timespec *tmo)
+{
+# ifdef __ASSUME_RECVMMSG_SYSCALL
+ return SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
+# elif defined __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL
+ return SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
+# elif defined __ASSUME_SOCKETCALL
+ static int have_recvmmsg;
+ if (__glibc_likely (have_recvmmsg >= 0))
+ {
+ int ret = SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags,
+ tmo);
+ /* The kernel returns -EINVAL for unknown socket operations.
+ We need to convert that error to an ENOSYS error. */
+ if (__builtin_expect (ret < 0, 0)
+ && have_recvmmsg == 0
+ && errno == EINVAL)
+ {
+ /* Try another call, this time with an invalid file
+ descriptor and all other parameters cleared. This call
+ will not cause any harm and it will return
+ immediately. */
+ ret = SOCKETCALL_CANCEL (invalid, -1);
+ if (errno == EINVAL)
+ {
+ have_recvmmsg = -1;
+ __set_errno (ENOSYS);
+ }
+ else
+ {
+ have_recvmmsg = 1;
+ __set_errno (EINVAL);
+ }
+ return -1;
+ }
+ return ret;
+ }
+ __set_errno (ENOSYS);
+ return -1;
+# else
+ __set_errno (ENOSYS);
+ return -1;
+# endif
+}
+compat_symbol (libc, __old_recvmmsg, recvmmsg, GLIBC_2_12);
+# endif /* SHLIB_COMPAT (libc, GLIBC_2_12, GLIBC_2_24) */
+#endif /* __WORDSIZE == 64 */
diff --git a/sysdeps/unix/sysv/linux/oldsendmmsg.c b/sysdeps/unix/sysv/linux/oldsendmmsg.c
new file mode 100644
index 0000000..59c18e8
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/oldsendmmsg.c
@@ -0,0 +1,75 @@
+/* Compatibility implementation of sendmmsg.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/socket.h>
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+#include <shlib-compat.h>
+
+#if __WORDSIZE == 64
+# if SHLIB_COMPAT (libc, GLIBC_2_14, GLIBC_2_24)
+
+int
+__old_sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen,
+ int flags)
+{
+# ifdef __ASSUME_SENDMMSG_SYSCALL
+ return SYSCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+# elif defined __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL
+ return SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+# elif defined __ASSUME_SOCKETCALL
+ static int have_sendmmsg;
+ if (__glibc_likely (have_sendmmsg >= 0))
+ {
+ int ret = SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+ /* The kernel returns -EINVAL for unknown socket operations.
+ We need to convert that error to an ENOSYS error. */
+ if (__builtin_expect (ret < 0, 0)
+ && have_sendmmsg == 0
+ && errno == EINVAL)
+ {
+ /* Try another call, this time with an invalid file
+ descriptor and all other parameters cleared. This call
+ will not cause any harm and it will return
+ immediately. */
+ ret = SOCKETCALL_CANCEL (invalid, -1);
+ if (errno == EINVAL)
+ {
+ have_sendmmsg = -1;
+ __set_errno (ENOSYS);
+ }
+ else
+ {
+ have_sendmmsg = 1;
+ __set_errno (EINVAL);
+ }
+ return -1;
+ }
+ return ret;
+ }
+ __set_errno (ENOSYS);
+ return -1;
+# else
+ __set_errno (ENOSYS);
+ return -1;
+# endif
+}
+
+compat_symbol (libc, __old_sendmmsg, sendmmsg, GLIBC_2_14);
+# endif /* SHLIB_COMPAT (libc, GLIBC_2_14, GLIBC_2_24) */
+#endif /* __WORDSIZE == 64 */
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
index 7839b5a..85286c4 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
@@ -2176,5 +2176,7 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
index 20d5a19..0abd098 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
@@ -90,7 +90,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 _Exit F
diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c
index bf18260..08b89ba 100644
--- a/sysdeps/unix/sysv/linux/recvmmsg.c
+++ b/sysdeps/unix/sysv/linux/recvmmsg.c
@@ -16,12 +16,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <errno.h>
#include <sys/socket.h>
-
+#include <socketcall.h>
#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-#include <kernel-features.h>
+#include <shlib-compat.h>
/* Do not use the recvmmsg syscall on socketcall architectures unless
it was added at the same time as the socketcall support or can be
@@ -32,31 +30,39 @@
# undef __NR_recvmmsg
#endif
-#ifdef __NR_recvmmsg
+static inline void
+adjust_mmsghdr (struct mmsghdr *vmessages, unsigned int vlen)
+{
+#if __WORDSIZE == 64
+ /* POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen
+ to be int and socklen_t respectively. However Linux defines it as
+ both size_t. So for 64-bit it requires some adjustments by zeroing
+ the pad fields. */
+ struct mmsghdr *vmhdr = vmessages;
+ for (unsigned int i = 0; i != 0; i--, vmhdr++)
+ {
+ vmhdr->msg_hdr.__glibc_reserved1 = 0;
+ vmhdr->msg_hdr.__glibc_reserved2 = 0;
+ }
+#endif
+}
+
int
-recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
- struct timespec *tmo)
+__recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen,
+ int flags, struct timespec *tmo)
{
+#ifdef __NR_recvmmsg
+ adjust_mmsghdr (vmessages, vlen);
return SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
-}
#elif defined __NR_socketcall
-# include <socketcall.h>
# ifdef __ASSUME_RECVMMSG_SOCKETCALL
-int
-recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
- struct timespec *tmo)
-{
+ adjust_mmsghdr (vmessages, vlen);
return SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
-}
# else
-static int have_recvmmsg;
-
-int
-recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
- struct timespec *tmo)
-{
+ static int have_recvmmsg;
if (__glibc_likely (have_recvmmsg >= 0))
{
+ adjust_mmsghdr (vmessages, vlen);
int ret = SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags,
tmo);
/* The kernel returns -EINVAL for unknown socket operations.
@@ -86,8 +92,19 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
}
__set_errno (ENOSYS);
return -1;
-}
# endif /* __ASSUME_RECVMMSG_SOCKETCALL */
#else
-# include <socket/recvmmsg.c>
+# define STUB 1
+ __set_errno (ENOSYS);
+ return -1;
+#endif
+}
+#ifdef STUB
+stub_warning (recvmmsg)
+#endif
+
+#if __WORDSIZE == 64
+versioned_symbol (libc, __recvmmsg, recvmmsg, GLIBC_2_24);
+#else
+weak_alias (__recvmmsg, recvmmsg)
#endif
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index 5892fcd..03a9b97 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -1872,7 +1872,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/sendmmsg.c b/sysdeps/unix/sysv/linux/sendmmsg.c
index 6e0d46b..9b19343 100644
--- a/sysdeps/unix/sysv/linux/sendmmsg.c
+++ b/sysdeps/unix/sysv/linux/sendmmsg.c
@@ -16,12 +16,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <errno.h>
#include <sys/socket.h>
-
+#include <socketcall.h>
#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-#include <kernel-features.h>
+#include <shlib-compat.h>
/* Do not use the sendmmsg syscall on socketcall architectures unless
it was added at the same time as the socketcall support or can be
@@ -32,31 +30,53 @@
# undef __NR_sendmmsg
#endif
-#ifdef __NR_sendmmsg
+#if __WORDSIZE == 64
+static inline int
+send_mmsghdr (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
+{
+ /* Emulate kernel interface for vlen size. */
+ if (vlen > IOV_MAX)
+ vlen = IOV_MAX;
+ if (vlen == 0)
+ return 0;
+ /* POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen
+ to be int and socklen_t respectively, however Linux defines it as both
+ size_t. So for 64-bit it requires some adjustments by copying to
+ temporary header and zeroing the pad fields.
+ The problem is sendmmsg's msghdr may points to an already-filled control
+ buffer and modifying it is not part of sendmmsg contract (the data may
+ be in ro map). So interact over the msghdr calling the sendmsg that
+ adjust the header using a temporary buffer. */
+ for (unsigned int i = 0; i < vlen; i++)
+ {
+ ssize_t ret = __sendmsg (fd, &vmessages[i].msg_hdr, flags);
+ if (ret < 0)
+ return -1;
+ vmessages[i].msg_len = ret;
+ }
+ return 1;
+}
+#endif
+
int
__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
{
+#if __WORDSIZE == 64
+ return send_mmsghdr (fd, vmessages, vlen, flags);
+#elif defined __NR_sendmmsg
return SYSCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
-}
-libc_hidden_def (__sendmmsg)
-weak_alias (__sendmmsg, sendmmsg)
#elif defined __NR_socketcall
-# include <socketcall.h>
# ifdef __ASSUME_SENDMMSG_SOCKETCALL
-int
-__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
-{
return SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
-}
# else
-static int have_sendmmsg;
-
-int
-__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
-{
+ static int have_sendmmsg;
if (__glibc_likely (have_sendmmsg >= 0))
{
+# if __WORDSIZE == 64
+ int ret = send_mmsghdr (fd, vmessages, vlen, flags);
+# else
int ret = SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+# endif
/* The kernel returns -EINVAL for unknown socket operations.
We need to convert that error to an ENOSYS error. */
if (__builtin_expect (ret < 0, 0)
@@ -84,10 +104,20 @@ __sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
}
__set_errno (ENOSYS);
return -1;
-}
# endif /* __ASSUME_SENDMMSG_SOCKETCALL */
+#else /* defined __NR_socketcall */
+# define STUB 1
+ __set_errno (ENOSYS);
+ return -1;
+#endif
+}
+#ifdef STUB
+stub_warning (sendmmsg)
+#endif
+
libc_hidden_def (__sendmmsg)
-weak_alias (__sendmmsg, sendmmsg)
+#if __WORDSIZE == 64
+versioned_symbol (libc, __sendmmsg, sendmmsg, GLIBC_2_24);
#else
-# include <socket/sendmmsg.c>
+weak_alias (__sendmmsg, sendmmsg)
#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index 015a2f1..38b976f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -1901,7 +1901,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
index 1e160bd..07b1332 100644
--- a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
@@ -2095,5 +2095,7 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index 175339e..baea1f5 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -1852,7 +1852,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
--
1.9.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] network: recvmmsg and sendmmsg standard compliance (BZ#16919)
2016-03-25 13:57 ` [PATCH 3/3] network: recvmmsg and sendmmsg " Adhemerval Zanella
@ 2016-03-25 20:00 ` Joseph Myers
2016-03-26 13:11 ` Adhemerval Zanella
0 siblings, 1 reply; 12+ messages in thread
From: Joseph Myers @ 2016-03-25 20:00 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Fri, 25 Mar 2016, Adhemerval Zanella wrote:
> diff --git a/sysdeps/unix/sysv/linux/oldrecvmmsg.c b/sysdeps/unix/sysv/linux/oldrecvmmsg.c
This file appears to be assuming the reversing of the meaning of
__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL that you otherwise removed from
the patch series. You need to make it match the current recvmmsg.c
instead.
> diff --git a/sysdeps/unix/sysv/linux/oldsendmmsg.c b/sysdeps/unix/sysv/linux/oldsendmmsg.c
Likewise.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] network: recvmmsg and sendmmsg standard compliance (BZ#16919)
2016-03-25 20:00 ` Joseph Myers
@ 2016-03-26 13:11 ` Adhemerval Zanella
0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2016-03-26 13:11 UTC (permalink / raw)
To: Joseph Myers; +Cc: libc-alpha
> On Mar 25, 2016, at 16:59, Joseph Myers <joseph@codesourcery.com> wrote:
>
>> On Fri, 25 Mar 2016, Adhemerval Zanella wrote:
>>
>> diff --git a/sysdeps/unix/sysv/linux/oldrecvmmsg.c b/sysdeps/unix/sysv/linux/oldrecvmmsg.c
>
> This file appears to be assuming the reversing of the meaning of
> __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL that you otherwise removed from
> the patch series. You need to make it match the current recvmmsg.c
> instead.
>
>> diff --git a/sysdeps/unix/sysv/linux/oldsendmmsg.c b/sysdeps/unix/sysv/linux/oldsendmmsg.c
>
> Likewise.
Indeed, I overlooked it. I will repost a new version with this fix.
> --
> Joseph S. Myers
> joseph@codesourcery.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] network: recvmmsg and sendmmsg standard compliance (BZ#16919)
2016-03-28 14:34 [PATCH v4 0/3] Fix {recv,send}{m}msg " Adhemerval Zanella
@ 2016-03-28 14:34 ` Adhemerval Zanella
0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2016-03-28 14:34 UTC (permalink / raw)
To: libc-alpha
POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen
to be of size int and socklen_t respectively, however Linux implements
it as a size_t. So for 64-bits architecture where sizeof of size_t is
larger than socklen_t, both sendmmsg and recvmmsg need to adjust the
mmsghdr::msg_hdr internal fields before issuing the syscall itself.
This patch fixes it by operating on the padding if it the case.
For recvmmsg, the most straightfoward case, only zero padding the fields
is suffice. However, for sendmmsg, where adjusting the buffer is out
of the contract (since it may point to a read-only data), the function
is rewritten to use sendmsg instead (which from previous patch
allocates a temporary msghdr to operate on).
Also for 64-bit ports that requires it, a new recvmmsg and sendmmsg
compat version is created (which uses size_t for both cmsghdr::cmsg_len
and internal
Tested on x86_64, i686, aarch64, armhf, and powerpc64le.
* sysdeps/unix/sysv/linux/Makefile
[$(subdir) = socket] (sysdep_routines): Add oldrecvmmsg and
oldsendmmsg.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Add recvmmsg and
sendmmsg.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/oldrecvmmsg.c: New file.
* sysdeps/unix/sysv/linux/oldsendmmsg.c: Likewise.
* sysdeps/unix/sysv/linux/recvmmsg.c (__recvmmsg): Adjust msghdr
iovlen and controllen fields to adjust to POSIX specification.
* sysdeps/unix/sysv/linux/sendmmsg.c (__sendmmsg): Likewise.
---
ChangeLog | 21 ++++++
sysdeps/unix/sysv/linux/Makefile | 3 +-
sysdeps/unix/sysv/linux/aarch64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/alpha/libc.abilist | 2 +
sysdeps/unix/sysv/linux/ia64/libc.abilist | 2 +
.../unix/sysv/linux/mips/mips64/n64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/oldrecvmmsg.c | 87 ++++++++++++++++++++++
sysdeps/unix/sysv/linux/oldsendmmsg.c | 76 +++++++++++++++++++
.../sysv/linux/powerpc/powerpc64/libc-le.abilist | 2 +
.../unix/sysv/linux/powerpc/powerpc64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/recvmmsg.c | 61 +++++++++------
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/sendmmsg.c | 72 ++++++++++++------
sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 2 +
.../sysv/linux/tile/tilegx/tilegx64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 2 +
16 files changed, 296 insertions(+), 44 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/oldrecvmmsg.c
create mode 100644 sysdeps/unix/sysv/linux/oldsendmmsg.c
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index af8e13a..6d556dc 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -124,7 +124,8 @@ ifeq ($(subdir),socket)
sysdep_headers += net/if_ppp.h net/ppp-comp.h \
net/ppp_defs.h net/if_arp.h net/route.h net/ethernet.h \
net/if_slip.h net/if_packet.h net/if_shaper.h
-sysdep_routines += cmsg_nxthdr oldrecvmsg oldsendmsg
+sysdep_routines += cmsg_nxthdr oldrecvmsg oldsendmsg \
+ oldrecvmmsg oldsendmmsg
CFLAGS-recvmsg.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-sendmsg.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-oldrecvmsg.c = -fexceptions -fasynchronous-unwind-tables
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index c3f2346..7981817 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2088,5 +2088,7 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 7822242..0c1e1ac 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -1999,7 +1999,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index f5739b4..b1388d1 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -1875,7 +1875,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index 6722f90..0e2ff75 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -1933,7 +1933,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/oldrecvmmsg.c b/sysdeps/unix/sysv/linux/oldrecvmmsg.c
new file mode 100644
index 0000000..4bf849b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/oldrecvmmsg.c
@@ -0,0 +1,87 @@
+/* Compatibility version of recvmsg.
+ Copyright (C) 2010-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/socket.h>
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+#include <shlib-compat.h>
+
+#if __WORDSIZE == 64
+# if SHLIB_COMPAT (libc, GLIBC_2_12, GLIBC_2_24)
+
+/* Do not use the recvmmsg syscall on socketcall architectures unless
+ it was added at the same time as the socketcall support or can be
+ assumed to be present. */
+# if defined __ASSUME_SOCKETCALL \
+ && !defined __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL \
+ && !defined __ASSUME_RECVMMSG_SYSCALL
+# undef __NR_recvmmsg
+# endif
+
+int
+__old_recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen,
+ int flags, struct timespec *tmo)
+{
+# ifdef __NR_recvmmsg
+ return SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
+# elif defined __NR_socketcall
+# ifdef __ASSUME_RECVMMSG_SOCKETCALL
+ return SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
+# else
+ static int have_recvmmsg;
+ if (__glibc_likely (have_recvmmsg >= 0))
+ {
+ int ret = SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags,
+ tmo);
+ /* The kernel returns -EINVAL for unknown socket operations.
+ We need to convert that error to an ENOSYS error. */
+ if (__builtin_expect (ret < 0, 0)
+ && have_recvmmsg == 0
+ && errno == EINVAL)
+ {
+ /* Try another call, this time with an invalid file
+ descriptor and all other parameters cleared. This call
+ will not cause any harm and it will return
+ immediately. */
+ ret = SOCKETCALL_CANCEL (invalid, -1);
+ if (errno == EINVAL)
+ {
+ have_recvmmsg = -1;
+ __set_errno (ENOSYS);
+ }
+ else
+ {
+ have_recvmmsg = 1;
+ __set_errno (EINVAL);
+ }
+ return -1;
+ }
+ return ret;
+ }
+ __set_errno (ENOSYS);
+ return -1;
+# endif /* __ASSUME_RECVMMSG_SOCKETCALL */
+# else
+ __set_errno (ENOSYS);
+ return -1;
+# endif
+}
+compat_symbol (libc, __old_recvmmsg, recvmmsg, GLIBC_2_12);
+
+# endif /* SHLIB_COMPAT (libc, GLIBC_2_12, GLIBC_2_24) */
+#endif /* __WORDSIZE == 64 */
diff --git a/sysdeps/unix/sysv/linux/oldsendmmsg.c b/sysdeps/unix/sysv/linux/oldsendmmsg.c
new file mode 100644
index 0000000..e40c311
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/oldsendmmsg.c
@@ -0,0 +1,76 @@
+/* Compatibility implementation of sendmmsg.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/socket.h>
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+#include <shlib-compat.h>
+
+#if __WORDSIZE == 64
+# if SHLIB_COMPAT (libc, GLIBC_2_14, GLIBC_2_24)
+
+int
+__old_sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen,
+ int flags)
+{
+# ifdef __NR_sendmmsg
+ return SYSCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+# elif defined __NR_socketcall
+# ifdef __ASSUME_SENDMMSG_SOCKETCALL
+ return SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+# else
+ static int have_sendmmsg;
+ if (__glibc_likely (have_sendmmsg >= 0))
+ {
+ int ret = SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+ /* The kernel returns -EINVAL for unknown socket operations.
+ We need to convert that error to an ENOSYS error. */
+ if (__builtin_expect (ret < 0, 0)
+ && have_sendmmsg == 0
+ && errno == EINVAL)
+ {
+ /* Try another call, this time with an invalid file
+ descriptor and all other parameters cleared. This call
+ will not cause any harm and it will return
+ immediately. */
+ ret = SOCKETCALL_CANCEL (invalid, -1);
+ if (errno == EINVAL)
+ {
+ have_sendmmsg = -1;
+ __set_errno (ENOSYS);
+ }
+ else
+ {
+ have_sendmmsg = 1;
+ __set_errno (EINVAL);
+ }
+ return -1;
+ }
+ return ret;
+ }
+ __set_errno (ENOSYS);
+ return -1;
+# endif /* __ASSUME_SENDMMSG_SOCKETCALL */
+# else /* defined __NR_socketcall */
+ __set_errno (ENOSYS);
+ return -1;
+# endif
+}
+compat_symbol (libc, __old_sendmmsg, sendmmsg, GLIBC_2_14);
+# endif /* SHLIB_COMPAT (libc, GLIBC_2_14, GLIBC_2_24) */
+#endif /* __WORDSIZE == 64 */
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
index 7839b5a..85286c4 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
@@ -2176,5 +2176,7 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
index 20d5a19..0abd098 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
@@ -90,7 +90,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 _Exit F
diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c
index bf18260..08b89ba 100644
--- a/sysdeps/unix/sysv/linux/recvmmsg.c
+++ b/sysdeps/unix/sysv/linux/recvmmsg.c
@@ -16,12 +16,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <errno.h>
#include <sys/socket.h>
-
+#include <socketcall.h>
#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-#include <kernel-features.h>
+#include <shlib-compat.h>
/* Do not use the recvmmsg syscall on socketcall architectures unless
it was added at the same time as the socketcall support or can be
@@ -32,31 +30,39 @@
# undef __NR_recvmmsg
#endif
-#ifdef __NR_recvmmsg
+static inline void
+adjust_mmsghdr (struct mmsghdr *vmessages, unsigned int vlen)
+{
+#if __WORDSIZE == 64
+ /* POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen
+ to be int and socklen_t respectively. However Linux defines it as
+ both size_t. So for 64-bit it requires some adjustments by zeroing
+ the pad fields. */
+ struct mmsghdr *vmhdr = vmessages;
+ for (unsigned int i = 0; i != 0; i--, vmhdr++)
+ {
+ vmhdr->msg_hdr.__glibc_reserved1 = 0;
+ vmhdr->msg_hdr.__glibc_reserved2 = 0;
+ }
+#endif
+}
+
int
-recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
- struct timespec *tmo)
+__recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen,
+ int flags, struct timespec *tmo)
{
+#ifdef __NR_recvmmsg
+ adjust_mmsghdr (vmessages, vlen);
return SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
-}
#elif defined __NR_socketcall
-# include <socketcall.h>
# ifdef __ASSUME_RECVMMSG_SOCKETCALL
-int
-recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
- struct timespec *tmo)
-{
+ adjust_mmsghdr (vmessages, vlen);
return SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
-}
# else
-static int have_recvmmsg;
-
-int
-recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
- struct timespec *tmo)
-{
+ static int have_recvmmsg;
if (__glibc_likely (have_recvmmsg >= 0))
{
+ adjust_mmsghdr (vmessages, vlen);
int ret = SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags,
tmo);
/* The kernel returns -EINVAL for unknown socket operations.
@@ -86,8 +92,19 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
}
__set_errno (ENOSYS);
return -1;
-}
# endif /* __ASSUME_RECVMMSG_SOCKETCALL */
#else
-# include <socket/recvmmsg.c>
+# define STUB 1
+ __set_errno (ENOSYS);
+ return -1;
+#endif
+}
+#ifdef STUB
+stub_warning (recvmmsg)
+#endif
+
+#if __WORDSIZE == 64
+versioned_symbol (libc, __recvmmsg, recvmmsg, GLIBC_2_24);
+#else
+weak_alias (__recvmmsg, recvmmsg)
#endif
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index 5892fcd..03a9b97 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -1872,7 +1872,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/sendmmsg.c b/sysdeps/unix/sysv/linux/sendmmsg.c
index 6e0d46b..9b19343 100644
--- a/sysdeps/unix/sysv/linux/sendmmsg.c
+++ b/sysdeps/unix/sysv/linux/sendmmsg.c
@@ -16,12 +16,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <errno.h>
#include <sys/socket.h>
-
+#include <socketcall.h>
#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-#include <kernel-features.h>
+#include <shlib-compat.h>
/* Do not use the sendmmsg syscall on socketcall architectures unless
it was added at the same time as the socketcall support or can be
@@ -32,31 +30,53 @@
# undef __NR_sendmmsg
#endif
-#ifdef __NR_sendmmsg
+#if __WORDSIZE == 64
+static inline int
+send_mmsghdr (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
+{
+ /* Emulate kernel interface for vlen size. */
+ if (vlen > IOV_MAX)
+ vlen = IOV_MAX;
+ if (vlen == 0)
+ return 0;
+ /* POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen
+ to be int and socklen_t respectively, however Linux defines it as both
+ size_t. So for 64-bit it requires some adjustments by copying to
+ temporary header and zeroing the pad fields.
+ The problem is sendmmsg's msghdr may points to an already-filled control
+ buffer and modifying it is not part of sendmmsg contract (the data may
+ be in ro map). So interact over the msghdr calling the sendmsg that
+ adjust the header using a temporary buffer. */
+ for (unsigned int i = 0; i < vlen; i++)
+ {
+ ssize_t ret = __sendmsg (fd, &vmessages[i].msg_hdr, flags);
+ if (ret < 0)
+ return -1;
+ vmessages[i].msg_len = ret;
+ }
+ return 1;
+}
+#endif
+
int
__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
{
+#if __WORDSIZE == 64
+ return send_mmsghdr (fd, vmessages, vlen, flags);
+#elif defined __NR_sendmmsg
return SYSCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
-}
-libc_hidden_def (__sendmmsg)
-weak_alias (__sendmmsg, sendmmsg)
#elif defined __NR_socketcall
-# include <socketcall.h>
# ifdef __ASSUME_SENDMMSG_SOCKETCALL
-int
-__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
-{
return SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
-}
# else
-static int have_sendmmsg;
-
-int
-__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
-{
+ static int have_sendmmsg;
if (__glibc_likely (have_sendmmsg >= 0))
{
+# if __WORDSIZE == 64
+ int ret = send_mmsghdr (fd, vmessages, vlen, flags);
+# else
int ret = SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+# endif
/* The kernel returns -EINVAL for unknown socket operations.
We need to convert that error to an ENOSYS error. */
if (__builtin_expect (ret < 0, 0)
@@ -84,10 +104,20 @@ __sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
}
__set_errno (ENOSYS);
return -1;
-}
# endif /* __ASSUME_SENDMMSG_SOCKETCALL */
+#else /* defined __NR_socketcall */
+# define STUB 1
+ __set_errno (ENOSYS);
+ return -1;
+#endif
+}
+#ifdef STUB
+stub_warning (sendmmsg)
+#endif
+
libc_hidden_def (__sendmmsg)
-weak_alias (__sendmmsg, sendmmsg)
+#if __WORDSIZE == 64
+versioned_symbol (libc, __sendmmsg, sendmmsg, GLIBC_2_24);
#else
-# include <socket/sendmmsg.c>
+weak_alias (__sendmmsg, sendmmsg)
#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index 015a2f1..38b976f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -1901,7 +1901,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
diff --git a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
index 1e160bd..07b1332 100644
--- a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
@@ -2095,5 +2095,7 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index 175339e..baea1f5 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -1852,7 +1852,9 @@ GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 recvmmsg F
GLIBC_2.24 recvmsg F
+GLIBC_2.24 sendmmsg F
GLIBC_2.24 sendmsg F
GLIBC_2.3 GLIBC_2.3 A
GLIBC_2.3 __ctype_b_loc F
--
1.9.1
^ permalink raw reply [flat|nested] 12+ messages in thread