arpresolve() now returns 0 on success otherwise an error code. Callers of arpresolve() now pass the error code back to their caller, masking out EWOULDBLOCK. This allows applications such as ping(8) to display a suitable error condition.diff -r1.68 -r1.69 src/sys/net/if_arcsubr.c
(roy)
--- src/sys/net/if_arcsubr.c 2015/08/24 22:21:26 1.68
+++ src/sys/net/if_arcsubr.c 2015/10/13 12:33:07 1.69
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_arcsubr.c,v 1.68 2015/08/24 22:21:26 pooka Exp $ */ | 1 | /* $NetBSD: if_arcsubr.c,v 1.69 2015/10/13 12:33:07 roy 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.68 2015/08/24 22:21:26 pooka Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.69 2015/10/13 12:33:07 roy 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/protosw.h> | 49 | #include <sys/protosw.h> | |
50 | #include <sys/socket.h> | 50 | #include <sys/socket.h> | |
51 | #include <sys/ioctl.h> | 51 | #include <sys/ioctl.h> | |
@@ -141,28 +141,28 @@ arc_output(struct ifnet *ifp, struct mbu | @@ -141,28 +141,28 @@ arc_output(struct ifnet *ifp, struct mbu | |||
141 | IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); | 141 | IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); | |
142 | 142 | |||
143 | switch (dst->sa_family) { | 143 | switch (dst->sa_family) { | |
144 | #ifdef INET | 144 | #ifdef INET | |
145 | case AF_INET: | 145 | case AF_INET: | |
146 | 146 | |||
147 | /* | 147 | /* | |
148 | * For now, use the simple IP addr -> ARCnet addr mapping | 148 | * For now, use the simple IP addr -> ARCnet addr mapping | |
149 | */ | 149 | */ | |
150 | if (m->m_flags & (M_BCAST|M_MCAST)) | 150 | if (m->m_flags & (M_BCAST|M_MCAST)) | |
151 | adst = arcbroadcastaddr; /* ARCnet broadcast address */ | 151 | adst = arcbroadcastaddr; /* ARCnet broadcast address */ | |
152 | else if (ifp->if_flags & IFF_NOARP) | 152 | else if (ifp->if_flags & IFF_NOARP) | |
153 | adst = ntohl(satocsin(dst)->sin_addr.s_addr) & 0xFF; | 153 | adst = ntohl(satocsin(dst)->sin_addr.s_addr) & 0xFF; | |
154 | else if (!arpresolve(ifp, rt, m, dst, &adst)) | 154 | else if ((error = arpresolve(ifp, rt, m, dst, &adst)) != 0) | |
155 | return 0; /* not resolved yet */ | 155 | return error == EWOULDBLOCK ? 0 : error; | |
156 | 156 | |||
157 | /* If broadcasting on a simplex interface, loopback a copy */ | 157 | /* If broadcasting on a simplex interface, loopback a copy */ | |
158 | if ((m->m_flags & (M_BCAST|M_MCAST)) && | 158 | if ((m->m_flags & (M_BCAST|M_MCAST)) && | |
159 | (ifp->if_flags & IFF_SIMPLEX)) | 159 | (ifp->if_flags & IFF_SIMPLEX)) | |
160 | mcopy = m_copy(m, 0, (int)M_COPYALL); | 160 | mcopy = m_copy(m, 0, (int)M_COPYALL); | |
161 | if (ifp->if_flags & IFF_LINK0) { | 161 | if (ifp->if_flags & IFF_LINK0) { | |
162 | atype = ARCTYPE_IP; | 162 | atype = ARCTYPE_IP; | |
163 | newencoding = 1; | 163 | newencoding = 1; | |
164 | } else { | 164 | } else { | |
165 | atype = ARCTYPE_IP_OLD; | 165 | atype = ARCTYPE_IP_OLD; | |
166 | newencoding = 0; | 166 | newencoding = 0; | |
167 | } | 167 | } | |
168 | break; | 168 | break; |
--- src/sys/net/if_ethersubr.c 2015/08/31 08:05:20 1.213
+++ src/sys/net/if_ethersubr.c 2015/10/13 12:33:07 1.214
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_ethersubr.c,v 1.213 2015/08/31 08:05:20 ozaki-r Exp $ */ | 1 | /* $NetBSD: if_ethersubr.c,v 1.214 2015/10/13 12:33:07 roy 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.213 2015/08/31 08:05:20 ozaki-r Exp $"); | 64 | __KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.214 2015/10/13 12:33:07 roy 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" | |
@@ -232,28 +232,28 @@ ether_output(struct ifnet * const ifp0, | @@ -232,28 +232,28 @@ ether_output(struct ifnet * const ifp0, | |||
232 | #endif /* NCARP > 0 */ | 232 | #endif /* NCARP > 0 */ | |
233 | 233 | |||
234 | if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) | 234 | if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) | |
235 | senderr(ENETDOWN); | 235 | senderr(ENETDOWN); | |
236 | 236 | |||
237 | switch (dst->sa_family) { | 237 | switch (dst->sa_family) { | |
238 | 238 | |||
239 | #ifdef INET | 239 | #ifdef INET | |
240 | case AF_INET: | 240 | case AF_INET: | |
241 | if (m->m_flags & M_BCAST) | 241 | if (m->m_flags & M_BCAST) | |
242 | (void)memcpy(edst, etherbroadcastaddr, sizeof(edst)); | 242 | (void)memcpy(edst, etherbroadcastaddr, sizeof(edst)); | |
243 | else if (m->m_flags & M_MCAST) | 243 | else if (m->m_flags & M_MCAST) | |
244 | ETHER_MAP_IP_MULTICAST(&satocsin(dst)->sin_addr, edst); | 244 | ETHER_MAP_IP_MULTICAST(&satocsin(dst)->sin_addr, edst); | |
245 | else if (!arpresolve(ifp, rt, m, dst, edst)) | 245 | else if ((error = arpresolve(ifp, rt, m, dst, edst)) != 0) | |
246 | return 0; /* if not yet resolved */ | 246 | return error == EWOULDBLOCK ? 0 : error; | |
247 | /* If broadcasting on a simplex interface, loopback a copy */ | 247 | /* If broadcasting on a simplex interface, loopback a copy */ | |
248 | if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX)) | 248 | if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX)) | |
249 | mcopy = m_copy(m, 0, (int)M_COPYALL); | 249 | mcopy = m_copy(m, 0, (int)M_COPYALL); | |
250 | etype = htons(ETHERTYPE_IP); | 250 | etype = htons(ETHERTYPE_IP); | |
251 | break; | 251 | break; | |
252 | 252 | |||
253 | case AF_ARP: | 253 | case AF_ARP: | |
254 | ah = mtod(m, struct arphdr *); | 254 | ah = mtod(m, struct arphdr *); | |
255 | if (m->m_flags & M_BCAST) | 255 | if (m->m_flags & M_BCAST) | |
256 | (void)memcpy(edst, etherbroadcastaddr, sizeof(edst)); | 256 | (void)memcpy(edst, etherbroadcastaddr, sizeof(edst)); | |
257 | else { | 257 | else { | |
258 | void *tha = ar_tha(ah); | 258 | void *tha = ar_tha(ah); | |
259 | 259 | |||
@@ -281,27 +281,27 @@ ether_output(struct ifnet * const ifp0, | @@ -281,27 +281,27 @@ ether_output(struct ifnet * const ifp0, | |||
281 | break; | 281 | break; | |
282 | #endif | 282 | #endif | |
283 | #ifdef INET6 | 283 | #ifdef INET6 | |
284 | case AF_INET6: | 284 | case AF_INET6: | |
285 | if (!nd6_storelladdr(ifp, rt, m, dst, edst, sizeof(edst))){ | 285 | if (!nd6_storelladdr(ifp, rt, m, dst, edst, sizeof(edst))){ | |
286 | /* something bad happened */ | 286 | /* something bad happened */ | |
287 | return (0); | 287 | return (0); | |
288 | } | 288 | } | |
289 | etype = htons(ETHERTYPE_IPV6); | 289 | etype = htons(ETHERTYPE_IPV6); | |
290 | break; | 290 | break; | |
291 | #endif | 291 | #endif | |
292 | #ifdef NETATALK | 292 | #ifdef NETATALK | |
293 | case AF_APPLETALK: | 293 | case AF_APPLETALK: | |
294 | if (!aarpresolve(ifp, m, (const struct sockaddr_at *)dst, edst)) { | 294 | if (aarpresolve(ifp, m, (const struct sockaddr_at *)dst, edst)) { | |
295 | #ifdef NETATALKDEBUG | 295 | #ifdef NETATALKDEBUG | |
296 | printf("aarpresolv failed\n"); | 296 | printf("aarpresolv failed\n"); | |
297 | #endif /* NETATALKDEBUG */ | 297 | #endif /* NETATALKDEBUG */ | |
298 | return (0); | 298 | return (0); | |
299 | } | 299 | } | |
300 | /* | 300 | /* | |
301 | * ifaddr is the first thing in at_ifaddr | 301 | * ifaddr is the first thing in at_ifaddr | |
302 | */ | 302 | */ | |
303 | aa = (struct at_ifaddr *) at_ifawithnet( | 303 | aa = (struct at_ifaddr *) at_ifawithnet( | |
304 | (const struct sockaddr_at *)dst, ifp); | 304 | (const struct sockaddr_at *)dst, ifp); | |
305 | if (aa == NULL) | 305 | if (aa == NULL) | |
306 | goto bad; | 306 | goto bad; | |
307 | 307 |
--- src/sys/net/Attic/if_fddisubr.c 2015/09/30 06:25:59 1.94
+++ src/sys/net/Attic/if_fddisubr.c 2015/10/13 12:33:07 1.95
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_fddisubr.c,v 1.94 2015/09/30 06:25:59 ozaki-r Exp $ */ | 1 | /* $NetBSD: if_fddisubr.c,v 1.95 2015/10/13 12:33:07 roy 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.94 2015/09/30 06:25:59 ozaki-r Exp $"); | 99 | __KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.95 2015/10/13 12:33:07 roy 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> | |
@@ -225,28 +225,28 @@ fddi_output(struct ifnet *ifp0, struct m | @@ -225,28 +225,28 @@ fddi_output(struct ifnet *ifp0, struct m | |||
225 | * do it before prepending link headers. | 225 | * do it before prepending link headers. | |
226 | */ | 226 | */ | |
227 | IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); | 227 | IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); | |
228 | 228 | |||
229 | switch (dst->sa_family) { | 229 | switch (dst->sa_family) { | |
230 | 230 | |||
231 | #ifdef INET | 231 | #ifdef INET | |
232 | case AF_INET: { | 232 | case AF_INET: { | |
233 | if (m->m_flags & M_BCAST) | 233 | if (m->m_flags & M_BCAST) | |
234 | memcpy(edst, fddibroadcastaddr, sizeof(edst)); | 234 | memcpy(edst, fddibroadcastaddr, sizeof(edst)); | |
235 | else if (m->m_flags & M_MCAST) { | 235 | else if (m->m_flags & M_MCAST) { | |
236 | ETHER_MAP_IP_MULTICAST(&satocsin(dst)->sin_addr, | 236 | ETHER_MAP_IP_MULTICAST(&satocsin(dst)->sin_addr, | |
237 | (char *)edst); | 237 | (char *)edst); | |
238 | } else if (!arpresolve(ifp, rt, m, dst, edst)) | 238 | } else if ((error = arpresolve(ifp, rt, m, dst, edst)) != 0) | |
239 | return (0); /* if not yet resolved */ | 239 | return error == EWOULDBLOCK ? 0 : error; | |
240 | /* If broadcasting on a simplex interface, loopback a copy */ | 240 | /* If broadcasting on a simplex interface, loopback a copy */ | |
241 | if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX)) | 241 | if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX)) | |
242 | mcopy = m_copy(m, 0, (int)M_COPYALL); | 242 | mcopy = m_copy(m, 0, (int)M_COPYALL); | |
243 | etype = htons(ETHERTYPE_IP); | 243 | etype = htons(ETHERTYPE_IP); | |
244 | break; | 244 | break; | |
245 | } | 245 | } | |
246 | #endif | 246 | #endif | |
247 | #ifdef INET6 | 247 | #ifdef INET6 | |
248 | case AF_INET6: | 248 | case AF_INET6: | |
249 | if (!nd6_storelladdr(ifp, rt, m, dst, edst, sizeof(edst))){ | 249 | if (!nd6_storelladdr(ifp, rt, m, dst, edst, sizeof(edst))){ | |
250 | /* something bad happened */ | 250 | /* something bad happened */ | |
251 | return (0); | 251 | return (0); | |
252 | } | 252 | } |
--- src/sys/net/if_ieee1394subr.c 2015/08/24 22:21:26 1.50
+++ src/sys/net/if_ieee1394subr.c 2015/10/13 12:33:07 1.51
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_ieee1394subr.c,v 1.50 2015/08/24 22:21:26 pooka Exp $ */ | 1 | /* $NetBSD: if_ieee1394subr.c,v 1.51 2015/10/13 12:33:07 roy Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Atsushi Onoe. | 8 | * by Atsushi Onoe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.50 2015/08/24 22:21:26 pooka Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.51 2015/10/13 12:33:07 roy Exp $"); | |
34 | 34 | |||
35 | #ifdef _KERNEL_OPT | 35 | #ifdef _KERNEL_OPT | |
36 | #include "opt_inet.h" | 36 | #include "opt_inet.h" | |
37 | #endif | 37 | #endif | |
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
41 | #include <sys/bus.h> | 41 | #include <sys/bus.h> | |
42 | #include <sys/device.h> | 42 | #include <sys/device.h> | |
43 | #include <sys/kernel.h> | 43 | #include <sys/kernel.h> | |
44 | #include <sys/mbuf.h> | 44 | #include <sys/mbuf.h> | |
45 | #include <sys/socket.h> | 45 | #include <sys/socket.h> | |
46 | #include <sys/sockio.h> | 46 | #include <sys/sockio.h> | |
@@ -128,28 +128,29 @@ ieee1394_output(struct ifnet *ifp, struc | @@ -128,28 +128,29 @@ ieee1394_output(struct ifnet *ifp, struc | |||
128 | error = ENOMEM; | 128 | error = ENOMEM; | |
129 | goto bad; | 129 | goto bad; | |
130 | } | 130 | } | |
131 | m_tag_prepend(m0, mtag); | 131 | m_tag_prepend(m0, mtag); | |
132 | } | 132 | } | |
133 | hwdst = (struct ieee1394_hwaddr *)(mtag + 1); | 133 | hwdst = (struct ieee1394_hwaddr *)(mtag + 1); | |
134 | } else { | 134 | } else { | |
135 | hwdst = &baddr; | 135 | hwdst = &baddr; | |
136 | } | 136 | } | |
137 | 137 | |||
138 | switch (dst->sa_family) { | 138 | switch (dst->sa_family) { | |
139 | #ifdef INET | 139 | #ifdef INET | |
140 | case AF_INET: | 140 | case AF_INET: | |
141 | if (unicast && (!arpresolve(ifp, rt, m0, dst, (u_char *)hwdst))) | 141 | if (unicast && | |
142 | return 0; /* if not yet resolved */ | 142 | (error = arpresolve(ifp, rt, m0, dst, (u_char *)hwdst)) !=0) | |
143 | return error == EWOULDBLOCK ? 0 : error; | |||
143 | /* if broadcasting on a simplex interface, loopback a copy */ | 144 | /* if broadcasting on a simplex interface, loopback a copy */ | |
144 | if ((m0->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX)) | 145 | if ((m0->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX)) | |
145 | mcopy = m_copy(m0, 0, M_COPYALL); | 146 | mcopy = m_copy(m0, 0, M_COPYALL); | |
146 | etype = htons(ETHERTYPE_IP); | 147 | etype = htons(ETHERTYPE_IP); | |
147 | break; | 148 | break; | |
148 | case AF_ARP: | 149 | case AF_ARP: | |
149 | ah = mtod(m0, struct arphdr *); | 150 | ah = mtod(m0, struct arphdr *); | |
150 | ah->ar_hrd = htons(ARPHRD_IEEE1394); | 151 | ah->ar_hrd = htons(ARPHRD_IEEE1394); | |
151 | etype = htons(ETHERTYPE_ARP); | 152 | etype = htons(ETHERTYPE_ARP); | |
152 | break; | 153 | break; | |
153 | #endif /* INET */ | 154 | #endif /* INET */ | |
154 | #ifdef INET6 | 155 | #ifdef INET6 | |
155 | case AF_INET6: | 156 | case AF_INET6: |
--- src/sys/netinet/if_arp.c 2015/10/13 11:13:37 1.186
+++ src/sys/netinet/if_arp.c 2015/10/13 12:33:07 1.187
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_arp.c,v 1.186 2015/10/13 11:13:37 roy Exp $ */ | 1 | /* $NetBSD: if_arp.c,v 1.187 2015/10/13 12:33:07 roy Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Public Access Networks Corporation ("Panix"). It was developed under | 8 | * by Public Access Networks Corporation ("Panix"). It was developed under | |
9 | * contract to Panix by Eric Haszlakiewicz and Thor Lancelot Simon. | 9 | * contract to Panix by Eric Haszlakiewicz and Thor Lancelot Simon. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -58,27 +58,27 @@ | @@ -58,27 +58,27 @@ | |||
58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
59 | * SUCH DAMAGE. | 59 | * SUCH DAMAGE. | |
60 | * | 60 | * | |
61 | * @(#)if_ether.c 8.2 (Berkeley) 9/26/94 | 61 | * @(#)if_ether.c 8.2 (Berkeley) 9/26/94 | |
62 | */ | 62 | */ | |
63 | 63 | |||
64 | /* | 64 | /* | |
65 | * Ethernet address resolution protocol. | 65 | * Ethernet address resolution protocol. | |
66 | * TODO: | 66 | * TODO: | |
67 | * add "inuse/lock" bit (or ref. count) along with valid bit | 67 | * add "inuse/lock" bit (or ref. count) along with valid bit | |
68 | */ | 68 | */ | |
69 | 69 | |||
70 | #include <sys/cdefs.h> | 70 | #include <sys/cdefs.h> | |
71 | __KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.186 2015/10/13 11:13:37 roy Exp $"); | 71 | __KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.187 2015/10/13 12:33:07 roy Exp $"); | |
72 | 72 | |||
73 | #ifdef _KERNEL_OPT | 73 | #ifdef _KERNEL_OPT | |
74 | #include "opt_ddb.h" | 74 | #include "opt_ddb.h" | |
75 | #include "opt_inet.h" | 75 | #include "opt_inet.h" | |
76 | #endif | 76 | #endif | |
77 | 77 | |||
78 | #ifdef INET | 78 | #ifdef INET | |
79 | 79 | |||
80 | #include "bridge.h" | 80 | #include "bridge.h" | |
81 | 81 | |||
82 | #include <sys/param.h> | 82 | #include <sys/param.h> | |
83 | #include <sys/systm.h> | 83 | #include <sys/systm.h> | |
84 | #include <sys/callout.h> | 84 | #include <sys/callout.h> | |
@@ -770,30 +770,31 @@ arprequest(struct ifnet *ifp, | @@ -770,30 +770,31 @@ arprequest(struct ifnet *ifp, | |||
770 | m->m_flags |= M_BCAST; | 770 | m->m_flags |= M_BCAST; | |
771 | arps = ARP_STAT_GETREF(); | 771 | arps = ARP_STAT_GETREF(); | |
772 | arps[ARP_STAT_SNDTOTAL]++; | 772 | arps[ARP_STAT_SNDTOTAL]++; | |
773 | arps[ARP_STAT_SENDREQUEST]++; | 773 | arps[ARP_STAT_SENDREQUEST]++; | |
774 | ARP_STAT_PUTREF(); | 774 | ARP_STAT_PUTREF(); | |
775 | (*ifp->if_output)(ifp, m, &sa, NULL); | 775 | (*ifp->if_output)(ifp, m, &sa, NULL); | |
776 | } | 776 | } | |
777 | 777 | |||
778 | /* | 778 | /* | |
779 | * Resolve an IP address into an ethernet address. If success, | 779 | * Resolve an IP address into an ethernet address. If success, | |
780 | * desten is filled in. If there is no entry in arptab, | 780 | * desten is filled in. If there is no entry in arptab, | |
781 | * set one up and broadcast a request for the IP address. | 781 | * set one up and broadcast a request for the IP address. | |
782 | * Hold onto this mbuf and resend it once the address | 782 | * Hold onto this mbuf and resend it once the address | |
783 | * is finally resolved. A return value of 1 indicates | 783 | * is finally resolved. A return value of 0 indicates | |
784 | * that desten has been filled in and the packet should be sent | 784 | * that desten has been filled in and the packet should be sent | |
785 | * normally; a 0 return indicates that the packet has been | 785 | * normally; a return value of EWOULDBLOCK indicates that the packet has been | |
786 | * taken over here, either now or for later transmission. | 786 | * held pending resolution. | |
787 | * Any other value indicates an error. | |||
787 | */ | 788 | */ | |
788 | int | 789 | int | |
789 | arpresolve(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m, | 790 | arpresolve(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m, | |
790 | const struct sockaddr *dst, u_char *desten) | 791 | const struct sockaddr *dst, u_char *desten) | |
791 | { | 792 | { | |
792 | struct llentry *la; | 793 | struct llentry *la; | |
793 | const struct sockaddr_dl *sdl; | 794 | const struct sockaddr_dl *sdl; | |
794 | const char *create_lookup; | 795 | const char *create_lookup; | |
795 | bool renew; | 796 | bool renew; | |
796 | int error; | 797 | int error; | |
797 | 798 | |||
798 | KASSERT(m != NULL); | 799 | KASSERT(m != NULL); | |
799 | 800 | |||
@@ -803,86 +804,87 @@ arpresolve(struct ifnet *ifp, struct rte | @@ -803,86 +804,87 @@ arpresolve(struct ifnet *ifp, struct rte | |||
803 | 804 | |||
804 | rt = la->la_rt; | 805 | rt = la->la_rt; | |
805 | sdl = satocsdl(rt->rt_gateway); | 806 | sdl = satocsdl(rt->rt_gateway); | |
806 | /* | 807 | /* | |
807 | * Check the address family and length is valid, the address | 808 | * Check the address family and length is valid, the address | |
808 | * is resolved; otherwise, try to resolve. | 809 | * is resolved; otherwise, try to resolve. | |
809 | */ | 810 | */ | |
810 | if ((rt->rt_expire == 0 || rt->rt_expire > time_uptime) && | 811 | if ((rt->rt_expire == 0 || rt->rt_expire > time_uptime) && | |
811 | sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) { | 812 | sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) { | |
812 | memcpy(desten, CLLADDR(sdl), | 813 | memcpy(desten, CLLADDR(sdl), | |
813 | min(sdl->sdl_alen, ifp->if_addrlen)); | 814 | min(sdl->sdl_alen, ifp->if_addrlen)); | |
814 | rt->rt_pksent = time_uptime; /* Time for last pkt sent */ | 815 | rt->rt_pksent = time_uptime; /* Time for last pkt sent */ | |
815 | LLE_RUNLOCK(la); | 816 | LLE_RUNLOCK(la); | |
816 | return 1; | 817 | return 0; | |
817 | } | 818 | } | |
818 | 819 | |||
819 | /* | 820 | /* | |
820 | * Re-send the ARP request when appropriate. | 821 | * Re-send the ARP request when appropriate. | |
821 | */ | 822 | */ | |
822 | #ifdef DIAGNOSTIC | 823 | #ifdef DIAGNOSTIC | |
823 | if (rt->rt_expire == 0) { | 824 | if (rt->rt_expire == 0) { | |
824 | /* This should never happen. (Should it? -gwr) */ | 825 | /* This should never happen. (Should it? -gwr) */ | |
825 | printf("arpresolve: unresolved and rt_expire == 0\n"); | 826 | printf("arpresolve: unresolved and rt_expire == 0\n"); | |
826 | /* Set expiration time to now (expired). */ | 827 | /* Set expiration time to now (expired). */ | |
827 | rt->rt_expire = time_uptime; | 828 | rt->rt_expire = time_uptime; | |
828 | } | 829 | } | |
829 | #endif | 830 | #endif | |
830 | 831 | |||
831 | notfound: | 832 | notfound: | |
832 | #ifdef IFF_STATICARP /* FreeBSD */ | 833 | #ifdef IFF_STATICARP /* FreeBSD */ | |
833 | #define _IFF_NOARP (IFF_NOARP | IFF_STATICARP) | 834 | #define _IFF_NOARP (IFF_NOARP | IFF_STATICARP) | |
834 | #else | 835 | #else | |
835 | #define _IFF_NOARP IFF_NOARP | 836 | #define _IFF_NOARP IFF_NOARP | |
836 | #endif | 837 | #endif | |
837 | if (ifp->if_flags & _IFF_NOARP) { | 838 | if (ifp->if_flags & _IFF_NOARP) { | |
838 | if (la != NULL) | 839 | if (la != NULL) | |
839 | LLE_RUNLOCK(la); | 840 | LLE_RUNLOCK(la); | |
840 | m_freem(m); | 841 | m_freem(m); | |
841 | return 0; | 842 | return ENOTSUP; | |
842 | } | 843 | } | |
843 | #undef _IFF_NOARP | 844 | #undef _IFF_NOARP | |
844 | if (la == NULL) { | 845 | if (la == NULL) { | |
845 | create_lookup = "create"; | 846 | create_lookup = "create"; | |
846 | IF_AFDATA_WLOCK(ifp); | 847 | IF_AFDATA_WLOCK(ifp); | |
847 | la = lla_create(LLTABLE(ifp), LLE_EXCLUSIVE, dst); | 848 | la = lla_create(LLTABLE(ifp), LLE_EXCLUSIVE, dst); | |
848 | IF_AFDATA_WUNLOCK(ifp); | 849 | IF_AFDATA_WUNLOCK(ifp); | |
849 | if (la == NULL) | 850 | if (la == NULL) | |
850 | ARP_STATINC(ARP_STAT_ALLOCFAIL); | 851 | ARP_STATINC(ARP_STAT_ALLOCFAIL); | |
851 | } else if (LLE_TRY_UPGRADE(la) == 0) { | 852 | } else if (LLE_TRY_UPGRADE(la) == 0) { | |
852 | create_lookup = "lookup"; | 853 | create_lookup = "lookup"; | |
853 | LLE_RUNLOCK(la); | 854 | LLE_RUNLOCK(la); | |
854 | IF_AFDATA_RLOCK(ifp); | 855 | IF_AFDATA_RLOCK(ifp); | |
855 | la = lla_lookup(LLTABLE(ifp), LLE_EXCLUSIVE, dst); | 856 | la = lla_lookup(LLTABLE(ifp), LLE_EXCLUSIVE, dst); | |
856 | IF_AFDATA_RUNLOCK(ifp); | 857 | IF_AFDATA_RUNLOCK(ifp); | |
857 | } | 858 | } | |
858 | 859 | |||
859 | if (la == NULL) { | 860 | if (la == NULL) { | |
860 | log(LOG_DEBUG, | 861 | log(LOG_DEBUG, | |
861 | "%s: failed to %s llentry for %s on %s\n", | 862 | "%s: failed to %s llentry for %s on %s\n", | |
862 | __func__, create_lookup, inet_ntoa(satocsin(dst)->sin_addr), | 863 | __func__, create_lookup, inet_ntoa(satocsin(dst)->sin_addr), | |
863 | ifp->if_xname); | 864 | ifp->if_xname); | |
864 | m_freem(m); | 865 | m_freem(m); | |
865 | return 0; | 866 | return EINVAL; | |
866 | } | 867 | } | |
867 | 868 | |||
868 | /* Just in case */ | 869 | /* Just in case */ | |
869 | if (la->la_rt == NULL) { | 870 | if (la->la_rt == NULL) { | |
871 | LLE_WUNLOCK(la); | |||
870 | log(LOG_DEBUG, | 872 | log(LOG_DEBUG, | |
871 | "%s: valid llentry has no rtentry for %s on %s\n", | 873 | "%s: valid llentry has no rtentry for %s on %s\n", | |
872 | __func__, inet_ntoa(satocsin(dst)->sin_addr), | 874 | __func__, inet_ntoa(satocsin(dst)->sin_addr), | |
873 | ifp->if_xname); | 875 | ifp->if_xname); | |
874 | m_freem(m); | 876 | m_freem(m); | |
875 | return 0; | 877 | return EINVAL; | |
876 | } | 878 | } | |
877 | rt = la->la_rt; | 879 | rt = la->la_rt; | |
878 | 880 | |||
879 | if ((la->la_flags & LLE_VALID) && | 881 | if ((la->la_flags & LLE_VALID) && | |
880 | ((la->la_flags & LLE_STATIC) || la->la_expire > time_uptime)) | 882 | ((la->la_flags & LLE_STATIC) || la->la_expire > time_uptime)) | |
881 | { | 883 | { | |
882 | sdl = satocsdl(rt->rt_gateway); | 884 | sdl = satocsdl(rt->rt_gateway); | |
883 | memcpy(desten, CLLADDR(sdl), | 885 | memcpy(desten, CLLADDR(sdl), | |
884 | min(sdl->sdl_alen, ifp->if_addrlen)); | 886 | min(sdl->sdl_alen, ifp->if_addrlen)); | |
885 | renew = false; | 887 | renew = false; | |
886 | /* | 888 | /* | |
887 | * If entry has an expiry time and it is approaching, | 889 | * If entry has an expiry time and it is approaching, | |
888 | * see if we need to send an ARP request within this | 890 | * see if we need to send an ARP request within this | |
@@ -899,27 +901,27 @@ notfound: | @@ -899,27 +901,27 @@ notfound: | |||
899 | 901 | |||
900 | if (renew) { | 902 | if (renew) { | |
901 | const u_int8_t *enaddr = | 903 | const u_int8_t *enaddr = | |
902 | #if NCARP > 0 | 904 | #if NCARP > 0 | |
903 | (rt->rt_ifp->if_type == IFT_CARP) ? | 905 | (rt->rt_ifp->if_type == IFT_CARP) ? | |
904 | CLLADDR(rt->rt_ifp->if_sadl): | 906 | CLLADDR(rt->rt_ifp->if_sadl): | |
905 | #endif | 907 | #endif | |
906 | CLLADDR(ifp->if_sadl); | 908 | CLLADDR(ifp->if_sadl); | |
907 | arprequest(ifp, | 909 | arprequest(ifp, | |
908 | &satocsin(rt->rt_ifa->ifa_addr)->sin_addr, | 910 | &satocsin(rt->rt_ifa->ifa_addr)->sin_addr, | |
909 | &satocsin(dst)->sin_addr, enaddr); | 911 | &satocsin(dst)->sin_addr, enaddr); | |
910 | } | 912 | } | |
911 | 913 | |||
912 | return 1; | 914 | return 0; | |
913 | } | 915 | } | |
914 | 916 | |||
915 | if (la->la_flags & LLE_STATIC) { /* should not happen! */ | 917 | if (la->la_flags & LLE_STATIC) { /* should not happen! */ | |
916 | log(LOG_DEBUG, "arpresolve: ouch, empty static llinfo for %s\n", | 918 | log(LOG_DEBUG, "arpresolve: ouch, empty static llinfo for %s\n", | |
917 | inet_ntoa(satocsin(dst)->sin_addr)); | 919 | inet_ntoa(satocsin(dst)->sin_addr)); | |
918 | m_freem(m); | 920 | m_freem(m); | |
919 | error = EINVAL; | 921 | error = EINVAL; | |
920 | goto done; | 922 | goto done; | |
921 | } | 923 | } | |
922 | 924 | |||
923 | renew = (la->la_asked == 0 || la->la_expire != time_uptime); | 925 | renew = (la->la_asked == 0 || la->la_expire != time_uptime); | |
924 | 926 | |||
925 | /* | 927 | /* | |
@@ -967,32 +969,32 @@ notfound: | @@ -967,32 +969,32 @@ notfound: | |||
967 | (rt->rt_ifp->if_type == IFT_CARP) ? | 969 | (rt->rt_ifp->if_type == IFT_CARP) ? | |
968 | CLLADDR(rt->rt_ifp->if_sadl): | 970 | CLLADDR(rt->rt_ifp->if_sadl): | |
969 | #endif | 971 | #endif | |
970 | CLLADDR(ifp->if_sadl); | 972 | CLLADDR(ifp->if_sadl); | |
971 | LLE_ADDREF(la); | 973 | LLE_ADDREF(la); | |
972 | la->la_expire = time_uptime; | 974 | la->la_expire = time_uptime; | |
973 | callout_reset(&la->la_timer, hz * arpt_down, | 975 | callout_reset(&la->la_timer, hz * arpt_down, | |
974 | arptimer, la); | 976 | arptimer, la); | |
975 | la->la_asked++; | 977 | la->la_asked++; | |
976 | LLE_WUNLOCK(la); | 978 | LLE_WUNLOCK(la); | |
977 | 979 | |||
978 | arprequest(ifp, &satocsin(rt->rt_ifa->ifa_addr)->sin_addr, | 980 | arprequest(ifp, &satocsin(rt->rt_ifa->ifa_addr)->sin_addr, | |
979 | &satocsin(dst)->sin_addr, enaddr); | 981 | &satocsin(dst)->sin_addr, enaddr); | |
980 | return error == 0; | 982 | return error; | |
981 | } | 983 | } | |
982 | done: | 984 | done: | |
983 | LLE_RUNLOCK(la); | 985 | LLE_RUNLOCK(la); | |
984 | 986 | |||
985 | return error == 0; | 987 | return error; | |
986 | } | 988 | } | |
987 | 989 | |||
988 | /* | 990 | /* | |
989 | * Common length and type checks are done here, | 991 | * Common length and type checks are done here, | |
990 | * then the protocol-specific routine is called. | 992 | * then the protocol-specific routine is called. | |
991 | */ | 993 | */ | |
992 | void | 994 | void | |
993 | arpintr(void) | 995 | arpintr(void) | |
994 | { | 996 | { | |
995 | struct mbuf *m; | 997 | struct mbuf *m; | |
996 | struct arphdr *ar; | 998 | struct arphdr *ar; | |
997 | int s; | 999 | int s; | |
998 | int arplen; | 1000 | int arplen; |