Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp570550ybg; Tue, 28 Jul 2020 13:05:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPRkglmNmxFQA/MDSQtrPtAunMgbrqikrXl9fLF3GAfL+f5wZgyiLjE0ZW88ypW1vgIVKd X-Received: by 2002:aa7:c655:: with SMTP id z21mr27811976edr.330.1595966711725; Tue, 28 Jul 2020 13:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595966711; cv=none; d=google.com; s=arc-20160816; b=SlrpfvcEGWQtmPDyOdV6hqpjElGn43HyH5QYZHr0Ms3Qj2u8XFBQ3RGDkhUlghXqyR Aqm1Too+XNjIp849Wvs3RO0gJhjGDH88I2ECJccRxr8ujMvmVUaebZQPpZ/vzrV/5qrJ SldxkwbPbhDMSuf+wtTkIMeaB91mPBT8HL4yDTvTiYjw+TcIB10lLXr/OFRI+Yluqaya va/6RyzqkpWpTAFN0psNXh9z6IOY+HFpFVmODB90z/a9xCLrjyjPiVpPqgDbybOGRgVj fyyl/wdvYdeuzwymk/wpeXfignoIfe6tFsQcN3FYqcltx6GwM5ZCzIGsimSFwwkDiY46 KOJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Lw5Yo6LYMJj0wtDoaefLNGkgc5QTYl1SaK6AazO3v2w=; b=q6irRJfXTh8xAcsYD7uyYQlLx9TgjrJEWZsNNDAF1dyVQF7bLPjX/sS/onReNH6EpL ai/brmztHKlPfkE7nFkbym6WEXbmkEttLJhkApzzYzsCxmeMM15BRRVMdBErGEAsPAZh grZnZkDuaHeefhbBKFReGjBoQBMpxYhMhx4PSAvIElf6lFT6iPnOERKeZPgLeEAbb5ok ynVdqCMvAv0vTrIqwDYePDkEOwAFkZsseqO6dzQu2aKcgdFxy/+STFtw2xu8bsui8wBt T9ASEFYtE9UI5snqd3v31v9t1V8VSPVo89K0yhgAs7i9V7dOSrIUcpfZKiFV72ZOKIky /eRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gq6HFa7X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i23si8254161ejj.446.2020.07.28.13.04.49; Tue, 28 Jul 2020 13:05:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gq6HFa7X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728559AbgG1Tww (ORCPT + 99 others); Tue, 28 Jul 2020 15:52:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728521AbgG1Twv (ORCPT ); Tue, 28 Jul 2020 15:52:51 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 707A3C0619D4 for ; Tue, 28 Jul 2020 12:52:51 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id p3so12680535pgh.3 for ; Tue, 28 Jul 2020 12:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Lw5Yo6LYMJj0wtDoaefLNGkgc5QTYl1SaK6AazO3v2w=; b=gq6HFa7X7QMj2DalmEMErYJdwibaHGKntgGODdJmOjnvl71XNlf89WdFly/p/8zUsD adf6UQmHbEE2XxscjVPyDBuPLHifM78QvAfOfX0iBq+iwH0lfV4yGvEBEVtksCgn6YyM K7ENcyD3xpKYwQsxBe6eWsKzfX5e3ZKuSjRas= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Lw5Yo6LYMJj0wtDoaefLNGkgc5QTYl1SaK6AazO3v2w=; b=dilVqKbuQs5K7qtvcIL+AuPqDldxKzipBxANuMElIPyHCMch2X8+9SjE50Av+uCkyv MyiQx9w7p49kIThgAX6wK5bJHuLEFdTiqwq6l3nMfsk+3ypOw/lWODR7DuKJtxd6Gnyc SeEpEu0sMQpcHLvbJu1gHfm3t/K1W1fQBdApiaEi8uU4HNJ9RgMqlz5BCAnppwLsZ/Fg InbxFIoZ5LWLvWC1jZgdiouzdl9hG7kZQmhjGrhgWZuy6kBFV0/VrNT5mtMfZotNbcO/ BN9BETbZDcBE/Oj8kHNtA5BzX6QsYj3IwrWIVPqPzPrqCeoLb6eXcIv2jcm0LvV5ACqk rpAQ== X-Gm-Message-State: AOAM5301lp4KtbmsSOK7Rk9SVKjG/1w47/zMWSnHSgbemcfnsTlNq3/R l1sLLlUWefV3A3u1nIV8pjZetA== X-Received: by 2002:aa7:93c3:: with SMTP id y3mr25907842pff.206.1595965970613; Tue, 28 Jul 2020 12:52:50 -0700 (PDT) Received: from google.com ([2620:15c:202:1:8edc:d4ff:fe53:350d]) by smtp.gmail.com with ESMTPSA id e8sm8677827pfd.34.2020.07.28.12.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 12:52:49 -0700 (PDT) Date: Tue, 28 Jul 2020 12:52:46 -0700 From: Brian Norris To: Xie He Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-x25@vger.kernel.org, Cong Wang Subject: Re: [PATCH] drivers/net/wan/lapbether: Use needed_headroom instead of hard_header_len Message-ID: <20200728195246.GA482576@google.com> References: <20200726110524.151957-1-xie.he.0141@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200726110524.151957-1-xie.he.0141@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (Reviewing as requested; I'm not familiar with this driver either, or really any WAN driver. It also seems that hard_header_len vs. needed_headroom aren't very well documented, and even I can't guarantee I understand them completely. So take my thoughts with a grain of salt.) Hi, On Sun, Jul 26, 2020 at 04:05:24AM -0700, Xie He wrote: > In net/packet/af_packet.c, the function packet_snd first reserves a > headroom of length (dev->hard_header_len + dev->needed_headroom). > Then if the socket is a SOCK_DGRAM socket, it calls dev_hard_header, > which calls dev->header_ops->create, to create the link layer header. > If the socket is a SOCK_RAW socket, it "un-reserves" a headroom of > length (dev->hard_header_len), and assumes the user to provide the > appropriate link layer header. > > So according to the logic of af_packet.c, dev->hard_header_len should > be the length of the header that would be created by > dev->header_ops->create. I believe I'm with you up to here, but: > However, this driver doesn't provide dev->header_ops, so logically > dev->hard_header_len should be 0. I'm not clear on this part. What's to say you shouldn't be implementing header_ops instead? Note that with WiFi drivers, they're exposing themselves as ARPHRD_ETHER, and only the Ethernet headers are part of the upper "protocol" headers. So my patch deferred to the eth headers. What is the intention with this X25 protocol? I guess the headers added in lapbeth_data_transmit() are supposed to be "invisible", as with this note in af_packet.c? - if device has no dev->hard_header routine, it adds and removes ll header inside itself. In this case ll header is invisible outside of device, but higher levels still should reserve dev->hard_header_len. If that's the case, then yes, I believe this patch should be correct. Brian > So we should use dev->needed_headroom instead of dev->hard_header_len > to request necessary headroom to be allocated. > > Signed-off-by: Xie He