Re: natd broken for days

From: Poul-Henning Kamp <phk_at_phk.freebsd.dk>
Date: Thu, 11 Nov 2004 19:53:17 +0100
Looks good.

In message <20041111172657.GF66206_at_cell.sick.ru>, Gleb Smirnoff writes:
>
>--J2SCkAp4GZ/dPZZf
>Content-Type: text/plain; charset=koi8-r
>Content-Disposition: inline
>
>On Thu, Nov 11, 2004 at 05:40:29PM +0100, Poul-Henning Kamp wrote:
>P> In message <20041111163638.GA700_at_laptop.6bone.nl>, Mark Santcroos writes:
>P> >On Thu, Nov 11, 2004 at 05:25:23AM -0800, Sean McNeil wrote:
>P> >> It has been reported that both amd64 and i386 architectures will panic
>P> >> in natd by jumping to address 0.  There has been no discussion since the
>P> >> reports, however, and I was wondering if anyone is looking into it.
>P> >
>P> >This should fix it.
>P> 
>P> We have a problem if that is the case, because then ipdivert
>P> doesn't run through net_init_domain() :-(
>
>Poul-Henning, can you review attached patch?
>
>Conrad, can you test it?
>
>-- 
>Totus tuus, Glebius.
>GLEBIUS-RIPN GLEB-RIPE
>
>--J2SCkAp4GZ/dPZZf
>Content-Type: text/plain; charset=koi8-r
>Content-Disposition: attachment; filename="uipc_domain.c.diff"
>
>Index: uipc_domain.c
>===================================================================
>RCS file: /home/ncvs/src/sys/kern/uipc_domain.c,v
>retrieving revision 1.39
>diff -u -r1.39 uipc_domain.c
>--- uipc_domain.c	8 Nov 2004 14:44:52 -0000	1.39
>+++ uipc_domain.c	11 Nov 2004 17:23:42 -0000
>_at__at_ -97,6 +97,34 _at__at_
> 	.pru_sosetlabel =	pru_sosetlabel_null
> };
> 
>+static void
>+protosw_init(struct protosw *pr)
>+{
>+	struct pr_usrreqs *pu;
>+
>+	pu = pr->pr_usrreqs;
>+	KASSERT(pu != NULL, ("protosw_init: %ssw[%d] has no usrreqs!",
>+	    pr->pr_domain->dom_name,
>+	    (int)(pr - pr->pr_domain->dom_protosw)));
>+
>+#define DEFAULT(foo, bar)	if ((foo) == NULL)  (foo) = (bar)
>+	DEFAULT(pu->pru_accept, pru_accept_notsupp);
>+	DEFAULT(pu->pru_connect, pru_connect_notsupp);
>+	DEFAULT(pu->pru_connect2, pru_connect2_notsupp);
>+	DEFAULT(pu->pru_control, pru_control_notsupp);
>+	DEFAULT(pu->pru_listen, pru_listen_notsupp);
>+	DEFAULT(pu->pru_rcvd, pru_rcvd_notsupp);
>+	DEFAULT(pu->pru_rcvoob, pru_rcvoob_notsupp);
>+	DEFAULT(pu->pru_sense, pru_sense_null);
>+	DEFAULT(pu->pru_sosend, sosend);
>+	DEFAULT(pu->pru_soreceive, soreceive);
>+	DEFAULT(pu->pru_sopoll, sopoll);
>+	DEFAULT(pu->pru_sosetlabel, pru_sosetlabel_null);
>+#undef DEFAULT
>+	if (pr->pr_init)
>+		(*pr->pr_init)();
>+}
>+
> /*
>  * Add a new protocol domain to the list of supported domains
>  * Note: you cant unload it again because a socket may be using it.
>_at__at_ -106,33 +134,11 _at__at_
> net_init_domain(struct domain *dp)
> {
> 	struct protosw *pr;
>-	struct pr_usrreqs *pu;
> 
> 	if (dp->dom_init)
> 		(*dp->dom_init)();
>-	for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++){
>-		pu = pr->pr_usrreqs;
>-		KASSERT(pu != NULL, 
>-		    ("domaininit: %ssw[%d] has no usrreqs!",
>-		    dp->dom_name, (int)(pr - dp->dom_protosw)));
>-#define DEFAULT(foo, bar)	if ((foo) == NULL)  (foo) = (bar)
>-		DEFAULT(pu->pru_accept, pru_accept_notsupp);
>-		DEFAULT(pu->pru_connect, pru_connect_notsupp);
>-		DEFAULT(pu->pru_connect2, pru_connect2_notsupp);
>-		DEFAULT(pu->pru_control, pru_control_notsupp);
>-		DEFAULT(pu->pru_listen, pru_listen_notsupp);
>-		DEFAULT(pu->pru_rcvd, pru_rcvd_notsupp);
>-		DEFAULT(pu->pru_rcvoob, pru_rcvoob_notsupp);
>-		DEFAULT(pu->pru_sense, pru_sense_null);
>-		DEFAULT(pu->pru_sosend, sosend);
>-		DEFAULT(pu->pru_soreceive, soreceive);
>-		DEFAULT(pu->pru_sopoll, sopoll);
>-		DEFAULT(pu->pru_sosetlabel, pru_sosetlabel_null);
>-#undef DEFAULT
>-
>-		if (pr->pr_init)
>-			(*pr->pr_init)();
>-	}
>+	for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
>+		protosw_init(pr);
> 	/*
> 	 * update global information about maximums
> 	 */
>_at__at_ -298,8 +304,7 _at__at_
> 	mtx_unlock(&Giant);
> 
> 	/* Initialize and activate the protocol. */
>-	if (fpr->pr_init)
>-		(fpr->pr_init)();
>+	protosw_init(fpr);
> 
> 	return (0);
> }
>
>--J2SCkAp4GZ/dPZZf--
>

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk_at_FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.
Received on Thu Nov 11 2004 - 17:53:24 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:21 UTC