[PATCH 23/30] Linux: Assume and consolidate getpeername wire-up syscall

Carlos O'Donell carlos@redhat.com
Tue Dec 6 16:20:03 GMT 2022


On 10/19/22 18:14, Adhemerval Zanella via Libc-alpha wrote:
> And disable if kernel does not support it.
> 
> Checked on x86_64-linux-gnu and i686-linux-gnu.

I assume this needs a v2 for the sparc32 changes noted by Joseph.

It looks good to me for the other arches.

Tested-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  sysdeps/unix/sysv/linux/generic/syscalls.list        | 1 -
>  sysdeps/unix/sysv/linux/getpeername.c                | 7 +------
>  sysdeps/unix/sysv/linux/i386/kernel-features.h       | 2 +-
>  sysdeps/unix/sysv/linux/kernel-features.h            | 1 +
>  sysdeps/unix/sysv/linux/m68k/kernel-features.h       | 2 +-
>  sysdeps/unix/sysv/linux/microblaze/kernel-features.h | 1 -
>  sysdeps/unix/sysv/linux/powerpc/kernel-features.h    | 1 -
>  sysdeps/unix/sysv/linux/s390/kernel-features.h       | 2 +-
>  sysdeps/unix/sysv/linux/sh/kernel-features.h         | 1 -
>  9 files changed, 5 insertions(+), 13 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list
> index a5bb00a3e4..b000ca3c7c 100644
> --- a/sysdeps/unix/sysv/linux/generic/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/generic/syscalls.list
> @@ -1,5 +1,4 @@
>  # File name	Caller	Syscall name	# args	Strong name	Weak names
>  
>  # Socket APIs
> -getpeername	-	getpeername	i:ipp	__getpeername	getpeername

OK. Remove default wrapper.

>  shutdown	-	shutdown	i:ii	__shutdown	shutdown
> diff --git a/sysdeps/unix/sysv/linux/getpeername.c b/sysdeps/unix/sysv/linux/getpeername.c
> index 09ca76b9ad..63fa8e2fe5 100644
> --- a/sysdeps/unix/sysv/linux/getpeername.c
> +++ b/sysdeps/unix/sysv/linux/getpeername.c
> @@ -15,19 +15,14 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <signal.h>
>  #include <sys/socket.h>
> -
>  #include <socketcall.h>
> -#include <kernel-features.h>
> -#include <sys/syscall.h>
>  
>  int
>  __getpeername (int fd, __SOCKADDR_ARG addr, socklen_t *len)
>  {
>  #ifdef __ASSUME_GETPEERNAME_SYSCALL
> -  return INLINE_SYSCALL (getpeername, 3, fd, addr.__sockaddr__, len);
> +  return INLINE_SYSCALL_CALL (getpeername, fd, addr.__sockaddr__, len);

OK. Default wrapper.

>  #else
>    return SOCKETCALL (getpeername, fd, addr.__sockaddr__, len);
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/i386/kernel-features.h b/sysdeps/unix/sysv/linux/i386/kernel-features.h
> index f294380215..423edc9017 100644
> --- a/sysdeps/unix/sysv/linux/i386/kernel-features.h
> +++ b/sysdeps/unix/sysv/linux/i386/kernel-features.h
> @@ -19,7 +19,6 @@
>  
>  /* Direct socketcalls available with kernel 4.3.  */
>  #if __LINUX_KERNEL_VERSION >= 0x040300
> -# define __ASSUME_GETPEERNAME_SYSCALL        1
>  # define __ASSUME_SHUTDOWN_SYSCALL           1
>  #endif
>  
> @@ -41,6 +40,7 @@
>  # undef __ASSUME_SOCKETPAIR_SYSCALL
>  # undef __ASSUME_LISTEN_SYSCALL
>  # undef __ASSUME_GETSOCKNAME_SYSCALL
> +# undef __ASSUME_GETPEERNAME_SYSCALL
>  #endif
>  
>  /* i686 only supports ipc syscall before 5.1.  */
> diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
> index 6fb99f5c35..c751530cd3 100644
> --- a/sysdeps/unix/sysv/linux/kernel-features.h
> +++ b/sysdeps/unix/sysv/linux/kernel-features.h
> @@ -84,6 +84,7 @@
>  #define __ASSUME_SOCKETPAIR_SYSCALL	1
>  #define __ASSUME_LISTEN_SYSCALL		1
>  #define __ASSUME_GETSOCKNAME_SYSCALL	1
> +#define __ASSUME_GETPEERNAME_SYSCALL	1
>  
>  /* Support for SysV IPC through wired syscalls.  All supported architectures
>     either support ipc syscall and/or all the ipc correspondent syscalls.  */
> diff --git a/sysdeps/unix/sysv/linux/m68k/kernel-features.h b/sysdeps/unix/sysv/linux/m68k/kernel-features.h
> index 898c24ba62..a7b3458a21 100644
> --- a/sysdeps/unix/sysv/linux/m68k/kernel-features.h
> +++ b/sysdeps/unix/sysv/linux/m68k/kernel-features.h
> @@ -19,7 +19,6 @@
>  
>  /* Direct socketcalls available with kernel 4.3.  */
>  #if __LINUX_KERNEL_VERSION >= 0x040300
> -# define __ASSUME_GETPEERNAME_SYSCALL        1
>  # define __ASSUME_SHUTDOWN_SYSCALL           1
>  #endif
>  
> @@ -43,6 +42,7 @@
>  # undef __ASSUME_SOCKETPAIR_SYSCALL
>  # undef __ASSUME_LISTEN_SYSCALL
>  # undef __ASSUME_GETSOCKNAME_SYSCALL
> +# undef __ASSUME_GETPEERNAME_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 7e2b15859e..328529434d 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h
> +++ b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h
> @@ -19,7 +19,6 @@
>  
>  /* All supported kernel versions for MicroBlaze have these syscalls.  */
>  #define __ASSUME_CONNECT_SYSCALL	1
> -#define __ASSUME_GETPEERNAME_SYSCALL	1
>  #define __ASSUME_SEND_SYSCALL		1
>  #define __ASSUME_RECV_SYSCALL		1
>  #define __ASSUME_SHUTDOWN_SYSCALL	1
> diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
> index 8953cb019f..7fae7ca429 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
> @@ -19,7 +19,6 @@
>  
>  /* New syscalls added for PowerPC in 2.6.37.  */
>  #define __ASSUME_CONNECT_SYSCALL	1
> -#define __ASSUME_GETPEERNAME_SYSCALL	1
>  #define __ASSUME_SEND_SYSCALL		1
>  #define __ASSUME_RECV_SYSCALL		1
>  #define __ASSUME_SHUTDOWN_SYSCALL	1
> diff --git a/sysdeps/unix/sysv/linux/s390/kernel-features.h b/sysdeps/unix/sysv/linux/s390/kernel-features.h
> index 1422ee620c..e797b71052 100644
> --- a/sysdeps/unix/sysv/linux/s390/kernel-features.h
> +++ b/sysdeps/unix/sysv/linux/s390/kernel-features.h
> @@ -19,7 +19,6 @@
>  
>  /* Direct socketcalls available with kernel 4.3.  */
>  #if __LINUX_KERNEL_VERSION >= 0x040300
> -# define __ASSUME_GETPEERNAME_SYSCALL        1
>  # define __ASSUME_SHUTDOWN_SYSCALL           1
>  #endif
>  
> @@ -43,6 +42,7 @@
>  # undef __ASSUME_SOCKETPAIR_SYSCALL
>  # undef __ASSUME_LISTEN_SYSCALL
>  # undef __ASSUME_GETSOCKNAME_SYSCALL
> +# undef __ASSUME_GETPEERNAME_SYSCALL
>  #endif
>  
>  /* s390 only supports ipc syscall before 5.1.  */
> diff --git a/sysdeps/unix/sysv/linux/sh/kernel-features.h b/sysdeps/unix/sysv/linux/sh/kernel-features.h
> index 91dc28f33f..3a0b4e6198 100644
> --- a/sysdeps/unix/sysv/linux/sh/kernel-features.h
> +++ b/sysdeps/unix/sysv/linux/sh/kernel-features.h
> @@ -24,7 +24,6 @@
>  
>  /* These syscalls were added for SH in 2.6.37.  */
>  #define __ASSUME_CONNECT_SYSCALL	1
> -#define __ASSUME_GETPEERNAME_SYSCALL	1
>  #define __ASSUME_SEND_SYSCALL		1
>  #define __ASSUME_RECV_SYSCALL		1
>  #define __ASSUME_SHUTDOWN_SYSCALL	1

-- 
Cheers,
Carlos.



More information about the Libc-alpha mailing list