Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys Rework the various sysctl-related routines to ...



details:   https://anonhg.NetBSD.org/src/rev/e2188f8005b3
branches:  pgoyette-compat
changeset: 447440:e2188f8005b3
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Fri Jan 11 06:27:45 2019 +0000

description:
Rework the various sysctl-related routines to call the correct code
for each version.  While here, extract the 5.0 specific code instead
of including in the main rtsock.c code.

Also, clean up all the sysctl-related routines to prevent building
more than one copy, no matter how many places rtsock.c gets #include'd
into!

diffstat:

 sys/compat/common/compat_50_mod.c |    7 +-
 sys/compat/common/compat_mod.h    |    4 +-
 sys/compat/common/rtsock_50.c     |   22 +++++++-
 sys/compat/net/route_50.h         |   42 +++++++++++++++
 sys/kern/compat_stub.c            |    7 ++-
 sys/net/rtsock.c                  |  106 ++++++++++++++++++++++---------------
 sys/sys/compat_stub.h             |   10 ++-
 7 files changed, 146 insertions(+), 52 deletions(-)

diffs (truncated from 452 to 300 lines):

diff -r 8b29795cd36d -r e2188f8005b3 sys/compat/common/compat_50_mod.c
--- a/sys/compat/common/compat_50_mod.c Fri Jan 11 06:18:17 2019 +0000
+++ b/sys/compat/common/compat_50_mod.c Fri Jan 11 06:27:45 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_50_mod.c,v 1.1.2.17 2018/10/12 22:30:54 pgoyette Exp $  */
+/*     $NetBSD: compat_50_mod.c,v 1.1.2.18 2019/01/11 06:27:45 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.1.2.17 2018/10/12 22:30:54 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_50_mod.c,v 1.1.2.18 2019/01/11 06:27:45 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -86,6 +86,7 @@
        wsevent_50_init();
        vnd_50_init();
        rndpseudo_50_init();
+       rtsock_50_init();
 
        return error;
 
@@ -106,6 +107,7 @@
 {
        int error = 0;
 
+       rtsock_50_fini();
        rndpseudo_50_fini();
        vnd_50_fini();
        wsevent_50_fini();
@@ -149,6 +151,7 @@
        wsevent_50_init();
        vnd_50_init();
        rndpseudo_50_init();
+       rtsock_50_init();
 
        return error;
 }
diff -r 8b29795cd36d -r e2188f8005b3 sys/compat/common/compat_mod.h
--- a/sys/compat/common/compat_mod.h    Fri Jan 11 06:18:17 2019 +0000
+++ b/sys/compat/common/compat_mod.h    Fri Jan 11 06:27:45 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_mod.h,v 1.1.42.23 2018/10/12 22:30:54 pgoyette Exp $    */
+/*     $NetBSD: compat_mod.h,v 1.1.42.24 2019/01/11 06:27:45 pgoyette Exp $    */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -74,6 +74,8 @@
 void vnd_50_fini(void);
 void rndpseudo_50_init(void);
 void rndpseudo_50_fini(void);
+void rtsock_50_init(void);
+void rtsock_50_fini(void);
 #endif
 
 #ifdef COMPAT_40
diff -r 8b29795cd36d -r e2188f8005b3 sys/compat/common/rtsock_50.c
--- a/sys/compat/common/rtsock_50.c     Fri Jan 11 06:18:17 2019 +0000
+++ b/sys/compat/common/rtsock_50.c     Fri Jan 11 06:27:45 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtsock_50.c,v 1.6.2.1 2018/05/21 04:36:03 pgoyette Exp $       */
+/*     $NetBSD: rtsock_50.c,v 1.6.2.2 2019/01/11 06:27:45 pgoyette Exp $       */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock_50.c,v 1.6.2.1 2018/05/21 04:36:03 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock_50.c,v 1.6.2.2 2019/01/11 06:27:45 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -78,6 +78,7 @@
 #define        COMPAT_RTSOCK
 
 #include <net/rtsock.c>
+#include <compat/net/route_50.h>
 
 void
 compat_50_rt_oifmsg(struct ifnet *ifp)
@@ -156,3 +157,20 @@
        w->w_where = (char *)w->w_where + len;
        return 0;
 }
+
+MODULE_SET_HOOK(rtsock_50_hook, "rts_50", compat_50_iflist);
+MODULE_UNSET_HOOK(rtsock_50_hook); 
+ 
+void
+rtsock_50_init(void)
+{
+ 
+       rtsock_50_hook_set();
+}
+ 
+void
+rtsock_50_fini(void)
+{  
+
+       rtsock_50_hook_unset();
+}
diff -r 8b29795cd36d -r e2188f8005b3 sys/compat/net/route_50.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/net/route_50.h Fri Jan 11 06:27:45 2019 +0000
@@ -0,0 +1,42 @@
+/*     $NetBSD: route_50.h,v 1.1.2.1 2019/01/11 06:27:45 pgoyette Exp $        */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Paul Goyette
+ *
+ * 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.
+ */
+
+#ifndef _COMPAT_NET_ROUTE_50_H_
+#define _COMPAT_NET_ROUTE_50_H_
+
+#include <net/route.h>
+
+/* compat interfaces */
+
+void rtsock_50_init(void);
+void rtsock_50_fini(void);
+
+#endif /* !_COMPAT_NET_ROUTE_70_H_ */
diff -r 8b29795cd36d -r e2188f8005b3 sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c    Fri Jan 11 06:18:17 2019 +0000
+++ b/sys/kern/compat_stub.c    Fri Jan 11 06:27:45 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.1.2.32 2018/10/15 22:06:16 pgoyette Exp $        */
+/* $NetBSD: compat_stub.c,v 1.1.2.33 2019/01/11 06:27:45 pgoyette Exp $        */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -157,6 +157,11 @@
 struct rtsock14_hook_t rtsock14_hook;
 
 /*
+ * rtsock 50 compatability
+ */
+struct rtsock_50_hook_t rtsock_50_hook;
+
+/*
  * rtsock 70 compatability
  */
 struct rtsock_70_hook_t rtsock_70_hook;
diff -r 8b29795cd36d -r e2188f8005b3 sys/net/rtsock.c
--- a/sys/net/rtsock.c  Fri Jan 11 06:18:17 2019 +0000
+++ b/sys/net/rtsock.c  Fri Jan 11 06:27:45 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtsock.c,v 1.238.2.13 2018/11/26 01:52:50 pgoyette Exp $       */
+/*     $NetBSD: rtsock.c,v 1.238.2.14 2019/01/11 06:27:45 pgoyette Exp $       */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.238.2.13 2018/11/26 01:52:50 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.238.2.14 2019/01/11 06:27:45 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -168,11 +168,11 @@
 static int rt_msg2(int, struct rt_addrinfo *, void *, struct rt_walkarg *, int *);
 static void _rt_setmetrics(int, const struct rt_xmsghdr *, struct rtentry *);
 static void rtm_setmetrics(const struct rtentry *, struct rt_xmsghdr *);
+static void rt_adjustcount(int, int);
+
+#ifndef COMPAT_RTSOCK
 static void sysctl_net_route_setup(struct sysctllog **);
-static int sysctl_dumpentry(struct rtentry *, void *);
-static int sysctl_iflist(int, struct rt_walkarg *, int);
-static int sysctl_rtable(SYSCTLFN_PROTO);
-static void rt_adjustcount(int, int);
+#endif
 
 static const struct protosw COMPATNAME(route_protosw)[];
 
@@ -192,9 +192,6 @@
 #endif
 
 #ifndef COMPAT_RTSOCK
-static int
-sysctl_iflist_addr(struct rt_walkarg *, struct ifaddr *, struct rt_addrinfo *);
-
 /*
  * Compat linkage
  */
@@ -1391,7 +1388,23 @@
 #endif
 
 /*
- * MODULE_HOOK glue for rtsock70_ifaddr_list and rtsock70_newaddrmsg1
+ * MODULE_HOOK glue for rtsock50_ifaddr_listif
+ */
+MODULE_CALL_HOOK_DECL(rtsock_50_hook, f,
+    (struct ifnet *ifp, struct rt_walkarg *w, struct rt_addrinfo *info, 
+     size_t len));
+#ifndef COMPAT_RTSOCK 
+MODULE_CALL_HOOK(rtsock_50_hook, f, 
+    (struct ifnet *ifp, struct rt_walkarg *w, struct rt_addrinfo *info,
+     size_t len),               
+    (ifp, w, info, len),
+    enosys());
+#endif
+
+
+/*
+ * MODULE_HOOK glue for rtsock70_newaddrmsg1, rtsock70_ifaddr_listaddr,
+ * and rtsock70_ifaddr_listif
  */
 MODULE_CALL_HOOK_DECL(rtsock_70_hook, f1, (int, struct ifaddr *));
 #ifndef COMPAT_RTSOCK
@@ -1405,7 +1418,7 @@
 MODULE_CALL_HOOK(rtsock_70_hook, f2,
     (struct rt_walkarg *w, struct ifaddr *ifa, struct rt_addrinfo *info),
     (w, ifa, info), 
-    sysctl_iflist_addr(w, ifa, info));
+    enosys());
 #endif
 
 /*
@@ -1684,7 +1697,6 @@
 #undef RTF_LLINFO
 #undef RTF_CLONED
 }
-#endif /* COMPAT_RTSOCK */
 
 /*
  * This is used in dumping the kernel table via sysctl().
@@ -1752,7 +1764,6 @@
        return error;
 }
 
-#ifndef COMPAT_RTSOCK  /* XXX need to include the stuff in COMPAT_50 */
 static int
 sysctl_iflist_addr(struct rt_walkarg *w, struct ifaddr *ifa,
      struct rt_addrinfo *info)
@@ -1769,16 +1780,13 @@
                ifam->ifam_flags = ifa->ifa_flags;
                ifam->ifam_metric = ifa->ifa_metric;
                ifam->ifam_addrs = info->rti_addrs;
-#ifndef COMPAT_RTSOCK
                ifam->ifam_pid = 0;
                ifam->ifam_addrflags = if_addrflags(ifa);
-#endif
                if ((error = copyout(w->w_tmem, w->w_where, len)) == 0)
                        w->w_where = (char *)w->w_where + len;
        }
        return error;
 }
-#endif /* XXX */
 
 static int
 sysctl_iflist(int af, struct rt_walkarg *w, int type)
@@ -1787,8 +1795,6 @@
        struct ifaddr *ifa;
        struct  rt_addrinfo info;
        int     cmd, len, error = 0;
-       int     (*iflist_if)(struct ifnet *, struct rt_walkarg *,
-                            struct rt_addrinfo *, size_t);
        int s;
        struct psref psref;
        int bound;
@@ -1796,24 +1802,16 @@
        switch (type) {
        case NET_RT_IFLIST:
                cmd = RTM_IFINFO;
-               iflist_if = sysctl_iflist_if;
                break;



Home | Main Index | Thread Index | Old Index