From owner-freebsd-bugs@FreeBSD.ORG Fri Mar 8 23:30:00 2013 Return-Path: <owner-freebsd-bugs@FreeBSD.ORG> Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D8837DD4 for <freebsd-bugs@smarthost.ysv.freebsd.org>; Fri, 8 Mar 2013 23:30:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id BBB12F51 for <freebsd-bugs@smarthost.ysv.freebsd.org>; Fri, 8 Mar 2013 23:30:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r28NU0jP079264 for <freebsd-bugs@freefall.freebsd.org>; Fri, 8 Mar 2013 23:30:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r28NU0E5079252; Fri, 8 Mar 2013 23:30:00 GMT (envelope-from gnats) Resent-Date: Fri, 8 Mar 2013 23:30:00 GMT Resent-Message-Id: <201303082330.r28NU0E5079252@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Keith Reynolds <keith.reynolds@tidalscale.com> Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 8927CDAB for <freebsd-gnats-submit@FreeBSD.org>; Fri, 8 Mar 2013 23:26:16 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 622B4F3D for <freebsd-gnats-submit@FreeBSD.org>; Fri, 8 Mar 2013 23:26:16 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r28NQFeC063318 for <freebsd-gnats-submit@FreeBSD.org>; Fri, 8 Mar 2013 23:26:15 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id r28NQF69063317; Fri, 8 Mar 2013 23:26:15 GMT (envelope-from nobody) Message-Id: <201303082326.r28NQF69063317@red.freebsd.org> Date: Fri, 8 Mar 2013 23:26:15 GMT From: Keith Reynolds <keith.reynolds@tidalscale.com> To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: misc/176771: user-mode netgraph node hangs when replying to control message X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports <freebsd-bugs.freebsd.org> List-Unsubscribe: <http://lists.freebsd.org/mailman/options/freebsd-bugs>, <mailto:freebsd-bugs-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/freebsd-bugs> List-Post: <mailto:freebsd-bugs@freebsd.org> List-Help: <mailto:freebsd-bugs-request@freebsd.org?subject=help> List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-bugs>, <mailto:freebsd-bugs-request@freebsd.org?subject=subscribe> X-List-Received-Date: Fri, 08 Mar 2013 23:30:00 -0000 >Number: 176771 >Category: misc >Synopsis: user-mode netgraph node hangs when replying to control message >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Mar 08 23:30:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Keith Reynolds >Release: 10.0-CURRENT >Organization: TidalScale >Environment: FreeBSD ts_bhyve1.local 10.0-CURRENT FreeBSD 10.0-CURRENT #1 r245569: Tue Mar 5 14:24:01 PST 2013 root@ts_bhyve1.local:/usr/obj/usr/src/sys/TS amd64 >Description: When a netgraph client calls NgSendReplyMsg() to reply to a netgraph control message that is marked as having a reply (msg->header.cmd & NGM_HASREPLY), the library blocks waiting for a reply that will never come, because the message that's being sent *IS* the reply. It doesn't account for the possibility that the user-mode client is replying to a netgraph control message rather than originating one. >How-To-Repeat: Write a user-mode netgraph client that responds to the NGM_GENERIC_COOKIE/NGM_TEXT_STATUS control message, which is marked as NGM_HASREPLY, and use "ngctl status <node_path>" to query it. The call to NgSendReplyMsg() will block until another control message comes in, which won't happen until you use ngctl to send another request. >Fix: See the attached patch to lib/libnetgraph/msg.c. The change checks msg->header.flags & NGF_RESP to determine if the message being sent is the expected reply before blocking to wait for one. Patch attached with submission follows: Index: msg.c =================================================================== --- msg.c (revision 245569) +++ msg.c (working copy) @@ -234,7 +234,7 @@ } /* Wait for reply if there should be one. */ - if (msg->header.cmd & NGM_HASREPLY) { + if (msg->header.cmd & NGM_HASREPLY && !(msg->header.flags & NGF_RESP)) { struct pollfd rfds; int n; >Release-Note: >Audit-Trail: >Unformatted: