diff options
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if_bridge.c | 6 | ||||
-rw-r--r-- | sys/net/if_ethersubr.c | 5 | ||||
-rw-r--r-- | sys/net/if_fddisubr.c | 41 | ||||
-rw-r--r-- | sys/net/if_tokensubr.c | 53 |
4 files changed, 91 insertions, 14 deletions
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 8936febc198..14c9e41766e 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.c,v 1.139 2004/12/17 12:42:02 pascoe Exp $ */ +/* $OpenBSD: if_bridge.c,v 1.140 2004/12/19 03:25:36 mcbride Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -1395,7 +1395,7 @@ bridge_input(struct ifnet *ifp, struct ether_header *eh, struct mbuf *m) if (bcmp(ac->ac_enaddr, eh->ether_dhost, ETHER_ADDR_LEN) == 0 #if NCARP > 0 || (ifl->ifp->if_carp && carp_ourether(ifl->ifp->if_carp, - eh, 0) != NULL) + eh, IFT_ETHER, 0) != NULL) #endif ) { if (srcifl->bif_flags & IFBIF_LEARNING) @@ -1418,7 +1418,7 @@ bridge_input(struct ifnet *ifp, struct ether_header *eh, struct mbuf *m) if (bcmp(ac->ac_enaddr, eh->ether_shost, ETHER_ADDR_LEN) == 0 #if NCARP > 0 || (ifl->ifp->if_carp && carp_ourether(ifl->ifp->if_carp, - eh, 1) != NULL) + eh, IFT_ETHER, 1) != NULL) #endif ) { m_freem(m); diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index cfc6fbc5cc5..c89daabab6e 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ethersubr.c,v 1.86 2004/12/17 12:42:02 pascoe Exp $ */ +/* $OpenBSD: if_ethersubr.c,v 1.87 2004/12/19 03:25:36 mcbride Exp $ */ /* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */ /* @@ -677,7 +677,8 @@ ether_input(ifp, eh, m) #if NCARP > 0 if (ifp->if_carp && ifp->if_type != IFT_CARP && - (carp_input(eh, m) == 0)) + (carp_input(m, (u_int8_t *)&eh->ether_shost, + (u_int8_t *)&eh->ether_dhost, eh->ether_type) == 0)) return; #endif /* NCARP > 0 */ diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index 3a0f4800ff8..1d9715919c3 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_fddisubr.c,v 1.42 2004/12/10 22:35:17 mcbride Exp $ */ +/* $OpenBSD: if_fddisubr.c,v 1.43 2004/12/19 03:25:36 mcbride Exp $ */ /* $NetBSD: if_fddisubr.c,v 1.5 1996/05/07 23:20:21 christos Exp $ */ /* @@ -152,8 +152,8 @@ extern struct ifqueue pkintrq; * Assumes that ifp is actually pointer to arpcom structure. */ int -fddi_output(ifp, m0, dst, rt0) - struct ifnet *ifp; +fddi_output(ifp0, m0, dst, rt0) + struct ifnet *ifp0; struct mbuf *m0; struct sockaddr *dst; struct rtentry *rt0; @@ -165,9 +165,28 @@ fddi_output(ifp, m0, dst, rt0) struct rtentry *rt; struct mbuf *mcopy = (struct mbuf *)0; struct fddi_header *fh; - struct arpcom *ac = (struct arpcom *)ifp; + struct arpcom *ac = (struct arpcom *)ifp0; short mflags; + struct ifnet *ifp = ifp0; + +#if NCARP > 0 + if (ifp->if_type == IFT_CARP) { + struct ifaddr *ifa; + /* loop back if this is going to the carp interface */ + if (dst != NULL && ifp0->if_link_state == LINK_STATE_UP && + (ifa = ifa_ifwithaddr(dst)) != NULL && + ifa->ifa_ifp == ifp0) + return (looutput(ifp0, m, dst, rt0)); + + ifp = ifp->if_carpdev; + ac = (struct arpcom *)ifp; + + if ((ifp0->if_flags & (IFF_UP|IFF_RUNNING)) != + (IFF_UP|IFF_RUNNING)) + senderr(ENETDOWN); + } +#endif /* NCARP > 0 */ if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) senderr(ENETDOWN); if ((rt = rt0) != NULL) { @@ -396,7 +415,7 @@ fddi_output(ifp, m0, dst, rt0) sizeof(fh->fddi_shost)); #if NCARP > 0 if (ifp->if_carp) { - error = carp_fix_lladdr(ifp, m, NULL, NULL); + error = carp_fix_lladdr(ifp0, m, dst, NULL); if (error) goto bad; } @@ -415,6 +434,10 @@ fddi_output(ifp, m0, dst, rt0) return (error); } ifp->if_obytes += len; +#if NCARP > 0 + if (ifp != ifp0) + ifp0->if_obytes += len; +#endif /* NCARP > 0 */ if (mflags & M_MCAST) ifp->if_omcasts++; if ((ifp->if_flags & IFF_OACTIVE) == 0) @@ -468,6 +491,14 @@ fddi_input(ifp, fh, m) goto dropanyway; etype = ntohs(l->llc_snap.ether_type); m_adj(m, LLC_SNAPFRAMELEN); + +#if NCARP > 0 + if (ifp->if_carp && ifp->if_type != IFT_CARP && + (carp_input(m, (u_int8_t *)&fh->fddi_shost, + (u_int8_t *)&fh->fddi_dhost, l->llc_snap.ether_type) == 0)) + return; +#endif + switch (etype) { #ifdef INET case ETHERTYPE_IP: diff --git a/sys/net/if_tokensubr.c b/sys/net/if_tokensubr.c index 74077d9c467..e815b80ed9a 100644 --- a/sys/net/if_tokensubr.c +++ b/sys/net/if_tokensubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tokensubr.c,v 1.16 2004/07/16 15:01:09 henning Exp $ */ +/* $OpenBSD: if_tokensubr.c,v 1.17 2004/12/19 03:25:36 mcbride Exp $ */ /* $NetBSD: if_tokensubr.c,v 1.7 1999/05/30 00:39:07 bad Exp $ */ /* @@ -75,6 +75,11 @@ #include "bpfilter.h" +#include "carp.h" +#if NCARP > 0 +#include <netinet/ip_carp.h> +#endif + #ifdef LLC #include <netccitt/dll.h> #include <netccitt/llc_var.h> @@ -122,8 +127,8 @@ int token_output(struct ifnet *, struct mbuf *, struct sockaddr *, * XXX route info has to go into the same mbuf as the header */ int -token_output(ifp, m0, dst, rt0) - struct ifnet *ifp; +token_output(ifp0, m0, dst, rt0) + struct ifnet *ifp0; struct mbuf *m0; struct sockaddr *dst; struct rtentry *rt0; @@ -136,12 +141,32 @@ token_output(ifp, m0, dst, rt0) struct mbuf *mcopy = (struct mbuf *)0; struct token_header *trh; #ifdef INET - struct arpcom *ac = (struct arpcom *)ifp; + struct arpcom *ac = (struct arpcom *)ifp0; #endif /* INET */ struct token_rif *rif = (struct token_rif *)0; struct token_rif bcastrif; size_t riflen = 0; short mflags; + struct ifnet *ifp = ifp0; + +#if NCARP > 0 + if (ifp->if_type == IFT_CARP) { + struct ifaddr *ifa; + + /* loop back if this is going to the carp interface */ + if (dst != NULL && ifp0->if_link_state == LINK_STATE_UP && + (ifa = ifa_ifwithaddr(dst)) != NULL && + ifa->ifa_ifp == ifp0) + return (looutput(ifp0, m, dst, rt0)); + + ifp = ifp->if_carpdev; + ac = (struct arpcom *)ifp; + + if ((ifp0->if_flags & (IFF_UP|IFF_RUNNING)) != + (IFF_UP|IFF_RUNNING)) + senderr(ENETDOWN); + } +#endif /* NCARP > 0 */ if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) senderr(ENETDOWN); @@ -384,6 +409,14 @@ token_output(ifp, m0, dst, rt0) #if 0 send: #endif /* 0 */ +#if NCARP > 0 + if (ifp->if_carp) { + error = carp_fix_lladdr(ifp0, m, dst, NULL); + if (error) + goto bad; + } +#endif + mflags = m->m_flags; len = m->m_pkthdr.len; @@ -399,6 +432,10 @@ send: return (error); } ifp->if_obytes += len; +#if NCARP > 0 + if (ifp != ifp0) + ifp0->if_obytes += len; +#endif /* NCARP > 0 */ if (mflags & M_MCAST) ifp->if_omcasts++; if ((ifp->if_flags & IFF_OACTIVE) == 0) @@ -467,6 +504,14 @@ token_input(ifp, m) goto dropanyway; etype = ntohs(l->llc_snap.ether_type); m_adj(m, LLC_SNAPFRAMELEN); + +#if NCARP > 0 + if (ifp->if_carp && ifp->if_type != IFT_CARP && + (carp_input(m, (u_int8_t *)&th->token_shost, + (u_int8_t *)&th->token_dhost, l->llc_snap.ether_type) == 0)) + return; +#endif + switch (etype) { #ifdef INET case ETHERTYPE_IP: |