S390: Call direct system calls for socket operations.

Message ID mvl26o$43c$1@ger.gmane.org
State Committed
Headers

Commit Message

Stefan Liebler Oct. 14, 2015, 8:02 a.m. UTC
  On 10/13/2015 01:54 PM, Adhemerval Zanella wrote:
> I would prefer to not add another arch-specific implementation, but instead
> use something like __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL and use accept4
> directly in sysdeps/unix/sysv/linux/accept.c. Same for recv and send.

That sounds reasonable. Here is the updated patch.

---
2015-10-14  Stefan Liebler  <stli@linux.vnet.ibm.com>

	* sysdeps/unix/sysv/linux/s390/kernel-features.h:
	(__ASSUME_*_SYSCALL) Define new macros.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list:
	Remove socketcall syscalls.
	* sysdeps/unix/sysv/linux/accept.c (__libc_accept):
	Use accept4 if defined __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL.
	* sysdeps/unix/sysv/linux/recv.c (__libc_recv):
	Use recvfrom if defined __ASSUME_RECVFROM_FOR_RECV_SYSCALL.
	* sysdeps/unix/sysv/linux/send.c (__libc_send):
	Use sendto if defined __ASSUME_SENDTO_FOR_SEND_SYSCALL.
  

Comments

Stefan Liebler Oct. 21, 2015, 8:36 a.m. UTC | #1
ping

On 10/14/2015 10:02 AM, Stefan Liebler wrote:
>
> On 10/13/2015 01:54 PM, Adhemerval Zanella wrote:
>> I would prefer to not add another arch-specific implementation, but
>> instead
>> use something like __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL and use accept4
>> directly in sysdeps/unix/sysv/linux/accept.c. Same for recv and send.
>
> That sounds reasonable. Here is the updated patch.
>
> ---
> 2015-10-14  Stefan Liebler  <stli@linux.vnet.ibm.com>
>
>      * sysdeps/unix/sysv/linux/s390/kernel-features.h:
>      (__ASSUME_*_SYSCALL) Define new macros.
>      * sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list:
>      Remove socketcall syscalls.
>      * sysdeps/unix/sysv/linux/accept.c (__libc_accept):
>      Use accept4 if defined __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL.
>      * sysdeps/unix/sysv/linux/recv.c (__libc_recv):
>      Use recvfrom if defined __ASSUME_RECVFROM_FOR_RECV_SYSCALL.
>      * sysdeps/unix/sysv/linux/send.c (__libc_send):
>      Use sendto if defined __ASSUME_SENDTO_FOR_SEND_SYSCALL.
  
Adhemerval Zanella Netto Oct. 21, 2015, 11:07 a.m. UTC | #2
LGTM.

On 21-10-2015 06:36, Stefan Liebler wrote:
> ping
> 
> On 10/14/2015 10:02 AM, Stefan Liebler wrote:
>>
>> On 10/13/2015 01:54 PM, Adhemerval Zanella wrote:
>>> I would prefer to not add another arch-specific implementation, but
>>> instead
>>> use something like __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL and use accept4
>>> directly in sysdeps/unix/sysv/linux/accept.c. Same for recv and send.
>>
>> That sounds reasonable. Here is the updated patch.
>>
>> ---
>> 2015-10-14  Stefan Liebler  <stli@linux.vnet.ibm.com>
>>
>>      * sysdeps/unix/sysv/linux/s390/kernel-features.h:
>>      (__ASSUME_*_SYSCALL) Define new macros.
>>      * sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list:
>>      Remove socketcall syscalls.
>>      * sysdeps/unix/sysv/linux/accept.c (__libc_accept):
>>      Use accept4 if defined __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL.
>>      * sysdeps/unix/sysv/linux/recv.c (__libc_recv):
>>      Use recvfrom if defined __ASSUME_RECVFROM_FOR_RECV_SYSCALL.
>>      * sysdeps/unix/sysv/linux/send.c (__libc_send):
>>      Use sendto if defined __ASSUME_SENDTO_FOR_SEND_SYSCALL.
>
  
Stefan Liebler Oct. 29, 2015, 10:09 a.m. UTC | #3
ping

Ok to commit?
Is it okay to handle the accept, recv, send calls in common-code?

On 10/14/2015 10:02 AM, Stefan Liebler wrote:
>
> On 10/13/2015 01:54 PM, Adhemerval Zanella wrote:
>> I would prefer to not add another arch-specific implementation, but
>> instead
>> use something like __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL and use accept4
>> directly in sysdeps/unix/sysv/linux/accept.c. Same for recv and send.
>
> That sounds reasonable. Here is the updated patch.
>
> ---
> 2015-10-14  Stefan Liebler  <stli@linux.vnet.ibm.com>
>
>      * sysdeps/unix/sysv/linux/s390/kernel-features.h:
>      (__ASSUME_*_SYSCALL) Define new macros.
>      * sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list:
>      Remove socketcall syscalls.
>      * sysdeps/unix/sysv/linux/accept.c (__libc_accept):
>      Use accept4 if defined __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL.
>      * sysdeps/unix/sysv/linux/recv.c (__libc_recv):
>      Use recvfrom if defined __ASSUME_RECVFROM_FOR_RECV_SYSCALL.
>      * sysdeps/unix/sysv/linux/send.c (__libc_send):
>      Use sendto if defined __ASSUME_SENDTO_FOR_SEND_SYSCALL.
  
Stefan Liebler Nov. 5, 2015, 3:34 p.m. UTC | #4
ping

ok to commit?

On 10/29/2015 11:09 AM, Stefan Liebler wrote:
> ping
>
> Ok to commit?
> Is it okay to handle the accept, recv, send calls in common-code?
>
> On 10/14/2015 10:02 AM, Stefan Liebler wrote:
>>
>> On 10/13/2015 01:54 PM, Adhemerval Zanella wrote:
>>> I would prefer to not add another arch-specific implementation, but
>>> instead
>>> use something like __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL and use accept4
>>> directly in sysdeps/unix/sysv/linux/accept.c. Same for recv and send.
>>
>> That sounds reasonable. Here is the updated patch.
>>
>> ---
>> 2015-10-14  Stefan Liebler  <stli@linux.vnet.ibm.com>
>>
>>      * sysdeps/unix/sysv/linux/s390/kernel-features.h:
>>      (__ASSUME_*_SYSCALL) Define new macros.
>>      * sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list:
>>      Remove socketcall syscalls.
>>      * sysdeps/unix/sysv/linux/accept.c (__libc_accept):
>>      Use accept4 if defined __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL.
>>      * sysdeps/unix/sysv/linux/recv.c (__libc_recv):
>>      Use recvfrom if defined __ASSUME_RECVFROM_FOR_RECV_SYSCALL.
>>      * sysdeps/unix/sysv/linux/send.c (__libc_send):
>>      Use sendto if defined __ASSUME_SENDTO_FOR_SEND_SYSCALL.
>
>
  
Andreas Schwab Nov. 5, 2015, 3:42 p.m. UTC | #5
Stefan Liebler <stli@linux.vnet.ibm.com> writes:

> 	* sysdeps/unix/sysv/linux/s390/kernel-features.h:
> 	(__ASSUME_*_SYSCALL) Define new macros.
> 	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list:
> 	Remove socketcall syscalls.
> 	* sysdeps/unix/sysv/linux/accept.c (__libc_accept):
> 	Use accept4 if defined __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL.
> 	* sysdeps/unix/sysv/linux/recv.c (__libc_recv):
> 	Use recvfrom if defined __ASSUME_RECVFROM_FOR_RECV_SYSCALL.
> 	* sysdeps/unix/sysv/linux/send.c (__libc_send):
> 	Use sendto if defined __ASSUME_SENDTO_FOR_SEND_SYSCALL.

Ok.

Andreas.
  

Patch

diff --git a/sysdeps/unix/sysv/linux/accept.c b/sysdeps/unix/sysv/linux/accept.c
index 8b4fff0..f536133 100644
--- a/sysdeps/unix/sysv/linux/accept.c
+++ b/sysdeps/unix/sysv/linux/accept.c
@@ -29,6 +29,8 @@  __libc_accept (int fd, __SOCKADDR_ARG addr, socklen_t *len)
 {
 #ifdef __ASSUME_ACCEPT_SYSCALL
   return SYSCALL_CANCEL (accept, fd, addr.__sockaddr__, len);
+#elif defined __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL
+  return SYSCALL_CANCEL (accept4, fd, addr.__sockaddr__, len, 0);
 #else
   return SOCKETCALL_CANCEL (accept, fd, addr.__sockaddr__, len);
 #endif
diff --git a/sysdeps/unix/sysv/linux/recv.c b/sysdeps/unix/sysv/linux/recv.c
index 12be890..ce701b5 100644
--- a/sysdeps/unix/sysv/linux/recv.c
+++ b/sysdeps/unix/sysv/linux/recv.c
@@ -29,6 +29,8 @@  __libc_recv (int fd, void *buf, size_t len, int flags)
 {
 #ifdef __ASSUME_RECV_SYSCALL
   return SYSCALL_CANCEL (recv, fd, buf, len, flags);
+#elif defined __ASSUME_RECVFROM_FOR_RECV_SYSCALL
+  return SYSCALL_CANCEL (recvfrom, fd, buf, len, flags, NULL, NULL);
 #else
   return SOCKETCALL_CANCEL (recv, fd, buf, len, flags);
 #endif
diff --git a/sysdeps/unix/sysv/linux/s390/kernel-features.h b/sysdeps/unix/sysv/linux/s390/kernel-features.h
index 96f73ef..eaa3483 100644
--- a/sysdeps/unix/sysv/linux/s390/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/s390/kernel-features.h
@@ -20,4 +20,28 @@ 
 /* S/390 uses socketcall.  */
 #define __ASSUME_SOCKETCALL		1
 
+/* Direct socketcalls available with kernel 4.3.  */
+#if __LINUX_KERNEL_VERSION >= 0x040300
+# define __ASSUME_RECVMMSG_SYSCALL           1
+# define __ASSUME_SENDMMSG_SYSCALL           1
+# define __ASSUME_SOCKET_SYSCALL             1
+# define __ASSUME_SOCKETPAIR_SYSCALL         1
+# define __ASSUME_BIND_SYSCALL               1
+# define __ASSUME_CONNECT_SYSCALL            1
+# define __ASSUME_LISTEN_SYSCALL             1
+# define __ASSUME_ACCEPT4_SYSCALL            1
+# define __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL 1
+# define __ASSUME_GETSOCKOPT_SYSCALL         1
+# define __ASSUME_SETSOCKOPT_SYSCALL         1
+# define __ASSUME_GETSOCKNAME_SYSCALL        1
+# 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
+
 #include_next <kernel-features.h>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index 5b8c102..9f03d26 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -12,22 +12,3 @@  shmget		-	shmget		i:iii	__shmget	shmget
 semop		-	semop		i:ipi	__semop		semop
 semget		-	semget		i:iii	__semget	semget
 semctl		-	semctl		i:iiii	__semctl	semctl
-
-# proper socket implementations:
-accept		-	accept		Ci:iBN	__libc_accept	__accept accept
-bind		-	bind		i:ipi	__bind		bind
-connect		-	connect		Ci:ipi	__libc_connect	__connect connect
-getpeername	-	getpeername	i:ipp	__getpeername	getpeername
-getsockname	-	getsockname	i:ipp	__getsockname	getsockname
-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
-socket		-	socket		i:iii	__socket	socket
-socketpair	-	socketpair	i:iiif	__socketpair	socketpair
diff --git a/sysdeps/unix/sysv/linux/send.c b/sysdeps/unix/sysv/linux/send.c
index d917e4d..529c27d 100644
--- a/sysdeps/unix/sysv/linux/send.c
+++ b/sysdeps/unix/sysv/linux/send.c
@@ -29,6 +29,8 @@  __libc_send (int fd, const void *buf, size_t len, int flags)
 {
 #ifdef __ASSUME_SEND_SYSCALL
   return SYSCALL_CANCEL (send, fd, buf, len, flags);
+#elif defined __ASSUME_SENDTO_FOR_SEND_SYSCALL
+  return SYSCALL_CANCEL (sendto, fd, buf, len, flags, NULL, 0);
 #else
   return SOCKETCALL_CANCEL (send, fd, buf, len, flags);
 #endif