Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3509231pxf; Mon, 15 Mar 2021 11:06:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+kFmuyG/bIjLQnXWvC40fjlV1OwzaGHztW9XalLLEqXUSMEyZAbsy3Qo2hAwA+qjL+Gue X-Received: by 2002:a17:906:f9db:: with SMTP id lj27mr25459759ejb.399.1615831600139; Mon, 15 Mar 2021 11:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615831600; cv=none; d=google.com; s=arc-20160816; b=AgcQinVJvX0eA2fzRb0MAFdrls8nLsKFjISWGuyQBFQX2F6o+2LLZ2G5FUg6QDscJ8 xFUwf0vZkL1ze0KdR371MRTP84951CDnBednZHh5NcdX4QCH43ywGP5sGCdo9k0Fpifx csRABHFcIZ4lhMzGKQjz8+LSzDyau9gfH3bvVlcKuSBd17JVAcomwjlYC12HF7BER3rA thtowsOtXWUsv7tS6g+SJB/TmmLPI/jm8kZH1152VLzfEXZaOzsdFq+eT5VXb2vBmxC+ OsDSRkw1VHBBG52iIwD26NHnU99waYQxrY3yZEDtTU5TIfjuFGwCw4L6Vaht3yuEg6Ws rPFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hGfJm1J8YauIsh3ariBkH6F/8Sicd6cuLCJf1Fzixm0=; b=iAddYHRFX0TOAeqKLV/wVrgZd+7p1OMZ9HYx27Mt1xrAbISPdCzqDnxIitfiC22+0q 7tBJi5bbWIOxhe1TTmKfpfAP2JzklLXZpiCT3V40J7YUZbxxYG7du+q++kMt3GCzMTQu enzn1EFdN2zLSCVbiQsmuwberDjD3QVbNSBDDx74Heda9oKf+SKBacZQb9mOZJfCe/0N feEmOiMT+ntjsPY7WJDWd+bIVBiS41Y9rU+sbYP/JF0AY8ex1otgcNmk9WiCgIh4PCGw zqs5pYwI0BoTZsL7VhnbP03s785oDcRbL/i5TIdkrHSyWsSTVyoqWSP3rmFPWrcy6k1v +MCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ig0gW8pj; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr7si11306184ejc.126.2021.03.15.11.06.12; Mon, 15 Mar 2021 11:06:40 -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=@linuxfoundation.org header.s=korg header.b=ig0gW8pj; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235572AbhCOOHx (ORCPT + 99 others); Mon, 15 Mar 2021 10:07:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:36788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232093AbhCON6H (ORCPT ); Mon, 15 Mar 2021 09:58:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BBC9C64EF9; Mon, 15 Mar 2021 13:58:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816684; bh=iDE8WNAc2YpEAw+DCtortrJQ9uhD2hnReSWZ40rFk4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ig0gW8pjj99v9ifzGoOxqtBDGCxTZzmBErolHP+sbjTOkH5Bh7qctFH31NQ+WyKzS kGvyc76nIsAjyG1MYljA45mr/FdmsqcgCO+Dz10i11hhtSIbcgC+KdKLkkb5lyHPLQ 8byyGiADi/dQP0tc3K6wcIdWdyTWCw/+UM5NbFh8= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Mikityanskiy , "David S. Miller" Subject: [PATCH 4.19 005/120] net: Introduce parse_protocol header_ops callback Date: Mon, 15 Mar 2021 14:55:56 +0100 Message-Id: <20210315135720.187858706@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135720.002213995@linuxfoundation.org> References: <20210315135720.002213995@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Maxim Mikityanskiy commit e78b2915517e8fcadb1bc130ad6aeac7099e510c upstream. Introduce a new optional header_ops callback called parse_protocol and a wrapper function dev_parse_header_protocol, similar to dev_parse_header. The new callback's purpose is to extract the protocol number from the L2 header, the format of which is known to the driver, but not to the upper layers of the stack. Signed-off-by: Maxim Mikityanskiy Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/linux/netdevice.h | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -274,6 +274,7 @@ struct header_ops { const struct net_device *dev, const unsigned char *haddr); bool (*validate)(const char *ll_header, unsigned int len); + __be16 (*parse_protocol)(const struct sk_buff *skb); }; /* These flag bits are private to the generic network queueing @@ -2895,6 +2896,15 @@ static inline int dev_parse_header(const return dev->header_ops->parse(skb, haddr); } +static inline __be16 dev_parse_header_protocol(const struct sk_buff *skb) +{ + const struct net_device *dev = skb->dev; + + if (!dev->header_ops || !dev->header_ops->parse_protocol) + return 0; + return dev->header_ops->parse_protocol(skb); +} + /* ll_header must have at least hard_header_len allocated */ static inline bool dev_validate_header(const struct net_device *dev, char *ll_header, int len)