From owner-freebsd-net@FreeBSD.ORG Thu Dec 19 19:59:07 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AB6ADB6F; Thu, 19 Dec 2013 19:59:07 +0000 (UTC) Received: from mail-qa0-x22c.google.com (mail-qa0-x22c.google.com [IPv6:2607:f8b0:400d:c00::22c]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 41A4C1327; Thu, 19 Dec 2013 19:59:07 +0000 (UTC) Received: by mail-qa0-f44.google.com with SMTP id i13so5212067qae.10 for ; Thu, 19 Dec 2013 11:59:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=OV33OWgXJAkYasNGb2tgucrVkNOYSSB686kbGz+G8Fk=; b=WPDnfA46xLYPTKCF0TYDdSnPjTO1Kpares3qMxvQkceVBC+LRckAGiXodUcks2fM79 9abetrp7v2KqriZ+ccu72aJFCpNtzgve0gk6HWQUfFQzvCCCufFF0TqOFICEditeGEIp r/XneX3vuwVx4+Ms9WeKDHsSjQ/bQxU92VY5Wsw7R0X4ILNlA3ADn2XRXiHM16MAovxU +kjUm+VyMmDmfdcB1Ka6HzGUJKuYXH7fvYT94d/hpDHcLy9/IGc6DlZ58q9mWeTrWi5y U0i28tDIOxQO9eYjlu2Vx/Bmqzaw0F+5KLjEheIv4IYc7oOMCLhOmI2tAlzWNplb7cKz 9DGQ== MIME-Version: 1.0 X-Received: by 10.49.129.38 with SMTP id nt6mr6564570qeb.78.1387483146476; Thu, 19 Dec 2013 11:59:06 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.224.53.200 with HTTP; Thu, 19 Dec 2013 11:59:06 -0800 (PST) In-Reply-To: References: <20131219151606.GB71033@FreeBSD.org> Date: Thu, 19 Dec 2013 11:59:06 -0800 X-Google-Sender-Auth: 8d637BCPJ7zKxakOVZeTjrzO66Y Message-ID: Subject: Re: Removing queue length check in ip_output (was Re: buf_ring in HEAD is racy) From: Adrian Chadd To: Gleb Smirnoff Content-Type: text/plain; charset=ISO-8859-1 Cc: Jack F Vogel , Michael Tuexen , Ryan Stone , freebsd-net X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Dec 2013 19:59:07 -0000 How's this? Index: sys/netinet/ip_output.c =================================================================== --- sys/netinet/ip_output.c (revision 259474) +++ sys/netinet/ip_output.c (working copy) @@ -123,7 +123,9 @@ struct mbuf *m0; int hlen = sizeof (struct ip); int mtu; +#if 0 int n; /* scratchpad */ +#endif int error = 0; struct sockaddr_in *dst; const struct sockaddr_in *gw; @@ -431,6 +433,25 @@ } /* + * Both in the SMP world, pre-emption world if_transmit() world, + * the following code doesn't really function as intended any further. + * + * + There can and will be multiple CPUs running this code path + * in parallel, and we do no lock holding when checking the + * queue depth; + * + And since other threads can be running concurrently, even if + * we do pass this check, another thread may queue some frames + * before this thread does and it will end up partially or fully + * failing to send anyway; + * + if_transmit() based drivers don't necessarily set ifq_len + * at all. + * + * This should be replaced with a method of pushing an entire list + * of fragment frames to the driver and have the driver decide + * whether it can queue or not queue the entire set. + */ +#if 0 + /* * Verify that we have any chance at all of being able to queue the * packet or packet fragments, unless ALTQ is enabled on the given * interface in which case packetdrop should be done by queueing. @@ -446,6 +467,7 @@ ifp->if_snd.ifq_drops += n; goto bad; } +#endif /* * Look for broadcast address and -a