Wed Jan 29 05:47:12 2020 UTC ()
Don't reference ifp->if_data directly; use if_export_if_data().


(thorpej)
diff -r1.9 -r1.10 src/sys/compat/common/rtsock_14.c
diff -r1.15 -r1.16 src/sys/compat/common/rtsock_50.c

cvs diff -r1.9 -r1.10 src/sys/compat/common/rtsock_14.c (expand / switch to unified diff)

--- src/sys/compat/common/rtsock_14.c 2019/12/12 02:15:42 1.9
+++ src/sys/compat/common/rtsock_14.c 2020/01/29 05:47:12 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rtsock_14.c,v 1.9 2019/12/12 02:15:42 pgoyette Exp $ */ 1/* $NetBSD: rtsock_14.c,v 1.10 2020/01/29 05:47:12 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -51,27 +51,27 @@ @@ -51,27 +51,27 @@
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE. 58 * SUCH DAMAGE.
59 * 59 *
60 * @(#)rtsock.c 8.7 (Berkeley) 10/12/95 60 * @(#)rtsock.c 8.7 (Berkeley) 10/12/95
61 */ 61 */
62 62
63#include <sys/cdefs.h> 63#include <sys/cdefs.h>
64__KERNEL_RCSID(0, "$NetBSD: rtsock_14.c,v 1.9 2019/12/12 02:15:42 pgoyette Exp $"); 64__KERNEL_RCSID(0, "$NetBSD: rtsock_14.c,v 1.10 2020/01/29 05:47:12 thorpej Exp $");
65 65
66#if defined(_KERNEL_OPT) 66#if defined(_KERNEL_OPT)
67#include "opt_compat_netbsd.h" 67#include "opt_compat_netbsd.h"
68#endif 68#endif
69 69
70#ifdef _KERNEL_OPT 70#ifdef _KERNEL_OPT
71#include "opt_inet.h" 71#include "opt_inet.h"
72#endif 72#endif
73 73
74#include <sys/param.h> 74#include <sys/param.h>
75#include <sys/systm.h> 75#include <sys/systm.h>
76#include <sys/proc.h> 76#include <sys/proc.h>
77#include <sys/mbuf.h> 77#include <sys/mbuf.h>
@@ -89,91 +89,95 @@ __KERNEL_RCSID(0, "$NetBSD: rtsock_14.c, @@ -89,91 +89,95 @@ __KERNEL_RCSID(0, "$NetBSD: rtsock_14.c,
89#include <net/if.h> 89#include <net/if.h>
90#include <net/route.h> 90#include <net/route.h>
91#include <net/raw_cb.h> 91#include <net/raw_cb.h>
92 92
93#include <compat/net/if.h> 93#include <compat/net/if.h>
94#include <compat/net/route.h> 94#include <compat/net/route.h>
95 95
96#include <compat/common/compat_mod.h> 96#include <compat/common/compat_mod.h>
97 97
98void 98void
99compat_14_rt_oifmsg(struct ifnet *ifp) 99compat_14_rt_oifmsg(struct ifnet *ifp)
100{ 100{
101 struct if_msghdr14 oifm; 101 struct if_msghdr14 oifm;
 102 struct if_data ifi;
102 struct mbuf *m; 103 struct mbuf *m;
103 struct rt_addrinfo info; 104 struct rt_addrinfo info;
104 struct timeval tv; 105 struct timeval tv;
105 106
106 if (compat_50_route_info.ri_cb.any_count == 0) 107 if (compat_50_route_info.ri_cb.any_count == 0)
107 return; 108 return;
108 (void)memset(&info, 0, sizeof(info)); 109 (void)memset(&info, 0, sizeof(info));
109 (void)memset(&oifm, 0, sizeof(oifm)); 110 (void)memset(&oifm, 0, sizeof(oifm));
 111 if_export_if_data(ifp, &ifi, false);
110 oifm.ifm_index = ifp->if_index; 112 oifm.ifm_index = ifp->if_index;
111 oifm.ifm_flags = ifp->if_flags; 113 oifm.ifm_flags = ifp->if_flags;
112 oifm.ifm_data.ifi_type = ifp->if_data.ifi_type; 114 oifm.ifm_data.ifi_type = ifi.ifi_type;
113 oifm.ifm_data.ifi_addrlen = ifp->if_data.ifi_addrlen; 115 oifm.ifm_data.ifi_addrlen = ifi.ifi_addrlen;
114 oifm.ifm_data.ifi_hdrlen = ifp->if_data.ifi_hdrlen; 116 oifm.ifm_data.ifi_hdrlen = ifi.ifi_hdrlen;
115 oifm.ifm_data.ifi_mtu = ifp->if_data.ifi_mtu; 117 oifm.ifm_data.ifi_mtu = ifi.ifi_mtu;
116 oifm.ifm_data.ifi_metric = ifp->if_data.ifi_metric; 118 oifm.ifm_data.ifi_metric = ifi.ifi_metric;
117 oifm.ifm_data.ifi_baudrate = ifp->if_data.ifi_baudrate; 119 oifm.ifm_data.ifi_baudrate = ifi.ifi_baudrate;
118 oifm.ifm_data.ifi_ipackets = ifp->if_data.ifi_ipackets; 120 oifm.ifm_data.ifi_ipackets = ifi.ifi_ipackets;
119 oifm.ifm_data.ifi_ierrors = ifp->if_data.ifi_ierrors; 121 oifm.ifm_data.ifi_ierrors = ifi.ifi_ierrors;
120 oifm.ifm_data.ifi_opackets = ifp->if_data.ifi_opackets; 122 oifm.ifm_data.ifi_opackets = ifi.ifi_opackets;
121 oifm.ifm_data.ifi_oerrors = ifp->if_data.ifi_oerrors; 123 oifm.ifm_data.ifi_oerrors = ifi.ifi_oerrors;
122 oifm.ifm_data.ifi_collisions = ifp->if_data.ifi_collisions; 124 oifm.ifm_data.ifi_collisions = ifi.ifi_collisions;
123 oifm.ifm_data.ifi_ibytes = ifp->if_data.ifi_ibytes; 125 oifm.ifm_data.ifi_ibytes = ifi.ifi_ibytes;
124 oifm.ifm_data.ifi_obytes = ifp->if_data.ifi_obytes; 126 oifm.ifm_data.ifi_obytes = ifi.ifi_obytes;
125 oifm.ifm_data.ifi_imcasts = ifp->if_data.ifi_imcasts; 127 oifm.ifm_data.ifi_imcasts = ifi.ifi_imcasts;
126 oifm.ifm_data.ifi_omcasts = ifp->if_data.ifi_omcasts; 128 oifm.ifm_data.ifi_omcasts = ifi.ifi_omcasts;
127 oifm.ifm_data.ifi_iqdrops = ifp->if_data.ifi_iqdrops; 129 oifm.ifm_data.ifi_iqdrops = ifi.ifi_iqdrops;
128 oifm.ifm_data.ifi_noproto = ifp->if_data.ifi_noproto; 130 oifm.ifm_data.ifi_noproto = ifi.ifi_noproto;
129 TIMESPEC_TO_TIMEVAL(&tv, &ifp->if_data.ifi_lastchange); 131 TIMESPEC_TO_TIMEVAL(&tv, &ifi.ifi_lastchange);
130 timeval_to_timeval50(&tv, &oifm.ifm_data.ifi_lastchange); 132 timeval_to_timeval50(&tv, &oifm.ifm_data.ifi_lastchange);
131 oifm.ifm_addrs = 0; 133 oifm.ifm_addrs = 0;
132 m = compat_50_rt_msg1(RTM_OOIFINFO, &info, (void *)&oifm, sizeof(oifm)); 134 m = compat_50_rt_msg1(RTM_OOIFINFO, &info, (void *)&oifm, sizeof(oifm));
133 if (m == NULL) 135 if (m == NULL)
134 return; 136 return;
135 compat_50_route_enqueue(m, 0); 137 compat_50_route_enqueue(m, 0);
136} 138}
137 139
138int 140int
139compat_14_iflist(struct ifnet *ifp, struct rt_walkarg *w, 141compat_14_iflist(struct ifnet *ifp, struct rt_walkarg *w,
140 struct rt_addrinfo *info, size_t len) 142 struct rt_addrinfo *info, size_t len)
141{ 143{
142 struct if_msghdr14 *ifm; 144 struct if_msghdr14 *ifm;
 145 struct if_data ifi;
143 struct timeval tv; 146 struct timeval tv;
144 int error; 147 int error;
145 148
146 ifm = (struct if_msghdr14 *)w->w_tmem; 149 ifm = (struct if_msghdr14 *)w->w_tmem;
 150 if_export_if_data(ifp, &ifi, false);
147 ifm->ifm_index = ifp->if_index; 151 ifm->ifm_index = ifp->if_index;
148 ifm->ifm_flags = ifp->if_flags; 152 ifm->ifm_flags = ifp->if_flags;
149 ifm->ifm_data.ifi_type = ifp->if_data.ifi_type; 153 ifm->ifm_data.ifi_type = ifi.ifi_type;
150 ifm->ifm_data.ifi_addrlen = ifp->if_data.ifi_addrlen; 154 ifm->ifm_data.ifi_addrlen = ifi.ifi_addrlen;
151 ifm->ifm_data.ifi_hdrlen = ifp->if_data.ifi_hdrlen; 155 ifm->ifm_data.ifi_hdrlen = ifi.ifi_hdrlen;
152 ifm->ifm_data.ifi_mtu = ifp->if_data.ifi_mtu; 156 ifm->ifm_data.ifi_mtu = ifi.ifi_mtu;
153 ifm->ifm_data.ifi_metric = ifp->if_data.ifi_metric; 157 ifm->ifm_data.ifi_metric = ifi.ifi_metric;
154 ifm->ifm_data.ifi_baudrate = ifp->if_data.ifi_baudrate; 158 ifm->ifm_data.ifi_baudrate = ifi.ifi_baudrate;
155 ifm->ifm_data.ifi_ipackets = ifp->if_data.ifi_ipackets; 159 ifm->ifm_data.ifi_ipackets = ifi.ifi_ipackets;
156 ifm->ifm_data.ifi_ierrors = ifp->if_data.ifi_ierrors; 160 ifm->ifm_data.ifi_ierrors = ifi.ifi_ierrors;
157 ifm->ifm_data.ifi_opackets = ifp->if_data.ifi_opackets; 161 ifm->ifm_data.ifi_opackets = ifi.ifi_opackets;
158 ifm->ifm_data.ifi_oerrors = ifp->if_data.ifi_oerrors; 162 ifm->ifm_data.ifi_oerrors = ifi.ifi_oerrors;
159 ifm->ifm_data.ifi_collisions = ifp->if_data.ifi_collisions; 163 ifm->ifm_data.ifi_collisions = ifi.ifi_collisions;
160 ifm->ifm_data.ifi_ibytes = ifp->if_data.ifi_ibytes; 164 ifm->ifm_data.ifi_ibytes = ifi.ifi_ibytes;
161 ifm->ifm_data.ifi_obytes = ifp->if_data.ifi_obytes; 165 ifm->ifm_data.ifi_obytes = ifi.ifi_obytes;
162 ifm->ifm_data.ifi_imcasts = ifp->if_data.ifi_imcasts; 166 ifm->ifm_data.ifi_imcasts = ifi.ifi_imcasts;
163 ifm->ifm_data.ifi_omcasts = ifp->if_data.ifi_omcasts; 167 ifm->ifm_data.ifi_omcasts = ifi.ifi_omcasts;
164 ifm->ifm_data.ifi_iqdrops = ifp->if_data.ifi_iqdrops; 168 ifm->ifm_data.ifi_iqdrops = ifi.ifi_iqdrops;
165 ifm->ifm_data.ifi_noproto = ifp->if_data.ifi_noproto; 169 ifm->ifm_data.ifi_noproto = ifi.ifi_noproto;
166 TIMESPEC_TO_TIMEVAL(&tv, &ifp->if_data.ifi_lastchange); 170 TIMESPEC_TO_TIMEVAL(&tv, &ifi.ifi_lastchange);
167 timeval_to_timeval50(&tv, &ifm->ifm_data.ifi_lastchange); 171 timeval_to_timeval50(&tv, &ifm->ifm_data.ifi_lastchange);
168 ifm->ifm_addrs = info->rti_addrs; 172 ifm->ifm_addrs = info->rti_addrs;
169 error = copyout(ifm, w->w_where, len); 173 error = copyout(ifm, w->w_where, len);
170 if (error) 174 if (error)
171 return error; 175 return error;
172 w->w_where = (char *)w->w_where + len; 176 w->w_where = (char *)w->w_where + len;
173 return 0; 177 return 0;
174} 178}
175 179
176void 180void
177rtsock_14_init(void) 181rtsock_14_init(void)
178{ 182{
179 183

cvs diff -r1.15 -r1.16 src/sys/compat/common/rtsock_50.c (expand / switch to unified diff)

--- src/sys/compat/common/rtsock_50.c 2019/12/12 02:15:42 1.15
+++ src/sys/compat/common/rtsock_50.c 2020/01/29 05:47:12 1.16
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rtsock_50.c,v 1.15 2019/12/12 02:15:42 pgoyette Exp $ */ 1/* $NetBSD: rtsock_50.c,v 1.16 2020/01/29 05:47:12 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -51,108 +51,112 @@ @@ -51,108 +51,112 @@
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE. 58 * SUCH DAMAGE.
59 * 59 *
60 * @(#)rtsock.c 8.7 (Berkeley) 10/12/95 60 * @(#)rtsock.c 8.7 (Berkeley) 10/12/95
61 */ 61 */
62 62
63#include <sys/cdefs.h> 63#include <sys/cdefs.h>
64__KERNEL_RCSID(0, "$NetBSD: rtsock_50.c,v 1.15 2019/12/12 02:15:42 pgoyette Exp $"); 64__KERNEL_RCSID(0, "$NetBSD: rtsock_50.c,v 1.16 2020/01/29 05:47:12 thorpej Exp $");
65 65
66#define COMPAT_RTSOCK /* Use the COMPATNAME/COMPATCALL macros and the 66#define COMPAT_RTSOCK /* Use the COMPATNAME/COMPATCALL macros and the
67 * various other compat definitions - see 67 * various other compat definitions - see
68 * sys/net/rtsock_shared.c for details 68 * sys/net/rtsock_shared.c for details
69 */ 69 */
70 70
71#include <net/rtsock_shared.c> 71#include <net/rtsock_shared.c>
72#include <compat/net/route_50.h> 72#include <compat/net/route_50.h>
73 73
74static struct sysctllog *clog; 74static struct sysctllog *clog;
75 75
76void 76void
77compat_50_rt_oifmsg(struct ifnet *ifp) 77compat_50_rt_oifmsg(struct ifnet *ifp)
78{ 78{
79 struct if_msghdr50 oifm; 79 struct if_msghdr50 oifm;
 80 struct if_data ifi;
80 struct mbuf *m; 81 struct mbuf *m;
81 struct rt_addrinfo info; 82 struct rt_addrinfo info;
82 83
83 if (COMPATNAME(route_info).ri_cb.any_count == 0) 84 if (COMPATNAME(route_info).ri_cb.any_count == 0)
84 return; 85 return;
85 (void)memset(&info, 0, sizeof(info)); 86 (void)memset(&info, 0, sizeof(info));
86 (void)memset(&oifm, 0, sizeof(oifm)); 87 (void)memset(&oifm, 0, sizeof(oifm));
 88 if_export_if_data(ifp, &ifi, false);
87 oifm.ifm_index = ifp->if_index; 89 oifm.ifm_index = ifp->if_index;
88 oifm.ifm_flags = ifp->if_flags; 90 oifm.ifm_flags = ifp->if_flags;
89 oifm.ifm_data.ifi_type = ifp->if_data.ifi_type; 91 oifm.ifm_data.ifi_type = ifi.ifi_type;
90 oifm.ifm_data.ifi_addrlen = ifp->if_data.ifi_addrlen; 92 oifm.ifm_data.ifi_addrlen = ifi.ifi_addrlen;
91 oifm.ifm_data.ifi_hdrlen = ifp->if_data.ifi_hdrlen; 93 oifm.ifm_data.ifi_hdrlen = ifi.ifi_hdrlen;
92 oifm.ifm_data.ifi_link_state = ifp->if_data.ifi_link_state; 94 oifm.ifm_data.ifi_link_state = ifi.ifi_link_state;
93 oifm.ifm_data.ifi_mtu = ifp->if_data.ifi_mtu; 95 oifm.ifm_data.ifi_mtu = ifi.ifi_mtu;
94 oifm.ifm_data.ifi_metric = ifp->if_data.ifi_metric; 96 oifm.ifm_data.ifi_metric = ifi.ifi_metric;
95 oifm.ifm_data.ifi_baudrate = ifp->if_data.ifi_baudrate; 97 oifm.ifm_data.ifi_baudrate = ifi.ifi_baudrate;
96 oifm.ifm_data.ifi_ipackets = ifp->if_data.ifi_ipackets; 98 oifm.ifm_data.ifi_ipackets = ifi.ifi_ipackets;
97 oifm.ifm_data.ifi_ierrors = ifp->if_data.ifi_ierrors; 99 oifm.ifm_data.ifi_ierrors = ifi.ifi_ierrors;
98 oifm.ifm_data.ifi_opackets = ifp->if_data.ifi_opackets; 100 oifm.ifm_data.ifi_opackets = ifi.ifi_opackets;
99 oifm.ifm_data.ifi_oerrors = ifp->if_data.ifi_oerrors; 101 oifm.ifm_data.ifi_oerrors = ifi.ifi_oerrors;
100 oifm.ifm_data.ifi_collisions = ifp->if_data.ifi_collisions; 102 oifm.ifm_data.ifi_collisions = ifi.ifi_collisions;
101 oifm.ifm_data.ifi_ibytes = ifp->if_data.ifi_ibytes; 103 oifm.ifm_data.ifi_ibytes = ifi.ifi_ibytes;
102 oifm.ifm_data.ifi_obytes = ifp->if_data.ifi_obytes; 104 oifm.ifm_data.ifi_obytes = ifi.ifi_obytes;
103 oifm.ifm_data.ifi_imcasts = ifp->if_data.ifi_imcasts; 105 oifm.ifm_data.ifi_imcasts = ifi.ifi_imcasts;
104 oifm.ifm_data.ifi_omcasts = ifp->if_data.ifi_omcasts; 106 oifm.ifm_data.ifi_omcasts = ifi.ifi_omcasts;
105 oifm.ifm_data.ifi_iqdrops = ifp->if_data.ifi_iqdrops; 107 oifm.ifm_data.ifi_iqdrops = ifi.ifi_iqdrops;
106 oifm.ifm_data.ifi_noproto = ifp->if_data.ifi_noproto; 108 oifm.ifm_data.ifi_noproto = ifi.ifi_noproto;
107 TIMESPEC_TO_TIMEVAL(&oifm.ifm_data.ifi_lastchange, 109 TIMESPEC_TO_TIMEVAL(&oifm.ifm_data.ifi_lastchange,
108 &ifp->if_data.ifi_lastchange); 110 &ifi.ifi_lastchange);
109 oifm.ifm_addrs = 0; 111 oifm.ifm_addrs = 0;
110 m = COMPATNAME(rt_msg1)(RTM_OIFINFO, &info, (void *)&oifm, sizeof(oifm)); 112 m = COMPATNAME(rt_msg1)(RTM_OIFINFO, &info, (void *)&oifm, sizeof(oifm));
111 if (m == NULL) 113 if (m == NULL)
112 return; 114 return;
113 COMPATNAME(route_enqueue)(m, 0); 115 COMPATNAME(route_enqueue)(m, 0);
114} 116}
115 117
116int 118int
117compat_50_iflist(struct ifnet *ifp, struct rt_walkarg *w, 119compat_50_iflist(struct ifnet *ifp, struct rt_walkarg *w,
118 struct rt_addrinfo *info, size_t len) 120 struct rt_addrinfo *info, size_t len)
119{ 121{
120 struct if_msghdr50 *ifm; 122 struct if_msghdr50 *ifm;
 123 struct if_data ifi;
121 int error; 124 int error;
122 125
123 ifm = (struct if_msghdr50 *)w->w_tmem; 126 ifm = (struct if_msghdr50 *)w->w_tmem;
 127 if_export_if_data(ifp, &ifi, false);
124 ifm->ifm_index = ifp->if_index; 128 ifm->ifm_index = ifp->if_index;
125 ifm->ifm_flags = ifp->if_flags; 129 ifm->ifm_flags = ifp->if_flags;
126 ifm->ifm_data.ifi_type = ifp->if_data.ifi_type; 130 ifm->ifm_data.ifi_type = ifi.ifi_type;
127 ifm->ifm_data.ifi_addrlen = ifp->if_data.ifi_addrlen; 131 ifm->ifm_data.ifi_addrlen = ifi.ifi_addrlen;
128 ifm->ifm_data.ifi_hdrlen = ifp->if_data.ifi_hdrlen; 132 ifm->ifm_data.ifi_hdrlen = ifi.ifi_hdrlen;
129 ifm->ifm_data.ifi_link_state = ifp->if_data.ifi_link_state; 133 ifm->ifm_data.ifi_link_state = ifi.ifi_link_state;
130 ifm->ifm_data.ifi_mtu = ifp->if_data.ifi_mtu; 134 ifm->ifm_data.ifi_mtu = ifi.ifi_mtu;
131 ifm->ifm_data.ifi_metric = ifp->if_data.ifi_metric; 135 ifm->ifm_data.ifi_metric = ifi.ifi_metric;
132 ifm->ifm_data.ifi_baudrate = ifp->if_data.ifi_baudrate; 136 ifm->ifm_data.ifi_baudrate = ifi.ifi_baudrate;
133 ifm->ifm_data.ifi_ipackets = ifp->if_data.ifi_ipackets; 137 ifm->ifm_data.ifi_ipackets = ifi.ifi_ipackets;
134 ifm->ifm_data.ifi_ierrors = ifp->if_data.ifi_ierrors; 138 ifm->ifm_data.ifi_ierrors = ifi.ifi_ierrors;
135 ifm->ifm_data.ifi_opackets = ifp->if_data.ifi_opackets; 139 ifm->ifm_data.ifi_opackets = ifi.ifi_opackets;
136 ifm->ifm_data.ifi_oerrors = ifp->if_data.ifi_oerrors; 140 ifm->ifm_data.ifi_oerrors = ifi.ifi_oerrors;
137 ifm->ifm_data.ifi_collisions = ifp->if_data.ifi_collisions; 141 ifm->ifm_data.ifi_collisions = ifi.ifi_collisions;
138 ifm->ifm_data.ifi_ibytes = ifp->if_data.ifi_ibytes; 142 ifm->ifm_data.ifi_ibytes = ifi.ifi_ibytes;
139 ifm->ifm_data.ifi_obytes = ifp->if_data.ifi_obytes; 143 ifm->ifm_data.ifi_obytes = ifi.ifi_obytes;
140 ifm->ifm_data.ifi_imcasts = ifp->if_data.ifi_imcasts; 144 ifm->ifm_data.ifi_imcasts = ifi.ifi_imcasts;
141 ifm->ifm_data.ifi_omcasts = ifp->if_data.ifi_omcasts; 145 ifm->ifm_data.ifi_omcasts = ifi.ifi_omcasts;
142 ifm->ifm_data.ifi_iqdrops = ifp->if_data.ifi_iqdrops; 146 ifm->ifm_data.ifi_iqdrops = ifi.ifi_iqdrops;
143 ifm->ifm_data.ifi_noproto = ifp->if_data.ifi_noproto; 147 ifm->ifm_data.ifi_noproto = ifi.ifi_noproto;
144 TIMESPEC_TO_TIMEVAL(&ifm->ifm_data.ifi_lastchange, 148 TIMESPEC_TO_TIMEVAL(&ifm->ifm_data.ifi_lastchange,
145 &ifp->if_data.ifi_lastchange); 149 &ifi.ifi_lastchange);
146 ifm->ifm_addrs = info->rti_addrs; 150 ifm->ifm_addrs = info->rti_addrs;
147 error = copyout(ifm, w->w_where, len); 151 error = copyout(ifm, w->w_where, len);
148 if (error) 152 if (error)
149 return error; 153 return error;
150 w->w_where = (char *)w->w_where + len; 154 w->w_where = (char *)w->w_where + len;
151 return 0; 155 return 0;
152} 156}
153 157
154void 158void
155rtsock_50_init(void) 159rtsock_50_init(void)
156{ 160{
157  161
158 MODULE_HOOK_SET(rtsock_iflist_50_hook, compat_50_iflist); 162 MODULE_HOOK_SET(rtsock_iflist_50_hook, compat_50_iflist);