From patchwork Mon Nov 24 21:49:40 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernard Pidoux X-Patchwork-Id: 10531 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 254D2DDD01 for ; Tue, 25 Nov 2008 09:43:47 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753309AbYKXWnm (ORCPT ); Mon, 24 Nov 2008 17:43:42 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753285AbYKXWnl (ORCPT ); Mon, 24 Nov 2008 17:43:41 -0500 Received: from smtp2-g19.free.fr ([212.27.42.28]:38347 "EHLO smtp2-g19.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753233AbYKXWnk (ORCPT ); Mon, 24 Nov 2008 17:43:40 -0500 Received: from smtp2-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp2-g19.free.fr (Postfix) with ESMTP id 5806C12C240; Mon, 24 Nov 2008 23:07:25 +0100 (CET) Received: from [192.168.0.66] (car75-2-82-66-61-83.fbx.proxad.net [82.66.61.83]) by smtp2-g19.free.fr (Postfix) with ESMTP id 42EB112BDD6; Mon, 24 Nov 2008 22:49:41 +0100 (CET) Message-ID: <492B2174.1030503@upmc.fr> Date: Mon, 24 Nov 2008 22:49:40 +0100 From: Bernard Pidoux Organization: Universite Pierre & Marie Curie - Paris 6 User-Agent: Thunderbird 2.0.0.12 (X11/20080306) MIME-Version: 1.0 To: Linux Netdev List , linux-hams CC: Ralf Baechle DL5RB , David Miller Subject: [PATCH] [ROSE] zero length frame filtering in af_rose.c Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since changeset e79ad711a0108475c1b3a03815527e7237020b08 from mainline, From David S. Miller, empty packet can be transmitted on connected socket for datagram protocols. However, this patch broke a high level application using ROSE network protocol with connected datagram. Bulletin Board Stations perform bulletins forwarding between BBS stations via ROSE network using a forward protocol. Now, if for some reason, a buffer in the application software happens to be empty at a specific moment, ROSE sends an empty packet via unfiltered packet socket. When received, this ROSE packet introduces perturbations of data exchange of BBS forwarding, for the application message forwarding protocol is waiting for something else. We agree that a more careful programming of the application protocol would avoid this situation and we are willing to debug it. But, as an empty frame is no use and does not have any meaning for ROSE protocol, we may consider filtering zero length data both when sending and receiving socket data. The proposed patch repaired BBS data exchange through ROSE network that were broken since 2.6.22.11 kernel. Signed-off-by: Bernard Pidoux --- net/rose/af_rose.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 8a54cff..92af3a6 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c @@ -1075,6 +1075,10 @@ static int rose_sendmsg(struct kiocb *iocb, struct socket *sock, unsigned char *asmptr; int n, size, qbit = 0; + /* ROSE empty frame has no meaning : don't send */ + if (len == 0) + return 0; + if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_EOR|MSG_CMSG_COMPAT)) return -EINVAL; @@ -1268,6 +1272,12 @@ static int rose_recvmsg(struct kiocb *iocb, struct socket *sock, skb_reset_transport_header(skb); copied = skb->len; + /* ROSE empty frame has no meaning : ignore it */ + if (copied == 0) { + skb_free_datagram(sk, skb); + return copied; + } + if (copied > size) { copied = size; msg->msg_flags |= MSG_TRUNC;