| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ip_carp.c,v 1.43 2010/08/11 09:36:44 pooka Exp $ */ | | 1 | /* $NetBSD: ip_carp.c,v 1.44 2010/08/11 11:06:42 pooka Exp $ */ |
2 | /* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */ | | 2 | /* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 2002 Michael Shalayeff. All rights reserved. | | 5 | * Copyright (c) 2002 Michael Shalayeff. All rights reserved. |
6 | * Copyright (c) 2003 Ryan McBride. All rights reserved. | | 6 | * Copyright (c) 2003 Ryan McBride. 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 |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, | | 20 | * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, |
21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | | 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | | 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
23 | * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 23 | * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | | 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | | 25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | | 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
27 | * THE POSSIBILITY OF SUCH DAMAGE. | | 27 | * THE POSSIBILITY OF SUCH DAMAGE. |
28 | */ | | 28 | */ |
29 | | | 29 | |
30 | #include "opt_inet.h" | | 30 | #include "opt_inet.h" |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.43 2010/08/11 09:36:44 pooka Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.44 2010/08/11 11:06:42 pooka Exp $"); |
34 | | | 34 | |
35 | /* | | 35 | /* |
36 | * TODO: | | 36 | * TODO: |
37 | * - iface reconfigure | | 37 | * - iface reconfigure |
38 | * - support for hardware checksum calculations; | | 38 | * - support for hardware checksum calculations; |
39 | * | | 39 | * |
40 | */ | | 40 | */ |
41 | | | 41 | |
42 | #include <sys/param.h> | | 42 | #include <sys/param.h> |
43 | #include <sys/proc.h> | | 43 | #include <sys/proc.h> |
44 | #include <sys/mbuf.h> | | 44 | #include <sys/mbuf.h> |
45 | #include <sys/socket.h> | | 45 | #include <sys/socket.h> |
46 | #include <sys/socketvar.h> | | 46 | #include <sys/socketvar.h> |
| @@ -1141,51 +1141,51 @@ carp_send_arp(struct carp_softc *sc) | | | @@ -1141,51 +1141,51 @@ carp_send_arp(struct carp_softc *sc) |
1141 | struct ifaddr *ifa; | | 1141 | struct ifaddr *ifa; |
1142 | struct in_addr *in; | | 1142 | struct in_addr *in; |
1143 | int s = splsoftnet(); | | 1143 | int s = splsoftnet(); |
1144 | | | 1144 | |
1145 | IFADDR_FOREACH(ifa, &sc->sc_if) { | | 1145 | IFADDR_FOREACH(ifa, &sc->sc_if) { |
1146 | | | 1146 | |
1147 | if (ifa->ifa_addr->sa_family != AF_INET) | | 1147 | if (ifa->ifa_addr->sa_family != AF_INET) |
1148 | continue; | | 1148 | continue; |
1149 | | | 1149 | |
1150 | in = &ifatoia(ifa)->ia_addr.sin_addr; | | 1150 | in = &ifatoia(ifa)->ia_addr.sin_addr; |
1151 | arprequest(sc->sc_carpdev, in, in, CLLADDR(sc->sc_if.if_sadl)); | | 1151 | arprequest(sc->sc_carpdev, in, in, CLLADDR(sc->sc_if.if_sadl)); |
1152 | | | 1152 | |
1153 | /* XXX: why does this need to delay? */ | | 1153 | /* XXX: why does this need to delay? */ |
1154 | kpause("carpdel", false, MIN(1, mstohz(1)), NULL); | | 1154 | kpause("carpdel", false, MAX(1, mstohz(1)), NULL); |
1155 | } | | 1155 | } |
1156 | splx(s); | | 1156 | splx(s); |
1157 | } | | 1157 | } |
1158 | | | 1158 | |
1159 | #ifdef INET6 | | 1159 | #ifdef INET6 |
1160 | void | | 1160 | void |
1161 | carp_send_na(struct carp_softc *sc) | | 1161 | carp_send_na(struct carp_softc *sc) |
1162 | { | | 1162 | { |
1163 | struct ifaddr *ifa; | | 1163 | struct ifaddr *ifa; |
1164 | struct in6_addr *in6; | | 1164 | struct in6_addr *in6; |
1165 | static struct in6_addr mcast = IN6ADDR_LINKLOCAL_ALLNODES_INIT; | | 1165 | static struct in6_addr mcast = IN6ADDR_LINKLOCAL_ALLNODES_INIT; |
1166 | int s = splsoftnet(); | | 1166 | int s = splsoftnet(); |
1167 | | | 1167 | |
1168 | IFADDR_FOREACH(ifa, &sc->sc_if) { | | 1168 | IFADDR_FOREACH(ifa, &sc->sc_if) { |
1169 | | | 1169 | |
1170 | if (ifa->ifa_addr->sa_family != AF_INET6) | | 1170 | if (ifa->ifa_addr->sa_family != AF_INET6) |
1171 | continue; | | 1171 | continue; |
1172 | | | 1172 | |
1173 | in6 = &ifatoia6(ifa)->ia_addr.sin6_addr; | | 1173 | in6 = &ifatoia6(ifa)->ia_addr.sin6_addr; |
1174 | nd6_na_output(sc->sc_carpdev, &mcast, in6, | | 1174 | nd6_na_output(sc->sc_carpdev, &mcast, in6, |
1175 | ND_NA_FLAG_OVERRIDE, 1, NULL); | | 1175 | ND_NA_FLAG_OVERRIDE, 1, NULL); |
1176 | | | 1176 | |
1177 | /* XXX: why does this need to delay? */ | | 1177 | /* XXX: why does this need to delay? */ |
1178 | kpause("carpdel6", false, MIN(1, mstohz(1)), NULL); | | 1178 | kpause("carpdel6", false, MAX(1, mstohz(1)), NULL); |
1179 | } | | 1179 | } |
1180 | splx(s); | | 1180 | splx(s); |
1181 | } | | 1181 | } |
1182 | #endif /* INET6 */ | | 1182 | #endif /* INET6 */ |
1183 | | | 1183 | |
1184 | /* | | 1184 | /* |
1185 | * Based on bridge_hash() in if_bridge.c | | 1185 | * Based on bridge_hash() in if_bridge.c |
1186 | */ | | 1186 | */ |
1187 | #define mix(a,b,c) \ | | 1187 | #define mix(a,b,c) \ |
1188 | do { \ | | 1188 | do { \ |
1189 | a -= b; a -= c; a ^= (c >> 13); \ | | 1189 | a -= b; a -= c; a ^= (c >> 13); \ |
1190 | b -= c; b -= a; b ^= (a << 8); \ | | 1190 | b -= c; b -= a; b ^= (a << 8); \ |
1191 | c -= a; c -= b; c ^= (b >> 13); \ | | 1191 | c -= a; c -= b; c ^= (b >> 13); \ |