mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
net: Add function for parsing the header length out of linear ethernet frames
This patch updates some of the flow_dissector api so that it can be used to parse the length of ethernet buffers stored in fragments. Most of the changes needed were to __skb_get_poff as it needed to be updated to support sending a linear buffer instead of a skb. I have split __skb_get_poff into two functions, the first is skb_get_poff and it retains the functionality of the original __skb_get_poff. The other function is __skb_get_poff which now works much like __skb_flow_dissect in relation to skb_flow_dissect in that it provides the same functionality but works with just a data buffer and hlen instead of needing an skb. Signed-off-by: Alexander Duyck <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
2c048e6462
commit
56193d1bce
6 changed files with 66 additions and 16 deletions
|
|
@ -145,6 +145,33 @@ int eth_rebuild_header(struct sk_buff *skb)
|
|||
}
|
||||
EXPORT_SYMBOL(eth_rebuild_header);
|
||||
|
||||
/**
|
||||
* eth_get_headlen - determine the the length of header for an ethernet frame
|
||||
* @data: pointer to start of frame
|
||||
* @len: total length of frame
|
||||
*
|
||||
* Make a best effort attempt to pull the length for all of the headers for
|
||||
* a given frame in a linear buffer.
|
||||
*/
|
||||
u32 eth_get_headlen(void *data, unsigned int len)
|
||||
{
|
||||
const struct ethhdr *eth = (const struct ethhdr *)data;
|
||||
struct flow_keys keys;
|
||||
|
||||
/* this should never happen, but better safe than sorry */
|
||||
if (len < sizeof(*eth))
|
||||
return len;
|
||||
|
||||
/* parse any remaining L2/L3 headers, check for L4 */
|
||||
if (!__skb_flow_dissect(NULL, &keys, data,
|
||||
eth->h_proto, sizeof(*eth), len))
|
||||
return max_t(u32, keys.thoff, sizeof(*eth));
|
||||
|
||||
/* parse for any L4 headers */
|
||||
return min_t(u32, __skb_get_poff(NULL, data, &keys, len), len);
|
||||
}
|
||||
EXPORT_SYMBOL(eth_get_headlen);
|
||||
|
||||
/**
|
||||
* eth_type_trans - determine the packet's protocol ID.
|
||||
* @skb: received socket data
|
||||
|
|
|
|||
Loading…
Reference in a new issue