Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Aug 2002 05:54:38 +0900
From:      JINMEI Tatuya / =?ISO-2022-JP?B?GyRCP0BMQEMjOkgbKEI=?= <jinmei@isl.rdc.toshiba.co.jp>
To:        Julian Elischer <julian@elischer.org>
Cc:        freebsd-net@FreeBSD.ORG
Subject:   Re: Error in UDP output processing?
Message-ID:  <y7vn0rqzdgx.wl@ocean.jinmei.org>
In-Reply-To: <Pine.BSF.4.21.0208131252440.17577-100000@InterJet.elischer.org>
References:  <y7vy9bazls9.wl@ocean.jinmei.org> <Pine.BSF.4.21.0208131252440.17577-100000@InterJet.elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
>>>>> On Tue, 13 Aug 2002 12:54:19 -0700 (PDT), 
>>>>> Julian Elischer <julian@elischer.org> said:

>> > 	I'm looking at the -STABLE sources for a bug we're having at work with
>> > a high capacity server that uses UDP.
>> 
>> > 	The bug is that when we run out of mbufs in udp_output() we do NOT
>> > disconnect the socket that caused the error.  All error cases goto release: 
>> > which
>> > is after the in_pcbdisconnect() call.  Is this intentional?
>> 
>> I don't think so.  The socket should be disconnected before returning
>> the error.

> Why?
> dropping a udp packet due to lack of local resources shouldn't affect the
> state of the socket.. just as having a router drop the packet shouldn't 
> affect it.. I don't understnad the question I guess.

I guess I was not clear.  I read the original message to mean
temporarily connected UDP sockets.  With the current code (I'm looking
at the rev. 1.64.2.15 of udp_usrreq.c) once the error happens the
socket will be locked as connected, and will not be able to receive
from other sources than the foreign address (while it should be,
because it is not connected by the application).

The fix would be like this (btw: we may want to combine the disconnect
part to avoid code duplication):

--- udp_usrreq.c.orig	Tue Aug 13 13:49:50 2002
+++ udp_usrreq.c	Tue Aug 13 13:52:34 2002
@@ -704,9 +704,7 @@
 	M_PREPEND(m, sizeof(struct udpiphdr), M_DONTWAIT);
 	if (m == 0) {
 		error = ENOBUFS;
-		if (addr)
-			splx(s);
-		goto release;
+		goto disconnect;
 	}
 
 	/*
@@ -741,7 +739,7 @@
 #ifdef IPSEC
 	if (ipsec_setsocket(m, inp->inp_socket) != 0) {
 		error = ENOBUFS;
-		goto release;
+		goto disconnect;
 	}
 #endif /*IPSEC*/
 	error = ip_output(m, inp->inp_options, &inp->inp_route,
@@ -754,6 +752,13 @@
 		splx(s);
 	}
 	return (error);
+
+disconnect:
+	if (addr) {
+		in_pcbdisconnect(inp);
+		inp->inp_laddr = laddr;	/* XXX rehash? */
+		splx(s);
+	}
 
 release:
 	m_freem(m);

					JINMEI, Tatuya
					Communication Platform Lab.
					Corporate R&D Center, Toshiba Corp.
					jinmei@isl.rdc.toshiba.co.jp

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?y7vn0rqzdgx.wl>