From owner-freebsd-net@FreeBSD.ORG  Mon May 24 02:17:39 2004
Return-Path: <owner-freebsd-net@FreeBSD.ORG>
Delivered-To: freebsd-net@freebsd.org
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9870E16A4CE
	for <freebsd-net@freebsd.org>; Mon, 24 May 2004 02:17:39 -0700 (PDT)
Received: from smtp-out2.xs4all.nl (smtp-out2.xs4all.nl [194.109.24.12])
	by mx1.FreeBSD.org (Postfix) with ESMTP id C87E843D1F
	for <freebsd-net@freebsd.org>; Mon, 24 May 2004 02:17:38 -0700 (PDT)
	(envelope-from wim@mediamessage.nl)
Received: from waldo (gwbw.xs4all.nl [213.84.100.200])
	by smtp-out2.xs4all.nl (8.12.10/8.12.10) with ESMTP id i4O9H5K1040887
	for <freebsd-net@freebsd.org>; Mon, 24 May 2004 11:17:05 +0200 (CEST)
Received: from localhost (waldo [127.0.0.1])
	by waldo (Postfix) with ESMTP id 84E6F36B50
	for <freebsd-net@freebsd.org>; Mon, 24 May 2004 11:17:03 +0200 (CEST)
Received: from waldo ([127.0.0.1])
	by localhost (waldo [127.0.0.1]) (amavisd-new, port 10024) with ESMTP
	id 11675-09 for <freebsd-net@freebsd.org>;
	Mon, 24 May 2004 11:16:56 +0200 (CEST)
Received: from crazyharry.buyways.nl (crazyharry.buyways.nl [192.168.218.74])
	by waldo (Postfix) with ESMTP id CB93536B4C
	for <freebsd-net@freebsd.org>; Mon, 24 May 2004 11:16:55 +0200 (CEST)
From: Wim Rijnders <wim@mediamessage.nl>
To: freebsd-net@freebsd.org
Content-Type: text/plain
Message-Id: <1085390095.633.26.camel@crazyharry>
Mime-Version: 1.0
X-Mailer: Ximian Evolution 1.4.5 
Date: Mon, 24 May 2004 11:14:55 +0200
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: by amavisd-new-20030616-p7 (Debian) at buyways.nl
Subject: netgraph: kernel panic due to M_DONTWAIT when connecting ksocket
X-BeenThere: freebsd-net@freebsd.org
X-Mailman-Version: 2.1.1
Precedence: list
List-Id: Networking and TCP/IP with FreeBSD <freebsd-net.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/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: Mon, 24 May 2004 09:17:39 -0000

Hello,

When trying to use a netgraph ksocket for a tcp connection, we get a
kernel panic on opening the connection. The panic is a result of a
KASSERT() on the value of a flag which we don't set ourselves and which
we don't appear to have control over.

Details of our investigation follow. What can we do to fix this?

---
We're using the 5.2-CURRENT release.

* We use ksockets in netgraph to create a tcp connection. The kernel
panics when creating a connection with code similar to:

    result= NgSendMsg(ctrlSoc, path, NGM_KSOCKET_COOKIE,
                 NGM_KSOCKET_CONNECT, &addr, sizeof(addr) )
 
* The kernel panic occurs in ng_ksocket.c , function
ng_ksocket_incoming2() on a call to macro NG_MKMESSAGE().

This macro is defined in ng_message.h. One of the first things it does
is perform this KASSERT():

KASSERT(!(how & M_DONTWAIT),                                  \
     ("NG_MKMESSAGE() with how=M_DONTWAIT (%d)\n", how));      \   


* We do not set the  M_DONTWAIT flag anywhere our code. The setting can
be traced to call in sowakeup(), line 320 in
/usr/src/sys/kern/uipc_socket2.c:

    if (sb->sb_flags & SB_UPCALL)
        sh freebeer*so->so_upcall)(so, so->so_upcallarg, M_DONTWAIT);
---

Kind regards,

Wim Rijnders
Buyways BV.