diff options
author | fenner <fenner@FreeBSD.org> | 1996-03-11 17:11:23 +0000 |
---|---|---|
committer | fenner <fenner@FreeBSD.org> | 1996-03-11 17:11:23 +0000 |
commit | e994b234d9da4c9226cbeb3d972cd0a53cb1d4fe (patch) | |
tree | f57437160ceedddacae9319b4d69460b072c0da4 /sys/netinet/ip_mroute.c | |
parent | 135587ee9741d70e874e48d6ba3467827d2bfc90 (diff) | |
download | FreeBSD-src-e994b234d9da4c9226cbeb3d972cd0a53cb1d4fe.zip FreeBSD-src-e994b234d9da4c9226cbeb3d972cd0a53cb1d4fe.tar.gz |
Cleaned up uninitialized 'rt' warning properly
Make a copy of the header of a packet that gets queued due to
lack of forwarding cache entry, so that nobody else can step
on it. Thanks to Mike Karels <karels@bsdi.com> for pointing
this one out.
Diffstat (limited to 'sys/netinet/ip_mroute.c')
-rw-r--r-- | sys/netinet/ip_mroute.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 4991200..d876d71 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -9,7 +9,7 @@ * Modified by Bill Fenner, PARC, April 1995 * * MROUTING Revision: 3.5 - * $Id: ip_mroute.c,v 1.28 1996/03/02 18:24:10 peter Exp $ + * $Id: ip_mroute.c,v 1.29 1996/03/11 15:13:17 davidg Exp $ */ #include "opt_mrouting.h" @@ -1107,7 +1107,7 @@ X_ip_mforward(ip, ifp, m, imo) struct mbuf *m; struct ip_moptions *imo; { - register struct mfc *rt = 0; /* XXX uninit warning */ + register struct mfc *rt; register u_char *ipoptions; static struct sockaddr_in k_igmpsrc = { sizeof k_igmpsrc, AF_INET }; static int srctun = 0; @@ -1148,7 +1148,7 @@ X_ip_mforward(ip, ifp, m, imo) (vifp->v_flags & VIFF_TUNNEL) ? "tunnel on " : "", vifp->v_ifp->if_name, vifp->v_ifp->if_unit); } - return (ip_mdq(m, ifp, rt, vifi)); + return (ip_mdq(m, ifp, NULL, vifi)); } if (rsvpdebug && ip->ip_p == IPPROTO_RSVP) { printf("Warning: IPPROTO_RSVP from %lx to %lx without vif option\n", @@ -1189,6 +1189,7 @@ X_ip_mforward(ip, ifp, m, imo) register struct mbuf *rte_m; register u_long hash; register int npkts; + int hlen = ip->ip_hl << 2; #ifdef UPCALL_TIMING struct timeval tp; @@ -1203,7 +1204,8 @@ X_ip_mforward(ip, ifp, m, imo) /* * Allocate mbufs early so that we don't do extra work if we are - * just going to fail anyway. + * just going to fail anyway. Make sure to pullup the header so + * that other people can't step on it. */ MGET(mb_ntry, M_DONTWAIT, MT_DATA); if (mb_ntry == NULL) { @@ -1211,6 +1213,8 @@ X_ip_mforward(ip, ifp, m, imo) return ENOBUFS; } mb0 = m_copy(m, 0, M_COPYALL); + if (mb0 && (M_HASCL(mb0) || mb0->m_len < hlen)) + mb0 = m_pullup(mb0, hlen); if (mb0 == NULL) { m_free(mb_ntry); splx(s); @@ -1228,7 +1232,6 @@ X_ip_mforward(ip, ifp, m, imo) } if (mb_rt == NULL) { - int hlen = ip->ip_hl << 2; int i; struct igmpmsg *im; @@ -1242,8 +1245,6 @@ X_ip_mforward(ip, ifp, m, imo) } /* Make a copy of the header to send to the user level process */ mm = m_copy(m, 0, hlen); - if (mm && (M_HASCL(mm) || mm->m_len < hlen)) - mm = m_pullup(mm, hlen); if (mm == NULL) { m_free(mb_ntry); m_freem(mb0); |