summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2013-10-19 16:09:53 +0000
committerbluhm <bluhm@openbsd.org>2013-10-19 16:09:53 +0000
commitf6f5242838b52d11f6d7801445e95ae6476b1084 (patch)
treecd1c191db358697a07fa8c1d8c22d11e5c995360 /sys
parentSupport the hibernate key (Fn-F12) (diff)
downloadwireguard-openbsd-f6f5242838b52d11f6d7801445e95ae6476b1084.tar.xz
wireguard-openbsd-f6f5242838b52d11f6d7801445e95ae6476b1084.zip
Now carp_set_addr() and carp_set_addr6() break out of the loop after
they have found the interface address, so we can get rid of the additional variable ia_if. No functional change. OK mpi@ phessler@
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/ip_carp.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index 756bb6c9172..cfa476b9cc0 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_carp.c,v 1.212 2013/10/19 09:23:59 bluhm Exp $ */
+/* $OpenBSD: ip_carp.c,v 1.213 2013/10/19 16:09:53 bluhm Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -2018,7 +2018,7 @@ int
carp_set_addr(struct carp_softc *sc, struct sockaddr_in *sin)
{
struct ifnet *ifp = sc->sc_carpdev;
- struct in_ifaddr *ia, *ia_if;
+ struct in_ifaddr *ia;
int error = 0;
/* XXX is this necessary? */
@@ -2032,21 +2032,17 @@ carp_set_addr(struct carp_softc *sc, struct sockaddr_in *sin)
}
/* we have to do this by hand to ensure we don't match on ourselves */
- ia_if = NULL;
TAILQ_FOREACH(ia, &in_ifaddr, ia_list) {
/* and, yeah, we need a multicast-capable iface too */
if (ia->ia_ifp != &sc->sc_if &&
ia->ia_ifp->if_type != IFT_CARP &&
(ia->ia_ifp->if_flags & IFF_MULTICAST) &&
ia->ia_ifp->if_rdomain == sc->sc_if.if_rdomain &&
- (sin->sin_addr.s_addr & ia->ia_netmask) == ia->ia_net) {
- ia_if = ia;
+ (sin->sin_addr.s_addr & ia->ia_netmask) == ia->ia_net)
break;
- }
}
- if (ia_if) {
- ia = ia_if;
+ if (ia) {
if (ifp) {
if (ifp != ia->ia_ifp)
return (EADDRNOTAVAIL);
@@ -2100,7 +2096,7 @@ int
carp_set_addr6(struct carp_softc *sc, struct sockaddr_in6 *sin6)
{
struct ifnet *ifp = sc->sc_carpdev;
- struct in6_ifaddr *ia, *ia_if;
+ struct in6_ifaddr *ia;
int error = 0;
if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
@@ -2113,7 +2109,6 @@ carp_set_addr6(struct carp_softc *sc, struct sockaddr_in6 *sin6)
}
/* we have to do this by hand to ensure we don't match on ourselves */
- ia_if = NULL;
TAILQ_FOREACH(ia, &in6_ifaddr, ia_list) {
int i;
@@ -2128,14 +2123,11 @@ carp_set_addr6(struct carp_softc *sc, struct sockaddr_in6 *sin6)
if (ia->ia_ifp != &sc->sc_if &&
ia->ia_ifp->if_type != IFT_CARP &&
(ia->ia_ifp->if_flags & IFF_MULTICAST) &&
- (i == 4)) {
- ia_if = ia;
+ (i == 4))
break;
- }
}
- if (ia_if) {
- ia = ia_if;
+ if (ia) {
if (sc->sc_carpdev) {
if (sc->sc_carpdev != ia->ia_ifp)
return (EADDRNOTAVAIL);