Commit e78b2915 authored by Maxim Mikityanskiy's avatar Maxim Mikityanskiy Committed by David S. Miller

net: Introduce parse_protocol header_ops callback

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: default avatarMaxim Mikityanskiy <maximmi@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d2aa125d
...@@ -274,6 +274,7 @@ struct header_ops { ...@@ -274,6 +274,7 @@ struct header_ops {
const struct net_device *dev, const struct net_device *dev,
const unsigned char *haddr); const unsigned char *haddr);
bool (*validate)(const char *ll_header, unsigned int len); 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 /* 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, ...@@ -2939,6 +2940,15 @@ static inline int dev_parse_header(const struct sk_buff *skb,
return dev->header_ops->parse(skb, haddr); 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 */ /* ll_header must have at least hard_header_len allocated */
static inline bool dev_validate_header(const struct net_device *dev, static inline bool dev_validate_header(const struct net_device *dev,
char *ll_header, int len) char *ll_header, int len)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment