Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp252619imp; Thu, 21 Feb 2019 00:23:40 -0800 (PST) X-Google-Smtp-Source: AHgI3IbQhRSt44PQRI9qg+VE+yAi3YrzrP706HIVMuq/VlQSURpZUlpVOZjfsWspB+VDEDCVe6sV X-Received: by 2002:a17:902:1008:: with SMTP id b8mr40266091pla.252.1550737420062; Thu, 21 Feb 2019 00:23:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550737420; cv=none; d=google.com; s=arc-20160816; b=wwiIO3x1JVh5TnEwOWZGGfc9w2z2JXKKDgOlDxOjv7LTw/gPozKd6M57nWq/R/zdRA /RnOkyPDP+Tt87NtYRzaZ4EN5xwhRYjbRHX2ZoGV60XoGgAizBIsFRJXZ6S71eTkklOs nLri1E1O6W3/iU5Dm/wodaf9aR5LUpYlEIzmV2uwdNsSw2M1kVnaBd9wf5O2+9u3MV/a G5h7dop0IL3wGSWcyymny+52XwzrW+H0AjYieBEIRiQwM6teDkOQgCQ6k0ueNP+iZ4Zr yzOf6WDt4N3H9YTXXnGSOJLAuUrm/cHkSCDxEgjdTF6PBHOrQJYtItcNmNb7J3dboYkq C6jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=TRIrOV0UaVnX88ywIRB+Ioa4KO9NF1Q7cZffdjhobtc=; b=nLiwi/ioEZMN5BsDgdiqqDRxQ6uLzGVnqwcw5Pj10wJPL2Mmw9vqrGOkUUQ6cUibyV AxoH//hS1mfUzcFtgTvWRAhXJ4bsrf1VcYleeQ4e5gjZNO+VeP/t52V+9vpgyGM6w06x 2wmIAIHazWgw6DH8GI7d/oucovaC201gTXA3lIJ/M9O3Llcql+Nu5YpX5qrwEObfsoBT Ku5j70b0/fxz9lNxXk4ZvBzKA6z3j2cLGNTGcgcGK4S+9XBn9J97osR6SlFXSh7F0vQx e+8VDJGd3Aml4SVjl6hPchS1Zn5FwPXJrlhS2D8hUN0GXmkSv18HhSgoUM5RsLVXkvyL BMEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j73si1830493pge.263.2019.02.21.00.23.24; Thu, 21 Feb 2019 00:23:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727406AbfBUIWa (ORCPT + 99 others); Thu, 21 Feb 2019 03:22:30 -0500 Received: from nautica.notk.org ([91.121.71.147]:55415 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727088AbfBUIW3 (ORCPT ); Thu, 21 Feb 2019 03:22:29 -0500 Received: by nautica.notk.org (Postfix, from userid 1001) id D1AE3C009; Thu, 21 Feb 2019 09:22:24 +0100 (CET) Date: Thu, 21 Feb 2019 09:22:09 +0100 From: Dominique Martinet To: Tom Herbert Cc: Tom Herbert , David Miller , Doron Roberts-Kedes , Dave Watson , Linux Kernel Network Developers , LKML Subject: Re: [PATCH v2] kcm: remove any offset before parsing messages Message-ID: <20190221082209.GA32719@nautica> References: <20181031025657.GA17861@nautica> <20190215010029.GA10899@nautica> <20190215015705.GA17974@nautica> <20190215033102.GA3099@nautica> <20190215045214.GA13123@nautica> <20190220041151.GA13520@nautica> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tom Herbert wrote on Wed, Feb 20, 2019: > > When the client closes the socket, some messages are obviously still "in > > flight", and the server will recv a POLLERR notification on the csock at > > some point with many messages left. > > The documentation says to unattach the csock when you get POLLER. If I > > do that, the kcm socket will no longer give me any message, so all the > > messages still in flight at the time are lost. > > So basically it sounds like you're interested in supporting TCP > connections that are half closed. I believe that the error in half > closed is EPIPE, so if the TCP socket returns that it can be ignored > and the socket can continue being attached and used to send data. Did you mean 'can continue being attached and used to receive data'? I can confirm getsockopt with SO_ERROR gets me EPIPE, but I don't see how to efficiently ignore EPIPE until POLLIN gets unset -- polling on both the csock and kcm socket will do many needless wakeups on only the csock from what I can see, so I'd need some holdoff timer or something. I guess it's possible though. > Another possibility is to add some linger semantics to an attached > socket. For instance, a large message might be sent so that part of > the messge is queued in TCP and part is queued in the KCM socket. > Unattach would probably break that message. We probably want to linger > option similar to SO_LINGER (or maybe just use the option on the TCP > socket) that means don't complete the detach until any message being > transmitted on the lower socket has been queued. That would certainly work, even if non-obvious from a user standpoint. > > > I'd like to see some retry on ENOMEM before this is merged though, so > > > while I'm there I'll resend this with a second patch doing that > > > retry,.. I think just not setting strp->interrupted and not reporting > > > the error up might be enough? Will have to try either way. > > > > I also tried playing with that without much success. > > I had assumed just not calling strp_parser_err() (which calls the > > abort_parser cb) would be enough, eventually calling strp_start_timer() > > like the !len case, but no can do. > > I think you need to ignore the ENOMEM and have a timer or other > callback to retry the operation in the future. Yes, that's what I had intended to try; basically just break out and schedule timer as said above. After a bit more debugging, this part works (__strp_recv() is called again); but the next packet that is treated properly is rejected because by the time __strp_recv() was called again a new skb was read and the length isn't large enough to go all the way into the new packet, so this test fails: } else if (len <= (ssize_t)head->len - skb->len - stm->strp.offset) { /* Length must be into new skb (and also * greater than zero) */ STRP_STATS_INCR(strp->stats.bad_hdr_len); strp_parser_err(strp, -EPROTO, desc); So I need to figure a way to say "call this function again without reading more data" somehow, or make this check more lax e.g. accept any len > 0 after a retry maybe... Removing that branch altogether seems to work at least but I'm not sure we'd want to? (grmbl at this slow VM and strparser not being possible to enable as a module, it takes ages to test) > > With that said, returning 0 from the parse function also raises POLLERR > > on the csock and hangs netparser, so things aren't that simple... > > Can you point to where this is happening. If the parse_msg callback > returns 0 that is suppose to indicate that more bytes are needed. I just blindly returned 0 "from time to time" in the kcm parser function, but looking at above it was failing on the same check. This somewhat makes sense for this one to fail here if a new packet was read, no sane parser function should give a length smaller than what they require to determine the length. Thanks, -- Dominique