From 06a429a3c8fa24e93f3d278910ae860abeab470f Mon Sep 17 00:00:00 2001 From: Archie Cobbs Date: Wed, 24 May 2000 21:16:56 +0000 Subject: [PATCH] Just need to pass the address family to if_simloop(), not the whole sockaddr. --- sys/net/if_ethersubr.c | 4 ++-- sys/net/if_fddisubr.c | 4 ++-- sys/net/if_iso88025subr.c | 6 ++++-- sys/net/if_loop.c | 22 ++++++++++++---------- sys/net/if_var.h | 3 +-- sys/netatalk/ddp_output.c | 4 +++- sys/netatm/ipatm/ipatm_output.c | 2 +- sys/netinet/ip_output.c | 2 +- sys/netinet6/ip6_mroute.c | 2 +- sys/netinet6/ip6_output.c | 2 +- 10 files changed, 28 insertions(+), 23 deletions(-) diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 1a5b0c9d21cb..8507d90521fd 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -359,10 +359,10 @@ ether_output(ifp, m, 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, hlen); + (void) if_simloop(ifp, n, dst->sa_family, hlen); } else if (bcmp(eh->ether_dhost, eh->ether_shost, ETHER_ADDR_LEN) == 0) { - (void) if_simloop(ifp, m, dst, hlen); + (void) if_simloop(ifp, m, dst->sa_family, hlen); return (0); /* XXX */ } } diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index b9c431aa2148..21c10fcc97d5 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -337,11 +337,11 @@ fddi_output(ifp, m, dst, rt0) struct mbuf *n = m_copy(m, 0, (int)M_COPYALL); (void) if_simloop(ifp, - n, dst, sizeof(struct fddi_header)); + n, dst->sa_family, sizeof(struct fddi_header)); } else if (bcmp(fh->fddi_dhost, fh->fddi_shost, sizeof(fh->fddi_shost)) == 0) { (void) if_simloop(ifp, - m, dst, sizeof(struct fddi_header)); + m, dst->sa_family, sizeof(struct fddi_header)); return(0); /* XXX */ } } diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c index bbd10d83f9d2..3dd47b893eff 100644 --- a/sys/net/if_iso88025subr.c +++ b/sys/net/if_iso88025subr.c @@ -285,10 +285,12 @@ iso88025_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct (loop_copy != -1)) { 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, ISO88025_HDR_LEN); + (void) if_simloop(ifp, + n, dst->sa_family, ISO88025_HDR_LEN); } else if (bcmp(th->iso88025_dhost, th->iso88025_shost, ETHER_ADDR_LEN) == 0) { - (void) if_simloop(ifp, m, dst, ISO88025_HDR_LEN); + (void) if_simloop(ifp, + m, dst->sa_family, ISO88025_HDR_LEN); return(0); /* XXX */ } } diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 3efef6d53906..5f6e91b30de0 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -186,7 +186,7 @@ looutput(ifp, m, dst, rt) return (EAFNOSUPPORT); } #endif - return(if_simloop(ifp, m, dst, 0)); + return(if_simloop(ifp, m, dst->sa_family, 0)); } /* @@ -201,29 +201,30 @@ looutput(ifp, m, dst, rt) */ int -if_simloop(ifp, m, dst, hlen) +if_simloop(ifp, m, af, hlen) struct ifnet *ifp; register struct mbuf *m; - struct sockaddr *dst; + int af; int hlen; { int s, isr; register struct ifqueue *ifq = 0; - if ((m->m_flags & M_PKTHDR) == 0) - panic("if_simloop: no HDR"); + KASSERT((m->m_flags & M_PKTHDR) != 0, ("if_simloop: no HDR")); m->m_pkthdr.rcvif = ifp; + /* BPF write needs to be handled specially */ - if (dst->sa_family == AF_UNSPEC) { - dst->sa_family = *(mtod(m, int *)); + if (af == AF_UNSPEC) { + KASSERT(m->m_len >= sizeof(int), ("if_simloop: m_len")); + af = *(mtod(m, int *)); m->m_len -= sizeof(int); m->m_pkthdr.len -= sizeof(int); m->m_data += sizeof(int); } + /* Let BPF see incoming packet */ if (ifp->if_bpf) { struct mbuf m0, *n = m; - u_int af = dst->sa_family; /* * We need to prepend the address family as @@ -254,7 +255,8 @@ if_simloop(ifp, m, dst, hlen) m_adj(m, hlen); } - switch (dst->sa_family) { + /* Deliver to upper layer protocol */ + switch (af) { #ifdef INET case AF_INET: ifq = &ipintrq; @@ -287,7 +289,7 @@ if_simloop(ifp, m, dst, hlen) break; #endif NETATALK default: - printf("if_simloop: can't handle af=%d\n", dst->sa_family); + printf("if_simloop: can't handle af=%d\n", af); m_freem(m); return (EAFNOSUPPORT); } diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 66b117c7df5c..a7060cd5e1f6 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -362,8 +362,7 @@ void ifafree __P((struct ifaddr *)); struct ifmultiaddr *ifmaof_ifpforaddr __P((struct sockaddr *, struct ifnet *)); -int if_simloop __P((struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, int hlen)); +int if_simloop __P((struct ifnet *ifp, struct mbuf *m, int af, int hlen)); #endif /* _KERNEL */ diff --git a/sys/netatalk/ddp_output.c b/sys/netatalk/ddp_output.c index 2344e707cad0..66e20dfe6181 100644 --- a/sys/netatalk/ddp_output.c +++ b/sys/netatalk/ddp_output.c @@ -21,6 +21,8 @@ * netatalk@itd.umich.edu */ +/* $FreeBSD$ */ + #include #include #include @@ -220,7 +222,7 @@ ddp_route( struct mbuf *m, struct route *ro) 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 (if_simloop(ifp, m, gate.sat_family, 0)); } return((*ifp->if_output)( ifp, diff --git a/sys/netatm/ipatm/ipatm_output.c b/sys/netatm/ipatm/ipatm_output.c index cdbe2a8e4152..1ca94f3938b7 100644 --- a/sys/netatm/ipatm/ipatm_output.c +++ b/sys/netatm/ipatm/ipatm_output.c @@ -139,7 +139,7 @@ ipatm_ifoutput(ifp, m, dst) /* * It's for us - hand packet to loopback driver */ - (void) if_simloop(ifp, m, dst, 0); + (void) if_simloop(ifp, m, dst->sa_family, 0); goto done; } } diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 47b2c37413b3..52db0993ced8 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1868,7 +1868,7 @@ ip_mloopback(ifp, m, dst, hlen) copym->m_pkthdr.rcvif = ifp; ip_input(copym); #else - if_simloop(ifp, copym, (struct sockaddr *)dst, 0); + if_simloop(ifp, copym, dst->sin_family, 0); #endif } } diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index 1f6b5f26ef75..5d5c065656d7 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -1643,7 +1643,7 @@ pim6_input(mp, offp, proto) #endif rc = if_simloop(mif6table[reg_mif_num].m6_ifp, m, - (struct sockaddr *) &dst, NULL); + dst.sin6_family, NULL); /* prepare the register head to send to the mrouting daemon */ m = mcp; diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index c7d0499611df..eb0474f35e27 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -2124,7 +2124,7 @@ ip6_mloopback(ifp, m, dst) copym = m_copy(m, 0, M_COPYALL); if (copym != NULL) { - (void)if_simloop(ifp, copym, (struct sockaddr *)dst, 0); + (void)if_simloop(ifp, copym, dst->sin6_family, 0); } }