mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 17:41:50 +00:00
net: core: rework basic flow dissection helper
When the core networking needs to detect the transport offset in a given packet and parse it explicitly, a full-blown flow_keys struct is used for storage. This patch introduces a smaller keys store, rework the basic flow dissect helper to use it, and apply this new helper where possible - namely in skb_probe_transport_header(). The used flow dissector data structures are renamed to match more closely the new role. The above gives ~50% performance improvement in micro benchmarking around skb_probe_transport_header() and ~30% around eth_get_headlen(), mostly due to the smaller memset. Small, but measurable improvement is measured also in macro benchmarking. v1 -> v2: use the new helper in eth_get_headlen() and skb_get_poff(), as per DaveM suggestion Suggested-by: David Miller <davem@davemloft.net> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
62515f95b4
commit
72a338bcc6
4 changed files with 28 additions and 20 deletions
|
@ -128,15 +128,15 @@ u32 eth_get_headlen(void *data, unsigned int len)
|
|||
{
|
||||
const unsigned int flags = FLOW_DISSECTOR_F_PARSE_1ST_FRAG;
|
||||
const struct ethhdr *eth = (const struct ethhdr *)data;
|
||||
struct flow_keys keys;
|
||||
struct flow_keys_basic keys;
|
||||
|
||||
/* this should never happen, but better safe than sorry */
|
||||
if (unlikely(len < sizeof(*eth)))
|
||||
return len;
|
||||
|
||||
/* parse any remaining L2/L3 headers, check for L4 */
|
||||
if (!skb_flow_dissect_flow_keys_buf(&keys, data, eth->h_proto,
|
||||
sizeof(*eth), len, flags))
|
||||
if (!skb_flow_dissect_flow_keys_basic(NULL, &keys, data, eth->h_proto,
|
||||
sizeof(*eth), len, flags))
|
||||
return max_t(u32, keys.control.thoff, sizeof(*eth));
|
||||
|
||||
/* parse for any L4 headers */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue