git: cf312f799a86 - main - linux(4): Handle SO_DOMAIN in getsockopt syscall.

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Mon, 11 Apr 2022 20:32:51 UTC
The branch main has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=cf312f799a867b4b1beef0536a162062659659a6

commit cf312f799a867b4b1beef0536a162062659659a6
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2022-04-11 20:31:28 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-04-11 20:31:28 +0000

    linux(4): Handle SO_DOMAIN in getsockopt syscall.
    
    Differential revision:  https://reviews.freebsd.org/D34714
---
 sys/compat/linux/linux_socket.c | 13 +++++++++++++
 sys/compat/linux/linux_socket.h |  1 +
 2 files changed, 14 insertions(+)

diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index 935d07ecb7e0..4ba023daaba2 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -553,6 +553,8 @@ linux_to_bsd_so_sockopt(int opt)
 		return (SO_ACCEPTCONN);
 	case LINUX_SO_PROTOCOL:
 		return (SO_PROTOCOL);
+	case LINUX_SO_DOMAIN:
+		return (SO_DOMAIN);
 	}
 	return (-1);
 }
@@ -2008,6 +2010,17 @@ linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args)
 			newval = -bsd_to_linux_errno(newval);
 			return (copyout(&newval, PTRIN(args->optval), len));
 			/* NOTREACHED */
+		case SO_DOMAIN:
+			len = sizeof(newval);
+			error = kern_getsockopt(td, args->s, level,
+			    name, &newval, UIO_SYSSPACE, &len);
+			if (error != 0)
+				return (error);
+			newval = bsd_to_linux_domain(newval);
+			if (newval == -1)
+				return (ENOPROTOOPT);
+			return (copyout(&newval, PTRIN(args->optval), len));
+			/* NOTREACHED */
 		default:
 			break;
 		}
diff --git a/sys/compat/linux/linux_socket.h b/sys/compat/linux/linux_socket.h
index 9c37d8c97c3d..4decb24236bb 100644
--- a/sys/compat/linux/linux_socket.h
+++ b/sys/compat/linux/linux_socket.h
@@ -199,6 +199,7 @@ int linux_accept(struct thread *td, struct linux_accept_args *args);
 #define	LINUX_SO_SNDBUFFORCE	32
 #define	LINUX_SO_RCVBUFFORCE	33
 #define	LINUX_SO_PROTOCOL	38
+#define	LINUX_SO_DOMAIN		39
 #define	LINUX_SO_PEERGROUPS	59
 
 /* Socket options */