Tue Jan 24 18:37:20 2017 UTC ()
Don't forget to free the mbuf when we decide not to reply to an ARP
request. This obviously is a terrible bug, since it allows a remote sender
to DoS the system with specially-crafted requests sent in a loop.


(maxv)
diff -r1.75 -r1.76 src/sys/net/if_arcsubr.c
diff -r1.49 -r1.50 src/sys/net/if_ecosubr.c
diff -r1.235 -r1.236 src/sys/net/if_ethersubr.c
diff -r1.103 -r1.104 src/sys/net/if_fddisubr.c
diff -r1.79 -r1.80 src/sys/net/if_tokensubr.c

cvs diff -r1.75 -r1.76 src/sys/net/if_arcsubr.c (expand / switch to unified diff)

--- src/sys/net/if_arcsubr.c 2017/01/11 13:08:29 1.75
+++ src/sys/net/if_arcsubr.c 2017/01/24 18:37:20 1.76
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_arcsubr.c,v 1.75 2017/01/11 13:08:29 ozaki-r Exp $ */ 1/* $NetBSD: if_arcsubr.c,v 1.76 2017/01/24 18:37:20 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Ignatios Souvatzis 4 * Copyright (c) 1994, 1995 Ignatios Souvatzis
5 * Copyright (c) 1982, 1989, 1993 5 * Copyright (c) 1982, 1989, 1993
6 * The Regents of the University of California. All rights reserved. 6 * The Regents of the University of California. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE. 30 * SUCH DAMAGE.
31 * 31 *
32 * from: NetBSD: if_ethersubr.c,v 1.9 1994/06/29 06:36:11 cgd Exp 32 * from: NetBSD: if_ethersubr.c,v 1.9 1994/06/29 06:36:11 cgd Exp
33 * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93 33 * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93
34 * 34 *
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.75 2017/01/11 13:08:29 ozaki-r Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.76 2017/01/24 18:37:20 maxv Exp $");
39 39
40#ifdef _KERNEL_OPT 40#ifdef _KERNEL_OPT
41#include "opt_inet.h" 41#include "opt_inet.h"
42#endif 42#endif
43 43
44#include <sys/param.h> 44#include <sys/param.h>
45#include <sys/systm.h> 45#include <sys/systm.h>
46#include <sys/kernel.h> 46#include <sys/kernel.h>
47#include <sys/malloc.h> 47#include <sys/malloc.h>
48#include <sys/mbuf.h> 48#include <sys/mbuf.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/errno.h> 50#include <sys/errno.h>
51#include <sys/syslog.h> 51#include <sys/syslog.h>
@@ -161,28 +161,30 @@ arc_output(struct ifnet *ifp, struct mbu @@ -161,28 +161,30 @@ arc_output(struct ifnet *ifp, struct mbu
161 newencoding = 1; 161 newencoding = 1;
162 } else { 162 } else {
163 atype = ARCTYPE_IP_OLD; 163 atype = ARCTYPE_IP_OLD;
164 newencoding = 0; 164 newencoding = 0;
165 } 165 }
166 break; 166 break;
167 167
168 case AF_ARP: 168 case AF_ARP:
169 arph = mtod(m, struct arphdr *); 169 arph = mtod(m, struct arphdr *);
170 if (m->m_flags & M_BCAST) 170 if (m->m_flags & M_BCAST)
171 adst = arcbroadcastaddr; 171 adst = arcbroadcastaddr;
172 else { 172 else {
173 uint8_t *tha = ar_tha(arph); 173 uint8_t *tha = ar_tha(arph);
174 if (tha == NULL) 174 if (tha == NULL) {
 175 m_freem(m);
175 return 0; 176 return 0;
 177 }
176 adst = *tha; 178 adst = *tha;
177 } 179 }
178 180
179 arph->ar_hrd = htons(ARPHRD_ARCNET); 181 arph->ar_hrd = htons(ARPHRD_ARCNET);
180 182
181 switch (ntohs(arph->ar_op)) { 183 switch (ntohs(arph->ar_op)) {
182 case ARPOP_REVREQUEST: 184 case ARPOP_REVREQUEST:
183 case ARPOP_REVREPLY: 185 case ARPOP_REVREPLY:
184 if (!(ifp->if_flags & IFF_LINK0)) { 186 if (!(ifp->if_flags & IFF_LINK0)) {
185 printf("%s: can't handle af%d\n", 187 printf("%s: can't handle af%d\n",
186 ifp->if_xname, dst->sa_family); 188 ifp->if_xname, dst->sa_family);
187 senderr(EAFNOSUPPORT); 189 senderr(EAFNOSUPPORT);
188 } 190 }

cvs diff -r1.49 -r1.50 src/sys/net/Attic/if_ecosubr.c (expand / switch to unified diff)

--- src/sys/net/Attic/if_ecosubr.c 2016/10/03 11:06:06 1.49
+++ src/sys/net/Attic/if_ecosubr.c 2017/01/24 18:37:20 1.50
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_ecosubr.c,v 1.49 2016/10/03 11:06:06 ozaki-r Exp $ */ 1/* $NetBSD: if_ecosubr.c,v 1.50 2017/01/24 18:37:20 maxv Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2001 Ben Harris 4 * Copyright (c) 2001 Ben Harris
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.
@@ -48,27 +48,27 @@ @@ -48,27 +48,27 @@
48 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 48 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * SUCH DAMAGE. 55 * SUCH DAMAGE.
56 * 56 *
57 * @(#)if_ethersubr.c 8.2 (Berkeley) 4/4/96 57 * @(#)if_ethersubr.c 8.2 (Berkeley) 4/4/96
58 */ 58 */
59 59
60#include <sys/cdefs.h> 60#include <sys/cdefs.h>
61__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.49 2016/10/03 11:06:06 ozaki-r Exp $"); 61__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.50 2017/01/24 18:37:20 maxv Exp $");
62 62
63#ifdef _KERNEL_OPT 63#ifdef _KERNEL_OPT
64#include "opt_inet.h" 64#include "opt_inet.h"
65#endif 65#endif
66 66
67#include <sys/param.h> 67#include <sys/param.h>
68#include <sys/errno.h> 68#include <sys/errno.h>
69#include <sys/kernel.h> 69#include <sys/kernel.h>
70#include <sys/socket.h> 70#include <sys/socket.h>
71#include <sys/sockio.h> 71#include <sys/sockio.h>
72#include <sys/syslog.h> 72#include <sys/syslog.h>
73#include <sys/systm.h> 73#include <sys/systm.h>
74 74
@@ -200,47 +200,52 @@ eco_output(struct ifnet *ifp, struct mbu @@ -200,47 +200,52 @@ eco_output(struct ifnet *ifp, struct mbu
200 else if (!arpresolve(ifp, rt, m, dst, ehdr.eco_dhost, 200 else if (!arpresolve(ifp, rt, m, dst, ehdr.eco_dhost,
201 sizeof(ehdr.eco_dhost))) 201 sizeof(ehdr.eco_dhost)))
202 return (0); /* if not yet resolved */ 202 return (0); /* if not yet resolved */
203 /* If broadcasting on a simplex interface, loopback a copy */ 203 /* If broadcasting on a simplex interface, loopback a copy */
204 if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX)) 204 if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
205 mcopy = m_copy(m, 0, (int)M_COPYALL); 205 mcopy = m_copy(m, 0, (int)M_COPYALL);
206 ehdr.eco_port = ECO_PORT_IP; 206 ehdr.eco_port = ECO_PORT_IP;
207 ehdr.eco_control = ECO_CTL_IP; 207 ehdr.eco_control = ECO_CTL_IP;
208 break; 208 break;
209 209
210 case AF_ARP: 210 case AF_ARP:
211 ah = mtod(m, struct arphdr *); 211 ah = mtod(m, struct arphdr *);
212 212
213 if (ntohs(ah->ar_pro) != ETHERTYPE_IP) 213 if (ntohs(ah->ar_pro) != ETHERTYPE_IP) {
214 return EAFNOSUPPORT; 214 error = EAFNOSUPPORT;
 215 goto bad;
 216 }
215 ehdr.eco_port = ECO_PORT_IP; 217 ehdr.eco_port = ECO_PORT_IP;
216 switch (ntohs(ah->ar_op)) { 218 switch (ntohs(ah->ar_op)) {
217 case ARPOP_REQUEST: 219 case ARPOP_REQUEST:
218 ehdr.eco_control = ECO_CTL_ARP_REQUEST; 220 ehdr.eco_control = ECO_CTL_ARP_REQUEST;
219 break; 221 break;
220 case ARPOP_REPLY: 222 case ARPOP_REPLY:
221 ehdr.eco_control = ECO_CTL_ARP_REPLY; 223 ehdr.eco_control = ECO_CTL_ARP_REPLY;
222 break; 224 break;
223 default: 225 default:
224 return EOPNOTSUPP; 226 error = EOPNOTSUPP;
 227 goto bad;
225 } 228 }
226 229
227 if (m->m_flags & M_BCAST) 230 if (m->m_flags & M_BCAST)
228 memcpy(ehdr.eco_dhost, eco_broadcastaddr, 231 memcpy(ehdr.eco_dhost, eco_broadcastaddr,
229 ECO_ADDR_LEN); 232 ECO_ADDR_LEN);
230 else { 233 else {
231 tha = ar_tha(ah); 234 tha = ar_tha(ah);
232 if (tha == NULL) 235 if (tha == NULL) {
 236 m_freem(m);
233 return 0; 237 return 0;
 238 }
234 memcpy(ehdr.eco_dhost, tha, ECO_ADDR_LEN); 239 memcpy(ehdr.eco_dhost, tha, ECO_ADDR_LEN);
235 } 240 }
236 241
237 MGETHDR(m1, M_DONTWAIT, MT_DATA); 242 MGETHDR(m1, M_DONTWAIT, MT_DATA);
238 if (m1 == NULL) 243 if (m1 == NULL)
239 senderr(ENOBUFS); 244 senderr(ENOBUFS);
240 M_MOVE_PKTHDR(m1, m); 245 M_MOVE_PKTHDR(m1, m);
241 m1->m_len = sizeof(*ecah); 246 m1->m_len = sizeof(*ecah);
242 m1->m_pkthdr.len = m1->m_len; 247 m1->m_pkthdr.len = m1->m_len;
243 MH_ALIGN(m1, m1->m_len); 248 MH_ALIGN(m1, m1->m_len);
244 ecah = mtod(m1, struct eco_arp *); 249 ecah = mtod(m1, struct eco_arp *);
245 memset(ecah, 0, m1->m_len); 250 memset(ecah, 0, m1->m_len);
246 memcpy(ecah->ecar_spa, ar_spa(ah), ah->ar_pln); 251 memcpy(ecah->ecar_spa, ar_spa(ah), ah->ar_pln);

cvs diff -r1.235 -r1.236 src/sys/net/if_ethersubr.c (expand / switch to unified diff)

--- src/sys/net/if_ethersubr.c 2017/01/13 06:11:56 1.235
+++ src/sys/net/if_ethersubr.c 2017/01/24 18:37:20 1.236
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_ethersubr.c,v 1.235 2017/01/13 06:11:56 msaitoh Exp $ */ 1/* $NetBSD: if_ethersubr.c,v 1.236 2017/01/24 18:37:20 maxv 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 * @(#)if_ethersubr.c 8.2 (Berkeley) 4/4/96 60 * @(#)if_ethersubr.c 8.2 (Berkeley) 4/4/96
61 */ 61 */
62 62
63#include <sys/cdefs.h> 63#include <sys/cdefs.h>
64__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.235 2017/01/13 06:11:56 msaitoh Exp $"); 64__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.236 2017/01/24 18:37:20 maxv Exp $");
65 65
66#ifdef _KERNEL_OPT 66#ifdef _KERNEL_OPT
67#include "opt_inet.h" 67#include "opt_inet.h"
68#include "opt_atalk.h" 68#include "opt_atalk.h"
69#include "opt_mbuftrace.h" 69#include "opt_mbuftrace.h"
70#include "opt_mpls.h" 70#include "opt_mpls.h"
71#include "opt_gateway.h" 71#include "opt_gateway.h"
72#include "opt_pppoe.h" 72#include "opt_pppoe.h"
73#include "opt_net_mpsafe.h" 73#include "opt_net_mpsafe.h"
74#endif 74#endif
75 75
76#include "vlan.h" 76#include "vlan.h"
77#include "pppoe.h" 77#include "pppoe.h"
@@ -269,26 +269,27 @@ ether_output(struct ifnet * const ifp0,  @@ -269,26 +269,27 @@ ether_output(struct ifnet * const ifp0,
269 mcopy = m_copy(m, 0, (int)M_COPYALL); 269 mcopy = m_copy(m, 0, (int)M_COPYALL);
270 etype = htons(ETHERTYPE_IP); 270 etype = htons(ETHERTYPE_IP);
271 break; 271 break;
272 272
273 case AF_ARP: 273 case AF_ARP:
274 ah = mtod(m, struct arphdr *); 274 ah = mtod(m, struct arphdr *);
275 if (m->m_flags & M_BCAST) 275 if (m->m_flags & M_BCAST)
276 (void)memcpy(edst, etherbroadcastaddr, sizeof(edst)); 276 (void)memcpy(edst, etherbroadcastaddr, sizeof(edst));
277 else { 277 else {
278 void *tha = ar_tha(ah); 278 void *tha = ar_tha(ah);
279 279
280 if (tha == NULL) { 280 if (tha == NULL) {
281 /* fake with ARPHDR_IEEE1394 */ 281 /* fake with ARPHDR_IEEE1394 */
 282 m_freem(m);
282 return 0; 283 return 0;
283 } 284 }
284 memcpy(edst, tha, sizeof(edst)); 285 memcpy(edst, tha, sizeof(edst));
285 } 286 }
286 287
287 ah->ar_hrd = htons(ARPHRD_ETHER); 288 ah->ar_hrd = htons(ARPHRD_ETHER);
288 289
289 switch (ntohs(ah->ar_op)) { 290 switch (ntohs(ah->ar_op)) {
290 case ARPOP_REVREQUEST: 291 case ARPOP_REVREQUEST:
291 case ARPOP_REVREPLY: 292 case ARPOP_REVREPLY:
292 etype = htons(ETHERTYPE_REVARP); 293 etype = htons(ETHERTYPE_REVARP);
293 break; 294 break;
294 295

cvs diff -r1.103 -r1.104 src/sys/net/Attic/if_fddisubr.c (expand / switch to unified diff)

--- src/sys/net/Attic/if_fddisubr.c 2017/01/11 13:08:29 1.103
+++ src/sys/net/Attic/if_fddisubr.c 2017/01/24 18:37:20 1.104
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_fddisubr.c,v 1.103 2017/01/11 13:08:29 ozaki-r Exp $ */ 1/* $NetBSD: if_fddisubr.c,v 1.104 2017/01/24 18:37:20 maxv 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.
@@ -86,27 +86,27 @@ @@ -86,27 +86,27 @@
86 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 86 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
87 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 87 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
88 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 88 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
89 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 89 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
90 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 90 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
91 * SUCH DAMAGE. 91 * SUCH DAMAGE.
92 * 92 *
93 * @(#)if_fddisubr.c 8.1 (Berkeley) 6/10/93 93 * @(#)if_fddisubr.c 8.1 (Berkeley) 6/10/93
94 * 94 *
95 * Id: if_fddisubr.c,v 1.15 1997/03/21 22:35:50 thomas Exp 95 * Id: if_fddisubr.c,v 1.15 1997/03/21 22:35:50 thomas Exp
96 */ 96 */
97 97
98#include <sys/cdefs.h> 98#include <sys/cdefs.h>
99__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.103 2017/01/11 13:08:29 ozaki-r Exp $"); 99__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.104 2017/01/24 18:37:20 maxv Exp $");
100 100
101#ifdef _KERNEL_OPT 101#ifdef _KERNEL_OPT
102#include "opt_gateway.h" 102#include "opt_gateway.h"
103#include "opt_inet.h" 103#include "opt_inet.h"
104#include "opt_atalk.h" 104#include "opt_atalk.h"
105#include "opt_mbuftrace.h" 105#include "opt_mbuftrace.h"
106#endif 106#endif
107 107
108 108
109#include <sys/param.h> 109#include <sys/param.h>
110#include <sys/systm.h> 110#include <sys/systm.h>
111#include <sys/kernel.h> 111#include <sys/kernel.h>
112#include <sys/malloc.h> 112#include <sys/malloc.h>
@@ -251,31 +251,33 @@ fddi_output(struct ifnet *ifp0, struct m @@ -251,31 +251,33 @@ fddi_output(struct ifnet *ifp0, struct m
251#ifdef INET6 251#ifdef INET6
252 case AF_INET6: 252 case AF_INET6:
253 if (!nd6_storelladdr(ifp, rt, m, dst, edst, sizeof(edst))){ 253 if (!nd6_storelladdr(ifp, rt, m, dst, edst, sizeof(edst))){
254 /* something bad happened */ 254 /* something bad happened */
255 return (0); 255 return (0);
256 } 256 }
257 etype = htons(ETHERTYPE_IPV6); 257 etype = htons(ETHERTYPE_IPV6);
258 break; 258 break;
259#endif 259#endif
260#ifdef AF_ARP 260#ifdef AF_ARP
261 case AF_ARP: { 261 case AF_ARP: {
262 struct arphdr *ah = mtod(m, struct arphdr *); 262 struct arphdr *ah = mtod(m, struct arphdr *);
263 if (m->m_flags & M_BCAST) 263 if (m->m_flags & M_BCAST)
264 memcpy(edst, etherbroadcastaddr, sizeof(edst)); 264 memcpy(edst, etherbroadcastaddr, sizeof(edst));
265 else { 265 else {
266 void *tha = ar_tha(ah); 266 void *tha = ar_tha(ah);
267 if (tha == NULL) 267 if (tha == NULL) {
 268 m_freem(m);
268 return 0; 269 return 0;
 270 }
269 memcpy(edst, tha, sizeof(edst)); 271 memcpy(edst, tha, sizeof(edst));
270 } 272 }
271 273
272 ah->ar_hrd = htons(ARPHRD_ETHER); 274 ah->ar_hrd = htons(ARPHRD_ETHER);
273 275
274 switch (ntohs(ah->ar_op)) { 276 switch (ntohs(ah->ar_op)) {
275 case ARPOP_REVREQUEST: 277 case ARPOP_REVREQUEST:
276 case ARPOP_REVREPLY: 278 case ARPOP_REVREPLY:
277 etype = htons(ETHERTYPE_REVARP); 279 etype = htons(ETHERTYPE_REVARP);
278 break; 280 break;
279 281
280 case ARPOP_REQUEST: 282 case ARPOP_REQUEST:
281 case ARPOP_REPLY: 283 case ARPOP_REPLY:

cvs diff -r1.79 -r1.80 src/sys/net/Attic/if_tokensubr.c (expand / switch to unified diff)

--- src/sys/net/Attic/if_tokensubr.c 2017/01/11 13:08:29 1.79
+++ src/sys/net/Attic/if_tokensubr.c 2017/01/24 18:37:20 1.80
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_tokensubr.c,v 1.79 2017/01/11 13:08:29 ozaki-r Exp $ */ 1/* $NetBSD: if_tokensubr.c,v 1.80 2017/01/24 18:37:20 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1989, 1993 4 * Copyright (c) 1982, 1989, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. 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.
@@ -82,27 +82,27 @@ @@ -82,27 +82,27 @@
82 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 82 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
83 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 83 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
84 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 84 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
85 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 85 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
86 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 86 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
87 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 87 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
88 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 88 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
89 * SUCH DAMAGE. 89 * SUCH DAMAGE.
90 * 90 *
91 * from: NetBSD: if_fddisubr.c,v 1.2 1995/08/19 04:35:29 cgd Exp 91 * from: NetBSD: if_fddisubr.c,v 1.2 1995/08/19 04:35:29 cgd Exp
92 */ 92 */
93 93
94#include <sys/cdefs.h> 94#include <sys/cdefs.h>
95__KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.79 2017/01/11 13:08:29 ozaki-r Exp $"); 95__KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.80 2017/01/24 18:37:20 maxv Exp $");
96 96
97#ifdef _KERNEL_OPT 97#ifdef _KERNEL_OPT
98#include "opt_inet.h" 98#include "opt_inet.h"
99#include "opt_atalk.h" 99#include "opt_atalk.h"
100#include "opt_gateway.h" 100#include "opt_gateway.h"
101#endif 101#endif
102 102
103#include <sys/param.h> 103#include <sys/param.h>
104#include <sys/systm.h> 104#include <sys/systm.h>
105#include <sys/kernel.h> 105#include <sys/kernel.h>
106#include <sys/malloc.h> 106#include <sys/malloc.h>
107#include <sys/mbuf.h> 107#include <sys/mbuf.h>
108#include <sys/ioctl.h> 108#include <sys/ioctl.h>
@@ -257,28 +257,30 @@ token_output(struct ifnet *ifp0, struct  @@ -257,28 +257,30 @@ token_output(struct ifnet *ifp0, struct
257 if (m->m_flags & M_BCAST) { 257 if (m->m_flags & M_BCAST) {
258 if (ifp->if_flags & IFF_LINK0) { 258 if (ifp->if_flags & IFF_LINK0) {
259 if (ifp->if_flags & IFF_LINK1) 259 if (ifp->if_flags & IFF_LINK1)
260 bcastrif.tr_rcf = htons(RCF_ALLROUTES); 260 bcastrif.tr_rcf = htons(RCF_ALLROUTES);
261 else 261 else
262 bcastrif.tr_rcf = htons(RCF_SINGLEROUTE); 262 bcastrif.tr_rcf = htons(RCF_SINGLEROUTE);
263 rif = &bcastrif; 263 rif = &bcastrif;
264 riflen = sizeof(rif->tr_rcf); 264 riflen = sizeof(rif->tr_rcf);
265 } 265 }
266 memcpy(edst, tokenbroadcastaddr, sizeof(edst)); 266 memcpy(edst, tokenbroadcastaddr, sizeof(edst));
267 } 267 }
268 else { 268 else {
269 void *tha = ar_tha(ah); 269 void *tha = ar_tha(ah);
270 if (tha == NULL) 270 if (tha == NULL) {
 271 m_freem(m);
271 return 0; 272 return 0;
 273 }
272 memcpy(edst, tha, sizeof(edst)); 274 memcpy(edst, tha, sizeof(edst));
273 trh = (struct token_header *)M_TRHSTART(m); 275 trh = (struct token_header *)M_TRHSTART(m);
274 trh->token_ac = TOKEN_AC; 276 trh->token_ac = TOKEN_AC;
275 trh->token_fc = TOKEN_FC; 277 trh->token_fc = TOKEN_FC;
276 if (trh->token_shost[0] & TOKEN_RI_PRESENT) { 278 if (trh->token_shost[0] & TOKEN_RI_PRESENT) {
277 struct token_rif *trrif; 279 struct token_rif *trrif;
278 280
279 trrif = TOKEN_RIF(trh); 281 trrif = TOKEN_RIF(trh);
280 riflen = (ntohs(trrif->tr_rcf) & TOKEN_RCF_LEN_MASK) >> 8; 282 riflen = (ntohs(trrif->tr_rcf) & TOKEN_RCF_LEN_MASK) >> 8;
281 } 283 }
282 memcpy((void *)trh->token_dhost, (void *)edst, 284 memcpy((void *)trh->token_dhost, (void *)edst,
283 sizeof (edst)); 285 sizeof (edst));
284 memcpy((void *)trh->token_shost, CLLADDR(ifp->if_sadl), 286 memcpy((void *)trh->token_shost, CLLADDR(ifp->if_sadl),