Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755539Ab0FXNkz (ORCPT ); Thu, 24 Jun 2010 09:40:55 -0400 Received: from g6t0187.atlanta.hp.com ([15.193.32.64]:17395 "EHLO g6t0187.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755329Ab0FXNky (ORCPT ); Thu, 24 Jun 2010 09:40:54 -0400 Message-ID: <4C236063.9050302@hp.com> Date: Thu, 24 Jun 2010 09:40:51 -0400 From: Vlad Yasevich User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: =?UTF-8?B?RGllZ28gRWxpbyDigJxGbGFtZWV5ZXPigJ0gUGV0dGVuw7I=?= CC: linux-kernel@vger.kernel.org, linux-sctp@vger.kernel.org Subject: Re: [PATCH] sctp: implement SIOCINQ ioctl() References: <1277329060-21543-1-git-send-email-flameeyes@gmail.com> <4C235B75.2000807@hp.com> <1277385636.13544.67.camel@yamato.local> In-Reply-To: <1277385636.13544.67.camel@yamato.local> X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1881 Lines: 48 Diego Elio “Flameeyes” Pettenò wrote: > Il giorno gio, 24/06/2010 alle 09.19 -0400, Vlad Yasevich ha scritto: >> This should add a check for sctp_style(sk, TCP), since one can't read >> from >> a TCP style listening sockets, but can do so from UDP-style >> (SOCK_SEQPACKET). > > I don't want to sound arrogant but... are you sure? Yes, I am sure. :) > > I ask because the simple testcase I wrote to make sure I didn't get it > wrong opened the socket as SOCK_STREAM, and yet all of this worked fine > (I'm attaching the source, for the sake of it)... > > I sure hope you're mistaken here and it is _supposed_ to work here as > well, as we cannot use SOCK_SEQPACKET in the software I'm writing this > for (feng, from the lscube project) as accept() fails on SOCK_SEQPACKET > (EOPNOTSUPP) -- which itslef is strange given that the man page for > accept(2) reports it's supported on SOCK_STREAM and SOCK_SEQPACKET. > You don't call accept() on an SCTP SEQPACKET socket. You can just read from it. SCTP uses SOCK_SEQPACKET to implement 1-to-many semantics, where you can have multiple associations all serviced by the same socket. In that case, the socket is placed into the listening state and then the application may simply read from it. Thus your code that just returns the size of the first skb should take that into consideration. So the condition really is: if (sctp_style(sk, TCP) && sctp_state(sk, LISTENING)) goto out; This way, you'll ignore listening SOCK_STREAM sockets which will not have any data anyway, but you'll check out listening SOCK_SEQPACKET sockets that may have data waiting on them. -vlad -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/