Fix the check supposed to prevent 'ip' and 'ip-stealth' balancing modes
authormpi <mpi@openbsd.org>
Tue, 19 Jul 2016 16:08:46 +0000 (16:08 +0000)
committermpi <mpi@openbsd.org>
Tue, 19 Jul 2016 16:08:46 +0000 (16:08 +0000)
from leaking the multicast address.

beck@ found the hard way that this made his second CARP master use a
wrong MAC address.

This is part of a bigger diff from Florian Riehm who is currently
working on a proper solution to fix balancing modes.

ok beck@, bluhm@

sys/netinet/ip_carp.c

index e8063c7..5767fd1 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ip_carp.c,v 1.291 2016/06/06 07:01:37 mpi Exp $       */
+/*     $OpenBSD: ip_carp.c,v 1.292 2016/07/19 16:08:46 mpi Exp $       */
 
 /*
  * Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -2281,14 +2281,13 @@ carp_start(struct ifnet *ifp)
                 * advertisements in 'ip' and 'ip-stealth' balacing
                 * modes.
                 */
-               if (sc->sc_balancing != CARP_BAL_IPSTEALTH &&
-                   sc->sc_balancing != CARP_BAL_IP &&
-                   (sc->cur_vhe && !sc->cur_vhe->vhe_leader)) {
+               if (sc->sc_balancing == CARP_BAL_IP ||
+                   sc->sc_balancing == CARP_BAL_IPSTEALTH) {
                        struct ether_header *eh;
                        uint8_t *esrc;
 
                        eh = mtod(m, struct ether_header *);
-                       esrc = sc->cur_vhe->vhe_enaddr;
+                       esrc = ((struct arpcom*)ifp->if_carpdev)->ac_enaddr;;
                        memcpy(eh->ether_shost, esrc, sizeof(eh->ether_shost));
                }