From owner-freebsd-bluetooth@FreeBSD.ORG Sat Oct 13 22:19:41 2012 Return-Path: Delivered-To: freebsd-bluetooth@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 66A2CA7B for ; Sat, 13 Oct 2012 22:19:41 +0000 (UTC) (envelope-from longwitz@incore.de) Received: from dss.incore.de (dss.incore.de [195.145.1.138]) by mx1.freebsd.org (Postfix) with ESMTP id 1DAD78FC0A for ; Sat, 13 Oct 2012 22:19:40 +0000 (UTC) Received: from secmail.incore (inetdns.dmz [10.1.0.3]) by dss.incore.de (Postfix) with ESMTP id 1A4365D424; Sun, 14 Oct 2012 00:19:33 +0200 (CEST) Received: from lolap.longwitz (ip-2-204-14-210.web.vodafone.de [2.204.14.210]) by secmail.incore (Postfix) with ESMTPS id AD1C55C14; Sun, 14 Oct 2012 00:19:32 +0200 (CEST) Message-ID: <5079E8F7.5050903@incore.de> Date: Sun, 14 Oct 2012 00:19:35 +0200 From: Andreas Longwitz User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:7.0.1) Gecko/20111007 Thunderbird/7.0.1 MIME-Version: 1.0 To: Maksim Yevmenkin Subject: Re: btpand problem References: <507736A8.4050605@incore.de> <5077490F.7010901@incore.de> <50782E05.5080005@incore.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-bluetooth@freebsd.org X-BeenThere: freebsd-bluetooth@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Using Bluetooth in FreeBSD environments List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Oct 2012 22:19:41 -0000 Hi, >>> Yes, I used the code fragment >>> >>> { >>> uint16_t mtu; >>> socklen_t len = sizeof(mtu); >>> getsockopt(chan->fd, SOL_L2CAP, SO_L2CAP_OMTU,&mtu,&len); >>> log_err("writev: %m (mtu %d)\n", mtu); >>> } >>> >>> and found mtu=1691 in all cases (ok or failed), same for SO_L2CAP_IMTU. >> >> I see, so it seems that the kernel is returning EMSGSIZE when trying to >> send a packet that is greater than L2CAP_MTU_DEFAULT.. >> >> you could build the bluetooth netgraph code with debugging turned on, and >> see if that kicked anything out about where the error is returned from.. >> The most obvious place to look at could be ng_btsocket_l2cap_send(), if >> that is the one, is pcb->omtu the correct value? > > there should be sysctl knobs to increase debug level for sockets and > ng messages for ng nodes. > > so, yes, please try to increase debug level for l2cap nodes and > sockets and see if anything pops up After increasing debug_level for net.bluetooth.l2cap from 3 --> 4 and adding a statement NG_BTSOCKET_L2CAP_INFO(..) in ng_btsocket_l2cap_send it was clear to me that in the case of the failed writev none of the debug statements triggers. This information pointed me to the possible solution of the problem. The reason for the EMSGSIZE error is the size of the send space reserved with soreserve() in ng_btsocket_l2cap_attach. After changing (in ng_btsocket_l2cap.h) the line #define NG_BTSOCKET_L2CAP_SENDSPACE NG_L2CAP_MTU_DEFAULT /* (64 * 1024) */ to #define NG_BTSOCKET_L2CAP_SENDSPACE (64 * 1024) the error is gone. Please verify if this correction is suitable. Andreas Longwitz