diff options
author | julian <julian@FreeBSD.org> | 1998-08-04 23:17:05 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1998-08-04 23:17:05 +0000 |
commit | 926810dcee72cabf9aeb2364563cd63a890a127b (patch) | |
tree | 85eea77c3067cfb9ec4c58ac3fd56acae8b16c87 /sys | |
parent | cd5930392d175536cc8b443270f3456d7bf7f47f (diff) | |
download | FreeBSD-src-926810dcee72cabf9aeb2364563cd63a890a127b.zip FreeBSD-src-926810dcee72cabf9aeb2364563cd63a890a127b.tar.gz |
fix broken loopback code for ddp (again)
Submitted by: Stefan Bethke <stb@hanse.de>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if_ethersubr.c | 9 | ||||
-rw-r--r-- | sys/netatalk/ddp_output.c | 41 |
2 files changed, 43 insertions, 7 deletions
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index e523232..ca66eb0 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93 - * $Id: if_ethersubr.c,v 1.50 1998/06/13 02:27:10 julian Exp $ + * $Id: if_ethersubr.c,v 1.51 1998/06/14 20:58:14 julian Exp $ */ #include "opt_atalk.h" @@ -132,6 +132,7 @@ ether_output(ifp, m0, dst, rt0) register struct rtentry *rt; register struct ether_header *eh; int off, len = m->m_pkthdr.len, loop_copy = 0; + int hlen; /* link layer header lenght */ struct arpcom *ac = (struct arpcom *)ifp; if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) @@ -161,6 +162,7 @@ ether_output(ifp, m0, dst, rt0) time_second < rt->rt_rmx.rmx_expire) senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH); } + hlen = ETHER_HDR_LEN; switch (dst->sa_family) { #ifdef INET case AF_INET: @@ -203,6 +205,7 @@ ether_output(ifp, m0, dst, rt0) llc.llc_snap_ether_type = htons( ETHERTYPE_AT ); bcopy(&llc, mtod(m, caddr_t), sizeof(struct llc)); type = htons(m->m_pkthdr.len); + hlen = sizeof(struct llc) + ETHER_HDR_LEN; } else { type = htons(ETHERTYPE_AT); } @@ -362,10 +365,10 @@ ether_output(ifp, m0, dst, rt0) if ((m->m_flags & M_BCAST) || (loop_copy > 0)) { struct mbuf *n = m_copy(m, 0, (int)M_COPYALL); - (void) if_simloop(ifp, n, dst, ETHER_HDR_LEN); + (void) if_simloop(ifp, n, dst, hlen); } else if (bcmp(eh->ether_dhost, eh->ether_shost, ETHER_ADDR_LEN) == 0) { - (void) if_simloop(ifp, m, dst, ETHER_HDR_LEN); + (void) if_simloop(ifp, m, dst, hlen); return(0); /* XXX */ } } diff --git a/sys/netatalk/ddp_output.c b/sys/netatalk/ddp_output.c index 8e1a308..2344e70 100644 --- a/sys/netatalk/ddp_output.c +++ b/sys/netatalk/ddp_output.c @@ -72,6 +72,11 @@ ddp_output( struct mbuf *m, struct socket *so) } deh->deh_bytes = htonl( deh->deh_bytes ); +#ifdef NETATALK_DEBUG + printf ("ddp_output: from %d.%d:%d to %d.%d:%d\n", + ntohs(deh->deh_snet), deh->deh_snode, deh->deh_sport, + ntohs(deh->deh_dnet), deh->deh_dnode, deh->deh_dport); +#endif return( ddp_route( m, &ddp->ddp_route )); } @@ -142,13 +147,24 @@ ddp_route( struct mbuf *m, struct route *ro) } } else { m_freem( m ); - return( EINVAL ); +#ifdef NETATALK_DEBUG + if (ro->ro_rt == NULL) + printf ("ddp_route: no ro_rt.\n"); + else if (ro->ro_rt->rt_ifa == NULL) + printf ("ddp_route: no ro_rt->rt_ifa\n"); + else + printf ("ddp_route: no ro_rt->rt_ifa->ifa_ifp\n"); +#endif + return( ENETUNREACH ); } if ( aa == NULL ) { -printf( "ddp_route: oops\n" ); +#ifdef NETATALK_DEBUG + printf( "ddp_route: no atalk address found for %s%d\n", + ifp->if_name, ifp->if_unit); +#endif m_freem( m ); - return( EINVAL ); + return( ENETUNREACH ); } /* @@ -189,7 +205,24 @@ printf( "ddp_route: oops\n" ); } ro->ro_rt->rt_use++; +#ifdef NETATALK_DEBUG + printf ("ddp_route: from %d.%d to %d.%d, via %d.%d (%s%d)\n", + ntohs(satosat(&aa->aa_addr)->sat_addr.s_net), + satosat(&aa->aa_addr)->sat_addr.s_node, + ntohs(satosat(&ro->ro_dst)->sat_addr.s_net), + satosat(&ro->ro_dst)->sat_addr.s_node, + ntohs(gate.sat_addr.s_net), + gate.sat_addr.s_node, + ifp->if_name, ifp->if_unit); +#endif + + /* short-circuit the output if we're sending this to ourself */ + if ((satosat(&aa->aa_addr)->sat_addr.s_net == satosat(&ro->ro_dst)->sat_addr.s_net) && + (satosat(&aa->aa_addr)->sat_addr.s_node == satosat(&ro->ro_dst)->sat_addr.s_node)) + { + return (if_simloop(ifp, m, (struct sockaddr *)&gate, 0)); + } + return((*ifp->if_output)( ifp, m, (struct sockaddr *)&gate, NULL)); /* XXX */ } - |