Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Split the COMPAT_50 socket-timeout stuff out of kern/uip...



details:   https://anonhg.NetBSD.org/src/rev/71967d9f2cf4
branches:  trunk
changeset: 455817:71967d9f2cf4
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Mon Apr 15 02:07:11 2019 +0000

description:
Split the COMPAT_50 socket-timeout stuff out of kern/uipc_socket.c
and into its own source file, which is now included in the compat_50
module.

(Not sure how this got missed during the original [pgoyette-compat] work)

diffstat:

 sys/compat/common/compat_50_mod.c       |    7 +-
 sys/compat/common/compat_mod.h          |    4 +-
 sys/compat/common/files.common          |    3 +-
 sys/compat/common/kern_uipc_socket_50.c |  233 ++++++++++++++++++++++++++++++++
 sys/kern/compat_stub.c                  |   11 +-
 sys/kern/uipc_socket.c                  |   83 +++-------
 sys/modules/compat_50/Makefile          |    3 +-
 sys/sys/compat_stub.h                   |   16 +-
 8 files changed, 297 insertions(+), 63 deletions(-)

diffs (truncated from 564 to 300 lines):

diff -r b11d58e4dd26 -r 71967d9f2cf4 sys/compat/common/compat_50_mod.c
--- a/sys/compat/common/compat_50_mod.c Sun Apr 14 22:09:50 2019 +0000
+++ b/sys/compat/common/compat_50_mod.c Mon Apr 15 02:07:11 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_50_mod.c,v 1.2 2019/01/27 02:08:39 pgoyette Exp $       */
+/*     $NetBSD: compat_50_mod.c,v 1.3 2019/04/15 02:07:11 pgoyette Exp $       */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_50_mod.c,v 1.2 2019/01/27 02:08:39 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_50_mod.c,v 1.3 2019/04/15 02:07:11 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -87,6 +87,7 @@
        vnd_50_init();
        rndpseudo_50_init();
        rtsock_50_init();
+       kern_uipc_socket_50_init();
 
        return error;
 
@@ -107,6 +108,7 @@
 {
        int error = 0;
 
+       kern_uipc_socket_50_fini();
        rtsock_50_fini();
        rndpseudo_50_fini();
        vnd_50_fini();
@@ -152,6 +154,7 @@
        vnd_50_init();
        rndpseudo_50_init();
        rtsock_50_init();
+       kern_uipc_socket_50_init();
 
        return error;
 }
diff -r b11d58e4dd26 -r 71967d9f2cf4 sys/compat/common/compat_mod.h
--- a/sys/compat/common/compat_mod.h    Sun Apr 14 22:09:50 2019 +0000
+++ b/sys/compat/common/compat_mod.h    Mon Apr 15 02:07:11 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_mod.h,v 1.3 2019/01/28 15:46:49 christos Exp $  */
+/*     $NetBSD: compat_mod.h,v 1.4 2019/04/15 02:07:11 pgoyette Exp $  */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -76,6 +76,8 @@
 void rndpseudo_50_fini(void);
 void rtsock_50_init(void);
 void rtsock_50_fini(void);
+void kern_uipc_socket_50_init(void);
+void kern_uipc_socket_50_fini(void);
 #endif
 
 #ifdef COMPAT_40
diff -r b11d58e4dd26 -r 71967d9f2cf4 sys/compat/common/files.common
--- a/sys/compat/common/files.common    Sun Apr 14 22:09:50 2019 +0000
+++ b/sys/compat/common/files.common    Mon Apr 15 02:07:11 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.common,v 1.2 2019/01/27 02:08:39 pgoyette Exp $
+#      $NetBSD: files.common,v 1.3 2019/04/15 02:07:11 pgoyette Exp $
 
 #
 # Generic utility files, used by various compat options.
@@ -85,6 +85,7 @@
 file   compat/common/clockctl_50.c             compat_50
 file   compat/common/if_spppsubr50.c           compat_50
 file   compat/common/uvm_50.c                  compat_50
+file   compat/common/kern_uipc_socket_50.c     compat_50
 
 # Compatibility code for NetBSD 6.0
 file   compat/common/compat_60_mod.c           compat_60
diff -r b11d58e4dd26 -r 71967d9f2cf4 sys/compat/common/kern_uipc_socket_50.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/kern_uipc_socket_50.c   Mon Apr 15 02:07:11 2019 +0000
@@ -0,0 +1,233 @@
+/*     $NetBSD: kern_uipc_socket_50.c,v 1.1 2019/04/15 02:07:11 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of Wasabi Systems, Inc, and by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 2004 The FreeBSD Foundation
+ * Copyright (c) 2004 Robert Watson
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)uipc_socket.c       8.6 (Berkeley) 5/2/95
+ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: Utah $Hdr: vn.c 1.13 94/04/02$
+ *
+ *     @(#)vn.c        8.9 (Berkeley) 5/14/95
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: kern_uipc_socket_50.c,v 1.1 2019/04/15 02:07:11 pgoyette Exp $");
+
+#if defined(_KERNEL_OPT)
+#include "opt_compat_netbsd.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/compat_stub.h>
+#include <sys/socketvar.h>
+
+#include <compat/sys/time.h>
+#include <compat/sys/socket.h>
+
+#include <compat/common/compat_mod.h>
+
+static int
+uipc_socket_50_getopt1(int opt, struct socket *so, struct sockopt *sopt,
+    struct timeval *tv)
+{
+       int optval, error;
+       struct timeval50 otv;
+
+       switch (opt) {
+
+       case SO_OSNDTIMEO:
+       case SO_ORCVTIMEO:
+               optval = (opt == SO_OSNDTIMEO ?
+                   so->so_snd.sb_timeo : so->so_rcv.sb_timeo);
+
+               otv.tv_sec = optval / hz;
+               otv.tv_usec = (optval % hz) * tick;
+
+               error = sockopt_set(sopt, &otv, sizeof(otv));
+               break;
+
+       case SO_OTIMESTAMP:
+               error = sockopt_setint(sopt, (so->so_options & opt) ? 1 : 0);
+               break;
+
+       default:
+               error = EPASSTHROUGH;
+       }
+       return error;
+}
+
+static int
+uipc_socket_50_setopt1(int opt, struct socket *so, const struct sockopt *sopt,
+    struct timeval *tv)
+{
+       int optval, error;
+       struct timeval50 otv;
+
+       switch (opt) {
+
+       case SO_OSNDTIMEO:
+       case SO_ORCVTIMEO:
+               error = sockopt_get(sopt, &otv, sizeof(otv));
+               if (error) {
+                       solock(so);
+                       break;
+               }
+               timeval50_to_timeval(&otv, tv);
+               opt = opt == SO_OSNDTIMEO ? SO_SNDTIMEO : SO_RCVTIMEO;
+               /*
+                * Processing will continue as for SO_SNDTIMEO
+                * and SO_RCVTIMEO, using the new-format tv
+                */
+               break;
+
+       case SO_OTIMESTAMP:
+               error = sockopt_getint(sopt, &optval);
+               solock(so);
+               if (error)
+                       break;
+               if (optval)
+                       so->so_options |= opt;
+               else
+                       so->so_options &= ~opt;
+               break;
+
+       default:
+               error = EPASSTHROUGH;
+       }
+       return error;
+}
+
+static int
+uipc_socket_50_sbts(int opt, struct mbuf **mp)
+{
+       struct timeval50 tv50;
+       struct timeval tv;
+
+       microtime(&tv);
+
+       if (opt & SO_OTIMESTAMP) {
+
+               timeval_to_timeval50(&tv, &tv50);
+               *mp = sbcreatecontrol(&tv50, sizeof(tv50), SCM_OTIMESTAMP,
+                   SOL_SOCKET);
+               if (*mp)
+                       mp = &(*mp)->m_next;
+               return 0;
+       } else
+               return EPASSTHROUGH;
+}
+
+void
+kern_uipc_socket_50_init(void)
+{
+
+       MODULE_HOOK_SET(uipc_socket_50_setopt1_hook, "sockop_50",
+           uipc_socket_50_setopt1);



Home | Main Index | Thread Index | Old Index