From: henning Date: Sun, 20 Apr 2014 14:54:39 +0000 (+0000) Subject: ether_output: instead of assembling the ethernet header and then calling X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=220df611e015e766c23f479345306f23905826fe;p=openbsd ether_output: instead of assembling the ethernet header and then calling carp_rewrite_lladdr to overwrite the src lladdr, get the intended src lladdr before assembling the ethernet header. carp_rewrite_lladdr -> carp_get_srclladdr ok reyk claudio --- diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 0ccb5c5cd2f..cf0de756f43 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ethersubr.c,v 1.166 2014/04/20 14:51:50 henning Exp $ */ +/* $OpenBSD: if_ethersubr.c,v 1.167 2014/04/20 14:54:39 henning Exp $ */ /* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */ /* @@ -343,6 +343,10 @@ ether_output(struct ifnet *ifp0, struct mbuf *m0, struct sockaddr *dst, if (!hdrcmplt) esrc = ac->ac_enaddr; +#if NCARP > 0 + if (ifp0 != ifp && ifp0->if_type == IFT_CARP) + esrc = carp_get_srclladdr(ifp0, esrc); +#endif /* * Add local net header. If no space in first mbuf, @@ -356,11 +360,6 @@ ether_output(struct ifnet *ifp0, struct mbuf *m0, struct sockaddr *dst, memcpy(eh->ether_dhost, edst, sizeof(eh->ether_dhost)); memcpy(eh->ether_shost, esrc, sizeof(eh->ether_shost)); -#if NCARP > 0 - if (ifp0 != ifp && ifp0->if_type == IFT_CARP) - carp_rewrite_lladdr(ifp0, eh->ether_shost); -#endif - #if NBRIDGE > 0 /* * Interfaces that are bridgeports need special handling for output. diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 1b95591028b..9228d89e48e 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.226 2014/04/14 09:06:42 mpi Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.227 2014/04/20 14:54:39 henning Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -1519,20 +1519,19 @@ carp_ourether(void *v, u_int8_t *ena) return (NULL); } -void -carp_rewrite_lladdr(struct ifnet *ifp, u_int8_t *s_enaddr) +u_char * +carp_get_srclladdr(struct ifnet *ifp, u_char *esrc) { struct carp_softc *sc = ifp->if_softc; if (sc->sc_balancing != CARP_BAL_IPSTEALTH && sc->sc_balancing != CARP_BAL_IP && sc->cur_vhe) { if (sc->cur_vhe->vhe_leader) - bcopy((caddr_t)sc->sc_ac.ac_enaddr, - (caddr_t)s_enaddr, ETHER_ADDR_LEN); + return (sc->sc_ac.ac_enaddr); else - bcopy((caddr_t)sc->cur_vhe->vhe_enaddr, - (caddr_t)s_enaddr, ETHER_ADDR_LEN); + return (sc->cur_vhe->vhe_enaddr); } + return (esrc); } int diff --git a/sys/netinet/ip_carp.h b/sys/netinet/ip_carp.h index 69c7c4abecf..b73e2d8be7a 100644 --- a/sys/netinet/ip_carp.h +++ b/sys/netinet/ip_carp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.h,v 1.30 2014/01/22 09:35:20 mpi Exp $ */ +/* $OpenBSD: ip_carp.h,v 1.31 2014/04/20 14:54:39 henning Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -178,7 +178,7 @@ int carp_output(struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *); int carp_sysctl(int *, u_int, void *, size_t *, void *, size_t); int carp_lsdrop(struct mbuf *, sa_family_t, u_int32_t *, u_int32_t *); -void carp_rewrite_lladdr(struct ifnet *, u_int8_t *); +u_char *carp_get_srclladdr(struct ifnet *, u_char *); int carp_our_mcastaddr(struct ifnet *, u_int8_t *); #endif /* _KERNEL */ #endif /* _NETINET_IP_CARP_H_ */