All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxim Mikityanskiy <maximmi@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>,
	Saeed Mahameed <saeedm@mellanox.com>,
	Willem de Bruijn <willemb@google.com>,
	Jason Wang <jasowang@redhat.com>,
	Eric Dumazet <edumazet@google.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Eran Ben Elisha <eranbe@mellanox.com>,
	Tariq Toukan <tariqt@mellanox.com>,
	Maxim Mikityanskiy <maximmi@mellanox.com>
Subject: [PATCH net-next v2 2/7] net: Introduce parse_protocol header_ops callback
Date: Thu, 21 Feb 2019 12:39:58 +0000	[thread overview]
Message-ID: <20190221123908.7196-3-maximmi@mellanox.com> (raw)
In-Reply-To: <20190221123908.7196-1-maximmi@mellanox.com>

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 <maximmi@mellanox.com>
---
 include/linux/netdevice.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index aab4d9f6613d..6997f62cb6a0 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);
 };
 
 /* These flag bits are private to the generic network queueing
@@ -2939,6 +2940,15 @@ static inline int dev_parse_header(const struct sk_buff *skb,
 	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)
-- 
2.19.1


  parent reply	other threads:[~2019-02-21 12:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21 12:39 [PATCH net-next v2 0/7] AF_PACKET transport_offset fix Maxim Mikityanskiy
2019-02-21 12:39 ` [PATCH net-next v2 1/7] net: Don't set transport offset to invalid value Maxim Mikityanskiy
2019-02-21 17:28   ` Willem de Bruijn
2019-02-22 12:30     ` Maxim Mikityanskiy
2019-02-22 14:16       ` Willem de Bruijn
2019-02-21 12:39 ` Maxim Mikityanskiy [this message]
2019-02-21 12:39 ` [PATCH net-next v2 3/7] net/ethernet: Add parse_protocol header_ops support Maxim Mikityanskiy
2019-02-21 12:40 ` [PATCH net-next v2 4/7] net/packet: Ask driver for protocol if not provided by user Maxim Mikityanskiy
2019-02-21 12:40 ` [PATCH net-next v2 5/7] net/packet: Remove redundant skb->protocol set Maxim Mikityanskiy
2019-02-21 12:40 ` [PATCH net-next v2 6/7] net/mlx5e: Remove the wrong assumption about transport offset Maxim Mikityanskiy
2019-02-21 12:40 ` [PATCH net-next v2 7/7] net/mlx5e: Trust kernel regarding " Maxim Mikityanskiy
2019-02-22 12:55 ` [PATCH net-next] net: Skip GSO length estimation if transport header is not set Maxim Mikityanskiy
2019-02-22 14:19   ` Willem de Bruijn
2019-02-24 20:41   ` David Miller
2019-02-22 14:20 ` [PATCH net-next v2 0/7] AF_PACKET transport_offset fix Willem de Bruijn
2019-02-22 20:55   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190221123908.7196-3-maximmi@mellanox.com \
    --to=maximmi@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eranbe@mellanox.com \
    --cc=jasowang@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.com \
    --cc=tariqt@mellanox.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.