Always call ip_output() with a valid route pointer. For igmp, also get the

multicast option structure off the stack rather than malloc.
This commit is contained in:
Garrett Wollman 1996-04-18 15:41:11 +00:00
parent 97f588a78b
commit 2eba88186e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=15292
2 changed files with 24 additions and 17 deletions

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* @(#)igmp.c 8.1 (Berkeley) 7/19/93
* $Id: igmp.c,v 1.16 1996/03/14 16:59:16 fenner Exp $
* $Id: igmp.c,v 1.17 1996/03/26 19:16:42 fenner Exp $
*/
/*
@ -422,6 +422,8 @@ igmp_slowtimo()
splx(s);
}
static struct route igmprt;
static void
igmp_sendpkt(inm, type, addr)
struct in_multi *inm;
@ -431,18 +433,13 @@ igmp_sendpkt(inm, type, addr)
struct mbuf *m;
struct igmp *igmp;
struct ip *ip;
struct ip_moptions *imo;
struct ip_moptions imo;
struct sockaddr_in *sin;
MGETHDR(m, M_DONTWAIT, MT_HEADER);
if (m == NULL)
return;
MALLOC(imo, struct ip_moptions *, sizeof *imo, M_IPMOPTS, M_DONTWAIT);
if (!imo) {
m_free(m);
return;
}
m->m_pkthdr.rcvif = loif;
m->m_pkthdr.len = sizeof(struct ip) + IGMP_MINLEN;
MH_ALIGN(m, IGMP_MINLEN + sizeof(struct ip));
@ -465,17 +462,20 @@ igmp_sendpkt(inm, type, addr)
ip->ip_src.s_addr = INADDR_ANY;
ip->ip_dst.s_addr = addr ? addr : igmp->igmp_group.s_addr;
imo->imo_multicast_ifp = inm->inm_ifp;
imo->imo_multicast_ttl = 1;
imo->imo_multicast_vif = -1;
imo.imo_multicast_ifp = inm->inm_ifp;
imo.imo_multicast_ttl = 1;
imo.imo_multicast_vif = -1;
/*
* Request loopback of the report if we are acting as a multicast
* router, so that the process-level routing demon can hear it.
*/
imo->imo_multicast_loop = (ip_mrouter != NULL);
imo.imo_multicast_loop = (ip_mrouter != NULL);
ip_output(m, router_alert, (struct route *)0, 0, imo);
/*
* XXX
* Do we have to worry about reentrancy here? Don't think so.
*/
ip_output(m, router_alert, &igmprt, 0, &imo);
FREE(imo, M_IPMOPTS);
++igmpstat.igps_snd_reports;
}

View File

@ -9,7 +9,7 @@
* Modified by Bill Fenner, PARC, April 1995
*
* MROUTING Revision: 3.5
* $Id: ip_mroute.c,v 1.30 1996/03/11 17:11:23 fenner Exp $
* $Id: ip_mroute.c,v 1.31 1996/03/26 19:16:44 fenner Exp $
*/
#include "opt_mrouting.h"
@ -1906,11 +1906,12 @@ tbf_send_packet(vifp, m)
{
struct ip_moptions imo;
int error;
static struct route ro;
int s = splnet();
if (vifp->v_flags & VIFF_TUNNEL) {
/* If tunnel options */
ip_output(m, (struct mbuf *)0, (struct route *)0,
ip_output(m, (struct mbuf *)0, &vifp->v_route,
IP_FORWARDING, (struct ip_moptions *)0);
} else {
imo.imo_multicast_ifp = vifp->v_ifp;
@ -1918,7 +1919,13 @@ tbf_send_packet(vifp, m)
imo.imo_multicast_loop = 1;
imo.imo_multicast_vif = -1;
error = ip_output(m, (struct mbuf *)0, (struct route *)0,
/*
* Re-entrancy should not be a problem here, because
* the packets that we send out and are looped back at us
* should get rejected because they appear to come from
* the loopback interface, thus preventing looping.
*/
error = ip_output(m, (struct mbuf *)0, &ro,
IP_FORWARDING, &imo);
if (mrtdebug & DEBUG_XMIT)