From owner-freebsd-net@FreeBSD.ORG Wed Dec 18 21:04:45 2013 Return-Path: <owner-freebsd-net@FreeBSD.ORG> Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 31B244EC; Wed, 18 Dec 2013 21:04:45 +0000 (UTC) Received: from mail-qa0-x22a.google.com (mail-qa0-x22a.google.com [IPv6:2607:f8b0:400d:c00::22a]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D57D713D1; Wed, 18 Dec 2013 21:04:44 +0000 (UTC) Received: by mail-qa0-f42.google.com with SMTP id k4so4123494qaq.15 for <multiple recipients>; Wed, 18 Dec 2013 13:04:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:cc:content-type; bh=bl1uflZ59yHSNTnRn6/Ls3ZRyhVhre4pTBYF+Hdongs=; b=Fy8zigV1vBK85tPNofpjAz9DQtfESZspuP5tF3JjP6cljvWWuy6ZzaAhQPW1XPO/ar di1akPLP+27K9A/Cv+C6R9eIM8Gqx/dCxqP7mI9adJw++HTZVQAolUW4zE+Mm3+R/GOY ZS9dfNJZcbHmnSpsEoZLNP59jbzMuHyYDvtoYYwy8aqTspkaUKBS7ZABvYm0KIz4X0fQ gemfkmjjlePv5yMB0CremaDDA4U9iehgG2oC1URh4TYuhyCPcw6QeOdWetQluJqjFKPT z/klZ/SkEqtZa8Y51izpjaCP6SKosA+yx6IFAwwaXdbSH82dS8K69p/inL6HCUe8XtEn JLpQ== MIME-Version: 1.0 X-Received: by 10.224.50.195 with SMTP id a3mr56612825qag.25.1387400684034; Wed, 18 Dec 2013 13:04:44 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.224.53.200 with HTTP; Wed, 18 Dec 2013 13:04:43 -0800 (PST) Date: Wed, 18 Dec 2013 13:04:43 -0800 X-Google-Sender-Auth: 6DxBAGLryJOu4cHWkIza0YuPVOk Message-ID: <CAJ-VmomyPq_2K-MFhb7vt6MM7RBbmn7yaTzUXb7+N7TbW1RmHQ@mail.gmail.com> Subject: Removing queue length check in ip_output (was Re: buf_ring in HEAD is racy) From: Adrian Chadd <adrian@freebsd.org> To: Ryan Stone <rysto32@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Cc: Jack F Vogel <jfv@freebsd.org>, Michael Tuexen <Michael.Tuexen@lurchi.franken.de>, freebsd-net <freebsd-net@freebsd.org> X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Networking and TCP/IP with FreeBSD <freebsd-net.freebsd.org> List-Unsubscribe: <http://lists.freebsd.org/mailman/options/freebsd-net>, <mailto:freebsd-net-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/freebsd-net/> List-Post: <mailto:freebsd-net@freebsd.org> List-Help: <mailto:freebsd-net-request@freebsd.org?subject=help> List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-net>, <mailto:freebsd-net-request@freebsd.org?subject=subscribe> X-List-Received-Date: Wed, 18 Dec 2013 21:04:45 -0000 How about we can this check in ip_output(): /* * 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. */ n = ip_len / mtu + 1; /* how many fragments ? */ if ( #ifdef ALTQ (!ALTQ_IS_ENABLED(&ifp->if_snd)) && #endif /* ALTQ */ (ifp->if_snd.ifq_len + n) >= ifp->if_snd.ifq_maxlen ) { error = ENOBUFS; IPSTAT_INC(ips_odropped); ifp->if_snd.ifq_drops += n; goto bad; } .. it's totally bogus in an if_transmit / SMP world. There's no locking and there's no guarantee that there will be headroom in the queue between this point and the later call to the if_output() method. -adrian