Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys Add the required hooks for rtsock_50 and modif...



details:   https://anonhg.NetBSD.org/src/rev/701c6cc59253
branches:  pgoyette-compat
changeset: 830896:701c6cc59253
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sun Jan 13 23:32:21 2019 +0000

description:
Add the required hooks for rtsock_50 and modify the COMPATCALL() macro
to use the hooks.  While the rtsock_50 situation is still sub-optimal
(it includes the main rtsock.c with a whole bunch of function and
variable redefinitions via macros), this at least makes it possible to
load the rtsock_50 code separately from more recent code, rather than
the previous requirement that rtsock_50 be built-in.

diffstat:

 sys/compat/common/rtsock_50.c |   55 +++++++++--
 sys/compat/net/if.h           |    4 +-
 sys/compat/net/route.h        |   12 +-
 sys/kern/compat_stub.c        |   10 +-
 sys/net/route.h               |   12 +-
 sys/net/rtsock.c              |  190 ++++++++++++++++++++++++++---------------
 sys/sys/compat_stub.h         |   17 +++-
 7 files changed, 200 insertions(+), 100 deletions(-)

diffs (truncated from 601 to 300 lines):

diff -r e396aeee9b11 -r 701c6cc59253 sys/compat/common/rtsock_50.c
--- a/sys/compat/common/rtsock_50.c     Sun Jan 13 10:49:49 2019 +0000
+++ b/sys/compat/common/rtsock_50.c     Sun Jan 13 23:32:21 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtsock_50.c,v 1.6.2.2 2019/01/11 06:27:45 pgoyette Exp $       */
+/*     $NetBSD: rtsock_50.c,v 1.6.2.3 2019/01/13 23:32:21 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.2 2019/01/11 06:27:45 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock_50.c,v 1.6.2.3 2019/01/13 23:32:21 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -80,7 +80,7 @@
 #include <net/rtsock.c>
 #include <compat/net/route_50.h>
 
-void
+int
 compat_50_rt_oifmsg(struct ifnet *ifp)
 {
        struct if_msghdr50 oifm;
@@ -88,7 +88,7 @@
        struct rt_addrinfo info;
 
        if (COMPATNAME(route_info).ri_cb.any_count == 0)
-               return;
+               return 0;
        (void)memset(&info, 0, sizeof(info));
        (void)memset(&oifm, 0, sizeof(oifm));
        oifm.ifm_index = ifp->if_index;
@@ -116,8 +116,10 @@
        oifm.ifm_addrs = 0;
        m = COMPATNAME(rt_msg1)(RTM_OIFINFO, &info, (void *)&oifm, sizeof(oifm));
        if (m == NULL)
-               return;
+               return 0;
        COMPATNAME(route_enqueue)(m, 0);
+
+       return 0;
 }
 
 int
@@ -158,19 +160,52 @@
        return 0;
 }
 
-MODULE_SET_HOOK(rtsock_50_hook, "rts_50", compat_50_iflist);
-MODULE_UNSET_HOOK(rtsock_50_hook); 
- 
+MODULE_SET_HOOK(rtsock_50_iflist_hook, "rts_50", compat_50_iflist);
+MODULE_UNSET_HOOK(rtsock_50_iflist_hook); 
+
+MODULE_SET_HOOK(rtsock_50_oifmsg_hook, "rts_50", compat_50_rt_oifmsg);
+MODULE_UNSET_HOOK(rtsock_50_oifmsg_hook); 
+
+MODULE_SET_HOOK(rtsock_50_rt_missmsg_hook, "rts_50", compat_50_rt_missmsg);
+MODULE_UNSET_HOOK(rtsock_50_rt_missmsg_hook); 
+
+MODULE_SET_HOOK(rtsock_50_rt_ifmsg_hook, "rts_50", compat_50_rt_ifmsg);
+MODULE_UNSET_HOOK(rtsock_50_rt_ifmsg_hook); 
+
+MODULE_SET_HOOK(rtsock_50_rt_newaddrmsg_hook, "rts_50",
+    compat_50_rt_newaddrmsg);
+MODULE_UNSET_HOOK(rtsock_50_rt_newaddrmsg_hook); 
+
+MODULE_SET_HOOK(rtsock_50_rt_ifannouncemsg_hook, "rts_50",
+    compat_50_rt_ifannouncemsg);
+MODULE_UNSET_HOOK(rtsock_50_rt_ifannouncemsg_hook); 
+
+MODULE_SET_HOOK(rtsock_50_rt_ieee80211msg_hook, "rts_50",
+    compat_50_rt_ieee80211msg);
+MODULE_UNSET_HOOK(rtsock_50_rt_ieee80211msg_hook); 
+
 void
 rtsock_50_init(void)
 {
  
-       rtsock_50_hook_set();
+       rtsock_50_iflist_hook_set();
+       rtsock_50_oifmsg_hook_set();
+       rtsock_50_rt_missmsg_hook_set();
+       rtsock_50_rt_ifmsg_hook_set();
+       rtsock_50_rt_newaddrmsg_hook_set();
+       rtsock_50_rt_ifannouncemsg_hook_set();
+       rtsock_50_rt_ieee80211msg_hook_set();
 }
  
 void
 rtsock_50_fini(void)
 {  
 
-       rtsock_50_hook_unset();
+       rtsock_50_iflist_hook_unset();
+       rtsock_50_oifmsg_hook_unset();
+       rtsock_50_rt_missmsg_hook_unset();
+       rtsock_50_rt_ifmsg_hook_unset();
+       rtsock_50_rt_newaddrmsg_hook_unset();
+       rtsock_50_rt_ifannouncemsg_hook_unset();
+       rtsock_50_rt_ieee80211msg_hook_unset();
 }
diff -r e396aeee9b11 -r 701c6cc59253 sys/compat/net/if.h
--- a/sys/compat/net/if.h       Sun Jan 13 10:49:49 2019 +0000
+++ b/sys/compat/net/if.h       Sun Jan 13 23:32:21 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.h,v 1.4.14.1 2018/09/17 11:04:30 pgoyette Exp $     */
+/*     $NetBSD: if.h,v 1.4.14.2 2019/01/13 23:32:21 pgoyette Exp $     */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -153,7 +153,7 @@
        struct  if_data50 ifm_data;/* statistics and other data about if */
 };
 
-void compat_50_rt_oifmsg(struct ifnet *);
+int compat_50_rt_oifmsg(struct ifnet *);
 int compat_50_iflist(struct ifnet *, struct rt_walkarg *, struct rt_addrinfo *,
     size_t);
 
diff -r e396aeee9b11 -r 701c6cc59253 sys/compat/net/route.h
--- a/sys/compat/net/route.h    Sun Jan 13 10:49:49 2019 +0000
+++ b/sys/compat/net/route.h    Sun Jan 13 23:32:21 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route.h,v 1.2.14.1 2018/10/15 04:33:34 pgoyette Exp $  */
+/*     $NetBSD: route.h,v 1.2.14.2 2019/01/13 23:32:21 pgoyette Exp $  */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -81,13 +81,13 @@
 #ifdef _KERNEL
 extern struct route_info compat_50_route_info;
 void   compat_50_route_enqueue(struct mbuf *, int);
-void   compat_50_rt_ifannouncemsg(struct ifnet *, int);
-void   compat_50_rt_ieee80211msg(struct ifnet *, int, void *, size_t);
-void   compat_50_rt_ifmsg(struct ifnet *);
-void   compat_50_rt_missmsg(int, const struct rt_addrinfo *, int, int);
+int    compat_50_rt_ifannouncemsg(struct ifnet *, int);
+int    compat_50_rt_ieee80211msg(struct ifnet *, int, void *, size_t);
+int    compat_50_rt_ifmsg(struct ifnet *);
+int    compat_50_rt_missmsg(int, const struct rt_addrinfo *, int, int);
 struct mbuf *
        compat_50_rt_msg1(int, struct rt_addrinfo *, void *, int);
-void   compat_50_rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *);
+int    compat_50_rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *);
 int    compat_70_rt_newaddrmsg1(int, struct ifaddr *);
 #endif
 
diff -r e396aeee9b11 -r 701c6cc59253 sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c    Sun Jan 13 10:49:49 2019 +0000
+++ b/sys/kern/compat_stub.c    Sun Jan 13 23:32:21 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.1.2.34 2019/01/13 10:49:50 pgoyette Exp $        */
+/* $NetBSD: compat_stub.c,v 1.1.2.35 2019/01/13 23:32:21 pgoyette Exp $        */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -165,7 +165,13 @@
 /*
  * rtsock 50 compatability
  */
-struct rtsock_50_hook_t rtsock_50_hook;
+struct rtsock_50_iflist_hook_t rtsock_50_iflist_hook;
+struct rtsock_50_oifmsg_hook_t rtsock_50_oifmsg_hook;
+struct rtsock_50_rt_missmsg_hook_t rtsock_50_rt_missmsg_hook;
+struct rtsock_50_rt_ifmsg_hook_t rtsock_50_rt_ifmsg_hook;
+struct rtsock_50_rt_ifannouncemsg_hook_t rtsock_50_rt_ifannouncemsg_hook;
+struct rtsock_50_rt_newaddrmsg_hook_t rtsock_50_rt_newaddrmsg_hook;
+struct rtsock_50_rt_ieee80211msg_hook_t rtsock_50_rt_ieee80211msg_hook;
 
 /*
  * rtsock 70 compatability
diff -r e396aeee9b11 -r 701c6cc59253 sys/net/route.h
--- a/sys/net/route.h   Sun Jan 13 10:49:49 2019 +0000
+++ b/sys/net/route.h   Sun Jan 13 23:32:21 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route.h,v 1.117.2.3 2018/11/26 01:52:50 pgoyette Exp $ */
+/*     $NetBSD: route.h,v 1.117.2.4 2019/01/13 23:32:22 pgoyette Exp $ */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -508,14 +508,14 @@
 void   rtcache_unref(struct rtentry *, struct route *);
 
 /* rtsock */
-void   rt_ieee80211msg(struct ifnet *, int, void *, size_t);
-void   rt_ifannouncemsg(struct ifnet *, int);
-void   rt_ifmsg(struct ifnet *);
-void   rt_missmsg(int, const struct rt_addrinfo *, int, int);
+int    rt_ieee80211msg(struct ifnet *, int, void *, size_t);
+int    rt_ifannouncemsg(struct ifnet *, int);
+int    rt_ifmsg(struct ifnet *);
+int    rt_missmsg(int, const struct rt_addrinfo *, int, int);
 struct mbuf *
        rt_msg1(int, struct rt_addrinfo *, void *, int);
 int    rt_msg3(int, struct rt_addrinfo *, void *, struct rt_walkarg *, int *);
-void   rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *);
+int    rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *);
 void   route_enqueue(struct mbuf *, int);
 
 struct llentry;
diff -r e396aeee9b11 -r 701c6cc59253 sys/net/rtsock.c
--- a/sys/net/rtsock.c  Sun Jan 13 10:49:49 2019 +0000
+++ b/sys/net/rtsock.c  Sun Jan 13 23:32:21 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtsock.c,v 1.238.2.17 2019/01/13 10:49:51 pgoyette Exp $       */
+/*     $NetBSD: rtsock.c,v 1.238.2.18 2019/01/13 23:32:22 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.17 2019/01/13 10:49:51 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.238.2.18 2019/01/13 23:32:22 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -120,7 +120,6 @@
 #define        DOMAINNAME      "oroute"
 CTASSERT(sizeof(struct ifa_xmsghdr) == 20);
 DOMAIN_DEFINE(compat_50_routedomain); /* forward declare and add to link set */
-#undef COMPAT_70
 #else /* COMPAT_RTSOCK */
 #define        RTM_XVERSION    RTM_VERSION
 #define        RTM_XNEWADDR    RTM_NEWADDR
@@ -137,11 +136,10 @@
 #define        DOMAINNAME      "route"
 CTASSERT(sizeof(struct ifa_xmsghdr) == 32);
 #ifdef COMPAT_50
-#define        COMPATCALL(name, args)  compat_50_ ## name args
+#define        COMPATCALL(name, args)  rtsock_50_ ## name ## _hook_call args
 #endif
 DOMAIN_DEFINE(routedomain); /* forward declare and add to link set */
 #undef COMPAT_50
-#undef COMPAT_14
 #endif /* COMPAT_RTSOCK */
 
 #ifndef COMPATCALL
@@ -1145,37 +1143,41 @@
        case RTM_ODELADDR:
        case RTM_ONEWADDR:
        case RTM_OCHGADDR:
-#ifdef COMPAT_70
-               return sizeof(struct ifa_msghdr70);
-#else
+               if (rtsock_70_iflist_hook.hooked)
+                       return sizeof(struct ifa_msghdr70);
+               else {
 #ifdef RTSOCK_DEBUG
-               printf("%s: unsupported RTM type %d\n", __func__, type);
+                       printf("%s: unsupported RTM type %d\n", __func__, type);
 #endif
-               return -1;
-#endif
+                       return -1;
+               }
+
        case RTM_DELADDR:
        case RTM_NEWADDR:
        case RTM_CHGADDR:
                return sizeof(struct ifa_xmsghdr);
 
        case RTM_OOIFINFO:
-#ifdef COMPAT_14
-               return sizeof(struct if_msghdr14);
-#else
+               if (rtsock_14_iflist_hook.hooked)
+                       return sizeof(struct if_msghdr14);
+               else {
 #ifdef RTSOCK_DEBUG
-               printf("%s: unsupported RTM type RTM_OOIFINFO\n", __func__);
+                       printf("%s: unsupported RTM type RTM_OOIFINFO\n",
+                           __func__);
 #endif
-               return -1;
-#endif
+                       return -1;
+               }
+
        case RTM_OIFINFO:
-#ifdef COMPAT_50
-               return sizeof(struct if_msghdr50);
-#else
+               if (rtsock_50_iflist_hook.hooked)
+                       return sizeof(struct if_msghdr50);
+               else {
 #ifdef RTSOCK_DEBUG
-               printf("%s: unsupported RTM type RTM_OIFINFO\n", __func__);
+                       printf("%s: unsupported RTM type RTM_OIFINFO\n",
+                           __func__);
 #endif
-               return -1;
-#endif
+                       return -1;



Home | Main Index | Thread Index | Old Index