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:

committed by
David S. Miller

parent
62515f95b4
commit
72a338bcc6
@@ -1171,7 +1171,7 @@ void __skb_get_hash(struct sk_buff *skb);
|
||||
u32 __skb_get_hash_symmetric(const struct sk_buff *skb);
|
||||
u32 skb_get_poff(const struct sk_buff *skb);
|
||||
u32 __skb_get_poff(const struct sk_buff *skb, void *data,
|
||||
const struct flow_keys *keys, int hlen);
|
||||
const struct flow_keys_basic *keys, int hlen);
|
||||
__be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
|
||||
void *data, int hlen_proto);
|
||||
|
||||
@@ -1208,13 +1208,14 @@ static inline bool skb_flow_dissect_flow_keys(const struct sk_buff *skb,
|
||||
NULL, 0, 0, 0, flags);
|
||||
}
|
||||
|
||||
static inline bool skb_flow_dissect_flow_keys_buf(struct flow_keys *flow,
|
||||
void *data, __be16 proto,
|
||||
int nhoff, int hlen,
|
||||
unsigned int flags)
|
||||
static inline bool
|
||||
skb_flow_dissect_flow_keys_basic(const struct sk_buff *skb,
|
||||
struct flow_keys_basic *flow, void *data,
|
||||
__be16 proto, int nhoff, int hlen,
|
||||
unsigned int flags)
|
||||
{
|
||||
memset(flow, 0, sizeof(*flow));
|
||||
return __skb_flow_dissect(NULL, &flow_keys_buf_dissector, flow,
|
||||
return __skb_flow_dissect(skb, &flow_keys_basic_dissector, flow,
|
||||
data, proto, nhoff, hlen, flags);
|
||||
}
|
||||
|
||||
@@ -2350,11 +2351,12 @@ static inline void skb_pop_mac_header(struct sk_buff *skb)
|
||||
static inline void skb_probe_transport_header(struct sk_buff *skb,
|
||||
const int offset_hint)
|
||||
{
|
||||
struct flow_keys keys;
|
||||
struct flow_keys_basic keys;
|
||||
|
||||
if (skb_transport_header_was_set(skb))
|
||||
return;
|
||||
else if (skb_flow_dissect_flow_keys(skb, &keys, 0))
|
||||
|
||||
if (skb_flow_dissect_flow_keys_basic(skb, &keys, 0, 0, 0, 0, 0))
|
||||
skb_set_transport_header(skb, keys.control.thoff);
|
||||
else
|
||||
skb_set_transport_header(skb, offset_hint);
|
||||
|
Reference in New Issue
Block a user