Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4695029imm; Mon, 17 Sep 2018 20:00:29 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ5XNcmDEI0eQdHiWaQvZGilRkgqyrv7yt6/y15lU4CPQbU7BbA+Z+5iYPnQQ1IrZUdO5u8 X-Received: by 2002:a62:8208:: with SMTP id w8-v6mr28208999pfd.215.1537239629540; Mon, 17 Sep 2018 20:00:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537239629; cv=none; d=google.com; s=arc-20160816; b=goq5uhq48g9AS2z1xXsH3o+9sYlVvTxaIz4FsGedWm7XREP1N5c1hocE7xZkTtNE8H BGtn9aHKypfRI3duv+cQLNgVbL1nVGjfJKixCJ813AgqbBKxvbrATytl1NPgcmTzejDm 2aetUCb16bKAvAU4nCehXBupMb+qZ2l3csEXzhe+nBe6Gh3rUtKjzuYECpxGoFYmMVUo KuATGN09fX42lMq5gX2I6pFh9gspXpqAmsJv8as9/T2L5V8z4gRY0HqzpN2K07V7wwPb FAxwSB+tK7CTWimImKbWkaNbNlRDC9mnQCRkk3OrEEx3jFgbaegdOikifdPf2M463O1W ljyQ== 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=PF19UQea34j4T8nShLYAnrf0sl9KlP/l/5nyt/Fw7Mg=; b=MGG5Fq0KnJwEXEqxzOkuipXzFT0Hgx9RICaBZIK8/q9tAuJ/dR/2UxBQi60dSezXr6 Pmh4FapjRbbxF+3UK4b2M4FlxTPLTtCGoa3s5cdEcmszTEY9QXSeEBSixxMe+5Irt28Y u/iTx1D2hY2BLyL6mRrPKPrRqneyUfR2pEqL6+v4cA9LjqNCHotbiPRzryEkIvHHgrO8 5uMLBk/mXfh3huzV2fQQjr4JaiBdkiy792znMk/CzSXJOP9MoT4fi90YRijhKgH6z+wg hCOmrqCvdJ98qpcLa3UlUbAb/quqibUxQ/GcBE5LBIPxmMONbcyexC6llrXPqj7lGX03 MTUg== 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 u134-v6si18654789pfc.244.2018.09.17.20.00.12; Mon, 17 Sep 2018 20:00:29 -0700 (PDT) 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 S1728970AbeIRI3U (ORCPT + 99 others); Tue, 18 Sep 2018 04:29:20 -0400 Received: from nautica.notk.org ([91.121.71.147]:60411 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725928AbeIRI3U (ORCPT ); Tue, 18 Sep 2018 04:29:20 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 885E2C009; Tue, 18 Sep 2018 04:58:52 +0200 (CEST) Date: Tue, 18 Sep 2018 04:58:37 +0200 From: Dominique Martinet To: David Miller Cc: doronrk@fb.com, tom@quantonium.net, davejwatson@fb.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] kcm: remove any offset before parsing messages Message-ID: <20180918025837.GA3548@nautica> References: <20180918015723.GA26300@nautica> <20180917.194059.1970452340378032090.davem@davemloft.net> <20180918024536.GA2061@nautica> <20180917.195150.315319338322641005.davem@davemloft.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180917.195150.315319338322641005.davem@davemloft.net> 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 David Miller wrote on Mon, Sep 17, 2018: > > No, they can see it, so it's possible to make a KCM program that works > > right now if you are careful (I'm not sure why the offset within bpf is > > different from the offset in the kernel though, it looks like the bpf > > program skips the qos part of the control buffer) > > What helper is used in the BPF program to get this offset value? > > (also good info to add to the commit message) Dave defined one himself ; for a simple protocol where the offset is in the first four bytes of the message. The whole bpf program could look like this: ------ struct kcm_rx_msg { int full_len; int offset; }; static inline struct kcm_rx_msg *kcm_rx_msg(struct __sk_buff *skb) { return (struct kcm_rx_msg *)skb->cb; } int decode_framing(struct __sk_buff *skb) { return load_word(skb, kcm_rx_msg(skb)->offset); } ------ If we go towards documenting it, adding a helper would be useful yes; buf if we pull that becomes unnecessary. (I'll add the example program in the commit message anyway at your suggestion) -- Dominique Martinet