Module Name: src Committed By: mlelstv Date: Sun Mar 26 10:32:38 UTC 2023
Modified Files: src/sys/netinet: ip_carp.c Log Message: Use backing device to send advertisements. Otherwise the packets originate from the virtual MAC address, which confuses switches. To generate a diff of this commit: cvs rdiff -u -r1.117 -r1.118 src/sys/netinet/ip_carp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/netinet/ip_carp.c diff -u src/sys/netinet/ip_carp.c:1.117 src/sys/netinet/ip_carp.c:1.118 --- src/sys/netinet/ip_carp.c:1.117 Fri Sep 2 23:48:11 2022 +++ src/sys/netinet/ip_carp.c Sun Mar 26 10:32:38 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_carp.c,v 1.117 2022/09/02 23:48:11 thorpej Exp $ */ +/* $NetBSD: ip_carp.c,v 1.118 2023/03/26 10:32:38 mlelstv Exp $ */ /* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */ /* @@ -33,7 +33,7 @@ #endif #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.117 2022/09/02 23:48:11 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.118 2023/03/26 10:32:38 mlelstv Exp $"); /* * TODO: @@ -1876,6 +1876,9 @@ carp_join_multicast(struct carp_softc *s struct ip_moptions *imo = &sc->sc_imo, tmpimo; struct in_addr addr; + if (sc->sc_carpdev == NULL) + return (ENETDOWN); + memset(&tmpimo, 0, sizeof(tmpimo)); addr.s_addr = INADDR_CARP_GROUP; if ((tmpimo.imo_membership[0] = @@ -1885,7 +1888,7 @@ carp_join_multicast(struct carp_softc *s imo->imo_membership[0] = tmpimo.imo_membership[0]; imo->imo_num_memberships = 1; - imo->imo_multicast_if_index = sc->sc_if.if_index; + imo->imo_multicast_if_index = sc->sc_carpdev->if_index; imo->imo_multicast_ttl = CARP_DFLTTL; imo->imo_multicast_loop = 0; return (0); @@ -1970,6 +1973,9 @@ carp_join_multicast6(struct carp_softc * struct sockaddr_in6 addr6; int error; + if (sc->sc_carpdev == NULL) + return (ENETDOWN); + /* Join IPv6 CARP multicast group */ memset(&addr6, 0, sizeof(addr6)); addr6.sin6_family = AF_INET6; @@ -1996,7 +2002,7 @@ carp_join_multicast6(struct carp_softc * } /* apply v6 multicast membership */ - im6o->im6o_multicast_if_index = sc->sc_if.if_index; + im6o->im6o_multicast_if_index = sc->sc_carpdev->if_index; if (imm) LIST_INSERT_HEAD(&im6o->im6o_memberships, imm, i6mm_chain);