From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxim Mikityanskiy Subject: [PATCH 2/7] net: Introduce parse_protocol header_ops callback Date: Mon, 14 Jan 2019 13:18:58 +0000 Message-ID: <20190114131841.1932-3-maximmi@mellanox.com> References: <20190114131841.1932-1-maximmi@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "netdev@vger.kernel.org" , Eran Ben Elisha , Tariq Toukan , Maxim Mikityanskiy To: "David S. Miller" , Saeed Mahameed , Willem de Bruijn , Jason Wang , Eric Dumazet Return-path: Received: from mail-eopbgr40053.outbound.protection.outlook.com ([40.107.4.53]:20091 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726449AbfANNTD (ORCPT ); Mon, 14 Jan 2019 08:19:03 -0500 In-Reply-To: <20190114131841.1932-1-maximmi@mellanox.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: 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 --- include/linux/netdevice.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 1377d085ef99..44b12430b0a7 100644 --- 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); }; =20 /* These flag bits are private to the generic network queueing @@ -2928,6 +2929,15 @@ static inline int dev_parse_header(const struct sk_b= uff *skb, return dev->header_ops->parse(skb, haddr); } =20 +static inline __be16 dev_parse_header_protocol(const struct sk_buff *skb) +{ + const struct net_device *dev =3D 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) --=20 2.19.1