From 778dfa7215c6a6a659b73f067cd2a655e841982d Mon Sep 17 00:00:00 2001 From: Ryan Thomas McBride Date: Sat, 18 Sep 2004 16:15:54 +0000 Subject: Oops, copy a pointer to ac_if, not the first bytes of the struct itself. Actually this doesn't matter right now, as the first bytes of struct ifnet are a pointer to the softc, which has ac_if at the beginning and thus by fluke the pointer is correct. This also makes the sc to ifp conversion for carp_macmatch6(). --- sys/netinet/ip_carp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sys/netinet') diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 96044f31de9..f28eccd1ca3 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.64 2004/09/18 06:51:49 mcbride Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.65 2004/09/18 16:15:53 mcbride Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -749,6 +749,7 @@ int carp_prepare_ad(struct mbuf *m, struct carp_softc *sc, struct carp_header *ch) { struct m_tag *mtag; + struct ifnet *ifp = &sc->sc_ac.ac_if; if (sc->sc_init_counter) { /* this could also be seconds since unix epoch */ @@ -770,7 +771,7 @@ carp_prepare_ad(struct mbuf *m, struct carp_softc *sc, struct carp_header *ch) sc->sc_ac.ac_if.if_oerrors++; return (ENOMEM); } - bcopy(&sc->sc_ac.ac_if, (caddr_t)(mtag + 1), sizeof(struct ifnet *)); + bcopy(&ifp, (caddr_t)(mtag + 1), sizeof(struct ifnet *)); m_tag_prepend(m, mtag); return (0); @@ -1140,14 +1141,16 @@ carp_macmatch6(void *v, struct mbuf *m, struct in6_addr *taddr) &ifatoia6(ifa)->ia_addr.sin6_addr) && ((sc->sc_ac.ac_if.if_flags & (IFF_UP|IFF_RUNNING)) == (IFF_UP|IFF_RUNNING))) { + struct ifnet *ifp = &sc->sc_ac.ac_if; + mtag = m_tag_get(PACKET_TAG_CARP, - sizeof(struct carp_softc *), M_NOWAIT); + sizeof(struct ifnet *), M_NOWAIT); if (mtag == NULL) { /* better a bit than nothing */ return (sc->sc_ac.ac_enaddr); } - bcopy(&sc, (caddr_t)(mtag + 1), - sizeof(struct carp_softc *)); + bcopy(&ifp, (caddr_t)(mtag + 1), + sizeof(struct ifnet *)); m_tag_prepend(m, mtag); return (sc->sc_ac.ac_enaddr); -- cgit v1.2.3