Pull up following revision(s) (requested by maxv in ticket #1429): sys/net/if_arcsubr.c: revision 1.76 via patch sys/net/if_ecosubr.c: revision 1.50 via patch sys/net/if_ethersubr.c: revision 1.236 via patch sys/net/if_fddisubr.c: revision 1.104 via patch sys/net/if_tokensubr.c: revision 1.80 via patch 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.diff -r1.63.14.1 -r1.63.14.1.2.1 src/sys/net/if_arcsubr.c
(snj)
--- src/sys/net/if_arcsubr.c 2012/10/23 16:19:47 1.63.14.1
+++ src/sys/net/if_arcsubr.c 2017/02/05 05:47:28 1.63.14.1.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_arcsubr.c,v 1.63.14.1 2012/10/23 16:19:47 riz Exp $ */ | 1 | /* $NetBSD: if_arcsubr.c,v 1.63.14.1.2.1 2017/02/05 05:47:28 snj 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.63.14.1 2012/10/23 16:19:47 riz Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.63.14.1.2.1 2017/02/05 05:47:28 snj Exp $"); | |
39 | 39 | |||
40 | #include "opt_inet.h" | 40 | #include "opt_inet.h" | |
41 | 41 | |||
42 | 42 | |||
43 | #include <sys/param.h> | 43 | #include <sys/param.h> | |
44 | #include <sys/systm.h> | 44 | #include <sys/systm.h> | |
45 | #include <sys/kernel.h> | 45 | #include <sys/kernel.h> | |
46 | #include <sys/malloc.h> | 46 | #include <sys/malloc.h> | |
47 | #include <sys/mbuf.h> | 47 | #include <sys/mbuf.h> | |
48 | #include <sys/protosw.h> | 48 | #include <sys/protosw.h> | |
49 | #include <sys/socket.h> | 49 | #include <sys/socket.h> | |
50 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> | |
51 | #include <sys/errno.h> | 51 | #include <sys/errno.h> | |
@@ -186,28 +186,30 @@ arc_output(struct ifnet *ifp, struct mbu | @@ -186,28 +186,30 @@ arc_output(struct ifnet *ifp, struct mbu | |||
186 | newencoding = 1; | 186 | newencoding = 1; | |
187 | } else { | 187 | } else { | |
188 | atype = ARCTYPE_IP_OLD; | 188 | atype = ARCTYPE_IP_OLD; | |
189 | newencoding = 0; | 189 | newencoding = 0; | |
190 | } | 190 | } | |
191 | break; | 191 | break; | |
192 | 192 | |||
193 | case AF_ARP: | 193 | case AF_ARP: | |
194 | arph = mtod(m, struct arphdr *); | 194 | arph = mtod(m, struct arphdr *); | |
195 | if (m->m_flags & M_BCAST) | 195 | if (m->m_flags & M_BCAST) | |
196 | adst = arcbroadcastaddr; | 196 | adst = arcbroadcastaddr; | |
197 | else { | 197 | else { | |
198 | uint8_t *tha = ar_tha(arph); | 198 | uint8_t *tha = ar_tha(arph); | |
199 | if (tha == NULL) | 199 | if (tha == NULL) { | |
200 | m_freem(m); | |||
200 | return 0; | 201 | return 0; | |
202 | } | |||
201 | adst = *tha; | 203 | adst = *tha; | |
202 | } | 204 | } | |
203 | 205 | |||
204 | arph->ar_hrd = htons(ARPHRD_ARCNET); | 206 | arph->ar_hrd = htons(ARPHRD_ARCNET); | |
205 | 207 | |||
206 | switch (ntohs(arph->ar_op)) { | 208 | switch (ntohs(arph->ar_op)) { | |
207 | case ARPOP_REVREQUEST: | 209 | case ARPOP_REVREQUEST: | |
208 | case ARPOP_REVREPLY: | 210 | case ARPOP_REVREPLY: | |
209 | if (!(ifp->if_flags & IFF_LINK0)) { | 211 | if (!(ifp->if_flags & IFF_LINK0)) { | |
210 | printf("%s: can't handle af%d\n", | 212 | printf("%s: can't handle af%d\n", | |
211 | ifp->if_xname, dst->sa_family); | 213 | ifp->if_xname, dst->sa_family); | |
212 | senderr(EAFNOSUPPORT); | 214 | senderr(EAFNOSUPPORT); | |
213 | } | 215 | } |
--- src/sys/net/Attic/if_ecosubr.c 2011/11/20 12:15:38 1.36
+++ src/sys/net/Attic/if_ecosubr.c 2017/02/05 05:47:28 1.36.18.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_ecosubr.c,v 1.36 2011/11/20 12:15:38 kiyohara Exp $ */ | 1 | /* $NetBSD: if_ecosubr.c,v 1.36.18.1 2017/02/05 05:47:28 snj 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.36 2011/11/20 12:15:38 kiyohara Exp $"); | 61 | __KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.36.18.1 2017/02/05 05:47:28 snj Exp $"); | |
62 | 62 | |||
63 | #include "opt_inet.h" | 63 | #include "opt_inet.h" | |
64 | #include "opt_pfil_hooks.h" | 64 | #include "opt_pfil_hooks.h" | |
65 | 65 | |||
66 | #include <sys/param.h> | 66 | #include <sys/param.h> | |
67 | #include <sys/errno.h> | 67 | #include <sys/errno.h> | |
68 | #include <sys/kernel.h> | 68 | #include <sys/kernel.h> | |
69 | #include <sys/socket.h> | 69 | #include <sys/socket.h> | |
70 | #include <sys/sockio.h> | 70 | #include <sys/sockio.h> | |
71 | #include <sys/syslog.h> | 71 | #include <sys/syslog.h> | |
72 | #include <sys/systm.h> | 72 | #include <sys/systm.h> | |
73 | 73 | |||
74 | #include <net/if.h> | 74 | #include <net/if.h> | |
@@ -232,47 +232,52 @@ eco_output(struct ifnet *ifp, struct mbu | @@ -232,47 +232,52 @@ eco_output(struct ifnet *ifp, struct mbu | |||
232 | 232 | |||
233 | else if (!arpresolve(ifp, rt, m, dst, ehdr.eco_dhost)) | 233 | else if (!arpresolve(ifp, rt, m, dst, ehdr.eco_dhost)) | |
234 | return (0); /* if not yet resolved */ | 234 | return (0); /* if not yet resolved */ | |
235 | /* If broadcasting on a simplex interface, loopback a copy */ | 235 | /* If broadcasting on a simplex interface, loopback a copy */ | |
236 | if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX)) | 236 | if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX)) | |
237 | mcopy = m_copy(m, 0, (int)M_COPYALL); | 237 | mcopy = m_copy(m, 0, (int)M_COPYALL); | |
238 | ehdr.eco_port = ECO_PORT_IP; | 238 | ehdr.eco_port = ECO_PORT_IP; | |
239 | ehdr.eco_control = ECO_CTL_IP; | 239 | ehdr.eco_control = ECO_CTL_IP; | |
240 | break; | 240 | break; | |
241 | 241 | |||
242 | case AF_ARP: | 242 | case AF_ARP: | |
243 | ah = mtod(m, struct arphdr *); | 243 | ah = mtod(m, struct arphdr *); | |
244 | 244 | |||
245 | if (ntohs(ah->ar_pro) != ETHERTYPE_IP) | 245 | if (ntohs(ah->ar_pro) != ETHERTYPE_IP) { | |
246 | return EAFNOSUPPORT; | 246 | error = EAFNOSUPPORT; | |
247 | goto bad; | |||
248 | } | |||
247 | ehdr.eco_port = ECO_PORT_IP; | 249 | ehdr.eco_port = ECO_PORT_IP; | |
248 | switch (ntohs(ah->ar_op)) { | 250 | switch (ntohs(ah->ar_op)) { | |
249 | case ARPOP_REQUEST: | 251 | case ARPOP_REQUEST: | |
250 | ehdr.eco_control = ECO_CTL_ARP_REQUEST; | 252 | ehdr.eco_control = ECO_CTL_ARP_REQUEST; | |
251 | break; | 253 | break; | |
252 | case ARPOP_REPLY: | 254 | case ARPOP_REPLY: | |
253 | ehdr.eco_control = ECO_CTL_ARP_REPLY; | 255 | ehdr.eco_control = ECO_CTL_ARP_REPLY; | |
254 | break; | 256 | break; | |
255 | default: | 257 | default: | |
256 | return EOPNOTSUPP; | 258 | error = EOPNOTSUPP; | |
259 | goto bad; | |||
257 | } | 260 | } | |
258 | 261 | |||
259 | if (m->m_flags & M_BCAST) | 262 | if (m->m_flags & M_BCAST) | |
260 | memcpy(ehdr.eco_dhost, eco_broadcastaddr, | 263 | memcpy(ehdr.eco_dhost, eco_broadcastaddr, | |
261 | ECO_ADDR_LEN); | 264 | ECO_ADDR_LEN); | |
262 | else { | 265 | else { | |
263 | tha = ar_tha(ah); | 266 | tha = ar_tha(ah); | |
264 | if (tha == NULL) | 267 | if (tha == NULL) { | |
268 | m_freem(m); | |||
265 | return 0; | 269 | return 0; | |
270 | } | |||
266 | memcpy(ehdr.eco_dhost, tha, ECO_ADDR_LEN); | 271 | memcpy(ehdr.eco_dhost, tha, ECO_ADDR_LEN); | |
267 | } | 272 | } | |
268 | 273 | |||
269 | MGETHDR(m1, M_DONTWAIT, MT_DATA); | 274 | MGETHDR(m1, M_DONTWAIT, MT_DATA); | |
270 | if (m1 == NULL) | 275 | if (m1 == NULL) | |
271 | senderr(ENOBUFS); | 276 | senderr(ENOBUFS); | |
272 | M_MOVE_PKTHDR(m1, m); | 277 | M_MOVE_PKTHDR(m1, m); | |
273 | m1->m_len = sizeof(*ecah); | 278 | m1->m_len = sizeof(*ecah); | |
274 | m1->m_pkthdr.len = m1->m_len; | 279 | m1->m_pkthdr.len = m1->m_len; | |
275 | MH_ALIGN(m1, m1->m_len); | 280 | MH_ALIGN(m1, m1->m_len); | |
276 | ecah = mtod(m1, struct eco_arp *); | 281 | ecah = mtod(m1, struct eco_arp *); | |
277 | memset(ecah, 0, m1->m_len); | 282 | memset(ecah, 0, m1->m_len); | |
278 | memcpy(ecah->ecar_spa, ar_spa(ah), ah->ar_pln); | 283 | memcpy(ecah->ecar_spa, ar_spa(ah), ah->ar_pln); |
--- src/sys/net/if_ethersubr.c 2014/06/18 09:34:27 1.188.8.3.2.1
+++ src/sys/net/if_ethersubr.c 2017/02/05 05:47:28 1.188.8.3.2.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_ethersubr.c,v 1.188.8.3.2.1 2014/06/18 09:34:27 msaitoh Exp $ */ | 1 | /* $NetBSD: if_ethersubr.c,v 1.188.8.3.2.2 2017/02/05 05:47:28 snj 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.188.8.3.2.1 2014/06/18 09:34:27 msaitoh Exp $"); | 64 | __KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.188.8.3.2.2 2017/02/05 05:47:28 snj Exp $"); | |
65 | 65 | |||
66 | #include "opt_inet.h" | 66 | #include "opt_inet.h" | |
67 | #include "opt_atalk.h" | 67 | #include "opt_atalk.h" | |
68 | #include "opt_iso.h" | 68 | #include "opt_iso.h" | |
69 | #include "opt_ipx.h" | 69 | #include "opt_ipx.h" | |
70 | #include "opt_mbuftrace.h" | 70 | #include "opt_mbuftrace.h" | |
71 | #include "opt_mpls.h" | 71 | #include "opt_mpls.h" | |
72 | #include "opt_gateway.h" | 72 | #include "opt_gateway.h" | |
73 | #include "opt_pfil_hooks.h" | 73 | #include "opt_pfil_hooks.h" | |
74 | #include "opt_pppoe.h" | 74 | #include "opt_pppoe.h" | |
75 | #include "vlan.h" | 75 | #include "vlan.h" | |
76 | #include "pppoe.h" | 76 | #include "pppoe.h" | |
77 | #include "bridge.h" | 77 | #include "bridge.h" | |
@@ -297,26 +297,27 @@ ether_output(struct ifnet * const ifp0, | @@ -297,26 +297,27 @@ ether_output(struct ifnet * const ifp0, | |||
297 | mcopy = m_copy(m, 0, (int)M_COPYALL); | 297 | mcopy = m_copy(m, 0, (int)M_COPYALL); | |
298 | etype = htons(ETHERTYPE_IP); | 298 | etype = htons(ETHERTYPE_IP); | |
299 | break; | 299 | break; | |
300 | 300 | |||
301 | case AF_ARP: | 301 | case AF_ARP: | |
302 | ah = mtod(m, struct arphdr *); | 302 | ah = mtod(m, struct arphdr *); | |
303 | if (m->m_flags & M_BCAST) | 303 | if (m->m_flags & M_BCAST) | |
304 | (void)memcpy(edst, etherbroadcastaddr, sizeof(edst)); | 304 | (void)memcpy(edst, etherbroadcastaddr, sizeof(edst)); | |
305 | else { | 305 | else { | |
306 | void *tha = ar_tha(ah); | 306 | void *tha = ar_tha(ah); | |
307 | 307 | |||
308 | if (tha == NULL) { | 308 | if (tha == NULL) { | |
309 | /* fake with ARPHDR_IEEE1394 */ | 309 | /* fake with ARPHDR_IEEE1394 */ | |
310 | m_freem(m); | |||
310 | return 0; | 311 | return 0; | |
311 | } | 312 | } | |
312 | memcpy(edst, tha, sizeof(edst)); | 313 | memcpy(edst, tha, sizeof(edst)); | |
313 | } | 314 | } | |
314 | 315 | |||
315 | ah->ar_hrd = htons(ARPHRD_ETHER); | 316 | ah->ar_hrd = htons(ARPHRD_ETHER); | |
316 | 317 | |||
317 | switch (ntohs(ah->ar_op)) { | 318 | switch (ntohs(ah->ar_op)) { | |
318 | case ARPOP_REVREQUEST: | 319 | case ARPOP_REVREQUEST: | |
319 | case ARPOP_REVREPLY: | 320 | case ARPOP_REVREPLY: | |
320 | etype = htons(ETHERTYPE_REVARP); | 321 | etype = htons(ETHERTYPE_REVARP); | |
321 | break; | 322 | break; | |
322 | 323 |
--- src/sys/net/Attic/if_fddisubr.c 2012/10/31 16:07:46 1.81.14.1
+++ src/sys/net/Attic/if_fddisubr.c 2017/02/05 05:47:28 1.81.14.1.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_fddisubr.c,v 1.81.14.1 2012/10/31 16:07:46 riz Exp $ */ | 1 | /* $NetBSD: if_fddisubr.c,v 1.81.14.1.2.1 2017/02/05 05:47:28 snj 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.81.14.1 2012/10/31 16:07:46 riz Exp $"); | 99 | __KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.81.14.1.2.1 2017/02/05 05:47:28 snj Exp $"); | |
100 | 100 | |||
101 | #include "opt_gateway.h" | 101 | #include "opt_gateway.h" | |
102 | #include "opt_inet.h" | 102 | #include "opt_inet.h" | |
103 | #include "opt_atalk.h" | 103 | #include "opt_atalk.h" | |
104 | #include "opt_iso.h" | 104 | #include "opt_iso.h" | |
105 | #include "opt_ipx.h" | 105 | #include "opt_ipx.h" | |
106 | #include "opt_mbuftrace.h" | 106 | #include "opt_mbuftrace.h" | |
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> | |
@@ -293,28 +293,30 @@ fddi_output(struct ifnet *ifp0, struct m | @@ -293,28 +293,30 @@ fddi_output(struct ifnet *ifp0, struct m | |||
293 | /* something bad happened */ | 293 | /* something bad happened */ | |
294 | return (0); | 294 | return (0); | |
295 | } | 295 | } | |
296 | etype = htons(ETHERTYPE_IPV6); | 296 | etype = htons(ETHERTYPE_IPV6); | |
297 | break; | 297 | break; | |
298 | #endif | 298 | #endif | |
299 | #ifdef AF_ARP | 299 | #ifdef AF_ARP | |
300 | case AF_ARP: { | 300 | case AF_ARP: { | |
301 | struct arphdr *ah = mtod(m, struct arphdr *); | 301 | struct arphdr *ah = mtod(m, struct arphdr *); | |
302 | if (m->m_flags & M_BCAST) | 302 | if (m->m_flags & M_BCAST) | |
303 | memcpy(edst, etherbroadcastaddr, sizeof(edst)); | 303 | memcpy(edst, etherbroadcastaddr, sizeof(edst)); | |
304 | else { | 304 | else { | |
305 | void *tha = ar_tha(ah); | 305 | void *tha = ar_tha(ah); | |
306 | if (tha == NULL) | 306 | if (tha == NULL) { | |
307 | m_freem(m); | |||
307 | return 0; | 308 | return 0; | |
309 | } | |||
308 | memcpy(edst, tha, sizeof(edst)); | 310 | memcpy(edst, tha, sizeof(edst)); | |
309 | } | 311 | } | |
310 | 312 | |||
311 | ah->ar_hrd = htons(ARPHRD_ETHER); | 313 | ah->ar_hrd = htons(ARPHRD_ETHER); | |
312 | 314 | |||
313 | switch (ntohs(ah->ar_op)) { | 315 | switch (ntohs(ah->ar_op)) { | |
314 | case ARPOP_REVREQUEST: | 316 | case ARPOP_REVREQUEST: | |
315 | case ARPOP_REVREPLY: | 317 | case ARPOP_REVREPLY: | |
316 | etype = htons(ETHERTYPE_REVARP); | 318 | etype = htons(ETHERTYPE_REVARP); | |
317 | break; | 319 | break; | |
318 | 320 | |||
319 | case ARPOP_REQUEST: | 321 | case ARPOP_REQUEST: | |
320 | case ARPOP_REPLY: | 322 | case ARPOP_REPLY: |
--- src/sys/net/Attic/if_tokensubr.c 2011/07/19 19:42:27 1.61
+++ src/sys/net/Attic/if_tokensubr.c 2017/02/05 05:47:28 1.61.18.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_tokensubr.c,v 1.61 2011/07/19 19:42:27 tron Exp $ */ | 1 | /* $NetBSD: if_tokensubr.c,v 1.61.18.1 2017/02/05 05:47:28 snj 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.61 2011/07/19 19:42:27 tron Exp $"); | 95 | __KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.61.18.1 2017/02/05 05:47:28 snj Exp $"); | |
96 | 96 | |||
97 | #include "opt_inet.h" | 97 | #include "opt_inet.h" | |
98 | #include "opt_atalk.h" | 98 | #include "opt_atalk.h" | |
99 | #include "opt_iso.h" | 99 | #include "opt_iso.h" | |
100 | #include "opt_gateway.h" | 100 | #include "opt_gateway.h" | |
101 | 101 | |||
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/protosw.h> | 108 | #include <sys/protosw.h> | |
@@ -295,28 +295,30 @@ token_output(struct ifnet *ifp0, struct | @@ -295,28 +295,30 @@ token_output(struct ifnet *ifp0, struct | |||
295 | if (m->m_flags & M_BCAST) { | 295 | if (m->m_flags & M_BCAST) { | |
296 | if (ifp->if_flags & IFF_LINK0) { | 296 | if (ifp->if_flags & IFF_LINK0) { | |
297 | if (ifp->if_flags & IFF_LINK1) | 297 | if (ifp->if_flags & IFF_LINK1) | |
298 | bcastrif.tr_rcf = htons(RCF_ALLROUTES); | 298 | bcastrif.tr_rcf = htons(RCF_ALLROUTES); | |
299 | else | 299 | else | |
300 | bcastrif.tr_rcf = htons(RCF_SINGLEROUTE); | 300 | bcastrif.tr_rcf = htons(RCF_SINGLEROUTE); | |
301 | rif = &bcastrif; | 301 | rif = &bcastrif; | |
302 | riflen = sizeof(rif->tr_rcf); | 302 | riflen = sizeof(rif->tr_rcf); | |
303 | } | 303 | } | |
304 | memcpy(edst, tokenbroadcastaddr, sizeof(edst)); | 304 | memcpy(edst, tokenbroadcastaddr, sizeof(edst)); | |
305 | } | 305 | } | |
306 | else { | 306 | else { | |
307 | void *tha = ar_tha(ah); | 307 | void *tha = ar_tha(ah); | |
308 | if (tha == NULL) | 308 | if (tha == NULL) { | |
309 | m_freem(m); | |||
309 | return 0; | 310 | return 0; | |
311 | } | |||
310 | memcpy(edst, tha, sizeof(edst)); | 312 | memcpy(edst, tha, sizeof(edst)); | |
311 | trh = (struct token_header *)M_TRHSTART(m); | 313 | trh = (struct token_header *)M_TRHSTART(m); | |
312 | trh->token_ac = TOKEN_AC; | 314 | trh->token_ac = TOKEN_AC; | |
313 | trh->token_fc = TOKEN_FC; | 315 | trh->token_fc = TOKEN_FC; | |
314 | if (trh->token_shost[0] & TOKEN_RI_PRESENT) { | 316 | if (trh->token_shost[0] & TOKEN_RI_PRESENT) { | |
315 | struct token_rif *trrif; | 317 | struct token_rif *trrif; | |
316 | 318 | |||
317 | trrif = TOKEN_RIF(trh); | 319 | trrif = TOKEN_RIF(trh); | |
318 | riflen = (ntohs(trrif->tr_rcf) & TOKEN_RCF_LEN_MASK) >> 8; | 320 | riflen = (ntohs(trrif->tr_rcf) & TOKEN_RCF_LEN_MASK) >> 8; | |
319 | } | 321 | } | |
320 | memcpy((void *)trh->token_dhost, (void *)edst, | 322 | memcpy((void *)trh->token_dhost, (void *)edst, | |
321 | sizeof (edst)); | 323 | sizeof (edst)); | |
322 | memcpy((void *)trh->token_shost, CLLADDR(ifp->if_sadl), | 324 | memcpy((void *)trh->token_shost, CLLADDR(ifp->if_sadl), |