svn commit: r247559 - in stable/8/sys: amd64/linux32 compat/linux i386/linux

John Baldwin jhb at FreeBSD.org
Fri Mar 1 18:39:56 UTC 2013


Author: jhb
Date: Fri Mar  1 18:39:55 2013
New Revision: 247559
URL: http://svnweb.freebsd.org/changeset/base/247559

Log:
  MFC 245849:
  Don't assume that all Linux TCP-level socket options are identical to
  FreeBSD TCP-level socket options (only the first two are).  Instead,
  using a mapping function and fail unsupported options as we do for other
  socket option levels.

Modified:
  stable/8/sys/amd64/linux32/linux.h
  stable/8/sys/compat/linux/linux_socket.c
  stable/8/sys/i386/linux/linux.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/   (props changed)
  stable/8/sys/compat/   (props changed)
  stable/8/sys/i386/   (props changed)

Modified: stable/8/sys/amd64/linux32/linux.h
==============================================================================
--- stable/8/sys/amd64/linux32/linux.h	Fri Mar  1 18:39:46 2013	(r247558)
+++ stable/8/sys/amd64/linux32/linux.h	Fri Mar  1 18:39:55 2013	(r247559)
@@ -721,6 +721,13 @@ union l_semun {
 #define	LINUX_IP_ADD_MEMBERSHIP		35
 #define	LINUX_IP_DROP_MEMBERSHIP	36
 
+#define	LINUX_TCP_NODELAY	1
+#define	LINUX_TCP_MAXSEG	2
+#define	LINUX_TCP_KEEPIDLE	4
+#define	LINUX_TCP_KEEPINTVL	5
+#define	LINUX_TCP_KEEPCNT	6
+#define	LINUX_TCP_MD5SIG	14
+
 struct l_sockaddr {
 	l_ushort	sa_family;
 	char		sa_data[14];

Modified: stable/8/sys/compat/linux/linux_socket.c
==============================================================================
--- stable/8/sys/compat/linux/linux_socket.c	Fri Mar  1 18:39:46 2013	(r247558)
+++ stable/8/sys/compat/linux/linux_socket.c	Fri Mar  1 18:39:55 2013	(r247559)
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
+#include <netinet/tcp.h>
 #ifdef INET6
 #include <netinet/ip6.h>
 #include <netinet6/ip6_var.h>
@@ -334,6 +335,21 @@ linux_to_bsd_so_sockopt(int opt)
 }
 
 static int
+linux_to_bsd_tcp_sockopt(int opt)
+{
+
+	switch (opt) {
+	case LINUX_TCP_NODELAY:
+		return (TCP_NODELAY);
+	case LINUX_TCP_MAXSEG:
+		return (TCP_MAXSEG);
+	case LINUX_TCP_MD5SIG:
+		return (TCP_MD5SIG);
+	}
+	return (-1);
+}
+
+static int
 linux_to_bsd_msg_flags(int flags)
 {
 	int ret_flags = 0;
@@ -1504,8 +1520,7 @@ linux_setsockopt(struct thread *td, stru
 		name = linux_to_bsd_ip_sockopt(args->optname);
 		break;
 	case IPPROTO_TCP:
-		/* Linux TCP option values match BSD's */
-		name = args->optname;
+		name = linux_to_bsd_tcp_sockopt(args->optname);
 		break;
 	default:
 		name = -1;
@@ -1599,8 +1614,7 @@ linux_getsockopt(struct thread *td, stru
 		name = linux_to_bsd_ip_sockopt(args->optname);
 		break;
 	case IPPROTO_TCP:
-		/* Linux TCP option values match BSD's */
-		name = args->optname;
+		name = linux_to_bsd_tcp_sockopt(args->optname);
 		break;
 	default:
 		name = -1;

Modified: stable/8/sys/i386/linux/linux.h
==============================================================================
--- stable/8/sys/i386/linux/linux.h	Fri Mar  1 18:39:46 2013	(r247558)
+++ stable/8/sys/i386/linux/linux.h	Fri Mar  1 18:39:55 2013	(r247559)
@@ -697,6 +697,13 @@ union l_semun {
 #define	LINUX_IP_ADD_MEMBERSHIP		35
 #define	LINUX_IP_DROP_MEMBERSHIP	36
 
+#define	LINUX_TCP_NODELAY	1
+#define	LINUX_TCP_MAXSEG	2
+#define	LINUX_TCP_KEEPIDLE	4
+#define	LINUX_TCP_KEEPINTVL	5
+#define	LINUX_TCP_KEEPCNT	6
+#define	LINUX_TCP_MD5SIG	14
+
 struct l_sockaddr {
 	l_ushort	sa_family;
 	char		sa_data[14];


More information about the svn-src-stable-8 mailing list